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.

Merge branch 'dev' into fix/pages-url-query

Francis Cao73c045118bc9
diff --cc src/queries/sql/pageviews/getPageviewExpandedMetrics.ts
index c16c91269,a0c489ac8..5561cdaf7
--- a/src/queries/sql/pageviews/getPageviewExpandedMetrics.ts
+++ b/src/queries/sql/pageviews/getPageviewExpandedMetrics.ts
@@@ -48,10 -49,9 +49,10 @@@ async function relationalQuery
let entryExitQuery = '';
let excludeDomain = '';
+ const isPathType = type === 'path' || type === 'entry' || type === 'exit';
if (column === 'referrer_domain') {
- excludeDomain = `and website_event.referrer_domain != website_event.hostname
+ excludeDomain = `and website_event.referrer_domain != regexp_replace(website_event.hostname, '^www.', '')
and website_event.referrer_domain != ''`;
if (type === 'domain') {
column = toPostgresGroupedReferrer(GROUPED_DOMAINS);
@@@ -95,7 -87,7 +96,7 @@@
sum(${getTimestampDiffSQL('t.min_time', 't.max_time')}) as "totaltime"
from (
select
- ${selectColumn} as name,
- ${column} as "name",
++ ${selectColumn} as "name",
website_event.session_id,
website_event.visit_id,
count(*) as "c",
@@@ -103,17 -95,18 +104,18 @@@
max(website_event.created_at) as "max_time"
from website_event
${cohortQuery}
- ${joinSessionQuery}
- ${entryExitQuery}
+ ${excludeBounceQuery}
+ ${joinSessionQuery}
+ ${entryExitQuery}
where website_event.website_id = {{websiteId::uuid}}
and website_event.created_at between {{startDate}} and {{endDate}}
- and website_event.event_type != 2
+ and website_event.event_type NOT IN (2, 5)
${excludeDomain}
${filterQuery}
- group by ${column}, website_event.session_id, website_event.visit_id
+ group by ${groupByColumn}, website_event.session_id, website_event.visit_id
) as t
where name != ''
- group by name
+ group by name
order by visitors desc, visits desc
limit ${limit}
offset ${offset}
@@@ -159,13 -149,9 +161,13 @@@ async function clickhouseQuery
from website_event
where website_id = {websiteId:UUID}
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
- and event_type != 2
+ and event_type NOT IN (2, 5)
group by visit_id) x
ON x.visit_id = website_event.visit_id`;
+
+ selectColumn = `if(x.url_query != '', concat(x.url_path, '?', x.url_query), x.url_path)`;
+ } else if (isPathType) {
+ selectColumn = `if(url_query != '', concat(url_path, '?', url_query), url_path)`;
}
return rawQuery(
diff --cc src/queries/sql/pageviews/getPageviewMetrics.ts
index a5d26f66e,a7a705f1d..9d6120bed
--- a/src/queries/sql/pageviews/getPageviewMetrics.ts
+++ b/src/queries/sql/pageviews/getPageviewMetrics.ts
@@@ -44,10 -45,9 +45,10 @@@ async function relationalQuery
let entryExitQuery = '';
let excludeDomain = '';
+ const isPathType = type === 'path' || type === 'entry' || type === 'exit';
if (column === 'referrer_domain') {
- excludeDomain = `and website_event.referrer_domain != website_event.hostname
+ excludeDomain = `and website_event.referrer_domain != regexp_replace(website_event.hostname, '^www.', '')
and website_event.referrer_domain != ''`;
}
@@@ -136,13 -128,9 +139,13 @@@ async function clickhouseQuery
from website_event
where website_id = {websiteId:UUID}
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
- and event_type != 2
+ and event_type NOT IN (2, 5)
group by visit_id) x
ON x.visit_id = website_event.visit_id`;
+
+ selectColumn = `if(x.url_query != '', concat(x.url_path, '?', x.url_query), x.url_path)`;
+ } else if (isPathType) {
+ selectColumn = `if(url_query != '', concat(url_path, '?', url_query), url_path)`;
}
sql = `