Bug 1306624 - Add telemetry probes to count how many times a user requests to print a document. r=mconley, data-review=liuche a=ritu
authorThauã Silveira <thaua@hp.com>
Wed, 05 Oct 2016 06:42:00 +0200
changeset 875973 684b31fa5cb1c69bcb7c25f7d57e31057c813b71
parent 875972 f60b2c0f87c04660422d13b9cac5e6762b0e7c98
child 875974 d33b1329a44d70645ee3bfc7b87063de4da8c54a
push id151235
push userphilringnalda@gmail.com
push dateTue, 25 Oct 2016 02:01:17 +0000
treeherdertry@98f56a8216a9 [default view] [failures only]
reviewersmconley, ritu
bugs1306624
milestone51.0a2
Bug 1306624 - Add telemetry probes to count how many times a user requests to print a document. r=mconley, data-review=liuche a=ritu
toolkit/components/telemetry/Histograms.json
toolkit/content/browser-content.js
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -6161,16 +6161,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) {