Skip to content

Commit 83feb98

Browse files
d13eamodio
authored andcommitted
Adds telemetry for inspect
1 parent d63d7c7 commit 83feb98

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

src/webviews/commitDetails/commitDetailsWebview.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,41 @@ export class CommitDetailsWebviewProvider
219219
this._wipSubscription?.subscription.dispose();
220220
}
221221

222+
getTelemetryContext() {
223+
return {
224+
...this.host.getTelemetryContext(),
225+
...this.getModeTelemetryContext(),
226+
};
227+
}
228+
229+
getModeTelemetryContext() {
230+
const context: Record<`context.${string}`, string | number | boolean | undefined> = {
231+
'context.mode': this.mode,
232+
};
233+
234+
if (this.mode === 'wip') {
235+
context['context.autolinks'] = this._context.wip?.pullRequest != null;
236+
context['context.overview.inReview'] = this._context.inReview;
237+
context['context.overview.codeSuggestions'] = this._context.wip?.codeSuggestions?.length ?? 0;
238+
if (this._context.wip?.repo != null) {
239+
const { idHash, uri, closed, folder, provider } = this._context.wip.repo;
240+
context['context.overview.repository.id'] = idHash;
241+
context['context.overview.repository.scheme'] = uri.scheme;
242+
context['context.overview.repository.closed'] = closed;
243+
context['context.overview.repository.folder.scheme'] = folder?.uri.scheme;
244+
context['context.overview.repository.provider.id'] = provider.id;
245+
}
246+
} else {
247+
context['context.autolinks'] =
248+
this._context.pullRequest != null ||
249+
(this._context.autolinkedIssues != null && this._context.autolinkedIssues.length > 0);
250+
context['context.inspect.pinned'] = this._context.pinned;
251+
context['context.inspect.uncommitted'] = this._context.commit?.isUncommitted ?? false;
252+
}
253+
254+
return context;
255+
}
256+
222257
private _skipNextRefreshOnVisibilityChange = false;
223258
private _shouldRefreshPullRequestDetails = false;
224259

@@ -233,7 +268,7 @@ export class CommitDetailsWebviewProvider
233268
}
234269
return [
235270
await this.onShowingCommit(arg as Partial<CommitSelectedEvent['data']> | undefined, options),
236-
undefined,
271+
this.getTelemetryContext(),
237272
];
238273
}
239274

0 commit comments

Comments
 (0)