Skip to content

fix(analytics): keep sessionless events out of session journeys - #601

Merged
lindesvard merged 1 commit into
Openpanel-dev:mainfrom
grootbro:fix/sessionless-analytics-575
Nov 2, 2026
Merged

lindesvard merged 1 commit into
Openpanel-dev:mainfrom
grootbro:fix/sessionless-analytics-575

Conversation

@grootbro

@grootbro grootbro commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Session-grouped analytics treat every event with session_id = '' as one session. Unrelated server users can complete a funnel together, appear in one flow/journey, and accumulate a large groupArray. Page duration windows also measure time between unrelated sessionless views.

Exclude empty session IDs before session-grouped funnel/conversion scans, flow path scans and their start/end anchor CTEs, and user-journey aggregation. Keep profile grouping eligible for sessionless events. Page tables and page-filtered metrics retain these views and visitors, but assign their duration zero; the page filter still applies after the duration window.

Fixes #575. No migration or configuration change is required. The separate session-count and session.performed_event follow-ups listed in the issue remain outside this fix.

Validation on an isolated native ClickHouse 26.1.3.52 server (the version pinned by the repository's local Compose file):

  • Executed the old and new parameterized builders on identical synthetic fixtures and saved result comparisons. Session conversions change from 2 to the correct 1; profile funnel/conversion results remain identical. False flow/journey paths disappear, while pageview/visitor counts remain unchanged and sessionless page durations become zero.
  • All 13 new integration tests pass; 11 fail on the old queries. Includes after/before/between flows, page filtering after the window, valid browser paths, and 100,000 sessionless views that previously formed one journey.
  • All 60 existing SQL tests across funnel, overview, pages and raw-filter handling pass against ClickHouse. Core typecheck, scoped Biome and git diff --check pass.
  • Independent static review found no P0–P2 issues in the supplied diff and source context.
  • No full build, application deployment or production database access. Verification was on a single node; no distributed-cluster claim is made, and existing distributed join semantics are unchanged.

Summary by CodeRabbit

  • Bug Fixes
    • Session-based conversion, funnel, and flow reports now exclude events that lack a session, preventing them from being grouped into session paths.
    • User journeys no longer connect unrelated events that have no session.
    • Sessionless pageviews continue to count in page metrics, but contribute zero elapsed time.

Exclude empty session ids from session-grouped funnels, conversions and flow paths so unrelated server events cannot become one synthetic session. Keep profile grouping and pageview/visitor counts, and assign zero page duration when no session is available. No migration or self-hosted configuration change is required.
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c6aedba5-6dd7-4d73-8847-3e5c771eba0b
📥 Commits

Reviewing files that changed from the base of the PR and between de94ef9 and e86e6e4.

📒 Files selected for processing: 6
  • packages/core/src/modules/chart/src/conversion.sql.ts
  • packages/core/src/modules/chart/src/funnel.sql.ts
  • packages/core/src/modules/chart/src/sankey.sql.ts
  • packages/core/src/modules/overview/src/overview.sql.ts
  • packages/core/src/modules/overview/src/pages.sql.ts
  • packages/core/test/sessionless-analytics.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

📝 Walkthrough

Analytics queries now distinguish events with empty session IDs from events in browser sessions. Session-grouped charts and journeys exclude sessionless events. Sessionless page views remain counted but receive zero duration.

Changes: Sessionless analytics

Layer / File(s) Summary
Session-grouped chart queries
packages/core/src/modules/chart/src/conversion.sql.ts, packages/core/src/modules/chart/src/funnel.sql.ts, packages/core/src/modules/chart/src/sankey.sql.ts, packages/core/test/sessionless-analytics.test.ts
Conversion and funnel queries filter empty session IDs when grouping by session. Sankey queries exclude empty session IDs from anchor selection and session paths. Integration tests cover grouping and flow results.
Overview journeys and page durations
packages/core/src/modules/overview/src/overview.sql.ts, packages/core/src/modules/overview/src/pages.sql.ts, packages/core/test/sessionless-analytics.test.ts
Journey queries exclude events with empty session IDs. Page duration queries assign zero duration to sessionless views. Integration tests cover journey transitions, page durations, page-filtered metrics, and 100,000 sessionless views.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: lindesvard

Merge Risk: ⚪ Minimal · up to e86e6

No confirmed issue blocks merging after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main fix: excluding sessionless events from session-based journeys. It does not mention related funnel, conversion, flow, and page-duration changes, but it remains conc…
Linked Issues check Passed Issue #575 is directly linked and has coding requirements. The diff adds the empty-session filter only for session-grouped funnel and conversion scans in funnel.sql.ts and conversion.sql.ts. It ad…
Out of Scope Changes check Passed The changes stay within Issue #575. Production changes are limited to the affected funnel, conversion, Sankey, overview journey, and page-duration query builders. The new integration test file verifie…
Docstring Coverage Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 6 files.
Full details: Title check

Explanation

The title clearly describes the main fix: excluding sessionless events from session-based journeys. It does not mention related funnel, conversion, flow, and page-duration changes, but it remains concise and accurately represents the primary objective.

Full details: Linked Issues check

Explanation

Issue #575 is directly linked and has coding requirements. The diff adds the empty-session filter only for session-grouped funnel and conversion scans in funnel.sql.ts and conversion.sql.ts. It adds the filter to Sankey path scans and anchor CTEs in sankey.sql.ts. It excludes empty sessions from user-journey event selection in overview.sql.ts. It sets sessionless page-view duration to zero in overview.sql.ts and pages.sql.ts while retaining rows and applying page filters after duration calculation. Profile-grouped funnel and conversion queries keep sessionless events eligible. The added integration tests cover these behaviors, including after, before, and between flows, page filtering, and 100,000 sessionless views.

Full details: Out of Scope Changes check

Explanation

The changes stay within Issue #575. Production changes are limited to the affected funnel, conversion, Sankey, overview journey, and page-duration query builders. The new integration test file verifies the requested behavior and is supporting scope. The diff does not change the stated out-of-scope session counts, realtime map behavior, or session.performed_event behavior. No migration or configuration change is included.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lindesvard
lindesvard merged commit 1418e31 into Openpanel-dev:main Nov 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session-grouped queries treat every sessionless event as one session (wrong results, ClickHouse OOM)

2 participants