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 cumulative mode

Blue Mouse684ca71706a3
diff --git a/backend/apps/cloud/src/analytics/analytics.service.ts b/backend/apps/cloud/src/analytics/analytics.service.ts
index 6f8909ceb..5d491c144 100644
--- a/backend/apps/cloud/src/analytics/analytics.service.ts
+++ b/backend/apps/cloud/src/analytics/analytics.service.ts
@@ -2764,6 +2764,18 @@ export class AnalyticsService {
const { visits, uniques, sdur } = this.extractChartData(data, xShifted)
+ // Propagate the previous cumulative value forward for empty buckets
+ if (mode === ChartRenderMode.CUMULATIVE) {
+ for (let i = 1; i < visits.length; ++i) {
+ if (visits[i] === 0) {
+ visits[i] = visits[i - 1]
+ }
+ if (uniques[i] === 0) {
+ uniques[i] = uniques[i - 1]
+ }
+ }
+ }
+
return Promise.resolve({
chart: {
x: xShifted,
diff --git a/backend/apps/community/src/analytics/analytics.service.ts b/backend/apps/community/src/analytics/analytics.service.ts
index 251db31d8..e43c82560 100644
--- a/backend/apps/community/src/analytics/analytics.service.ts
+++ b/backend/apps/community/src/analytics/analytics.service.ts
@@ -2554,6 +2554,18 @@ export class AnalyticsService {
const { visits, uniques, sdur } = this.extractChartData(data, xShifted)
+ // Propagate the previous cumulative value forward for empty buckets
+ if (mode === ChartRenderMode.CUMULATIVE) {
+ for (let i = 1; i < visits.length; ++i) {
+ if (visits[i] === 0) {
+ visits[i] = visits[i - 1]
+ }
+ if (uniques[i] === 0) {
+ uniques[i] = uniques[i - 1]
+ }
+ }
+ }
+
return Promise.resolve({
chart: {
x: xShifted,