📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
fix error when you are not reload a page
kruzhambus064ea11b830d
diff --git a/src/pages/CrashHandler/index.tsx b/src/pages/CrashHandler/index.tsxindex 942f818c4..a06818740 100644--- a/src/pages/CrashHandler/index.tsx+++ b/src/pages/CrashHandler/index.tsx@@ -1,7 +1,8 @@import React from 'react'import _toString from 'lodash/toString'import { ExclamationTriangleIcon, ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline'-import { CONTACT_EMAIL } from 'redux/constants'+import { CONTACT_EMAIL, PAGE_FORCE_REFRESHED } from 'redux/constants'+import { getItem, setItem } from 'utils/localstorage'interface CrashHandlerProps {children: JSX.Element@@ -14,6 +15,19 @@ interface CrashHandlerState {crashStackShown: boolean}+const retryPageLoading = () => {+ const pageHasAlreadyBeenForceRefreshed = JSON.parse(+ getItem(PAGE_FORCE_REFRESHED) || 'false',+ ) as boolean++ if (!pageHasAlreadyBeenForceRefreshed) {+ setItem(PAGE_FORCE_REFRESHED, 'true')+ return window.location.reload()+ }+ setItem(PAGE_FORCE_REFRESHED, 'false')+ return null+}+class CrashHandler extends React.Component<CrashHandlerProps, CrashHandlerState> {constructor(props: CrashHandlerProps) {super(props)@@ -25,6 +39,10 @@ class CrashHandler extends React.Component<CrashHandlerProps, CrashHandlerState>}}+ componentDidCatch() {+ retryPageLoading()+ }+static getDerivedStateFromError(error: Error) {return {errorMessage: _toString(error),diff --git a/src/redux/constants/index.ts b/src/redux/constants/index.tsindex c79b77f8f..addd4eb4c 100644--- a/src/redux/constants/index.ts+++ b/src/redux/constants/index.ts@@ -198,6 +198,9 @@ export const LOW_EVENTS_WARNING: string = 'low_events_warning'export const TOKEN: string = 'access_token'export const REFRESH_TOKEN: string = 'refresh_token'+// LocalStorage+export const PAGE_FORCE_REFRESHED = 'page-force-refreshed'+// List of languages with translations availableexport const whitelist: string[] = ['en', 'uk', 'pl', 'de', 'sv', 'el', 'ru', 'hi', 'zh']export const defaultLanguage: string = 'en'