Page MenuHomePhabricator

Build A/B test bucketing infrastructure for the table of contents.
Closed, ResolvedPublic5 Estimated Story Points

Description

Build the A/B test infrastructure for the table of contents.

Acceptance criteria

  • Generalize all existing A/B test JavaScript code which is currently tied to the sticky header A/B test
  • For initial page views, bucketing should be determined by page ID
  • For follow up page views, all links should be intercepted to add the tableofcontents query string using the current value
  • When the tableofcontents query string is present that should control the bucket used.

Developer notes

https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/759367

QA steps

The AB test has been enabled on Beta with the following bucket distribution:

unsampled (not part of experiment): 0%
control (should see TOC in content): 50%
treatment (should see TOC in sidebar): 50%

Testing the bucketing

  • Based on the distribution above, a general sweep across the article pages (e.g. https://en.wikipedia.beta.wmflabs.org/wiki/Dog, https://en.wikipedia.beta.wmflabs.org/wiki/Cat, etc) on beta should be performed asserting that you always either see the old TOC in the content or the new TOC in the sidebar but never both. Roughly half the articles should show the new TOC and the other half should show the old TOC. Because the bucketing is done with the article id instead of the user id, the assigned bucket for a particular article should remain constant regardless of whether the user is logged in or not.

If having trouble, check that the skin-vector-toc-experiment class is on the body tag. This determines whether the AB test is enabled for that page. It's possible anonymous pages might be cached and not have the experiment enabled yet.

Testing link hijacking

Per the AC, part of this ticket involved attempting to hijack every link on the page in an effort to have the user remain in a particular bucket across pages when they click a link. This is expected to not be robust (for example, if the user clicks a link from Google there is a chance they won't remain in the same bucket), however it should mostly work when clicking links that lead to articles with a TOC. Therefore, the following steps can be performed, for example:

Link hijacking the Dog article
  • Go to https://en.wikipedia.beta.wmflabs.org/wiki/Dog . Assert that the old TOC shows in the content.
  • Click on the "domestic" link in the article
  • Assert that a tableofcontents=0 query param is appended to the end of the url and the old TOC is shown when the page is loaded.
Link hijacking the Cat article
  • Go to https://en.wikipedia.beta.wmflabs.org/wiki/Cat . Assert that the new TOC shows in the sidebar.
  • Click on the "domesticated" link in the article
  • Assert that a tableofcontents=1 query param is appended to the end of the url and the new TOC is shown when the page is loaded.

Testing query param override

When the AB test is enabled, using the tableofcontents query param should override the particular bucket that would have otherwise been chosen.

Query param override of Dog article
Query param override of Cat article

QA Results - Beta

ACStatusDetails
1T302046#7981781
2T302046#7981781
3T302046#7981781

QA Results - Prod

ACStatusDetails
1T302046#7981802
2T302046#7981802
3T302046#7981802

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Jdrewniak renamed this task from Build A/B test infrastructure for the table of contents. to Build A/B test bucketing infrastructure for the table of contents..Mar 2 2022, 10:55 PM

Change 769080 had a related patch set uploaded (by Nray; author: Nray):

[mediawiki/skins/Vector@master] POC and WIP: Initial AB Test infrastructure for Table of Contents

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

nray subscribed.

Still very much working on this but am far enough along that it would be very beneficial to get a sanity check on the approach. Therefore, I am moving to code review (and thank you in advance)

Change 759367 had a related patch set uploaded (by Nray; author: Nray):

[mediawiki/skins/Vector@master] Build TOC AB test infrastructure

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

Change 769080 abandoned by Nray:

[mediawiki/skins/Vector@master] POC and WIP: Initial AB Test infrastructure for Table of Contents

Reason:

Please see I134df1440b9de0cb32990be9f28655971583bb9a for now

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

Change 759367 abandoned by Nray:

[mediawiki/skins/Vector@master] Build TOC AB test infrastructure

Reason:

Will make a new patch

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

Change 770625 had a related patch set uploaded (by Nray; author: Nray):

[mediawiki/skins/Vector@master] Build A/B test bucketing infrastructure for the table of contents.

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

Change 771701 had a related patch set uploaded (by Nray; author: Nray):

[mediawiki/skins/Vector@master] Revise AB.js to handle server sampling/bucketing as well as clientside

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

Test wiki created on Patch demo by Jdlrobson using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/344378f5de/w/

Change 771701 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Revise AB.js to handle other features + server sampling/bucketing

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

https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/770625 is all that's remaining here, right? Some feedback there.

Yes, I will work on it today

Change 774985 had a related patch set uploaded (by Nray; author: Nray):

[mediawiki/extensions/WikimediaEvents@master] Add WebABTestArticleIdFactory and WebABTestArticleIdStrategy classes

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

Change 774985 merged by jenkins-bot:

[mediawiki/extensions/WikimediaEvents@master] Add WebABTestArticleIdFactory and WebABTestArticleIdStrategy classes

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

nray moved this task from QA to Code Review on the Web-Team-Backlog (Kanbanana-FY-2021-22) board.
nray added a subscriber: Edtadros.

@Jdlrobson I moved this back to code review as I made a small change after your +2 due to visual regressions

Change 770625 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Build A/B test bucketing infrastructure for the table of contents.

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

@nray Post-merge comment left on the patch.

Change 779551 had a related patch set uploaded (by Nray; author: Nray):

[operations/mediawiki-config@master] Enable Table of Contents AB test on Beta

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

Change 779551 merged by jenkins-bot:

[operations/mediawiki-config@master] Enable Table of Contents AB test on Beta

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

Change 779923 had a related patch set uploaded (by Nray; author: Nray):

[operations/mediawiki-config@master] Correct AB test config

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

Change 779923 merged by jenkins-bot:

[operations/mediawiki-config@master] Correct AB test config

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

nray added a subscriber: cjming.

@Edtadros The AB test bucketing has been enabled on beta and QA instructions have been written for this ticket. Please let me know if you run into trouble or have any questions

Also thank you to @Jdlrobson for figuring out why the config I initially had wasn't working (I messed up) and @cjming for deploying the fix!

cc @ovasileva

Moving back to needs more work due to this bug report: T306366

Test Result - Beta

Status: ✅ PASS
Environment: beta
OS: macOS Monterey
Browser: Chrome
Device: MBP
Emulated Device:NA

Test Artifact(s):

QA Steps

Testing link hijacking
Per the AC, part of this ticket involved attempting to hijack every link on the page in an effort to have the user remain in a particular bucket across pages when they click a link. This is expected to not be robust (for example, if the user clicks a link from Google there is a chance they won't remain in the same bucket), however it should mostly work when clicking links that lead to articles with a TOC. Therefore, the following steps can be performed, for example:

✅ AC1: Link hijacking the Dog article
Go to https://en.wikipedia.beta.wmflabs.org/wiki/Dog. Assert that the old TOC shows in the content.

Screen Shot 2022-04-19 at 7.16.35 AM.png (1×1 px, 440 KB)

Click on the "domestic" link in the article
Assert that a tableofcontents=0 query param is appended to the end of the url and the old TOC is shown when the page is loaded.
Screen Shot 2022-04-19 at 7.18.33 AM.png (1×1 px, 369 KB)

✅ AC2: Link hijacking the Cat article
Go to https://en.wikipedia.beta.wmflabs.org/wiki/Cat . Assert that the new TOC shows in the sidebar.

Screen Shot 2022-04-19 at 7.20.46 AM.png (1×1 px, 485 KB)

Click on the "domesticated" link in the article
Assert that a tableofcontents=1 query param is appended to the end of the url and the new TOC is shown when the page is loaded.
Screen Shot 2022-04-19 at 7.21.30 AM.png (1×1 px, 523 KB)

✅ AC3: Testing query param override
When the AB test is enabled, using the tableofcontents query param should override the particular bucket that would have otherwise been chosen.

Query param override of Dog article
Go to https://en.wikipedia.beta.wmflabs.org/wiki/Dog?tableofcontents=1
Assert that the new TOC is shown in the sidebar

Screen Shot 2022-04-19 at 7.23.13 AM.png (1×1 px, 393 KB)

Go to https://en.wikipedia.beta.wmflabs.org/wiki/Dog?tableofcontents=0
Assert that the old TOC is shown in the content
Screen Shot 2022-04-19 at 7.24.08 AM.png (1×1 px, 493 KB)

Query param override of Cat article
Go to https://en.wikipedia.beta.wmflabs.org/wiki/Cat?tableofcontents=1
Assert that the new TOC is shown in the sidebar
Screen Shot 2022-04-19 at 7.25.09 AM.png (1×1 px, 531 KB)

Go to https://en.wikipedia.beta.wmflabs.org/wiki/Cat?tableofcontents=0
Assert that the old TOC is shown in the content
Screen Shot 2022-04-19 at 7.25.54 AM.png (1×1 px, 357 KB)

@nray Is this testable in prod yet? I see the TOC, but there is no query param. Also, I can't seem to find a page with the legacy toc. I've tried multiple users and a lot of random pages.

@nray Is this testable in prod yet? I see the TOC, but there is no query param. Also, I can't seem to find a page with the legacy toc. I've tried multiple users and a lot of random pages.

@Edtadros - right now, the a/b test is only available on euwiki and hewiki in prod

Test Result - Beta

Status: ✅ PASS
Environment: beta
OS: macOS Monterey
Browser: Chrome
Device: MBP
Emulated Device:NA

Test Artifact(s):

QA Steps

Testing link hijacking
Per the AC, part of this ticket involved attempting to hijack every link on the page in an effort to have the user remain in a particular bucket across pages when they click a link. This is expected to not be robust (for example, if the user clicks a link from Google there is a chance they won't remain in the same bucket), however it should mostly work when clicking links that lead to articles with a TOC. Therefore, the following steps can be performed, for example:

✅ AC1: Link hijacking the Dog article
Go to https://en.wikipedia.beta.wmflabs.org/wiki/Dog. Assert that the old TOC shows in the content.

Screen Shot 2022-04-19 at 7.16.35 AM.png (1×1 px, 440 KB)

Click on the "domestic" link in the article
Assert that a tableofcontents=0 query param is appended to the end of the url and the old TOC is shown when the page is loaded.
Screen Shot 2022-04-19 at 7.18.33 AM.png (1×1 px, 369 KB)

✅ AC2: Link hijacking the Cat article
Go to https://en.wikipedia.beta.wmflabs.org/wiki/Cat . Assert that the new TOC shows in the sidebar.

Screen Shot 2022-04-19 at 7.20.46 AM.png (1×1 px, 485 KB)

Click on the "domesticated" link in the article
Assert that a tableofcontents=1 query param is appended to the end of the url and the new TOC is shown when the page is loaded.
Screen Shot 2022-04-19 at 7.21.30 AM.png (1×1 px, 523 KB)

✅ AC3: Testing query param override
When the AB test is enabled, using the tableofcontents query param should override the particular bucket that would have otherwise been chosen.

Query param override of Dog article
Go to https://en.wikipedia.beta.wmflabs.org/wiki/Dog?tableofcontents=1
Assert that the new TOC is shown in the sidebar

Screen Shot 2022-04-19 at 7.23.13 AM.png (1×1 px, 393 KB)

Go to https://en.wikipedia.beta.wmflabs.org/wiki/Dog?tableofcontents=0
Assert that the old TOC is shown in the content
Screen Shot 2022-04-19 at 7.24.08 AM.png (1×1 px, 493 KB)

Query param override of Cat article
Go to https://en.wikipedia.beta.wmflabs.org/wiki/Cat?tableofcontents=1
Assert that the new TOC is shown in the sidebar
Screen Shot 2022-04-19 at 7.25.09 AM.png (1×1 px, 531 KB)

Go to https://en.wikipedia.beta.wmflabs.org/wiki/Cat?tableofcontents=0
Assert that the old TOC is shown in the content
Screen Shot 2022-04-19 at 7.25.54 AM.png (1×1 px, 357 KB)

Test Result - Prod

Status: ✅ PASS
Environment: euwiki
OS: macOS Monterey
Browser: Chrome
Device: MBP
Emulated Device:NA

Test Artifact(s):

QA Steps

Testing link hijacking
Per the AC, part of this ticket involved attempting to hijack every link on the page in an effort to have the user remain in a particular bucket across pages when they click a link. This is expected to not be robust (for example, if the user clicks a link from Google there is a chance they won't remain in the same bucket), however it should mostly work when clicking links that lead to articles with a TOC. Therefore, the following steps can be performed, for example:

✅ AC1: Link hijacking the Cat Stevens article
Go to https://eu.wikipedia.org/wiki/Cat_Stevens. Assert that the old TOC shows in the content.

Screen Shot 2022-06-05 at 6.23.36 PM.png (624×1 px, 262 KB)

Click on the "folk-rock" link in the article
Assert that a tableofcontents=0 query param is appended to the end of the url and the old TOC is shown when the page is loaded.
Screen Shot 2022-06-05 at 6.24.19 PM.png (627×1 px, 298 KB)

✅ AC2: Link hijacking the Luxenburgo article
Go to https://eu.wikipedia.org/wiki/Luxenburgo . Assert that the new TOC shows in the sidebar.
Screen Shot 2022-06-05 at 6.26.46 PM.png (615×1 px, 281 KB)

Click on the "Belgikarekin" link in the article
Assert that a tableofcontents=1 query param is appended to the end of the url and the new TOC is shown when the page is loaded.
Screen Shot 2022-06-05 at 6.27.53 PM.png (625×1 px, 236 KB)

✅ AC3: Testing query param override
When the AB test is enabled, using the tableofcontents query param should override the particular bucket that would have otherwise been chosen.

Query param override of Cat Stevens article
Go to https://eu.wikipedia.org/wiki/Cat_Stevens?tableofcontents=1
Assert that the new TOC is shown in the sidebar

Screen Shot 2022-06-05 at 6.29.48 PM.png (606×1 px, 215 KB)

Go to https://eu.wikipedia.org/wiki/Cat_Stevens?tableofcontents=0
Assert that the old TOC is shown in the content
Screen Shot 2022-06-05 at 6.31.15 PM.png (624×1 px, 263 KB)

Query param override of Luxenburgo article
Go to https://eu.wikipedia.org/wiki/Luxenburgo?tableofcontents=1
Assert that the new TOC is shown in the sidebar
Screen Shot 2022-06-05 at 6.32.38 PM.png (625×1 px, 276 KB)

Go to https://eu.wikipedia.org/wiki/Luxenburgo?tableofcontents=0
Assert that the old TOC is shown in the content
Screen Shot 2022-06-05 at 6.33.11 PM.png (623×1 px, 191 KB)

Resolving as A/B test is live

Test wiki on Patch demo by Jdlrobson using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/344378f5de/w/