Skip to content

Commit fe3803e

Browse files
authored
Report snooze duration for inline completions (microsoft#254848)
report snooze duration
1 parent 8bd52a1 commit fe3803e

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/vs/editor/browser/services/inlineCompletionsService.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { InstantiationType, registerSingleton } from '../../../platform/instanti
1414
import { createDecorator, ServicesAccessor } from '../../../platform/instantiation/common/instantiation.js';
1515
import { IQuickInputService, IQuickPickItem } from '../../../platform/quickinput/common/quickInput.js';
1616
import { IStorageService, StorageScope, StorageTarget } from '../../../platform/storage/common/storage.js';
17+
import { ITelemetryService } from '../../../platform/telemetry/common/telemetry.js';
1718

1819
export const IInlineCompletionsService = createDecorator<IInlineCompletionsService>('IInlineCompletionsService');
1920

@@ -69,7 +70,10 @@ export class InlineCompletionsService extends Disposable implements IInlineCompl
6970

7071
private _timer: WindowIntervalTimer;
7172

72-
constructor(@IContextKeyService private _contextKeyService: IContextKeyService) {
73+
constructor(
74+
@IContextKeyService private _contextKeyService: IContextKeyService,
75+
@ITelemetryService private _telemetryService: ITelemetryService,
76+
) {
7377
super();
7478

7579
this._timer = this._register(new WindowIntervalTimer());
@@ -92,6 +96,8 @@ export class InlineCompletionsService extends Disposable implements IInlineCompl
9296
}
9397

9498
const wasSnoozing = this.isSnoozing();
99+
const timeLeft = this.snoozeTimeLeft;
100+
95101
this._snoozeTimeEnd = Date.now() + durationMs;
96102

97103
if (!wasSnoozing) {
@@ -108,6 +114,8 @@ export class InlineCompletionsService extends Disposable implements IInlineCompl
108114
},
109115
this.snoozeTimeLeft + 1,
110116
);
117+
118+
this._reportSnooze(durationMs - timeLeft, durationMs);
111119
}
112120

113121
isSnoozing(): boolean {
@@ -116,11 +124,28 @@ export class InlineCompletionsService extends Disposable implements IInlineCompl
116124

117125
cancelSnooze(): void {
118126
if (this.isSnoozing()) {
127+
this._reportSnooze(-this.snoozeTimeLeft, 0);
119128
this._snoozeTimeEnd = undefined;
120129
this._timer.cancel();
121130
this._onDidChangeIsSnoozing.fire(false);
122131
}
123132
}
133+
134+
private _reportSnooze(deltaMs: number, totalMs: number): void {
135+
const deltaSeconds = Math.round(deltaMs / 1000);
136+
const totalSeconds = Math.round(totalMs / 1000);
137+
type WorkspaceStatsClassification = {
138+
owner: 'benibenj';
139+
comment: 'Snooze duration for inline completions';
140+
deltaSeconds: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The duration by which the snooze has changed, in seconds.' };
141+
totalSeconds: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The total duration for which inline completions are snoozed, in seconds.' };
142+
};
143+
type WorkspaceStatsEvent = {
144+
deltaSeconds: number;
145+
totalSeconds: number;
146+
};
147+
this._telemetryService.publicLog2<WorkspaceStatsEvent, WorkspaceStatsClassification>('inlineCompletions.snooze', { deltaSeconds, totalSeconds });
148+
}
124149
}
125150

126151
registerSingleton(IInlineCompletionsService, InlineCompletionsService, InstantiationType.Delayed);

0 commit comments

Comments
 (0)