Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

some update and fix cookie utils

Maksim Mrugdcd71cd6ba83
diff --git a/app/App.tsx b/app/App.tsx
index 0a500daa9..719ddb005 100644
--- a/app/App.tsx
+++ b/app/App.tsx
@@ -110,12 +110,18 @@ const App = () => {
}, [paddleLoaded, authenticated]) // eslint-disable-line
useEffect(() => {
- const loaderEl = document.getElementById('loader')
+ let loaderEl: HTMLElement | null = null
+
+ if (document) {
+ loaderEl = document.getElementById('loader')
+ }
if (loaderEl) {
loaderEl.classList.add('available')
setTimeout(() => {
- loaderEl.outerHTML = ''
+ if (loaderEl) {
+ loaderEl.outerHTML = ''
+ }
}, 1000)
}
}, [])
diff --git a/app/root.tsx b/app/root.tsx
index c4974130e..ff400e828 100644
--- a/app/root.tsx
+++ b/app/root.tsx
@@ -31,7 +31,7 @@ const options = {
}
if (process.env.NODE_ENV !== 'production') {
- localStorage.debug = 'swetrix:*'
+ // localStorage.debug = 'swetrix:*'
}
export const links: LinksFunction = () => [
diff --git a/app/utils/cookie.ts b/app/utils/cookie.ts
index 35e9a653c..fc0a50bca 100644
--- a/app/utils/cookie.ts
+++ b/app/utils/cookie.ts
@@ -5,20 +5,20 @@ const COOKIE_DOMAIN = 'swetrix.com'
const COOKIE_SUFFIX = (isDevelopment || isSelfhosted) ? '' : `; domain=${COOKIE_DOMAIN}; secure`
export const getCookie = (key: string) => {
- const match = document.cookie.match(new RegExp(`(^| )${key}=([^;]+)`))
+ // const match = document.cookie.match(new RegExp(`(^| )${key}=([^;]+)`))
- if (match) {
- return match[2]
- }
+ // if (match) {
+ // return match[2]
+ // }
return null
}
export const setCookie = (key: string, value: string | number | boolean, maxAge = 3600, sameSite = 'strict') => {
- document.cookie = `${key}=${value}; max-age=${maxAge}; path=/; SameSite=${sameSite}${COOKIE_SUFFIX}`
+ // document.cookie = `${key}=${value}; max-age=${maxAge}; path=/; SameSite=${sameSite}${COOKIE_SUFFIX}`
}
export const deleteCookie = (key: string) => {
- document.cookie = `${key}=; max-age=0; path=/; SameSite=strict`
- document.cookie = `${key}=; max-age=0; path=/; SameSite=strict${COOKIE_SUFFIX}`
+ // document.cookie = `${key}=; max-age=0; path=/; SameSite=strict`
+ // document.cookie = `${key}=; max-age=0; path=/; SameSite=strict${COOKIE_SUFFIX}`
}
diff --git a/app/utils/refreshToken.ts b/app/utils/refreshToken.ts
index c19feeba3..7eb66ba18 100644
--- a/app/utils/refreshToken.ts
+++ b/app/utils/refreshToken.ts
@@ -10,11 +10,11 @@ export const getRefreshToken = () => {
// let refreshToken = getCookie(REFRESH_TOKEN)
// if (_isEmpty(refreshToken)) {
- // refreshToken = sessionStorage.getItem(REFRESH_TOKEN)
+ // refreshToken = sessionStorage.getItem(REFRESH_TOKEN)
// }
// return refreshToken
- return
+ return null
}
export const setRefreshToken = (token: string, temporary: boolean = false) => {