Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Add Session Activity guards for showing multiple records per result

Francis Caof9cf213261f8
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,