Merge branch 'dev' of https://github.com/umami-software/umami into dev
This commit is contained in:
@@ -70,16 +70,16 @@ async function clickhouseQuery(websiteId: string, sessionId: string) {
|
|||||||
return rawQuery(
|
return rawQuery(
|
||||||
`
|
`
|
||||||
select id,
|
select id,
|
||||||
websiteId,
|
any(websiteId) as websiteId,
|
||||||
distinctId,
|
argMax(distinctId, max_time) as distinctId,
|
||||||
browser,
|
argMax(browser, max_time) as browser,
|
||||||
os,
|
argMax(os, max_time) as os,
|
||||||
device,
|
argMax(device, max_time) as device,
|
||||||
screen,
|
argMax(screen, max_time) as screen,
|
||||||
language,
|
argMax(language, max_time) as language,
|
||||||
country,
|
argMax(country, max_time) as country,
|
||||||
region,
|
argMax(region, max_time) as region,
|
||||||
city,
|
argMax(city, max_time) as city,
|
||||||
${getDateStringSQL('min(min_time)')} as firstAt,
|
${getDateStringSQL('min(min_time)')} as firstAt,
|
||||||
${getDateStringSQL('max(max_time)')} as lastAt,
|
${getDateStringSQL('max(max_time)')} as lastAt,
|
||||||
uniq(visit_id) visits,
|
uniq(visit_id) visits,
|
||||||
@@ -108,7 +108,7 @@ async function clickhouseQuery(websiteId: string, sessionId: string) {
|
|||||||
and session_id = {sessionId:UUID}
|
and session_id = {sessionId:UUID}
|
||||||
and event_type != ${EVENT_TYPE.performance}
|
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 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 },
|
{ websiteId, sessionId },
|
||||||
FUNCTION_NAME,
|
FUNCTION_NAME,
|
||||||
|
|||||||
@@ -100,22 +100,22 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters) {
|
|||||||
sql = `
|
sql = `
|
||||||
select
|
select
|
||||||
session_id as id,
|
session_id as id,
|
||||||
website_id as websiteId,
|
any(website_id) as websiteId,
|
||||||
hostname,
|
argMax(hostname, created_at) as hostname,
|
||||||
browser,
|
argMax(browser, created_at) as browser,
|
||||||
os,
|
argMax(os, created_at) as os,
|
||||||
device,
|
argMax(device, created_at) as device,
|
||||||
screen,
|
argMax(screen, created_at) as screen,
|
||||||
language,
|
argMax(language, created_at) as language,
|
||||||
country,
|
argMax(country, created_at) as country,
|
||||||
region,
|
argMax(region, created_at) as region,
|
||||||
city,
|
argMax(city, created_at) as city,
|
||||||
${getDateStringSQL('min(created_at)')} as firstAt,
|
${getDateStringSQL('min(created_at)')} as firstAt,
|
||||||
${getDateStringSQL('max(created_at)')} as lastAt,
|
${getDateStringSQL('max(created_at)')} as lastAt,
|
||||||
uniq(visit_id) as visits,
|
uniq(visit_id) as visits,
|
||||||
sumIf(1, event_type = 1) as views,
|
sumIf(1, event_type = 1) as views,
|
||||||
sumIf(1, event_type = 2) as events,
|
sumIf(1, event_type = 2) as events,
|
||||||
lastAt as createdAt
|
max(created_at) as createdAt
|
||||||
from website_event
|
from website_event
|
||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
@@ -123,29 +123,29 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters) {
|
|||||||
${dateQuery}
|
${dateQuery}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${searchQuery}
|
${searchQuery}
|
||||||
group by session_id, website_id, hostname, browser, os, device, screen, language, country, region, city
|
group by session_id
|
||||||
order by lastAt desc
|
order by lastAt desc
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
sql = `
|
sql = `
|
||||||
select
|
select
|
||||||
session_id as id,
|
session_id as id,
|
||||||
website_id as websiteId,
|
any(website_id) as websiteId,
|
||||||
arrayFirst(x -> 1, hostname) hostname,
|
argMax(arrayFirst(x -> 1, hostname), max_time) as hostname,
|
||||||
browser,
|
argMax(browser, max_time) as browser,
|
||||||
os,
|
argMax(os, max_time) as os,
|
||||||
device,
|
argMax(device, max_time) as device,
|
||||||
screen,
|
argMax(screen, max_time) as screen,
|
||||||
language,
|
argMax(language, max_time) as language,
|
||||||
country,
|
argMax(country, max_time) as country,
|
||||||
region,
|
argMax(region, max_time) as region,
|
||||||
city,
|
argMax(city, max_time) as city,
|
||||||
${getDateStringSQL('min(min_time)')} as firstAt,
|
${getDateStringSQL('min(min_time)')} as firstAt,
|
||||||
${getDateStringSQL('max(max_time)')} as lastAt,
|
${getDateStringSQL('max(max_time)')} as lastAt,
|
||||||
uniq(visit_id) as visits,
|
uniq(visit_id) as visits,
|
||||||
sumIf(views, event_type = 1) as views,
|
sumIf(views, event_type = 1) as views,
|
||||||
sum(length(event_name)) as events,
|
sum(length(event_name)) as events,
|
||||||
lastAt as createdAt
|
max(max_time) as createdAt
|
||||||
from website_event_stats_hourly as website_event
|
from website_event_stats_hourly as website_event
|
||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
@@ -153,7 +153,7 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters) {
|
|||||||
${dateQuery}
|
${dateQuery}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${searchQuery}
|
${searchQuery}
|
||||||
group by session_id, website_id, hostname, browser, os, device, screen, language, country, region, city
|
group by session_id
|
||||||
order by lastAt desc
|
order by lastAt desc
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user