From b0c52f4668757b547fae80181c461d76672201fc Mon Sep 17 00:00:00 2001 From: Keith Daulton Date: Mon, 13 Jan 2025 19:51:56 -0500 Subject: [PATCH] Adds command tracking for home --- docs/telemetry-events.md | 11 +++++++++++ src/constants.telemetry.ts | 2 ++ src/system/vscode/command.ts | 11 +++++++++++ 3 files changed, 24 insertions(+) diff --git a/docs/telemetry-events.md b/docs/telemetry-events.md index 065e3dccc9a87..435948ee898d9 100644 --- a/docs/telemetry-events.md +++ b/docs/telemetry-events.md @@ -998,6 +998,17 @@ or } ``` +### home/command + +> Sent when a Home command is executed + +```typescript +{ + 'command': string, + 'webview': string +} +``` + ### home/createBranch > Sent when the user chooses to create a branch from the home view diff --git a/src/constants.telemetry.ts b/src/constants.telemetry.ts index 65e9e11d6a08a..0c491a5c6ebb5 100644 --- a/src/constants.telemetry.ts +++ b/src/constants.telemetry.ts @@ -144,6 +144,8 @@ export interface TelemetryEvents extends WebviewShowAbortedEvents, WebviewShownE /** Sent when the user changes the selected tab (mode) on the Graph Details view */ 'graphDetails/mode/changed': GraphDetailsModeChangedEvent; + /** Sent when a Home command is executed */ + 'home/command': CommandEventData; /** Sent when the new Home view preview is toggled on/off */ 'home/preview/toggled': HomePreviewToggledEvent; /** Sent when the user chooses to create a branch from the home view */ diff --git a/src/system/vscode/command.ts b/src/system/vscode/command.ts index 39ed01aa7c5e9..9cda48d0c652e 100644 --- a/src/system/vscode/command.ts +++ b/src/system/vscode/command.ts @@ -46,6 +46,12 @@ export function registerCommand(command: Commands, callback: CommandCallback, th 'context.mode': context?.mode, 'context.submode': context?.submode, }); + } else if (command.startsWith('gitlens.home.')) { + Container.instance.telemetry.sendEvent('home/command', { + command: command, + 'context.mode': context?.mode, + 'context.submode': context?.submode, + }); } void Container.instance.usage.track(`command:${command}:executed`).catch(); @@ -75,6 +81,11 @@ export function registerWebviewCommand(command: Commands, callback: CommandCallb command: command, webview: webview ?? '', }); + } else if (webview === 'gitlens.views.home' || command.startsWith('gitlens.home.')) { + Container.instance.telemetry.sendEvent('home/command', { + command: command, + webview: webview ?? '', + }); } void Container.instance.usage.track(`command:${command}:executed`).catch();