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!

fixed quantiles crash

Blue Mouse94dbdabde8cc
diff --git a/apps/production/src/analytics/analytics.service.ts b/apps/production/src/analytics/analytics.service.ts
index fad880cab..a7076d62b 100644
--- a/apps/production/src/analytics/analytics.service.ts
+++ b/apps/production/src/analytics/analytics.service.ts
@@ -87,6 +87,7 @@ import {
IPageflow,
PerfMeasure,
} from './interfaces'
+import { DEFAULT_MEASURE } from './analytics.controller'
dayjs.extend(utc)
dayjs.extend(dayjsTimezone)
@@ -279,7 +280,9 @@ const generateParamsQuery = (
const columnsQuery = columns.join(', ')
if (isPerformance) {
- const fn = MEASURES_MAP[measure]
+ const processedMeasure = measure === 'quantiles' ? DEFAULT_MEASURE : measure
+
+ const fn = MEASURES_MAP[processedMeasure]
if (col === 'pg') {
return `SELECT ${columnsQuery}, round(divide(${fn}(pageLoad), 1000), 2) as count ${subQuery} GROUP BY ${columnsQuery}`
diff --git a/apps/selfhosted/src/analytics/analytics.service.ts b/apps/selfhosted/src/analytics/analytics.service.ts
index 975505080..8af6c805a 100644
--- a/apps/selfhosted/src/analytics/analytics.service.ts
+++ b/apps/selfhosted/src/analytics/analytics.service.ts
@@ -76,6 +76,7 @@ import {
IPageflow,
PerfMeasure,
} from './interfaces'
+import { DEFAULT_MEASURE } from './analytics.controller'
dayjs.extend(utc)
dayjs.extend(dayjsTimezone)
@@ -267,7 +268,9 @@ const generateParamsQuery = (
const columnsQuery = columns.join(', ')
if (isPerformance) {
- const fn = MEASURES_MAP[measure]
+ const processedMeasure = measure === 'quantiles' ? DEFAULT_MEASURE : measure
+
+ const fn = MEASURES_MAP[processedMeasure]
if (col === 'pg') {
return `SELECT ${columnsQuery}, round(divide(${fn}(pageLoad), 1000), 2) as count ${subQuery} GROUP BY ${columnsQuery}`