mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
Add even more MSAL error telemetry (#246335)
This commit is contained in:
committed by
GitHub
parent
1b1ed33f82
commit
febbcf78c8
@@ -5,11 +5,15 @@
|
||||
|
||||
import { LogLevel as MsalLogLevel } from '@azure/msal-node';
|
||||
import { env, LogLevel, LogOutputChannel } from 'vscode';
|
||||
import { MicrosoftAuthenticationTelemetryReporter } from './telemetryReporter';
|
||||
|
||||
export class MsalLoggerOptions {
|
||||
piiLoggingEnabled = false;
|
||||
|
||||
constructor(private readonly _output: LogOutputChannel) { }
|
||||
constructor(
|
||||
private readonly _output: LogOutputChannel,
|
||||
private readonly _telemtryReporter: MicrosoftAuthenticationTelemetryReporter
|
||||
) { }
|
||||
|
||||
get logLevel(): MsalLogLevel {
|
||||
return this._toMsalLogLevel(env.logLevel);
|
||||
@@ -27,6 +31,7 @@ export class MsalLoggerOptions {
|
||||
switch (level) {
|
||||
case MsalLogLevel.Error:
|
||||
this._output.error(message);
|
||||
this._telemtryReporter.sendTelemetryErrorEvent(message);
|
||||
return;
|
||||
case MsalLogLevel.Warning:
|
||||
this._output.warn(message);
|
||||
|
||||
@@ -86,7 +86,7 @@ export class MsalAuthProvider implements AuthenticationProvider {
|
||||
uriHandler: UriEventHandler,
|
||||
env: Environment = Environment.AzureCloud
|
||||
): Promise<MsalAuthProvider> {
|
||||
const publicClientManager = await CachedPublicClientApplicationManager.create(context.secrets, logger, env.name);
|
||||
const publicClientManager = await CachedPublicClientApplicationManager.create(context.secrets, logger, telemetryReporter, env.name);
|
||||
context.subscriptions.push(publicClientManager);
|
||||
const authProvider = new MsalAuthProvider(context, telemetryReporter, logger, uriHandler, publicClientManager, env);
|
||||
await authProvider.initialize();
|
||||
|
||||
@@ -11,6 +11,7 @@ import { SecretStorageCachePlugin } from '../common/cachePlugin';
|
||||
import { MsalLoggerOptions } from '../common/loggerOptions';
|
||||
import { ICachedPublicClientApplication } from '../common/publicClientCache';
|
||||
import { IAccountAccess } from '../common/accountAccess';
|
||||
import { MicrosoftAuthenticationTelemetryReporter } from '../common/telemetryReporter';
|
||||
|
||||
export class CachedPublicClientApplication implements ICachedPublicClientApplication {
|
||||
// Core properties
|
||||
@@ -44,8 +45,9 @@ export class CachedPublicClientApplication implements ICachedPublicClientApplica
|
||||
private readonly _secretStorage: SecretStorage,
|
||||
private readonly _accountAccess: IAccountAccess,
|
||||
private readonly _logger: LogOutputChannel,
|
||||
telemetryReporter: MicrosoftAuthenticationTelemetryReporter
|
||||
) {
|
||||
const loggerOptions = new MsalLoggerOptions(_logger);
|
||||
const loggerOptions = new MsalLoggerOptions(_logger, telemetryReporter);
|
||||
const nativeBrokerPlugin = new NativeBrokerPlugin();
|
||||
this._isBrokerAvailable = nativeBrokerPlugin.isBrokerAvailable;
|
||||
this._pca = new PublicClientApplication({
|
||||
@@ -75,9 +77,10 @@ export class CachedPublicClientApplication implements ICachedPublicClientApplica
|
||||
clientId: string,
|
||||
secretStorage: SecretStorage,
|
||||
accountAccess: IAccountAccess,
|
||||
logger: LogOutputChannel
|
||||
logger: LogOutputChannel,
|
||||
telemetryReporter: MicrosoftAuthenticationTelemetryReporter
|
||||
): Promise<CachedPublicClientApplication> {
|
||||
const app = new CachedPublicClientApplication(clientId, secretStorage, accountAccess, logger);
|
||||
const app = new CachedPublicClientApplication(clientId, secretStorage, accountAccess, logger, telemetryReporter);
|
||||
await app.initialize();
|
||||
return app;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { SecretStorage, LogOutputChannel, Disposable, EventEmitter, Memento, Eve
|
||||
import { ICachedPublicClientApplication, ICachedPublicClientApplicationManager } from '../common/publicClientCache';
|
||||
import { CachedPublicClientApplication } from './cachedPublicClientApplication';
|
||||
import { IAccountAccess, ScopedAccountAccess } from '../common/accountAccess';
|
||||
import { MicrosoftAuthenticationTelemetryReporter } from '../common/telemetryReporter';
|
||||
|
||||
export interface IPublicClientApplicationInfo {
|
||||
clientId: string;
|
||||
@@ -29,6 +30,7 @@ export class CachedPublicClientApplicationManager implements ICachedPublicClient
|
||||
private readonly _accountAccess: IAccountAccess,
|
||||
private readonly _secretStorage: SecretStorage,
|
||||
private readonly _logger: LogOutputChannel,
|
||||
private readonly _telemetryReporter: MicrosoftAuthenticationTelemetryReporter,
|
||||
disposables: Disposable[]
|
||||
) {
|
||||
this._disposable = Disposable.from(
|
||||
@@ -41,13 +43,14 @@ export class CachedPublicClientApplicationManager implements ICachedPublicClient
|
||||
static async create(
|
||||
secretStorage: SecretStorage,
|
||||
logger: LogOutputChannel,
|
||||
telemetryReporter: MicrosoftAuthenticationTelemetryReporter,
|
||||
cloudName: string
|
||||
): Promise<CachedPublicClientApplicationManager> {
|
||||
const pcasSecretStorage = await PublicClientApplicationsSecretStorage.create(secretStorage, cloudName);
|
||||
// TODO: Remove the migrations in a version
|
||||
const migrations = await pcasSecretStorage.getOldValue();
|
||||
const accountAccess = await ScopedAccountAccess.create(secretStorage, cloudName, logger, migrations);
|
||||
const manager = new CachedPublicClientApplicationManager(pcasSecretStorage, accountAccess, secretStorage, logger, [pcasSecretStorage, accountAccess]);
|
||||
const manager = new CachedPublicClientApplicationManager(pcasSecretStorage, accountAccess, secretStorage, logger, telemetryReporter, [pcasSecretStorage, accountAccess]);
|
||||
await manager.initialize();
|
||||
return manager;
|
||||
}
|
||||
@@ -138,7 +141,7 @@ export class CachedPublicClientApplicationManager implements ICachedPublicClient
|
||||
}
|
||||
|
||||
private async _doCreatePublicClientApplication(clientId: string): Promise<ICachedPublicClientApplication> {
|
||||
const pca = await CachedPublicClientApplication.create(clientId, this._secretStorage, this._accountAccess, this._logger);
|
||||
const pca = await CachedPublicClientApplication.create(clientId, this._secretStorage, this._accountAccess, this._logger, this._telemetryReporter);
|
||||
this._pcas.set(clientId, pca);
|
||||
const disposable = Disposable.from(
|
||||
pca,
|
||||
|
||||
Reference in New Issue
Block a user