-
Notifications
You must be signed in to change notification settings - Fork 51
PM-225 Fix privacy violation related to cookie #1590
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { BETA_MODE_COOKIE_TAG } from '../config/constants' | ||
|
||
/** | ||
* Save an item to localStorage. | ||
* @param {string} key - The key under which the data will be stored. | ||
* @param {any} value - The data to store (will be stringified). | ||
*/ | ||
export function saveToLocalStorage (key, value) { | ||
if (!key || typeof key !== 'string') { | ||
throw new Error('Key must be a valid string.') | ||
} | ||
|
||
try { | ||
const jsonValue = JSON.stringify(value) | ||
window.localStorage.setItem(key, jsonValue) | ||
} catch (error) { | ||
console.error('Failed to save to localStorage:', error) | ||
} | ||
} | ||
|
||
/** | ||
* Get an item from localStorage. | ||
* @param {string} key - The key under which the data is stored. | ||
* @returns {any} - The parsed data from localStorage, or null if not found. | ||
*/ | ||
export function getFromLocalStorage (key) { | ||
if (!key || typeof key !== 'string') { | ||
throw new Error('Key must be a valid string.') | ||
} | ||
|
||
try { | ||
const jsonValue = window.localStorage.getItem(key) | ||
return jsonValue ? JSON.parse(jsonValue) : null | ||
} catch (error) { | ||
console.error('Failed to retrieve from localStorage:', error) | ||
return null | ||
} | ||
} | ||
|
||
/** | ||
* Remove an item from localStorage. | ||
* @param {string} key - The key of the item to remove. | ||
*/ | ||
export function removeFromLocalStorage (key) { | ||
if (!key || typeof key !== 'string') { | ||
throw new Error('Key must be a valid string.') | ||
} | ||
|
||
try { | ||
window.localStorage.removeItem(key) | ||
} catch (error) { | ||
console.error('Failed to remove from localStorage:', error) | ||
} | ||
} | ||
|
||
/** | ||
* A function that checks whether beta mode is enabled or not | ||
*/ | ||
export function isBetaMode () { | ||
return getFromLocalStorage(BETA_MODE_COOKIE_TAG) === 'true' | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.