From f9cf213261f8f8a722b19cabde3d94eccaef29d8 Mon Sep 17 00:00:00 2001 From: Francis Cao Date: Wed, 10 Jun 2026 09:18:25 -0700 Subject: [PATCH] Add Session Activity guards for showing multiple records per result --- src/queries/sql/sessions/getWebsiteSession.ts | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/queries/sql/sessions/getWebsiteSession.ts b/src/queries/sql/sessions/getWebsiteSession.ts index 28a85f969..3ad2c1677 100644 --- a/src/queries/sql/sessions/getWebsiteSession.ts +++ b/src/queries/sql/sessions/getWebsiteSession.ts @@ -70,16 +70,16 @@ async function clickhouseQuery(websiteId: string, sessionId: string) { return rawQuery( ` select id, - websiteId, - distinctId, - browser, - os, - device, - screen, - language, - country, - region, - city, + any(websiteId) as websiteId, + argMax(distinctId, max_time) as distinctId, + argMax(browser, max_time) as browser, + argMax(os, max_time) as os, + argMax(device, max_time) as device, + argMax(screen, max_time) as screen, + argMax(language, max_time) as language, + argMax(country, max_time) as country, + argMax(region, max_time) as region, + argMax(city, max_time) as city, ${getDateStringSQL('min(min_time)')} as firstAt, ${getDateStringSQL('max(max_time)')} as lastAt, uniq(visit_id) visits, @@ -108,7 +108,7 @@ async function clickhouseQuery(websiteId: string, sessionId: string) { and session_id = {sessionId:UUID} and event_type != ${EVENT_TYPE.performance} group by session_id, distinct_id, visit_id, website_id, browser, os, device, screen, language, country, region, city) t - group by id, websiteId, distinctId, browser, os, device, screen, language, country, region, city; + group by id; `, { websiteId, sessionId }, FUNCTION_NAME,