Bug 1456772 - Fix web console message_count reporting r?yulia
MozReview-Commit-ID: 4DoChJ5AtCG
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -1877,23 +1877,24 @@ Toolbox.prototype = {
return panel;
});
},
_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, {
"host": this._hostType,
"width": width,
"start_state": reason,
"panel_name": id,
- "cold": !this.getPanel(id)
+ "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, {
"host": this._hostType,
"width": width,
@@ -1901,16 +1902,23 @@ Toolbox.prototype = {
"next_panel": id,
"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(
+ "devtools.main", "enter", "webconsole", null, "message_count", 0);
+ }
}
this._telemetry.preparePendingEvent(
"devtools.main", "enter", panelName, null, pending);
this._telemetry.toolOpened(id);
},
/**
* Focus a tool's panel by id
--- a/devtools/client/webconsole/new-console-output-wrapper.js
+++ b/devtools/client/webconsole/new-console-output-wrapper.js
@@ -8,16 +8,17 @@ const dom = require("devtools/client/sha
const ReactDOM = require("devtools/client/shared/vendor/react-dom");
const { Provider } = require("devtools/client/shared/vendor/react-redux");
const actions = require("devtools/client/webconsole/actions/index");
const { createContextMenu } = require("devtools/client/webconsole/utils/context-menu");
const { configureStore } = require("devtools/client/webconsole/store");
const { isPacketPrivate } = require("devtools/client/webconsole/utils/messages");
const { getAllMessagesById, getMessage } = require("devtools/client/webconsole/selectors/messages");
+const Telemetry = require("devtools/client/shared/telemetry");
const EventEmitter = require("devtools/shared/event-emitter");
const ConsoleOutput = createFactory(require("devtools/client/webconsole/components/ConsoleOutput"));
const FilterBar = createFactory(require("devtools/client/webconsole/components/FilterBar"));
const SideBar = createFactory(require("devtools/client/webconsole/components/SideBar"));
const JSTerm = createFactory(require("devtools/client/webconsole/components/JSTerm"));
let store = null;
@@ -33,16 +34,18 @@ function NewConsoleOutputWrapper(parentN
this.init = this.init.bind(this);
this.queuedMessageAdds = [];
this.queuedMessageUpdates = [];
this.queuedRequestUpdates = [];
this.throttledDispatchPromise = null;
+ this._telemetry = new Telemetry();
+
store = configureStore(this.hud);
}
NewConsoleOutputWrapper.prototype = {
init: function() {
return new Promise((resolve) => {
const attachRefToHud = (id, node) => {
this.hud[id] = node;
};
@@ -381,16 +384,21 @@ NewConsoleOutputWrapper.prototype = {
return;
}
this.throttledDispatchPromise = new Promise(done => {
setTimeout(() => {
this.throttledDispatchPromise = null;
store.dispatch(actions.messagesAdd(this.queuedMessageAdds));
+
+ const length = this.queuedMessageAdds.length;
+ this._telemetry.addEventProperty(
+ "devtools.main", "enter", "webconsole", null, "message_count", length);
+
this.queuedMessageAdds = [];
if (this.queuedMessageUpdates.length > 0) {
this.queuedMessageUpdates.forEach(({ message, res }) => {
store.dispatch(actions.networkMessageUpdate(message, null, res));
this.hud.emit("network-message-updated", res);
});
this.queuedMessageUpdates = [];
--- a/devtools/server/actors/webconsole.js
+++ b/devtools/server/actors/webconsole.js
@@ -25,17 +25,16 @@ loader.lazyRequireGetter(this, "StackTra
loader.lazyRequireGetter(this, "JSPropertyProvider", "devtools/shared/webconsole/js-property-provider", true);
loader.lazyRequireGetter(this, "Parser", "resource://devtools/shared/Parser.jsm", true);
loader.lazyRequireGetter(this, "NetUtil", "resource://gre/modules/NetUtil.jsm", true);
loader.lazyRequireGetter(this, "addWebConsoleCommands", "devtools/server/actors/webconsole/utils", true);
loader.lazyRequireGetter(this, "CONSOLE_WORKER_IDS", "devtools/server/actors/webconsole/utils", true);
loader.lazyRequireGetter(this, "WebConsoleUtils", "devtools/server/actors/webconsole/utils", true);
loader.lazyRequireGetter(this, "EnvironmentActor", "devtools/server/actors/environment", true);
loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
-loader.lazyRequireGetter(this, "Telemetry", "devtools/client/shared/telemetry");
// Overwrite implemented listeners for workers so that we don't attempt
// to load an unsupported module.
if (isWorker) {
loader.lazyRequireGetter(this, "ConsoleAPIListener", "devtools/server/actors/webconsole/worker-listeners", true);
loader.lazyRequireGetter(this, "ConsoleServiceListener", "devtools/server/actors/webconsole/worker-listeners", true);
} else {
loader.lazyRequireGetter(this, "ConsoleAPIListener", "devtools/server/actors/webconsole/listeners", true);
@@ -71,18 +70,16 @@ function WebConsoleActor(connection, par
this.dbg = this.parentActor.makeDebugger();
this._netEvents = new Map();
this._networkEventActorsByURL = new Map();
this._gripDepth = 0;
this._listeners = new Set();
this._lastConsoleInputEvaluation = undefined;
- this._telemetry = new Telemetry();
-
this.objectGrip = this.objectGrip.bind(this);
this._onWillNavigate = this._onWillNavigate.bind(this);
this._onChangedToplevelDocument = this._onChangedToplevelDocument.bind(this);
EventEmitter.on(this.parentActor, "changed-toplevel-document",
this._onChangedToplevelDocument);
this._onObserverNotification = this._onObserverNotification.bind(this);
if (this.parentActor.isRootActor) {
Services.obs.addObserver(this._onObserverNotification,
@@ -860,19 +857,16 @@ WebConsoleActor.prototype =
}
messages.push(message);
});
break;
}
}
}
- this._telemetry.addEventProperty(
- "devtools.main", "enter", "webconsole", null, "message_count", messages.length);
-
return {
from: this.actorID,
messages: messages,
};
},
/**
* Handler for the "evaluateJSAsync" request. This method evaluates the given