Skip to content

Commit 6306259

Browse files
Have authentication.clientIdUsage fire before invoking the provider (microsoft#234300)
To help us capture the extensions that don't resolve.
1 parent 2ee7ae8 commit 6306259

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/vs/workbench/api/browser/mainThreadAuthentication.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,11 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
299299
}
300300

301301
async $getSession(providerId: string, scopes: string[], extensionId: string, extensionName: string, options: AuthenticationGetSessionOptions): Promise<AuthenticationSession | undefined> {
302+
this.sendClientIdUsageTelemetry(extensionId, providerId, scopes);
302303
const session = await this.doGetSession(providerId, scopes, extensionId, extensionName, options);
303304

304305
if (session) {
305-
this.sendProviderUsageTelemetry(extensionId, providerId, scopes);
306+
this.sendProviderUsageTelemetry(extensionId, providerId);
306307
this.authenticationUsageService.addAccountUsage(providerId, session.account.label, scopes, extensionId, extensionName);
307308
}
308309

@@ -314,18 +315,18 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
314315
return accounts;
315316
}
316317

317-
private sendProviderUsageTelemetry(extensionId: string, providerId: string, scopes: string[]): void {
318-
// TODO@TylerLeonhardt this is a temporary addition to telemetry to understand what extensions are overriding the client id.
319-
// We can use this telemetry to reach out to these extension authors and let them know that they many need configuration changes
320-
// due to the adoption of the Microsoft broker.
321-
// Remove this in a few iterations.
318+
// TODO@TylerLeonhardt this is a temporary addition to telemetry to understand what extensions are overriding the client id.
319+
// We can use this telemetry to reach out to these extension authors and let them know that they many need configuration changes
320+
// due to the adoption of the Microsoft broker.
321+
// Remove this in a few iterations.
322+
private _sentClientIdUsageEvents = new Set<string>();
323+
private sendClientIdUsageTelemetry(extensionId: string, providerId: string, scopes: string[]): void {
322324
const containsVSCodeClientIdScope = scopes.some(scope => scope.startsWith('VSCODE_CLIENT_ID:'));
323-
324325
const key = `${extensionId}|${providerId}|${containsVSCodeClientIdScope}`;
325-
if (this._sentProviderUsageEvents.has(key)) {
326+
if (this._sentClientIdUsageEvents.has(key)) {
326327
return;
327328
}
328-
329+
this._sentClientIdUsageEvents.add(key);
329330
if (containsVSCodeClientIdScope) {
330331
type ClientIdUsageClassification = {
331332
owner: 'TylerLeonhardt';
@@ -334,7 +335,13 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
334335
};
335336
this.telemetryService.publicLog2<{ extensionId: string }, ClientIdUsageClassification>('authentication.clientIdUsage', { extensionId });
336337
}
338+
}
337339

340+
private sendProviderUsageTelemetry(extensionId: string, providerId: string): void {
341+
const key = `${extensionId}|${providerId}`;
342+
if (this._sentProviderUsageEvents.has(key)) {
343+
return;
344+
}
338345
this._sentProviderUsageEvents.add(key);
339346
type AuthProviderUsageClassification = {
340347
owner: 'TylerLeonhardt';

0 commit comments

Comments
 (0)