mirror of
https://github.com/ente-io/ente.git
synced 2025-06-15 04:47:14 +00:00
Sentry has a measurable impact on page load, a metric that I'm keen to improve. Apparently by default it loses us 8-9 page speed points, though that can be reduced to 3-4 (https://github.com/getsentry/sentry-javascript/issues/9179). All of this is doable, but there are bigger tasks to deal with. This is not to say that Sentry won't be useful again at some point, when we have time to deal with it better. But right now, we discussed that it's just better to remove Sentry instead of piling on to the sunk cost.
70 lines
2.0 KiB
TypeScript
70 lines
2.0 KiB
TypeScript
import { logError } from "@ente/shared/sentry";
|
|
|
|
export enum LS_KEYS {
|
|
USER = "user",
|
|
SESSION = "session",
|
|
KEY_ATTRIBUTES = "keyAttributes",
|
|
ORIGINAL_KEY_ATTRIBUTES = "originalKeyAttributes",
|
|
SUBSCRIPTION = "subscription",
|
|
FAMILY_DATA = "familyData",
|
|
PLANS = "plans",
|
|
IS_FIRST_LOGIN = "isFirstLogin",
|
|
JUST_SIGNED_UP = "justSignedUp",
|
|
SHOW_BACK_BUTTON = "showBackButton",
|
|
EXPORT = "export",
|
|
THUMBNAIL_FIX_STATE = "thumbnailFixState",
|
|
LIVE_PHOTO_INFO_SHOWN_COUNT = "livePhotoInfoShownCount",
|
|
LOGS = "logs",
|
|
USER_DETAILS = "userDetails",
|
|
COLLECTION_SORT_BY = "collectionSortBy",
|
|
THEME = "theme",
|
|
WAIT_TIME = "waitTime",
|
|
API_ENDPOINT = "apiEndpoint",
|
|
// Moved to the new wrapper @/utils/local-storage
|
|
// LOCALE = 'locale',
|
|
MAP_ENABLED = "mapEnabled",
|
|
SRP_SETUP_ATTRIBUTES = "srpSetupAttributes",
|
|
SRP_ATTRIBUTES = "srpAttributes",
|
|
CF_PROXY_DISABLED = "cfProxyDisabled",
|
|
REFERRAL_SOURCE = "referralSource",
|
|
CLIENT_PACKAGE = "clientPackage",
|
|
}
|
|
|
|
export const setData = (key: LS_KEYS, value: object) => {
|
|
if (typeof localStorage === "undefined") {
|
|
return null;
|
|
}
|
|
localStorage.setItem(key, JSON.stringify(value));
|
|
};
|
|
|
|
export const removeData = (key: LS_KEYS) => {
|
|
if (typeof localStorage === "undefined") {
|
|
return null;
|
|
}
|
|
localStorage.removeItem(key);
|
|
};
|
|
|
|
export const getData = (key: LS_KEYS) => {
|
|
try {
|
|
if (
|
|
typeof localStorage === "undefined" ||
|
|
typeof key === "undefined" ||
|
|
typeof localStorage.getItem(key) === "undefined" ||
|
|
localStorage.getItem(key) === "undefined"
|
|
) {
|
|
return null;
|
|
}
|
|
const data = localStorage.getItem(key);
|
|
return data && JSON.parse(data);
|
|
} catch (e) {
|
|
logError(e, "Failed to Parse JSON for key " + key);
|
|
}
|
|
};
|
|
|
|
export const clearData = () => {
|
|
if (typeof localStorage === "undefined") {
|
|
return null;
|
|
}
|
|
localStorage.clear();
|
|
};
|