Page MenuHomePhabricator

Fix session tick mixin relating to when events fire
Closed, ResolvedPublic5 Estimated Story Points

Assigned To
Authored By
bwang
Feb 14 2025, 5:32 PM
Referenced Files
F58508598: screenshot 50.png
Feb 27 2025, 2:51 AM
F58508590: screenshot 49.png
Feb 27 2025, 2:51 AM
F58508586: screenshot 48.png
Feb 27 2025, 2:51 AM
F58508583: screenshot 47.png
Feb 27 2025, 2:51 AM
F58437394: screenshot 40.png
Feb 24 2025, 10:09 PM
F58437381: screenshot 39.png
Feb 24 2025, 10:09 PM

Description

Background

-Multiple bugs with session tick mixin were discovered, this task is to fix them for the Ab test deploy next week

User story

  • As a data analyst, I need reliable session tick events to do analysis for the AB test

Requirements

  • Session tick 0 is fired immediately the first time the search experience is opened
  • Subsequent ticks are fired every 30 seconds after
  • ticks are paused when the user navigates away from the tab making it inactive
  • After 100 seconds of inactivity (no clicks, scrolling, navigation, etc), the tick events stop, but when the activity is resumed again the ticks continue
  • After 30min of inactivity, and then activity is resumed, the ticks begin again but the action_context gets reset to 0.
  • The patch has been backported to production so we can perform data QA.

BDD

Feature: Ensure session tick events fire correctly for A/B test  

  Scenario: Session tick 0 fires immediately when search is opened  
    Given a user logs in on mobile  
    When they click the search bar for the first time  
    Then a tick event with action context 0 is fired  

  Scenario: Session tick events fire every 30 seconds  
    Given the user has opened the search experience  
    When 30 seconds pass  
    Then a new tick event should fire with an incrementing action context  

  Scenario: Tick events pause when the tab is inactive  
    Given the user has session ticks firing  
    When the user navigates away from the tab  
    Then tick events should stop  

  Scenario: Tick events resume when activity is detected  
    Given tick events stopped due to inactivity  
    When the user navigates back to the tab  
    Then tick events should continue firing  

  Scenario: Tick events stop after 100 seconds of inactivity but resume  
    Given a user has session ticks firing  
    When no user interaction occurs for 100 seconds  
    Then tick events stop  
    When activity resumes  
    Then tick events continue  

  Scenario: Tick events continue after navigation  
    Given session tick events are firing  
    When the user navigates to a different article page  
    Then tick events should continue firing  

  Scenario: Tick events reset action_context after 30 minutes of inactivity  
    Given a user has session ticks firing  
    When the user is inactive for 30 minutes  
    Then tick events should restart  
    And action_context should reset to 0

Test Steps

  1. Log in on mobile.
  2. Open the browser console and enter the following command:
mw.loader.using('mediawiki.api').then(function () {
  new mw.Api().saveOption('eventlogging-display-console', '1');
});
  1. Refresh the page and navigate to an article page.
  2. AC1: Confirm no A/B test events are fired.
  3. Click the search bar.
  4. AC2: Confirm a tick event with action context of 0 is fired.
  5. AC3: Confirm tick events are fired every 30 seconds with an incrementing action context.
  6. Navigate away from the browser tab and wait 5 minutes.
  7. AC4: Confirm that tick events stop while the tab is inactive.
  8. Navigate back to the browser tab.
  9. AC5: Confirm that tick events resume.
  10. Stay on the tab and keep the mouse still for over 100 seconds.
  11. AC6: Confirm that tick events stop after 100 seconds of inactivity.
  12. Resume activity (e.g., move the mouse or click).
  13. AC7: Confirm that tick events resume after user activity.
  14. Navigate to a different article page.
  15. AC8: Confirm that tick events continue after navigation.
  16. Remain inactive for 30 minutes.
  17. Resume activity.
  18. AC9: Confirm that tick events restart with action_context reset to 0 after 30 minutes of inactivity.

QA Results - Beta

QA Results - Prod

ACStatusDetails
1T386495#10585744
2T386495#10585744
3T386495#10585744
4T386495#10585744
5T386495#10585744
6T386495#10585744
7✅ / ❓T386495#10585744 The behavior exhibited already was accepted in beta, I'm just highlighting it here as well.
8T386495#10585744
9T386495#10585744

Event Timeline

bwang triaged this task as High priority.Feb 14 2025, 5:33 PM
bwang updated the task description. (Show Details)

Change #1119565 had a related patch set uploaded (by Bernard Wang; author: Bernard Wang):

[mediawiki/extensions/WikimediaEvents@master] Fix 0 tick not firing for session length mixin, and ensure ticks happen every 30 seconds

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

meeting notes: requires QA in prod (backport to cawiki/euwiki) and verify data integrity and that events are firing.

Jdlrobson-WMF renamed this task from Fix session tick mixin to Fix session tick mixin relating to when events fire.Feb 18 2025, 6:53 PM
Jdlrobson-WMF set the point value for this task to 5.Feb 18 2025, 7:01 PM

Locally tested:

  • zero tick
  • pause and unpause mechanic
  • session tick across pages

Not locally tested:

  • 100 seconds of inactivity
  • 30 minutes of inactivity

Lmk if you have any questions!

Change #1119565 merged by jenkins-bot:

[mediawiki/extensions/WikimediaEvents@master] Fix 0 tick not firing for session length mixin, and ensure ticks happen every 30 seconds

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

Change #1121450 had a related patch set uploaded (by Jdrewniak; author: Bernard Wang):

[mediawiki/extensions/WikimediaEvents@wmf/1.44.0-wmf.17] Fix 0 tick not firing for session length mixin, and ensure ticks happen every 30 seconds

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

Change #1121450 merged by jenkins-bot:

[mediawiki/extensions/WikimediaEvents@wmf/1.44.0-wmf.17] Fix 0 tick not firing for session length mixin, and ensure ticks happen every 30 seconds

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

Mentioned in SAL (#wikimedia-operations) [2025-02-20T22:22:45Z] <jdrewniak@deploy2002> Started scap sync-world: Backport for [[gerrit:1121450|Fix 0 tick not firing for session length mixin, and ensure ticks happen every 30 seconds (T386495)]]

Mentioned in SAL (#wikimedia-operations) [2025-02-20T22:25:25Z] <jdrewniak@deploy2002> jdrewniak: Backport for [[gerrit:1121450|Fix 0 tick not firing for session length mixin, and ensure ticks happen every 30 seconds (T386495)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2025-02-20T22:36:37Z] <jdrewniak@deploy2002> Finished scap sync-world: Backport for [[gerrit:1121450|Fix 0 tick not firing for session length mixin, and ensure ticks happen every 30 seconds (T386495)]] (duration: 13m 52s)

This can be tested in production with test.wikipedia.org. you still need to be bucketed in the experiment group though

Edtadros subscribed.

Status: ✅ PASS / ❓ Needs attention
Environment: Beta
OS: macOS
Browser: Chrome
Device: MS

Test Case 1: Verify session tick events fire correctly

  1. Log in on mobile.
  2. Open the browser console and enter the following command:
mw.loader.using('mediawiki.api').then(function () {
  new mw.Api().saveOption('eventlogging-display-console', '1');
});
  1. Refresh the page and navigate to an article page.
  2. ✅AC1: Confirm no A/B test events are fired.

screenshot 39.png (902×1 px, 227 KB)

  1. Click the search bar.
  2. ✅AC2: Confirm a tick event with action context of 0 is fired.

screenshot 40.png (1×1 px, 311 KB)

  1. ✅AC3: Confirm tick events are fired every 30 seconds with an incrementing action context.

This is confirmed

  1. Navigate away from the browser tab and wait 5 minutes.
  2. ✅AC4: Confirm that tick events stop while the tab is inactive.

This is confirmed

  1. Navigate back to the browser tab.
  2. ✅AC5: Confirm that tick events resume.

This is confirmed

  1. Stay on the tab and keep the mouse still for over 100 seconds.
  2. ✅AC6: Confirm that tick events stop after 100 seconds of inactivity.

This is confirmed

  1. Resume activity (e.g., move the mouse or click).
  2. ✅ / ❓ AC7: Confirm that tick events resume after user activity.

This is questionable. As discussed with Jan, "user activity" isn't very clear here. It does stop at about 100 seconds but resuming doesn’t work that easily. So if I leave the browser to work in another app. Then come back and activate the tab it won’t resume. If I click into the page like into the search field (already open) it doesn’t do anything. But. Clicking out of search and back in resumes. Clicking a different tab and back resumes. The resume logic was not implemented by the Web Team so this should be discussed with the Metrics Platform team (also per Jan)

  1. Navigate to a different article page.
  2. ✅AC8: Confirm that tick events continue after navigation.

this is confirmed

  1. Remain inactive for 30 minutes.
  2. Resume activity.
  3. ✅AC9: Confirm that tick events restart with action_context reset to 0 after 30 minutes of inactivity.

this is confirmed

Jdlrobson-WMF subscribed.

Bernard who should sign this off?

Status: ✅ PASS / ❓ Needs attention
Environment: cawiki
OS: macOS
Browser: Chrome
Device: MS

Test Case 1: Verify session tick events fire correctly

  1. Log in on mobile.
  2. Open the browser console and enter the following command:
mw.loader.using('mediawiki.api').then(function () {
  new mw.Api().saveOption('eventlogging-display-console', '1');
});
  1. Refresh the page and navigate to an article page.
  2. ✅AC1: Confirm no A/B test events are fired.

No AB Test events were fired.

  1. Click the search bar.
  2. ✅AC2: Confirm a tick event with action context of 0 is fired.

screenshot 47.png (1×1 px, 210 KB)

  1. ✅AC3: Confirm tick events are fired every 30 seconds with an incrementing action context.

screenshot 48.png (1×1 px, 307 KB)

  1. Navigate away from the browser tab and wait 5 minutes.
  2. ✅AC4: Confirm that tick events stop while the tab is inactive.

screenshot 49.png (1×1 px, 320 KB)

  1. Navigate back to the browser tab.
  2. ✅AC5: Confirm that tick events resume.

Navigating to an entirely different browser or app then activating the tab does not work. What does work is going from a tab within the same browser window and then back to the tab, this yields an immediate tick.

screenshot 50.png (1×1 px, 306 KB)

  1. Stay on the tab and keep the mouse still for over 100 seconds.
  2. ✅AC6: Confirm that tick events stop after 100 seconds of inactivity.

See AC4, Only 3 tick events happen totalling 90 seconds, so a 4th doesn't appear due to inactivity.

  1. Resume activity (e.g., move the mouse or click).
  2. ✅ / ❓ AC7: Confirm that tick events resume after user activity.

See AC5. Also this is what was discussed during beta testing with Jan, "user activity" isn't very clear here. It does stop at about 100 seconds but resuming doesn’t work that easily. So if I leave the browser to work in another app. Then come back and activate the tab it won’t resume. If I click into the page like into the search field (already open) it doesn’t do anything. But. Clicking out of search and back in resumes. Clicking a different tab and back resumes. The resume logic was not implemented by the Web Team so this should be discussed with the Metrics Platform team (also per Jan)

  1. Navigate to a different article page.
  2. ✅AC8: Confirm that tick events continue after navigation.

this is confirmed

  1. Remain inactive for 30 minutes.
  2. Resume activity.
  3. ✅AC9: Confirm that tick events restart with action_context reset to 0 after 30 minutes of inactivity.

this is confirmed