From 97dbc43821cbcf2e6b3393c427e8cd326f61bcf9 Mon Sep 17 00:00:00 2001 From: Monica Chew Date: Thu, 28 Aug 2014 09:29:14 -0700 Subject: [PATCH] Bug 1058133: Telemetry for tracking protection events (r=bmcbride) --- browser/base/content/browser.js | 23 ++++++++++++++++++++ browser/base/content/urlbarBindings.xml | 8 +++++++ toolkit/components/telemetry/Histograms.json | 17 +++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index ae6e274f37c..833861f9b3e 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1279,6 +1279,12 @@ var gBrowserInit = { Services.telemetry.getHistogramById("MASTER_PASSWORD_ENABLED").add(mpEnabled); } }, 5000); + + // Telemetry for tracking protection. + let tpEnabled = gPrefService + .getBoolPref("privacy.trackingprotection.enabled"); + Services.telemetry.getHistogramById("TRACKING_PROTECTION_ENABLED") + .add(tpEnabled); }); this.delayedStartupFinished = true; @@ -6496,6 +6502,10 @@ var gIdentityHandler = { nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT | nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT)) { this.showBadContentDoorhanger(state); + } else { + // We didn't show the shield + Services.telemetry.getHistogramById("TRACKING_PROTECTION_SHIELD") + .add(0); } }, @@ -6517,6 +6527,19 @@ var gIdentityHandler = { // default let iconState = "bad-content-blocked-notification-icon"; + // Telemetry for whether the shield was due to tracking protection or not + let histogram = Services.telemetry.getHistogramById + ("TRACKING_PROTECTION_SHIELD"); + if (state & Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT) { + histogram.add(1); + } else if (state & + Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT) { + histogram.add(2); + } else { + // The shield is due to mixed content, just keep a count so we can + // normalize later. + histogram.add(3); + } if (state & (Ci.nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT | Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT)) { diff --git a/browser/base/content/urlbarBindings.xml b/browser/base/content/urlbarBindings.xml index 1cf8c49120e..c6e41d1d342 100644 --- a/browser/base/content/urlbarBindings.xml +++ b/browser/base/content/urlbarBindings.xml @@ -1819,6 +1819,10 @@ // places this host on the tracking protection white list. Services.perms.add(normalizedUrl, "trackingprotection", Services.perms.ALLOW_ACTION); + // Telemetry for disable protection + let histogram = Services.telemetry.getHistogramById( + "TRACKING_PROTECTION_EVENTS"); + histogram.add(1); BrowserReload(); ]]> @@ -1829,6 +1833,10 @@ // from the tracking protection white list (any list actually). Services.perms.remove(gBrowser.selectedBrowser.currentURI.host, "trackingprotection"); + // Telemetry for enable protection + let histogram = Services.telemetry.getHistogramById( + "TRACKING_PROTECTION_EVENTS"); + histogram.add(2); BrowserReload(); ]]> diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index f731a978769..b1abd651407 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -6506,5 +6506,22 @@ "high": "10000000", "n_buckets": 10, "description": "Sidebar showing: seconds that the sidebar has been opened" + }, + "TRACKING_PROTECTION_ENABLED": { + "expires_in_version": "never", + "kind": "boolean", + "description": "Whether or not a session has tracking protection enabled" + }, + "TRACKING_PROTECTION_SHIELD": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 4, + "description": "Tracking protection shield (0 = not shown, 1 = blocked, 2 = loaded, 3 = due to mixed content" + }, + "TRACKING_PROTECTION_EVENTS": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 3, + "description": "Doorhanger shown = 0, Disable = 1, Enable = 2" } }