diff --git a/extensions/microsoft-authentication/src/common/telemetryReporter.ts b/extensions/microsoft-authentication/src/common/telemetryReporter.ts index 25ac2623282..c28aa887e0c 100644 --- a/extensions/microsoft-authentication/src/common/telemetryReporter.ts +++ b/extensions/microsoft-authentication/src/common/telemetryReporter.ts @@ -66,6 +66,24 @@ export class MicrosoftAuthenticationTelemetryReporter implements IExperimentatio */ this._telemetryReporter.sendTelemetryEvent('logoutFailed'); } + + sendTelemetryErrorEvent(error: unknown): void { + const errorMessage = error instanceof Error ? error.message : String(error); + const errorStack = error instanceof Error ? error.stack : undefined; + const errorName = error instanceof Error ? error.name : undefined; + + /* __GDPR__ + "msalError" : { + "owner": "TylerLeonhardt", + "comment": "Used to determine how often users run into issues with the login flow.", + "errorMessage": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The error message from the exception." }, + "errorStack": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The stack trace from the exception." }, + "errorName": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The name of the error." } + } + */ + this._telemetryReporter.sendTelemetryErrorEvent('msalError', { errorMessage, errorStack, errorName }); + } + /** * Sends an event for an account type available at startup. * @param scopes The scopes for the session diff --git a/extensions/microsoft-authentication/src/node/authProvider.ts b/extensions/microsoft-authentication/src/node/authProvider.ts index a08b8f6ec66..cc422957ca9 100644 --- a/extensions/microsoft-authentication/src/node/authProvider.ts +++ b/extensions/microsoft-authentication/src/node/authProvider.ts @@ -354,6 +354,7 @@ export class MsalAuthProvider implements AuthenticationProvider { } catch (e) { // If we can't get a token silently, the account is probably in a bad state so we should skip it // MSAL will log this already, so we don't need to log it again + this._telemetryReporter.sendTelemetryErrorEvent(e); continue; } }