Page MenuHomePhabricator

xLab JS SDK: Adapt Experiment to ClickThroughRateInstrument
Closed, ResolvedPublic2 Estimated Story Points

Description

Background

How can the ClickThroughRateInstrument.js integrate with Experiment.js?
If Experiment has its own method send() for submitting events and CTR instrument uses submitInteraction(), including when you pass an Instrument to it – which Experiment does not appear to be a child of – so I don't think it's possible to write:

const experiment = mw.xLab.getExperiment( 'my_experiment' );
if ( experiment.isEnrolled() ) {
   const { ClickThroughRateInstrument } = require( 'ext.wikimediaEvents.metricsPlatform' );
   const ctrInstrument = ClickThroughRateInstrument.start(
       '[data-pinnable-element-id="vector-main-menu"] .vector-pinnable-header-unpin-button',
       'pinnable-header.vector-main-menu.unpin',
       experiment
   );
}

Am I missing something here?

Good catch.
We sorta lost track of this thread in between trying to deliver on SDS 2.4 (.11) and starting to discuss a vision for instrumentation 😅
In the interest of keeping the work we've already done/remaining consistent with what we've already shown other teams, I suggest that we take the shortest possible step of adding an Experiment#submitInteraction() method that:

  • Proxies to Experiment#send()`
  • Is documented as internal and unstable

In the long run though, I think that Click-through Rate Instrument should be moved into the MetricsPlatform extension and that WikimediaEvents should come to depend on that. I'm a little hazy on the path for this though – it might be entangled with Click-through Rate Instrument V2

This task covers the shortest possible step to make Experiment work with ClickThroughRateInstrument described above.

AC

  • Add Experiment#submitInteraction() and make it proxy to #send()
  • Document Experiment#submitInteraction() as internal and unstable
  • Bump the default schema version to 1.4.2

Event Timeline

phuedx set the point value for this task to 2.

@cjming: One more criterion for acceptance criteria:

- const SCHEMA_ID = '/analytics/product_metrics/web/base/1.3.0';
+ const SCHEMA_ID = '/analytics/product_metrics/web/base/1.4.2';

Change #1148970 had a related patch set uploaded (by Clare Ming; author: Clare Ming):

[mediawiki/extensions/MetricsPlatform@master] Add proxy submit method for JS experiments

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

Change #1148983 had a related patch set uploaded (by Clare Ming; author: Clare Ming):

[mediawiki/extensions/WikimediaEvents@master] Bump web base schema version for experiments

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

Change #1148983 merged by jenkins-bot:

[mediawiki/extensions/WikimediaEvents@master] Bump web base schema version for experiments

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

Change #1148970 merged by jenkins-bot:

[mediawiki/extensions/MetricsPlatform@master] Add proxy submit method for JS experiments

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