Skip to content

Instrument cache location #7868

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

Open
wants to merge 15 commits into
base: dev
Choose a base branch
from
Open

Conversation

konstantin-msft
Copy link
Collaborator

  • Instrument cache location

@Copilot Copilot AI review requested due to automatic review settings June 26, 2025 20:42
@github-actions github-actions bot added documentation Related to documentation. msal-browser Related to msal-browser package msal-common Related to msal-common package labels Jun 26, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds instrumentation of the cache location into performance events and updates tests to supply and verify this new field.

  • Introduces a new cacheLocation property on PerformanceEvent and updates the API doc.
  • Populates cacheLocation in BaseInteractionClient during initialization.
  • Updates existing tests and adds new ones in PublicClientApplication.spec.ts to set and assert on cacheLocation.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/msal-common/src/telemetry/performance/PerformanceEvent.ts Added optional cacheLocation field to performance events
lib/msal-common/apiReview/msal-common.api.md Updated API review to include cacheLocation
lib/msal-browser/src/interaction_client/BaseInteractionClient.ts Instrumented cacheLocation in performance client setup
lib/msal-browser/test/custom_auth//SignClient.spec.ts Imported cache enums, default perf client, and set cache config
lib/msal-browser/test/app/PublicClientApplication.spec.ts Added assertions/tests for cacheLocation instrumentation
Comments suppressed due to low confidence (3)

lib/msal-common/src/telemetry/performance/PerformanceEvent.ts:902

  • The cacheLocation property is typed as a generic string, which allows invalid values. Consider using the BrowserCacheLocation enum or a union type of allowed values (e.g., 'localStorage' | 'sessionStorage') for stronger type safety.
    cacheLocation?: string;

lib/msal-browser/src/interaction_client/BaseInteractionClient.ts:85

  • Accessing config.cache.cacheLocation directly can throw if cache or cacheLocation is undefined. Consider adding a null-check or default value, e.g., config.cache?.cacheLocation or providing a fallback.
    }

lib/msal-browser/test/app/PublicClientApplication.spec.ts:930

  • BrowserCacheLocation is used here but not imported at the top of the file, which will cause a compilation error. Please add import { BrowserCacheLocation } from '../../../../src/utils/BrowserConstants.js';.
                    cacheLocation: BrowserCacheLocation.LocalStorage,

tnorling
tnorling previously approved these changes Jun 26, 2025
sameerag
sameerag previously approved these changes Jun 26, 2025
@konstantin-msft konstantin-msft dismissed stale reviews from sameerag and tnorling via 4cad1ef July 2, 2025 17:43
@konstantin-msft konstantin-msft force-pushed the instrument_cache_location branch from c0eb420 to 4cad1ef Compare July 2, 2025 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Related to documentation. msal-browser Related to msal-browser package msal-common Related to msal-common package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants