Bug 1478273 - When clicked on the side bar pane, it disappears r=gl
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Thu, 16 Aug 2018 15:05:31 +0000
changeset 487956 ee51ad97d401d529454fd1fe7dc8b2fc44389afd
parent 487955 32e98ec84de35a219e857c660cf69efcd9ff1b1c
child 487957 21291aa6b4c8b57eac9bfaa79cfdb7c3baabb6e7
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)
reviewersgl
bugs1478273
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 1478273 - When clicked on the side bar pane, it disappears r=gl Differential Revision: https://phabricator.services.mozilla.com/D3505
devtools/client/framework/toolbox.js
devtools/client/inspector/toolsidebar.js
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -3380,21 +3380,32 @@ Toolbox.prototype = {
    * to true.
    * @see browser/components/extensions/ext-devtools.js
    */
   isWebExtensionEnabled: function(extensionUUID) {
     const extInfo = this._webExtensions.get(extensionUUID);
     return extInfo && Services.prefs.getBoolPref(extInfo.pref, false);
   },
 
+  /**
+   * Returns a panel id in the case of built in panels or "other" in the case of
+   * third party panels. This is necessary due to limitations in addon id strings,
+   * the permitted length of event telemetry property values and what we actually
+   * want to see in our telemetry.
+   *
+   * @param {String} id
+   *        The panel id we would like to process.
+   */
   getTelemetryPanelNameOrOther: function(id) {
     if (!this._toolNames) {
       const definitions = gDevTools.getToolDefinitionArray();
       const definitionIds = definitions.map(definition => definition.id);
 
       this._toolNames = new Set(definitionIds);
     }
+
     if (!this._toolNames.has(id)) {
       return "other";
     }
+
     return id;
   },
 };
--- a/devtools/client/inspector/toolsidebar.js
+++ b/devtools/client/inspector/toolsidebar.js
@@ -327,31 +327,62 @@ ToolSidebar.prototype = {
    *         id of the previously selected tool.
    */
   updateTelemetryOnChange: function(currentToolId, previousToolId) {
     if (currentToolId === previousToolId || !this._telemetry) {
       // Skip telemetry if the tool id did not change or telemetry is unavailable.
       return;
     }
 
+    currentToolId = this.getTelemetryPanelNameOrOther(currentToolId);
+
     if (previousToolId) {
+      previousToolId = this.getTelemetryPanelNameOrOther(previousToolId);
+
       this._telemetry.toolClosed(previousToolId);
 
       this._telemetry.recordEvent("devtools.main", "sidepanel_changed", "inspector", null,
         {
           "oldpanel": previousToolId,
           "newpanel": currentToolId,
           "session_id": this._toolPanel._toolbox.sessionId
         }
       );
     }
     this._telemetry.toolOpened(currentToolId);
   },
 
   /**
+   * Returns a panel id in the case of built in panels or "other" in the case of
+   * third party panels. This is necessary due to limitations in addon id strings,
+   * the permitted length of event telemetry property values and what we actually
+   * want to see in our telemetry.
+   *
+   * @param {String} id
+   *        The panel id we would like to process.
+   */
+  getTelemetryPanelNameOrOther: function(id) {
+    if (!this._toolNames) {
+      // Get all built in tool ids. We identify third party tool ids by checking
+      // for a "-", which shows it originates from an addon.
+      const ids = this._tabbar.state.tabs.map(({ id: toolId }) => {
+        return toolId.includes("-") ? "other" : toolId;
+      });
+
+      this._toolNames = new Set(ids);
+    }
+
+    if (!this._toolNames.has(id)) {
+      return "other";
+    }
+
+    return id;
+  },
+
+  /**
    * Show the sidebar.
    *
    * @param  {String} id
    *         The sidebar tab id to select.
    */
   show: function(id) {
     this._tabbox.removeAttribute("hidden");