Page MenuHomePhabricator

ge.utils.setUserVariant does not work when executed outside of Special:Homepage
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Ensure wgGEUseMetricsPlatformExtension is set to true in the site config
  • As an user in the control group for Revise Tone, go to https://ar.wikipedia.beta.wmcloud.org/'s main page
    • You can verify you are in the control group by checking the Revise Tone task is missing from your Homepage (the task type selector looks like F70142662)
  • On the main page, open the dev tools console and execute ge.utils.setUserVariant('growthexperiments-revise-tone_control')
  • Go to Special:Homepage and open the task type selector

What happens?:

The Revise Tone task is missing. No error indicates the ge.utils.setUserVariant()

What should have happened instead?:

Either:

  • The Revise Tone task is added, since the user was just opted into the treatment group, or
  • the ge.utils.setUserVariant() execution errors out.

Notes
This bug only appears when the xLab manager is in use. Otherwise, the ge.utils.setUserVariant() helper can be used from any page. This makes the bug a Regression (of sort).

This was noticed, because @Dyolf77_WMF was having troubles with opting into Revise Tone treatment group on beta. Investigation showed the cause was executing the helper from the main page.

Event Timeline

Restricted Application added subscribers: hubaishan, Aklapper. · View Herald Transcript

setUserVariant has two modes of working. Roughly, its structure is:

if ( mw.config.get( 'wgGEUseMetricsPlatformExtension' ) ) {
    // Use mw.xLab.overrideExperimentGroup to override the variant for the user
} else {
    // Use the `growthexperiments-homepage-variant` user property to override the variant
}

wgGEUseMetricsPlatformExtension should be set to Util::useMetricsPlatform(). Unfortunately, we do this in SpecialHomepage::execute, which means the wgGEUseMetricsPlatformExtension variable is only populated on Special:Homepage. On all other pages, it returns the fallback value. The default fallback value is null. In JavaScript, null casts to false, which means the user-property-based branch of the code runs. That branch successfully changes the user property, but...we do not actually use it for determining the variant, so the user sees no change.

Change #1204843 had a related patch set uploaded (by Sergio Gimeno; author: Sergio Gimeno):

[mediawiki/extensions/GrowthExperiments@master] fix(ge.utils.setUserVariant): return wgGEUseMetricsPlatformExtension JS var

https://gerrit.wikimedia.org/r/1204843

Change #1204843 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] fix(ge.utils.setUserVariant): add GEUseMetricsPlatformExtension JS var

https://gerrit.wikimedia.org/r/1204843

@Urbanecm_WMF tell me if I'm looking into this correctly.

After confirming that I'm in the revise tone control group, I now notice that the ge.utils.setUserVariant() can be executed on the Main Page in arwiki beta.

Executing ge.utils.setUserVariant('growthexperiments-revise-tone_control') reloads the page as expected.

Nothing errors out.

Resolving based on QA feedback.