TypeConstraint Function

Block events that do not match the specified names or data.

This constraint is created implicitly if you define the .events property on a metric.

{
  name: 'Logged in',
  constraints: [
    TypeConstraint([
      'logged-in'
    ])
  ]
}

Signature

TypeConstraint(
  events: Array.<String | TypeConstraint~EventChecker>
)
-> Constraint

Parameters (1)

events
Array.<String | TypeConstraint~EventChecker>

Passing a string for an event name ignores the event data. If you want to filter by data or context, implement the structure described below.

Type Definitions

    EventChecker

    A specification for both event name and the data (or context) it is triggered with.

    {
      name: 'Logged in (mobile)',
      constraints: [
        TypeConstraint([
          { name: 'logged-in', when: data => data.isUsingMobile }
        ])
      ]
    }

    Properties

    name: String

    The name of the event.

    data: (Object, Object) -> Boolean

    A predicate function to check if the data is OK. Arguments are [data, context].