Skip to content

Commit

Permalink
Bug 1647346 - Instrument telemetry for closing tabs in the debugger r…
Browse files Browse the repository at this point in the history
…=loganfsmyth,tdsmith

Differential Revision: https://phabricator.services.mozilla.com/D83160
  • Loading branch information
darkwing committed Jul 20, 2020
1 parent 8dd9fb9 commit 42fe332
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
12 changes: 11 additions & 1 deletion devtools/client/debugger/src/actions/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

import { removeDocument } from "../utils/editor";
import { recordEvent } from "../utils/telemetry";
import { selectSource } from "./sources";

import {
Expand Down Expand Up @@ -67,7 +68,11 @@ export function moveTabBySourceId(
* @memberof actions/tabs
* @static
*/
export function closeTab(cx: Context, source: Source) {
export function closeTab(
cx: Context,
source: Source,
reason: string = "click"
) {
return ({ dispatch, getState, client }: ThunkArgs) => {
removeDocument(source.id);

Expand All @@ -76,6 +81,11 @@ export function closeTab(cx: Context, source: Source) {

const sourceId = getNewSelectedSourceId(getState(), tabs);
dispatch(selectSource(cx, sourceId));

recordEvent("close_source_tab", {
reason,
num_tabs: tabs.length,
});
};
}

Expand Down
9 changes: 6 additions & 3 deletions devtools/client/debugger/src/components/Editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,19 @@ class Editor extends PureComponent<Props, State> {
L10N.getStr("toggleCondPanel.logPoint.key"),
this.onToggleConditionalPanel
);
shortcuts.on(L10N.getStr("sourceTabs.closeTab.key"), this.onClosePress);
shortcuts.on(
L10N.getStr("sourceTabs.closeTab.key"),
this.onCloseShortcutPress
);
shortcuts.on("Esc", this.onEscape);
}

onClosePress = (key: mixed, e: KeyboardEvent) => {
onCloseShortcutPress = (key: mixed, e: KeyboardEvent) => {
const { cx, selectedSource } = this.props;
if (selectedSource) {
e.preventDefault();
e.stopPropagation();
this.props.closeTab(cx, selectedSource);
this.props.closeTab(cx, selectedSource, "shortcut");
}
};

Expand Down
13 changes: 13 additions & 0 deletions toolkit/components/telemetry/Events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,19 @@ devtools.main:
extra_keys:
width: Toolbox width rounded up to the nearest 50px.
session_id: The start time of the session in milliseconds since epoch (Unix Timestamp) e.g. 1396381378123.
close_source_tab:
objects: ["debugger"]
bug_numbers: [1647346]
notification_emails: ["[email protected]", "[email protected]", "[email protected]"]
products:
- "firefox"
record_in_processes: ["main"]
description: The method by which users close source tabs within the debugger
release_channel_collection: opt-out
expiry_version: "82"
extra_keys:
reason: The method that the tab was closed ("click" or "shortcut")
num_tabs: The number of open tabs at the time the tab was closed
connection_attempt:
objects: ["aboutdebugging"]
bug_numbers: [1549970]
Expand Down

0 comments on commit 42fe332

Please sign in to comment.