Bug 1513309 - Add telemetry for the storage access API; r=johannh,janerik a=lizzard
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 30 Jan 2019 12:41:58 +0000
changeset 515693 7f38e67b9aede6d070475e6e09c6be3e617325e5
parent 515692 c5a3a2a563c90e116ec873aaee027164cb22ef97
child 515694 0c326e548cb88aec3b2fb09337cba0f36ec8bcae
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh, janerik, lizzard
bugs1513309
milestone66.0
Bug 1513309 - Add telemetry for the storage access API; r=johannh,janerik a=lizzard Differential Revision: https://phabricator.services.mozilla.com/D17860
browser/modules/PermissionUI.jsm
toolkit/components/telemetry/Histograms.json
--- a/browser/modules/PermissionUI.jsm
+++ b/browser/modules/PermissionUI.jsm
@@ -901,37 +901,43 @@ StorageAccessPermissionPrompt.prototype 
   },
 
   get message() {
     return gBrowserBundle.formatStringFromName("storageAccess.message", ["<>", "<>"], 2);
   },
 
   get promptActions() {
     let self = this;
+
+    let storageAccessHistogram = Services.telemetry.getHistogramById("STORAGE_ACCESS_API_UI");
+
     return [{
         label: gBrowserBundle.GetStringFromName("storageAccess.DontAllow.label"),
         accessKey: gBrowserBundle.GetStringFromName("storageAccess.DontAllow.accesskey"),
         action: Ci.nsIPermissionManager.DENY_ACTION,
         callback(state) {
+          storageAccessHistogram.add("Deny");
           self.cancel();
         },
       },
       {
         label: gBrowserBundle.GetStringFromName("storageAccess.Allow.label"),
         accessKey: gBrowserBundle.GetStringFromName("storageAccess.Allow.accesskey"),
         action: Ci.nsIPermissionManager.ALLOW_ACTION,
         callback(state) {
+          storageAccessHistogram.add("Allow");
           self.allow({"storage-access": "allow"});
         },
       },
       {
         label: gBrowserBundle.GetStringFromName("storageAccess.AllowOnAnySite.label"),
         accessKey: gBrowserBundle.GetStringFromName("storageAccess.AllowOnAnySite.accesskey"),
         action: Ci.nsIPermissionManager.ALLOW_ACTION,
         callback(state) {
+          storageAccessHistogram.add("AllowOnAnySite");
           self.allow({"storage-access": "allow-on-any-site"});
         },
     }];
   },
 
   get topLevelPrincipal() {
     return this.request.topLevelPrincipal;
   },
@@ -959,21 +965,28 @@ StorageAccessPermissionPrompt.prototype 
         continue;
       }
       origins.add(perm.principal.origin);
     }
     return origins.size;
   },
 
   onBeforeShow() {
+    let storageAccessHistogram = Services.telemetry.getHistogramById("STORAGE_ACCESS_API_UI");
+
+    storageAccessHistogram.add("Request");
+
     let thirdPartyOrigin = this.request.principal.origin;
     if (this._autoGrants &&
         this.getOriginsThirdPartyHasAccessTo(thirdPartyOrigin) <
           this.maxConcurrentAutomaticGrants) {
       // Automatically accept the prompt
       this.allow({"storage-access": "allow-auto-grant"});
+
+      storageAccessHistogram.add("AllowAutomatically");
+
       return false;
     }
     return true;
   },
 };
 
 PermissionUI.StorageAccessPermissionPrompt = StorageAccessPermissionPrompt;
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -8108,16 +8108,25 @@
     "record_in_processes": ["main", "content"],
     "alert_emails": ["seceng-telemetry@mozilla.com", "fxprivacyandsecurity@mozilla.com"],
     "bug_numbers": [767676],
     "expires_in_version": "never",
     "kind": "enumerated",
     "n_values": 100,
     "description": "Security-related UI events (addons, form submission, TLS certs, Safe Browsing, updates and geolocation). See /security/manager/ssl/nsISecurityUITelemetry.idl for the specific values."
   },
+  "STORAGE_ACCESS_API_UI": {
+    "record_in_processes": ["main"],
+    "alert_emails": ["seceng-telemetry@mozilla.com", "ehsan+telemetry@mozilla.com"],
+    "bug_numbers": [1513309],
+    "expires_in_version": "73",
+    "kind": "categorical",
+    "labels": ["Request", "AllowAutomatically", "Deny", "Allow", "AllowOnAnySite"],
+    "description": "Storage Access API UI events."
+  },
   "IPC_TRANSACTION_CANCEL": {
     "record_in_processes": ["main", "content"],
     "alert_emails": ["billm@mozilla.com"],
     "expires_in_version": "never",
     "kind": "boolean",
     "description": "True when an IPC transaction is canceled"
   },
   "IPC_SAME_PROCESS_MESSAGE_COPY_OOM_KB": {