Bug 1306624 - Add telemetry probes to count how many times a user requests to print a document. r=mconley, data-review=liuche
authorThauã Silveira <thaua@hp.com>
Wed, 05 Oct 2016 06:42:00 +0200
changeset 317263 1ee5506cde86ec25d9cc9d5212986941f7451857
parent 317234 bfe9d976f7509cf82989edbac61d56eb3fa4f2c5
child 317264 4c17e2d68479d6682fab60d40ca3b60e0de13f45
push id30800
push userphilringnalda@gmail.com
push dateTue, 11 Oct 2016 02:08:53 +0000
treeherdermozilla-central@ece56e142a1e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1306624
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1306624 - Add telemetry probes to count how many times a user requests to print a document. r=mconley, data-review=liuche
toolkit/components/telemetry/Histograms.json
toolkit/content/browser-content.js
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -6284,16 +6284,25 @@
   "PRINT_PREVIEW_SIMPLIFY_PAGE_UNAVAILABLE_COUNT": {
      "alert_emails": ["carnold@mozilla.org"],
      "bug_numbers": [1287587],
      "expires_in_version": "56",
      "kind": "count",
      "releaseChannelCollection": "opt-out",
      "description": "A counter incremented every time the simplified mode is unavailable on print preview."
    },
+  "PRINT_DIALOG_OPENED_COUNT": {
+    "alert_emails": ["carnold@mozilla.org"],
+    "bug_numbers": [1306624],
+    "expires_in_version": "56",
+    "kind": "count",
+    "keyed": true,
+    "releaseChannelCollection": "opt-out",
+    "description": "A counter incremented every time the user opens print dialog."
+  },
   "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."
--- a/toolkit/content/browser-content.js
+++ b/toolkit/content/browser-content.js
@@ -642,27 +642,33 @@ var Printing = {
     // "about:blank" as its URI.
     if (printSettings && simplifiedMode) {
       printSettings.docURL = contentWindow.document.baseURI;
     }
 
     try {
       let print = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
                                .getInterface(Ci.nsIWebBrowserPrint);
+
+      if (print.doingPrintPreview) {
+        this.logKeyedTelemetry("PRINT_DIALOG_OPENED_COUNT", "FROM_PREVIEW");
+      } else {
+        this.logKeyedTelemetry("PRINT_DIALOG_OPENED_COUNT", "FROM_PAGE");
+      }
+
       print.print(printSettings, null);
 
-      let histogram = Services.telemetry.getKeyedHistogramById("PRINT_COUNT");
       if (print.doingPrintPreview) {
         if (simplifiedMode) {
-          histogram.add("SIMPLIFIED");
+          this.logKeyedTelemetry("PRINT_COUNT", "SIMPLIFIED");
         } else {
-          histogram.add("WITH_PREVIEW");
+          this.logKeyedTelemetry("PRINT_COUNT", "WITH_PREVIEW");
         }
       } else {
-        histogram.add("WITHOUT_PREVIEW");
+        this.logKeyedTelemetry("PRINT_COUNT", "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", {
@@ -678,16 +684,21 @@ var Printing = {
 
       PSSVC.savePrintSettingsToPrefs(printSettings, true,
                                      printSettings.kInitSaveAll);
       PSSVC.savePrintSettingsToPrefs(printSettings, false,
                                      printSettings.kInitSavePrinterName);
     }
   },
 
+  logKeyedTelemetry(id, key) {
+    let histogram = Services.telemetry.getKeyedHistogramById(id);
+    histogram.add(key);
+  },
+
   updatePageCount() {
     let numPages = docShell.printPreview.printPreviewNumPages;
     sendAsyncMessage("Printing:Preview:UpdatePageCount", {
       numPages: numPages,
     });
   },
 
   navigate(navType, pageNum) {