Bug 1448061 - Improve accuracy of devtools entry points telemetry r?jdescottes draft
authorMike Ratcliffe <mratcliffe@mozilla.com>
Thu, 22 Mar 2018 16:53:23 +0000
changeset 771168 c1c0aabbf3092f76dde77a351d5d9eacf687b6c8
parent 771093 7771df14ea181add1dc4133f0f5559bf620bf976
push id103594
push userbmo:mratcliffe@mozilla.com
push dateThu, 22 Mar 2018 16:58:22 +0000
reviewersjdescottes
bugs1448061
milestone61.0a1
Bug 1448061 - Improve accuracy of devtools entry points telemetry r?jdescottes MozReview-Commit-ID: GmXQktPew5B
devtools/startup/DevToolsShim.jsm
devtools/startup/devtools-startup.js
toolkit/components/telemetry/Histograms.json
--- a/devtools/startup/DevToolsShim.jsm
+++ b/devtools/startup/DevToolsShim.jsm
@@ -148,17 +148,17 @@ this.DevToolsShim = {
     let {scratchpads, browserConsole, browserToolbox} = session;
     let hasDevToolsData = browserConsole || browserToolbox ||
                           (scratchpads && scratchpads.length);
     if (!hasDevToolsData) {
       // Do not initialize DevTools unless there is DevTools specific data in the session.
       return;
     }
 
-    this.initDevTools();
+    this.initDevTools("SessionRestore");
     this._gDevTools.restoreDevToolsSession(session);
   },
 
   /**
    * Called from nsContextMenu.js in mozilla-central when using the Inspect Element
    * context menu item.
    *
    * @param {XULTab} tab
--- a/devtools/startup/devtools-startup.js
+++ b/devtools/startup/devtools-startup.js
@@ -268,17 +268,17 @@ DevToolsStartup.prototype = {
       return;
     }
 
     this.hookWindow(window);
 
     if (Services.prefs.getBoolPref(TOOLBAR_VISIBLE_PREF, false)) {
       // Loading devtools-browser will open the developer toolbar by also checking this
       // pref.
-      this.initDevTools();
+      this.initDevTools("DeveloperToolbar");
     }
 
     // This listener is called for all Firefox windows, but we want to execute some code
     // only once.
     if (!this._firstWindowReadyReceived) {
       this.onFirstWindowReady(window);
       this._firstWindowReadyReceived = true;
     }
@@ -607,28 +607,17 @@ DevToolsStartup.prototype = {
 
   initDevTools: function(reason) {
     // If an entry point is fired and tools are not enabled open the installation page
     if (!Services.prefs.getBoolPref(DEVTOOLS_ENABLED_PREF)) {
       this.openInstallPage(reason);
       return null;
     }
 
-    if (reason && !this.recorded) {
-      // Only save the first call for each firefox run as next call
-      // won't necessarely start the tool. For example key shortcuts may
-      // only change the currently selected tool.
-      try {
-        Services.telemetry.getHistogramById("DEVTOOLS_ENTRY_POINT")
-                          .add(reason);
-      } catch (e) {
-        dump("DevTools telemetry entry point failed: " + e + "\n");
-      }
-      this.recorded = true;
-    }
+    this.sendEntryPointTelemetry(reason);
 
     this.initialized = true;
     let { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
     // Ensure loading main devtools module that hooks up into browser UI
     // and initialize all devtools machinery.
     require("devtools/client/framework/devtools-browser");
     return require;
   },
@@ -745,16 +734,18 @@ DevToolsStartup.prototype = {
     if (pauseOnStartup) {
       let observe = function(subject, topic, data) {
         devtoolsThreadResumed = true;
         Services.obs.removeObserver(observe, "devtools-thread-resumed");
       };
       Services.obs.addObserver(observe, "devtools-thread-resumed");
     }
 
+    this.sendEntryPointTelemetry("CommandLine");
+
     const { BrowserToolboxProcess } = ChromeUtils.import("resource://devtools/client/framework/ToolboxProcess.jsm", {});
     BrowserToolboxProcess.init();
 
     if (pauseOnStartup) {
       // Spin the event loop until the debugger connects.
       let tm = Cc["@mozilla.org/thread-manager;1"].getService();
       tm.spinEventLoopUntil(() => {
         return devtoolsThreadResumed;
@@ -829,16 +820,31 @@ DevToolsStartup.prototype = {
       dump("Unable to start debugger server on " + portOrPath + ": " + e);
     }
 
     if (cmdLine.state == Ci.nsICommandLine.STATE_REMOTE_AUTO) {
       cmdLine.preventDefault = true;
     }
   },
 
+  sendEntryPointTelemetry(reason) {
+    if (reason && !this.recorded) {
+      // Only save the first call for each firefox run as next call
+      // won't necessarely start the tool. For example key shortcuts may
+      // only change the currently selected tool.
+      try {
+        Services.telemetry.getHistogramById("DEVTOOLS_ENTRY_POINT")
+                          .add(reason);
+      } catch (e) {
+        dump("DevTools telemetry entry point failed: " + e + "\n");
+      }
+      this.recorded = true;
+    }
+  },
+
   // Used by tests and the toolbox to register the same key shortcuts in toolboxes loaded
   // in a window window.
   get KeyShortcuts() {
     return KeyShortcuts;
   },
   get wrappedJSObject() {
     return this;
   },
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -9289,17 +9289,17 @@
     "description": "Records the type of timeout that happened while attempting to init the encoder. Audio = 0, Video = 1. Recorded immediately following a timeout"
   },
   "DEVTOOLS_ENTRY_POINT": {
     "record_in_processes": ["main"],
     "bug_numbers": [1378863],
     "alert_emails": ["dev-developer-tools@lists.mozilla.org", "apoirot@mozilla.com"],
     "expires_in_version": "never",
     "kind": "categorical",
-    "labels": ["KeyShortcut", "SystemMenu", "HamburgerMenu", "ContextMenu", "CommandLine"],
+    "labels": ["KeyShortcut", "SystemMenu", "HamburgerMenu", "ContextMenu", "CommandLine", "DeveloperToolbar", "SessionRestore"],
     "releaseChannelCollection": "opt-out",
     "description": "Records how the user is triggering Developer Tools startup."
   },
   "DEVTOOLS_TOOLBOX_OPENED_COUNT": {
     "record_in_processes": ["main", "content"],
     "alert_emails": ["dev-developer-tools@lists.mozilla.org"],
     "expires_in_version": "never",
     "kind": "count",