mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/WikiEditor
synced 2024-11-23 15:57:15 +00:00
Update schema logging of bucket for new DiscussionTools A/B test
Bug: T304030 Depends-On: I5e57bb9b7958576f3a04373748331a86f4626fb5 Change-Id: I084d26c95d5be78eddb4edd1b42aa52eef909356
This commit is contained in:
parent
d3850e5262
commit
ce2ecf084f
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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' ) {
|
||||||
|
|
Loading…
Reference in a new issue