Repository navigation
Count entry and exit pages per visit on ClickHouse - #4638
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
Without event filters, the ClickHouse entry/exit metrics read website_event_stats_hourly and merged entry_url / exit_url per session (`group by s`). That keeps one entry page (the first visit's) and one exit page (the last visit's) per session, so a page that starts or ends any later visit is never counted. The relational query takes the entry/exit page of every visit (`distinct on (visit_id)`). Group the hourly states by session and visit, so both backends count the same pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@pcbeingused333 is attempting to deploy a commit to the Umami Software Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
[Medium impact] This PR appears safe to merge. SummaryUpdates ClickHouse entry/exit metrics to select a page for each visit, matching the relational query.
Reviews (1) · Last reviewed commit: "Count entry and exit pages per visit on ..." · Reviewed by Greptile |
This branch has not been deployed
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.
Without event filters, the ClickHouse branch of
getPageviewMetricscomputes entry/exit pages fromwebsite_event_stats_hourly, mergingentry_url/exit_urlgrouped by session (group by s). That keeps one entry page (the first visit's) and one exit page (the last visit's) per session. Any page that starts or ends a later visit is never counted, so the Entry and Exit tables are missing pages. The relational branch takes the entry/exit page of every visit (distinct on (visit_id)), so Postgres/MySQL and ClickHouse instances report different pages for the same traffic.How it shows up
Seeded data: the same 37 events (8 visitors, 15 visits) sent through
/api/sendwith fixed timestamps to two instances built fromdev. One runs on PostgreSQL only; the other runs on PostgreSQL + ClickHouse. ThenGET /api/websites/:id/metrics?type=entry|exit:/8,/blog/b6/8/8,/blog/b6/blog/a6,/blog/b6,/3/blog/b5,/3/blog/a6,/blog/b6,/3Six visitors came back for a second visit that started on
/blog/b. ClickHouse dropped those entries, and the exits of their first visits (/blog/a). The "after" column is the patched query run against the same ClickHouse data.With an event filter (for example
path=…), ClickHouse takes the other branch, which already groups per visit. The two backends agree there.Change
group by s→group by s, visit_idforentry/exitin the hourly-table branch.visit_idis part of the table's primary key.Tests
src/queries/sql/pageviews/getPageviewMetrics.test.ts(new), in the style ofgetPageviewExpandedMetrics.test.ts. It checks that the ClickHouse entry/exit query merges per visit. It fails ondevand passes with the change.Also seen in the same comparison, not changed here
/metrics/expanded?type=entry|exit:pageviewsdiffers. The relational query joins only the entry/exit event of each visit (x.target_created_at = website_event.created_at), so/gets 9 pageviews. ClickHouse joins every event of the visit, so/gets 21.visitors/visitsmatch. With apathfilter, the relational expanded query returns nothing, because the filter has to match the entry event itself. ClickHouse returns the entry pages of visits that viewed that path, as the non-expanded endpoint does on both backends. Happy to align one way or the other if you say which is intended./daterange: on ClickHouse,endDatecomes from the hourly table, so it's truncated to the hour (23:00:00vs23:30:30)./revenue/statscomparison.sumisnullon PostgreSQL and0on ClickHouse when the comparison period has no revenue.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.