Bug 1484251 - Part 3 - Use Telemetry events to record interactions in the identity popup. r=Gijs
authorJohann Hofmann <jhofmann@mozilla.com>
Thu, 11 Oct 2018 13:13:58 +0000
changeset 499153 8794df889e3fc61be3f1fc17e65f59d18f5d2d83
parent 499152 734669014545775f6ff6cc63d8354bbec4b5ba7b
child 499154 29d9b2d2192d80733b6be89a31816d97ffda9163
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1484251
milestone64.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 1484251 - Part 3 - Use Telemetry events to record interactions in the identity popup. r=Gijs This removes the old TRACKING_PROTECTION_EVENTS probe and replaces it with new Telemetry events that record basic user interaction in the identity popup. We are now measuring interaction with more elements than before, not just block/unblock. We're also dropping the old way of measuring updates to onSecurityChange, since with the recent changes to content blocking it would just record most page loads. Differential Revision: https://phabricator.services.mozilla.com/D6895
browser/app/profile/firefox.js
browser/base/content/browser-contentblocking.js
browser/base/content/browser-siteIdentity.js
browser/components/controlcenter/content/panel.inc.xul
browser/components/nsBrowserGlue.js
toolkit/components/telemetry/Events.yaml
toolkit/components/telemetry/Histograms.json
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1287,16 +1287,18 @@ pref("pdfjs.firstRun", true);
 // The values of preferredAction and alwaysAskBeforeHandling before pdf.js
 // became the default.
 pref("pdfjs.previousHandler.preferredAction", 0);
 pref("pdfjs.previousHandler.alwaysAskBeforeHandling", false);
 
 // Is the sidebar positioned ahead of the content browser
 pref("sidebar.position_start", true);
 
+pref("security.identitypopup.recordEventElemetry", true);
+
 // Block insecure active content on https pages
 pref("security.mixed_content.block_active_content", true);
 
 // Show degraded UI for http pages with password fields.
 pref("security.insecure_password.ui.enabled", true);
 
 // Show in-content login form warning UI for insecure login fields
 pref("security.insecure_field_warning.contextual.enabled", true);
--- a/browser/base/content/browser-contentblocking.js
+++ b/browser/base/content/browser-contentblocking.js
@@ -1,14 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 var FastBlock = {
   reportBreakageLabel: "fastblock",
+  telemetryIdentifier: "fb",
   PREF_ENABLED: "browser.fastblock.enabled",
   PREF_UI_ENABLED: "browser.contentblocking.fastblock.control-center.ui.enabled",
 
   get categoryItem() {
     delete this.categoryItem;
     return this.categoryItem = document.getElementById("identity-popup-content-blocking-category-fastblock");
   },
 
@@ -19,16 +20,17 @@ var FastBlock = {
 
   isBlockerActivated(state) {
     return state & Ci.nsIWebProgressListener.STATE_BLOCKED_SLOW_TRACKING_CONTENT;
   },
 };
 
 var TrackingProtection = {
   reportBreakageLabel: "trackingprotection",
+  telemetryIdentifier: "tp",
   PREF_ENABLED_GLOBALLY: "privacy.trackingprotection.enabled",
   PREF_ENABLED_IN_PRIVATE_WINDOWS: "privacy.trackingprotection.pbmode.enabled",
   PREF_UI_ENABLED: "browser.contentblocking.trackingprotection.control-center.ui.enabled",
   enabledGlobally: false,
   enabledInPrivateWindows: false,
 
   get categoryItem() {
     delete this.categoryItem;
@@ -120,16 +122,17 @@ var TrackingProtection = {
 
   isBlockerActivated(state) {
     return state & Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT;
   },
 };
 
 var ThirdPartyCookies = {
   reportBreakageLabel: "cookierestrictions",
+  telemetryIdentifier: "cr",
   PREF_ENABLED: "network.cookie.cookieBehavior",
   PREF_REPORT_BREAKAGE_ENABLED: "browser.contentblocking.rejecttrackers.reportBreakage.enabled",
   PREF_ENABLED_VALUES: [
     // These values match the ones exposed under the Content Blocking section
     // of the Preferences UI.
     Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN,  // Block all third-party cookies
     Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER,  // Block third-party cookies from trackers
   ],
@@ -429,23 +432,16 @@ var ContentBlocking = {
     // Save this URI to make sure that the user really only submits the location
     // they see in the report breakage dialog.
     this.reportURI = gBrowser.currentURI;
     let urlWithoutQuery = this.reportURI.asciiSpec.replace("?" + this.reportURI.query, "");
     this.reportBreakageURL.textContent = urlWithoutQuery;
     this.identityPopupMultiView.showSubView("identity-popup-breakageReportView");
   },
 
-  eventsHistogramAdd(value) {
-    if (PrivateBrowsingUtils.isWindowPrivate(window)) {
-      return;
-    }
-    Services.telemetry.getHistogramById("TRACKING_PROTECTION_EVENTS").add(value);
-  },
-
   shieldHistogramAdd(value) {
     if (PrivateBrowsingUtils.isWindowPrivate(window)) {
       return;
     }
     Services.telemetry.getHistogramById("TRACKING_PROTECTION_SHIELD").add(value);
   },
 
   onSecurityChange(oldState, state, webProgress, isSimulated,
@@ -534,55 +530,46 @@ var ContentBlocking = {
       this.shieldHistogramAdd(1);
     } else if (active) {
       this.iconBox.setAttribute("tooltiptext", this.activeTooltipText);
       this.shieldHistogramAdd(2);
     } else {
       this.iconBox.removeAttribute("tooltiptext");
       this.shieldHistogramAdd(0);
     }
-
-    // Telemetry for state change.
-    this.eventsHistogramAdd(0);
   },
 
   disableForCurrentPage() {
     let baseURI = this._baseURIForChannelClassifier;
 
     // Add the current host in the 'trackingprotection' consumer of
     // the permission manager using a normalized URI. This effectively
     // places this host on the tracking protection allowlist.
     if (PrivateBrowsingUtils.isBrowserPrivate(gBrowser.selectedBrowser)) {
       PrivateBrowsingUtils.addToTrackingAllowlist(baseURI);
     } else {
       Services.perms.add(baseURI,
         "trackingprotection", Services.perms.ALLOW_ACTION);
     }
 
-    // Telemetry for disable protection.
-    this.eventsHistogramAdd(1);
-
     this.hideIdentityPopupAndReload();
   },
 
   enableForCurrentPage() {
     // Remove the current host from the 'trackingprotection' consumer
     // of the permission manager. This effectively removes this host
     // from the tracking protection allowlist.
     let baseURI = this._baseURIForChannelClassifier;
 
     if (PrivateBrowsingUtils.isBrowserPrivate(gBrowser.selectedBrowser)) {
       PrivateBrowsingUtils.removeFromTrackingAllowlist(baseURI);
     } else {
       Services.perms.remove(baseURI, "trackingprotection");
     }
 
-    // Telemetry for enable protection.
-    this.eventsHistogramAdd(2);
-
     this.hideIdentityPopupAndReload();
   },
 
   dontShowIntroPanelAgain() {
     if (!PrivateBrowsingUtils.isBrowserPrivate(gBrowser.selectedBrowser)) {
       Services.prefs.setIntPref(this.prefIntroCount, this.MAX_INTROS);
       Services.prefs.savePrefFile(null);
     }
--- a/browser/base/content/browser-siteIdentity.js
+++ b/browser/base/content/browser-siteIdentity.js
@@ -239,16 +239,24 @@ var gIdentityHandler = {
 
     event.stopPropagation();
   },
 
   openPermissionPreferences() {
     openPreferences("privacy-permissions", { origin: "identityPopup-permissions-PreferencesButton" });
   },
 
+  recordClick(object) {
+    let extra = {};
+    for (let blocker of ContentBlocking.blockers) {
+      extra[blocker.telemetryIdentifier] = blocker.activated ? "true" : "false";
+    }
+    Services.telemetry.recordEvent("security.ui.identitypopup", "click", object, null, extra);
+  },
+
   /**
    * Handler for mouseclicks on the "More Information" button in the
    * "identity-popup" panel.
    */
   handleMoreInfoClick(event) {
     displaySecurityInfo();
     event.stopPropagation();
     PanelMultiView.hidePopup(this._identityPopup);
@@ -836,16 +844,24 @@ var gIdentityHandler = {
     PanelMultiView.openPopup(this._identityPopup, this._identityIcon,
                              "bottomcenter topleft").catch(Cu.reportError);
   },
 
   onPopupShown(event) {
     if (event.target == this._identityPopup) {
       window.addEventListener("focus", this, true);
     }
+
+    let extra = {};
+    for (let blocker of ContentBlocking.blockers) {
+      extra[blocker.telemetryIdentifier] = blocker.activated ? "true" : "false";
+    }
+
+    let shieldStatus = ContentBlocking.iconBox.hasAttribute("active") ? "shield-showing" : "shield-hidden";
+    Services.telemetry.recordEvent("security.ui.identitypopup", "open", "identity_popup", shieldStatus, extra);
   },
 
   onPopupHidden(event) {
     if (event.target == this._identityPopup) {
       window.removeEventListener("focus", this, true);
       this._identityBox.removeAttribute("open");
     }
   },
--- a/browser/components/controlcenter/content/panel.inc.xul
+++ b/browser/components/controlcenter/content/panel.inc.xul
@@ -71,68 +71,70 @@
                      tooltiptext="&contentBlocking.exception.tooltip;"/>
               <label id="identity-popup-content-blocking-disabled-label-global"
                      value="&contentBlocking.disabled.label;"
                      tooltiptext="&contentBlocking.disabled.tooltip;"/>
             </hbox>
             <toolbarbutton id="tracking-protection-preferences-button"
                            class="identity-popup-preferences-button subviewbutton"
                            tooltiptext="&trackingProtection.tooltip;"
-                           oncommand="ContentBlocking.openPreferences('identityPopup-TP-preferencesButton');" />
+                           oncommand="ContentBlocking.openPreferences('identityPopup-TP-preferencesButton'); gIdentityHandler.recordClick('cb_prefs_button');" />
           </hbox>
 
           <description id="identity-popup-content-blocking-detected"
                        crop="end">&contentBlocking.detected;</description>
           <description id="identity-popup-content-blocking-not-detected"
                        crop="end">&contentBlocking.notDetected;</description>
 
           <vbox id="identity-popup-content-blocking-category-list">
             <hbox id="identity-popup-content-blocking-category-fastblock"
                   class="identity-popup-content-blocking-category" align="center" role="group">
               <image class="identity-popup-content-blocking-category-icon fastblock-icon"/>
               <label flex="1" class="identity-popup-content-blocking-category-label">&contentBlocking.fastBlock.label;</label>
               <label flex="1" class="identity-popup-content-blocking-category-state-label">&contentBlocking.fastBlock.blocked.label;</label>
               <label flex="1" class="identity-popup-content-blocking-category-add-blocking text-link"
-                     onclick="ContentBlocking.openPreferences('identityPopup-CB-fastblock');">&contentBlocking.fastBlock.add.label;</label>
+                     onclick="ContentBlocking.openPreferences('identityPopup-CB-fastblock'); gIdentityHandler.recordClick('fb_add_blocking');">&contentBlocking.fastBlock.add.label;</label>
             </hbox>
             <hbox id="identity-popup-content-blocking-category-tracking-protection"
                   class="identity-popup-content-blocking-category" align="center" role="group">
               <image class="identity-popup-content-blocking-category-icon tracking-protection-icon"/>
               <label flex="1" class="identity-popup-content-blocking-category-label">&contentBlocking.trackingProtection3.label;</label>
               <label flex="1" class="identity-popup-content-blocking-category-state-label">&contentBlocking.trackingProtection.blocked.label;</label>
               <label flex="1" class="identity-popup-content-blocking-category-add-blocking text-link"
-                     onclick="ContentBlocking.openPreferences('identityPopup-CB-tracking-protection');">&contentBlocking.trackingProtection.add.label;</label>
+                     id="identity-popup-tracking-protection-add-blocking"
+                     onclick="ContentBlocking.openPreferences('identityPopup-CB-tracking-protection'); gIdentityHandler.recordClick('tp_add_blocking');">&contentBlocking.trackingProtection.add.label;</label>
             </hbox>
             <hbox id="identity-popup-content-blocking-category-3rdpartycookies"
                   class="identity-popup-content-blocking-category" align="center" role="group">
               <image class="identity-popup-content-blocking-category-icon thirdpartycookies-icon"/>
               <label flex="1" class="identity-popup-content-blocking-category-label">&contentBlocking.3rdPartyCookies.label;</label>
               <label flex="1" class="identity-popup-content-blocking-category-state-label">&contentBlocking.3rdPartyCookies.blocked.label;</label>
               <label flex="1" class="identity-popup-content-blocking-category-add-blocking text-link"
-                     onclick="ContentBlocking.openPreferences('identityPopup-CB-3rdpartycookies');">&contentBlocking.3rdPartyCookies.add.label;</label>
+                     id="identity-popup-3rdpartycookies-add-blocking"
+                     onclick="ContentBlocking.openPreferences('identityPopup-CB-3rdpartycookies'); gIdentityHandler.recordClick('cookies_add_blocking');">&contentBlocking.3rdPartyCookies.add.label;</label>
             </hbox>
           </vbox>
 
           <button id="tracking-action-unblock"
                   class="tracking-protection-button"
                   label="&trackingProtection.unblock4.label;"
                   accesskey="&trackingProtection.unblock4.accesskey;"
-                  oncommand="ContentBlocking.disableForCurrentPage();" />
+                  oncommand="ContentBlocking.disableForCurrentPage(); gIdentityHandler.recordClick('unblock');" />
           <button id="tracking-action-unblock-private"
                   class="tracking-protection-button"
                   label="&trackingProtection.unblockPrivate4.label;"
                   accesskey="&trackingProtection.unblockPrivate4.accesskey;"
-                  oncommand="ContentBlocking.disableForCurrentPage();" />
+                  oncommand="ContentBlocking.disableForCurrentPage(); gIdentityHandler.recordClick('unblock_private');" />
           <button id="tracking-action-block"
                   class="tracking-protection-button"
                   label="&trackingProtection.block5.label;"
                   accesskey="&trackingProtection.block5.accesskey;"
-                  oncommand="ContentBlocking.enableForCurrentPage();" />
+                  oncommand="ContentBlocking.enableForCurrentPage(); gIdentityHandler.recordClick('block');" />
           <label id="identity-popup-content-blocking-report-breakage"
-                 onclick="ContentBlocking.showReportBreakageSubview();"
+                 onclick="ContentBlocking.showReportBreakageSubview(); gIdentityHandler.recordClick('report_breakage');"
                  class="text-link subviewkeynav"
                  flex="1">&contentBlocking.openBreakageReportView2.label;</label>
         </vbox>
       </hbox>
 
       <!-- Permissions Section -->
       <hbox class="identity-popup-section"
             when-connection="not-secure secure secure-ev secure-cert-user-overridden file extension">
@@ -155,17 +157,17 @@
       </hbox>
 
       <!-- Clear Site Data Button -->
       <vbox hidden="true"
             id="identity-popup-clear-sitedata-footer"
             class="identity-popup-footer">
         <button id="identity-popup-clear-sitedata-button"
                 label="&identity.clearSiteData;"
-                oncommand="gIdentityHandler.clearSiteData(event);"/>
+                oncommand="gIdentityHandler.clearSiteData(event); gIdentityHandler.recordClick('clear_sitedata');"/>
       </vbox>
     </panelview>
 
     <!-- Security SubView -->
     <panelview id="identity-popup-securityView"
                title="&identity.securityView.label;"
                descriptionheightworkaround="true">
       <vbox class="identity-popup-security-content">
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1346,16 +1346,19 @@ BrowserGlue.prototype = {
     this._firstWindowTelemetry(aWindow);
     this._firstWindowLoaded();
 
     // Set the default favicon size for UI views that use the page-icon protocol.
     PlacesUtils.favicons.setDefaultIconURIPreferredSize(16 * aWindow.devicePixelRatio);
   },
 
   _recordContentBlockingTelemetry() {
+    let recordIdentityPopupEvents = Services.prefs.getBoolPref("security.identitypopup.recordEventElemetry");
+    Services.telemetry.setEventRecordingEnabled("security.ui.identitypopup", recordIdentityPopupEvents);
+
     let tpEnabled = Services.prefs.getBoolPref("privacy.trackingprotection.enabled");
     Services.telemetry.getHistogramById("TRACKING_PROTECTION_ENABLED").add(tpEnabled);
 
     let tpPBDisabled = Services.prefs.getBoolPref("privacy.trackingprotection.pbmode.enabled");
     Services.telemetry.getHistogramById("TRACKING_PROTECTION_PBM_DISABLED").add(!tpPBDisabled);
 
     let cookieBehavior = Services.prefs.getIntPref("network.cookie.cookieBehavior");
     Services.telemetry.getHistogramById("COOKIE_BEHAVIOR").add(cookieBehavior);
--- a/toolkit/components/telemetry/Events.yaml
+++ b/toolkit/components/telemetry/Events.yaml
@@ -546,8 +546,63 @@ devtools.main:
     record_in_processes: ["main"]
     description: The amount of time a tool was opened for.
     release_channel_collection: opt-out
     expiry_version: never
     extra_keys:
       time_open: Time open.
       os: The OS name and version e.g. "Linux 4.4.0-1014-aws", "Darwin 14.5.0", "Windows_NT 6.1.7601" or "Windows_NT 10.0.15063." This can be used to make sense of data when a feature is only available from a particular operating system build number.
       session_id: The start time of the session in milliseconds since epoch (Unix Timestamp) e.g. 1396381378123.
+
+security.ui.identitypopup:
+  open:
+    objects: ["identity_popup"]
+    bug_numbers:
+      - 1484251
+    description: >
+      How many times the control center was opened.
+      Keyed by the state of the content blocking shield, where the shield-showing key indicates
+      that the shield icon in the identity UI is visible to the user, and shield-hidden indicates
+      that it is not visible.
+    expiry_version: "70"
+    notification_emails:
+      - jhofmann@mozilla.com
+      - pdol@mozilla.com
+      - seceng-telemetry@mozilla.com
+    release_channel_collection: opt-in
+    record_in_processes:
+      - main
+    extra_keys:
+      fb: Whether FastBlock was active while the user opened the popup
+      tp: Whether Tracking Protection was active while the user opened the popup
+      cr: Whether Cookie Restrictions was active while the user opened the popup
+    products:
+      - firefox
+  click:
+    objects: [
+      "fb_add_blocking",
+      "tp_add_blocking",
+      "cookies_add_blocking",
+      "cb_prefs_button",
+      "clear_sitedata",
+      "unblock",
+      "unblock_private",
+      "block",
+      "report_breakage"
+    ]
+    bug_numbers:
+      - 1484251
+    description: >
+      User interaction by click events in the identity popup.
+    expiry_version: "70"
+    notification_emails:
+      - jhofmann@mozilla.com
+      - pdol@mozilla.com
+      - seceng-telemetry@mozilla.com
+    release_channel_collection: opt-in
+    record_in_processes:
+      - main
+    extra_keys:
+      fb: Whether FastBlock was active while the user interacted with the UI
+      tp: Whether Tracking Protection was active while the user interacted with the UI
+      cr: Whether Cookie Restrictions was active while the user interacted with the UI
+    products:
+      - firefox
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -11368,19 +11368,20 @@
     "alert_emails": ["safebrowsing-telemetry@mozilla.org"],
     "bug_numbers": [1058133]
   },
   "TRACKING_PROTECTION_EVENTS": {
     "record_in_processes": ["main", "content"],
     "expires_in_version": "never",
     "kind": "enumerated",
     "n_values": 3,
-    "description": "A value of 0 is sent when the security UI changes on pages loaded outside of Private Browsing mode, a value of 1 is sent when users manually disable TP on that page, and 2 is sent when users manually re-enable TP on that page.",
+    "description": "(Fennec Only) A value of 0 is sent when the security UI changes on pages loaded outside of Private Browsing mode, a value of 1 is sent when users manually disable TP on that page, and 2 is sent when users manually re-enable TP on that page.",
     "alert_emails": ["safebrowsing-telemetry@mozilla.org"],
-    "bug_numbers": [1058133]
+    "bug_numbers": [1058133],
+    "products": ["fennec"]
   },
   "SERVICE_WORKER_LAUNCH_TIME": {
     "record_in_processes": ["main", "content"],
     "expires_in_version": "never",
     "bug_numbers": [1328398],
     "kind": "exponential",
     "high": 5000,
     "n_buckets": 25,