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!

fixed potential log/generalStats loop

Blue Mouse17c99168e795
diff --git a/src/api/index.js b/src/api/index.js
index 4e9a1c742..48f6e3f2d 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -35,7 +35,7 @@ api.interceptors.response.use(
(error) => {
if (error.response?.data.statusCode === 401) {
removeAccessToken()
- store.dispatch(authActions.logout())
+ store.dispatch(authActions.logout(true))
}
return Promise.reject(error)
},
diff --git a/src/redux/actions/auth/index.js b/src/redux/actions/auth/index.js
index bff08f4fa..c8739200a 100644
--- a/src/redux/actions/auth/index.js
+++ b/src/redux/actions/auth/index.js
@@ -31,12 +31,13 @@ export const authActions = {
}
},
- logout() {
+ logout(basedOn401Error) {
removeAccessToken()
removeItem(LS_VIEW_PREFS_SETTING)
return {
type: types.LOGOUT,
+ payload: { basedOn401Error },
}
},
diff --git a/src/redux/sagas/auth/workers/logout.js b/src/redux/sagas/auth/workers/logout.js
index ebcf11f61..ec671a523 100644
--- a/src/redux/sagas/auth/workers/logout.js
+++ b/src/redux/sagas/auth/workers/logout.js
@@ -7,12 +7,14 @@ import { THEME_TYPE } from 'redux/constants'
const debug = Debug('swetrix:rx:s:logout')
-export default function* logoutWorker() {
+export default function* logoutWorker({ payload: { basedOn401Error } = {} }) {
try {
- const stats = yield call(getGeneralStats)
+ if (!basedOn401Error) {
+ const stats = yield call(getGeneralStats)
+ yield put(UIActions.setGeneralStats(stats))
+ }
yield put(UIActions.setThemeType(THEME_TYPE.christmas))
- yield put(UIActions.setGeneralStats(stats))
} catch (e) {
debug('Error while getting general stats data: %s', e)
}