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) perfomance compare when activeTab change

kruzhambusb7966e79cd3f
diff --git a/src/pages/Project/View/ViewProject.tsx b/src/pages/Project/View/ViewProject.tsx
index 594f14ea0..a107e5c82 100644
--- a/src/pages/Project/View/ViewProject.tsx
+++ b/src/pages/Project/View/ViewProject.tsx
@@ -44,7 +44,7 @@ import {
tbPeriodPairs, getProjectCacheKey, LIVE_VISITORS_UPDATE_INTERVAL, DEFAULT_TIMEZONE, CDN_URL, isDevelopment,
timeBucketToDays, getProjectCacheCustomKey, roleViewer, MAX_MONTHS_IN_PAST, PROJECT_TABS,
TimeFormat, getProjectForcastCacheKey, chartTypes, roleAdmin, TRAFFIC_PANELS_ORDER, PERFORMANCE_PANELS_ORDER, isSelfhosted, tbPeriodPairsCompare,
- PERIOD_PAIRS_COMPARE, filtersPeriodPairs, IS_ACTIVE_COMPARE,
+ PERIOD_PAIRS_COMPARE, filtersPeriodPairs, IS_ACTIVE_COMPARE, getProjectCacheCustomKeyPerf,
} from 'redux/constants'
import { IUser } from 'redux/models/IUser'
import { IProject, ILiveStats } from 'redux/models/IProject'
@@ -689,7 +689,7 @@ const ViewProject = ({
if (activePeriod?.period === 'custom' ? diffCompare <= diff : diffCompare <= activePeriod?.countDays) {
fromCompare = getFormatDate(dateRangeCompare[0])
toCompare = getFormatDate(dateRangeCompare[1])
- keyCompare = getProjectCacheCustomKey(fromCompare, toCompare, timeBucket)
+ keyCompare = getProjectCacheCustomKeyPerf(fromCompare, toCompare, timeBucket)
} else {
showError(t('project.compareDateRangeError'))
compareDisable()
@@ -705,7 +705,7 @@ const ViewProject = ({
if (date) {
fromCompare = date.from
toCompare = date.to
- keyCompare = getProjectCacheCustomKey(fromCompare, toCompare, timeBucket)
+ keyCompare = getProjectCacheCustomKeyPerf(fromCompare, toCompare, timeBucket)
}
}
@@ -755,6 +755,7 @@ const ViewProject = ({
return
}
+ console.log(dataCompare)
if (!_isEmpty(dataCompare) && !_isEmpty(dataCompare?.chart)) {
setDataChartPerfCompare(dataCompare.chart)
}
diff --git a/src/redux/constants/index.ts b/src/redux/constants/index.ts
index 7f3986d86..150d8c4b5 100644
--- a/src/redux/constants/index.ts
+++ b/src/redux/constants/index.ts
@@ -233,6 +233,7 @@ export const getProjectCacheKey = (period: string, timeBucket: string): string =
export const getProjectCaptchaCacheKey = (period: string, timeBucket: string): string => `${period}${timeBucket}captcha`
export const getProjectForcastCacheKey = (period: string, timeBucket: string, periodToForecast: string): string => `${period}${timeBucket}${periodToForecast}forecast`
export const getProjectCacheCustomKey = (from: string, to: string, timeBucket: string): string => `${from}-${to}-${timeBucket}`
+export const getProjectCacheCustomKeyPerf = (from: string, to: string, timeBucket: string): string => `${from}-${to}-${timeBucket}perf`
export const getUserFlowCacheKey = (pid: string, period: string): string => `${pid}${period}userflow`
// Cookies