Page MenuHomePhabricator

MediaWiki Session ID should persist according to user inactivity
Closed, ResolvedPublic

Description

Our notion of session as implemented in sessionTick needs to be the same as the notion of session that governs the lifespan of a Session ID memoized by mw.user.sessionId.

Currently this is not the case, as the value of mw.user.sessionId is a session cookie and consequently has a different TTL (one not based on user inactivity).

Potential solutions involve finding a home for the code dedicated to detecting a session boundary from sessionTick (as discussed on the patch).

Considerations

  • Placing this code in mw.user may be weird
  • Placing the code in ext.WikimediaEvents or ext.EventLogging would restrict usage of this session ID to clients with those modules loaded
  • Relocating the relevant code from sessionTick is going to (rightly so) trigger a new review

Acceptance Criteria

  • As a data scientist, I am able to change the sampling rate as defined by sessionTick (aka end of a "session" = inactivity for 30 minutes)

Event Timeline

@jlinehan: In which codebase would such changes have to take place?

Placing the code in ext.wikimediaEvents or ext.eventLogging would restrict usage of this session ID to clients with those modules loaded

Both of these are loaded unconditionally on production page loads of all kinds. If the code is standalone or augmentative/reactive in nature, it can live in wmE. If it needs to export an interface to be called programmatically from within code in individual features, then it can live in EL (since wmE cannot be depended on as it is wmf-specific).

@jlinehan: In which codebase would such changes have to take place?

I thought I replied to this days ago but my comment is not here. The interface in question lives today in MediaWiki core (specifically, mw.user.sessionId), however we may introduce a new interface rather than modify the one in core (for various reasons e.g. potential to complicate mw.user, breaking existing callers of mw.user.sessionId that use it for things besides analytics, so on...). In that case, such an interface will likely be sited somewhere in extensions WikimediaEvents (where the relevent session tracking code lives today) and/or (possibly) EventLogging.

Placing the code in ext.wikimediaEvents or ext.eventLogging would restrict usage of this session ID to clients with those modules loaded

Both of these are loaded unconditionally on production page loads of all kinds. If the code is standalone or augmentative/reactive in nature, it can live in wmE. If it needs to export an interface to be called programmatically from within code in individual features, then it can live in EL (since wmE cannot be depended on as it is wmf-specific).

It will likely be EL in that case, but I will follow up here when I make a full assessment.

Sampling session lengths should be done with a token that uses the same semantics as the sessions themselves, so this is a dependency of sampling the session tick data stream.

sdkim updated the task description. (Show Details)
sdkim added a project: Better Use Of Data.

Change 659060 had a related patch set uploaded (by Jason Linehan; owner: Jason Linehan):
[mediawiki/extensions/EventLogging@master] [WIP] Sampling logic and session/pageview token support

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

Uploaded WIP patch for engineers to discuss if desired at BUOD meeting. Not tested yet while I wrestle with my vagrant install but the point is clear. Will test, iterate patchsets and add tests from here.

Change 659060 merged by jenkins-bot:
[mediawiki/extensions/EventLogging@master] Sampling logic and session/pageview id support

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

kzimmerman triaged this task as Medium priority.Mon, Feb 8, 7:30 PM