Expand all

mw.testKitchen.Experiment

Methods

getAssignedGroup() → {string|null} #

Gets the group assigned to the user when they were enrolled in the experiment.

Returns:

Type
string | null
Implements:
Source:
Gets the group assigned to the user when they were enrolled in the experiment.

getStartDate() → {Date|null} #

Gets the UTC start date of the experiment.

Returns:

If the experiment is configured, the UTC start date of the experiment; null otherwise

Type
Date | null
Implements:
Source:
Gets the UTC start date of the experiment.

isAssignedGroup(…groups) → {boolean} #

Gets whether the group assigned to the current user is one of the given groups.

Example

const e = mw.testKitchen.getExperiment( 'my-awesome-experiment' );

// Is the current user assigned A or B for the "My Awesome Experiment" experiment?
if ( e.isAssignedGroup( 'A', 'B' ) {
  // ...
}

Parameters:

Name Type Attributes Description
groups string repeatable

Returns:

Type
boolean
Implements:
Source:
See:
Gets whether the group assigned to the current user is one of the given groups.

send(action, [interactionData], [contextualAttributes]) #

Sends an analytics event.

If the event sender is an experiment, then the event is decorated with experiment-related data before it is sent. The experiment-related data are specified and documented in the fragment/analytics/product_metrics/experiment schema fragment.

If per-event contextual attributes are passed via the contextualAttributes param, then they are added to the event before it is sent.

Parameters:

Name Type Attributes Description
action string

The action that the user enrolled in this experiment took, e.g. "hover", "click"

interactionData Object optional

Additional data about the action that the user enrolled in the experiment took

contextualAttributes Array.<string> optional

Per-event contextual attributes

Inherited from:
Implements:
Source:
Sends an analytics event.

sendExposure() #

Logs an exposure event with 2-tier deduplication.

Implements:
Source:
Logs an exposure event with 2-tier deduplication.

submitInteraction(action, [interactionData], [contextualAttributes])package #

Submits an event related to this experiment.

This method makes Experiment compatible with the click-through rate implementation in the ext.wikimediaEvents.testKitchen ResourceLoader module by proxying to mw.testKitchen.ExperimentInterface#send. Calling this outside of Test Kitchen is not supported.

If per-event contextual attributes are passed via the contextualAttributes param, then they are added to the event before it is sent.

Parameters:

Name Type Attributes Description
action string

The action related to the submitted event

interactionData Object optional

Additional data

contextualAttributes Array.<string> optional

Per-event contextual attributes

Implements:
Source:
See:
Submits an event related to this experiment.

use(instrumentation) → {mw.testKitchen.ExperimentInterface} #

Uses the generic instrumentation to send analytics events for this experiment.

This method is chainable.

Parameters:

Name Type Description
instrumentation mw.testKitchen.GenericInstrumentation

Returns:

Type
mw.testKitchen.ExperimentInterface
Implements:
Source:
Uses the generic instrumentation to send analytics events for this experiment.