== b== 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.
== acceptance criteria== AC
 Create a schema on desktop 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):
- `S- `sessiontToken` (as in e.g. [[https://meta.wikimedia.org/wiki/Schema:Popups | Schema:Popups]])` = mw.user.sessionId()`)
- Whether user is logged-in, logged-out- `pageTitle` (` = mw.config.get( 'wgPageName' )`)
- Page name- `namespaceId` (` = mw.config.get( 'wgNamespaceNumber')`)
- Page namespace ID- `skin` (` = mw.config.get( 'skin')`)
 The user will be sampled per session (not per pageview)instrumentation will sample by user session and not by pageview.
 To start with, the sampling rate is 0.1% of all distinct browser sessions.
== Developer nNotes
- It's not reliably possible for all browsers to detect whether a user has entered print mode (https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeprint). This part of the instrumentation will thus be limited to certain browsers.
- 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.
= Open qQuestions
 Can we provide a list of browsers which support detecting whether a user has entered print mode?
== Closed Questions
[x] Are we tracking prints for all skins or just Vector?
 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?
 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.
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?