📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
(feature) 'minute' time bucket (#177)
Andrii Romasiunad99dfd63312
diff --git a/apps/production/src/analytics/analytics.service.ts b/apps/production/src/analytics/analytics.service.tsindex 806cd7ab7..c2db8cf7d 100644--- a/apps/production/src/analytics/analytics.service.ts+++ b/apps/production/src/analytics/analytics.service.ts@@ -106,6 +106,7 @@ export const validPeriods = []const validTimebuckets = [+ TimeBucketType.MINUTE,TimeBucketType.HOUR,TimeBucketType.DAY,TimeBucketType.MONTH,@@ -115,6 +116,10 @@ const validTimebuckets = [// mapping of allowed timebuckets per difference between days// (e.g. if difference is lower than (lt) (including) -> then the specified timebuckets are allowed to be applied)const timeBucketToDays = [+ {+ lt: 0,+ tb: [TimeBucketType.MINUTE, TimeBucketType.HOUR],+ }, // < 1 day{lt: 7,tb: [TimeBucketType.HOUR, TimeBucketType.DAY, TimeBucketType.MONTH],@@ -134,6 +139,7 @@ const timeBucketToDays = [const customEVvalidate = /^[a-zA-Z](?:[\w\.]){0,62}$/const timeBucketConversion = {+ minute: 'toStartOfMinute',hour: 'toStartOfHour',day: 'toStartOfDay',month: 'toStartOfMonth',@@ -1051,6 +1057,7 @@ export class AnalyticsService {let formatswitch (timeBucket) {+ case TimeBucketType.MINUTE:case TimeBucketType.HOUR:format = 'YYYY-MM-DD HH:mm:ss'break@@ -1176,6 +1183,17 @@ export class AnalyticsService {}getGroupSubquery(timeBucket: TimeBucketType): [string, string] {+ if (timeBucket === TimeBucketType.MINUTE) {+ return [+ `toYear(tz_created) as year,+ toMonth(tz_created) as month,+ toDayOfMonth(tz_created) as day,+ toHour(tz_created) as hour,+ toMinute(tz_created) as minute`,+ 'year, month, day, hour, minute',+ ]+ }+if (timeBucket === TimeBucketType.HOUR) {return [`toYear(tz_created) as year,diff --git a/apps/production/src/analytics/dto/getData.dto.ts b/apps/production/src/analytics/dto/getData.dto.tsindex 26e3deabc..c51c3d227 100644--- a/apps/production/src/analytics/dto/getData.dto.ts+++ b/apps/production/src/analytics/dto/getData.dto.ts@@ -3,6 +3,7 @@ import { IsNotEmpty } from 'class-validator'import { DEFAULT_TIMEZONE } from '../../user/entities/user.entity'export enum TimeBucketType {+ MINUTE = 'minute',HOUR = 'hour',DAY = 'day',MONTH = 'month',