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: Preserve the timezone on hourly bucket keys

Blue Mouse2d899ac7322e
diff --git a/backend/apps/cloud/src/project/gsc.service.ts b/backend/apps/cloud/src/project/gsc.service.ts
index 2bff195c3..b758eeedc 100644
--- a/backend/apps/cloud/src/project/gsc.service.ts
+++ b/backend/apps/cloud/src/project/gsc.service.ts
@@ -1,6 +1,7 @@
import { parse as parseDomain } from 'tldts'
import _isEmpty from 'lodash/isEmpty'
import dayjs from 'dayjs'
+import utc from 'dayjs/plugin/utc'
import {
Injectable,
BadRequestException,
@@ -16,6 +17,8 @@ import { isDevelopment, PRODUCTION_ORIGIN, redis } from '../common/constants'
import { ProjectService } from './project.service'
import { deriveKey } from '../common/utils'
+dayjs.extend(utc)
+
type StoredTokens = {
access_token?: string
refresh_token?: string
@@ -578,7 +581,7 @@ export class GSCService {
return rows.map((row) => ({
date: row.keys?.[0]
? isHourly
- ? dayjs(row.keys[0]).format('YYYY-MM-DD HH:mm:ss')
+ ? dayjs.utc(row.keys[0]).format('YYYY-MM-DD HH:mm:ss')
: row.keys[0]
: '',
clicks: Math.round(row.clicks || 0),