Page MenuHomePhabricator

Spike on instrumenting session length
Closed, ResolvedPublic3 Estimated Story PointsSpike

Description

Session length will be the StickyHeaders experiment's primary metric, see T409163: Set up measurement plan and instrumentation spec for mobile sticky headers.
There are two available implementations with overlapping logic:

@jwang suggests the following from a past instrumentation effort:

the search recommendation feature had session length tracking enabled before. It fired events every 30 seconds, starting when the search box was focused. In the analysis, we count the maximum number of tick events to determine the session length.
Here is the instrumentation spec of search recommendation. I think we could do similar tracking, but change the trigger to when the user loads the page. (FYI. this tick method starts from page load)

Determine whether one of the implementations can be re-used.

NOTE: both implementations send events through EventLogging, namely mw.eventLog.submit and mw.eventLog.submitInteraction. These calls should be replaced with mw.xLab.Experiment#send.

Output of spike: confirmed we want to tweak WikimediaEvents' SessionLengthInstrumentMixin to be xLab-Experiment-friendly as a short-term solution and are happy to help out ́Experiment Platform with a patch from our end, if they can provide code review.

Breaking out the implementation work to T410533, moving the WIP patches over there for further work.

Event Timeline

If I'm reading correctly, the WikimediaEvents system will track session lengths if wgWMESessionTick is enabled in MediaWiki config which ... I can confirm is enabled on both beta and production wikis.

Do we need to do anything additional to get those session ticks associated with our experiment data? Or do we have any special requirements that differ from what's normally tracked?

mfossati changed the subtype of this task from "Task" to "Spike".Nov 13 2025, 11:44 AM

Do we need to do anything additional to get those session ticks associated with our experiment data?

Yes, we'll have to bind the instrument to our xLab experiment.
This is done in ImageBrowsing as follows:

Or do we have any special requirements that differ from what's normally tracked?

I think we should stick to @jwang 's suggestion and check whether available implementations fit.

This is done in ImageBrowsing as follows:

Excellent I'll poke further at this today...

I think we should stick to @jwang 's suggestion and check whether available implementations fit.

*nod*

Looks like sessionTick.js saves into a specific event (mediawiki.client.session_tick) and schema (/analytics/session_tick/2.0.0), so either we'd have to modify it to accept our data, or use a port or different method though that would be extended if need be.

Now to look into SessionLength mixin in more detail :D

Ok, the SessionLength mixin looks perfect. Starting on a proof of concept patch just to make sure I understand what it looks like (then I presume we have to finalize the schema details)

Change #1205212 had a related patch set uploaded (by Bvibber; author: Bvibber):

[mediawiki/extensions/ReaderExperiments@master] WIP Sticky Headers: provisional code for instrumentation setup

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

Change #1206441 had a related patch set uploaded (by Bvibber; author: Bvibber):

[mediawiki/extensions/WikimediaEvents@master] WIP Adapt xLab Instrument support in SessionLengthInstrumentMixin

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

Output of spike: confirmed we want to tweak WikimediaEvents' SessionLengthInstrumentMixin to be xLab-Experiment-friendly as a short-term solution and are happy to help out ́Experiment Platform with a patch from our end, if they can provide code review.

Breaking out the implementation work to T410533, I'll move the WIP patches over there for further work and code review.

Follow-up work ongoing! Closing