Skip to content

Commit b538c41

Browse files
authored
Merge branch 'dev' into preflightBrowserEnvironmentCheck-setinteractioninprogress
2 parents 7509e54 + f0e04c5 commit b538c41

10 files changed

+70
-14
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "minor",
3+
"comment": "Add errorCode and subErrorCode to client telemetry events (#4863)",
4+
"packageName": "@azure/msal-browser",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "minor",
3+
"comment": "Add errorCode and subErrorCode to performance telemetry events (#4863)",
4+
"packageName": "@azure/msal-common",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

lib/msal-browser/src/app/ClientApplication.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,16 @@ export abstract class ClientApplication {
364364
});
365365
atPopupMeasurement.flushMeasurement();
366366
return result;
367-
}).catch((e) => {
367+
}).catch((e: AuthError) => {
368368
if (loggedInAccounts.length > 0) {
369369
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, InteractionType.Popup, null, e);
370370
} else {
371371
this.eventHandler.emitEvent(EventType.LOGIN_FAILURE, InteractionType.Popup, null, e);
372372
}
373373

374374
atPopupMeasurement.endMeasurement({
375+
errorCode: e.errorCode,
376+
subErrorCode: e.subError,
375377
success: false
376378
});
377379
atPopupMeasurement.flushMeasurement();
@@ -432,13 +434,16 @@ export abstract class ClientApplication {
432434
return result.then((response) => {
433435
this.eventHandler.emitEvent(EventType.SSO_SILENT_SUCCESS, InteractionType.Silent, response);
434436
ssoSilentMeasurement.endMeasurement({
435-
success: true
437+
success: true,
438+
isNativeBroker: response.fromNativeBroker
436439
});
437440
ssoSilentMeasurement.flushMeasurement();
438441
return response;
439-
}).catch ((e) => {
442+
}).catch ((e: AuthError) => {
440443
this.eventHandler.emitEvent(EventType.SSO_SILENT_FAILURE, InteractionType.Silent, null, e);
441444
ssoSilentMeasurement.endMeasurement({
445+
errorCode: e.errorCode,
446+
subErrorCode: e.subError,
442447
success: false
443448
});
444449
ssoSilentMeasurement.flushMeasurement();
@@ -477,15 +482,18 @@ export abstract class ClientApplication {
477482
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_SUCCESS, InteractionType.Silent, result);
478483
this.hybridAuthCodeResponses.delete(hybridAuthCode);
479484
atbcMeasurement.endMeasurement({
480-
success: true
485+
success: true,
486+
isNativeBroker: result.fromNativeBroker
481487
});
482488
atbcMeasurement.flushMeasurement();
483489
return result;
484490
})
485-
.catch((error: Error) => {
491+
.catch((error: AuthError) => {
486492
this.hybridAuthCodeResponses.delete(hybridAuthCode);
487493
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, InteractionType.Silent, null, error);
488494
atbcMeasurement.endMeasurement({
495+
errorCode: error.errorCode,
496+
subErrorCode: error.subError,
489497
success: false
490498
});
491499
atbcMeasurement.flushMeasurement();
@@ -519,6 +527,8 @@ export abstract class ClientApplication {
519527
} catch (e) {
520528
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, InteractionType.Silent, null, e);
521529
atbcMeasurement.endMeasurement({
530+
errorCode: e instanceof AuthError && e.errorCode || undefined,
531+
subErrorCode: e instanceof AuthError && e.subError || undefined,
522532
success: false
523533
});
524534
throw e;
@@ -583,6 +593,8 @@ export abstract class ClientApplication {
583593
})
584594
.catch((error) => {
585595
atbrtMeasurement.endMeasurement({
596+
errorCode: error.errorCode,
597+
subErrorCode: error.subError,
586598
success: false
587599
});
588600
throw error;

lib/msal-browser/src/app/PublicClientApplication.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,17 @@ export class PublicClientApplication extends ClientApplication implements IPubli
125125
this.activeSilentTokenRequests.delete(silentRequestKey);
126126
atsMeasurement.endMeasurement({
127127
success: true,
128-
fromCache: result.fromCache
128+
fromCache: result.fromCache,
129+
isNativeBroker: result.fromNativeBroker
129130
});
130131
atsMeasurement.flushMeasurement();
131132
return result;
132133
})
133-
.catch((error) => {
134+
.catch((error: AuthError) => {
134135
this.activeSilentTokenRequests.delete(silentRequestKey);
135136
atsMeasurement.endMeasurement({
137+
errorCode: error.errorCode,
138+
subErrorCode: error.subError,
136139
success: false
137140
});
138141
atsMeasurement.flushMeasurement();
@@ -193,12 +196,15 @@ export class PublicClientApplication extends ClientApplication implements IPubli
193196
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, InteractionType.Silent, response);
194197
astsAsyncMeasurement.endMeasurement({
195198
success: true,
196-
fromCache: response.fromCache
199+
fromCache: response.fromCache,
200+
isNativeBroker: response.fromNativeBroker
197201
});
198202
return response;
199-
}).catch((tokenRenewalError) => {
203+
}).catch((tokenRenewalError: AuthError) => {
200204
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, InteractionType.Silent, null, tokenRenewalError);
201205
astsAsyncMeasurement.endMeasurement({
206+
errorCode: tokenRenewalError.errorCode,
207+
subErrorCode: tokenRenewalError.subError,
202208
success: false
203209
});
204210
throw tokenRenewalError;

lib/msal-browser/src/interaction_client/NativeInteractionClient.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License.
44
*/
55

6-
import { AuthenticationResult, Logger, ICrypto, PromptValue, AuthToken, Constants, AccountEntity, AuthorityType, ScopeSet, TimeUtils, AuthenticationScheme, UrlString, OIDC_DEFAULT_SCOPES, PopTokenGenerator, SignedHttpRequestParameters, IPerformanceClient, PerformanceEvents, ClientAuthError } from "@azure/msal-common";
6+
import { AuthenticationResult, Logger, ICrypto, PromptValue, AuthToken, Constants, AccountEntity, AuthorityType, ScopeSet, TimeUtils, AuthenticationScheme, UrlString, OIDC_DEFAULT_SCOPES, PopTokenGenerator, SignedHttpRequestParameters, IPerformanceClient, PerformanceEvents, ClientAuthError, AuthError } from "@azure/msal-common";
77
import { BaseInteractionClient } from "./BaseInteractionClient";
88
import { BrowserConfiguration } from "../config/Configuration";
99
import { BrowserCacheManager } from "../cache/BrowserCacheManager";
@@ -61,9 +61,11 @@ export class NativeInteractionClient extends BaseInteractionClient {
6161
});
6262
return result;
6363
})
64-
.catch((error) => {
64+
.catch((error: AuthError) => {
6565
nativeATMeasurement.endMeasurement({
6666
success: false,
67+
errorCode: error.errorCode,
68+
subErrorCode: error.subError,
6769
isNativeBroker: true
6870
});
6971
throw error;

lib/msal-browser/src/interaction_client/SilentCacheClient.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import { StandardInteractionClient } from "./StandardInteractionClient";
7-
import { CommonSilentFlowRequest, AuthenticationResult, SilentFlowClient, ServerTelemetryManager, AccountInfo, AzureCloudOptions, PerformanceEvents} from "@azure/msal-common";
7+
import { CommonSilentFlowRequest, AuthenticationResult, SilentFlowClient, ServerTelemetryManager, AccountInfo, AzureCloudOptions, PerformanceEvents, AuthError} from "@azure/msal-common";
88
import { SilentRequest } from "../request/SilentRequest";
99
import { ApiId } from "../utils/BrowserConstants";
1010
import { BrowserAuthError, BrowserAuthErrorMessage } from "../error/BrowserAuthError";
@@ -34,6 +34,8 @@ export class SilentCacheClient extends StandardInteractionClient {
3434
this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
3535
}
3636
acquireTokenMeasurement.endMeasurement({
37+
errorCode: error instanceof AuthError && error.errorCode || undefined,
38+
subErrorCode: error instanceof AuthError && error.subError || undefined,
3739
success: false
3840
});
3941
throw error;

lib/msal-browser/src/interaction_client/SilentIframeClient.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export class SilentIframeClient extends StandardInteractionClient {
7373
serverTelemetryManager.cacheFailedRequest(e);
7474
this.browserStorage.cleanRequestByState(silentRequest.state);
7575
acquireTokenMeasurement.endMeasurement({
76+
errorCode: e instanceof AuthError && e.errorCode || undefined,
77+
subErrorCode: e instanceof AuthError && e.subError || undefined,
7678
success: false
7779
});
7880
throw e;

lib/msal-browser/src/interaction_client/SilentRefreshClient.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export class SilentRefreshClient extends StandardInteractionClient {
4040
}
4141
serverTelemetryManager.cacheFailedRequest(e);
4242
acquireTokenMeasurement.endMeasurement({
43+
errorCode: e.errorCode,
44+
subErrorCode: e.subError,
4345
success: false
4446
});
4547
throw e;

lib/msal-browser/src/interaction_client/StandardInteractionClient.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License.
44
*/
55

6-
import { ServerTelemetryManager, CommonAuthorizationCodeRequest, Constants, AuthorizationCodeClient, ClientConfiguration, AuthorityOptions, Authority, AuthorityFactory, ServerAuthorizationCodeResponse, UrlString, CommonEndSessionRequest, ProtocolUtils, ResponseMode, StringUtils, IdTokenClaims, AccountInfo, AzureCloudOptions, PerformanceEvents } from "@azure/msal-common";
6+
import { ServerTelemetryManager, CommonAuthorizationCodeRequest, Constants, AuthorizationCodeClient, ClientConfiguration, AuthorityOptions, Authority, AuthorityFactory, ServerAuthorizationCodeResponse, UrlString, CommonEndSessionRequest, ProtocolUtils, ResponseMode, StringUtils, IdTokenClaims, AccountInfo, AzureCloudOptions, PerformanceEvents, AuthError } from "@azure/msal-common";
77
import { BaseInteractionClient } from "./BaseInteractionClient";
88
import { AuthorizationUrlRequest } from "../request/AuthorizationUrlRequest";
99
import { BrowserConstants, InteractionType } from "../utils/BrowserConstants";
@@ -223,8 +223,10 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
223223

224224
return result;
225225
})
226-
.catch((error:Error) => {
226+
.catch((error:AuthError) => {
227227
getAuthorityMeasurement.endMeasurement({
228+
errorCode: error.errorCode,
229+
subErrorCode: error.subError,
228230
success: false
229231
});
230232

lib/msal-common/src/telemetry/performance/PerformanceEvent.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,20 @@ export type PerformanceEvent = {
202202
*/
203203
success?: boolean | null,
204204

205+
/**
206+
* Add specific error code in case of failure
207+
*
208+
* @type {string}
209+
*/
210+
errorCode?: string,
211+
212+
/**
213+
* Add specific sub error code in case of failure
214+
*
215+
* @type {string}
216+
*/
217+
subErrorCode?: string,
218+
205219
/**
206220
* Name of the library used for the operation.
207221
*

0 commit comments

Comments
 (0)