Bug 1756252: Collect telemetry on synced tabs usage r=markh

Differential Revision: https://phabricator.services.mozilla.com/D139221
This commit is contained in:
Sammy Khamis
2022-02-23 02:39:26 +00:00
parent 467a37216b
commit be54278282
4 changed files with 53 additions and 3 deletions

View File

@@ -255,8 +255,8 @@ this.SyncedTabsPanelList = class SyncedTabsPanelList {
if (hasNextPage) { if (hasNextPage) {
client.tabs = client.tabs.slice(0, maxTabs); client.tabs = client.tabs.slice(0, maxTabs);
} }
for (let tab of client.tabs) { for (let [index, tab] of client.tabs.entries()) {
let tabEnt = this._createSyncedTabElement(tab); let tabEnt = this._createSyncedTabElement(tab, index);
container.appendChild(tabEnt); container.appendChild(tabEnt);
} }
if (hasNextPage) { if (hasNextPage) {
@@ -266,7 +266,7 @@ this.SyncedTabsPanelList = class SyncedTabsPanelList {
} }
} }
_createSyncedTabElement(tabInfo) { _createSyncedTabElement(tabInfo, index) {
let item = document.createXULElement("toolbarbutton"); let item = document.createXULElement("toolbarbutton");
let tooltipText = (tabInfo.title ? tabInfo.title + "\n" : "") + tabInfo.url; let tooltipText = (tabInfo.title ? tabInfo.title + "\n" : "") + tabInfo.url;
item.setAttribute("itemtype", "tab"); item.setAttribute("itemtype", "tab");
@@ -283,6 +283,15 @@ this.SyncedTabsPanelList = class SyncedTabsPanelList {
// We need to use "click" instead of "command" here so openUILink // We need to use "click" instead of "command" here so openUILink
// respects different buttons (eg, to open in a new tab). // respects different buttons (eg, to open in a new tab).
item.addEventListener("click", e => { item.addEventListener("click", e => {
// We want to differentiate between when the fxa panel is within the app menu/hamburger bar
let object = "fxa_avatar_menu";
const appMenuPanel = document.getElementById("appMenu-popup");
if (appMenuPanel.contains(e.currentTarget)) {
object = "fxa_app_menu";
}
SyncedTabs.recordSyncedTabsTelemetry(object, "click", {
tab_pos: index.toString(),
});
document.defaultView.openUILink(tabInfo.url, e, { document.defaultView.openUILink(tabInfo.url, e, {
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal( triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal(
{} {}

View File

@@ -180,6 +180,16 @@ Object.assign(SyncedTabsListStore.prototype, EventEmitter.prototype, {
this._selectedRow = [parentRow, childRow]; this._selectedRow = [parentRow, childRow];
this.inputFocused = false; this.inputFocused = false;
this._change("all"); this._change("all");
// Record the telemetry event
let extraOptions = {
tab_pos: this._selectedRow[1].toString(),
filter: this.filter,
};
this._SyncedTabs.recordSyncedTabsTelemetry(
"synced_tabs_sidebar",
"click",
extraOptions
);
}, },
_tabCount() { _tabCount() {

View File

@@ -273,4 +273,15 @@ var SyncedTabs = {
return b.tabs[0].lastUsed - a.tabs[0].lastUsed; return b.tabs[0].lastUsed - a.tabs[0].lastUsed;
}); });
}, },
recordSyncedTabsTelemetry(object, tabEvent, extraOptions) {
Services.telemetry.setEventRecordingEnabled("synced_tabs", true);
Services.telemetry.recordEvent(
"synced_tabs",
tabEvent,
object,
null,
extraOptions
);
},
}; };

View File

@@ -3160,3 +3160,23 @@ privacy_segmentation:
- rtestard@mozilla.com - rtestard@mozilla.com
expiry_version: "106" expiry_version: "106"
products: ["firefox"] products: ["firefox"]
synced_tabs:
click:
objects: [
"fxa_avatar_menu",
"fxa_app_menu",
"synced_tabs_sidebar",
]
methods: ["click"]
release_channel_collection: opt-out
products:
- "firefox"
record_in_processes: ["main"]
description: Record how users access and use synced tabs component
bug_numbers: [1756252]
notification_emails: ["sync-dev@mozilla.org"]
expiry_version: "never"
extra_keys:
tab_pos: position of the tab clicked
filter: was there a filter enabled