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!

fix cache

kruzhambuseb2289fc3561
diff --git a/src/pages/Captcha/View/ViewCaptcha.jsx b/src/pages/Captcha/View/ViewCaptcha.jsx
index eb500d1f1..410028369 100644
--- a/src/pages/Captcha/View/ViewCaptcha.jsx
+++ b/src/pages/Captcha/View/ViewCaptcha.jsx
@@ -32,7 +32,7 @@ import { getItem, setItem } from 'utils/localstorage'
import Title from 'components/Title'
import EventsRunningOutBanner from 'components/EventsRunningOutBanner'
import {
- tbPeriodPairs, getProjectCacheKey, timeBucketToDays, getProjectCacheCustomKey, roleViewer,
+ tbPeriodPairs, getProjectCaptchaCacheKey, timeBucketToDays, getProjectCacheCustomKey, roleViewer,
MAX_MONTHS_IN_PAST, MAX_MONTHS_IN_PAST_FREE, TimeFormat, chartTypes,
} from 'redux/constants'
import Button from 'ui/Button'
@@ -148,7 +148,7 @@ const ViewProject = ({
to = getFormatDate(dateRange[1])
key = getProjectCacheCustomKey(from, to, timeBucket)
} else {
- key = getProjectCacheKey(period, timeBucket)
+ key = getProjectCaptchaCacheKey(period, timeBucket)
}
if (!forced && !_isEmpty(cache[id]) && !_isEmpty(cache[id][key])) {
@@ -217,6 +217,11 @@ const ViewProject = ({
}
}
+ useEffect(() => {
+ loadAnalytics()
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [chartType])
+
// this funtion is used for requesting the data from the API when the filter is changed
const filterHandler = (column, filter, isExclusive = false) => {
let newFilters
diff --git a/src/redux/actions/ui/index.js b/src/redux/actions/ui/index.js
index 8bea73f23..e17d78020 100644
--- a/src/redux/actions/ui/index.js
+++ b/src/redux/actions/ui/index.js
@@ -124,7 +124,7 @@ const setProjectCache = (pid, data, key) => ({
})
const setCaptchaProjectCache = (pid, data, key) => ({
- type: types.SET_CAPTCHA_PROJECT_CHACHE,
+ type: types.SET_CAPTCHA_PROJECT_CACHE,
payload: {
pid, data, key,
},
diff --git a/src/redux/actions/ui/types.js b/src/redux/actions/ui/types.js
index e37ea59cb..e0a76db40 100644
--- a/src/redux/actions/ui/types.js
+++ b/src/redux/actions/ui/types.js
@@ -4,7 +4,7 @@ export const types = {
SET_PROJECTS_LOADING: 'UI_SET_PROJECTS_LOADING',
REMOVE_PROJECT: 'UI_REMOVE_PROJECT',
SET_PROJECT_CACHE: 'UI_SET_PROJECT_CACHE',
- SET_CAPTCHA_PROJECT_CHACHE: 'UI_SET_CAPTCHA_PROJECT_CHACHE',
+ SET_CAPTCHA_PROJECT_CACHE: 'UI_SET_CAPTCHA_PROJECT_CACHE',
DELETE_PROJECT_CACHE: 'UI_DELETE_PROJECT_CACHE',
DELETE_CAPTCHA_PROJECT_CACHE: 'UI_DELETE_CAPTCHA_PROJECT_CACHE',
SET_PROJECT_VIEW_PREFS: 'UI_SET_PROJECT_VIEW_PREFS',
diff --git a/src/redux/constants/index.js b/src/redux/constants/index.js
index e9cc4862b..6df533b94 100644
--- a/src/redux/constants/index.js
+++ b/src/redux/constants/index.js
@@ -153,6 +153,7 @@ export const GENERAL_STATS_UPDATE_INTERVAL = 60000
// Functions
export const getProjectCacheKey = (period, timeBucket) => `${period}${timeBucket}`
+export const getProjectCaptchaCacheKey = (period, timeBucket) => `${period}${timeBucket}captcha`
export const getProjectForcastCacheKey = (period, timeBucket, periodToForecast) => `${period}${timeBucket}${periodToForecast}forecast`
export const getProjectCacheCustomKey = (from, to, timeBucket) => `${from}-${to}-${timeBucket}`
diff --git a/src/redux/reducers/ui/cache.js b/src/redux/reducers/ui/cache.js
index 7a661844e..9654378a6 100644
--- a/src/redux/reducers/ui/cache.js
+++ b/src/redux/reducers/ui/cache.js
@@ -2,7 +2,9 @@ import { types } from 'redux/actions/ui/types'
import _filter from 'lodash/filter'
import _isEmpty from 'lodash/isEmpty'
-import { getProjectCacheKey, LS_VIEW_PREFS_SETTING, LS_CAPTCHA_VIEW_PREFS_SETTING } from 'redux/constants'
+import {
+ getProjectCacheKey, LS_VIEW_PREFS_SETTING, LS_CAPTCHA_VIEW_PREFS_SETTING, getProjectCaptchaCacheKey,
+} from 'redux/constants'
export const getInitialViewPrefs = (LS_VIEW) => {
if (typeof window !== 'undefined' && window.localStorage) {
@@ -98,7 +100,7 @@ const cacheReducer = (state = getInitialState(), { type, payload }) => {
case types.DELETE_CAPTCHA_PROJECT_CACHE: {
const { pid, period, timeBucket } = payload
- const key = getProjectCacheKey(period, timeBucket)
+ const key = getProjectCaptchaCacheKey(period, timeBucket)
if (_isEmpty(period) || _isEmpty(timeBucket)) {
if (_isEmpty(pid)) {