== Background
Prior to changing to our new print styles, we would like to establish a baseline of the number of users printing on desktop. We would like to look at the following questions:
- How many users are printing per session?
- How many users are printing multiple times per session?
Based on [[https://phabricator.wikimedia.org/T167237#3402915|prior data]], there is probably going to be a substantial amount of daily variation in the data, and also, printing activity may be affected by seasonal changes. So this new data should not be used for any day to day comparisons. But it will give us a better idea of how our print feature is being used.
== AC
[] Create a schema with the following:
Events (which are referred to as actions in [[ https://meta.wikimedia.org/wiki/Schema:Popups | the Popups schema ]]).
- Clicks on the "printable version" link.
- Browser print events (where browser supports it), in form of [[https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeprint |onbeforeprint]]
Properties (for all events):
- `sessionToken` (` = mw.user.sessionId()`)
- `isAnon`
- `pageTitle` (` = mw.config.get( 'wgPageName' )`)
- `namespaceId` (` = mw.config.get( 'wgNamespaceNumber')`)
- `skin` (` = mw.config.get( 'skin')`)
[] The instrumentation will sample by user session and not by pageview.
[] To start with, the sampling rate is 0.1% of all distinct browser sessions.
== Notes
- We are not considering users without JavaScript.
- We cannot tell if the user actually abandons the print, only that they clicked. For instance, various factors including how the print styles look may actually lead to a user abandoning a print, but we will have no idea about that.
- @bmansurov found that Opera would trigger the `beforeprint` event twice (see T171162#3457776). Ensure that it's only handled once.
- Define the instrumentation in the WikimediaEvents extension as Wikimedia-specific and skin-agnostic.
== Closed Questions
[x] Are we tracking prints for all skins or just Vector?
@phuedx: By listening to the the `onbeforeprint`, we should be able to instrument all skins. I've added the `skin` property to the event above.
[x] What is the sampling rate?
~~@phuedx: 0.1% of all distinct browser sessions seems to be a sensible default. This yields a peak rate of [[ https://grafana.wikimedia.org/dashboard/db/eventlogging-schema?var-schema=NavigationTiming&refresh=5m&orgId=1 | 5 events per second for the NavigationTiming instrumentation ]], for example.~~
@Tbayer: Per T169730#3475086, 10% of all distinct browser sessions.
[x] Can we provide a list of browsers which support detecting whether a user has entered print mode?
@phuedx: Per T171162#3457776, listening to the `onbeforeprint` event with a matchMedia API fallback should yield the following coverage:
# IE6+
# Edge 12+
# Firefox for Android 54
# Firefox 6+
# Chrome 9+
# Safari 5.1+
# Opera 12.1+ (though @bmansurov's testing revises this to Opera 15+)
# Opera Mini
# Android Browser 3+
Which I think equates to very nearly all Grade A and Grade C browsers.
See http://caniuse.com/#feat=beforeafterprint and http://caniuse.com/#feat=matchmedia for coverage of the primary and fallback approaches.
== Next
In the longer term we will want to consider the following questions but these should be considered out of scope for this task - please see T169731:
[] Is the overall number of users who print multiple times per session decreasing or increasing after the deployment of the new print styles? (Will likely require an A/B test but that is out of the scope of this task)
[] Can we [[https://phabricator.wikimedia.org/T169730#3446799 | bucket by session]] for an actual A/B test?