Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

fix(dashboard): broken funnels on profile_id

Carl-Gerhard Lindesvärdc5d25779c690
diff --git a/packages/db/src/services/funnel.service.ts b/packages/db/src/services/funnel.service.ts
index 101463f07..e56743498 100644
--- a/packages/db/src/services/funnel.service.ts
+++ b/packages/db/src/services/funnel.service.ts
@@ -16,7 +16,7 @@ export class FunnelService {
private getFunnelGroup(group?: string) {
return group === 'profile_id'
- ? [`COALESCE(nullIf(s.profile_id, ''), e.profile_id)`, 'profile_id']
+ ? [`COALESCE(nullIf(s.profile_id, ''), profile_id)`, 'profile_id']
: ['session_id', 'session_id'];
}
@@ -155,12 +155,15 @@ export class FunnelService {
: null;
// Base funnel query with CTEs
- const funnelQuery = clix(this.client).with('funnel', funnelCte);
+ const funnelQuery = clix(this.client);
if (sessionsCte) {
+ funnelCte.join('sessions s', 's.id = session_id');
funnelQuery.with('sessions', sessionsCte);
}
+ funnelQuery.with('funnel', funnelCte);
+
funnelQuery
.select<{
level: number;