Bug 1378863 - Add telemetry probe to track DevTools entry points. r=jdescottes datareview=francois
MozReview-Commit-ID: CvhK7Lvw5oP
--- a/devtools/client/devtools-startup.js
+++ b/devtools/client/devtools-startup.js
@@ -245,17 +245,17 @@ DevToolsStartup.prototype = {
viewId: "PanelUI-developer",
shortcutId: "key_toggleToolbox",
tooltiptext: "developer-button.tooltiptext2",
defaultArea: AppConstants.MOZ_DEV_EDITION ?
CustomizableUI.AREA_NAVBAR :
CustomizableUI.AREA_PANEL,
onViewShowing: (event) => {
// Ensure creating the menuitems in the system menu before trying to copy them.
- this.initDevTools();
+ this.initDevTools("HamburgerMenu");
// Populate the subview with whatever menuitems are in the developer
// menu. We skip menu elements, because the menu panel has no way
// of dealing with those right now.
let doc = event.target.ownerDocument;
let menu = doc.getElementById("menuWebDeveloperPopup");
@@ -295,17 +295,19 @@ DevToolsStartup.prototype = {
/*
* We listen to the "Web Developer" system menu, which is under "Tools" main item.
* This menu item is hardcoded empty in Firefox UI. We listen for its opening to
* populate it lazily. Loading main DevTools module is going to populate it.
*/
hookWebDeveloperMenu(window) {
let menu = window.document.getElementById("webDeveloperMenu");
- menu.addEventListener("popupshowing", () => this.initDevTools(), { once: true });
+ menu.addEventListener("popupshowing", () => {
+ this.initDevTools("SystemMenu");
+ }, { once: true });
},
hookKeyShortcuts(window) {
let doc = window.document;
let keyset = doc.createElement("keyset");
keyset.setAttribute("id", "devtoolsKeyset");
for (let key of KeyShortcuts) {
@@ -316,17 +318,17 @@ DevToolsStartup.prototype = {
// Appending a <key> element is not always enough. The <keyset> needs
// to be detached and reattached to make sure the <key> is taken into
// account (see bug 832984).
let mainKeyset = doc.getElementById("mainKeyset");
mainKeyset.parentNode.insertBefore(keyset, mainKeyset);
},
onKey(window, key) {
- let require = this.initDevTools();
+ let require = this.initDevTools("KeyShortcut");
let { gDevToolsBrowser } = require("devtools/client/framework/devtools-browser");
gDevToolsBrowser.onKeyShortcut(window, key);
},
// Create a <xul:key> DOM Element
createKey(doc, { id, toolId, shortcut, modifiers: mod }, oncommand) {
let k = doc.createElement("key");
k.id = "key_" + (id || toolId);
@@ -349,29 +351,40 @@ DevToolsStartup.prototype = {
},
/**
* Boolean flag to check if DevTools have been already initialized or not.
* By initialized, we mean that its main modules are loaded.
*/
initialized: false,
- initDevTools: function () {
+ initDevTools: function (reason) {
+ if (!this.initialized) {
+ // Only save the first call for each firefox run as next call
+ // won't necessarely start the tool. For example key shortcuts may
+ // only change the currently selected tool.
+ try {
+ Services.telemetry.getHistogramById("DEVTOOLS_ENTRY_POINT")
+ .add(reason);
+ } catch (e) {
+ dump("DevTools telemetry entry point failed: " + e + "\n");
+ }
+ }
this.initialized = true;
let { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
// Ensure loading main devtools module that hooks up into browser UI
// and initialize all devtools machinery.
require("devtools/client/framework/devtools-browser");
return require;
},
handleConsoleFlag: function (cmdLine) {
let window = Services.wm.getMostRecentWindow("devtools:webconsole");
if (!window) {
- this.initDevTools();
+ this.initDevTools("CommandLine");
let { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
let hudservice = require("devtools/client/webconsole/hudservice");
let { console } = Cu.import("resource://gre/modules/Console.jsm", {});
hudservice.toggleBrowserConsole().catch(console.error);
} else {
// the Browser Console was already open
window.focus();
@@ -379,17 +392,17 @@ DevToolsStartup.prototype = {
if (cmdLine.state == Ci.nsICommandLine.STATE_REMOTE_AUTO) {
cmdLine.preventDefault = true;
}
},
// Open the toolbox on the selected tab once the browser starts up.
handleDevToolsFlag: function (window) {
- const require = this.initDevTools();
+ const require = this.initDevTools("CommandLine");
const {gDevTools} = require("devtools/client/framework/devtools");
const {TargetFactory} = require("devtools/client/framework/target");
let target = TargetFactory.forTab(window.gBrowser.selectedTab);
gDevTools.showToolbox(target);
},
_isRemoteDebuggingEnabled() {
let remoteDebuggingEnabled = false;
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -9321,16 +9321,26 @@
"WEBRTC_CALL_TYPE": {
"record_in_processes": ["main", "content"],
"alert_emails": ["webrtc-telemetry-alerts@mozilla.com"],
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 8,
"description": "Type of call: (Bitmask) Audio = 1, Video = 2, DataChannels = 4"
},
+ "DEVTOOLS_ENTRY_POINT": {
+ "record_in_processes": ["main"],
+ "bug_numbers": [1378863],
+ "alert_emails": ["dev-developer-tools@lists.mozilla.org", "apoirot@mozilla.com"],
+ "expires_in_version": "60",
+ "kind": "categorical",
+ "labels": ["KeyShortcut", "SystemMenu", "HamburgerMenu", "ContextMenu", "CommandLine"],
+ "releaseChannelCollection": "opt-out",
+ "description": "Records how the user is triggering Developer Tools startup."
+ },
"DEVTOOLS_TOOLBOX_OPENED_COUNT": {
"record_in_processes": ["main", "content"],
"alert_emails": ["dev-developer-tools@lists.mozilla.org"],
"expires_in_version": "never",
"kind": "count",
"bug_numbers": [1247985],
"description": "Number of times the DevTools toolbox has been opened.",
"releaseChannelCollection": "opt-out"