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

Bug: T304030
Depends-On: I5e57bb9b7958576f3a04373748331a86f4626fb5
Change-Id: I084d26c95d5be78eddb4edd1b42aa52eef909356
This commit is contained in:
David Lynch 2022-05-19 01:08:37 -05:00
parent d3850e5262
commit ce2ecf084f
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' ) {