Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions change/@azure-msal-browser-naa-bridge-type.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"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"
}
7 changes: 7 additions & 0 deletions change/@azure-msal-common-naa-bridge-type.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -345,6 +348,7 @@ export class NestedAppAuthController implements IController {
});
ssoSilentMeasurement.add({
nestedAppAuthRequest: true,
bridgeType: "NAA",
});

try {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
Expand Down Expand Up @@ -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 }),
Expand All @@ -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"],
Expand Down
1 change: 1 addition & 0 deletions lib/msal-common/apiReview/msal-common.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2485,6 +2485,7 @@ export type PerformanceEvent = {
extensionHandshakeTimeoutMs?: number;
extensionHandshakeTimedOut?: boolean;
nestedAppAuthRequest?: boolean;
bridgeType?: "NAA" | "PWB";
multiMatchedAT?: number;
multiMatchedID?: number;
multiMatchedRT?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ export type PerformanceEvent = {
* Nested App Auth Fields
*/
nestedAppAuthRequest?: boolean;
bridgeType?: "NAA" | "PWB";
Comment thread
sameerag marked this conversation as resolved.
Resolved

/**
* Multiple matched access/id/refresh tokens in the cache
Expand Down
Loading