Reading depth hook should send additional sampling bucket parameter
The hook that enables the Reading depth test should send an additional paramter that specifies which test bucket the hook being is calling from. Bug: T191532 Change-Id: Ifd9f43220c476ece8a0c0cee46b62b58a717c616
This commit is contained in:
parent
b340e04a22
commit
e27cbf2a49
10
README.md
10
README.md
|
@ -122,11 +122,11 @@ Group membership can be debugged from the console via:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const AB = mw.mobileFrontend.require('skins.minerva.scripts/AB')
|
const AB = mw.mobileFrontend.require('skins.minerva.scripts/AB')
|
||||||
new AB(
|
new AB({
|
||||||
'WME.PageIssuesAB',
|
testName: 'WME.PageIssuesAB',
|
||||||
mw.config.get( 'wgMinervaABSamplingRate', 0 ),
|
samplingRate: mw.config.get( 'wgMinervaABSamplingRate', 0 ),
|
||||||
mw.user.sessionId()
|
sessionId: mw.user.sessionId()
|
||||||
).getBucket()
|
}).getBucket()
|
||||||
```
|
```
|
||||||
|
|
||||||
And since session ID is an input in calculating the group, reassignment occurs
|
And since session ID is an input in calculating the group, reassignment occurs
|
||||||
|
|
|
@ -11,14 +11,21 @@
|
||||||
/**
|
/**
|
||||||
* Buckets users based on params and exposes an `isEnabled` and `getBucket` method.
|
* Buckets users based on params and exposes an `isEnabled` and `getBucket` method.
|
||||||
*
|
*
|
||||||
* @param {string} testName name of the AB-test.
|
* @param {Object} config configuration object for AB test.
|
||||||
* @param {number} samplingRate sampling rate for the AB-test.
|
* @param {string} config.testName
|
||||||
* @param {number} sessionId session ID for user bucketing.
|
* @param {number} config.samplingRate sampling rate for the AB-test.
|
||||||
|
* @param {number} config.sessionId session ID for user bucketing
|
||||||
|
* @param {function} [config.onABStart] function that triggers event-logging when user is either
|
||||||
|
* in bucket A or B.
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function AB( testName, samplingRate, sessionId ) {
|
function AB( config ) {
|
||||||
|
|
||||||
var CONTROL_BUCKET = 'control',
|
var CONTROL_BUCKET = 'control',
|
||||||
|
testName = config.testName,
|
||||||
|
samplingRate = config.samplingRate,
|
||||||
|
sessionId = config.sessionId,
|
||||||
|
onABStart = config.onABStart || function () {},
|
||||||
test = {
|
test = {
|
||||||
name: testName,
|
name: testName,
|
||||||
enabled: !!samplingRate,
|
enabled: !!samplingRate,
|
||||||
|
@ -28,13 +35,6 @@
|
||||||
B: samplingRate / 2
|
B: samplingRate / 2
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
* Starts the AB-test and enters the user into the Reading Depth test.
|
|
||||||
*/
|
|
||||||
function startABTest() {
|
|
||||||
// See: https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/WikimediaEvents/+/437686/
|
|
||||||
mw.track( 'wikimedia.event.ReadingDepthSchema.enable' );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the users AB-test bucket
|
* Gets the users AB-test bucket
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
*/
|
*/
|
||||||
function init() {
|
function init() {
|
||||||
if ( isEnabled() ) {
|
if ( isEnabled() ) {
|
||||||
startABTest();
|
onABStart( getBucket() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,20 @@
|
||||||
NS_MAIN = 0,
|
NS_MAIN = 0,
|
||||||
NS_TALK = 1,
|
NS_TALK = 1,
|
||||||
NS_CATEGORY = 14,
|
NS_CATEGORY = 14,
|
||||||
isInGroupB = new AB(
|
isInGroupB = new AB( {
|
||||||
'WME.PageIssuesAB',
|
testName: 'WME.PageIssuesAB',
|
||||||
mw.config.get( 'wgMinervaABSamplingRate', 0 ),
|
samplingRate: mw.config.get( 'wgMinervaABSamplingRate', 0 ),
|
||||||
mw.user.sessionId()
|
sessionId: mw.user.sessionId(),
|
||||||
).getBucket() === 'B',
|
onABStart: function ( bucket ) {
|
||||||
|
// See: https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/WikimediaEvents/+/437686/
|
||||||
|
var READING_DEPTH_BUCKET_KEYS = {
|
||||||
|
A: 'page-issues-a_sample',
|
||||||
|
B: 'page-issues-b_sample'
|
||||||
|
},
|
||||||
|
readingDepthBucket = READING_DEPTH_BUCKET_KEYS[ bucket ];
|
||||||
|
mw.track( 'wikimedia.event.ReadingDepthSchema.enable', readingDepthBucket );
|
||||||
|
}
|
||||||
|
} ).getBucket() === 'B',
|
||||||
Icon = M.require( 'mobile.startup/Icon' );
|
Icon = M.require( 'mobile.startup/Icon' );
|
||||||
|
|
||||||
( function () {
|
( function () {
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
( function ( M ) {
|
( function ( M ) {
|
||||||
|
|
||||||
var AB = M.require( 'skins.minerva.scripts/AB' ),
|
var AB = M.require( 'skins.minerva.scripts/AB' ),
|
||||||
aBName = 'WME.MinervaABTest',
|
util = M.require( 'mobile.startup/util' ),
|
||||||
samplingRate = 0.5;
|
defaultConfig = {
|
||||||
|
testName: 'WME.MinervaABTest',
|
||||||
|
samplingRate: 0.5,
|
||||||
|
sessionId: mw.user.generateRandomSessionId()
|
||||||
|
};
|
||||||
|
|
||||||
QUnit.module( 'Minerva AB-test' );
|
QUnit.module( 'Minerva AB-test' );
|
||||||
|
|
||||||
|
@ -14,10 +18,12 @@
|
||||||
},
|
},
|
||||||
maxUsers = 1000,
|
maxUsers = 1000,
|
||||||
bucketingTest,
|
bucketingTest,
|
||||||
|
config,
|
||||||
i;
|
i;
|
||||||
|
|
||||||
for ( i = 0; i < maxUsers; i++ ) {
|
for ( i = 0; i < maxUsers; i++ ) {
|
||||||
bucketingTest = new AB( aBName, samplingRate, mw.user.generateRandomSessionId() );
|
config = util.extend( {}, defaultConfig, { sessionId: mw.user.generateRandomSessionId() } );
|
||||||
|
bucketingTest = new AB( config );
|
||||||
userBuckets[ bucketingTest.getBucket() ] += 1;
|
userBuckets[ bucketingTest.getBucket() ] += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue