Bug 1476393 - Record pwmgr histograms in sync ping r=markh,tcsc
authorirrationalagent <leifdoines@gmail.com>
Fri, 03 Aug 2018 09:30:06 -0600
changeset 486398 3fd274a79d272c32e03b03993945688e087c7e56
parent 486397 44517ac63b7ca1e1d8f71fe320cedd50b60c56fe
child 486399 8015bcc55dae2b966149fc857cf7e0963f46e3a9
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh, tcsc
bugs1476393
milestone63.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 1476393 - Record pwmgr histograms in sync ping r=markh,tcsc MozReview-Commit-ID: CkZAwlCORtX
toolkit/components/passwordmgr/content/passwordManager.js
toolkit/components/passwordmgr/nsLoginManager.js
toolkit/components/passwordmgr/nsLoginManagerPrompter.js
--- a/toolkit/components/passwordmgr/content/passwordManager.js
+++ b/toolkit/components/passwordmgr/content/passwordManager.js
@@ -96,18 +96,20 @@ function Startup() {
   LoadSignons();
 
   // filter the table if requested by caller
   if (window.arguments &&
       window.arguments[0] &&
       window.arguments[0].filterString) {
     setFilter(window.arguments[0].filterString);
     Services.telemetry.getHistogramById("PWMGR_MANAGE_OPENED").add(1);
+    Services.obs.notifyObservers(null, "weave:telemetry:histogram", "PWMGR_MANAGE_OPENED");
   } else {
     Services.telemetry.getHistogramById("PWMGR_MANAGE_OPENED").add(0);
+    Services.obs.notifyObservers(null, "weave:telemetry:histogram", "PWMGR_MANAGE_OPENED");
   }
 
   FocusFilterBox();
 }
 
 function Shutdown() {
   Services.obs.removeObserver(signonReloadDisplay, "passwordmgr-storage-changed");
 }
@@ -404,47 +406,50 @@ function DeleteAllSignons() {
   box.rowCountChanged(0, -deletedSignons.length);
   box.invalidate();
 
   // disable buttons
   removeButton.setAttribute("disabled", "true");
   removeAllButton.setAttribute("disabled", "true");
   FinalizeSignonDeletions(syncNeeded);
   Services.telemetry.getHistogramById("PWMGR_MANAGE_DELETED_ALL").add(1);
+  Services.obs.notifyObservers(null, "weave:telemetry:histogram", "PWMGR_MANAGE_DELETED_ALL");
 }
 
 function TogglePasswordVisible() {
   if (showingPasswords || masterPasswordLogin(AskUserShowPasswords)) {
     showingPasswords = !showingPasswords;
     togglePasswordsButton.label = kSignonBundle.getString(showingPasswords ? "hidePasswords" : "showPasswords");
     togglePasswordsButton.accessKey = kSignonBundle.getString(showingPasswords ? "hidePasswordsAccessKey" : "showPasswordsAccessKey");
     document.getElementById("passwordCol").hidden = !showingPasswords;
     FilterPasswords();
   }
 
   // Notify observers that the password visibility toggling is
   // completed.  (Mostly useful for tests)
   Services.obs.notifyObservers(null, "passwordmgr-password-toggle-complete");
   Services.telemetry.getHistogramById("PWMGR_MANAGE_VISIBILITY_TOGGLED").add(showingPasswords);
+  Services.obs.notifyObservers(null, "weave:telemetry:histogram", "PWMGR_MANAGE_VISIBILITY_TOGGLED");
 }
 
 function AskUserShowPasswords() {
   let dummy = { value: false };
 
   // Confirm the user wants to display passwords
   return Services.prompt.confirmEx(window,
           null,
           kSignonBundle.getString("noMasterPasswordPrompt"), Services.prompt.STD_YES_NO_BUTTONS,
           null, null, null, null, dummy) == 0; // 0=="Yes" button
 }
 
 function FinalizeSignonDeletions(syncNeeded) {
   for (let s = 0; s < deletedSignons.length; s++) {
     Services.logins.removeLogin(deletedSignons[s]);
     Services.telemetry.getHistogramById("PWMGR_MANAGE_DELETED").add(1);
+    Services.obs.notifyObservers(null, "weave:telemetry:histogram", "PWMGR_MANAGE_DELETED");
   }
   // If the deletion has been performed in a filtered view, reflect the deletion in the unfiltered table.
   // See bug 405389.
   if (syncNeeded) {
     try {
       signons = Services.logins.getAllLogins();
     } catch (e) {
       signons = [];
@@ -620,26 +625,28 @@ function CopyPassword() {
     return;
   // Copy selected signon's password to clipboard
   let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
                   getService(Ci.nsIClipboardHelper);
   let row = signonsTree.currentIndex;
   let password = signonsTreeView.getCellText(row, {id: "passwordCol" });
   clipboard.copyString(password);
   Services.telemetry.getHistogramById("PWMGR_MANAGE_COPIED_PASSWORD").add(1);
+  Services.obs.notifyObservers(null, "weave:telemetry:histogram", "PWMGR_MANAGE_COPIED_PASSWORD");
 }
 
 function CopyUsername() {
   // Copy selected signon's username to clipboard
   let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
                   getService(Ci.nsIClipboardHelper);
   let row = signonsTree.currentIndex;
   let username = signonsTreeView.getCellText(row, {id: "userCol" });
   clipboard.copyString(username);
   Services.telemetry.getHistogramById("PWMGR_MANAGE_COPIED_USERNAME").add(1);
+  Services.obs.notifyObservers(null, "weave:telemetry:histogram", "PWMGR_MANAGE_COPIED_USERNAME");
 }
 
 function EditCellInSelectedRow(columnName) {
   let row = signonsTree.currentIndex;
   let columnElement = getColumnByName(columnName);
   signonsTree.startEditing(row, signonsTree.columns.getColumnFor(columnElement));
 }
 
--- a/toolkit/components/passwordmgr/nsLoginManager.js
+++ b/toolkit/components/passwordmgr/nsLoginManager.js
@@ -200,20 +200,23 @@ LoginManager.prototype = {
       this.getAllDisabledHosts({}).length
     );
     clearAndGetHistogram("PWMGR_NUM_SAVED_PASSWORDS").add(
       this.countLogins("", "", "")
     );
     clearAndGetHistogram("PWMGR_NUM_HTTPAUTH_PASSWORDS").add(
       this.countLogins("", null, "")
     );
+    Services.obs.notifyObservers(null, "weave:telemetry:histogram", "PWMGR_BLOCKLIST_NUM_SITES");
+    Services.obs.notifyObservers(null, "weave:telemetry:histogram", "PWMGR_NUM_SAVED_PASSWORDS");
 
     // This is a boolean histogram, and not a flag, because we don't want to
     // record any value if _gatherTelemetry is not called.
     clearAndGetHistogram("PWMGR_SAVING_ENABLED").add(this._remember);
+    Services.obs.notifyObservers(null, "weave:telemetry:histogram", "PWMGR_SAVING_ENABLED");
 
     // Don't try to get logins if MP is enabled, since we don't want to show a MP prompt.
     if (!this.isLoggedIn) {
       return;
     }
 
     let logins = this.getAllLogins({});
 
@@ -230,21 +233,23 @@ LoginManager.prototype = {
       login.QueryInterface(Ci.nsILoginMetaInfo);
       let timeLastUsedAgeMs = referenceTimeMs - login.timeLastUsed;
       if (timeLastUsedAgeMs > 0) {
         loginLastUsedDaysHistogram.add(
           Math.floor(timeLastUsedAgeMs / MS_PER_DAY)
         );
       }
     }
+    Services.obs.notifyObservers(null, "weave:telemetry:histogram", "PWMGR_LOGIN_LAST_USED_DAYS");
 
     let passwordsCountHistogram = clearAndGetHistogram("PWMGR_NUM_PASSWORDS_PER_HOSTNAME");
     for (let count of hostnameCount.values()) {
       passwordsCountHistogram.add(count);
     }
+    Services.obs.notifyObservers(null, "weave:telemetry:histogram", "PWMGR_NUM_PASSWORDS_PER_HOSTNAME");
   },
 
 
   /**
    * Ensures that a login isn't missing any necessary fields.
    *
    * @param login
    *        The login to check.
--- a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
+++ b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
@@ -816,16 +816,17 @@ LoginManagerPrompter.prototype = {
     let host = this._getShortDisplayHost(login.hostname);
     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);
+    Services.obs.notifyObservers(null, "weave:telemetry:histogram", histogramName);
 
     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,
                                   });
@@ -969,35 +970,38 @@ LoginManagerPrompter.prototype = {
           Services.telemetry.recordEvent("savant", "pwmgr", "update", null,
                                         {
                                           subcategory: "prompt",
                                           flow_id,
                                         });
         }
         readDataFromUI();
         persistData();
+        Services.obs.notifyObservers(null, "weave:telemetry:histogram", histogramName);
         browser.focus();
       }
     };
 
     let secondaryActions = [{
       label: this._getLocalizedString(initialMsgNames.secondaryButtonLabel),
       accessKey: this._getLocalizedString(initialMsgNames.secondaryButtonAccessKey),
       callback: () => {
         histogram.add(PROMPT_NOTNOW);
+        Services.obs.notifyObservers(null, "weave:telemetry:histogram", histogramName);
         browser.focus();
       }
     }];
     // Include a "Never for this site" button when saving a new password.
     if (type == "password-save") {
       secondaryActions.push({
         label: this._getLocalizedString("notifyBarNeverRememberButtonText2"),
         accessKey: this._getLocalizedString("notifyBarNeverRememberButtonAccessKey2"),
         callback: () => {
           histogram.add(PROMPT_NEVER);
+          Services.obs.notifyObservers(null, "weave:telemetry:histogram", histogramName);
           Services.logins.setLoginSavingEnabled(login.hostname, false);
           browser.focus();
         }
       });
     }
 
     let usernamePlaceholder = this._getLocalizedString("noUsernamePlaceholder");
     let togglePasswordLabel = this._getLocalizedString("togglePasswordLabel");