diff --git a/change/@azure-msal-browser-0c5b4f43-6dec-40eb-8a4d-60a63666c744.json b/change/@azure-msal-browser-0c5b4f43-6dec-40eb-8a4d-60a63666c744.json new file mode 100644 index 0000000000..b35b1b7a37 --- /dev/null +++ b/change/@azure-msal-browser-0c5b4f43-6dec-40eb-8a4d-60a63666c744.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "Disable ServerTelemetryManager by default [#8600](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/8600)", + "packageName": "@azure/msal-browser", + "email": "thomas.norling@microsoft.com", + "dependentChangeType": "patch" +} \ No newline at end of file diff --git a/change/@azure-msal-common-ac7e7225-f5ff-4376-a86b-b6989215c195.json b/change/@azure-msal-common-ac7e7225-f5ff-4376-a86b-b6989215c195.json new file mode 100644 index 0000000000..3411cb3a67 --- /dev/null +++ b/change/@azure-msal-common-ac7e7225-f5ff-4376-a86b-b6989215c195.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "Disable ServerTelemetryManager by default [#8600](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/8600)", + "packageName": "@azure/msal-common", + "email": "thomas.norling@microsoft.com", + "dependentChangeType": "patch" +} \ No newline at end of file diff --git a/lib/msal-browser/apiReview/msal-browser.api.md b/lib/msal-browser/apiReview/msal-browser.api.md index 22843e65bc..07af9f2cb2 100644 --- a/lib/msal-browser/apiReview/msal-browser.api.md +++ b/lib/msal-browser/apiReview/msal-browser.api.md @@ -411,6 +411,7 @@ export type BrowserSystemOptions = SystemOptions & { allowPlatformBroker?: boolean; nativeBrokerHandshakeTimeout?: number; protocolMode?: ProtocolMode; + serverTelemetryEnabled?: boolean; }; // Warning: (ae-missing-release-tag) "BrowserTelemetryOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -1542,8 +1543,8 @@ export type WrapperSKU = (typeof WrapperSKU)[keyof typeof WrapperSKU]; // src/cache/LocalStorage.ts:366:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen // src/cache/LocalStorage.ts:429:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen // src/cache/LocalStorage.ts:460:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen -// src/config/Configuration.ts:217:5 - (ae-incompatible-release-tags) The symbol "experimental" is marked as @public, but its signature references "BrowserExperimentalOptions" which is marked as @internal -// src/config/Configuration.ts:226:5 - (ae-forgotten-export) The symbol "InternalAuthOptions" needs to be exported by the entry point index.d.ts +// src/config/Configuration.ts:222:5 - (ae-incompatible-release-tags) The symbol "experimental" is marked as @public, but its signature references "BrowserExperimentalOptions" which is marked as @internal +// src/config/Configuration.ts:231:5 - (ae-forgotten-export) The symbol "InternalAuthOptions" needs to be exported by the entry point index.d.ts // src/event/EventHandler.ts:116:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen // src/event/EventHandler.ts:143:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen // src/index.ts:8:12 - (tsdoc-characters-after-block-tag) The token "@azure" looks like a TSDoc tag but contains an invalid character "/"; if it is not a tag, use a backslash to escape the "@" diff --git a/lib/msal-browser/docs/configuration.md b/lib/msal-browser/docs/configuration.md index 1cde172cce..4781fe36d8 100644 --- a/lib/msal-browser/docs/configuration.md +++ b/lib/msal-browser/docs/configuration.md @@ -53,7 +53,8 @@ const msalConfig = { windowHashTimeout: 60000, iframeHashTimeout: 6000, loadFrameTimeout: 0, - protocolMode: "AAD" + protocolMode: "AAD", + serverTelemetryEnabled: false, }, telemetry: { application: { @@ -104,7 +105,8 @@ See [Caching in MSAL](./caching.md) for more. | `cryptoOptions` | Config object for crypto operations in the browser. | See [below](#crypto-config-options.) | See [below](#crypto-config-options.) | | `popupBridgeTimeout` | Timeout in milliseconds to wait for the popup to send its response via BroadcastChannel. If the user closes the popup without completing authentication, `loginPopup` or `acquireTokenPopup` will reject with a `timed_out` error after this timeout. See [Popup closure detection](./login-user.md#popup-closure-detection-and-interactionstatus). | integer (milliseconds) | `60000` | | `iframeBridgeTimeout` | Timeout in milliseconds to wait for a hidden iframe to send its response via BroadcastChannel during silent token acquisition (`ssoSilent`, `acquireTokenSilent`). If the iframe does not respond within this time, the call will reject with a `timed_out` error. | integer (milliseconds) | `10000` | -| `protocolMode` | Enum representing the protocol mode to use. If `"AAD"`, will function on the OIDC-compliant AAD v2 endpoints; if `"OIDC"`, will function on other OIDC-compliant endpoints. +| `protocolMode` | Enum representing the protocol mode to use. If `"AAD"`, will function on the OIDC-compliant AAD v2 endpoints; if `"OIDC"`, will function on other OIDC-compliant endpoints. | string | `"AAD"` | +| `serverTelemetryEnabled` | Enables MSER server telemetry headers and browser cache writes for failed requests. When `false`, MSAL does not send MSER headers and does not persist server telemetry data to browser storage. This option is deprecated and will be removed in a future release. | boolean | `false` | #### Logger Config Options diff --git a/lib/msal-browser/src/config/Configuration.ts b/lib/msal-browser/src/config/Configuration.ts index 03e77eb658..0679aebfb6 100644 --- a/lib/msal-browser/src/config/Configuration.ts +++ b/lib/msal-browser/src/config/Configuration.ts @@ -167,6 +167,11 @@ export type BrowserSystemOptions = SystemOptions & { * Enum that represents the protocol that msal follows. Used for configuring proper endpoints. */ protocolMode?: ProtocolMode; + /** + * @deprecated This option will be removed in a future release. + * Flag to enable emitting telemetry to the STS. When disabled, failed requests are not cached to browser storage and x-client-current-telemetry, x-client-last-telemetry parameters are not sent to the STS. Defaults to false. + */ + serverTelemetryEnabled?: boolean; }; /** @internal */ @@ -315,6 +320,7 @@ export function buildConfiguration( userInputSystem?.nativeBrokerHandshakeTimeout || DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS, protocolMode: ProtocolMode.AAD, + serverTelemetryEnabled: false, }; const providedSystemOptions: Required = { diff --git a/lib/msal-browser/src/interaction_client/BaseInteractionClient.ts b/lib/msal-browser/src/interaction_client/BaseInteractionClient.ts index aef29d8129..9650d7c266 100644 --- a/lib/msal-browser/src/interaction_client/BaseInteractionClient.ts +++ b/lib/msal-browser/src/interaction_client/BaseInteractionClient.ts @@ -10,6 +10,7 @@ import { AccountInfo, UrlString, ServerTelemetryManager, + StubServerTelemetryManager, ServerTelemetryRequest, createClientConfigurationError, ClientConfigurationErrorCodes, @@ -108,6 +109,7 @@ export function getRedirectUri( * @param browserStorage - Browser cache manager instance for storing telemetry data * @param logger - Optional logger instance for verbose logging * @param forceRefresh - Optional flag to force refresh of telemetry data + * @param enabled - Optional flag to enable or disable server telemetry (default: true for custom_auth flows, false for standard flows) * @returns Configured ServerTelemetryManager instance */ export function initializeServerTelemetryManager( @@ -116,9 +118,18 @@ export function initializeServerTelemetryManager( correlationId: string, browserStorage: BrowserCacheManager, logger: Logger, - forceRefresh?: boolean + forceRefresh?: boolean, + enabled: boolean = true ): ServerTelemetryManager { logger.verbose("initializeServerTelemetryManager called", correlationId); + if (!enabled) { + logger.verbose( + "Server telemetry is disabled in configuration. Skipping telemetry manager initialization.", + correlationId + ); + return new StubServerTelemetryManager(); + } + const telemetryPayload: ServerTelemetryRequest = { clientId: clientId, correlationId: correlationId, diff --git a/lib/msal-browser/src/interaction_client/PlatformAuthInteractionClient.ts b/lib/msal-browser/src/interaction_client/PlatformAuthInteractionClient.ts index 7e48ed9b28..2dc8f0a075 100644 --- a/lib/msal-browser/src/interaction_client/PlatformAuthInteractionClient.ts +++ b/lib/msal-browser/src/interaction_client/PlatformAuthInteractionClient.ts @@ -177,7 +177,9 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient { this.config.auth.clientId, this.correlationId, this.browserStorage, - this.logger + this.logger, + undefined, + this.config.system.serverTelemetryEnabled ); try { @@ -369,7 +371,9 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient { this.config.auth.clientId, this.correlationId, this.browserStorage, - this.logger + this.logger, + undefined, + this.config.system.serverTelemetryEnabled ); serverTelemetryManager.setNativeBrokerErrorCode(e.errorCode); if (isFatalNativeAuthError(e)) { @@ -472,7 +476,9 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient { this.config.auth.clientId, this.correlationId, this.browserStorage, - this.logger + this.logger, + undefined, + this.config.system.serverTelemetryEnabled ); serverTelemetryManager.clearNativeBrokerErrorCode(); this.performanceClient?.addFields( diff --git a/lib/msal-browser/src/interaction_client/PopupClient.ts b/lib/msal-browser/src/interaction_client/PopupClient.ts index c31914f2f1..a97c515e06 100644 --- a/lib/msal-browser/src/interaction_client/PopupClient.ts +++ b/lib/msal-browser/src/interaction_client/PopupClient.ts @@ -298,7 +298,9 @@ export class PopupClient extends StandardInteractionClient { this.config.auth.clientId, this.correlationId, this.browserStorage, - this.logger + this.logger, + undefined, + this.config.system.serverTelemetryEnabled ); const pkce = @@ -533,7 +535,9 @@ export class PopupClient extends StandardInteractionClient { this.config.auth.clientId, correlationId, this.browserStorage, - this.logger + this.logger, + undefined, + this.config.system.serverTelemetryEnabled ), requestAuthority: request.authority, requestAzureCloudOptions: request.azureCloudOptions, @@ -699,7 +703,9 @@ export class PopupClient extends StandardInteractionClient { this.config.auth.clientId, this.correlationId, this.browserStorage, - this.logger + this.logger, + undefined, + this.config.system.serverTelemetryEnabled ); try { diff --git a/lib/msal-browser/src/interaction_client/RedirectClient.ts b/lib/msal-browser/src/interaction_client/RedirectClient.ts index b378051a05..2cbcf544d9 100644 --- a/lib/msal-browser/src/interaction_client/RedirectClient.ts +++ b/lib/msal-browser/src/interaction_client/RedirectClient.ts @@ -197,7 +197,9 @@ export class RedirectClient extends StandardInteractionClient { this.config.auth.clientId, this.correlationId, this.browserStorage, - this.logger + this.logger, + undefined, + this.config.system.serverTelemetryEnabled ); const pkceCodes = await invokeAsync( @@ -414,7 +416,9 @@ export class RedirectClient extends StandardInteractionClient { this.config.auth.clientId, this.correlationId, this.browserStorage, - this.logger + this.logger, + undefined, + this.config.system.serverTelemetryEnabled ); const navigateToLoginRequestUrl = @@ -815,7 +819,9 @@ export class RedirectClient extends StandardInteractionClient { this.config.auth.clientId, this.correlationId, this.browserStorage, - this.logger + this.logger, + undefined, + this.config.system.serverTelemetryEnabled ); try { diff --git a/lib/msal-browser/src/interaction_client/SilentAuthCodeClient.ts b/lib/msal-browser/src/interaction_client/SilentAuthCodeClient.ts index da6669213f..b8b9732800 100644 --- a/lib/msal-browser/src/interaction_client/SilentAuthCodeClient.ts +++ b/lib/msal-browser/src/interaction_client/SilentAuthCodeClient.ts @@ -104,7 +104,9 @@ export class SilentAuthCodeClient extends StandardInteractionClient { this.config.auth.clientId, this.correlationId, this.browserStorage, - this.logger + this.logger, + undefined, + this.config.system.serverTelemetryEnabled ); try { diff --git a/lib/msal-browser/src/interaction_client/SilentCacheClient.ts b/lib/msal-browser/src/interaction_client/SilentCacheClient.ts index 17caccbc94..f964c3410e 100644 --- a/lib/msal-browser/src/interaction_client/SilentCacheClient.ts +++ b/lib/msal-browser/src/interaction_client/SilentCacheClient.ts @@ -36,7 +36,9 @@ export class SilentCacheClient extends StandardInteractionClient { this.config.auth.clientId, this.correlationId, this.browserStorage, - this.logger + this.logger, + undefined, + this.config.system.serverTelemetryEnabled ); const clientConfig = await invokeAsync( diff --git a/lib/msal-browser/src/interaction_client/SilentIframeClient.ts b/lib/msal-browser/src/interaction_client/SilentIframeClient.ts index 2b6a59ca91..200ba0c8ff 100644 --- a/lib/msal-browser/src/interaction_client/SilentIframeClient.ts +++ b/lib/msal-browser/src/interaction_client/SilentIframeClient.ts @@ -171,7 +171,9 @@ export class SilentIframeClient extends StandardInteractionClient { this.config.auth.clientId, this.correlationId, this.browserStorage, - this.logger + this.logger, + undefined, + this.config.system.serverTelemetryEnabled ); try { @@ -342,7 +344,9 @@ export class SilentIframeClient extends StandardInteractionClient { this.config.auth.clientId, correlationId, this.browserStorage, - this.logger + this.logger, + undefined, + this.config.system.serverTelemetryEnabled ), requestAuthority: request.authority, requestAzureCloudOptions: request.azureCloudOptions, @@ -436,7 +440,9 @@ export class SilentIframeClient extends StandardInteractionClient { this.config.auth.clientId, this.correlationId, this.browserStorage, - this.logger + this.logger, + undefined, + this.config.system.serverTelemetryEnabled ), requestAuthority: silentRequest.authority, requestAzureCloudOptions: silentRequest.azureCloudOptions, diff --git a/lib/msal-browser/src/interaction_client/SilentRefreshClient.ts b/lib/msal-browser/src/interaction_client/SilentRefreshClient.ts index 8b733bdb65..9d1f20c49a 100644 --- a/lib/msal-browser/src/interaction_client/SilentRefreshClient.ts +++ b/lib/msal-browser/src/interaction_client/SilentRefreshClient.ts @@ -68,7 +68,9 @@ export class SilentRefreshClient extends StandardInteractionClient { this.config.auth.clientId, this.correlationId, this.browserStorage, - this.logger + this.logger, + undefined, + this.config.system.serverTelemetryEnabled ); const refreshTokenClient = await this.createRefreshTokenClient({ diff --git a/lib/msal-browser/test/app/PublicClientApplication.spec.ts b/lib/msal-browser/test/app/PublicClientApplication.spec.ts index 1434f00c2d..f7ba4c8f8f 100644 --- a/lib/msal-browser/test/app/PublicClientApplication.spec.ts +++ b/lib/msal-browser/test/app/PublicClientApplication.spec.ts @@ -5757,6 +5757,9 @@ describe("PublicClientApplication.ts Class Unit Tests", () => { }); it("throws error that SilentFlowClient.acquireToken() throws", async () => { + // Enable server telemetry so cacheFailedRequest writes to storage + //@ts-ignore + pca.config.system.serverTelemetryEnabled = true; const testError: AuthError = new AuthError( "create_login_url_error", "Error in creating a login url" @@ -5800,6 +5803,9 @@ describe("PublicClientApplication.ts Class Unit Tests", () => { }); it("throws error that SilentFlowClient.acquireToken() throws when making parallel requests", async () => { + // Enable server telemetry so cacheFailedRequest writes to storage + //@ts-ignore + pca.config.system.serverTelemetryEnabled = true; const testError: AuthError = new AuthError( "create_login_url_error", "Error in creating a login url" diff --git a/lib/msal-browser/test/config/Configuration.spec.ts b/lib/msal-browser/test/config/Configuration.spec.ts index 45d880fbbf..1a75b99a47 100644 --- a/lib/msal-browser/test/config/Configuration.spec.ts +++ b/lib/msal-browser/test/config/Configuration.spec.ts @@ -71,6 +71,25 @@ describe("Configuration.ts Class Unit Tests", () => { expect(emptyConfig.system?.allowPlatformBroker).toBe(false); }); + it("serverTelemetryEnabled defaults to false", () => { + const config = buildConfiguration( + { auth: { clientId: TEST_CONFIG.MSAL_CLIENT_ID } }, + true + ); + expect(config.system.serverTelemetryEnabled).toBe(false); + }); + + it("sets serverTelemetryEnabled to passed in true value", () => { + const config = buildConfiguration( + { + auth: { clientId: TEST_CONFIG.MSAL_CLIENT_ID }, + system: { serverTelemetryEnabled: true }, + }, + true + ); + expect(config.system.serverTelemetryEnabled).toBe(true); + }); + it("sets allowPlatformBroker to passed in true value", () => { const config: Configuration = buildConfiguration( { diff --git a/lib/msal-browser/test/interaction_client/PlatformAuthInteractionClient.spec.ts b/lib/msal-browser/test/interaction_client/PlatformAuthInteractionClient.spec.ts index 05136c9b11..d1e5c8d421 100644 --- a/lib/msal-browser/test/interaction_client/PlatformAuthInteractionClient.spec.ts +++ b/lib/msal-browser/test/interaction_client/PlatformAuthInteractionClient.spec.ts @@ -1110,6 +1110,10 @@ describe("PlatformAuthInteractionClient Tests", () => { }); it("does not set native broker error to server telemetry", async () => { + // Enable server telemetry so telemetry data is written to storage + //@ts-ignore + platformAuthInteractionClient.config.system.serverTelemetryEnabled = + true; jest.spyOn( PlatformAuthExtensionHandler.prototype, "sendMessage" @@ -1134,6 +1138,10 @@ describe("PlatformAuthInteractionClient Tests", () => { }); it("sets native broker error to server telemetry", async () => { + // Enable server telemetry so telemetry data is written to storage + //@ts-ignore + platformAuthInteractionClient.config.system.serverTelemetryEnabled = + true; jest.spyOn( PlatformAuthExtensionHandler.prototype, "sendMessage" @@ -1162,6 +1170,10 @@ describe("PlatformAuthInteractionClient Tests", () => { }); it("resets native broker error in server telemetry", async () => { + // Enable server telemetry so telemetry data is written to storage + //@ts-ignore + platformAuthInteractionClient.config.system.serverTelemetryEnabled = + true; const sendMessageStub = jest .spyOn(PlatformAuthExtensionHandler.prototype, "sendMessage") .mockImplementation(); @@ -1423,6 +1435,10 @@ describe("PlatformAuthInteractionClient Tests", () => { }); it("sets native broker error to server telemetry", (done) => { + // Enable server telemetry so telemetry data is written to storage + //@ts-ignore + platformAuthInteractionClient.config.system.serverTelemetryEnabled = + true; jest.spyOn( NavigationClient.prototype, "navigateExternal" @@ -1458,6 +1474,10 @@ describe("PlatformAuthInteractionClient Tests", () => { }); it("resets native broker error in server telemetry", async () => { + // Enable server telemetry so telemetry data is written to storage + //@ts-ignore + platformAuthInteractionClient.config.system.serverTelemetryEnabled = + true; jest.spyOn( NavigationClient.prototype, "navigateExternal" diff --git a/lib/msal-browser/test/interaction_client/PopupClient.spec.ts b/lib/msal-browser/test/interaction_client/PopupClient.spec.ts index aee10422ff..e542505d0b 100644 --- a/lib/msal-browser/test/interaction_client/PopupClient.spec.ts +++ b/lib/msal-browser/test/interaction_client/PopupClient.spec.ts @@ -867,6 +867,9 @@ describe("PopupClient", () => { }); it("catches error and cleans cache before rethrowing", async () => { + // Enable server telemetry so cacheFailedRequest writes to storage + //@ts-ignore + popupClient.config.system.serverTelemetryEnabled = true; const testError: AuthError = new AuthError( "create_login_url_error", "Error in creating a login url" @@ -1136,6 +1139,9 @@ describe("PopupClient", () => { }); it("catches error and cleans cache before rethrowing", async () => { + // Enable server telemetry so cacheFailedRequest writes to storage + //@ts-ignore + popupClient.config.system.serverTelemetryEnabled = true; const testError: AuthError = new AuthError( "create_logout_url_error", "Error in creating a logout url" diff --git a/lib/msal-browser/test/interaction_client/RedirectClient.spec.ts b/lib/msal-browser/test/interaction_client/RedirectClient.spec.ts index 7aacf13865..d149b14d54 100644 --- a/lib/msal-browser/test/interaction_client/RedirectClient.spec.ts +++ b/lib/msal-browser/test/interaction_client/RedirectClient.spec.ts @@ -2775,6 +2775,9 @@ describe("RedirectClient", () => { }); it("errors thrown are cached for telemetry and logout failure event is raised", (done) => { + // Enable server telemetry so cacheFailedRequest writes to storage + //@ts-ignore + redirectClient.config.system.serverTelemetryEnabled = true; const testError = createBrowserAuthError( BrowserAuthErrorCodes.emptyNavigateUri ); diff --git a/lib/msal-browser/test/interaction_client/SilentIframeClient.spec.ts b/lib/msal-browser/test/interaction_client/SilentIframeClient.spec.ts index aa3372ed56..46da4aaeaa 100644 --- a/lib/msal-browser/test/interaction_client/SilentIframeClient.spec.ts +++ b/lib/msal-browser/test/interaction_client/SilentIframeClient.spec.ts @@ -228,6 +228,9 @@ describe("SilentIframeClient", () => { }); it("Errors thrown during token acquisition are cached for telemetry and browserStorage is cleaned", (done) => { + // Enable server telemetry so cacheFailedRequest writes to storage + //@ts-ignore + silentIframeClient.config.system.serverTelemetryEnabled = true; jest.spyOn( AuthorizeProtocol, "getAuthCodeRequestUrl" diff --git a/lib/msal-common/apiReview/msal-common.api.md b/lib/msal-common/apiReview/msal-common.api.md index 13b4c6f04c..b78df20ca3 100644 --- a/lib/msal-common/apiReview/msal-common.api.md +++ b/lib/msal-common/apiReview/msal-common.api.md @@ -4439,6 +4439,35 @@ export class StubPerformanceClient implements IPerformanceClient { startMeasurement(measureName: string, correlationId?: string | undefined): InProgressPerformanceEvent; } +// Warning: (ae-internal-missing-underscore) The name "StubServerTelemetryManager" should be prefixed with an underscore because the declaration is marked as @internal +// +// @internal (undocumented) +export class StubServerTelemetryManager extends ServerTelemetryManager { + constructor(); + // (undocumented) + cacheFailedRequest(): void; + // (undocumented) + clearNativeBrokerErrorCode(): void; + // (undocumented) + clearTelemetryCache(): void; + // (undocumented) + generateCurrentRequestHeaderValue(): string; + // (undocumented) + generateLastRequestHeaderValue(): string; + // (undocumented) + getNativeBrokerErrorCode(): string | undefined; + // (undocumented) + getRegionDiscoveryFields(): string; + // (undocumented) + incrementCacheHits(): number; + // (undocumented) + setCacheOutcome(): void; + // (undocumented) + setNativeBrokerErrorCode(): void; + // (undocumented) + updateRegionDiscoveryMetadata(): void; +} + // Warning: (ae-missing-release-tag) "SubMeasurement" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) diff --git a/lib/msal-common/src/exports-common.ts b/lib/msal-common/src/exports-common.ts index 6f1251895f..fba2b120c3 100644 --- a/lib/msal-common/src/exports-common.ts +++ b/lib/msal-common/src/exports-common.ts @@ -168,6 +168,9 @@ export { StringDict } from "./utils/MsalTypes.js"; export { RequestStateObject, LibraryStateObject } from "./utils/StateTypes.js"; export * as ProtocolUtils from "./utils/ProtocolUtils.js"; export * from "./utils/FunctionWrappers.js"; -export { ServerTelemetryManager } from "./telemetry/server/ServerTelemetryManager.js"; +export { + ServerTelemetryManager, + StubServerTelemetryManager, +} from "./telemetry/server/ServerTelemetryManager.js"; export { ServerTelemetryRequest } from "./telemetry/server/ServerTelemetryRequest.js"; export { version } from "./packageMetadata.js"; diff --git a/lib/msal-common/src/request/RequestParameterBuilder.ts b/lib/msal-common/src/request/RequestParameterBuilder.ts index 2d0dae4289..c349308f14 100644 --- a/lib/msal-common/src/request/RequestParameterBuilder.ts +++ b/lib/msal-common/src/request/RequestParameterBuilder.ts @@ -596,14 +596,24 @@ export function addServerTelemetry( parameters: Map, serverTelemetryManager: ServerTelemetryManager ): void { - parameters.set( - AADServerParamKeys.X_CLIENT_CURR_TELEM, - serverTelemetryManager.generateCurrentRequestHeaderValue() - ); - parameters.set( - AADServerParamKeys.X_CLIENT_LAST_TELEM, - serverTelemetryManager.generateLastRequestHeaderValue() - ); + const currentTelemetryHeader = + serverTelemetryManager.generateCurrentRequestHeaderValue(); + const lastTelemetryHeader = + serverTelemetryManager.generateLastRequestHeaderValue(); + + if (currentTelemetryHeader) { + parameters.set( + AADServerParamKeys.X_CLIENT_CURR_TELEM, + currentTelemetryHeader + ); + } + + if (lastTelemetryHeader) { + parameters.set( + AADServerParamKeys.X_CLIENT_LAST_TELEM, + lastTelemetryHeader + ); + } } /** diff --git a/lib/msal-common/src/telemetry/server/ServerTelemetryManager.ts b/lib/msal-common/src/telemetry/server/ServerTelemetryManager.ts index 38254a121d..198956a4a5 100644 --- a/lib/msal-common/src/telemetry/server/ServerTelemetryManager.ts +++ b/lib/msal-common/src/telemetry/server/ServerTelemetryManager.ts @@ -167,40 +167,44 @@ export class ServerTelemetryManager { * @param error */ cacheFailedRequest(error: unknown): void { - const lastRequests = this.getLastRequests(); - if ( - lastRequests.errors.length >= - Constants.SERVER_TELEM_MAX_CACHED_ERRORS - ) { - // Remove a cached error to make room, first in first out - lastRequests.failedRequests.shift(); // apiId - lastRequests.failedRequests.shift(); // correlationId - lastRequests.errors.shift(); - } - - lastRequests.failedRequests.push(this.apiId, this.correlationId); + try { + const lastRequests = this.getLastRequests(); + if ( + lastRequests.errors.length >= + Constants.SERVER_TELEM_MAX_CACHED_ERRORS + ) { + // Remove a cached error to make room, first in first out + lastRequests.failedRequests.shift(); // apiId + lastRequests.failedRequests.shift(); // correlationId + lastRequests.errors.shift(); + } - if (error instanceof Error && !!error && error.toString()) { - if (error instanceof AuthError) { - if (error.subError) { - lastRequests.errors.push(error.subError); - } else if (error.errorCode) { - lastRequests.errors.push(error.errorCode); + lastRequests.failedRequests.push(this.apiId, this.correlationId); + + if (error instanceof Error && !!error && error.toString()) { + if (error instanceof AuthError) { + if (error.subError) { + lastRequests.errors.push(error.subError); + } else if (error.errorCode) { + lastRequests.errors.push(error.errorCode); + } else { + lastRequests.errors.push(error.toString()); + } } else { lastRequests.errors.push(error.toString()); } } else { - lastRequests.errors.push(error.toString()); + lastRequests.errors.push(Constants.SERVER_TELEM_UNKNOWN_ERROR); } - } else { - lastRequests.errors.push(Constants.SERVER_TELEM_UNKNOWN_ERROR); - } - this.cacheManager.setServerTelemetry( - this.telemetryCacheKey, - lastRequests, - this.correlationId - ); + this.cacheManager.setServerTelemetry( + this.telemetryCacheKey, + lastRequests, + this.correlationId + ); + } catch { + // Ignore telemetry cache failures to avoid masking the original auth error path. + } return; } @@ -369,3 +373,45 @@ export class ServerTelemetryManager { return makeExtraSkuString(params); } } + +/** @internal */ +export class StubServerTelemetryManager extends ServerTelemetryManager { + constructor() { + super( + { clientId: "", apiId: 0, correlationId: "", forceRefresh: false }, + {} as unknown as CacheManager + ); + } + + generateCurrentRequestHeaderValue(): string { + return ""; + } + + generateLastRequestHeaderValue(): string { + return ""; + } + + cacheFailedRequest(): void {} + + incrementCacheHits(): number { + return 0; + } + + clearTelemetryCache(): void {} + + getRegionDiscoveryFields(): string { + return ""; + } + + updateRegionDiscoveryMetadata(): void {} + + setCacheOutcome(): void {} + + setNativeBrokerErrorCode(): void {} + + getNativeBrokerErrorCode(): string | undefined { + return undefined; + } + + clearNativeBrokerErrorCode(): void {} +} diff --git a/samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserAAD.spec.ts b/samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserAAD.spec.ts index 835afdfb70..66596366af 100644 --- a/samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserAAD.spec.ts +++ b/samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserAAD.spec.ts @@ -583,13 +583,7 @@ describe("AAD-Prod Tests", () => { await BrowserCache.getTelemetryCacheEntry( aadMsalConfig.auth.clientId ); - expect(telemetryCacheEntry).toBeDefined(); - expect(telemetryCacheEntry["cacheHits"]).toEqual(1); - // Remove Telemetry Cache entry for next test - await BrowserCache.removeTokens([ - BrowserCacheUtils.getTelemetryKey(aadMsalConfig.auth.clientId), - ]); - + expect(telemetryCacheEntry).toBeNull(); // Verify browser cache contains Account, idToken, AccessToken and RefreshToken await BrowserCache.verifyTokenStore({ scopes: aadTokenRequest.scopes, @@ -621,3 +615,7 @@ describe("AAD-Prod Tests", () => { }); }); }); + + + + diff --git a/samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserAADMultiTenant.spec.ts b/samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserAADMultiTenant.spec.ts index 43603c8b75..5e45dec8f1 100644 --- a/samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserAADMultiTenant.spec.ts +++ b/samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserAADMultiTenant.spec.ts @@ -252,13 +252,7 @@ describe("AAD-Prod Tests", () => { await BrowserCache.getTelemetryCacheEntry( aadMsalConfig.auth.clientId ); - expect(telemetryCacheEntry).toBeDefined(); - expect(telemetryCacheEntry["cacheHits"]).toEqual(1); - // Remove Telemetry Cache entry for next test - await BrowserCache.removeTokens([ - BrowserCacheUtils.getTelemetryKey(aadMsalConfig.auth.clientId), - ]); - + expect(telemetryCacheEntry).toBeNull(); // Verify browser cache contains Account, idToken, AccessToken and RefreshToken await BrowserCache.verifyTokenStore({ scopes: aadTokenRequest.scopes, @@ -392,13 +386,7 @@ describe("AAD-Prod Tests", () => { await BrowserCache.getTelemetryCacheEntry( aadMsalConfig.auth.clientId ); - expect(telemetryCacheEntry).toBeDefined(); - expect(telemetryCacheEntry["cacheHits"]).toEqual(1); - // Remove Telemetry Cache entry for next test - await BrowserCache.removeTokens([ - BrowserCacheUtils.getTelemetryKey(aadMsalConfig.auth.clientId), - ]); - + expect(telemetryCacheEntry).toBeNull(); // Verify browser cache contains Account, idToken, AccessToken and RefreshToken await BrowserCache.verifyTokenStore({ scopes: aadTokenRequest.scopes, @@ -509,3 +497,7 @@ describe("AAD-Prod Tests", () => { }); }); + + + + diff --git a/samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserAADTenanted.spec.ts b/samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserAADTenanted.spec.ts index 7bd1f7fc87..65ef1c0492 100644 --- a/samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserAADTenanted.spec.ts +++ b/samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserAADTenanted.spec.ts @@ -457,13 +457,7 @@ describe("AAD-Prod Tests", () => { await BrowserCache.getTelemetryCacheEntry( aadMsalConfig.auth.clientId ); - expect(telemetryCacheEntry).toBeDefined(); - expect(telemetryCacheEntry["cacheHits"]).toEqual(1); - // Remove Telemetry Cache entry for next test - await BrowserCache.removeTokens([ - BrowserCacheUtils.getTelemetryKey(aadMsalConfig.auth.clientId), - ]); - + expect(telemetryCacheEntry).toBeNull(); // Verify browser cache contains Account, idToken, AccessToken and RefreshToken await BrowserCache.verifyTokenStore({ scopes: aadTokenRequest.scopes, @@ -496,3 +490,7 @@ describe("AAD-Prod Tests", () => { }); }); + + + + diff --git a/samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserB2C.spec.ts b/samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserB2C.spec.ts index fddaeb635d..7f8858682a 100644 --- a/samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserB2C.spec.ts +++ b/samples/msal-browser-samples/VanillaJSTestApp2.0/app/customizable-e2e-test/test/browserB2C.spec.ts @@ -254,16 +254,8 @@ describe("B2C Tests", () => { await BrowserCache.getTelemetryCacheEntry( b2cMsalConfig.auth.clientId ); - expect(telemetryCacheEntry).toBeDefined(); - expect(telemetryCacheEntry["cacheHits"]).toEqual(1); - // Remove Telemetry Cache entry for next test - await BrowserCache.removeTokens([ - BrowserCacheUtils.getTelemetryKey( - b2cMsalConfig.auth.clientId - ), - ]); - - // Verify we now have an access_token + expect(telemetryCacheEntry).toBeNull(); + // Verify we now have an access_token await BrowserCache.verifyTokenStore({ scopes: b2cTokenRequest.scopes, }); @@ -488,16 +480,8 @@ describe("B2C Tests", () => { await BrowserCache.getTelemetryCacheEntry( b2cMsalConfig.auth.clientId ); - expect(telemetryCacheEntry).toBeDefined(); - expect(telemetryCacheEntry["cacheHits"]).toEqual(1); - // Remove Telemetry Cache entry for next test - await BrowserCache.removeTokens([ - BrowserCacheUtils.getTelemetryKey( - b2cMsalConfig.auth.clientId - ), - ]); - - // Verify we now have an access_token + expect(telemetryCacheEntry).toBeNull(); + // Verify we now have an access_token await BrowserCache.verifyTokenStore({ scopes: b2cTokenRequest.scopes, }); @@ -525,3 +509,7 @@ describe("B2C Tests", () => { }); }); }); + + + + diff --git a/samples/msal-react-samples/nextjs-sample/test/profile.spec.ts b/samples/msal-react-samples/nextjs-sample/test/profile.spec.ts index 4459c61457..8ff9d41c8c 100644 --- a/samples/msal-react-samples/nextjs-sample/test/profile.spec.ts +++ b/samples/msal-react-samples/nextjs-sample/test/profile.spec.ts @@ -23,8 +23,7 @@ async function verifyTokenStore( const telemetryCacheEntry = await BrowserCache.getTelemetryCacheEntry( "0845a021-afdf-4126-abdd-099c5e6948e1" ); - expect(telemetryCacheEntry).not.toBeNull(); - expect(telemetryCacheEntry["cacheHits"]).toBeGreaterThanOrEqual(1); + expect(telemetryCacheEntry).toBeNull(); } describe("/profile", () => { @@ -158,3 +157,4 @@ describe("/profile", () => { await verifyTokenStore(BrowserCache, ["User.Read"]); }); }); + diff --git a/samples/msal-react-samples/react-router-sample/test/profile.spec.ts b/samples/msal-react-samples/react-router-sample/test/profile.spec.ts index c63b1b2c5f..052e71f9c2 100644 --- a/samples/msal-react-samples/react-router-sample/test/profile.spec.ts +++ b/samples/msal-react-samples/react-router-sample/test/profile.spec.ts @@ -23,8 +23,7 @@ async function verifyTokenStore( const telemetryCacheEntry = await BrowserCache.getTelemetryCacheEntry( "0845a021-afdf-4126-abdd-099c5e6948e1" ); - expect(telemetryCacheEntry).not.toBeNull(); - expect(telemetryCacheEntry["cacheHits"]).toBeGreaterThanOrEqual(1); + expect(telemetryCacheEntry).toBeNull(); } describe("/profile", () => { @@ -161,3 +160,4 @@ describe("/profile", () => { await verifyTokenStore(BrowserCache, ["User.Read"]); }); }); + diff --git a/samples/msal-react-samples/react-router-sample/test/profileRawContext.spec.ts b/samples/msal-react-samples/react-router-sample/test/profileRawContext.spec.ts index 24d6356e43..8d71074b5f 100644 --- a/samples/msal-react-samples/react-router-sample/test/profileRawContext.spec.ts +++ b/samples/msal-react-samples/react-router-sample/test/profileRawContext.spec.ts @@ -23,8 +23,7 @@ async function verifyTokenStore( const telemetryCacheEntry = await BrowserCache.getTelemetryCacheEntry( "0845a021-afdf-4126-abdd-099c5e6948e1" ); - expect(telemetryCacheEntry).not.toBeNull(); - expect(telemetryCacheEntry["cacheHits"]).toBeGreaterThanOrEqual(1); + expect(telemetryCacheEntry).toBeNull(); } describe("/profileRawContext", () => { @@ -99,3 +98,4 @@ describe("/profileRawContext", () => { await verifyTokenStore(BrowserCache, ["User.Read"]); }); }); + diff --git a/samples/msal-react-samples/react-router-sample/test/profileWithMsal.spec.ts b/samples/msal-react-samples/react-router-sample/test/profileWithMsal.spec.ts index 8f9cb4ad86..2df6249cd4 100644 --- a/samples/msal-react-samples/react-router-sample/test/profileWithMsal.spec.ts +++ b/samples/msal-react-samples/react-router-sample/test/profileWithMsal.spec.ts @@ -23,8 +23,7 @@ async function verifyTokenStore( const telemetryCacheEntry = await BrowserCache.getTelemetryCacheEntry( "0845a021-afdf-4126-abdd-099c5e6948e1" ); - expect(telemetryCacheEntry).not.toBeNull(); - expect(telemetryCacheEntry["cacheHits"]).toBeGreaterThanOrEqual(1); + expect(telemetryCacheEntry).toBeNull(); } describe("/profileWithMsal", () => { @@ -92,3 +91,4 @@ describe("/profileWithMsal", () => { await verifyTokenStore(BrowserCache, ["User.Read"]); }); }); + diff --git a/samples/msal-react-samples/react16-sample/test/profile.spec.ts b/samples/msal-react-samples/react16-sample/test/profile.spec.ts index c63b1b2c5f..052e71f9c2 100644 --- a/samples/msal-react-samples/react16-sample/test/profile.spec.ts +++ b/samples/msal-react-samples/react16-sample/test/profile.spec.ts @@ -23,8 +23,7 @@ async function verifyTokenStore( const telemetryCacheEntry = await BrowserCache.getTelemetryCacheEntry( "0845a021-afdf-4126-abdd-099c5e6948e1" ); - expect(telemetryCacheEntry).not.toBeNull(); - expect(telemetryCacheEntry["cacheHits"]).toBeGreaterThanOrEqual(1); + expect(telemetryCacheEntry).toBeNull(); } describe("/profile", () => { @@ -161,3 +160,4 @@ describe("/profile", () => { await verifyTokenStore(BrowserCache, ["User.Read"]); }); }); + diff --git a/samples/msal-react-samples/react16-sample/test/profileRawContext.spec.ts b/samples/msal-react-samples/react16-sample/test/profileRawContext.spec.ts index 24d6356e43..8d71074b5f 100644 --- a/samples/msal-react-samples/react16-sample/test/profileRawContext.spec.ts +++ b/samples/msal-react-samples/react16-sample/test/profileRawContext.spec.ts @@ -23,8 +23,7 @@ async function verifyTokenStore( const telemetryCacheEntry = await BrowserCache.getTelemetryCacheEntry( "0845a021-afdf-4126-abdd-099c5e6948e1" ); - expect(telemetryCacheEntry).not.toBeNull(); - expect(telemetryCacheEntry["cacheHits"]).toBeGreaterThanOrEqual(1); + expect(telemetryCacheEntry).toBeNull(); } describe("/profileRawContext", () => { @@ -99,3 +98,4 @@ describe("/profileRawContext", () => { await verifyTokenStore(BrowserCache, ["User.Read"]); }); }); + diff --git a/samples/msal-react-samples/react16-sample/test/profileWithMsal.spec.ts b/samples/msal-react-samples/react16-sample/test/profileWithMsal.spec.ts index 8f9cb4ad86..2df6249cd4 100644 --- a/samples/msal-react-samples/react16-sample/test/profileWithMsal.spec.ts +++ b/samples/msal-react-samples/react16-sample/test/profileWithMsal.spec.ts @@ -23,8 +23,7 @@ async function verifyTokenStore( const telemetryCacheEntry = await BrowserCache.getTelemetryCacheEntry( "0845a021-afdf-4126-abdd-099c5e6948e1" ); - expect(telemetryCacheEntry).not.toBeNull(); - expect(telemetryCacheEntry["cacheHits"]).toBeGreaterThanOrEqual(1); + expect(telemetryCacheEntry).toBeNull(); } describe("/profileWithMsal", () => { @@ -92,3 +91,4 @@ describe("/profileWithMsal", () => { await verifyTokenStore(BrowserCache, ["User.Read"]); }); }); + diff --git a/samples/msal-react-samples/react17-sample/test/profile.spec.ts b/samples/msal-react-samples/react17-sample/test/profile.spec.ts index c63b1b2c5f..052e71f9c2 100644 --- a/samples/msal-react-samples/react17-sample/test/profile.spec.ts +++ b/samples/msal-react-samples/react17-sample/test/profile.spec.ts @@ -23,8 +23,7 @@ async function verifyTokenStore( const telemetryCacheEntry = await BrowserCache.getTelemetryCacheEntry( "0845a021-afdf-4126-abdd-099c5e6948e1" ); - expect(telemetryCacheEntry).not.toBeNull(); - expect(telemetryCacheEntry["cacheHits"]).toBeGreaterThanOrEqual(1); + expect(telemetryCacheEntry).toBeNull(); } describe("/profile", () => { @@ -161,3 +160,4 @@ describe("/profile", () => { await verifyTokenStore(BrowserCache, ["User.Read"]); }); }); + diff --git a/samples/msal-react-samples/react17-sample/test/profileRawContext.spec.ts b/samples/msal-react-samples/react17-sample/test/profileRawContext.spec.ts index 24d6356e43..8d71074b5f 100644 --- a/samples/msal-react-samples/react17-sample/test/profileRawContext.spec.ts +++ b/samples/msal-react-samples/react17-sample/test/profileRawContext.spec.ts @@ -23,8 +23,7 @@ async function verifyTokenStore( const telemetryCacheEntry = await BrowserCache.getTelemetryCacheEntry( "0845a021-afdf-4126-abdd-099c5e6948e1" ); - expect(telemetryCacheEntry).not.toBeNull(); - expect(telemetryCacheEntry["cacheHits"]).toBeGreaterThanOrEqual(1); + expect(telemetryCacheEntry).toBeNull(); } describe("/profileRawContext", () => { @@ -99,3 +98,4 @@ describe("/profileRawContext", () => { await verifyTokenStore(BrowserCache, ["User.Read"]); }); }); + diff --git a/samples/msal-react-samples/react17-sample/test/profileWithMsal.spec.ts b/samples/msal-react-samples/react17-sample/test/profileWithMsal.spec.ts index 8f9cb4ad86..2df6249cd4 100644 --- a/samples/msal-react-samples/react17-sample/test/profileWithMsal.spec.ts +++ b/samples/msal-react-samples/react17-sample/test/profileWithMsal.spec.ts @@ -23,8 +23,7 @@ async function verifyTokenStore( const telemetryCacheEntry = await BrowserCache.getTelemetryCacheEntry( "0845a021-afdf-4126-abdd-099c5e6948e1" ); - expect(telemetryCacheEntry).not.toBeNull(); - expect(telemetryCacheEntry["cacheHits"]).toBeGreaterThanOrEqual(1); + expect(telemetryCacheEntry).toBeNull(); } describe("/profileWithMsal", () => { @@ -92,3 +91,4 @@ describe("/profileWithMsal", () => { await verifyTokenStore(BrowserCache, ["User.Read"]); }); }); + diff --git a/samples/msal-react-samples/react18-sample/test/profile.spec.ts b/samples/msal-react-samples/react18-sample/test/profile.spec.ts index c63b1b2c5f..052e71f9c2 100644 --- a/samples/msal-react-samples/react18-sample/test/profile.spec.ts +++ b/samples/msal-react-samples/react18-sample/test/profile.spec.ts @@ -23,8 +23,7 @@ async function verifyTokenStore( const telemetryCacheEntry = await BrowserCache.getTelemetryCacheEntry( "0845a021-afdf-4126-abdd-099c5e6948e1" ); - expect(telemetryCacheEntry).not.toBeNull(); - expect(telemetryCacheEntry["cacheHits"]).toBeGreaterThanOrEqual(1); + expect(telemetryCacheEntry).toBeNull(); } describe("/profile", () => { @@ -161,3 +160,4 @@ describe("/profile", () => { await verifyTokenStore(BrowserCache, ["User.Read"]); }); }); + diff --git a/samples/msal-react-samples/react18-sample/test/profileRawContext.spec.ts b/samples/msal-react-samples/react18-sample/test/profileRawContext.spec.ts index 24d6356e43..8d71074b5f 100644 --- a/samples/msal-react-samples/react18-sample/test/profileRawContext.spec.ts +++ b/samples/msal-react-samples/react18-sample/test/profileRawContext.spec.ts @@ -23,8 +23,7 @@ async function verifyTokenStore( const telemetryCacheEntry = await BrowserCache.getTelemetryCacheEntry( "0845a021-afdf-4126-abdd-099c5e6948e1" ); - expect(telemetryCacheEntry).not.toBeNull(); - expect(telemetryCacheEntry["cacheHits"]).toBeGreaterThanOrEqual(1); + expect(telemetryCacheEntry).toBeNull(); } describe("/profileRawContext", () => { @@ -99,3 +98,4 @@ describe("/profileRawContext", () => { await verifyTokenStore(BrowserCache, ["User.Read"]); }); }); + diff --git a/samples/msal-react-samples/react18-sample/test/profileWithMsal.spec.ts b/samples/msal-react-samples/react18-sample/test/profileWithMsal.spec.ts index 8f9cb4ad86..2df6249cd4 100644 --- a/samples/msal-react-samples/react18-sample/test/profileWithMsal.spec.ts +++ b/samples/msal-react-samples/react18-sample/test/profileWithMsal.spec.ts @@ -23,8 +23,7 @@ async function verifyTokenStore( const telemetryCacheEntry = await BrowserCache.getTelemetryCacheEntry( "0845a021-afdf-4126-abdd-099c5e6948e1" ); - expect(telemetryCacheEntry).not.toBeNull(); - expect(telemetryCacheEntry["cacheHits"]).toBeGreaterThanOrEqual(1); + expect(telemetryCacheEntry).toBeNull(); } describe("/profileWithMsal", () => { @@ -92,3 +91,4 @@ describe("/profileWithMsal", () => { await verifyTokenStore(BrowserCache, ["User.Read"]); }); }); + diff --git a/samples/msal-react-samples/typescript-sample/test/profile.spec.ts b/samples/msal-react-samples/typescript-sample/test/profile.spec.ts index 3d031514cc..7ad9eda6d3 100644 --- a/samples/msal-react-samples/typescript-sample/test/profile.spec.ts +++ b/samples/msal-react-samples/typescript-sample/test/profile.spec.ts @@ -33,8 +33,7 @@ async function verifyTokenStore( const telemetryCacheEntry = await BrowserCache.getTelemetryCacheEntry( "0845a021-afdf-4126-abdd-099c5e6948e1" ); - expect(telemetryCacheEntry).not.toBeNull(); - expect(telemetryCacheEntry!.cacheHits).toBeGreaterThanOrEqual(1); + expect(telemetryCacheEntry).toBeNull(); } describe("/profile", () => {