--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -104,24 +104,24 @@ loader.lazyGetter(this, "registerHarOver
* @param {string} frameId
* A unique identifier to differentiate toolbox documents from the
* chrome codebase when passing DOM messages
*/
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<extensionUUID, extensionName>
this._webExtensions = new Map();
this._toolPanels = new Map();
this._inspectorExtensionSidebars = new Map();
- this._telemetry = new Telemetry();
this._initInspector = null;
this._inspector = null;
this._styleSheets = null;
this._netMonitorAPI = null;
// Map of frames (id => frame-info) and currently selected frame id.
this.frameMap = new Map();
@@ -540,20 +540,20 @@ Toolbox.prototype = {
await this.selectTool(this._defaultToolId, "initial_panel");
// Wait until the original tool is selected so that the split
// console input will receive focus.
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);
}
await promise.all([
splitConsolePromise,
framesPromise
]);
@@ -711,32 +711,32 @@ Toolbox.prototype = {
case Toolbox.HostType.SIDE: return "side";
case Toolbox.HostType.WINDOW: return "window";
case Toolbox.HostType.CUSTOM: return "other";
default: return "bottom";
}
},
_pingTelemetry: function() {
- this._telemetry.toolOpened("toolbox");
-
- this._telemetry.logOncePerBrowserVersion(SCREENSIZE_HISTOGRAM,
+ this.telemetry.toolOpened("toolbox");
+
+ 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.preparePendingEvent(
+ this.telemetry.logKeyedScalar(CURRENT_THEME_SCALAR, currentTheme, 1);
+
+ 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()
);
},
/**
* Create a simple object to store the state of a toolbox button. The checked state of
* a button can be updated arbitrarily outside of the scope of the toolbar and its
* controllers. In order to simplify this interaction this object emits an
@@ -1844,17 +1844,17 @@ Toolbox.prototype = {
throw new Error("Can't select tool, wait for toolbox 'ready' event");
}
// Check if the tool exists.
if (this.panelDefinitions.find((definition) => definition.id === id) ||
id === "options" ||
this.additionalToolDefinitions.get(id)) {
if (this.currentToolId) {
- this._telemetry.toolClosed(this.currentToolId);
+ this.telemetry.toolClosed(this.currentToolId);
}
this._pingTelemetrySelectTool(id, reason);
} else {
throw new Error("No tool found");
}
// and select the right iframe
@@ -1879,50 +1879,50 @@ Toolbox.prototype = {
},
_pingTelemetrySelectTool(id, reason) {
const width = Math.ceil(this.win.outerWidth / 50) * 50;
const panelName = this.getTelemetryPanelName(id);
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,
"panel_name": panelName,
"cold": cold
});
// 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,
"next_panel": panelName,
"reason": reason
});
}
const pending = ["host", "width", "start_state", "panel_name", "cold"];
if (id === "webconsole") {
pending.push("message_count");
// 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);
},
/**
* Focus a tool's panel by id
* @param {string} id
* The id of tool to focus
*/
focusTool: function(id, state = true) {
@@ -1980,17 +1980,17 @@ Toolbox.prototype = {
// Ensure split console is visible if console was already loaded in background
let iframe = this.webconsolePanel.querySelector(".toolbox-panel-iframe");
if (iframe) {
this.setIframeVisible(iframe, true);
}
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
});
this.emit("split-console");
this.focusConsoleInput();
});
},
@@ -2001,17 +2001,17 @@ Toolbox.prototype = {
* closed.
*/
closeSplitConsole: function() {
this._splitConsole = false;
Services.prefs.setBoolPref(SPLITCONSOLE_ENABLED_PREF, false);
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
});
this.emit("split-console");
if (this._lastFocusedElement) {
this._lastFocusedElement.focus();
@@ -2453,17 +2453,17 @@ Toolbox.prototype = {
this._buildDockOptions();
this._addKeysToWindow();
// We blurred the tools at start of switchHost, but also when clicking on
// host switching button. We now have to restore the focus.
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);
},
/**
* Test the availability of a tool (both globally registered tools and
* additional tools registered to this toolbox) by tool id.
*
@@ -2837,29 +2837,29 @@ Toolbox.prototype = {
});
// We need to grab a reference to win before this._host is destroyed.
const win = this.win;
const host = this._getTelemetryHostString();
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
// target.
deferred.resolve(settleAll(outstanding)
.catch(console.error)
.then(() => {
let api = this._netMonitorAPI;