Remove A/B test code

It's unlikely we'll do another feature A/B test any time soon.

Bug: T322492
Bug: T341491
Depends-On: Ia3712e2930fcd971bce44f568430602ce3949f23
Change-Id: I1ef4191f9466b7420a2fead571615ed6d49f873e
This commit is contained in:
Ed Sanders 2024-04-04 15:18:31 +01:00 committed by Bartosz Dziewoński
parent 93d9417dba
commit 66ddcf5b64
5 changed files with 0 additions and 110 deletions

View file

@ -483,12 +483,6 @@
"ConfigFactory"
]
},
"resourceloader": {
"class": "MediaWiki\\Extension\\DiscussionTools\\Hooks\\ResourceLoaderHooks",
"services": [
"ConfigFactory"
]
},
"discussiontools": {
"class": "MediaWiki\\Extension\\DiscussionTools\\Hooks\\DiscussionToolsHooks"
},
@ -543,10 +537,6 @@
"value": false,
"description": "Make DiscussionTools a BetaFeature."
},
"DiscussionToolsABTest": {
"value": false,
"description": "A/B test DiscussionTools features for logged in users. false, any valid feature string for an option below, or an array thereof"
},
"DiscussionTools_visualenhancements": {
"value": "default",
"description": "Override availability of DiscussionTools visual enhancements. 'default', 'available', or 'unavailable'."

View file

@ -253,15 +253,6 @@ class HookUtils {
return true;
}
// Being in the "test" group for this feature means it's enabled. This
// overrules the wiki's beta feature setting. (However, a user who's
// in the control group can still bypass this and enable the feature
// normally.)
$abtest = static::determineUserABTestBucket( $user, $feature );
if ( $abtest === 'test' ) {
return true;
}
// No feature-specific override found.
if ( $dtConfig->get( 'DiscussionToolsBeta' ) ) {
@ -305,36 +296,6 @@ class HookUtils {
}
}
/**
* Work out the A/B test bucket for the current user
*
* Currently this just checks whether the user is logged in, and assigns
* them to a consistent bucket based on their ID.
*
* @param UserIdentity $user
* @param string|null $feature Feature to check for (one of static::FEATURES)
* Null will check for any DT feature.
* @return string 'test' if in the test group, 'control' if in the control group, or '' if
* they're not in the test
*/
public static function determineUserABTestBucket( UserIdentity $user, ?string $feature = null ): string {
$services = MediaWikiServices::getInstance();
$dtConfig = $services->getConfigFactory()->makeConfig( 'discussiontools' );
$abtest = $dtConfig->get( 'DiscussionToolsABTest' );
if ( !$abtest ) {
return '';
}
if (
( $feature ? in_array( $feature, (array)$abtest, true ) : (bool)$abtest ) &&
$user->isRegistered()
) {
return $user->getId() % 2 === 0 ? 'test' : 'control';
}
return '';
}
/**
* Check if the tools are available for a given title
*

View file

@ -138,17 +138,6 @@ class PageHooks implements
}
}
// This doesn't involve any DB checks, and so we can put it on every
// page to make it easy to pick for logging in WikiEditor. If this
// becomes not-cheap, move it elsewhere.
$abstate = HookUtils::determineUserABTestBucket( $user );
if ( $abstate ) {
$output->addJsConfigVars(
'wgDiscussionToolsABTestBucket',
$abstate
);
}
// Replace the action=edit&section=new form with the new topic tool.
if ( HookUtils::shouldOpenNewTopicTool( $output->getContext() ) ) {
$output->addJsConfigVars( 'wgDiscussionToolsStartNewTopicTool', true );

View file

@ -1,43 +0,0 @@
<?php
/**
* DiscussionTools resource loader hooks
*
* @file
* @ingroup Extensions
* @license MIT
*/
namespace MediaWiki\Extension\DiscussionTools\Hooks;
use MediaWiki\Config\Config;
use MediaWiki\Config\ConfigFactory;
use MediaWiki\ResourceLoader\Hook\ResourceLoaderGetConfigVarsHook;
class ResourceLoaderHooks implements
ResourceLoaderGetConfigVarsHook
{
private Config $config;
public function __construct(
ConfigFactory $configFactory
) {
$this->config = $configFactory->makeConfig( 'discussiontools' );
}
/**
* Set static (not request-specific) JS configuration variables
*
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
* @param array &$vars Array of variables to be added into the output of the startup module
* @param string $skin Current skin name to restrict config variables to a certain skin
* @param Config $config
*/
public function onResourceLoaderGetConfigVars( array &$vars, $skin, Config $config ): void {
$abtest = $this->config->get( 'DiscussionToolsABTest' );
if ( $abtest ) {
$vars['wgDiscussionToolsABTest'] = $abtest;
}
}
}

View file

@ -11,13 +11,6 @@ mw.dt.initState = {
firstLoad: true
};
// A/B test for logged out users:
if ( mw.user.isAnon() && mw.config.get( 'wgDiscussionToolsABTest' ) && mw.config.get( 'wgDiscussionToolsABTestBucket' ) ) {
const token = mw.cookie.get( 'DTABid', '', mw.user.generateRandomSessionId() );
mw.cookie.set( 'DTAB', mw.config.get( 'wgDiscussionToolsABTestBucket' ), { path: '/', expires: 90 * 86400, prefix: '' } );
mw.cookie.set( 'DTABid', token, { path: '/', expires: 90 * 86400, prefix: '' } );
}
if ( url.searchParams.get( 'dtrepliedto' ) ) {
// If we had to reload the page to highlight the new comment, extract that data from the URL and
// clean it up.