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!

some improvments

Maksim Mrugc4fdb3a6d7a2
diff --git a/apps/production/src/analytics/analytics.controller.ts b/apps/production/src/analytics/analytics.controller.ts
index 4879acbbc..d4e4ae5f5 100644
--- a/apps/production/src/analytics/analytics.controller.ts
+++ b/apps/production/src/analytics/analytics.controller.ts
@@ -2,6 +2,7 @@ import * as _isEmpty from 'lodash/isEmpty'
import * as _isArray from 'lodash/isArray'
import * as _toNumber from 'lodash/toNumber'
import * as _pick from 'lodash/pick'
+import * as _includes from 'lodash/includes'
import * as _map from 'lodash/map'
import * as _uniqBy from 'lodash/uniqBy'
import * as _round from 'lodash/round'
@@ -299,12 +300,13 @@ export class AnalyticsController {
const res = await this.analyticsService.getTimeBucketForAllTime(
pid,
period,
- timeBucket,
)
diff = res.diff
// eslint-disable-next-line prefer-destructuring
- newTimebucket = res.timeBucket[0]
+ newTimebucket = _includes(res.timeBucket, timeBucket)
+ ? timeBucket
+ : res.timeBucket[0]
allowedTumebucketForPeriodAll = res.timeBucket
}
@@ -1153,11 +1155,12 @@ export class AnalyticsController {
const res = await this.analyticsService.getTimeBucketForAllTime(
pid,
period,
- timeBucket,
)
// eslint-disable-next-line prefer-destructuring
- newTimeBucket = res.timeBucket[0]
+ newTimeBucket = _includes(res.timeBucket, timeBucket)
+ ? timeBucket
+ : res.timeBucket[0]
diff = res.diff
timeBucketForAllTime = res.timeBucket
}
diff --git a/apps/production/src/analytics/analytics.service.ts b/apps/production/src/analytics/analytics.service.ts
index 7297476f5..c8296439b 100644
--- a/apps/production/src/analytics/analytics.service.ts
+++ b/apps/production/src/analytics/analytics.service.ts
@@ -645,12 +645,11 @@ export class AnalyticsService {
async getTimeBucketForAllTime(
pid: string,
period: string,
- timeBucket: TimeBucketType,
): Promise<{
timeBucket: TimeBucketType[]
diff: number
}> {
- if (period !== validPeriods[validPeriods.length - 1]) {
+ if (period !== 'all') {
return null
}
@@ -666,6 +665,7 @@ export class AnalyticsService {
{ params: { pid } },
)
.toPromise()
+
let newTimeBucket = [TimeBucketType.MONTH]
let diff = null
@@ -680,7 +680,7 @@ export class AnalyticsService {
)
}
- newTimeBucket = _includes(tbMap.tb, timeBucket) ? [timeBucket] : tbMap.tb
+ newTimeBucket = tbMap.tb
}
return {