fix(analytics): count a bounce from the session's latest version - #723
Merged
Makisuo merged 1 commit intoSep 1, 2026
Merged
Conversation
`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
force-pushed
the
fix/03-analytics-bounce-session-version
branch
from
September 1, 2026 14:51
c82c5b6 to
5420071
Compare
🍁 Maple PR previewWarning Preview cleanup could not be confirmed. The Alchemy teardown outcome was Final commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Third of a five-PR stack, based on #722.
session_replaysis aReplacingMergeTree(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 <= 1reasoning 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_insertis 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.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.