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!

add new timebucket year

Maksim Mrug338e4c07d1c6
diff --git a/apps/production/src/analytics/analytics.service.ts b/apps/production/src/analytics/analytics.service.ts
index c8296439b..400aee71e 100644
--- a/apps/production/src/analytics/analytics.service.ts
+++ b/apps/production/src/analytics/analytics.service.ts
@@ -137,6 +137,7 @@ const timeBucketConversion = {
hour: 'toStartOfHour',
day: 'toStartOfDay',
month: 'toStartOfMonth',
+ year: 'toStartOfYear',
}
const isValidTimezone = (timezone: string): boolean => {
@@ -1061,6 +1062,10 @@ export class AnalyticsService {
format = 'YYYY-MM'
break
+ case TimeBucketType.YEAR:
+ format = 'YYYY'
+ break
+
default:
throw new BadRequestException(
`The provided time bucket (${timeBucket}) is incorrect`,
@@ -1188,6 +1193,10 @@ export class AnalyticsService {
]
}
+ if (timeBucket === TimeBucketType.YEAR) {
+ return [`toYear(tz_created) as year`, 'year']
+ }
+
return [
`toYear(tz_created) as year,
toMonth(tz_created) as month,