Skip to content

Commit 4d8df69

Browse files
committed
(selfhosted) fix: funnel filters does not work for custom events
1 parent b9ca71b commit 4d8df69

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

apps/selfhosted/src/analytics/analytics.service.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import {
4848
ERROR_COLUMNS,
4949
MIN_PAGES_IN_FUNNEL,
5050
MAX_PAGES_IN_FUNNEL,
51+
ALL_COLUMNS,
5152
} from '../common/constants'
5253
import {
5354
getFunnelsClickhouse,
@@ -1552,13 +1553,19 @@ export class AnalyticsService {
15521553
}
15531554

15541555
async getFilters(pid: string, type: string): Promise<Array<string>> {
1555-
if (!_includes(TRAFFIC_COLUMNS, type)) {
1556+
if (!_includes(ALL_COLUMNS, type)) {
15561557
throw new UnprocessableEntityException(
15571558
`The provided type (${type}) is incorrect`,
15581559
)
15591560
}
15601561

1561-
const query = `SELECT ${type} FROM analytics WHERE pid={pid:FixedString(12)} AND ${type} IS NOT NULL GROUP BY ${type}`
1562+
let query = `SELECT ${type} FROM analytics WHERE pid={pid:FixedString(12)} AND ${type} IS NOT NULL GROUP BY ${type}`
1563+
1564+
if (type === 'ev') {
1565+
query =
1566+
'SELECT ev FROM customEV WHERE pid={pid:FixedString(12)} AND ev IS NOT NULL GROUP BY ev'
1567+
}
1568+
15621569
const results = await clickhouse
15631570
.query(query, { params: { pid } })
15641571
.toPromise()

apps/selfhosted/src/common/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ const TRAFFIC_COLUMNS = [
110110
'ca',
111111
]
112112

113+
const ALL_COLUMNS = [...TRAFFIC_COLUMNS, 'ev']
114+
113115
const PERFORMANCE_COLUMNS = ['cc', 'rg', 'ct', 'pg', 'dv', 'br']
114116
const ERROR_COLUMNS = ['pg', 'dv', 'br', 'os', 'lc', 'cc', 'rg', 'ct']
115117

@@ -152,4 +154,5 @@ export {
152154
ERROR_COLUMNS,
153155
REDIS_LOG_ERROR_CACHE_KEY,
154156
PID_REGEX,
157+
ALL_COLUMNS,
155158
}

0 commit comments

Comments
 (0)