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\ChangeTagsListActiveHook;
use MediaWiki\ChangeTags\Hook\ListDefinedTagsHook; use MediaWiki\ChangeTags\Hook\ListDefinedTagsHook;
use MediaWiki\Extension\BetaFeatures\BetaFeatures; use MediaWiki\Extension\BetaFeatures\BetaFeatures;
use MediaWiki\Extension\DiscussionTools\Hooks as DiscussionToolsHooks;
use MediaWiki\Extension\EventLogging\EventLogging; use MediaWiki\Extension\EventLogging\EventLogging;
use MediaWiki\Hook\EditPage__attemptSave_afterHook; use MediaWiki\Hook\EditPage__attemptSave_afterHook;
use MediaWiki\Hook\EditPage__attemptSaveHook; use MediaWiki\Hook\EditPage__attemptSaveHook;
@ -146,8 +147,11 @@ class Hooks implements
'mw_version' => MW_VERSION, 'mw_version' => MW_VERSION,
] + $data; ] + $data;
if ( $this->userOptionsLookup->getOption( $user, 'discussiontools-abtest2' ) ) { $bucket = ExtensionRegistry::getInstance()->isLoaded( 'DiscussionTools' ) ?
$data['bucket'] = $this->userOptionsLookup->getOption( $user, 'discussiontools-abtest2' ); // @phan-suppress-next-line PhanUndeclaredClassMethod
DiscussionToolsHooks\HookUtils::determineUserABTestBucket( $user ) : false;
if ( $bucket ) {
$data['bucket'] = $bucket;
} }
if ( $user->isAnon() ) { if ( $user->isAnon() ) {
@ -194,7 +198,9 @@ class Hooks implements
'user_editcount' => $editCount ?: 0, '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 ) { if ( $bucket ) {
$data['bucket'] = $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 // DiscussionTools New Topic A/B test for logged out users
if ( !mw.config.get( 'wgDiscussionToolsABTest' ) ) { if ( !mw.config.get( 'wgDiscussionToolsABTest' ) ) {
return; return;
} }
if ( mw.user.isAnon() ) { if ( mw.config.get( 'wgDiscussionToolsABTestBucket' ) ) {
var tokenData = mw.storage.getObject( 'DTNewTopicABToken' ); data.bucket = mw.config.get( 'wgDiscussionToolsABTestBucket' );
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' );
} }
} }
@ -104,7 +93,7 @@
data.user_class = 'IP'; data.user_class = 'IP';
} }
addABTestData( data, true ); addABTestData( data );
// Schema's kind of a mess of special properties // Schema's kind of a mess of special properties
if ( data.action === 'init' || data.action === 'abort' || data.action === 'saveFailure' ) { if ( data.action === 'init' || data.action === 'abort' || data.action === 'saveFailure' ) {