Skip to content

fix(analytics): count a bounce from the session's latest version - #723

Merged
Makisuo merged 1 commit into
fix/02-web-client-request-timeoutfrom
fix/03-analytics-bounce-session-version
Sep 1, 2026
Merged

fix(analytics): count a bounce from the session's latest version#723
Makisuo merged 1 commit into
fix/02-web-client-request-timeoutfrom
fix/03-analytics-bounce-session-version

Conversation

@Makisuo

@Makisuo Makisuo commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Third of a five-PR stack, based on #722.

session_replays is a ReplacingMergeTree(Version): a session's start row and its end row coexist until a merge. uniqIf(SessionId, PageViews <= 1) counts a session whenever any visible version matches, so a finished multi-page session was a bounce for as long as its start row survived. Recent traffic reported a bounce rate approaching 100%.

Counting it as "identified, minus those with a page view above one" holds only when no version reports more than one, which is the intended definition. The PageViews <= 1 reasoning is preserved: a session still on its start row is a bounce rather than vanishing from both sides of the ratio. Both the summary and the per-bucket query change together, as their doc comments require.

The e2e suite could not have caught this

optimize_on_insert is on by default, so the suite's single seeding INSERT collapsed its v1/v2 pairs before anything read them — a suite built entirely around un-merged duplicates was asserting over pre-deduplicated rows. It now seeds one INSERT per version with merges held off, and asserts the bounce count directly rather than only raw-vs-rollup parity, which is equally satisfied when both sides are wrong.

Verified against a real ClickHouse 26.2: 76 tests pass with the fix; the new assertion reports 3 bounces out of 3 identified sessions without it.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

`session_replays` is a `ReplacingMergeTree(Version)`: a session's start row and
its end row coexist until a merge. `uniqIf(SessionId, PageViews <= 1)` counts a
session whenever ANY visible version matches, so a finished multi-page session
was a bounce for as long as its start row survived — recent traffic reported a
bounce rate approaching 100%.

Counting it as "identified, minus those with a page view above one" holds only
when no version reports more than one, which is the intended definition. The
`PageViews <= 1` reasoning is preserved: a session still on its start row is a
bounce rather than vanishing from both sides of the ratio.

The e2e suite could not have caught this. `optimize_on_insert` is on by default,
so its single seeding INSERT collapsed the v1/v2 pairs before anything read
them, leaving a suite built around un-merged duplicates asserting over
pre-deduplicated rows. It now seeds one INSERT per version with merges held off,
and asserts the bounce count directly — parity between two sources is equally
satisfied when both are wrong.
@Makisuo
Makisuo force-pushed the fix/03-analytics-bounce-session-version branch from c82c5b6 to 5420071 Compare September 1, 2026 14:51
@Makisuo
Makisuo merged commit 3526911 into main Sep 1, 2026
33 checks passed
@Makisuo
Makisuo deleted the fix/03-analytics-bounce-session-version branch September 1, 2026 15:33
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

🍁 Maple PR preview

Warning

Preview cleanup could not be confirmed. The Alchemy teardown outcome was skipped.

Final commit 5420071 · View workflow run

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.

1 participant