Merge "Improve DiscussionTools a/b test bucket logging"

This commit is contained in:
jenkins-bot 2022-02-12 01:38:32 +00:00 committed by Gerrit Code Review
commit 1418002309

View file

@ -48,6 +48,25 @@
};
}
function addABTestData( data ) {
// DiscussionTools New Topic A/B test for logged out users
if ( !mw.config.get( 'wgDiscussionToolsABTest' ) ) {
return;
}
if ( mw.user.isAnon() ) {
var tokenData = mw.storage.getObject( 'DTNewTopicABToken' );
if ( !tokenData ) {
return;
}
var anonid = parseInt( tokenData.token.slice( 0, 8 ), 16 );
data.bucket = anonid % 2 === 0 ? 'test' : 'control';
// eslint-disable-next-line camelcase
data.anonymous_user_id = tokenData.token;
} else if ( mw.user.options.get( 'discussiontools-abtest2' ) ) {
data.bucket = mw.user.options.get( 'discussiontools-abtest2' );
}
}
var actionPrefixMap = {
firstChange: 'first_change',
saveIntent: 'save_intent',
@ -83,12 +102,7 @@
data.user_class = 'IP';
}
if ( mw.config.get( 'wgDiscussionToolsABTestBucket' ) ) {
data.bucket = mw.config.get( 'wgDiscussionToolsABTestBucket' );
if ( mw.config.get( 'wgDiscussionToolsAnonymousUserId' ) ) {
data.anonymous_user_id = mw.config.get( 'wgDiscussionToolsAnonymousUserId' );
}
}
addABTestData( data );
// Schema's kind of a mess of special properties
if ( data.action === 'init' || data.action === 'abort' || data.action === 'saveFailure' ) {
@ -122,12 +136,7 @@
integration: 'page',
editor_interface: 'wikitext'
};
if ( mw.config.get( 'wgDiscussionToolsABTestBucket' ) ) {
data.bucket = mw.config.get( 'wgDiscussionToolsABTestBucket' );
if ( mw.config.get( 'wgDiscussionToolsAnonymousUserId' ) ) {
data.anonymous_user_id = mw.config.get( 'wgDiscussionToolsAnonymousUserId' );
}
}
addABTestData( data );
/* eslint-enable camelcase */
return data;
} );