зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1500147 - Part 3: Record add-on manager telemetry for page/browser actions r=rpl
Differential Revision: https://phabricator.services.mozilla.com/D18003 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
6ef0bc9dc2
Коммит
911fb7280f
|
@ -875,6 +875,11 @@ var BrowserPageActions = {
|
||||||
this._contextAction = null;
|
this._contextAction = null;
|
||||||
|
|
||||||
PageActions.logTelemetry("managed", action);
|
PageActions.logTelemetry("managed", action);
|
||||||
|
AMTelemetry.recordActionEvent({
|
||||||
|
object: "pageAction",
|
||||||
|
action: "manage",
|
||||||
|
extra: {addonId: action.extensionID},
|
||||||
|
});
|
||||||
|
|
||||||
let viewID = "addons://detail/" + encodeURIComponent(action.extensionID);
|
let viewID = "addons://detail/" + encodeURIComponent(action.extensionID);
|
||||||
window.BrowserOpenAddonsMgr(viewID);
|
window.BrowserOpenAddonsMgr(viewID);
|
||||||
|
|
|
@ -12,6 +12,7 @@ ChromeUtils.import("resource://gre/modules/NotificationDB.jsm");
|
||||||
|
|
||||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||||
AddonManager: "resource://gre/modules/AddonManager.jsm",
|
AddonManager: "resource://gre/modules/AddonManager.jsm",
|
||||||
|
AMTelemetry: "resource://gre/modules/AddonManager.jsm",
|
||||||
BrowserUsageTelemetry: "resource:///modules/BrowserUsageTelemetry.jsm",
|
BrowserUsageTelemetry: "resource:///modules/BrowserUsageTelemetry.jsm",
|
||||||
BrowserUtils: "resource://gre/modules/BrowserUtils.jsm",
|
BrowserUtils: "resource://gre/modules/BrowserUtils.jsm",
|
||||||
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
|
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
|
||||||
|
@ -6374,6 +6375,12 @@ var ToolbarContextMenu = {
|
||||||
let btnFlags = BUTTON_POS_0 * titleString + BUTTON_POS_1 * titleCancel;
|
let btnFlags = BUTTON_POS_0 * titleString + BUTTON_POS_1 * titleCancel;
|
||||||
let response = confirmEx(null, title, message, btnFlags, btnTitle, null, null, null,
|
let response = confirmEx(null, title, message, btnFlags, btnTitle, null, null, null,
|
||||||
{value: 0});
|
{value: 0});
|
||||||
|
AMTelemetry.recordActionEvent({
|
||||||
|
object: "browserAction",
|
||||||
|
action: "uninstall",
|
||||||
|
value: response ? "cancelled" : "accepted",
|
||||||
|
extra: {addonId: addon.id},
|
||||||
|
});
|
||||||
if (response == 0) {
|
if (response == 0) {
|
||||||
addon.uninstall();
|
addon.uninstall();
|
||||||
}
|
}
|
||||||
|
@ -6384,6 +6391,11 @@ var ToolbarContextMenu = {
|
||||||
if (id) {
|
if (id) {
|
||||||
let viewID = "addons://detail/" + encodeURIComponent(id);
|
let viewID = "addons://detail/" + encodeURIComponent(id);
|
||||||
BrowserOpenAddonsMgr(viewID);
|
BrowserOpenAddonsMgr(viewID);
|
||||||
|
AMTelemetry.recordActionEvent({
|
||||||
|
object: "browserAction",
|
||||||
|
action: "manage",
|
||||||
|
extra: {addonId: id},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -44,6 +44,32 @@ let contextMenuItems = {
|
||||||
"context-bookmarkpage": "hidden",
|
"context-bookmarkpage": "hidden",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const TELEMETRY_CATEGORY = "addonsManager";
|
||||||
|
const TELEMETRY_METHODS = new Set(["action", "link", "view"]);
|
||||||
|
const type = "extension";
|
||||||
|
|
||||||
|
function assertTelemetryMatches(events) {
|
||||||
|
let snapshot = Services.telemetry.snapshotEvents(
|
||||||
|
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true);
|
||||||
|
|
||||||
|
if (events.length == 0) {
|
||||||
|
ok(!snapshot.parent || snapshot.parent.length == 0, "There are no telemetry events");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure we got some data.
|
||||||
|
ok(snapshot.parent && snapshot.parent.length > 0, "Got parent telemetry events in the snapshot");
|
||||||
|
|
||||||
|
// Only look at the related events after stripping the timestamp and category.
|
||||||
|
let relatedEvents = snapshot.parent
|
||||||
|
.filter(([timestamp, category, method]) =>
|
||||||
|
category == TELEMETRY_CATEGORY && TELEMETRY_METHODS.has(method))
|
||||||
|
.map(relatedEvent => relatedEvent.slice(2, 6));
|
||||||
|
|
||||||
|
// Events are now [method, object, value, extra] as expected.
|
||||||
|
Assert.deepEqual(relatedEvents, events, "The events are recorded correctly");
|
||||||
|
}
|
||||||
|
|
||||||
add_task(async function browseraction_popup_contextmenu() {
|
add_task(async function browseraction_popup_contextmenu() {
|
||||||
let extension = ExtensionTestUtils.loadExtension(extData);
|
let extension = ExtensionTestUtils.loadExtension(extData);
|
||||||
await extension.startup();
|
await extension.startup();
|
||||||
|
@ -245,9 +271,21 @@ add_task(async function browseraction_contextmenu_manage_extension() {
|
||||||
|
|
||||||
info("Run tests in normal mode");
|
info("Run tests in normal mode");
|
||||||
await main(false);
|
await main(false);
|
||||||
|
assertTelemetryMatches([
|
||||||
|
["action", "browserAction", null, {action: "manage", addonId: id}],
|
||||||
|
["view", "aboutAddons", "detail", {addonId: id, type}],
|
||||||
|
["action", "browserAction", null, {action: "manage", addonId: id}],
|
||||||
|
["view", "aboutAddons", "detail", {addonId: id, type}],
|
||||||
|
]);
|
||||||
|
|
||||||
info("Run tests in customize mode");
|
info("Run tests in customize mode");
|
||||||
await main(true);
|
await main(true);
|
||||||
|
assertTelemetryMatches([
|
||||||
|
["action", "browserAction", null, {action: "manage", addonId: id}],
|
||||||
|
["view", "aboutAddons", "detail", {addonId: id, type}],
|
||||||
|
["action", "browserAction", null, {action: "manage", addonId: id}],
|
||||||
|
["view", "aboutAddons", "detail", {addonId: id, type}],
|
||||||
|
]);
|
||||||
|
|
||||||
info("Close the dummy tab and finish");
|
info("Close the dummy tab and finish");
|
||||||
win.gBrowser.removeTab(dummyTab);
|
win.gBrowser.removeTab(dummyTab);
|
||||||
|
@ -348,9 +386,19 @@ add_task(async function browseraction_contextmenu_remove_extension() {
|
||||||
info("Run tests in normal mode");
|
info("Run tests in normal mode");
|
||||||
await main(false);
|
await main(false);
|
||||||
|
|
||||||
|
assertTelemetryMatches([
|
||||||
|
["action", "browserAction", "cancelled", {action: "uninstall", addonId: id}],
|
||||||
|
["action", "browserAction", "cancelled", {action: "uninstall", addonId: id}],
|
||||||
|
]);
|
||||||
|
|
||||||
info("Run tests in customize mode");
|
info("Run tests in customize mode");
|
||||||
await main(true);
|
await main(true);
|
||||||
|
|
||||||
|
assertTelemetryMatches([
|
||||||
|
["action", "browserAction", "cancelled", {action: "uninstall", addonId: id}],
|
||||||
|
["action", "browserAction", "cancelled", {action: "uninstall", addonId: id}],
|
||||||
|
]);
|
||||||
|
|
||||||
let addon = await AddonManager.getAddonByID(id);
|
let addon = await AddonManager.getAddonByID(id);
|
||||||
ok(addon, "Addon is still installed");
|
ok(addon, "Addon is still installed");
|
||||||
|
|
||||||
|
@ -367,6 +415,10 @@ add_task(async function browseraction_contextmenu_remove_extension() {
|
||||||
await testContextMenu("toolbar-context-menu", false);
|
await testContextMenu("toolbar-context-menu", false);
|
||||||
await uninstalled;
|
await uninstalled;
|
||||||
|
|
||||||
|
assertTelemetryMatches([
|
||||||
|
["action", "browserAction", "accepted", {action: "uninstall", addonId: id}],
|
||||||
|
]);
|
||||||
|
|
||||||
addon = await AddonManager.getAddonByID(id);
|
addon = await AddonManager.getAddonByID(id);
|
||||||
ok(!addon, "Addon has been uninstalled");
|
ok(!addon, "Addon has been uninstalled");
|
||||||
|
|
||||||
|
|
|
@ -1262,6 +1262,8 @@ add_task(async function removeRetainState() {
|
||||||
// Opens the context menu on a non-built-in action. (The context menu for
|
// Opens the context menu on a non-built-in action. (The context menu for
|
||||||
// built-in actions is tested in browser_page_action_menu.js.)
|
// built-in actions is tested in browser_page_action_menu.js.)
|
||||||
add_task(async function contextMenu() {
|
add_task(async function contextMenu() {
|
||||||
|
Services.telemetry.clearEvents();
|
||||||
|
|
||||||
// Add a test action.
|
// Add a test action.
|
||||||
let action = PageActions.addAction(new PageActions.Action({
|
let action = PageActions.addAction(new PageActions.Action({
|
||||||
id: "test-contextMenu",
|
id: "test-contextMenu",
|
||||||
|
@ -1445,6 +1447,20 @@ add_task(async function contextMenu() {
|
||||||
// Done, clean up.
|
// Done, clean up.
|
||||||
action.remove();
|
action.remove();
|
||||||
|
|
||||||
|
// Check the telemetry was collected properly.
|
||||||
|
let snapshot = Services.telemetry.snapshotEvents(
|
||||||
|
Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true);
|
||||||
|
ok(snapshot.parent && snapshot.parent.length > 0,
|
||||||
|
"Got parent telemetry events in the snapshot");
|
||||||
|
let relatedEvents = snapshot.parent
|
||||||
|
.filter(([timestamp, category, method]) =>
|
||||||
|
category == "addonsManager" && method == "action")
|
||||||
|
.map(relatedEvent => relatedEvent.slice(3, 6));
|
||||||
|
Assert.deepEqual(relatedEvents, [
|
||||||
|
["pageAction", null, {action: "manage"}],
|
||||||
|
["pageAction", null, {action: "manage"}],
|
||||||
|
]);
|
||||||
|
|
||||||
// urlbar tests that run after this one can break if the mouse is left over
|
// urlbar tests that run after this one can break if the mouse is left over
|
||||||
// the area where the urlbar popup appears, which seems to happen due to the
|
// the area where the urlbar popup appears, which seems to happen due to the
|
||||||
// above synthesized mouse events. Move it over the urlbar.
|
// above synthesized mouse events. Move it over the urlbar.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче