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!

simplified general stats logic

Blue Mouseba424dc56c25
diff --git a/src/redux/constants/index.ts b/src/redux/constants/index.ts
index 204b68fc7..e7d59d7ba 100644
--- a/src/redux/constants/index.ts
+++ b/src/redux/constants/index.ts
@@ -221,7 +221,6 @@ export const SECURITY_EMAIL: string = '[email protected]'
export const isSelfhosted: boolean = Boolean(process.env.REACT_APP_SELFHOSTED)
export const LIVE_VISITORS_UPDATE_INTERVAL: number = 40000
-export const GENERAL_STATS_UPDATE_INTERVAL: number = 60000
// Functions
export const getProjectCacheKey = (period: string, timeBucket: string): string => `${period}${timeBucket}`
diff --git a/src/redux/sagas/ui/worker_general_stats.ts b/src/redux/sagas/ui/worker_general_stats.ts
index e13625458..c653f9879 100644
--- a/src/redux/sagas/ui/worker_general_stats.ts
+++ b/src/redux/sagas/ui/worker_general_stats.ts
@@ -1,16 +1,16 @@
import {
- put, call, delay, select,
+ put, call, delay,
} from 'redux-saga/effects'
import Debug from 'debug'
import { getGeneralStats } from 'api'
import UIActions from 'redux/reducers/ui'
-import { GENERAL_STATS_UPDATE_INTERVAL, isSelfhosted } from 'redux/constants'
+import { isSelfhosted } from 'redux/constants'
import { IStats } from 'redux/models/IStats'
const debug = Debug('swetrix:rx:s:general-stats')
-const NOT_AUTHED_INTERVAL = 5000 // 5 seconds
+const RETRY_INTERVAL = 10000 // 10 seconds
export default function* generalStats() {
if (isSelfhosted) {
@@ -18,20 +18,15 @@ export default function* generalStats() {
}
while (true) {
- const isAuthenticated: boolean = yield select(state => state.auth.authenticated)
- if (isAuthenticated) {
- yield delay(NOT_AUTHED_INTERVAL)
- continue
- }
-
try {
const stats: IStats = yield call(getGeneralStats)
yield put(UIActions.setGeneralStats(stats))
+ return
} catch (e) {
debug('Error while getting general stats data: %s', e)
}
- yield delay(GENERAL_STATS_UPDATE_INTERVAL)
+ yield delay(RETRY_INTERVAL)
}
}