Page MenuHomePhabricator

Wire up new sessionLength instrumentation in search recommendations
Closed, ResolvedPublic2 Estimated Story Points

Description

Background

The stream used by this instrument will be created in https://phabricator.wikimedia.org/T380926

User story

  • As the web team, we need data from our A/B test to make the most informed decision

Requirements

  • Events are fired for session length based off the spec

BDD

Feature: Verify session length events for search recommendations  
  Scenario: Events fire for bucketed users  
    Given a user is bucketed into the A/B test for RelatedArticles  
    When the user interacts with search recommendations  
    Then events should fire as per the specification  

  Scenario: Events do not fire for non-bucketed users  
    Given a user is not bucketed into the A/B test for RelatedArticles  
    When the user interacts with search recommendations  
    Then no events should fire for session length

Test Steps

Test Case 1: Verify events for bucketed users

  1. Open an incognito window and visit https://en.m.wikipedia.beta.wmflabs.org/w/index.php?title=T352930.
  2. Use the following code in the JavaScript console as a logged-in user:
mw.loader.using( 'mediawiki.api' ).then( function () {  
  new mw.Api().saveOption( 'eventlogging-display-console', '1' );  
} );
  1. Interact with search recommendations (e.g., open the search bar, click a recommendation).
  2. Monitor the browser console for session length events.
  3. Verify that the events are firing correctly and include relevant fields as per the spec.
  4. AC1: Events fire for bucketed users and contain required fields.

Test Case 2: Verify no events for non-bucketed users

  1. Open an incognito window and visit https://en.m.wikipedia.beta.wmflabs.org/w/index.php?title=T352930.
  2. Use the same JavaScript code in the console as a logged-in user:
mw.loader.using( 'mediawiki.api' ).then( function () {  
  new mw.Api().saveOption( 'eventlogging-display-console', '1' );  
} );
  1. Confirm that you are not bucketed into the A/B test (e.g., no search recommendations appear).
  2. Perform similar interactions as in Test Case 1.
  3. Verify that no session length events are fired in the browser console.
  4. AC2: No events fire for non-bucketed users.

Design

  • none

Acceptance criteria

  • Instrumentation fires for each item in the spec and with the correct fields

Communication criteria - does this need an announcement or discussion?

  • no

QA Results - Beta

ACStatusDetails
1T381604#10494965
2T381604#10494965

Event Timeline

bwang triaged this task as High priority.Dec 5 2024, 5:56 PM
bwang edited projects, added: Web-Team; removed: Web-Team-Backlog-Archived.
Jdlrobson changed the task status from Open to In Progress.Dec 5 2024, 6:10 PM
Jdlrobson renamed this task from Implement instrumentation spec for search recommendations to Implement sessionTick instrumentation spec for search recommendations.Dec 12 2024, 5:46 PM
bwang renamed this task from Implement sessionTick instrumentation spec for search recommendations to Use new sessionLength instrumentation in search recommendations.Dec 16 2024, 9:22 PM
bwang updated the task description. (Show Details)
bwang updated the task description. (Show Details)
ovasileva raised the priority of this task from High to Unbreak Now!.Jan 13 2025, 11:33 AM
ovasileva lowered the priority of this task from Unbreak Now! to High.
bwang renamed this task from Use new sessionLength instrumentation in search recommendations to Write up new sessionLength instrumentation in search recommendations.Jan 13 2025, 8:34 PM
SToyofuku-WMF renamed this task from Write up new sessionLength instrumentation in search recommendations to Wire up new sessionLength instrumentation in search recommendations.Jan 13 2025, 9:10 PM
Jdlrobson set the point value for this task to 2.Jan 14 2025, 5:33 PM

Q: Where are we planning to call the sessionLength mixin?
A: Starts when the A/B test starts. The mixin would start ticking and send an integer once a minute with an associated session id and the name of the event. It would stop automatically after 30 minutes if the session ends but we don't need to explicitly stop it. Closing browser would also stop the instrumentation.

bwang removed bwang as the assignee of this task.Jan 14 2025, 6:12 PM

Change #1111722 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/WikimediaEvents@master] WIP: Instrument empty search experiment

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

Change #1111722 merged by jenkins-bot:

[mediawiki/extensions/WikimediaEvents@master] Instrument empty search experiment

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

In terms of QA, for now we just want to verify that events are firing at different per the requirements on https://en.m.wikipedia.beta.wmflabs.org/w/index.php?title=T352930 when bucketed and when not bucketed (you have a 50% chance in an incognito window of either bucket).

You can surface events as a logged in user using the following code:

Please note the code might take some time to show up on beta cluster (hopefully will be there by 4 PST) to ensure the latest code is running on beta cluster.

mw.loader.using( 'mediawiki.api' ).then( function () {
  new mw.Api().saveOption( 'eventlogging-display-console', '1' );
} );
Edtadros subscribed.

Status: ✅ PASS
Environment: Beta
OS: macOS
Browser: Chrome
Device: MS

Test Case 1: Verify events for bucketed users

  1. Open an incognito window and visit https://en.m.wikipedia.beta.wmflabs.org/w/index.php?title=T352930.
  2. Log in to a user account.
  3. Open the JavaScript console and execute the following code:
mw.loader.using( 'mediawiki.api' ).then( function () {  
  new mw.Api().saveOption( 'eventlogging-display-console', '1' );  
} );
  1. Interact with search recommendations (e.g., open the search bar, click a recommendation).
  2. Observe the browser console for session length events.
  3. AC1: Events fire for bucketed users and include the required fields as per the specification.
{
    "$schema": "/analytics/session_tick/2.0.0",
    "tick": 9,
    "dt": "2025-01-25T18:35:37.314Z",
    "meta": {
        "stream": "mediawiki.client.session_tick",
        "domain": "en.wikipedia.beta.wmflabs.org"
    }
}

Test Case 2: Verify no events for non-bucketed users

  1. Open an incognito window and visit https://en.m.wikipedia.beta.wmflabs.org/w/index.php?title=T352930.
  2. Log in to a user account.
  3. Open the JavaScript console and execute the following code:
mw.loader.using( 'mediawiki.api' ).then( function () {  
  new mw.Api().saveOption( 'eventlogging-display-console', '1' );  
} );
  1. Confirm that you are not bucketed into the A/B test (e.g., no search recommendations are displayed).
  2. Interact with the search interface as in Test Case 1.
  3. Verify that no session length events are fired in the browser console.
  4. AC2: No events fire for non-bucketed users.

I was able to get a non bucketed instance, and no session_tick events fired

{
    "wiki": "enwiki",
    "skin": "minerva",
    "is_bot": false,
    "$schema": "/analytics/mediawiki/web_ab_test_enrollment/2.0.0",
    "web_session_id": "ca081e936edf914d967a",
    "group": "experimentDisabled",
    "experiment_name": "RelatedArticles test experiment betacluster\t",
    "is_anon": false,
    "dt": "2025-01-25T18:44:54.987Z",
    "meta": {
        "stream": "mediawiki.web_ab_test_enrollment",
        "domain": "en.wikipedia.beta.wmflabs.org"
    }
}

screenshot 140.png (1,375×338 px, 127 KB)

Jdlrobson-WMF claimed this task.