Merge "Update schema logging of bucket for new DiscussionTools A/B test"

This commit is contained in:
jenkins-bot 2022-05-20 22:28:18 +00:00 committed by Gerrit Code Review
commit 54019ffc38
2 changed files with 13 additions and 18 deletions

View file

@ -19,6 +19,7 @@ use MediaWiki\Cache\CacheKeyHelper;
use MediaWiki\ChangeTags\Hook\ChangeTagsListActiveHook;
use MediaWiki\ChangeTags\Hook\ListDefinedTagsHook;
use MediaWiki\Extension\BetaFeatures\BetaFeatures;
use MediaWiki\Extension\DiscussionTools\Hooks as DiscussionToolsHooks;
use MediaWiki\Extension\EventLogging\EventLogging;
use MediaWiki\Hook\EditPage__attemptSave_afterHook;
use MediaWiki\Hook\EditPage__attemptSaveHook;
@ -146,8 +147,11 @@ class Hooks implements
'mw_version' => MW_VERSION,
] + $data;
if ( $this->userOptionsLookup->getOption( $user, 'discussiontools-abtest2' ) ) {
$data['bucket'] = $this->userOptionsLookup->getOption( $user, 'discussiontools-abtest2' );
$bucket = ExtensionRegistry::getInstance()->isLoaded( 'DiscussionTools' ) ?
// @phan-suppress-next-line PhanUndeclaredClassMethod
DiscussionToolsHooks\HookUtils::determineUserABTestBucket( $user ) : false;
if ( $bucket ) {
$data['bucket'] = $bucket;
}
if ( $user->isAnon() ) {
@ -194,7 +198,9 @@ class Hooks implements
'user_editcount' => $editCount ?: 0,
];
$bucket = $this->userOptionsLookup->getOption( $user, 'discussiontools-abtest2' );
$bucket = ExtensionRegistry::getInstance()->isLoaded( 'DiscussionTools' ) ?
// @phan-suppress-next-line PhanUndeclaredClassMethod
DiscussionToolsHooks\HookUtils::determineUserABTestBucket( $user ) : false;
if ( $bucket ) {
$data['bucket'] = $bucket;
}

View file

@ -48,24 +48,13 @@
};
}
function addABTestData( data, addToken ) {
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';
if ( addToken ) {
// eslint-disable-next-line camelcase
data.anonymous_user_token = tokenData.token;
}
} else if ( mw.user.options.get( 'discussiontools-abtest2' ) ) {
data.bucket = mw.user.options.get( 'discussiontools-abtest2' );
if ( mw.config.get( 'wgDiscussionToolsABTestBucket' ) ) {
data.bucket = mw.config.get( 'wgDiscussionToolsABTestBucket' );
}
}
@ -104,7 +93,7 @@
data.user_class = 'IP';
}
addABTestData( data, true );
addABTestData( data );
// Schema's kind of a mess of special properties
if ( data.action === 'init' || data.action === 'abort' || data.action === 'saveFailure' ) {