Methods
getAssignedGroup() → {string|null}
#
null}
#
Gets the group assigned to the current user.
- Source:
Returns:
- Type
-
string
|
null
isAssignedGroup(…groups) → {boolean}
#
Gets whether the group assigned to the current user is one of the given groups.
Example
const e = mw.xLab.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 |
- Source:
- See:
Returns:
- Type
- boolean
send(action, [interactionData])
#
Sends an analytics event related to the experiment.
If the user is enrolled in the experiment, then the event is decorated with
experiment-related data and sent. The experiment-related data are specified and documented in
the fragment/analytics/product_metrics/experiment schema fragment.
By default, the analytics event will be sent to the product_metrics.web_base stream and be
validated with the /analytics/product_metrics/web/base/1.5.0 schema. The stream and schema
can be overridden with Experiment#setStream and Experiment#setSchema,
respectively.
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 |
- Source:
- See:
setSchema(schemaID) → {Experiment}
#
Sets the ID of the schema used to validate analytics events sent with
Experiment#send.
This method is chainable.
Parameters:
| Name | Type | Description |
|---|---|---|
schemaID |
string |
- Source:
Returns:
- Type
- Experiment
Sets the ID of the schema used to validate analytics events sent with
Experiment#send.
setStream(streamName) → {Experiment}
#
Sets the stream to send analytics events to with Experiment#send.
This method is chainable.
Parameters:
| Name | Type | Description |
|---|---|---|
streamName |
string |
- Source:
Returns:
The instance on which this method was called
- Type
- Experiment
Experiment#send.
submitInteraction(action, interactionData)package
#
Submits an event related to this experiment.
This method makes Experiment compatible with the click-through rate implementation in the
ext.wikimediaEvents.xLab ResourceLoader module by proxying to Experiment#send.
Calling this outside of xLab is not supported.
Parameters:
| Name | Type | Description |
|---|---|---|
action |
string | The action related to the submitted event |
interactionData |
Object | Additional data |
- Source:
- See: