Bug 1938424 - metrics event when tabs added to tab group r=dao,jswinarton,tabbrowser-reviewers,extension-reviewers,robwu

When using the tab context menu or drag-dropping tabs to put them into a group, record a metric for the number of tabs added to the group.

Data Science asked us to launch with this metric disabled so that they could control it using server knobs. They expect a high volume of events, so they expect to only enable this metric for some proportion of users.

I converted the existing `TabMove` event derived from `UIEvent` being fired when tabs change their tab index in the tab strip. `UIEvent` doesn't allow for attaching additional context/detail to the event. `TabMove` is now a `CustomEvent` that provides more context about the moved tab and it fires in more cases -- it's possible for the tab index not to change despite the tab having "moved" into/out of a tab group.

This approach would not capture tab movements that occur across multiple frames/event loop iterations.

Differential Revision: https://phabricator.services.mozilla.com/D244616
This commit is contained in:
Stephen Thompson
2025-04-11 13:52:22 +00:00
parent cd6729c28d
commit f2e07044ae
17 changed files with 488 additions and 158 deletions

View File

@@ -158,7 +158,7 @@ const kLastIndex = Number.MAX_SAFE_INTEGER - 1;
import { PrivateBrowsingUtils } from "resource://gre/modules/PrivateBrowsingUtils.sys.mjs";
import { TabGroupMetrics } from "moz-src:///browser/components/tabbrowser/TabGroupMetrics.sys.mjs";
import { TabMetrics } from "moz-src:///browser/components/tabbrowser/TabMetrics.sys.mjs";
import { TelemetryTimestamps } from "resource://gre/modules/TelemetryTimestamps.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
@@ -899,16 +899,16 @@ export var SessionStore = {
openSavedTabGroup(
tabGroupId,
targetWindow,
{ source = TabGroupMetrics.METRIC_SOURCE.UNKNOWN } = {}
{ source = TabMetrics.METRIC_SOURCE.UNKNOWN } = {}
) {
let isVerticalMode = targetWindow.gBrowser.tabContainer.verticalMode;
Glean.tabgroup.reopen.record({
id: tabGroupId,
source,
layout: isVerticalMode
? TabGroupMetrics.METRIC_TABS_LAYOUT.VERTICAL
: TabGroupMetrics.METRIC_TABS_LAYOUT.HORIZONTAL,
type: TabGroupMetrics.METRIC_REOPEN_TYPE.SAVED,
? TabMetrics.METRIC_TABS_LAYOUT.VERTICAL
: TabMetrics.METRIC_TABS_LAYOUT.HORIZONTAL,
type: TabMetrics.METRIC_REOPEN_TYPE.SAVED,
});
return SessionStoreInternal.openSavedTabGroup(tabGroupId, targetWindow);