From f2083da25547ad9089a8e11728306d6424bf1fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thau=C3=A3=20Silveira?= Date: Wed, 5 Oct 2016 06:42:00 +0200 Subject: [PATCH] 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 | 9 +++++++++ toolkit/content/browser-content.js | 19 +++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 9f6ec33f1373..e496f6a2f93b 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -6289,6 +6289,15 @@ "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], diff --git a/toolkit/content/browser-content.js b/toolkit/content/browser-content.js index 10c1faad3a47..3b9d65e136ed 100644 --- a/toolkit/content/browser-content.js +++ b/toolkit/content/browser-content.js @@ -647,17 +647,23 @@ var Printing = { 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, @@ -683,6 +689,11 @@ var Printing = { } }, + logKeyedTelemetry(id, key) { + let histogram = Services.telemetry.getKeyedHistogramById(id); + histogram.add(key); + }, + updatePageCount() { let numPages = docShell.printPreview.printPreviewNumPages; sendAsyncMessage("Printing:Preview:UpdatePageCount", {