Bug 1046234 - Add more DevTools Telemetry measures (display size etc.) r=pbrosset, r=gijs

This commit is contained in:
Michael Ratcliffe 2015-03-13 11:52:45 +00:00
Родитель f97a2b3f70
Коммит 2b45132b59
5 изменённых файлов: 200 добавлений и 9 удалений

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

@ -27,6 +27,13 @@ XPCOMUtils.defineLazyModuleGetter(this, "DebuggerClient",
"resource://gre/modules/devtools/dbg-client.jsm");
const EventEmitter = devtools.require("devtools/toolkit/event-emitter");
const Telemetry = devtools.require("devtools/shared/telemetry");
const TABS_OPEN_PEAK_HISTOGRAM = "DEVTOOLS_TABS_OPEN_PEAK_LINEAR";
const TABS_OPEN_AVG_HISTOGRAM = "DEVTOOLS_TABS_OPEN_AVERAGE_LINEAR";
const TABS_PINNED_PEAK_HISTOGRAM = "DEVTOOLS_TABS_PINNED_PEAK_EXPONENTIAL";
const TABS_PINNED_AVG_HISTOGRAM = "DEVTOOLS_TABS_PINNED_AVERAGE_EXPONENTIAL";
const FORBIDDEN_IDS = new Set(["toolbox", ""]);
const MAX_ORDINAL = 99;
@ -467,6 +474,23 @@ DevTools.prototype = {
return toolbox.destroy().then(() => true);
},
_pingTelemetry: function() {
let mean = function(arr) {
if (arr.length === 0) {
return 0;
}
let total = arr.reduce((a, b) => a + b);
return Math.ceil(total / arr.length);
};
let tabStats = gDevToolsBrowser._tabStats;
this._telemetry.log(TABS_OPEN_PEAK_HISTOGRAM, tabStats.peakOpen);
this._telemetry.log(TABS_OPEN_AVG_HISTOGRAM, mean(tabStats.histOpen));
this._telemetry.log(TABS_PINNED_PEAK_HISTOGRAM, tabStats.peakPinned);
this._telemetry.log(TABS_PINNED_AVG_HISTOGRAM, mean(tabStats.histPinned));
},
/**
* Called to tear down a tools provider.
*/
@ -487,6 +511,9 @@ DevTools.prototype = {
this.unregisterTool(key, true);
}
this._pingTelemetry();
this._telemetry = null;
// Cleaning down the toolboxes: i.e.
// for (let [target, toolbox] of this._toolboxes) toolbox.destroy();
// Is taken care of by the gDevToolsBrowser.forgetBrowserWindow
@ -522,6 +549,13 @@ let gDevToolsBrowser = {
*/
_trackedBrowserWindows: new Set(),
_tabStats: {
peakOpen: 0,
peakPinned: 0,
histOpen: [],
histPinned: []
},
/**
* This function is for the benefit of Tools:DevToolbox in
* browser/base/content/browser-sets.inc and should not be used outside
@ -819,9 +853,12 @@ let gDevToolsBrowser = {
broadcaster.removeAttribute("key");
}
let tabContainer = win.document.getElementById("tabbrowser-tabs")
tabContainer.addEventListener("TabSelect",
gDevToolsBrowser._updateMenuCheckbox, false);
let tabContainer = win.document.getElementById("tabbrowser-tabs");
tabContainer.addEventListener("TabSelect", this, false);
tabContainer.addEventListener("TabOpen", this, false);
tabContainer.addEventListener("TabClose", this, false);
tabContainer.addEventListener("TabPinned", this, false);
tabContainer.addEventListener("TabUnpinned", this, false);
},
/**
@ -1253,9 +1290,40 @@ let gDevToolsBrowser = {
}
}
let tabContainer = win.document.getElementById("tabbrowser-tabs")
tabContainer.removeEventListener("TabSelect",
gDevToolsBrowser._updateMenuCheckbox, false);
let tabContainer = win.document.getElementById("tabbrowser-tabs");
tabContainer.removeEventListener("TabSelect", this, false);
tabContainer.removeEventListener("TabOpen", this, false);
tabContainer.removeEventListener("TabClose", this, false);
tabContainer.removeEventListener("TabPinned", this, false);
tabContainer.removeEventListener("TabUnpinned", this, false);
},
handleEvent: function(event) {
switch (event.type) {
case "TabOpen":
case "TabClose":
case "TabPinned":
case "TabUnpinned":
let open = 0;
let pinned = 0;
for (let win of this._trackedBrowserWindows) {
let tabContainer = win.gBrowser.tabContainer;
let numPinnedTabs = tabContainer.tabbrowser._numPinnedTabs;
let numTabs = tabContainer.itemCount - numPinnedTabs;
open += numTabs;
pinned += numPinnedTabs;
}
this._tabStats.histOpen.push(open);
this._tabStats.histPinned.push(pinned);
this._tabStats.peakOpen = Math.max(open, this._tabStats.peakOpen);
this._tabStats.peakPinned = Math.max(pinned, this._tabStats.peakPinned);
break;
case "TabSelect":
gDevToolsBrowser._updateMenuCheckbox();
}
},
/**

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

@ -10,6 +10,9 @@ const SPLITCONSOLE_ENABLED_PREF = "devtools.toolbox.splitconsoleEnabled";
const SPLITCONSOLE_HEIGHT_PREF = "devtools.toolbox.splitconsoleHeight";
const MIN_ZOOM = 0.5;
const MAX_ZOOM = 2;
const OS_HISTOGRAM = "DEVTOOLS_OS_ENUMERATED_PER_USER";
const OS_IS_64_BITS = "DEVTOOLS_OS_IS_64_BITS_PER_USER";
const SCREENSIZE_HISTOGRAM = "DEVTOOLS_SCREEN_RESOLUTION_ENUMERATED_PER_USER";
let {Cc, Ci, Cu} = require("chrome");
let {Promise: promise} = require("resource://gre/modules/Promise.jsm");
@ -49,6 +52,19 @@ loader.lazyGetter(this, "Selection", () => require("devtools/framework/selection
loader.lazyGetter(this, "InspectorFront", () => require("devtools/server/actors/inspector").InspectorFront);
loader.lazyRequireGetter(this, "DevToolsUtils", "devtools/toolkit/DevToolsUtils");
XPCOMUtils.defineLazyGetter(this, "screenManager", () => {
return Cc["@mozilla.org/gfx/screenmanager;1"].getService(Ci.nsIScreenManager);
});
XPCOMUtils.defineLazyGetter(this, "oscpu", () => {
return Cc["@mozilla.org/network/protocol;1?name=http"]
.getService(Ci.nsIHttpProtocolHandler).oscpu;
});
XPCOMUtils.defineLazyGetter(this, "is64Bit", () => {
return Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo).is64Bit;
});
// White-list buttons that can be toggled to prevent adding prefs for
// addons that have manually inserted toolbarbuttons into DOM.
// (By default, supported target is only local tab)
@ -334,7 +350,7 @@ Toolbox.prototype = {
let buttonsPromise = this._buildButtons();
this._telemetry.toolOpened("toolbox");
this._pingTelemetry();
this.selectTool(this._defaultToolId).then(panel => {
@ -359,7 +375,7 @@ Toolbox.prototype = {
// Load the toolbox-level actor fronts and utilities now
this._target.makeRemote().then(() => {
iframe.setAttribute("src", this._URL);
iframe.setAttribute("aria-label", toolboxStrings("toolbox.label"))
iframe.setAttribute("aria-label", toolboxStrings("toolbox.label"));
let domHelper = new DOMHelpers(iframe.contentWindow);
domHelper.onceDOMReady(domReady);
});
@ -368,6 +384,16 @@ Toolbox.prototype = {
}).then(null, console.error.bind(console));
},
_pingTelemetry: function() {
this._telemetry.toolOpened("toolbox");
this._telemetry.logOncePerBrowserVersion(OS_HISTOGRAM,
this._getOsCpu());
this._telemetry.logOncePerBrowserVersion(OS_IS_64_BITS, is64Bit ? 1 : 0);
this._telemetry.logOncePerBrowserVersion(SCREENSIZE_HISTOGRAM,
this._getScreenDimensions());
},
/**
* Because our panels are lazy loaded this is a good place to watch for
* "pref-changed" events.
@ -1575,6 +1601,41 @@ Toolbox.prototype = {
return this.doc.getElementById("toolbox-notificationbox");
},
_getScreenDimensions: function() {
let width = {};
let height = {};
screenManager.primaryScreen.GetRect({}, {}, width, height);
let dims = width.value + "x" + height.value;
if (width.value < 800 || height.value < 600) return 0;
if (dims === "800x600") return 1;
if (dims === "1024x768") return 2;
if (dims === "1280x800") return 3;
if (dims === "1280x1024") return 4;
if (dims === "1366x768") return 5;
if (dims === "1440x900") return 6;
if (dims === "1920x1080") return 7;
if (dims === "2560×1440") return 8;
if (dims === "2560×1600") return 9;
if (dims === "2880x1800") return 10;
if (width.value > 2880 || height.value > 1800) return 12;
return 11; // Other dimension such as a VM.
},
_getOsCpu: function() {
if (oscpu.contains("NT 5.1") || oscpu.contains("NT 5.2")) return 0;
if (oscpu.contains("NT 6.0")) return 1;
if (oscpu.contains("NT 6.1")) return 2;
if (oscpu.contains("NT 6.2")) return 3;
if (oscpu.contains("NT 6.3")) return 4;
if (oscpu.contains("OS X")) return 5;
if (oscpu.contains("Linux")) return 6;
return 12; // Other OS.
},
/**
* Destroy the current host, and remove event listeners from its frame.
*

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

@ -6546,6 +6546,52 @@
"kind": "boolean",
"description": "Was WebIDE's debug button used during this runtime connection?"
},
"DEVTOOLS_OS_ENUMERATED_PER_USER": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 13,
"description": "OS of DevTools user (0:Windows XP, 1:Windows Vista, 2:Windows 7, 3:Windows 8, 4:Windows 8.1, 5:OSX, 6:Linux 7:reserved, 8:reserved, 9:reserved, 10:reserved, 11:reserved, 12:other)"
},
"DEVTOOLS_OS_IS_64_BITS_PER_USER": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 3,
"description": "OS bit size of DevTools user (0:32bit, 1:64bit, 2:128bit)"
},
"DEVTOOLS_SCREEN_RESOLUTION_ENUMERATED_PER_USER": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 13,
"description": "Screen resolution of DevTools user (0:lower, 1:800x600, 2:1024x768, 3:1280x800, 4:1280x1024, 5:1366x768, 6:1440x900, 7:1920x1080, 8:2560×1440, 9:2560×1600, 10:2880x1800, 11:other, 12:higher)"
},
"DEVTOOLS_TABS_OPEN_PEAK_LINEAR": {
"expires_in_version": "never",
"kind": "linear",
"high": "101",
"n_buckets": 100,
"description": "The peak number of open tabs in all windows for a session for devtools users."
},
"DEVTOOLS_TABS_OPEN_AVERAGE_EXPONENTIAL": {
"expires_in_version": "never",
"kind": "exponential",
"high": "101",
"n_buckets": "100",
"description": "The mean number of open tabs in all windows for a session for devtools users."
},
"DEVTOOLS_TABS_PINNED_PEAK_EXPONENTIAL": {
"expires_in_version": "never",
"kind": "exponential",
"high": "101",
"n_buckets": "100",
"description": "The peak number of pinned tabs (app tabs) in all windows for a session for devtools users."
},
"DEVTOOLS_TABS_PINNED_AVERAGE_LINEAR": {
"expires_in_version": "never",
"kind": "linear",
"high": "101",
"n_buckets": "100",
"description": "The mean number of pinned tabs (app tabs) in all windows for a session for devtools users."
},
"BROWSER_IS_USER_DEFAULT": {
"expires_in_version": "never",
"kind": "boolean",

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

@ -909,6 +909,17 @@ nsXULAppInfo::GetAccessibilityIsUIA(bool* aResult)
return NS_OK;
}
NS_IMETHODIMP
nsXULAppInfo::GetIs64Bit(bool* aResult)
{
#ifdef HAVE_64BIT_BUILD
*aResult = true;
#else
*aResult = false;
#endif
return NS_OK;
}
NS_IMETHODIMP
nsXULAppInfo::EnsureContentProcess()
{

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

@ -23,7 +23,7 @@ bool BrowserTabsRemoteAutostart();
* stable/frozen, please contact Benjamin Smedberg.
*/
[scriptable, uuid(fb861ca6-426f-4edf-844e-bbabec9bbc1a)]
[scriptable, uuid(5754b56e-f392-426d-aec0-3ba7c49aff32)]
interface nsIXULRuntime : nsISupports
{
/**
@ -109,6 +109,11 @@ interface nsIXULRuntime : nsISupports
*/
readonly attribute boolean accessibilityIsUIA;
/**
* Indicates whether the current Firefox build is 64-bit.
*/
readonly attribute boolean is64Bit;
/**
* Signal the apprunner to invalidate caches on the next restart.
* This will cause components to be autoregistered and all