Bug 1923972 - Telemetry for icons on the sidebar r=sidebar-reviewers,nsharpley
Differential Revision: https://phabricator.services.mozilla.com/D226681
This commit is contained in:
@@ -99,6 +99,7 @@ var SidebarController = {
|
||||
? "sidebar-history-context-menu"
|
||||
: undefined,
|
||||
gleanEvent: Glean.history.sidebarToggle,
|
||||
gleanClickEvent: Glean.sidebar.historyIconClick,
|
||||
}),
|
||||
],
|
||||
[
|
||||
@@ -116,6 +117,7 @@ var SidebarController = {
|
||||
contextMenuId: this.sidebarRevampEnabled
|
||||
? "sidebar-synced-tabs-context-menu"
|
||||
: undefined,
|
||||
gleanClickEvent: Glean.sidebar.syncedTabsIconClick,
|
||||
}),
|
||||
],
|
||||
[
|
||||
@@ -130,6 +132,7 @@ var SidebarController = {
|
||||
iconUrl: "chrome://browser/skin/bookmark-hollow.svg",
|
||||
disabled: true,
|
||||
gleanEvent: Glean.bookmarks.sidebarToggle,
|
||||
gleanClickEvent: Glean.sidebar.bookmarksIconClick,
|
||||
}),
|
||||
],
|
||||
]);
|
||||
@@ -145,6 +148,7 @@ var SidebarController = {
|
||||
// Bug 1900915 to expose as conditional tool
|
||||
revampL10nId: "sidebar-menu-genai-chat-label",
|
||||
iconUrl: "chrome://global/skin/icons/highlights.svg",
|
||||
gleanClickEvent: Glean.sidebar.chatbotIconClick,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1618,6 +1622,28 @@ var SidebarController = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Record to Glean when any of the sidebar icons are clicked.
|
||||
*
|
||||
* @param {string} commandID - Command ID of the icon.
|
||||
* @param {boolean} expanded - Whether the sidebar was expanded when clicked.
|
||||
*/
|
||||
recordIconClick(commandID, expanded) {
|
||||
const sidebar = this.sidebars.get(commandID);
|
||||
const isExtension = sidebar && Object.hasOwn(sidebar, "extensionId");
|
||||
if (isExtension) {
|
||||
const addonId = sidebar.extensionId;
|
||||
Glean.sidebar.addonIconClick.record({
|
||||
sidebar_open: expanded,
|
||||
addon_id: AMTelemetry.getTrimmedString(addonId),
|
||||
});
|
||||
} else if (sidebar.gleanClickEvent) {
|
||||
sidebar.gleanClickEvent.record({
|
||||
sidebar_open: expanded,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the checked state only on the menu items of the specified sidebar, or
|
||||
* none if the argument is an empty string.
|
||||
|
||||
@@ -145,6 +145,104 @@ sidebar:
|
||||
- rtestard@mozilla.com
|
||||
expires: never
|
||||
telemetry_mirror: SIDEBAR_LINK
|
||||
chatbot_icon_click:
|
||||
type: event
|
||||
description: >
|
||||
The chatbot icon was clicked.
|
||||
bugs:
|
||||
- https://bugzil.la/1923972
|
||||
data_reviews:
|
||||
- https://phabricator.services.mozilla.com/D226681
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
expires: never
|
||||
notification_emails:
|
||||
- vsabino@mozilla.com
|
||||
send_in_pings:
|
||||
- events
|
||||
extra_keys:
|
||||
sidebar_open:
|
||||
type: boolean
|
||||
description: Whether the sidebar is expanded or collapsed.
|
||||
history_icon_click:
|
||||
type: event
|
||||
description: >
|
||||
The history icon was clicked.
|
||||
bugs:
|
||||
- https://bugzil.la/1923972
|
||||
data_reviews:
|
||||
- https://phabricator.services.mozilla.com/D226681
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
expires: never
|
||||
notification_emails:
|
||||
- vsabino@mozilla.com
|
||||
send_in_pings:
|
||||
- events
|
||||
extra_keys:
|
||||
sidebar_open:
|
||||
type: boolean
|
||||
description: Whether the sidebar is expanded or collapsed.
|
||||
synced_tabs_icon_click:
|
||||
type: event
|
||||
description: >
|
||||
The synced tabs icon was clicked.
|
||||
bugs:
|
||||
- https://bugzil.la/1923972
|
||||
data_reviews:
|
||||
- https://phabricator.services.mozilla.com/D226681
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
expires: never
|
||||
notification_emails:
|
||||
- vsabino@mozilla.com
|
||||
send_in_pings:
|
||||
- events
|
||||
extra_keys:
|
||||
sidebar_open:
|
||||
type: boolean
|
||||
description: Whether the sidebar is expanded or collapsed.
|
||||
bookmarks_icon_click:
|
||||
type: event
|
||||
description: >
|
||||
The bookmarks icon was clicked.
|
||||
bugs:
|
||||
- https://bugzil.la/1923972
|
||||
data_reviews:
|
||||
- https://phabricator.services.mozilla.com/D226681
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
expires: never
|
||||
notification_emails:
|
||||
- vsabino@mozilla.com
|
||||
send_in_pings:
|
||||
- events
|
||||
extra_keys:
|
||||
sidebar_open:
|
||||
type: boolean
|
||||
description: Whether the sidebar is expanded or collapsed.
|
||||
addon_icon_click:
|
||||
type: event
|
||||
description: >
|
||||
An extension icon was clicked.
|
||||
bugs:
|
||||
- https://bugzil.la/1923972
|
||||
data_reviews:
|
||||
- https://phabricator.services.mozilla.com/D226681
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
expires: never
|
||||
notification_emails:
|
||||
- vsabino@mozilla.com
|
||||
send_in_pings:
|
||||
- events
|
||||
extra_keys:
|
||||
sidebar_open:
|
||||
type: boolean
|
||||
description: Whether the sidebar is expanded or collapsed.
|
||||
addon_id:
|
||||
type: string
|
||||
description: The extension's ID.
|
||||
history:
|
||||
sidebar_toggle:
|
||||
type: event
|
||||
|
||||
@@ -241,6 +241,7 @@ export default class SidebarMain extends MozLitElement {
|
||||
}
|
||||
|
||||
showView(view) {
|
||||
window.SidebarController.recordIconClick(view, this.expanded);
|
||||
window.SidebarController.toggle(view);
|
||||
if (view === "viewCustomizeSidebar") {
|
||||
Glean.sidebarCustomize.iconClick.record();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
requestLongerTimeout(2);
|
||||
requestLongerTimeout(10);
|
||||
|
||||
const lazy = {};
|
||||
|
||||
@@ -36,6 +36,8 @@ add_task(async function test_metrics_initialized() {
|
||||
});
|
||||
|
||||
add_task(async function test_sidebar_expand() {
|
||||
SidebarController.toggleExpanded(false);
|
||||
|
||||
info("Expand the sidebar.");
|
||||
EventUtils.synthesizeMouseAtCenter(SidebarController.toolbarButton, {});
|
||||
await TestUtils.waitForCondition(
|
||||
@@ -445,3 +447,68 @@ add_task(async function test_sidebar_position_rtl_ui() {
|
||||
sandbox.restore();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
async function testIconClick(expanded) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.ml.chat.enabled", true],
|
||||
["sidebar.main.tools", "aichat,syncedtabs,history,bookmarks"],
|
||||
],
|
||||
});
|
||||
|
||||
const { sidebarMain } = SidebarController;
|
||||
const gleanEvents = [
|
||||
Glean.sidebar.chatbotIconClick,
|
||||
Glean.sidebar.syncedTabsIconClick,
|
||||
Glean.sidebar.historyIconClick,
|
||||
Glean.sidebar.bookmarksIconClick,
|
||||
];
|
||||
sidebarMain.toolButtons.forEach((button, i) => {
|
||||
SidebarController.toggleExpanded(expanded);
|
||||
|
||||
info(`Click the icon for: ${button.getAttribute("view")}`);
|
||||
EventUtils.synthesizeMouseAtCenter(button, {});
|
||||
|
||||
const events = gleanEvents[i].testGetValue();
|
||||
Assert.equal(events?.length, 1, "One event was reported.");
|
||||
Assert.deepEqual(
|
||||
events?.[0].extra,
|
||||
{ sidebar_open: `${expanded}` },
|
||||
`Event indicates the sidebar was ${expanded ? "expanded" : "collapsed"}.`
|
||||
);
|
||||
});
|
||||
|
||||
info("Load an extension.");
|
||||
const extension = ExtensionTestUtils.loadExtension({ ...extData });
|
||||
await extension.startup();
|
||||
await extension.awaitMessage("sidebar");
|
||||
|
||||
SidebarController.toggleExpanded(expanded);
|
||||
|
||||
info("Click the icon for the extension.");
|
||||
const extensionButton = sidebarMain.extensionButtons[0];
|
||||
EventUtils.synthesizeMouseAtCenter(extensionButton, {});
|
||||
|
||||
const events = Glean.sidebar.addonIconClick.testGetValue();
|
||||
Assert.equal(events?.length, 1, "One event was reported.");
|
||||
Assert.equal(
|
||||
events?.[0].extra.sidebar_open,
|
||||
`${expanded}`,
|
||||
`Event indicates the sidebar was ${expanded ? "expanded" : "collapsed"}.`
|
||||
);
|
||||
Assert.ok(events?.[0].extra.addon_id, "Event has the extension's ID.");
|
||||
|
||||
info("Unload the extension.");
|
||||
await extension.unload();
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
Services.fog.testResetFOG();
|
||||
}
|
||||
|
||||
add_task(async function test_icon_click_collapsed_sidebar() {
|
||||
await testIconClick(false);
|
||||
});
|
||||
|
||||
add_task(async function test_icon_click_expanded_sidebar() {
|
||||
await testIconClick(true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user