In a few analyses, we have begun to suspect that we are recording fewer sessions than we should expect given our pageviews, unique devices, and chosen sampling rate. We wondered if the sessionTick instrument was perhaps not sending tick 0 immediately on page load, but was instead waiting until after the first interval (tick) had passed. However this was not the case. As written, tick 0 should be sent immediately on page load. There could be some latency from the event output buffer (which we should measure and quantify or work around if necessary), but not enough to explain the numbers we see.
While testing on Firefox 80.0, it was found that sessionTick events would not fire, and the reason was traced to mw.requestIdleCallback, which is simply window.requestIdleCallback during these tests, pointing perhaps to an upstream bug in detecting idle states. Adding a manual timeout value (50ms was chosen, in line with the requestIdleCallback polyfill in mw.startup) solved the issue.
It's unknown how many browsers may be affected by this, or if this alone explains the missing sessions. I will update the description as we learn more.
Needed for QA:
- @jlinehan checks error logs, resolves the increase in errors since patch was deployed
- @cchen verifies that session counts > unique devices
- @mpopov re-test session ticks (https://docs.google.com/spreadsheets/d/1IWBXKzMT--SmlrJ17bjK4eAHf4aXdsnCqoltD4Ni-l4/edit#gid=0)