Page MenuHomePhabricator

Minimize volume of exposure events sent
Closed, ResolvedPublic5 Estimated Story Points

Description

We should minimize the volume of exposure events.

At the very least, exposure events should not be sent more than once per experiment per page view even if there are multiple logExposure() calls on a page. Ideally, however, exposure events would not be sent more than once per experiment per epoch.

Design of memory mechanism

@cjming wrote:

Based on the concluding comments in T414739: [Spike] Design memory mechanism for exposureLogged flags, I'll try to succinctly revise the proposal and pseudocode to where we landed.
To summarize, we want to implement a 2-tier architecture (for JavaScript client-side - PHP server-side will will remain 1 tier because of caching issues) for a versioned exposure ledger that minimizes redundant logging while preserves data integrity during experiment changes/updates.

Tier 1 - in-memory floor

  • scope: single page view (JS) or HTTP request (PHP)
  • guarantees no more than one exposure logging event per request/view

Tier 2 - best effort, optimal ceiling

  • scope: browser tab/session per origin (JS only)
  • deduplicates exposures across internal navigations and refreshes using mw.storage.session
  • records 1 exposure event per session per origin (i.e. exposure on jawiki is invisible to an exposure on kowiki)

Remembering if exposure was logged on the web

Implementation:

  • use versioned keys - hash experiment parameters to bypass old storage and trigger a fresh exposure event when the experiment config state changes
  • progressive exposure suppression (JS only) - capture session starts with a 5 minute TTL for the first 10 exposure attempts (to pre-empt rapid navigation or refreshes), then pivot to a 24 hour TTL to suppress for the rest of the lifetime of the tab
  • for the panic button scenario, introduce a global epoch variable? Server provides a timestamp to recover from systemic/pipeline issues - forces all users to re-log exposures regardless of storage state
    • update experiment config in ExperimentManager::getExperimentConfig() to return a new key called global_reset_epoch

For JS and PHP implementation proposals refer to T414740#11635559

Acceptance criteria

Event Timeline

KReid-WMF triaged this task as Medium priority.Jan 20 2026, 5:44 PM
KReid-WMF updated the task description. (Show Details)
KReid-WMF moved this task from Incoming to READY TO GROOM on the Test Kitchen board.
mpopov added a subscriber: cjming.
KReid-WMF set the point value for this task to 5.Feb 24 2026, 4:33 PM

Change #1260612 had a related patch set uploaded (by Clare Ming; author: Clare Ming):

[mediawiki/extensions/TestKitchen@master] Minimize volume of exposure logging events sent

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

Change #1262048 had a related patch set uploaded (by Clare Ming; author: Clare Ming):

[mediawiki/extensions/TestKitchen@master] Minimize duplicate experiment exposure events via two-tier deduplication

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

Change #1262048 abandoned by Phuedx:

[mediawiki/extensions/TestKitchen@master] Minimize duplicate experiment exposure events via two-tier deduplication

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

Change #1264653 had a related patch set uploaded (by Clare Ming; author: Clare Ming):

[operations/mediawiki-config@master] Add TestKitchenExposureResetEpoch config variable

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

Change #1260612 merged by jenkins-bot:

[mediawiki/extensions/TestKitchen@master] Minimize duplicate experiment exposure events via two-tier deduplication

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

Change #1264653 merged by jenkins-bot:

[operations/mediawiki-config@master] Add TestKitchenExposureResetEpoch config variable

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

Mentioned in SAL (#wikimedia-operations) [2026-03-30T20:42:48Z] <cjming@deploy1003> Started scap sync-world: Backport for [[gerrit:1264652|Add delete-redirect to filemovers on Wikimedia Commons (T421373)]], [[gerrit:1264653|Add TestKitchenExposureResetEpoch config variable (T414738)]]

Mentioned in SAL (#wikimedia-operations) [2026-03-30T20:44:34Z] <cjming@deploy1003> cjming, nmw03: Backport for [[gerrit:1264652|Add delete-redirect to filemovers on Wikimedia Commons (T421373)]], [[gerrit:1264653|Add TestKitchenExposureResetEpoch config variable (T414738)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2026-03-30T20:49:38Z] <cjming@deploy1003> Finished scap sync-world: Backport for [[gerrit:1264652|Add delete-redirect to filemovers on Wikimedia Commons (T421373)]], [[gerrit:1264653|Add TestKitchenExposureResetEpoch config variable (T414738)]] (duration: 06m 49s)