Skip to content

Commit 37ba74e

Browse files
committed
Adds scope into tracking
1 parent 2ebd871 commit 37ba74e

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

docs/telemetry-events.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2022,13 +2022,18 @@ or
20222022
```typescript
20232023
{
20242024
'context.period': 'all' | `${number}|D` | `${number}|M` | `${number}|Y`,
2025+
'context.scope.hasBase': boolean,
2026+
'context.scope.hasHead': boolean,
20252027
'context.scope.type': 'file' | 'folder' | 'repo',
20262028
'context.showAllBranches': boolean,
20272029
'context.sliceBy': 'branch' | 'author',
20282030
'context.webview.host': 'editor' | 'view',
20292031
'context.webview.id': string,
20302032
'context.webview.instanceId': string,
2031-
'context.webview.type': string
2033+
'context.webview.type': string,
2034+
'scope.hasBase': boolean,
2035+
'scope.hasHead': boolean,
2036+
'scope.type': 'file' | 'folder' | 'repo'
20322037
}
20332038
```
20342039

@@ -2039,6 +2044,8 @@ or
20392044
```typescript
20402045
{
20412046
'context.period': 'all' | `${number}|D` | `${number}|M` | `${number}|Y`,
2047+
'context.scope.hasBase': boolean,
2048+
'context.scope.hasHead': boolean,
20422049
'context.scope.type': 'file' | 'folder' | 'repo',
20432050
'context.showAllBranches': boolean,
20442051
'context.sliceBy': 'branch' | 'author',
@@ -2056,6 +2063,8 @@ or
20562063
```typescript
20572064
{
20582065
'context.period': 'all' | `${number}|D` | `${number}|M` | `${number}|Y`,
2066+
'context.scope.hasBase': boolean,
2067+
'context.scope.hasHead': boolean,
20592068
'context.scope.type': 'file' | 'folder' | 'repo',
20602069
'context.showAllBranches': boolean,
20612070
'context.sliceBy': 'branch' | 'author',
@@ -2076,6 +2085,8 @@ or
20762085
```typescript
20772086
{
20782087
'context.period': 'all' | `${number}|D` | `${number}|M` | `${number}|Y`,
2088+
'context.scope.hasBase': boolean,
2089+
'context.scope.hasHead': boolean,
20792090
'context.scope.type': 'file' | 'folder' | 'repo',
20802091
'context.showAllBranches': boolean,
20812092
'context.sliceBy': 'branch' | 'author',
@@ -2093,6 +2104,8 @@ or
20932104
```typescript
20942105
{
20952106
'context.period': 'all' | `${number}|D` | `${number}|M` | `${number}|Y`,
2107+
'context.scope.hasBase': boolean,
2108+
'context.scope.hasHead': boolean,
20962109
'context.scope.type': 'file' | 'folder' | 'repo',
20972110
'context.showAllBranches': boolean,
20982111
'context.sliceBy': 'branch' | 'author',
@@ -2125,6 +2138,8 @@ or
21252138
'context.config.allowMultiple': boolean,
21262139
'context.config.queryLimit': number,
21272140
'context.period': 'all' | `${number}|D` | `${number}|M` | `${number}|Y`,
2141+
'context.scope.hasBase': boolean,
2142+
'context.scope.hasHead': boolean,
21282143
'context.scope.type': 'file' | 'folder' | 'repo',
21292144
'context.showAllBranches': boolean,
21302145
'context.sliceBy': 'branch' | 'author',

src/constants.telemetry.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ export interface TelemetryEvents extends WebviewShowAbortedEvents, WebviewShownE
258258
/** Sent when the Visual History is shown */
259259
'timeline/shown': TimelineShownEvent;
260260
/** Sent when the user clicks on the "Open in Editor" button on the Visual History */
261-
'timeline/action/openInEditor': TimelineContextEventData;
261+
'timeline/action/openInEditor': TimelineActionOpenInEditorEvent;
262262
/** Sent when the editor changes on the Visual History */
263263
'timeline/editor/changed': TimelineContextEventData;
264264
/** Sent when the user selects (clicks on) a commit on the Visual History */
@@ -877,6 +877,8 @@ export interface SubscriptionEventDataWithPrevious
877877

878878
type TimelineContextEventData = WebviewTelemetryContext & {
879879
'context.period': TimelinePeriod | undefined;
880+
'context.scope.hasHead': boolean | undefined;
881+
'context.scope.hasBase': boolean | undefined;
880882
'context.scope.type': TimelineScopeType | undefined;
881883
'context.showAllBranches': boolean | undefined;
882884
'context.sliceBy': TimelineSliceBy | undefined;
@@ -894,6 +896,12 @@ interface TimelineConfigChangedEvent extends TimelineContextEventData {
894896
sliceBy: TimelineSliceBy;
895897
}
896898

899+
interface TimelineActionOpenInEditorEvent extends TimelineContextEventData {
900+
'scope.type': TimelineScopeType;
901+
'scope.hasHead': boolean;
902+
'scope.hasBase': boolean;
903+
}
904+
897905
interface UsageTrackEvent {
898906
'usage.key': TrackedUsageKeys;
899907
'usage.count': number;

src/webviews/plus/timeline/timelineWebview.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ export class TimelineWebviewProvider implements WebviewProvider<State, State, Ti
166166
return {
167167
...this.host.getTelemetryContext(),
168168
'context.period': this._context.config.period,
169+
'context.scope.hasHead': this._context.scope?.head != null,
170+
'context.scope.hasBase': this._context.scope?.base != null,
169171
'context.scope.type': this._context.scope?.type,
170172
'context.showAllBranches': this._context.config.showAllBranches,
171173
'context.sliceBy': this._context.config.sliceBy,
@@ -236,7 +238,12 @@ export class TimelineWebviewProvider implements WebviewProvider<State, State, Ti
236238
if (this._context.scope?.type !== 'file') return;
237239

238240
void executeCommand<TimelineScope>('gitlens.visualizeHistory', this._context.scope);
239-
this.container.telemetry.sendEvent('timeline/action/openInEditor', this.getTelemetryContext());
241+
this.container.telemetry.sendEvent('timeline/action/openInEditor', {
242+
...this.getTelemetryContext(),
243+
'scope.type': this._context.scope.type,
244+
'scope.hasHead': this._context.scope.head != null,
245+
'scope.hasBase': this._context.scope.base != null,
246+
});
240247
},
241248
this,
242249
),
@@ -504,6 +511,12 @@ export class TimelineWebviewProvider implements WebviewProvider<State, State, Ti
504511
// If we are changing the type, and in the view, open it in the editor
505512
if (this.host.is('view') || e.params.altOrShift) {
506513
void executeCommand<TimelineScope>('gitlens.visualizeHistory', scope);
514+
this.container.telemetry.sendEvent('timeline/action/openInEditor', {
515+
...this.getTelemetryContext(),
516+
'scope.type': scope.type,
517+
'scope.hasHead': scope.head != null,
518+
'scope.hasBase': scope.base != null,
519+
});
507520
return;
508521
}
509522

0 commit comments

Comments
 (0)