📈 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
fixed sdur chart metric incorrect values
Blue Mouse9baa670e86c1
diff --git a/src/analytics/analytics.service.ts b/src/analytics/analytics.service.tsindex 095a78966..8b610683c 100644--- a/src/analytics/analytics.service.ts+++ b/src/analytics/analytics.service.ts@@ -9,6 +9,7 @@ import * as _some from 'lodash/some'import * as _find from 'lodash/find'import * as _now from 'lodash/now'import * as _values from 'lodash/values'+import * as _round from 'lodash/round'import * as dayjs from 'dayjs'import * as utc from 'dayjs/plugin/utc'import * as timezone from 'dayjs/plugin/timezone'@@ -537,7 +538,7 @@ export class AnalyticsService {// Average session duration calculationconst avgSdurQuery = `SELECT avg(sdur) ${subQuery} AND sdur IS NOT NULL`let avgSdur = await clickhouse.query(avgSdurQuery, paramsData).toPromise()- avgSdur = avgSdur[0]['avg(sdur)']+ avgSdur = _round(avgSdur[0]['avg(sdur)'])let groupDateIteratorconst now = dayjs.utc().endOf(timeBucket)@@ -596,11 +597,11 @@ export class AnalyticsService {while (idx < resSize) {const index = result[idx].indexconst v = result[idx]['count()']- const s = result[idx]['avg(sdur)']- sdur[index] = Number(s)if (index === result[1 + idx]?.index) {const u = result[1 + idx]['count()']+ const s = result[1 + idx]['avg(sdur)']+ sdur[index] = _round(s)visits[index] = v + uuniques[index] = uidx += 2