Have `authentication.clientIdUsage` fire before invoking the provider (#234300)

To help us capture the extensions that don't resolve.
This commit is contained in:
Tyler James Leonhardt 2024-11-20 14:14:37 -08:00 коммит произвёл GitHub
Родитель 2ee7ae88b4
Коммит 6306259d87
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 16 добавлений и 9 удалений

Просмотреть файл

@ -299,10 +299,11 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
}
async $getSession(providerId: string, scopes: string[], extensionId: string, extensionName: string, options: AuthenticationGetSessionOptions): Promise<AuthenticationSession | undefined> {
this.sendClientIdUsageTelemetry(extensionId, providerId, scopes);
const session = await this.doGetSession(providerId, scopes, extensionId, extensionName, options);
if (session) {
this.sendProviderUsageTelemetry(extensionId, providerId, scopes);
this.sendProviderUsageTelemetry(extensionId, providerId);
this.authenticationUsageService.addAccountUsage(providerId, session.account.label, scopes, extensionId, extensionName);
}
@ -314,18 +315,18 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
return accounts;
}
private sendProviderUsageTelemetry(extensionId: string, providerId: string, scopes: string[]): void {
// TODO@TylerLeonhardt this is a temporary addition to telemetry to understand what extensions are overriding the client id.
// We can use this telemetry to reach out to these extension authors and let them know that they many need configuration changes
// due to the adoption of the Microsoft broker.
// Remove this in a few iterations.
// TODO@TylerLeonhardt this is a temporary addition to telemetry to understand what extensions are overriding the client id.
// We can use this telemetry to reach out to these extension authors and let them know that they many need configuration changes
// due to the adoption of the Microsoft broker.
// Remove this in a few iterations.
private _sentClientIdUsageEvents = new Set<string>();
private sendClientIdUsageTelemetry(extensionId: string, providerId: string, scopes: string[]): void {
const containsVSCodeClientIdScope = scopes.some(scope => scope.startsWith('VSCODE_CLIENT_ID:'));
const key = `${extensionId}|${providerId}|${containsVSCodeClientIdScope}`;
if (this._sentProviderUsageEvents.has(key)) {
if (this._sentClientIdUsageEvents.has(key)) {
return;
}
this._sentClientIdUsageEvents.add(key);
if (containsVSCodeClientIdScope) {
type ClientIdUsageClassification = {
owner: 'TylerLeonhardt';
@ -334,7 +335,13 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
};
this.telemetryService.publicLog2<{ extensionId: string }, ClientIdUsageClassification>('authentication.clientIdUsage', { extensionId });
}
}
private sendProviderUsageTelemetry(extensionId: string, providerId: string): void {
const key = `${extensionId}|${providerId}`;
if (this._sentProviderUsageEvents.has(key)) {
return;
}
this._sentProviderUsageEvents.add(key);
type AuthProviderUsageClassification = {
owner: 'TylerLeonhardt';