Hygiene: remove unused function AB.onABStart()

Callback usage was removed in I67fb6e448f6ecc97c89c1187e491ee05f7a312ef
so this function may be removed.

Bug: T191532
Change-Id: I88f0d6740c9e9615faba2e3c60772269c705f43e
This commit is contained in:
Stephen Niedzielski 2018-08-08 10:37:42 -05:00 committed by Jdlrobson
parent f67c410859
commit 061d155303
1 changed files with 7 additions and 31 deletions

View File

@ -1,31 +1,23 @@
/* /*
* Bucketing wrapper for creating AB-tests. * Bucketing wrapper for creating AB-tests.
* *
* Given a test name, sampling rate, and session ID, provides a class * Given a test name, sampling rate, and session ID, provides a class that buckets users into
* that buckets users into predefined bucket ("control", "A", "B") and * predefined bucket ("control", "A", "B") and starts an AB-test.
* starts an AB-test.
*/ */
( function ( M, mwExperiments ) {
( function ( mw, M, mwExperiments ) {
/** /**
* 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 {Object} config Configuration object for AB test.
* @param {Object} config configuration object for AB test.
* @param {string} config.testName * @param {string} config.testName
* @param {number} config.samplingRate sampling rate for the AB-test. * @param {number} config.samplingRate Sampling rate for the AB-test.
* @param {number} config.sessionId session ID for user bucketing * @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( config ) { function AB( config ) {
var CONTROL_BUCKET = 'control', var CONTROL_BUCKET = 'control',
testName = config.testName, testName = config.testName,
samplingRate = config.samplingRate, samplingRate = config.samplingRate,
sessionId = config.sessionId, sessionId = config.sessionId,
onABStart = config.onABStart || function () {},
test = { test = {
name: testName, name: testName,
enabled: !!samplingRate, enabled: !!samplingRate,
@ -38,7 +30,6 @@
/** /**
* Gets the users AB-test bucket * Gets the users AB-test bucket
*
* @return {string} AB-test bucket, CONTROL_BUCKET by default, "A" or "B" buckets otherwise. * @return {string} AB-test bucket, CONTROL_BUCKET by default, "A" or "B" buckets otherwise.
*/ */
function getBucket() { function getBucket() {
@ -47,26 +38,12 @@
/** /**
* Checks whether or not a user is in the AB-test, * Checks whether or not a user is in the AB-test,
*
* @return {boolean} * @return {boolean}
*/ */
function isEnabled() { function isEnabled() {
return getBucket() !== CONTROL_BUCKET; return getBucket() !== CONTROL_BUCKET;
} }
/**
* Initiates the AB-test.
*
* return {void}
*/
function init() {
if ( isEnabled() ) {
onABStart( getBucket() );
}
}
init();
return { return {
getBucket: getBucket, getBucket: getBucket,
isEnabled: isEnabled isEnabled: isEnabled
@ -74,5 +51,4 @@
} }
M.define( 'skins.minerva.scripts/AB', AB ); M.define( 'skins.minerva.scripts/AB', AB );
}( mw.mobileFrontend, mw.experiments ) );
}( mw, mw.mobileFrontend, mw.experiments ) );