Page MenuHomePhabricator

xLab: Include experiment enrollment in the JS client library
Closed, ResolvedPublic5 Estimated Story Points

Description

Description

With the proposed updates to the experiment membership tracking schema (fragment proposed in T389995), we will need to update the javascript client library to supplements events i.e. be able to read and populate fields for the new experiment data object (to supercede the previously defined experiments data object)

Proposed payload to be added to all events:

experiment: {
  enrolled: "2025-hoverlinks-blue-3",
  assigned: "a_group_name",
  subject_id: "0000001badb00200000ff1ce1badb002000000ff1ce0000000ff1ce0000000",
  sampling_unit: "mw-user",
  other_assigned: {
    "experiment_name_2": "control",
    "experiment_name_3": "any_group"
  }
}

Additionally, the xLab SDK will house the experiment manager API such that all current experiment-related methods will be removed from the EventLogging ResourceLoader module and moved into a new xLab ResourceLoader module (T390089: JS xLab SDK: Implement the JS API we need for feature code to get the experiment and the assigned group).

We can also take the opportunity to improve the way we are checking if the schema title supports experimentation. This feature was added for the web base schema 1.3.0 and, at this time, we are just checking the exact name and the version to be sure that the needed experiments fragment schema is there to fill the enrollment details. We should find a better way. In fact, the web base schema has been already updated a couple of times and the current way of doing that won't work properly.
We could say something like the following:

if ( schemaID === '/analytics/product_metrics/web/base' && version(schemaID) >= 1.3.0 )

Acceptance Criteria

  • Remove mw.eventLog.isCurrentUserEnrolled()
  • Update mw.eventLog.getCurrentUserExperiments() to read experiment details from wgMetricsPlatformUserExperiments and prepare them according to the experiment schema fragment
  • Decorate events with enrolled, assigned, subject_id, sampling_unit keys for experiment-related events, and other_assigned for all events as long as coordinator is set to xlab
    • Leave enrollment details as they are when coordinator is previously set to custom. sampling_unit, subject_ids and other_assigned won't be filled and we will assume that enrolled and assigned were filled by the custom coordinator
    • coordinator will be set to forced when the assigned group for the enrolled experiment has been overriden
  • The way we check if the schema title supports experimentation has been improved/updated

Details

TitleReferenceAuthorSource BranchDest Branch
JS client library updates to simplify the submitInteraction functionrepos/data-engineering/metrics-platform!84sfaciadd-enrollment-detailsmain
Customize query in GitLab

Event Timeline

cjming updated the task description. (Show Details)
Sfaci updated the task description. (Show Details)
Sfaci updated the task description. (Show Details)

The change related to the JS client library is ready for review: https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform/-/merge_requests/84

That patch also covers the part we had to implement for T390308: [Community Updates module] Migrate experiments fragment

Milimetric set the point value for this task to 5.Apr 18 2025, 9:21 PM

Change #1137836 had a related patch set uploaded (by Santiago Faci; author: Santiago Faci):

[mediawiki/extensions/MetricsPlatform@master] JS xLab SDK: A couple of updates

https://gerrit.wikimedia.org/r/1137836

Change #1137836 merged by jenkins-bot:

[mediawiki/extensions/MetricsPlatform@master] JS xLab SDK: A couple of updates

https://gerrit.wikimedia.org/r/1137836