зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1076857 - Add basic telemetry to Storage Inspector. r=mratcliffe
This commit is contained in:
Родитель
2da9dfd0ef
Коммит
b723a94632
|
@ -145,6 +145,11 @@ Telemetry.prototype = {
|
|||
userHistogram: "DEVTOOLS_NETMONITOR_OPENED_PER_USER_FLAG",
|
||||
timerHistogram: "DEVTOOLS_NETMONITOR_TIME_ACTIVE_SECONDS"
|
||||
},
|
||||
storage: {
|
||||
histogram: "DEVTOOLS_STORAGE_OPENED_BOOLEAN",
|
||||
userHistogram: "DEVTOOLS_STORAGE_OPENED_PER_USER_FLAG",
|
||||
timerHistogram: "DEVTOOLS_STORAGE_TIME_ACTIVE_SECONDS"
|
||||
},
|
||||
tilt: {
|
||||
histogram: "DEVTOOLS_TILT_OPENED_BOOLEAN",
|
||||
userHistogram: "DEVTOOLS_TILT_OPENED_PER_USER_FLAG",
|
||||
|
|
|
@ -60,6 +60,7 @@ skip-if = e10s # Bug 1086492 - Disable tilt for e10s
|
|||
[browser_telemetry_toolboxtabs_netmonitor.js]
|
||||
[browser_telemetry_toolboxtabs_options.js]
|
||||
[browser_telemetry_toolboxtabs_shadereditor.js]
|
||||
[browser_telemetry_toolboxtabs_storage.js]
|
||||
[browser_telemetry_toolboxtabs_styleeditor.js]
|
||||
[browser_telemetry_toolboxtabs_webaudioeditor.js]
|
||||
[browser_telemetry_toolboxtabs_webconsole.js]
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const TEST_URI = "data:text/html;charset=utf-8,<p>browser_telemetry_toolboxtabs_storage.js</p>";
|
||||
|
||||
// Because we need to gather stats for the period of time that a tool has been
|
||||
// opened we make use of setTimeout() to create tool active times.
|
||||
const TOOL_DELAY = 200;
|
||||
|
||||
let {Promise: promise} = Cu.import("resource://gre/modules/devtools/deprecated-sync-thenables.js", {});
|
||||
let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
|
||||
|
||||
let require = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools.require;
|
||||
let Telemetry = require("devtools/shared/telemetry");
|
||||
|
||||
let STORAGE_PREF = "devtools.storage.enabled";
|
||||
Services.prefs.setBoolPref(STORAGE_PREF, true);
|
||||
|
||||
function init() {
|
||||
Telemetry.prototype.telemetryInfo = {};
|
||||
Telemetry.prototype._oldlog = Telemetry.prototype.log;
|
||||
Telemetry.prototype.log = function(histogramId, value) {
|
||||
if (!this.telemetryInfo) {
|
||||
// Can be removed when Bug 992911 lands (see Bug 1011652 Comment 10)
|
||||
return;
|
||||
}
|
||||
if (histogramId) {
|
||||
if (!this.telemetryInfo[histogramId]) {
|
||||
this.telemetryInfo[histogramId] = [];
|
||||
}
|
||||
|
||||
this.telemetryInfo[histogramId].push(value);
|
||||
}
|
||||
}
|
||||
|
||||
openToolboxTabTwice("storage", false);
|
||||
}
|
||||
|
||||
function openToolboxTabTwice(id, secondPass) {
|
||||
let target = TargetFactory.forTab(gBrowser.selectedTab);
|
||||
|
||||
gDevTools.showToolbox(target, id).then(function(toolbox) {
|
||||
info("Toolbox tab " + id + " opened");
|
||||
|
||||
toolbox.once("destroyed", function() {
|
||||
if (secondPass) {
|
||||
checkResults();
|
||||
} else {
|
||||
openToolboxTabTwice(id, true);
|
||||
}
|
||||
});
|
||||
// We use a timeout to check the tools active time
|
||||
setTimeout(function() {
|
||||
gDevTools.closeToolbox(target);
|
||||
}, TOOL_DELAY);
|
||||
}).then(null, reportError);
|
||||
}
|
||||
|
||||
function checkResults() {
|
||||
let result = Telemetry.prototype.telemetryInfo;
|
||||
|
||||
for (let [histId, value] of Iterator(result)) {
|
||||
if (histId.endsWith("OPENED_PER_USER_FLAG")) {
|
||||
ok(value.length === 1 && value[0] === true,
|
||||
"Per user value " + histId + " has a single value of true");
|
||||
} else if (histId.endsWith("OPENED_BOOLEAN")) {
|
||||
ok(value.length > 1, histId + " has more than one entry");
|
||||
|
||||
let okay = value.every(function(element) {
|
||||
return element === true;
|
||||
});
|
||||
|
||||
ok(okay, "All " + histId + " entries are === true");
|
||||
} else if (histId.endsWith("TIME_ACTIVE_SECONDS")) {
|
||||
ok(value.length > 1, histId + " has more than one entry");
|
||||
|
||||
let okay = value.every(function(element) {
|
||||
return element > 0;
|
||||
});
|
||||
|
||||
ok(okay, "All " + histId + " entries have time > 0");
|
||||
}
|
||||
}
|
||||
|
||||
finishUp();
|
||||
}
|
||||
|
||||
function reportError(error) {
|
||||
let stack = " " + error.stack.replace(/\n?.*?@/g, "\n JS frame :: ");
|
||||
|
||||
ok(false, "ERROR: " + error + " at " + error.fileName + ":" +
|
||||
error.lineNumber + "\n\nStack trace:" + stack);
|
||||
finishUp();
|
||||
}
|
||||
|
||||
function finishUp() {
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
Telemetry.prototype.log = Telemetry.prototype._oldlog;
|
||||
delete Telemetry.prototype._oldlog;
|
||||
delete Telemetry.prototype.telemetryInfo;
|
||||
|
||||
Services.prefs.clearUserPref(STORAGE_PREF);
|
||||
|
||||
TargetFactory = Services = promise = require = null;
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
waitForFocus(init, content);
|
||||
}, true);
|
||||
|
||||
content.location = TEST_URI;
|
||||
}
|
|
@ -59,7 +59,7 @@ StoragePanel.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Destroy the style editor.
|
||||
* Destroy the storage inspector.
|
||||
*/
|
||||
destroy: function() {
|
||||
if (!this._destroyed) {
|
||||
|
|
|
@ -21,6 +21,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "ViewHelpers",
|
|||
XPCOMUtils.defineLazyModuleGetter(this, "VariablesView",
|
||||
"resource:///modules/devtools/VariablesView.jsm");
|
||||
|
||||
let Telemetry = require("devtools/shared/telemetry");
|
||||
|
||||
/**
|
||||
* Localization convenience methods.
|
||||
*/
|
||||
|
@ -85,6 +87,9 @@ this.StorageUI = function StorageUI(front, target, panelWin) {
|
|||
|
||||
this.handleKeypress = this.handleKeypress.bind(this);
|
||||
this._panelDoc.addEventListener("keypress", this.handleKeypress);
|
||||
|
||||
this._telemetry = new Telemetry();
|
||||
this._telemetry.toolOpened("storage");
|
||||
}
|
||||
|
||||
exports.StorageUI = StorageUI;
|
||||
|
@ -97,6 +102,7 @@ StorageUI.prototype = {
|
|||
destroy: function() {
|
||||
this.front.off("stores-update", this.onUpdate);
|
||||
this._panelDoc.removeEventListener("keypress", this.handleKeypress);
|
||||
this._telemetry.toolClosed("storage");
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -5856,6 +5856,11 @@
|
|||
"kind": "boolean",
|
||||
"description": "How many times has the devtool's Network Monitor been opened?"
|
||||
},
|
||||
"DEVTOOLS_STORAGE_OPENED_BOOLEAN": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "boolean",
|
||||
"description": "How many times has the Storage Inspector been opened?"
|
||||
},
|
||||
"DEVTOOLS_PAINTFLASHING_OPENED_BOOLEAN": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "boolean",
|
||||
|
@ -5976,6 +5981,11 @@
|
|||
"kind": "flag",
|
||||
"description": "How many users have opened the devtool's Network Monitor?"
|
||||
},
|
||||
"DEVTOOLS_STORAGE_OPENED_PER_USER_FLAG": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "flag",
|
||||
"description": "How many users have opened the devtool's Storage Inspector?"
|
||||
},
|
||||
"DEVTOOLS_PAINTFLASHING_OPENED_PER_USER_FLAG": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "flag",
|
||||
|
@ -6130,6 +6140,13 @@
|
|||
"n_buckets": 100,
|
||||
"description": "How long has the network monitor been active (seconds)"
|
||||
},
|
||||
"DEVTOOLS_STORAGE_TIME_ACTIVE_SECONDS": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
"high": "10000000",
|
||||
"n_buckets": 100,
|
||||
"description": "How long has the storage inspector been active (seconds)"
|
||||
},
|
||||
"DEVTOOLS_PAINTFLASHING_TIME_ACTIVE_SECONDS": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
|
|
Загрузка…
Ссылка в новой задаче