mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-17 20:41:32 +00:00
e4e9bb3bd6
Introduce PopupsAnonsExperimentalGroupSize config variable. This defines a population size who will be subject to experimentation. If the group size is undefined or 0 (default) and PopupsBetaFeature is false (default value) Popups will be enabled for everyone. If it is any other value, half that group will see page previews. Drop the config variable PopupsSchemaSamplingRate - we will now only EventLog when an experiment is occuring. This means we can simplify the MWEventLogger class as shouldLog will always be truthy. Given server side eventlogging is only used for preference changes traffic should be low and not need sampling. Introduce getUserBucket which determines whether a user is in a bucket on, off or control based on the value of PopupsAnonsExperimentalGroupSize. Add tests showing how these buckets are calculated. Caution: A kill switch wgPopupsEventLogging is provided for safety. It defaults to false. Before merging, please check if any config changes are necessary. Bug: T171853 Change-Id: If2a0c5fceae78262c44cb522af38a925cc5919d3
67 lines
1.4 KiB
JavaScript
67 lines
1.4 KiB
JavaScript
/**
|
|
* Creates a **minimal** stub that can be used in place of an `mw.User`
|
|
* instance.
|
|
*
|
|
* @param {boolean} isAnon The return value of the `#isAnon`.
|
|
* @return {Object}
|
|
*/
|
|
export function createStubUser( isAnon ) {
|
|
return {
|
|
isAnon: function () {
|
|
return isAnon;
|
|
},
|
|
sessionId: function () {
|
|
return '0123456789';
|
|
}
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a **minimal** stub that can be used in place of an `mw.Map`
|
|
* instance.
|
|
*
|
|
* @return {mw.Map}
|
|
*/
|
|
export function createStubMap() {
|
|
var m = new Map(); /* global Map */
|
|
m.get = function ( key, fallback ) {
|
|
fallback = arguments.length > 1 ? fallback : null;
|
|
if ( typeof key === 'string' ) {
|
|
return m.has( key ) ? Map.prototype.get.call( m, key ) : fallback;
|
|
}
|
|
// Invalid selection key
|
|
return null;
|
|
};
|
|
return m;
|
|
}
|
|
|
|
/**
|
|
* Creates a stub that can be used as a replacement to mw.experiements
|
|
* @param {string} bucket getBucket will respond with this bucket.
|
|
* @return {object}
|
|
*/
|
|
export function createStubExperiments( bucket ) {
|
|
return {
|
|
getBucket: function () {
|
|
return bucket;
|
|
}
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a **minimal** stub that can be used in place of an instance of
|
|
* `mw.Title`.
|
|
*
|
|
* @param {Number} namespace
|
|
* @param {String} prefixedDb, e.g. Foo, or File:Bar.jpg
|
|
* @return {Object}
|
|
*/
|
|
export function createStubTitle( namespace, prefixedDb ) {
|
|
return {
|
|
namespace: namespace,
|
|
getPrefixedDb: function () {
|
|
return prefixedDb;
|
|
}
|
|
};
|
|
}
|