Expand all

mw.testKitchen.StubbedExperimentInterface

Properties

eventCount :numberconstant #

The number of events that have been sent for the experiment.

Type:

  • number
Source:
The number of events that have been sent for the experiment.

events :Array.<mw.testKitchen.TestEvent>constant #

The events that have been sent for the experiment.

Type:

Source:
The events that have been sent for the experiment.

Methods

getAssignedGroup() → {string|null} #

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

Returns:

Type
string | null
Inherited from:
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
Inherited from:
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
Inherited from:
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:
Source:
Sends an analytics event.

sendExposure() #

Sends an exposure event for this experiment with mw.testKitchen.ExperimentInterface#send.

The exposure event will always have:

  1. action=experiment_exposure
  2. The following contextual attributes:
    • agent_geo_ip_country
    • performer_is_logged_in
    • performer_is_temp
    • performer_is_bot
    • performer_edit_count
    • mediawiki_database
Inherited from:
Source:
Sends an exposure event for this experiment with mw.testKitchen.ExperimentInterface#send.

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

Inherited from:
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
Inherited from:
Source:
Uses the generic instrumentation to send analytics events for this experiment.