Background
While working on preserving the TOC A/B test code in T310527, the next iteration of the experiment will test logged-in users by bucketing by user ID rather than page ID. This requires a refactor of the TOC A/B test feature.
Description
Refactor the TOC A/B test to bucket by user instead of by page (excluding anons).
Acceptance criteria
- When TOC A/B test is enabled, it applies only to logged-in users.
- Control group sees old treatment of TOC
- Control group loads legacy TOC styles (skins.vector.AB.styles)
- Treatment group sees new treatment of TOC
- Treatment group doesn't load legacy TOC styles (skins.vector.AB.styles) << path of least resistance is to load AB overriding styles when test is enabled
- Unsampled users see whatever is specified by default config. << with the current implementation and test scope, all logged-in users will be sampled so users will be in either control or treatment buckets
Developer notes
Previous TOC A/B test functionality leveraged backend bucketing based on page ID using the PageSplitter object referenced by the WebABTestArticleIdStrategy and WebABTestArticleIdFactory classes in WME and applies the necessary classes to the body using a Vector hook.
To switch to using user ID, we can use the Vector hook to assign logged users in the treatment or control groups and assigning relevant body classes accordingly. However the current state of CSS for showing the appropriate TOC in an A/B test context does not account for grid being active so there is some added complexity to display the correctly styled TOC/page with grid enabled.
It should simplify showing the correct TOC to control/treatment buckets once grid has landed (instead of having to account for both use cases of grid being on or off). In SkinVector22:getTemplateData(), the data that's passed to the template only considers whether grid is enabled which means many of the styles related to the classes (i.e. vector-layout-grid vector-toc-visible vs vector-layout-legacy) applied by that method need to be overridden during an active A/B test.
QA steps
- Set up local event logging with local config (toggling the enabled key between true and false):
$wgVectorWebABTestEnrollment = [ 'name' => 'skin-vector-toc-experiment', 'enabled' => true, 'buckets' => [ 'unsampled' => [ 'samplingRate' => 0, ], 'control' => [ 'samplingRate' => 0.5, ], 'treatment' => [ 'samplingRate' => 0.5, ] ] ];
- With the experiment enabled:
- Log in as a user with an even id and navigate to a page with a TOC:
- The treatment should be visible - collapsible TOC (no TOC inline in main content)
- There should be a stylesheet called skins.vector.AB.styles upon inspection via console
- An event is logged with group property set to treatment
- Log in as a user with an odd id and navigate to a page with a TOC:
- The treatment should not be visible - TOC inline in main content (no collapsible TOC)
- There should be a stylesheet added called skins.vector.AB.styles upon inspection via console
- An event is logged with group property set to control
- Navigate to a page with a TOC as an anonymous user:
- You should see TOC as defined by default config (collapsible TOC - no inline TOC)
- There should be a stylesheet added called skins.vector.AB.styles upon inspection via console
- No event should be logged
- Log in as a user with an even id and navigate to a page with a TOC:
- With the experiment disabled:
- Log in as a user with an even or odd id and navigate to a page with a TOC:
- You should see TOC as defined by default config (collapsible TOC - no inline TOC)
- There should be no stylesheet called skins.vector.AB.styles upon inspection via console
- No event should be logged
- Navigate to a page with a TOC as an anonymous user:
- You should see TOC as defined by default config (collapsible TOC - no inline TOC)
- There should be no stylesheet called skins.vector.AB.styles upon inspection via console
- No event should be logged
- Log in as a user with an even or odd id and navigate to a page with a TOC: