Bug 1628165 - Add telemetry probe for clicks on vulnerable password learn more link. r=MattN
☠☠ backed out by 0d27285d90d7 ☠ ☠
authorJared Wein <jwein@mozilla.com>
Thu, 16 Apr 2020 21:24:19 +0000
changeset 524512 fdddf4601d4d8e70a78f3938b817b14acb4d0d98
parent 524511 39ee5303a7e89a03482a9a1cb13a39f3760fff3c
child 524513 9ff15f0fcf970ae82efefa9991ff897f5e9c825c
push id113227
push userjwein@mozilla.com
push dateThu, 16 Apr 2020 21:35:07 +0000
treeherderautoland@9ff15f0fcf97 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1628165
milestone77.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 1628165 - Add telemetry probe for clicks on vulnerable password learn more link. r=MattN This also fixes a bug where we weren't recording the telemetry probe clicks on breached password learn more links due to the refactoring and renaming of the .alert-link class. A test has been added that would have caught that mistake in automation. Differential Revision: https://phabricator.services.mozilla.com/D70142
browser/components/aboutlogins/content/components/login-item.js
browser/components/aboutlogins/tests/browser/browser_aaa_eventTelemetry_run_first.js
toolkit/components/telemetry/Events.yaml
--- a/browser/components/aboutlogins/content/components/login-item.js
+++ b/browser/components/aboutlogins/content/components/login-item.js
@@ -91,30 +91,31 @@ export default class LoginItem extends H
       ".alert-link"
     );
     this._vulnerableAlertLearnMoreLink = this._vulnerableAlert.querySelector(
       ".alert-learn-more-link"
     );
 
     this.render();
 
-    this._breachAlertLink.addEventListener("click", this);
+    this._breachAlertLearnMoreLink.addEventListener("click", this);
     this._cancelButton.addEventListener("click", this);
     this._copyPasswordButton.addEventListener("click", this);
     this._copyUsernameButton.addEventListener("click", this);
     this._deleteButton.addEventListener("click", this);
     this._editButton.addEventListener("click", this);
     this._errorMessageLink.addEventListener("click", this);
     this._form.addEventListener("submit", this);
     this._originInput.addEventListener("blur", this);
     this._originInput.addEventListener("click", this);
     this._originInput.addEventListener("mousedown", this, true);
     this._originInput.addEventListener("auxclick", this);
     this._originDisplayInput.addEventListener("click", this);
     this._revealCheckbox.addEventListener("click", this);
+    this._vulnerableAlertLearnMoreLink.addEventListener("click", this);
     window.addEventListener("AboutLoginsInitialLoginSelected", this);
     window.addEventListener("AboutLoginsLoadInitialFavicon", this);
     window.addEventListener("AboutLoginsLoginSelected", this);
     window.addEventListener("AboutLoginsShowBlankLogin", this);
   }
 
   focus() {
     if (!this._editButton.disabled) {
@@ -487,24 +488,27 @@ export default class LoginItem extends H
               cancelable: true,
             })
           );
           return;
         }
         if (classList.contains("origin-input")) {
           this._handleOriginClick();
         }
-        if (classList.contains("alert-link")) {
+        if (classList.contains("alert-learn-more-link")) {
           if (event.currentTarget.closest(".breach-alert")) {
             this._recordTelemetryEvent({
               object: "existing_login",
               method: "learn_more_breach",
             });
           } else if (event.currentTarget.closest(".vulnerable-alert")) {
-            // TODO: Add telemetry event
+            this._recordTelemetryEvent({
+              object: "existing_login",
+              method: "learn_more_vulnerable",
+            });
           }
         }
         break;
       }
       case "submit": {
         // Prevent page navigation form submit behavior.
         event.preventDefault();
         if (!this._isFormValid({ reportErrors: true })) {
--- a/browser/components/aboutlogins/tests/browser/browser_aaa_eventTelemetry_run_first.js
+++ b/browser/components/aboutlogins/tests/browser/browser_aaa_eventTelemetry_run_first.js
@@ -58,54 +58,77 @@ add_task(async function test_telemetry_e
     let loginList = content.document.querySelector("login-list");
     let loginListItem = loginList.shadowRoot.querySelector(
       ".login-list-item.breached"
     );
     loginListItem.click();
   });
   await LoginTestUtils.telemetry.waitForEventCount(2);
 
+  // Need to change the learn-more to a local address for testing.
+  const FAKE_LEARN_MORE_URL = "https://learn-more.example.com/";
+  let promiseNewTab = BrowserTestUtils.waitForNewTab(
+    gBrowser,
+    FAKE_LEARN_MORE_URL
+  );
+  await SpecialPowers.spawn(
+    gBrowser.selectedBrowser,
+    [FAKE_LEARN_MORE_URL],
+    async function(fakeLearnMoreUrl) {
+      let loginItem = content.document.querySelector("login-item");
+      let learnMoreLink = loginItem.shadowRoot.querySelector(
+        ".alert-learn-more-link"
+      );
+      learnMoreLink.href = fakeLearnMoreUrl;
+      learnMoreLink.click();
+    }
+  );
+  let newTab = await promiseNewTab;
+  ok(true, "New tab opened to " + FAKE_LEARN_MORE_URL);
+  BrowserTestUtils.removeTab(newTab);
+  await LoginTestUtils.telemetry.waitForEventCount(3);
+
   await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
     let loginItem = content.document.querySelector("login-item");
     let copyButton = loginItem.shadowRoot.querySelector(
       ".copy-username-button"
     );
     copyButton.click();
   });
-  await LoginTestUtils.telemetry.waitForEventCount(3);
+  await LoginTestUtils.telemetry.waitForEventCount(4);
 
   if (OSKeyStoreTestUtils.canTestOSKeyStoreLogin()) {
     let reauthObserved = OSKeyStoreTestUtils.waitForOSKeyStoreLogin(true);
     await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
       let loginItem = content.document.querySelector("login-item");
       let copyButton = loginItem.shadowRoot.querySelector(
         ".copy-password-button"
       );
       copyButton.click();
     });
     await reauthObserved;
     // When reauth is observed an extra telemetry event will be recorded
     // for the reauth, hence the event count increasing by 2 here, and later
     // in the test as well.
-    await LoginTestUtils.telemetry.waitForEventCount(5);
+    await LoginTestUtils.telemetry.waitForEventCount(6);
   }
   let nextTelemetryEventCount = OSKeyStoreTestUtils.canTestOSKeyStoreLogin()
-    ? 6
-    : 4;
+    ? 7
+    : 5;
 
-  let promiseNewTab = BrowserTestUtils.waitForNewTab(
+  promiseNewTab = BrowserTestUtils.waitForNewTab(
     gBrowser,
     TEST_LOGIN3.origin + "/"
   );
   await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
     let loginItem = content.document.querySelector("login-item");
     let originInput = loginItem.shadowRoot.querySelector(".origin-input");
     originInput.click();
   });
-  let newTab = await promiseNewTab;
+  newTab = await promiseNewTab;
   ok(true, "New tab opened to " + TEST_LOGIN3.origin);
   BrowserTestUtils.removeTab(newTab);
   await LoginTestUtils.telemetry.waitForEventCount(nextTelemetryEventCount++);
 
   // Show the password
   if (OSKeyStoreTestUtils.canTestOSKeyStoreLogin()) {
     let reauthObserved = forceAuthTimeoutAndWaitForOSKeyStoreLogin({
       loginResult: true,
@@ -235,16 +258,24 @@ add_task(async function test_telemetry_e
     input.setUserInput("test");
   });
   await LoginTestUtils.telemetry.waitForEventCount(nextTelemetryEventCount++);
 
   const testOSAuth = OSKeyStoreTestUtils.canTestOSKeyStoreLogin();
   let expectedEvents = [
     [true, "pwmgr", "open_management", "direct"],
     [true, "pwmgr", "select", "existing_login", null, { breached: "true" }],
+    [
+      true,
+      "pwmgr",
+      "learn_more_breach",
+      "existing_login",
+      null,
+      { breached: "true" },
+    ],
     [true, "pwmgr", "copy", "username", null, { breached: "true" }],
     [testOSAuth, "pwmgr", "reauthenticate", "os_auth", "success"],
     [testOSAuth, "pwmgr", "copy", "password", null, { breached: "true" }],
     [true, "pwmgr", "open_site", "existing_login", null, { breached: "true" }],
     [testOSAuth, "pwmgr", "reauthenticate", "os_auth", "success"],
     [testOSAuth, "pwmgr", "show", "password", null, { breached: "true" }],
     [testOSAuth, "pwmgr", "hide", "password", null, { breached: "true" }],
     [testOSAuth, "pwmgr", "reauthenticate", "os_auth", "success_no_prompt"],
--- a/toolkit/components/telemetry/Events.yaml
+++ b/toolkit/components/telemetry/Events.yaml
@@ -649,27 +649,29 @@ pwmgr:
       "cancel",
       "copy",
       "delete",
       "dismiss_breach_alert",
       "edit",
       "filter",
       "hide",
       "learn_more_breach",
+      "learn_more_vulnerable",
       "new",
       "open_site",
       "save",
       "select",
       "show",
       "sort",
     ]
     bug_numbers:
       - 1548463
       - 1600958
       - 1549115
+      - 1628165
     expiry_version: never
     notification_emails: ["loines@mozilla.com", "passwords-dev@mozilla.org", "jaws@mozilla.com"]
     release_channel_collection: opt-out
     products:
       - "firefox"
     record_in_processes: [content]
   autocomplete_field:
     objects: ["generatedpassword"]