Page MenuHomePhabricator

JS xLab SDK: Implement the JS API we need for feature code to get the experiment and the assigned group
Closed, ResolvedPublic8 Estimated Story Points

Description

Description

This task is a proposal to create a new mw.xLab module in the MetricsPlatform extension to start working there on the new JS xLab API following the current approach we prepared for the feature code to deal with the experiment enrollment configuration.

We propose the following:

  • Create a module called mw.xLab where the needed API will be included for feature code to get experiment details for the current user
  • There will be a getExperiment( EXPERIMENT_NAME ) function to get the enrollment details (the assigned group) for the experiment whose name if passed as parameter as an Experiment object
  • The proposed API for the Experiment class is the following:
namespace mw.xLab {
  interface Experiment {

    /**
     * Gets whether the EESA enrolled the current user in this experiment.
     *
     * @private
     */
    isEnrolled(): boolean;

    /**
     * Gets the group the current user was assigned by the EESA when they were
     * enrolled in this experiment.
     */
    getAssignedGroup(): string|null;

    /**
     * Sends an interaction event associated with this experiment if the EESA
     * enrolled the current user in this experiment.
     */
     send( action: string, interactionData: ?Object ): void;
  }
}

Acceptance Criteria

  • A new module, mw.xLab has been created
  • The new module contains the required API:
    • const experiment = getExperiment( EXPERIMENT_NAME)
    • experiment.isEnrolled() (private)
    • experiment.getAssignedGroup()
    • experiment.send( action, interactionData )
    • When assigned was arrived at by way of a CDN experiment, set the subject_id field to the string value of awaiting
NOTE: we will also consider adding mw.xLab.getAllExperiments()

Event Timeline

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

[mediawiki/extensions/MetricsPlatform@master] Added support for groups (removed for features) and the new API for the JS xLab SDK

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

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

[mediawiki/extensions/MetricsPlatform@master] JS xLab SDK: Adding an API for the feature code to manage experiment enrollment

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

The task is currently blocked by T390303: Update CI for MetricsPlatform extension where we are already pushed a patch to update the dependencies for the extension regarding the CI pipeline. At this time CI is failing because EventLogging is a new dependency that wasn't configured as such yet.

T390303: Update CI for MetricsPlatform extension has been already merged and https://gerrit.wikimedia.org/r/1131969 is ready for review.

Notice that the stretch goal (Experiment extends Instrument) has not been implemented for now. We'll create a follow up ticket to do it

Change #1131969 merged by jenkins-bot:

[mediawiki/extensions/MetricsPlatform@master] JS xLab SDK: Adding an API for the feature code to manage experiment enrollment

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

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

[mediawiki/extensions/MetricsPlatform@master] JS xLab SDK: Several fixes:

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

@Sfaci, @cjming: I've left some comments on https://gerrit.wikimedia.org/r/c/mediawiki/extensions/MetricsPlatform/+/1131969 that should be addressed before calling this task Done™

@phuedx I have pushed a follow up patch to fix the issues you mentioned there: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/MetricsPlatform/+/1133386

Change #1133386 merged by jenkins-bot:

[mediawiki/extensions/MetricsPlatform@master] JS xLab SDK: Several fixes:

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

@Sfaci: As discussed and per our notes in https://etherpad.wikimedia.org/p/go, we need to:

  1. Make Experiment#isEnrolled() private
  2. Make Experiment#submitInteraction() use Experiment#isEnrolled()
  3. Make Experiment#submitInteraction() set _all_ properties on the experiment object
  4. Rename Experiment#submitInteraction() to #send()
phuedx updated the task description. (Show Details)
Milimetric set the point value for this task to 8.

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

[mediawiki/extensions/MetricsPlatform@master] JS xLab SDK: Several fixes/improvements for the Experiment class

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

Change #1136470 merged by jenkins-bot:

[mediawiki/extensions/MetricsPlatform@master] JS xLab SDK: Several fixes/improvements for the Experiment class

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

Change #1131433 abandoned by Santiago Faci:

[mediawiki/extensions/MetricsPlatform@master] DNM: Added support for groups (removed for features) and the new API for the JS xLab SDK

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

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

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

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

Change #1136982 merged by jenkins-bot:

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

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

phuedx updated the task description. (Show Details)