Fix language treatment A/B test bucket counting

Register a temporary requirement that is configured the same as the
"LanguageInHeader" requirement. Pass that requirement a custom
configuration, in which the language treatment A/B test is always
enabled. Increment the bucket corresponding to whether the requirement
is met.

Supporting changes:

* Add a version to the base bucket name and set it to 2

Bug: T286932
Change-Id: Ic639687237074a13e7feb3c9084a35db0e5cb902
This commit is contained in:
Sam Smith 2021-08-05 15:30:31 +01:00
parent 000f20213e
commit e6e2120099
1 changed files with 42 additions and 10 deletions

View File

@ -83,6 +83,48 @@ return [
)
);
// ---
// Temporary T286932 - remove after languages A/B test is finished.
$requirementName = 'T286932';
// MultiConfig checks each config in turn, allowing us to override the main config for specific keys. In this
// case, override the "VectorLanguageInHeaderABTest" configuration value so that the following requirement
// always buckets the user as if the language treatment A/B test were running.
$config = new MultiConfig( [
new HashConfig( [
Constants::CONFIG_LANGUAGE_IN_HEADER_TREATMENT_AB_TEST => true,
] ),
$services->getMainConfig(),
] );
$featureManager->registerRequirement(
new OverridableConfigRequirement(
$config,
$context->getUser(),
$context->getRequest(),
CentralIdLookup::factoryNonLocal(),
Constants::CONFIG_KEY_LANGUAGE_IN_HEADER,
$requirementName,
/* $overrideName = */ '',
Constants::CONFIG_LANGUAGE_IN_HEADER_TREATMENT_AB_TEST
)
);
if (
$context->getUser()->isRegistered() &&
$featureManager->isRequirementMet( Constants::REQUIREMENT_LATEST_SKIN_VERSION )
) {
$bucket = 'vector.language_test_2_' . (
$featureManager->isRequirementMet( $requirementName )
? 'a'
: 'b'
);
$services->getStatsdDataFactory()->increment( $bucket );
}
// ---
$featureManager->registerFeature(
Constants::FEATURE_LANGUAGE_IN_HEADER,
[
@ -134,16 +176,6 @@ return [
]
);
// Temporary T286932 - remove after languages A/B test is finished.
if ( $context->getUser()->isRegistered() ) {
$bucket = 'vector.language_test_' . (
$featureManager->isFeatureEnabled( Constants::FEATURE_CONSOLIDATE_USER_LINKS )
? 'a'
: 'b'
);
$services->getStatsdDataFactory()->increment( $bucket );
}
// Feature: Sticky header
// ================================
$featureManager->registerRequirement(