Bug 1458770 - Use the toolbox's Telemetry instance in the Inspector. r=miker

This commit is contained in:
Gabriel Luong 2018-05-04 09:36:11 -04:00
Родитель c6174cef5a
Коммит 811900ed03
3 изменённых файлов: 28 добавлений и 28 удалений

Просмотреть файл

@ -109,6 +109,7 @@ function Toolbox(target, selectedTool, hostType, contentWindow, frameId) {
this._target = target; this._target = target;
this._win = contentWindow; this._win = contentWindow;
this.frameId = frameId; this.frameId = frameId;
this.telemetry = new Telemetry();
// Map of the available DevTools WebExtensions: // Map of the available DevTools WebExtensions:
// Map<extensionUUID, extensionName> // Map<extensionUUID, extensionName>
@ -116,7 +117,6 @@ function Toolbox(target, selectedTool, hostType, contentWindow, frameId) {
this._toolPanels = new Map(); this._toolPanels = new Map();
this._inspectorExtensionSidebars = new Map(); this._inspectorExtensionSidebars = new Map();
this._telemetry = new Telemetry();
this._initInspector = null; this._initInspector = null;
this._inspector = null; this._inspector = null;
@ -545,10 +545,10 @@ Toolbox.prototype = {
let splitConsolePromise = promise.resolve(); let splitConsolePromise = promise.resolve();
if (Services.prefs.getBoolPref(SPLITCONSOLE_ENABLED_PREF)) { if (Services.prefs.getBoolPref(SPLITCONSOLE_ENABLED_PREF)) {
splitConsolePromise = this.openSplitConsole(); splitConsolePromise = this.openSplitConsole();
this._telemetry.addEventProperty( this.telemetry.addEventProperty(
"devtools.main", "open", "tools", null, "splitconsole", true); "devtools.main", "open", "tools", null, "splitconsole", true);
} else { } else {
this._telemetry.addEventProperty( this.telemetry.addEventProperty(
"devtools.main", "open", "tools", null, "splitconsole", false); "devtools.main", "open", "tools", null, "splitconsole", false);
} }
@ -716,22 +716,22 @@ Toolbox.prototype = {
}, },
_pingTelemetry: function() { _pingTelemetry: function() {
this._telemetry.toolOpened("toolbox"); this.telemetry.toolOpened("toolbox");
this._telemetry.logOncePerBrowserVersion(SCREENSIZE_HISTOGRAM, this.telemetry.logOncePerBrowserVersion(SCREENSIZE_HISTOGRAM,
system.getScreenDimensions()); 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: // Log current theme. The question we want to answer is:
// "What proportion of users use which themes?" // "What proportion of users use which themes?"
let currentTheme = Services.prefs.getCharPref("devtools.theme"); 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, "devtools.main", "open", "tools", null,
["entrypoint", "first_panel", "host", "splitconsole", "width"] ["entrypoint", "first_panel", "host", "splitconsole", "width"]
); );
this._telemetry.addEventProperty( this.telemetry.addEventProperty(
"devtools.main", "open", "tools", null, "host", this._getTelemetryHostString() "devtools.main", "open", "tools", null, "host", this._getTelemetryHostString()
); );
}, },
@ -1849,7 +1849,7 @@ Toolbox.prototype = {
id === "options" || id === "options" ||
this.additionalToolDefinitions.get(id)) { this.additionalToolDefinitions.get(id)) {
if (this.currentToolId) { if (this.currentToolId) {
this._telemetry.toolClosed(this.currentToolId); this.telemetry.toolClosed(this.currentToolId);
} }
this._pingTelemetrySelectTool(id, reason); this._pingTelemetrySelectTool(id, reason);
@ -1884,7 +1884,7 @@ Toolbox.prototype = {
const prevPanelName = this.getTelemetryPanelName(this.currentToolId); const prevPanelName = this.getTelemetryPanelName(this.currentToolId);
const cold = !this.getPanel(id); const cold = !this.getPanel(id);
this._telemetry.addEventProperties("devtools.main", "enter", panelName, null, { this.telemetry.addEventProperties("devtools.main", "enter", panelName, null, {
"host": this._hostType, "host": this._hostType,
"width": width, "width": width,
"start_state": reason, "start_state": reason,
@ -1895,7 +1895,7 @@ Toolbox.prototype = {
// On first load this.currentToolId === undefined so we need to skip sending // On first load this.currentToolId === undefined so we need to skip sending
// a devtools.main.exit telemetry event. // a devtools.main.exit telemetry event.
if (this.currentToolId) { if (this.currentToolId) {
this._telemetry.recordEvent("devtools.main", "exit", prevPanelName, null, { this.telemetry.recordEvent("devtools.main", "exit", prevPanelName, null, {
"host": this._hostType, "host": this._hostType,
"width": width, "width": width,
"panel_name": prevPanelName, "panel_name": prevPanelName,
@ -1911,13 +1911,13 @@ Toolbox.prototype = {
// Cold webconsole event message_count is handled in // Cold webconsole event message_count is handled in
// devtools/client/webconsole/new-console-output-wrapper.js // devtools/client/webconsole/new-console-output-wrapper.js
if (!cold) { if (!cold) {
this._telemetry.addEventProperty( this.telemetry.addEventProperty(
"devtools.main", "enter", "webconsole", null, "message_count", 0); "devtools.main", "enter", "webconsole", null, "message_count", 0);
} }
} }
this._telemetry.preparePendingEvent( this.telemetry.preparePendingEvent(
"devtools.main", "enter", panelName, null, pending); "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(() => { return this.loadTool("webconsole").then(() => {
this.component.setIsSplitConsoleActive(true); 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(), "host": this._getTelemetryHostString(),
"width": Math.ceil(this.win.outerWidth / 50) * 50 "width": Math.ceil(this.win.outerWidth / 50) * 50
}); });
@ -2006,7 +2006,7 @@ Toolbox.prototype = {
this._refreshConsoleDisplay(); this._refreshConsoleDisplay();
this.component.setIsSplitConsoleActive(false); 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(), "host": this._getTelemetryHostString(),
"width": Math.ceil(this.win.outerWidth / 50) * 50 "width": Math.ceil(this.win.outerWidth / 50) * 50
}); });
@ -2458,7 +2458,7 @@ Toolbox.prototype = {
this.focusTool(this.currentToolId, true); this.focusTool(this.currentToolId, true);
this.emit("host-changed"); this.emit("host-changed");
this._telemetry.log(HOST_HISTOGRAM, this._getTelemetryHostId()); this.telemetry.log(HOST_HISTOGRAM, this._getTelemetryHostId());
this.component.setCurrentHostType(hostType); this.component.setCurrentHostType(hostType);
}, },
@ -2842,19 +2842,19 @@ Toolbox.prototype = {
const width = Math.ceil(win.outerWidth / 50) * 50; const width = Math.ceil(win.outerWidth / 50) * 50;
const prevPanelName = this.getTelemetryPanelName(this.currentToolId); const prevPanelName = this.getTelemetryPanelName(this.currentToolId);
this._telemetry.toolClosed("toolbox"); this.telemetry.toolClosed("toolbox");
this._telemetry.recordEvent("devtools.main", "close", "tools", null, { this.telemetry.recordEvent("devtools.main", "close", "tools", null, {
host: host, host: host,
width: width width: width
}); });
this._telemetry.recordEvent("devtools.main", "exit", prevPanelName, null, { this.telemetry.recordEvent("devtools.main", "exit", prevPanelName, null, {
"host": host, "host": host,
"width": width, "width": width,
"panel_name": this.getTelemetryPanelName(this.currentToolId), "panel_name": this.getTelemetryPanelName(this.currentToolId),
"next_panel": "none", "next_panel": "none",
"reason": "toolbox_close" "reason": "toolbox_close"
}); });
this._telemetry.destroy(); this.telemetry.destroy();
// Finish all outstanding tasks (which means finish destroying panels and // Finish all outstanding tasks (which means finish destroying panels and
// then destroying the host, successfully or not) before destroying the // then destroying the host, successfully or not) before destroying the

Просмотреть файл

@ -13,7 +13,6 @@ const promise = require("promise");
const EventEmitter = require("devtools/shared/event-emitter"); const EventEmitter = require("devtools/shared/event-emitter");
const {executeSoon} = require("devtools/shared/DevToolsUtils"); const {executeSoon} = require("devtools/shared/DevToolsUtils");
const {Toolbox} = require("devtools/client/framework/toolbox"); const {Toolbox} = require("devtools/client/framework/toolbox");
const Telemetry = require("devtools/client/shared/telemetry");
const HighlightersOverlay = require("devtools/client/inspector/shared/highlighters-overlay"); const HighlightersOverlay = require("devtools/client/inspector/shared/highlighters-overlay");
const ReflowTracker = require("devtools/client/inspector/shared/reflow-tracker"); const ReflowTracker = require("devtools/client/inspector/shared/reflow-tracker");
const Store = require("devtools/client/inspector/store"); const Store = require("devtools/client/inspector/store");
@ -104,6 +103,7 @@ function Inspector(toolbox) {
this.panelDoc = window.document; this.panelDoc = window.document;
this.panelWin = window; this.panelWin = window;
this.panelWin.inspector = this; this.panelWin.inspector = this;
this.telemetry = toolbox.telemetry;
this.store = Store(); this.store = Store();
@ -114,7 +114,6 @@ function Inspector(toolbox) {
this.highlighters = new HighlightersOverlay(this); this.highlighters = new HighlightersOverlay(this);
this.reflowTracker = new ReflowTracker(this._target); this.reflowTracker = new ReflowTracker(this._target);
this.styleChangeTracker = new InspectorStyleChangeTracker(this); this.styleChangeTracker = new InspectorStyleChangeTracker(this);
this.telemetry = new Telemetry();
// Store the URL of the target page prior to navigation in order to ensure // 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. // telemetry counts in the Grid Inspector are not double counted on reload.
@ -1340,6 +1339,8 @@ Inspector.prototype = {
this.styleChangeTracker.destroy(); this.styleChangeTracker.destroy();
this.search.destroy(); this.search.destroy();
this.telemetry = null;
this._target = null;
this._toolbox = null; this._toolbox = null;
this.breadcrumbs = null; this.breadcrumbs = null;
this.highlighters = null; this.highlighters = null;
@ -1354,7 +1355,6 @@ Inspector.prototype = {
this.show3PaneTooltip = null; this.show3PaneTooltip = null;
this.sidebar = null; this.sidebar = null;
this.store = null; this.store = null;
this.target = null;
this.threePaneTooltip = null; this.threePaneTooltip = null;
this._panelDestroyer = promise.all([ this._panelDestroyer = promise.all([

Просмотреть файл

@ -6,8 +6,7 @@
"use strict"; "use strict";
var EventEmitter = require("devtools/shared/event-emitter"); const EventEmitter = require("devtools/shared/event-emitter");
var Telemetry = require("devtools/client/shared/telemetry");
/** /**
* This object represents replacement for ToolSidebar * This object represents replacement for ToolSidebar
@ -31,7 +30,7 @@ function ToolSidebar(tabbox, panel, uid, options = {}) {
this._options = options; this._options = options;
if (!options.disableTelemetry) { if (!options.disableTelemetry) {
this._telemetry = new Telemetry(); this._telemetry = this._toolPanel.telemetry;
} }
this._tabs = []; this._tabs = [];
@ -347,6 +346,7 @@ ToolSidebar.prototype = {
this._tabs = null; this._tabs = null;
this._tabbox = null; this._tabbox = null;
this._telemetry = null;
this._panelDoc = null; this._panelDoc = null;
this._toolPanel = null; this._toolPanel = null;
} }