Skip to content

Commit 99ce6b4

Browse files
authored
Merge branch 'dev' into remove-debug-msal-common
2 parents 33fce80 + b61e875 commit 99ce6b4

File tree

57 files changed

+22915
-6664
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+22915
-6664
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 performance telemetry API #4570",
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 performance telemetry API #4570",
4+
"packageName": "@azure/msal-common",
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": "patch",
3+
"comment": "Use IGuidGenerator interface for GuidGenerator class #4570",
4+
"packageName": "@azure/msal-node",
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": "patch",
3+
"comment": "Use React 17 for dev deps #4570",
4+
"packageName": "@azure/msal-react",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

lib/msal-browser/docs/performance.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,82 @@ const msalInstance = new msal.PublicClientApplication({
5050
}
5151
});
5252
```
53+
54+
## Measuring performance
55+
56+
Applications that want to measure the performance of authentication flows in MSAL.js can do so manually, or consume the performance measures taken by the library itself.
57+
58+
### addPerformanceCallback
59+
60+
Since version `@azure/[email protected]`, applications can register a callback to receive performance measurements taken by the library. These measurement will include end-to-end measurements for top-level APIs, as well as measurements for important internal APIs.
61+
62+
**Note for MSFT first-party applications**: We will be publishing an internal build of `@azure/msal-browser` that is already instrumented to capture this telemetry. Contact us for more details.
63+
64+
#### Example
65+
66+
```typescript
67+
const msalInstance = new PublicClientApplication(config);
68+
69+
msalInstance.addPerformanceCallback((events: PerformanceEvent[]) => {
70+
events.forEach(event => {
71+
console.log(event);
72+
});
73+
});
74+
```
75+
76+
Example event:
77+
78+
```typescript
79+
const event: PerformanceEvent = {
80+
correlationId: "03cad3ff-6682-4e3d-a0b4-d517b531c718",
81+
durationMs: 1873,
82+
endPageVisibility: "hidden",
83+
fromCache: false,
84+
name: "acquireTokenSilent",
85+
startPageVisibility: "visible",
86+
startTimeMs: 1636414041888,
87+
success: true,
88+
silentCacheClientAcquireTokenDurationMs: 0,
89+
silentRefreshClientAcquireTokenDurationMs: 150,
90+
silentIframeClientAcquireTokenDurationMs: 0
91+
cryptoOptsGetPublicKeyThumbprintDurationMs: 200,
92+
cryptoOptsSignJwtDurationMs: 8,
93+
clientId: "b50703d7-d12b-4ddc-8758-91053fe0aba4",
94+
authority: "https://login.microsoftonline.com/common",
95+
libraryName: "@azure/msal-browser-1p",
96+
libraryVersion: "2.22.2-beta.2",
97+
appName: "my-application",
98+
appVersion: "1.0.0"
99+
}
100+
```
101+
102+
The complete details for `PerformanceEvents` objects can be found [here](../../msal-common/src/telemetry/performance/PerformanceEvent.ts). Below is a list of some notable properties:
103+
104+
| **Property** | Type | Description |
105+
| ---------------------------------- | --------- | ---------------------------------------------------------------------- |
106+
| `name` | `string` | Name of the operation, usually matches the top-level API name (e.g. `acquireTokenSilent`, `acquireTokenByCode`, `ssoSilent`). |
107+
| `durationMs` | `number` | End-to-end duration in milliseconds for the operation. |
108+
| `success` | `boolean` | Whether the operation was successful or not. |
109+
| `fromCache` | `boolean` | Whether the operation retrieved the result from the cache. |
110+
| `correlationId` | `string` | Correlation ID used for the operation (preferably unique per request). |
111+
| `libraryVersion` | `string` | Version of MSAL.js used for the operation. |
112+
| `authority` | `string` | Authority used for the operation. |
113+
| `<internalFunctionName>DurationMs` | `number` | Duration in milliseconds for an internal operation. |
114+
115+
### removePerformanceCallback
116+
117+
The `addPerformanceCallback` API will return a callback id, which an application can pass to `PublicClientApplication.removePerformanceCallback` to unregister that callback from receiving performance events. It will return a boolean indicating whether or not the callback was successfully removed.
118+
119+
#### Example
120+
121+
```typescript
122+
const msalInstance = new PublicClientApplication(config);
123+
124+
const callbackId: string = msalInstance.addPerformanceCallback((events: PerformanceEvent[]) => {
125+
events.forEach(event => {
126+
console.log(event);
127+
});
128+
});
129+
130+
const removed: boolean = msalInstance.removePerformanceCallback(callbackId);
131+
```

0 commit comments

Comments
 (0)