Bug 1463083 - Instrument inspection of inspector side panel switching with event telemetry r=yulia

MozReview-Commit-ID: ANPWNvYRfdH

--HG--
extra : rebase_source : 2bc1e86ebaa8eda2ec0b858c918996e1f3600f79
This commit is contained in:
Michael Ratcliffe 2018-05-24 14:21:49 +01:00
Родитель d4c9aea2cf
Коммит 190ce58cbf
3 изменённых файлов: 120 добавлений и 0 удалений

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

@ -334,6 +334,13 @@ ToolSidebar.prototype = {
if (previousToolId) {
this._telemetry.toolClosed(previousToolId);
this._telemetry.recordEvent("devtools.main", "sidepanel_changed", "inspector", null,
{
oldpanel: previousToolId,
newpanel: currentToolId
}
);
}
this._telemetry.toolOpened(currentToolId);
},

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

@ -5,12 +5,89 @@
"use strict";
const TEST_URI = "data:text/html;charset=utf-8,<p>browser_telemetry_sidebar.js</p>";
const OPTOUT = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT;
// 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;
const DATA = [
{
timestamp: null,
category: "devtools.main",
method: "sidepanel_changed",
object: "inspector",
value: null,
extra: {
oldpanel: "computedview",
newpanel: "fontinspector"
}
},
{
timestamp: null,
category: "devtools.main",
method: "sidepanel_changed",
object: "inspector",
value: null,
extra: {
oldpanel: "fontinspector",
newpanel: "layoutview"
}
},
{
timestamp: null,
category: "devtools.main",
method: "sidepanel_changed",
object: "inspector",
value: null,
extra: {
oldpanel: "layoutview",
newpanel: "computedview"
}
},
{
timestamp: null,
category: "devtools.main",
method: "sidepanel_changed",
object: "inspector",
value: null,
extra: {
oldpanel: "computedview",
newpanel: "fontinspector"
}
},
{
timestamp: null,
category: "devtools.main",
method: "sidepanel_changed",
object: "inspector",
value: null,
extra: {
oldpanel: "fontinspector",
newpanel: "layoutview"
}
},
{
timestamp: null,
category: "devtools.main",
method: "sidepanel_changed",
object: "inspector",
value: null,
extra: {
oldpanel: "layoutview",
newpanel: "computedview"
}
}
];
add_task(async function() {
// Let's reset the counts.
Services.telemetry.clearEvents();
// Ensure no events have been logged
const snapshot = Services.telemetry.snapshotEvents(OPTOUT, true);
ok(!snapshot.parent, "No events have been logged for the main process");
await addTab(TEST_URI);
startTelemetry();
@ -20,6 +97,7 @@ add_task(async function() {
await testSidebar(toolbox);
checkResults();
checkEventTelemetry();
await gDevTools.closeToolbox(target);
gBrowser.removeCurrentTab();
@ -63,3 +141,27 @@ function checkResults() {
checkTelemetry("DEVTOOLS_LAYOUTVIEW_TIME_ACTIVE_SECONDS", "", null, "hasentries");
checkTelemetry("DEVTOOLS_FONTINSPECTOR_TIME_ACTIVE_SECONDS", "", null, "hasentries");
}
function checkEventTelemetry() {
const snapshot = Services.telemetry.snapshotEvents(OPTOUT, true);
const events = snapshot.parent.filter(event => event[1] === "devtools.main" &&
event[2] === "sidepanel_changed" &&
event[3] === "inspector" &&
event[4] === null
);
for (let i in DATA) {
const [ timestamp, category, method, object, value, extra ] = events[i];
const expected = DATA[i];
// ignore timestamp
ok(timestamp > 0, "timestamp is greater than 0");
is(category, expected.category, "category is correct");
is(method, expected.method, "method is correct");
is(object, expected.object, "object is correct");
is(value, expected.value, "value is correct");
is(extra.oldpanel, expected.extra.oldpanel, "oldpanel is correct");
is(extra.newpanel, expected.extra.newpanel, "newpanel is correct");
}
}

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

@ -290,3 +290,14 @@ devtools.main:
description: User is editing a CSS rule by clicking on or next to a CSS property, enabling / disabling a rule or creating a new property.
release_channel_collection: opt-out
expiry_version: never
sidepanel_changed:
objects: ["inspector"]
bug_numbers: [1463083]
notification_emails: ["dev-developer-tools@lists.mozilla.org", "hkirschner@mozilla.com"]
record_in_processes: ["main"]
description: User has switched sidepanel tabs.
release_channel_collection: opt-out
expiry_version: never
extra_keys:
oldpanel: The panel the user is switching from
newpanel: The panel the user is switching to