diff --git a/change/@azure-msal-browser-4528d6eb-771f-4813-aa74-7303829ecc70.json b/change/@azure-msal-browser-4528d6eb-771f-4813-aa74-7303829ecc70.json index 809d6b26da..9123eb778b 100644 --- a/change/@azure-msal-browser-4528d6eb-771f-4813-aa74-7303829ecc70.json +++ b/change/@azure-msal-browser-4528d6eb-771f-4813-aa74-7303829ecc70.json @@ -1,6 +1,6 @@ { "type": "patch", - "comment": "Allow overriding log level and PII setting with local storage key-values #6704", + "comment": "Allow overriding log level and PII setting with session storage key-values #6704", "packageName": "@azure/msal-browser", "email": "kshabelko@microsoft.com", "dependentChangeType": "patch" diff --git a/lib/msal-browser/docs/logging.md b/lib/msal-browser/docs/logging.md index b46e707a99..5dae39f1c3 100644 --- a/lib/msal-browser/docs/logging.md +++ b/lib/msal-browser/docs/logging.md @@ -63,22 +63,20 @@ An example usage in a sample can be accessed [here](https://github.com/AzureAD/m These are the steps to override MSAL log level and PII settings to troubleshoot errors in non-dev environments: -### Navigate to local storage +### Navigate to session storage 1. Open developer tools by pressing F12 2. Navigate to `Application` tab -3. Click `Storage` and expand `Local Storage` +3. Click `Storage` and expand `Session Storage` 4. Select target domain -Additional details can be found [here](https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/storage/localstorage). +Additional details can be found [here](https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/storage/sessionstorage). ### Override log level -Add `msal.browser.log.level` key to `Local Storage`, set it's value to the desired log level (`Verbose`, for example) and refresh the page. +Add `msal.browser.log.level` key to `Session Storage`, set it's value to the desired log level (`Verbose`, for example) and refresh the page. Check `LogLevel` enum for the available options [here](../../msal-common/src/logger/Logger.ts). ### Override PII log setting -Add `msal.browser.log.pii` key to `Local Storage`, set it's value to `true` or `false` and refresh the page. - -**_NOTE:_** Make sure to remove the log keys from `Local Storage` once troubleshooting is done. +Add `msal.browser.log.pii` key to `Session Storage`, set it's value to `true` or `false` and refresh the page. diff --git a/lib/msal-browser/src/operatingcontext/BaseOperatingContext.ts b/lib/msal-browser/src/operatingcontext/BaseOperatingContext.ts index ed883a8dee..39ce4beb64 100644 --- a/lib/msal-browser/src/operatingcontext/BaseOperatingContext.ts +++ b/lib/msal-browser/src/operatingcontext/BaseOperatingContext.ts @@ -66,15 +66,16 @@ export abstract class BaseOperatingContext { this.browserEnvironment = typeof window !== "undefined"; this.config = buildConfiguration(config, this.browserEnvironment); - let localStorage: Storage | undefined; + let sessionStorage: Storage | undefined; try { - localStorage = window[BrowserCacheLocation.LocalStorage]; + sessionStorage = window[BrowserCacheLocation.SessionStorage]; // Mute errors if it's a non-browser environment or cookies are blocked. } catch (e) {} - const logLevelKey = localStorage?.getItem(LOG_LEVEL_CACHE_KEY); + const logLevelKey = sessionStorage?.getItem(LOG_LEVEL_CACHE_KEY); const piiLoggingEnabled = - localStorage?.getItem(LOG_PII_CACHE_KEY)?.toLowerCase() === "true"; + sessionStorage?.getItem(LOG_PII_CACHE_KEY)?.toLowerCase() === + "true"; if (logLevelKey || piiLoggingEnabled) { const logLevel =