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!

(selfhosted) fix: funnel filters does not work for custom events

Blue Mouse4d8df69310fa
diff --git a/apps/selfhosted/src/analytics/analytics.service.ts b/apps/selfhosted/src/analytics/analytics.service.ts
index d9df423a4..a3c649bcf 100644
--- a/apps/selfhosted/src/analytics/analytics.service.ts
+++ b/apps/selfhosted/src/analytics/analytics.service.ts
@@ -48,6 +48,7 @@ import {
ERROR_COLUMNS,
MIN_PAGES_IN_FUNNEL,
MAX_PAGES_IN_FUNNEL,
+ ALL_COLUMNS,
} from '../common/constants'
import {
getFunnelsClickhouse,
@@ -1552,13 +1553,19 @@ export class AnalyticsService {
}
async getFilters(pid: string, type: string): Promise<Array<string>> {
- if (!_includes(TRAFFIC_COLUMNS, type)) {
+ if (!_includes(ALL_COLUMNS, type)) {
throw new UnprocessableEntityException(
`The provided type (${type}) is incorrect`,
)
}
- const query = `SELECT ${type} FROM analytics WHERE pid={pid:FixedString(12)} AND ${type} IS NOT NULL GROUP BY ${type}`
+ let query = `SELECT ${type} FROM analytics WHERE pid={pid:FixedString(12)} AND ${type} IS NOT NULL GROUP BY ${type}`
+
+ if (type === 'ev') {
+ query =
+ 'SELECT ev FROM customEV WHERE pid={pid:FixedString(12)} AND ev IS NOT NULL GROUP BY ev'
+ }
+
const results = await clickhouse
.query(query, { params: { pid } })
.toPromise()
diff --git a/apps/selfhosted/src/common/constants.ts b/apps/selfhosted/src/common/constants.ts
index 226134eca..ae2f97e59 100644
--- a/apps/selfhosted/src/common/constants.ts
+++ b/apps/selfhosted/src/common/constants.ts
@@ -110,6 +110,8 @@ const TRAFFIC_COLUMNS = [
'ca',
]
+const ALL_COLUMNS = [...TRAFFIC_COLUMNS, 'ev']
+
const PERFORMANCE_COLUMNS = ['cc', 'rg', 'ct', 'pg', 'dv', 'br']
const ERROR_COLUMNS = ['pg', 'dv', 'br', 'os', 'lc', 'cc', 'rg', 'ct']
@@ -152,4 +154,5 @@ export {
ERROR_COLUMNS,
REDIS_LOG_ERROR_CACHE_KEY,
PID_REGEX,
+ ALL_COLUMNS,
}