diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js index 9887e3bd23f4..213363a70591 100644 --- a/devtools/client/framework/toolbox.js +++ b/devtools/client/framework/toolbox.js @@ -109,6 +109,7 @@ function Toolbox(target, selectedTool, hostType, contentWindow, frameId) { this._target = target; this._win = contentWindow; this.frameId = frameId; + this.telemetry = new Telemetry(); // Map of the available DevTools WebExtensions: // Map @@ -116,7 +117,6 @@ function Toolbox(target, selectedTool, hostType, contentWindow, frameId) { this._toolPanels = new Map(); this._inspectorExtensionSidebars = new Map(); - this._telemetry = new Telemetry(); this._initInspector = null; this._inspector = null; @@ -545,10 +545,10 @@ Toolbox.prototype = { let splitConsolePromise = promise.resolve(); if (Services.prefs.getBoolPref(SPLITCONSOLE_ENABLED_PREF)) { splitConsolePromise = this.openSplitConsole(); - this._telemetry.addEventProperty( + this.telemetry.addEventProperty( "devtools.main", "open", "tools", null, "splitconsole", true); } else { - this._telemetry.addEventProperty( + this.telemetry.addEventProperty( "devtools.main", "open", "tools", null, "splitconsole", false); } @@ -716,22 +716,22 @@ Toolbox.prototype = { }, _pingTelemetry: function() { - this._telemetry.toolOpened("toolbox"); + this.telemetry.toolOpened("toolbox"); - this._telemetry.logOncePerBrowserVersion(SCREENSIZE_HISTOGRAM, + this.telemetry.logOncePerBrowserVersion(SCREENSIZE_HISTOGRAM, system.getScreenDimensions()); - this._telemetry.log(HOST_HISTOGRAM, this._getTelemetryHostId()); + this.telemetry.log(HOST_HISTOGRAM, this._getTelemetryHostId()); // Log current theme. The question we want to answer is: // "What proportion of users use which themes?" let currentTheme = Services.prefs.getCharPref("devtools.theme"); - this._telemetry.logKeyedScalar(CURRENT_THEME_SCALAR, currentTheme, 1); + this.telemetry.logKeyedScalar(CURRENT_THEME_SCALAR, currentTheme, 1); - this._telemetry.preparePendingEvent( + this.telemetry.preparePendingEvent( "devtools.main", "open", "tools", null, ["entrypoint", "first_panel", "host", "splitconsole", "width"] ); - this._telemetry.addEventProperty( + this.telemetry.addEventProperty( "devtools.main", "open", "tools", null, "host", this._getTelemetryHostString() ); }, @@ -1849,7 +1849,7 @@ Toolbox.prototype = { id === "options" || this.additionalToolDefinitions.get(id)) { if (this.currentToolId) { - this._telemetry.toolClosed(this.currentToolId); + this.telemetry.toolClosed(this.currentToolId); } this._pingTelemetrySelectTool(id, reason); @@ -1884,7 +1884,7 @@ Toolbox.prototype = { const prevPanelName = this.getTelemetryPanelName(this.currentToolId); const cold = !this.getPanel(id); - this._telemetry.addEventProperties("devtools.main", "enter", panelName, null, { + this.telemetry.addEventProperties("devtools.main", "enter", panelName, null, { "host": this._hostType, "width": width, "start_state": reason, @@ -1895,7 +1895,7 @@ Toolbox.prototype = { // On first load this.currentToolId === undefined so we need to skip sending // a devtools.main.exit telemetry event. if (this.currentToolId) { - this._telemetry.recordEvent("devtools.main", "exit", prevPanelName, null, { + this.telemetry.recordEvent("devtools.main", "exit", prevPanelName, null, { "host": this._hostType, "width": width, "panel_name": prevPanelName, @@ -1911,13 +1911,13 @@ Toolbox.prototype = { // Cold webconsole event message_count is handled in // devtools/client/webconsole/new-console-output-wrapper.js if (!cold) { - this._telemetry.addEventProperty( + this.telemetry.addEventProperty( "devtools.main", "enter", "webconsole", null, "message_count", 0); } } - this._telemetry.preparePendingEvent( + this.telemetry.preparePendingEvent( "devtools.main", "enter", panelName, null, pending); - this._telemetry.toolOpened(id); + this.telemetry.toolOpened(id); }, /** @@ -1985,7 +1985,7 @@ Toolbox.prototype = { return this.loadTool("webconsole").then(() => { this.component.setIsSplitConsoleActive(true); - this._telemetry.recordEvent("devtools.main", "activate", "split_console", null, { + this.telemetry.recordEvent("devtools.main", "activate", "split_console", null, { "host": this._getTelemetryHostString(), "width": Math.ceil(this.win.outerWidth / 50) * 50 }); @@ -2006,7 +2006,7 @@ Toolbox.prototype = { this._refreshConsoleDisplay(); this.component.setIsSplitConsoleActive(false); - this._telemetry.recordEvent("devtools.main", "deactivate", "split_console", null, { + this.telemetry.recordEvent("devtools.main", "deactivate", "split_console", null, { "host": this._getTelemetryHostString(), "width": Math.ceil(this.win.outerWidth / 50) * 50 }); @@ -2458,7 +2458,7 @@ Toolbox.prototype = { this.focusTool(this.currentToolId, true); this.emit("host-changed"); - this._telemetry.log(HOST_HISTOGRAM, this._getTelemetryHostId()); + this.telemetry.log(HOST_HISTOGRAM, this._getTelemetryHostId()); this.component.setCurrentHostType(hostType); }, @@ -2842,19 +2842,19 @@ Toolbox.prototype = { const width = Math.ceil(win.outerWidth / 50) * 50; const prevPanelName = this.getTelemetryPanelName(this.currentToolId); - this._telemetry.toolClosed("toolbox"); - this._telemetry.recordEvent("devtools.main", "close", "tools", null, { + this.telemetry.toolClosed("toolbox"); + this.telemetry.recordEvent("devtools.main", "close", "tools", null, { host: host, width: width }); - this._telemetry.recordEvent("devtools.main", "exit", prevPanelName, null, { + this.telemetry.recordEvent("devtools.main", "exit", prevPanelName, null, { "host": host, "width": width, "panel_name": this.getTelemetryPanelName(this.currentToolId), "next_panel": "none", "reason": "toolbox_close" }); - this._telemetry.destroy(); + this.telemetry.destroy(); // Finish all outstanding tasks (which means finish destroying panels and // then destroying the host, successfully or not) before destroying the diff --git a/devtools/client/inspector/inspector.js b/devtools/client/inspector/inspector.js index 6185d64bfa42..1cef8ed7d316 100644 --- a/devtools/client/inspector/inspector.js +++ b/devtools/client/inspector/inspector.js @@ -13,7 +13,6 @@ const promise = require("promise"); const EventEmitter = require("devtools/shared/event-emitter"); const {executeSoon} = require("devtools/shared/DevToolsUtils"); const {Toolbox} = require("devtools/client/framework/toolbox"); -const Telemetry = require("devtools/client/shared/telemetry"); const HighlightersOverlay = require("devtools/client/inspector/shared/highlighters-overlay"); const ReflowTracker = require("devtools/client/inspector/shared/reflow-tracker"); const Store = require("devtools/client/inspector/store"); @@ -104,6 +103,7 @@ function Inspector(toolbox) { this.panelDoc = window.document; this.panelWin = window; this.panelWin.inspector = this; + this.telemetry = toolbox.telemetry; this.store = Store(); @@ -114,7 +114,6 @@ function Inspector(toolbox) { this.highlighters = new HighlightersOverlay(this); this.reflowTracker = new ReflowTracker(this._target); this.styleChangeTracker = new InspectorStyleChangeTracker(this); - this.telemetry = new Telemetry(); // Store the URL of the target page prior to navigation in order to ensure // telemetry counts in the Grid Inspector are not double counted on reload. @@ -1340,6 +1339,8 @@ Inspector.prototype = { this.styleChangeTracker.destroy(); this.search.destroy(); + this.telemetry = null; + this._target = null; this._toolbox = null; this.breadcrumbs = null; this.highlighters = null; @@ -1354,7 +1355,6 @@ Inspector.prototype = { this.show3PaneTooltip = null; this.sidebar = null; this.store = null; - this.target = null; this.threePaneTooltip = null; this._panelDestroyer = promise.all([ diff --git a/devtools/client/inspector/toolsidebar.js b/devtools/client/inspector/toolsidebar.js index 073697602c6c..a1642ac987c1 100644 --- a/devtools/client/inspector/toolsidebar.js +++ b/devtools/client/inspector/toolsidebar.js @@ -6,8 +6,7 @@ "use strict"; -var EventEmitter = require("devtools/shared/event-emitter"); -var Telemetry = require("devtools/client/shared/telemetry"); +const EventEmitter = require("devtools/shared/event-emitter"); /** * This object represents replacement for ToolSidebar @@ -31,7 +30,7 @@ function ToolSidebar(tabbox, panel, uid, options = {}) { this._options = options; if (!options.disableTelemetry) { - this._telemetry = new Telemetry(); + this._telemetry = this._toolPanel.telemetry; } this._tabs = []; @@ -347,6 +346,7 @@ ToolSidebar.prototype = { this._tabs = null; this._tabbox = null; + this._telemetry = null; this._panelDoc = null; this._toolPanel = null; }