This patch adds the most basic tab interaction metrics for tab groups. As discussed in standup, we agreed to move the `remove_` class of metrics into its own bug due to extra complexity involved in correctly capturing these events. One other thing we discussed was what the scope of events should be for the `close_` class of events, i.e. should we *only* capture an event when someone clicks the "X" button or closes from the TOM menu, or should we also account for things like context menus, keyboard shortcuts, etc.? Originally we agreed to capture _all_ tab close events and mark any source that was not one of the above mentioned two as unknown. However, after thinking about this more, I don't believe this is the right approach. There are many places in the codebase where a tab is closed but not because a user deliberately did it (e.g. when moving a tab to a new window — this is actually done by creating a new tab in a new window and closing the old). We currently don't distinguish between user-initiated close actions, so it would take some time to find all these places and exclude them. I favour an explicit inclusion approach (which is what we are doing elsewhere). In this patch I added events for: - closing a tab from the "X" close button (`close_tabstrip`) - closing a tab from the tab context menu (`close_tabstrip`) - closing a tab from the TOM (`close_tabmenu`) There are other places that could potentially be addressed, so I suggest moving these to a follow-up bug and addressing them for 139. Differential Revision: https://phabricator.services.mozilla.com/D244915
64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
/**
|
|
* A common list of systems, surfaces, controls, etc. from which user
|
|
* interactions with tabs could originate. These "source" values
|
|
* should be sent as extra data with tab-related metrics events.
|
|
*/
|
|
const METRIC_SOURCE = Object.freeze({
|
|
TAB_OVERFLOW_MENU: "tab_overflow",
|
|
TAB_GROUP_MENU: "tab_group",
|
|
TAB_MENU: "tab_menu",
|
|
TAB_STRIP: "tab_strip",
|
|
DRAG_AND_DROP: "drag",
|
|
SUGGEST: "suggest",
|
|
RECENT_TABS: "recent",
|
|
UNKNOWN: "unknown",
|
|
});
|
|
|
|
const METRIC_TABS_LAYOUT = Object.freeze({
|
|
HORIZONTAL: "horizontal",
|
|
VERTICAL: "vertical",
|
|
});
|
|
|
|
const METRIC_REOPEN_TYPE = Object.freeze({
|
|
SAVED: "saved",
|
|
DELETED: "deleted",
|
|
});
|
|
|
|
/**
|
|
* @typedef {object} TabMetricsContext
|
|
* @property {boolean} [isUserTriggered=false]
|
|
* Should be true if there was an explicit action/request from the user
|
|
* (as opposed to some action being taken internally or for technical
|
|
* bookkeeping reasons alone). This causes telemetry events to fire.
|
|
* @property {string} [telemetrySource="unknown"]
|
|
* The system, surface, or control the user used to take this action.
|
|
* @see TabMetrics.METRIC_SOURCE for possible values.
|
|
* Defaults to "unknown".
|
|
*/
|
|
|
|
/**
|
|
* Creates a `TabMetricsContext` object for a user event originating from
|
|
* the specified source.
|
|
*
|
|
* @param {string} telemetrySource
|
|
* @see TabMetrics.METRIC_SOURCE
|
|
* @returns {TabMetricsContext}
|
|
*/
|
|
function userTriggeredContext(telemetrySource) {
|
|
return {
|
|
isUserTriggered: true,
|
|
telemetrySource,
|
|
};
|
|
}
|
|
|
|
export const TabMetrics = {
|
|
METRIC_SOURCE,
|
|
METRIC_TABS_LAYOUT,
|
|
METRIC_REOPEN_TYPE,
|
|
userTriggeredContext,
|
|
};
|