Page MenuHomePhabricator

Image Browsing: Gate the feature properly
Closed, ResolvedPublic3 Estimated Story Points

Description

Before adding the ReaderExperiments extension to production, we need to take some additional steps to "gate" the ImageBrowsing prototype to a limited subset of users.

Requirements

Ensure that the Image Browsing code (at least the bulk of it, i.e. Vue.js and components) only loads when both of the conditions below are met:

  • The user is on the minerva skin (we understand some Desktop users request this, but that number is negligible for our experiment)
  • At least one of the following is true:
    • The user has been bucketed into the experiment group for an active A/B test via xLab
    • The user has manually enabled the Image Browsing feature via the correct URL parameter feature flag.

If these conditions are not met, the only impact our feature should have on visitors should be:

  • An empty <div> has been added to article pages
  • A small amount of JS (not Vue, Codex, or any UI components) has been loaded to test for whether the full UI needs to be displayed.
Open question: target wikis

In addition to the above conditions, the A/B test for ImageBrowsing will only be run on a subset of target wikis. It's actually not currently clear to me how this will be achieved:

  • Will we enable the extension on all Wikipedias and then use xLab to limit the A/B testing (meaning that users with URL params on non-target Wikis could still see this feature if they were curious)?
  • Or will we only enable the extension on the target wikis, meaning that users on other-language Wikipedias would have no way to see this? I could see this option being what we'd want if we are concerned about not having the UI sufficiently translated.
Open Question: Should opt-in users on Vector be supported?

If for some reason we wish to allow opt-in users on Vector to see this feature, we can probably accommodate that as long as there is an easy way within xLab to scope the experiment to Minerva skin only.

Implementation notes
  • We currently add the ResourceModule containing the ImageBrowsing UI (CSS & JS plus messages, etc) to article pages in PHP. We need to modify this approach – we should define a new very small RL module that contains basic JS initialization code to test for the above conditions. If the conditions have been met, the full UI can be loaded from another RL module via mw.loader.using, mw.loader.load, etc. Only this first small module should be added to payloads for non-participating users.
QA notes

Please check the following things during QA:

  • The Image Browing UI no longer shows up normally by default
    • The ext.readerExperiments.imageBrowsing ResourceLoader module should not be loaded at all in this case; this can be tested by opening the browser console on a Wiki article page and running mw.inspect() – check to see if ext.readerExperiments.imageBrowsing is in the results (it would be listed near the top if so given its size).
  • The Image Browsing UI does show up properly if the ?imageBrowsing=1 or imageBrowsing=true URL param is used AND the user is on Minerva skin
  • The Image Browsing UI does not show up if the URL param is used but the user IS NOT on Minerva skin

Other behavior should be unchanged

Details

Event Timeline

We don't typically do this for experiments as... well we can't.

If you truly want to limit your audience, it is better to feature detect on the browser the conditions you want - for example you might want to check window.innerWidth if you want to limit your audience to a certain viewport and you probably want to check the skin minerva.

For every experience I've worked on previously, we've just limited the experiment to minerva. Although this also captures desktop Minerva users, these are easy to filter out (since they will have access_method = desktop )

Adjusted ticket based on our Slack discussion.
In summary:

  • CSS-only approach isn’t enough since non-bucketed users shouldn’t load the experiment code/Vue at all.

Consensus is to create a small ResourceLoader “gate” module that:

  1. Checks experiment bucketing (client-side),
  2. Confirms mobile/Minerva skin,
  3. Allows URL param override.

If conditions pass, the gate module loads the full Image Browsing module with the UI.

egardner renamed this task from Image Browsing: Gate the feature to "mobile" users only to Image Browsing: Gate the feature properly.Sep 12 2025, 7:40 PM
egardner updated the task description. (Show Details)

Change #1187912 had a related patch set uploaded (by Kimberly Sarabia; author: Kimberly Sarabia):

[mediawiki/extensions/ReaderExperiments@master] [WIP] Gate image browsing feature

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

ovasileva set the point value for this task to 3.Sep 15 2025, 4:48 PM
How to Toggle Headers for Metrics Platform Buckets (Control vs Test)
  1. Open Inssman Extension
    • Make sure the extension is switched On (top-right toggle should be blue).
  1. Create a New Rule
    • In the left menu, click Modify Header under Create Rule.
    • Give your rule a name (e.g. test).
  1. Set Request Matching
    • Under If Request, choose:
    • Condition: Contain
    • Value: http://localhost (Replace with your actual service endpoint if different.)
  1. Define Header Modification
    • Under Operator, select:
    • Action: Set
    • Scope: Request
    • Add the header:
    • Key: X-Experiment-Enrollments

Value:

  • For Control bucket: vsing-ab-test=image-browsing-control
  • For Test bucket: vsing-ab-test=image-browsing-test
  1. Toggle Between Control and Test
    • To switch, simply edit the header value to either:
    • ...-control → assigns traffic to the control group.
    • ...-test → assigns traffic to the experimental bucket.
    • Save your change with the disk icon (top-right).
    • Confirm Rule is Active
    • Make sure the rule’s toggle is on (blue).
    • Run a request through your service and verify the header is injected.

Change #1187912 merged by jenkins-bot:

[mediawiki/extensions/ReaderExperiments@master] Gate image browsing feature

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

Test wiki created on Patch demo by ETadros (WMF) using patch(es) linked to this task:
https://d28ccc16c7.catalyst.wmcloud.org/w/

@KSarabia-WMF, I think I'm not using Inssman correctly or something since I cannot get the carousel to appear unless I have a query param. I did this in patchdemo, so I'm not sure if that's another issue.

Test Result - Patchdemo

Status: ❓Need More Info
Environment: patchdemo (https://d28ccc16c7.catalyst.wmcloud.org/)
OS: macOS Sequoia 15.5
Browser: Chrome Canary (latest as of test date)
Device: MS
Emulated Device: NA

Test Case 1: Default case – no experiment, no param

  1. Open a wiki article page in Minerva skin.
  2. Do not set any URL params or headers.
  3. Run mw.inspect() in console.
  4. AC1: The Image Browsing UI is not shown.
  5. AC2: The module ext.readerExperiments.imageBrowsing is not listed in mw.inspect().

screenshot 209.png (1,579×1,865 px, 517 KB)

Test Case 2: URL param + Minerva

  1. Open a wiki article page in Minerva skin with ?imageBrowsing=1.
  2. Run mw.inspect() in console.
  3. AC3: The Image Browsing UI is shown.
  4. AC4: The module ext.readerExperiments.imageBrowsing is listed in mw.inspect().

screenshot 210.png (1,576×1,368 px, 652 KB)

Test Case 3: URL param + non-Minerva

  1. Open a wiki article page in Vector skin with ?imageBrowsing=1.
  2. Run mw.inspect() in console.
  3. AC5: The Image Browsing UI is not shown.
  4. AC6: The module ext.readerExperiments.imageBrowsing is not listed.

screenshot 211.png (1,577×1,586 px, 572 KB)

Test Case 4: Experiment enrollment – test bucket

  1. Configure request header X-Experiment-Enrollments: vsing-ab-test=image-browsing-test using Inssman.
  2. Open a wiki article page in Minerva skin.
  3. AC7: The Image Browsing UI is shown.

Unless I use the query param I don't see the image carousel. But the request header shows in the network tab

screenshot 216.png (1,577×1,847 px, 649 KB)

screenshot 215.png (1,575×1,312 px, 374 KB)

Test Case 5: Experiment enrollment – control bucket

  1. Configure request header X-Experiment-Enrollments: vsing-ab-test=image-browsing-control.
  2. Open a wiki article page in Minerva skin.
  3. AC8: The Image Browsing UI is not shown.
  4. AC9: The module ext.readerExperiments.imageBrowsing is not listed.

Leaving this as a question mark since I'm not really sure how valid the test is since when I'm part of the control I don't see the carousel.

screenshot 213.png (1,577×1,864 px, 674 KB)

screenshot 214.png (1,574×1,146 px, 329 KB)

@Edtadros re: test case 4 - I think this won't work on PatchDemo, since it's missing the required extensions MetricsPlatform and WikimediaEvents. We'll have to test this locally with a fully working dev environment.
Also, I'm not sure why vsing-ab-test is indicated as the header key: according to the docs, we should use the machine-readable experiment name, which is fy2025-26-we3.1-image-browsing-ab-test.
This definitely needs more work, stay tuned!

I've managed to set up a full local dev environment and test the remaining cases:

Test Case 4: Experiment enrollment – test bucket

  1. Configure request header X-Experiment-Enrollments: vsing-ab-test=image-browsing-test using Inssman.

As mentioned in T404233#11234555, the header value should be fy2025-26-we3.1-image-browsing-ab-test=image-browsing-test.
image-browsing-test corresponds to the treatment group on MPIC.

Screenshot 2025-10-06 at 19.45.01.png (2,076×2,406 px, 412 KB)

  1. Open a wiki article page in Minerva skin.
  2. AC7: The Image Browsing UI is shown.

✅ it works!

Screenshot 2025-10-06 at 19.50.08.png (5,120×2,746 px, 1 MB)

Test Case 5: Experiment enrollment – control bucket

  1. Configure request header X-Experiment-Enrollments: vsing-ab-test=image-browsing-control.

The header value should be fy2025-26-we3.1-image-browsing-ab-test=control.

  1. Open a wiki article page in Minerva skin.
  2. AC8: The Image Browsing UI is not shown.

  1. AC9: The module ext.readerExperiments.imageBrowsing is not listed.


Screenshot 2025-10-06 at 19.46.02.png (5,100×2,752 px, 880 KB)

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

https://d28ccc16c7.catalyst.wmcloud.org/w/

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

https://d28ccc16c7.catalyst.wmcloud.org/w/