fix(queries): count custom events correctly on the hourly rollup, trying to address greptile findings

`website_event_stats_hourly` sets `views` to
`sumIf(1, event_type NOT IN (2, 5))`, so `views` is 0 on custom event
rows and the `events_count` join was summing zeroes. Switched it to
`sum(length(event_name))`, which is how `getWebsiteSessionStats`
already counts custom events on that table.

Also dropped the `getEventExpandedMetrics` change from the previous
commit. That report is filtered to custom events, so every visit it
lists has already fired at least one, and its `bounces` column counts
visits where the event fired exactly once rather than visits with a
single pageview. The threshold rule does not apply there, so the query
is left untouched.
This commit is contained in:
Federico D'Eredità committed 2026-07-26 18:49:59 +02:00
1 parent 82a5a12208
commit 92e9b276d2
2 files changed
+7 -24

No files matched your search

+1 -1
View File
@@ -153,7 +153,7 @@ async function clickhouseQuery(
group by session_id, visit_id
) as t
left join (
select session_id, visit_id, toUInt32(sumIf(views, event_type = ${EVENT_TYPE.customEvent})) as events_count
select session_id, visit_id, toUInt32(sum(length(event_name))) as events_count
from website_event_stats_hourly
where website_id = {websiteId:UUID}
and created_at between {startDate:DateTime64} and {endDate:DateTime64}