Bug 1287587 - Add more telemetry probes for gathering data on the Simplify Page feature for Print Preview. r=mconley, a=sledru
authorThauã Silveira <thaua@hp.com>
Mon, 25 Jul 2016 12:07:00 -0400
changeset 340130 bb3556aea128783493a9d505aab8cab2b081a027
parent 340129 587fb55f71b54e64522709f587e5c1897c055ce2
child 340131 11204e05dff9e25706f51673c3f7a57880b86534
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley, sledru
bugs1287587
milestone49.0a2
Bug 1287587 - Add more telemetry probes for gathering data on the Simplify Page feature for Print Preview. r=mconley, a=sledru
toolkit/components/printing/content/printUtils.js
toolkit/components/telemetry/Histograms.json
toolkit/content/browser-content.js
--- a/toolkit/components/printing/content/printUtils.js
+++ b/toolkit/components/printing/content/printUtils.js
@@ -192,16 +192,19 @@ var PrintUtils = {
     // if we're already in PP mode, don't set the listener; chances
     // are it is null because someone is calling printPreview() to
     // get us to refresh the display.
     if (!this.inPrintPreview) {
       this._listener = aListenerObj;
       this._sourceBrowser = aListenerObj.getSourceBrowser();
       this._originalTitle = this._sourceBrowser.contentTitle;
       this._originalURL = this._sourceBrowser.currentURI.spec;
+
+      // Here we log telemetry data for when the user enters print preview.
+      this.logTelemetry("PRINT_PREVIEW_OPENED_COUNT");
     } else {
       // collapse the browser here -- it will be shown in
       // enterPrintPreview; this forces a reflow which fixes display
       // issues in bug 267422.
       this._sourceBrowser = this._listener.getPrintPreviewBrowser();
       this._sourceBrowser.collapsed = true;
     }
 
@@ -630,16 +633,22 @@ var PrintUtils = {
       this._sourceBrowser.focus();
     gFocusedElement = null;
 
     this.setSimplifiedMode(false);
 
     this._listener.onExit();
   },
 
+  logTelemetry: function (ID)
+  {
+    let histogram = Services.telemetry.getHistogramById(ID);
+    histogram.add(true);
+  },
+
   onKeyDownPP: function (aEvent)
   {
     // Esc exits the PP
     if (aEvent.keyCode == aEvent.DOM_VK_ESCAPE) {
       PrintUtils.exitPrintPreview();
     }
   },
 
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -5879,16 +5879,33 @@
     "expires_in_version": "52",
     "kind": "exponential",
     "keyed": true,
     "low": 200,
     "high": 20000,
     "n_buckets": 50,
     "description": "(Bug 1207089) Time in ms between displaying a popup notification and dismissing it without an action the first time, keyed by ID"
   },
+  "PRINT_PREVIEW_OPENED_COUNT": {
+    "alert_emails": ["carnold@mozilla.org"],
+    "bug_numbers": [1275570],
+    "expires_in_version": "56",
+    "kind": "count",
+    "releaseChannelCollection": "opt-out",
+    "description": "A counter incremented every time the browser enters print preview."
+  },
+  "PRINT_COUNT": {
+    "alert_emails": ["carnold@mozilla.org"],
+    "bug_numbers": [1287587],
+    "expires_in_version": "56",
+    "kind": "count",
+    "keyed": true,
+    "releaseChannelCollection": "opt-out",
+    "description": "A counter incremented every time the user prints a document."
+  },
   "DEVTOOLS_DEBUGGER_RDP_LOCAL_RELOAD_MS": {
     "expires_in_version": "never",
     "kind": "exponential",
     "high": 10000,
     "n_buckets": 1000,
     "description": "The time (in milliseconds) that it took a 'reload' request to go round trip."
   },
   "DEVTOOLS_DEBUGGER_RDP_REMOTE_RELOAD_MS": {
--- a/toolkit/content/browser-content.js
+++ b/toolkit/content/browser-content.js
@@ -633,16 +633,23 @@ var Printing = {
 
   print(contentWindow) {
     let printSettings = this.getPrintSettings();
     let rv = Cr.NS_OK;
     try {
       let print = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
                                .getInterface(Ci.nsIWebBrowserPrint);
       print.print(printSettings, null);
+
+      let histogram = Services.telemetry.getKeyedHistogramById("PRINT_COUNT");
+      if (print.doingPrintPreview) {
+        histogram.add("WITH_PREVIEW");
+      } else {
+        histogram.add("WITHOUT_PREVIEW");
+      }
     } catch(e) {
       // Pressing cancel is expressed as an NS_ERROR_ABORT return value,
       // causing an exception to be thrown which we catch here.
       if (e.result != Cr.NS_ERROR_ABORT) {
         Cu.reportError(`In Printing:Print:Done handler, got unexpected rv
                         ${e.result}.`);
         sendAsyncMessage("Printing:Error", {
           isPrinting: true,