From dc3a7481b134833833167863ec98cab79607ff0f Mon Sep 17 00:00:00 2001 From: sameerag Date: Wed, 23 Sep 2026 15:11:03 -0700 Subject: [PATCH 1/4] Add NAA bridge type telemetry Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0587e9e4-12b2-49aa-867a-24103c92dcb1 --- .../@azure-msal-browser-naa-bridge-type.json | 7 +++ .../@azure-msal-common-naa-bridge-type.json | 7 +++ .../controllers/NestedAppAuthController.ts | 7 ++- .../NestedAppAuthController.spec.ts | 45 +++++++++++++++++++ lib/msal-common/apiReview/msal-common.api.md | 1 + .../telemetry/performance/PerformanceEvent.ts | 1 + 6 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 change/@azure-msal-browser-naa-bridge-type.json create mode 100644 change/@azure-msal-common-naa-bridge-type.json diff --git a/change/@azure-msal-browser-naa-bridge-type.json b/change/@azure-msal-browser-naa-bridge-type.json new file mode 100644 index 0000000000..0587c097a4 --- /dev/null +++ b/change/@azure-msal-browser-naa-bridge-type.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "Identify Nested App Auth performance events with the NAA bridge type [#0](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/0)", + "packageName": "@azure/msal-browser", + "email": "Sameera.Gajjarapu@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@azure-msal-common-naa-bridge-type.json b/change/@azure-msal-common-naa-bridge-type.json new file mode 100644 index 0000000000..bc71fcbd67 --- /dev/null +++ b/change/@azure-msal-common-naa-bridge-type.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "Add a bridge type field to performance telemetry [#0](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/0)", + "packageName": "@azure/msal-common", + "email": "Sameera.Gajjarapu@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/lib/msal-browser/src/controllers/NestedAppAuthController.ts b/lib/msal-browser/src/controllers/NestedAppAuthController.ts index c06b5b34f9..61a22e3eb2 100644 --- a/lib/msal-browser/src/controllers/NestedAppAuthController.ts +++ b/lib/msal-browser/src/controllers/NestedAppAuthController.ts @@ -222,7 +222,10 @@ export class NestedAppAuthController implements IController { correlationId ); - atPopupMeasurement.add({ nestedAppAuthRequest: true }); + atPopupMeasurement.add({ + nestedAppAuthRequest: true, + bridgeType: "NAA", + }); try { enforceResourceParameter(this.config.auth.isMcp, validRequest); @@ -345,6 +348,7 @@ export class NestedAppAuthController implements IController { }); ssoSilentMeasurement.add({ nestedAppAuthRequest: true, + bridgeType: "NAA", }); try { @@ -438,6 +442,7 @@ export class NestedAppAuthController implements IController { atsMeasurement?.add({ nestedAppAuthRequest: true, + bridgeType: "NAA", }); // if the request has claims, we cannot look up in the cache diff --git a/lib/msal-browser/test/controllers/NestedAppAuthController.spec.ts b/lib/msal-browser/test/controllers/NestedAppAuthController.spec.ts index be3c985b2f..947348888c 100644 --- a/lib/msal-browser/test/controllers/NestedAppAuthController.spec.ts +++ b/lib/msal-browser/test/controllers/NestedAppAuthController.spec.ts @@ -1001,6 +1001,11 @@ describe("NestedAppAuthController.ts Class Unit Tests", () => { const result = await localPca.acquireTokenPopup(testRequest); + expect(mockMeasurement.add).toHaveBeenCalledWith({ + nestedAppAuthRequest: true, + bridgeType: "NAA", + }); + // Verify measurement.end was called with account parameter expect(mockMeasurement.end).toHaveBeenCalledWith( expect.objectContaining({ success: true }), @@ -1072,6 +1077,11 @@ describe("NestedAppAuthController.ts Class Unit Tests", () => { const result = await localPca.acquireTokenSilent(silentRequest); + expect(mockMeasurement.add).toHaveBeenCalledWith({ + nestedAppAuthRequest: true, + bridgeType: "NAA", + }); + // Verify measurement.end was called with account parameter expect(mockMeasurement.end).toHaveBeenCalledWith( expect.objectContaining({ success: true }), @@ -1089,6 +1099,41 @@ describe("NestedAppAuthController.ts Class Unit Tests", () => { expect(result.account).toBeDefined(); }); + it("should add the NAA bridge type to silent cache measurements", async () => { + const mockMeasurement = { + end: jest.fn().mockReturnValue({}), + discard: jest.fn(), + add: jest.fn(), + increment: jest.fn(), + event: { + eventId: "test-event-id", + status: "InProgress" as any, + authority: TEST_CONFIG.validAuthority, + clientId: TEST_CONFIG.MSAL_CLIENT_ID, + correlationId: RANDOM_TEST_GUID, + name: "test-event", + startTimeMs: Date.now(), + libraryName: "msal-browser", + libraryVersion: "test-version", + }, + measurement: {}, + }; + + jest.spyOn(performanceClient, "startMeasurement").mockReturnValue( + mockMeasurement as any + ); + + await (localPca as any).controller.acquireTokenFromCache({ + scopes: ["user.read"], + forceRefresh: true, + }); + + expect(mockMeasurement.add).toHaveBeenCalledWith({ + nestedAppAuthRequest: true, + bridgeType: "NAA", + }); + }); + it("should not pass account when account is not provided in request", async () => { const silentRequest = { scopes: ["user.read"], diff --git a/lib/msal-common/apiReview/msal-common.api.md b/lib/msal-common/apiReview/msal-common.api.md index 1cbaee5940..a4153ebde2 100644 --- a/lib/msal-common/apiReview/msal-common.api.md +++ b/lib/msal-common/apiReview/msal-common.api.md @@ -2485,6 +2485,7 @@ export type PerformanceEvent = { extensionHandshakeTimeoutMs?: number; extensionHandshakeTimedOut?: boolean; nestedAppAuthRequest?: boolean; + bridgeType?: "NAA" | "PWB"; multiMatchedAT?: number; multiMatchedID?: number; multiMatchedRT?: number; diff --git a/lib/msal-common/src/telemetry/performance/PerformanceEvent.ts b/lib/msal-common/src/telemetry/performance/PerformanceEvent.ts index 7c45de28fa..409e00b630 100644 --- a/lib/msal-common/src/telemetry/performance/PerformanceEvent.ts +++ b/lib/msal-common/src/telemetry/performance/PerformanceEvent.ts @@ -323,6 +323,7 @@ export type PerformanceEvent = { * Nested App Auth Fields */ nestedAppAuthRequest?: boolean; + bridgeType?: "NAA" | "PWB"; /** * Multiple matched access/id/refresh tokens in the cache From 8e73d34e464883a4f82632c0463b319327e5ea56 Mon Sep 17 00:00:00 2001 From: sameerag Date: Wed, 23 Sep 2026 15:11:40 -0700 Subject: [PATCH 2/4] Link telemetry changefiles to PR Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0587e9e4-12b2-49aa-867a-24103c92dcb1 --- change/@azure-msal-browser-naa-bridge-type.json | 2 +- change/@azure-msal-common-naa-bridge-type.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/change/@azure-msal-browser-naa-bridge-type.json b/change/@azure-msal-browser-naa-bridge-type.json index 0587c097a4..e5f1edff43 100644 --- a/change/@azure-msal-browser-naa-bridge-type.json +++ b/change/@azure-msal-browser-naa-bridge-type.json @@ -1,6 +1,6 @@ { "type": "patch", - "comment": "Identify Nested App Auth performance events with the NAA bridge type [#0](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/0)", + "comment": "Identify Nested App Auth performance events with the NAA bridge type [#8864](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/8864)", "packageName": "@azure/msal-browser", "email": "Sameera.Gajjarapu@microsoft.com", "dependentChangeType": "patch" diff --git a/change/@azure-msal-common-naa-bridge-type.json b/change/@azure-msal-common-naa-bridge-type.json index bc71fcbd67..ca7f63765b 100644 --- a/change/@azure-msal-common-naa-bridge-type.json +++ b/change/@azure-msal-common-naa-bridge-type.json @@ -1,6 +1,6 @@ { "type": "patch", - "comment": "Add a bridge type field to performance telemetry [#0](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/0)", + "comment": "Add a bridge type field to performance telemetry [#8864](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/8864)", "packageName": "@azure/msal-common", "email": "Sameera.Gajjarapu@microsoft.com", "dependentChangeType": "patch" From 06a1b117becb0c334e723799fed9542df5728c6e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 23 Sep 2026 22:55:59 +0000 Subject: [PATCH 3/4] Document performance bridge type Co-authored-by: sameerag <21958742+sameerag@users.noreply.github.com> --- lib/msal-browser/docs/performance.md | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/msal-browser/docs/performance.md b/lib/msal-browser/docs/performance.md index bc324bf882..9832d31228 100644 --- a/lib/msal-browser/docs/performance.md +++ b/lib/msal-browser/docs/performance.md @@ -90,6 +90,7 @@ The complete details for `PerformanceEvents` objects can be found [here](../../m | `correlationId` | `string` | Correlation ID used for the operation (preferably unique per request). | | `libraryVersion` | `string` | Version of MSAL.js used for the operation. | | `authority` | `string` | Authority used for the operation. | +| `bridgeType` | `"NAA" \| "PWB"` | Bridge type used for the operation. | | `DurationMs` | `number` | Duration in milliseconds for an internal operation. | ### removePerformanceCallback From 6a4b07550dcf7787cba5ab6d5273f08aa0538634 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 14 Oct 2026 17:48:56 +0000 Subject: [PATCH 4/4] Restore performance documentation sections Co-authored-by: sameerag <21958742+sameerag@users.noreply.github.com> --- lib/msal-browser/docs/performance.md | 54 +++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/lib/msal-browser/docs/performance.md b/lib/msal-browser/docs/performance.md index 3703d5d3b4..2e8eee0d62 100644 --- a/lib/msal-browser/docs/performance.md +++ b/lib/msal-browser/docs/performance.md @@ -84,14 +84,52 @@ The complete details for `PerformanceEvents` objects can be found [here](../../m | **Property** | Type | Description | | ---------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------- | | `name` | `string` | Name of the operation, usually matches the top-level API name (e.g. `acquireTokenSilent`, `acquireTokenByCode`, `ssoSilent`). | -| `durationMs` | `number` | End-to-end duration in milliseconds for the operation. | -| `success` | `boolean` | Whether the operation was successful or not. | -| `fromCache` | `boolean` | Whether the operation retrieved the result from the cache. | -| `correlationId` | `string` | Correlation ID used for the operation (preferably unique per request). | -| `libraryVersion` | `string` | Version of MSAL.js used for the operation. | -| `authority` | `string` | Authority used for the operation. | -| `bridgeType` | `"NAA" \| "PWB"` | Bridge type used for the operation. | -| `DurationMs` | `number` | Duration in milliseconds for an internal operation. | +| `durationMs` | `number` | End-to-end duration in milliseconds for the operation. | +| `success` | `boolean` | Whether the operation was successful or not. | +| `fromCache` | `boolean` | Whether the operation retrieved the result from the cache. | +| `correlationId` | `string` | Correlation ID used for the operation (preferably unique per request). | +| `libraryVersion` | `string` | Version of MSAL.js used for the operation. | +| `authority` | `string` | Authority used for the operation. | +| `bridgeType` | `"NAA" \| "PWB"` | Bridge type used for the operation. | +| `DurationMs` | `number` | Duration in milliseconds for an internal operation. | + +### Platform broker measurements + +When platform brokering is enabled, MSAL measures provider discovery and provider creation during initialization, and extension or DOM transport, response validation, request initialization, response processing, and cache updates during authentication. These child measurements are folded into their enclosing top-level event as `DurationMs` fields under the same `correlationId`; they are not emitted as separate callback events. During initialization, extension handshake duration is available as `ext.nativeMessageHandlerHandshakeDurationMs` and extension provider creation duration is available as `ext.platformAuthExtensionCreateProviderDurationMs`. + +The root event includes the following platform broker context: + +| **Property** | Type | Description | +| ------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `allowPlatformBroker` | `boolean` | Whether the application enabled platform broker support. | +| `platformAuthProviderAvailable` | `boolean` | Whether MSAL created a platform authentication provider. | +| `platformAuthProviderType` | `string` | `PlatformAuthDOMHandler` or `PlatformAuthExtensionHandler` when a provider is available. This property is omitted when `platformAuthProviderAvailable` is false. | +| `extensionInstalled` | `boolean` | Whether an extension handshake response identified a compatible Microsoft Single Sign On extension. Omitted when no extension responds. | +| `extensionHandshakeTimedOut` | `boolean` | Whether extension discovery failed because no extension responded before the handshake timeout. | +| `extensionHandshakeTimeoutMs` | `number` | Configured extension handshake timeout in milliseconds. | + +Platform broker telemetry does not include tokens, claims, account identifiers, request or response payloads, URLs, or exception messages. + +#### Diagnosing platform broker flows + +Use the following fields as query or dashboard dimensions: + +| **Question** | **Filter or grouping** | +| --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Did the application enable brokering? | Filter on `allowPlatformBroker === true`. | +| Was a provider created? | Filter on `platformAuthProviderAvailable`; group available providers by `platformAuthProviderType`. | +| Did extension discovery succeed? | Filter on `extensionInstalled`; use `extensionHandshakeTimedOut` to distinguish a timeout from a response that did not identify a compatible extension. | +| Did the broker return an error? | Filter on `brokerErrorName` and `brokerErrorCode`; `user_cancelled` identifies user cancellation. | +| Which platform broker stage was slow? | Inspect the `DurationMs` fields in `ext`, including `nativeMessageHandlerHandshakeDurationMs` and provider, transport, validation, and cache durations. | +| Did a web flow run after broker failure? | When `platformAuthProviderAvailable` is false or broker error fields are present, inspect the enclosing top-level event's outcome to determine whether fallback succeeded. | + +To troubleshoot an individual request: + +1. Find the top-level performance event by `correlationId`. +2. Confirm `allowPlatformBroker`, then check `platformAuthProviderAvailable` and the conditional `platformAuthProviderType`. +3. For the extension flow, inspect `extensionInstalled`, `extensionHandshakeTimedOut`, and `extensionHandshakeTimeoutMs`. +4. Compare the nested duration fields in `ext` to identify the lifecycle stage where time was spent. +5. Inspect `brokerErrorName` and `brokerErrorCode`, then use the top-level event's outcome to distinguish a terminal broker failure from a successful web fallback. ### removePerformanceCallback