Fix MSAL Runtime telemetry not firing (#282595)

We were too strict. This should actually yield telemtry.

Fixes https://github.com/microsoft/vscode/issues/282593
This commit is contained in:
Tyler James Leonhardt
2025-12-10 15:48:55 -08:00
committed by GitHub
parent 71f35296d2
commit e3bbd5bb1d
2 changed files with 6 additions and 3 deletions

View File

@@ -108,9 +108,10 @@ export class MicrosoftAuthenticationTelemetryReporter implements IExperimentatio
}); });
} }
sendTelemetryClientAuthErrorEvent(error: ClientAuthError): void { sendTelemetryClientAuthErrorEvent(error: AuthError): void {
const errorCode = error.errorCode; const errorCode = error.errorCode;
const correlationId = error.correlationId; const correlationId = error.correlationId;
const errorName = error.name;
let brokerErrorCode: string | undefined; let brokerErrorCode: string | undefined;
let brokerStatusCode: string | undefined; let brokerStatusCode: string | undefined;
let brokerTag: string | undefined; let brokerTag: string | undefined;
@@ -126,6 +127,7 @@ export class MicrosoftAuthenticationTelemetryReporter implements IExperimentatio
"msalClientAuthError" : { "msalClientAuthError" : {
"owner": "TylerLeonhardt", "owner": "TylerLeonhardt",
"comment": "Used to determine how often users run into client auth errors during the login flow.", "comment": "Used to determine how often users run into client auth errors during the login flow.",
"errorName": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The name of the client auth error." },
"errorCode": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The client auth error code." }, "errorCode": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The client auth error code." },
"correlationId": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The client auth error correlation id." }, "correlationId": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The client auth error correlation id." },
"brokerErrorCode": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The broker error code." }, "brokerErrorCode": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The broker error code." },
@@ -134,6 +136,7 @@ export class MicrosoftAuthenticationTelemetryReporter implements IExperimentatio
} }
*/ */
this._telemetryReporter.sendTelemetryErrorEvent('msalClientAuthError', { this._telemetryReporter.sendTelemetryErrorEvent('msalClientAuthError', {
errorName,
errorCode, errorCode,
correlationId, correlationId,
brokerErrorCode, brokerErrorCode,

View File

@@ -2,7 +2,7 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { AccountInfo, AuthenticationResult, ClientAuthError, ClientAuthErrorCodes, ServerError, SilentFlowRequest } from '@azure/msal-node'; import { AccountInfo, AuthenticationResult, AuthError, ClientAuthError, ClientAuthErrorCodes, ServerError } from '@azure/msal-node';
import { AuthenticationChallenge, AuthenticationConstraint, AuthenticationGetSessionOptions, AuthenticationProvider, AuthenticationProviderAuthenticationSessionsChangeEvent, AuthenticationProviderSessionOptions, AuthenticationSession, AuthenticationSessionAccountInformation, CancellationError, env, EventEmitter, ExtensionContext, ExtensionKind, l10n, LogOutputChannel, Uri, window } from 'vscode'; import { AuthenticationChallenge, AuthenticationConstraint, AuthenticationGetSessionOptions, AuthenticationProvider, AuthenticationProviderAuthenticationSessionsChangeEvent, AuthenticationProviderSessionOptions, AuthenticationSession, AuthenticationSessionAccountInformation, CancellationError, env, EventEmitter, ExtensionContext, ExtensionKind, l10n, LogOutputChannel, Uri, window } from 'vscode';
import { Environment } from '@azure/ms-rest-azure-env'; import { Environment } from '@azure/ms-rest-azure-env';
import { CachedPublicClientApplicationManager } from './publicClientCache'; import { CachedPublicClientApplicationManager } from './publicClientCache';
@@ -522,7 +522,7 @@ export class MsalAuthProvider implements AuthenticationProvider {
} catch (e) { } catch (e) {
// If we can't get a token silently, the account is probably in a bad state so we should skip it // 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 // MSAL will log this already, so we don't need to log it again
if (e instanceof ClientAuthError) { if (e instanceof AuthError) {
this._telemetryReporter.sendTelemetryClientAuthErrorEvent(e); this._telemetryReporter.sendTelemetryClientAuthErrorEvent(e);
} else { } else {
this._telemetryReporter.sendTelemetryErrorEvent(e); this._telemetryReporter.sendTelemetryErrorEvent(e);