Bug 1465685 - Add Password Manager probes for Savant Shield study; r=MattN draft
authorBianca Danforth <bdanforth@mozilla.com>
Thu, 07 Jun 2018 03:23:47 -0700
changeset 805944 3708e443de487766ff8bf38237a462519a9db82b
parent 805938 83ee5cb70e11effed0ef3b8a66251dc712f55bad
child 805945 d88dbf2ad97892e14c6a9378cae2559af9c40b92
push id112814
push userbdanforth@mozilla.com
push dateFri, 08 Jun 2018 18:50:06 +0000
reviewersMattN
bugs1465685
milestone62.0a1
Bug 1465685 - Add Password Manager probes for Savant Shield study; r=MattN These probes will register and record (for the duration of the study only): * When the user is prompted by the Password Manager * When the user saves their login information through the Password Manager prompt * When the user updates their login information through the Password Manager prompt * When the user uses login information stored by the Password Manager Both the 'pwmgr' and 'pwmgr_use' probe have an 'extra' field called 'flow_id'. This is a tab identifier. For a given session, flow_id remains constant, even if the tab is moved to a different index within the same window. Tabs at the same index in different windows will have different flow_ids. MozReview-Commit-ID: CoBNl6lUQmH
browser/components/nsBrowserGlue.js
browser/modules/SavantShieldStudy.jsm
toolkit/components/passwordmgr/LoginManagerParent.jsm
toolkit/components/passwordmgr/nsLoginManagerPrompter.js
toolkit/components/telemetry/Events.yaml
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -223,16 +223,18 @@ const listeners = {
     "Reader:UpdateReaderButton": ["ReaderParent"],
     // PLEASE KEEP THIS LIST IN SYNC WITH THE MOBILE LISTENERS IN BrowserCLH.js
     "RemoteLogins:findLogins": ["LoginManagerParent"],
     "RemoteLogins:findRecipes": ["LoginManagerParent"],
     "RemoteLogins:onFormSubmit": ["LoginManagerParent"],
     "RemoteLogins:autoCompleteLogins": ["LoginManagerParent"],
     "RemoteLogins:removeLogin": ["LoginManagerParent"],
     "RemoteLogins:insecureLoginFormPresent": ["LoginManagerParent"],
+    // For Savant Shield study, bug 1465685. Study on desktop only.
+    "LoginStats:LoginFillSuccessful": ["LoginManagerParent"],
     // PLEASE KEEP THIS LIST IN SYNC WITH THE MOBILE LISTENERS IN BrowserCLH.js
     "WCCR:registerProtocolHandler": ["Feeds"],
     "WCCR:registerContentHandler": ["Feeds"],
     "rtcpeer:CancelRequest": ["webrtcUI"],
     "rtcpeer:Request": ["webrtcUI"],
     "webrtc:CancelRequest": ["webrtcUI"],
     "webrtc:Request": ["webrtcUI"],
     "webrtc:StopRecording": ["webrtcUI"],
--- a/browser/modules/SavantShieldStudy.jsm
+++ b/browser/modules/SavantShieldStudy.jsm
@@ -1,12 +1,14 @@
 /* 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/. */
 
+/* eslint semi: error */
+
 "use strict";
 
 var EXPORTED_SYMBOLS = ["SavantShieldStudy"];
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 XPCOMUtils.defineLazyModuleGetters(this, {
--- a/toolkit/components/passwordmgr/LoginManagerParent.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerParent.jsm
@@ -107,16 +107,26 @@ var LoginManagerParent = {
         break;
       }
 
       case "RemoteLogins:removeLogin": {
         let login = LoginHelper.vanillaObjectToLogin(data.login);
         AutoCompletePopup.removeLogin(login);
         break;
       }
+
+      case "LoginStats:LoginFillSuccessful": {
+        const flow_id = msg.target.ownerGlobal.gBrowser.getTabForBrowser(msg.target).linkedPanel;
+        Services.telemetry.recordEvent("savant", "pwmgr_use", "use", null,
+                                      {
+                                        subcategory: "feature",
+                                        flow_id,
+                                      });
+        break;
+      }
     }
 
     return undefined;
   },
 
   /**
    * Trigger a login form fill and send relevant data (e.g. logins and recipes)
    * to the child process (LoginManagerContent).
--- a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
+++ b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
@@ -817,16 +817,24 @@ LoginManagerPrompter.prototype = {
     let promptMsg = type == "password-save" ? this._getLocalizedString(saveMsgNames.prompt, [brandShortName, host])
                                             : this._getLocalizedString(changeMsgNames.prompt);
 
     let histogramName = type == "password-save" ? "PWMGR_PROMPT_REMEMBER_ACTION"
                                                 : "PWMGR_PROMPT_UPDATE_ACTION";
     let histogram = Services.telemetry.getHistogramById(histogramName);
     histogram.add(PROMPT_DISPLAYED);
 
+    const promptType = type == "password-save" ? "save" : "update";
+    const flow_id = browser.ownerGlobal.gBrowser.getTabForBrowser(browser).linkedPanel;
+    Services.telemetry.recordEvent("savant", "pwmgr", "ask", promptType,
+                                  {
+                                    subcategory: "prompt",
+                                    flow_id,
+                                  });
+
     let chromeDoc = browser.ownerDocument;
 
     let currentNotification;
 
     let updateButtonStatus = (element) => {
       let mainActionButton = element.button;
       // Disable the main button inside the menu-button if the password field is empty.
       if (login.password.length == 0) {
@@ -944,18 +952,30 @@ LoginManagerPrompter.prototype = {
     };
 
     // The main action is the "Save" or "Update" button.
     let mainAction = {
       label: this._getLocalizedString(initialMsgNames.buttonLabel),
       accessKey: this._getLocalizedString(initialMsgNames.buttonAccessKey),
       callback: () => {
         histogram.add(PROMPT_ADD_OR_UPDATE);
+        const flow_id = browser.ownerGlobal.gBrowser.getTabForBrowser(browser).linkedPanel;
         if (histogramName == "PWMGR_PROMPT_REMEMBER_ACTION") {
           Services.obs.notifyObservers(null, "LoginStats:NewSavedPassword");
+          Services.telemetry.recordEvent("savant", "pwmgr", "save", null,
+                                        {
+                                          subcategory: "prompt",
+                                          flow_id,
+                                        });
+        } else if (histogramName == "PWMGR_PROMPT_UPDATE_ACTION") {
+          Services.telemetry.recordEvent("savant", "pwmgr", "update", null,
+                                        {
+                                          subcategory: "prompt",
+                                          flow_id,
+                                        });
         }
         readDataFromUI();
         persistData();
         browser.focus();
       }
     };
 
     let secondaryActions = [{
--- a/toolkit/components/telemetry/Events.yaml
+++ b/toolkit/components/telemetry/Events.yaml
@@ -221,16 +221,45 @@ savant:
       This is recorded any time the dotdotdot (aka pageAction) menu is opened.
     bug_numbers: [1457226, 1465697]
     notification_emails:
       - "bdanforth@mozilla.com"
       - "shong@mozilla.com"
     expiry_version: "65"
     extra_keys:
       subcategory: The broad event category for this probe. E.g. navigation
+  pwmgr_use:
+    objects: ["use"]
+    release_channel_collection: opt-out
+    record_in_processes: ["main"]
+    description: >
+      Client uses saved login information from the Password Manager
+    bug_numbers: [1457226, 1465685]
+    notification_emails:
+      - "bdanforth@mozilla.com"
+      - "shong@mozilla.com"
+    expiry_version: "65"
+    extra_keys:
+      subcategory: The broad event category for this probe. E.g. navigation
+      flow_id: A tab identifier to associate events occuring in the same tab
+  pwmgr:
+    objects: ["ask", "save", "update"]
+    release_channel_collection: opt-out
+    record_in_processes: ["main"]
+    description: >
+      Password Manager asks the user to save or update login information.
+      For ask prompts, the value field indicate a save versus update ask.
+    bug_numbers: [1457226, 1465685]
+    notification_emails:
+      - "bdanforth@mozilla.com"
+      - "shong@mozilla.com"
+    expiry_version: "65"
+    extra_keys:
+      subcategory: The broad event category for this probe. E.g. navigation
+      flow_id: A tab identifier to associate events occuring in the same tab
 
 # This category contains event entries used for Telemetry tests.
 # They will not be sent out with any pings.
 telemetry.test:
   test:
     methods: ["test1", "test2"]
     objects: ["object1", "object2"]
     bug_numbers: [1286606]