-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Instrument correlation between silent and interactive requests #7146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Instrument correlation between silent and interactive requests #7146
Conversation
konstantin-msft
commented
Jun 5, 2024
- Instrument correlation between silent and interactive requests
// Warning: (tsdoc-undefined-tag) The TSDoc tag "@return" is not defined in this configuration | ||
generateRequestThumbprint(request: SilentRequest | SsoSilentRequest | PopupRequest | RedirectRequest): string; | ||
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen | ||
// Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Are these duplicated?
47299f2
to
2671e45
Compare
* Serializes thumbprint map entries when redirect begins * Rehydrates thumbprint map when returning from redirect * Adds embeddedClientId to perf thumbprint when available
* @return string | ||
*/ | ||
getThumbprintMapSerialized(): string { | ||
const toArray = (map : any) : any => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can probably simplify this with const stringifiedThumbprints = JSON.stringify(Array.from(this.thumbprints.entries()))
@@ -93,6 +93,7 @@ export const TemporaryCacheKeys = { | |||
CORRELATION_ID: "request.correlationId", | |||
NATIVE_REQUEST: "request.native", | |||
REDIRECT_CONTEXT: "request.redirect.context", | |||
THUMBPRINTS: "thumbprints", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THUMBPRINTS: "thumbprints", -> THUMBPRINTS: "request.telemetry.thumbprints",
PerformanceEvents.AcquireTokenRedirect, | ||
PerformanceEvents.AcquireTokenPopup, | ||
] | ||
PerformanceEvents.AcquireTokenSilent.toString(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use event.name in Object.values([PerformanceEvents.AcquireTokenSilent, ...])
to avoid converting each entry to string
] | ||
PerformanceEvents.AcquireTokenSilent.toString(), | ||
PerformanceEvents.SsoSilent.toString(), | ||
].includes(event.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
] | ||
PerformanceEvents.AcquireTokenSilent.toString(), | ||
PerformanceEvents.SsoSilent.toString(), | ||
].includes(event.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -500,6 +511,13 @@ export class RedirectClient extends StandardInteractionClient { | |||
); | |||
} | |||
|
|||
// Not sure if this is the right place for this logic to live | |||
// Read thumbprints from temporary cache if PerformanceClient is not 3P |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read thumbprints from temporary cache if PerformanceClient is not 3P
-> Read thumbprints from temporary cache if PerformanceClient is instance of BrowserPerformanceClient
. Please remove this comment as code below is pretty clear
@@ -114,6 +115,16 @@ export class RedirectClient extends StandardInteractionClient { | |||
validRequest.loginHint || "", | |||
validRequest.account || null | |||
); | |||
|
|||
// Cache thumbprints for telemetry linking if PerformanceClient is not 3P |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read thumbprints from temporary cache if PerformanceClient is not 3P
-> Read thumbprints from temporary cache if PerformanceClient is instance of BrowserPerformanceClient
. Please remove this comment as code below is pretty clear
@@ -1337,6 +1345,15 @@ export class BrowserCacheManager extends CacheManager { | |||
return parsedRequest; | |||
} | |||
|
|||
getCachedThumbprints(): string { | |||
const cachedThumbprintsSerialized = this.getTemporaryCache( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be simplified with
return this.getTemporaryCache(...) || ""