Bug 1630228 - Add telemetry events for OFF 12 devtools experiment r=nchevobbe,janerik
☠☠ backed out by bc7658646927 ☠ ☠
authorJulian Descottes <jdescottes@mozilla.com>
Tue, 28 Apr 2020 20:22:16 +0000
changeset 526574 8a9c309238471368ab4d7b17b04119eb9f12ed31
parent 526573 11f6beab6bdfc33f122bbe54b818bd390ad51da2
child 526575 92172b9cef6b88934c7d54beb7e3d311a69df127
push id37358
push useropoprus@mozilla.com
push dateWed, 29 Apr 2020 03:05:14 +0000
treeherdermozilla-central@6bb8423186c1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnchevobbe, janerik
bugs1630228
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 1630228 - Add telemetry events for OFF 12 devtools experiment r=nchevobbe,janerik Depends on D71037 Differential Revision: https://phabricator.services.mozilla.com/D71988
devtools/client/framework/devtools-browser.js
devtools/client/framework/enable-devtools-popup.js
devtools/client/framework/toolbox.js
toolkit/components/telemetry/Events.yaml
--- a/devtools/client/framework/devtools-browser.js
+++ b/devtools/client/framework/devtools-browser.js
@@ -316,17 +316,17 @@ var gDevToolsBrowser = (exports.gDevTool
         // of DevTools. The preference here is used as part of an experiment to
         // disable the F12 shortcut by default.
         const isF12Disabled = Services.prefs.getBoolPref(
           DEVTOOLS_F12_DISABLED_PREF,
           false
         );
 
         if (isF12Disabled) {
-          toggleEnableDevToolsPopup(window.document);
+          toggleEnableDevToolsPopup(window.document, startTime);
         } else {
           await gDevToolsBrowser.toggleToolboxCommand(
             window.gBrowser,
             startTime
           );
         }
         break;
       case "browserToolbox":
--- a/devtools/client/framework/enable-devtools-popup.js
+++ b/devtools/client/framework/enable-devtools-popup.js
@@ -1,14 +1,22 @@
 /* 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/. */
 
 "use strict";
 
+loader.lazyGetter(this, "telemetry", () => {
+  const Telemetry = require("devtools/client/shared/telemetry");
+  return new Telemetry();
+});
+
+// This session id will be initialized the first time the popup is displayed.
+let telemetrySessionId = null;
+
 /**
  * Helper dedicated to toggle a popup triggered by pressing F12 if DevTools have
  * never been opened by the user.
  *
  * This popup should be anchored below the main hamburger menu of Firefox,
  * which contains the Web Developer menu.
  *
  * This is part of the OFF12 experiment which tries to disable F12 by default to
@@ -23,11 +31,25 @@ exports.toggleEnableDevToolsPopup = func
   const anchor = doc
     .getElementById("PanelUI-menu-button")
     .querySelector(".toolbarbutton-icon");
 
   const isVisible = popup.state === "open";
   if (isVisible) {
     popup.hidePopup();
   } else {
+    if (!telemetrySessionId) {
+      telemetrySessionId = parseInt(telemetry.msSinceProcessStart(), 10);
+    }
     popup.openPopup(anchor, "bottomcenter topright");
+    telemetry.recordEvent("f12_popup_displayed", "tools", null, {
+      session_id: telemetrySessionId,
+    });
   }
 };
+
+/**
+ * If a session id was already generated here for telemetry, expose it so that
+ * the toolbox can use it as its own session id.
+ */
+exports.getF12SessionId = function() {
+  return telemetrySessionId;
+};
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -207,16 +207,23 @@ loader.lazyRequireGetter(
 );
 
 loader.lazyRequireGetter(
   this,
   "PICKER_TYPES",
   "devtools/shared/picker-constants"
 );
 
+loader.lazyRequireGetter(
+  this,
+  "getF12SessionId",
+  "devtools/client/framework/enable-devtools-popup",
+  true
+);
+
 const DEVTOOLS_F12_DISABLED_PREF = "devtools.experiment.f12.shortcut_disabled";
 
 /**
  * A "Toolbox" is the component that holds all the tools for one specific
  * target. Visually, it's a document that includes the tools tabs and all
  * the iframes where the tool panels will be living in.
  *
  * @param {object} target
@@ -252,16 +259,29 @@ function Toolbox(
 
   // The session ID is used to determine which telemetry events belong to which
   // toolbox session. Because we use Amplitude to analyse the telemetry data we
   // must use the time since the system wide epoch as the session ID.
   this.sessionId = msSinceProcessStart;
 
   // If the user opened the toolbox, we can now enable the F12 shortcut.
   if (Services.prefs.getBoolPref(DEVTOOLS_F12_DISABLED_PREF, false)) {
+    // If the toolbox is opening while F12 was disabled, the user might have
+    // pressed F12 and seen the "enable devtools" notification.
+    // A telemetry session_id was generated for the f12_popup_displayed event.
+    // Reuse it here in order to link the toolbox session to the
+    // f12_popup_displayed events.
+    // getF12SessionId() might return null if the popup was never displayed.
+    // In this case, fallback on the provided `msSinceProcessStart`.
+    this.sessionId = getF12SessionId() || msSinceProcessStart;
+
+    this.telemetry.recordEvent("f12_enabled", "tools", null, {
+      session_id: this.sessionId,
+    });
+
     // Flip the preference.
     Services.prefs.setBoolPref(DEVTOOLS_F12_DISABLED_PREF, false);
   }
 
   // Map of the available DevTools WebExtensions:
   //   Map<extensionUUID, extensionName>
   this._webExtensions = new Map();
 
@@ -1451,16 +1471,17 @@ Toolbox.prototype = {
 
     // Log current theme. The question we want to answer is:
     // "What proportion of users use which themes?"
     const currentTheme = Services.prefs.getCharPref("devtools.theme");
     this.telemetry.keyedScalarAdd(CURRENT_THEME_SCALAR, currentTheme, 1);
 
     const browserWin = this.topWindow;
     this.telemetry.preparePendingEvent(browserWin, "open", "tools", null, [
+      "enable_f12",
       "entrypoint",
       "first_panel",
       "host",
       "shortcut",
       "splitconsole",
       "width",
       "session_id",
     ]);
--- a/toolkit/components/telemetry/Events.yaml
+++ b/toolkit/components/telemetry/Events.yaml
@@ -1202,16 +1202,40 @@ devtools.main:
     expiry_version: never
     extra_keys:
       host: "Toolbox host (positioning): bottom, side, window or other."
       width: Toolbox width rounded up to the nearest 50px.
       next_panel: The name of the panel closed or other.
       panel_name: The name of the panel opened or other
       reason: debuggerStatement, breakpoint, exception, tab_switch, toolbox_show, initial_panel, toggle_settings_off, toggle_settings_on, key_shortcut, select_next_key, select_prev_key, tool_unloaded, inspect_dom, toolbox_closed, unknown etc.
       session_id: The start time of the session in milliseconds since epoch (Unix Timestamp) e.g. 1396381378123.
+  f12_enabled:
+    objects: ["tools"]
+    bug_numbers: [1630228]
+    notification_emails: ["dev-developer-tools@lists.mozilla.org", "hkirschner@mozilla.com"]
+    products:
+      - "firefox"
+    record_in_processes: ["main"]
+    description: User opened DevTools for the first time, which enables the F12 shortcut.
+    release_channel_collection: opt-out
+    expiry_version: "80"
+    extra_keys:
+      session_id: The start time of the session in milliseconds since epoch (Unix Timestamp) e.g. 1396381378123.
+  f12_popup_displayed:
+    objects: ["tools"]
+    bug_numbers: [1630228]
+    notification_emails: ["dev-developer-tools@lists.mozilla.org", "hkirschner@mozilla.com"]
+    products:
+      - "firefox"
+    record_in_processes: ["main"]
+    description: User triggered the "enable devtools" notification after pressing F12.
+    release_channel_collection: opt-out
+    expiry_version: "80"
+    extra_keys:
+      session_id: The start time of the session in milliseconds since epoch (Unix Timestamp) e.g. 1396381378123.
   filters_changed:
     objects: ["netmonitor", "webconsole"]
     bug_numbers: [1463144, 1463095]
     notification_emails: ["dev-developer-tools@lists.mozilla.org", "hkirschner@mozilla.com"]
     products:
       - "firefox"
       - "fennec"
       - "geckoview"
@@ -1647,25 +1671,25 @@ security.ui.protections:
     products:
       - firefox
     extra_keys:
       category: The category of protections the user is in, standard, strict or custom.
 
 security.ui.app_menu:
   click:
     bug_numbers:
-      - 1603545 
+      - 1603545
       - 1616229
     description: >
       Privacy and Security click events on app menu.
     objects: [
       "open_full_report",
     ]
     expiry_version: "80"
-    record_in_processes: 
+    record_in_processes:
       - main
     release_channel_collection: opt-out
     notification_emails:
       - chsiang@mozilla.com
       - ewright@mozilla.com
       - seceng-telemetry@mozilla.com
     products:
       - firefox