mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 20:57:17 +01:00
fix pageview metrics / channel metrics
This commit is contained in:
parent
33662f9f5e
commit
ab08fcb00f
2 changed files with 13 additions and 7 deletions
|
|
@ -21,7 +21,7 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
|||
referrer_query as query,
|
||||
count(distinct session_id) as visitors
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
where website_id = {{websiteId::uuid}}
|
||||
${filterQuery}
|
||||
${dateQuery}
|
||||
group by 1, 2
|
||||
|
|
|
|||
|
|
@ -32,15 +32,17 @@ async function relationalQuery(
|
|||
websiteId,
|
||||
{
|
||||
...filters,
|
||||
eventType: column === 'event_name' ? EVENT_TYPE.customEvent : EVENT_TYPE.pageView,
|
||||
},
|
||||
{ joinSession: SESSION_COLUMNS.includes(type) },
|
||||
{ joinSession: SESSION_COLUMNS.includes(type) || column === 'referrer_domain' },
|
||||
);
|
||||
|
||||
let entryExitQuery = '';
|
||||
let excludeDomain = '';
|
||||
|
||||
if (column === 'referrer_domain') {
|
||||
excludeDomain = `and website_event.referrer_domain != website_event.hostname
|
||||
and website_event.referrer_domain is not null`;
|
||||
excludeDomain = `and website_event.referrer_domain != session.hostname
|
||||
and website_event.referrer_domain != ''`;
|
||||
}
|
||||
|
||||
if (type === 'entry' || type === 'exit') {
|
||||
|
|
@ -53,6 +55,7 @@ async function relationalQuery(
|
|||
from website_event
|
||||
where website_event.website_id = {{websiteId::uuid}}
|
||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||
and event_type = {{eventType}}
|
||||
group by visit_id
|
||||
) x
|
||||
on x.visit_id = website_event.visit_id
|
||||
|
|
@ -63,7 +66,7 @@ async function relationalQuery(
|
|||
return rawQuery(
|
||||
`
|
||||
select ${column} x,
|
||||
${column === 'referrer_domain' ? 'count(distinct session_id)' : 'count(*)'} as y
|
||||
${column === 'referrer_domain' ? 'count(distinct website_event.session_id)' : 'count(*)'} as y
|
||||
from website_event
|
||||
${joinSession}
|
||||
${entryExitQuery}
|
||||
|
|
@ -102,7 +105,7 @@ async function clickhouseQuery(
|
|||
let entryExitQuery = '';
|
||||
|
||||
if (column === 'referrer_domain') {
|
||||
excludeDomain = `and referrer_domain != hostname and hostname != ''`;
|
||||
excludeDomain = `and referrer_domain != hostname and referrer_domain != ''`;
|
||||
}
|
||||
|
||||
if (type === 'entry' || type === 'exit') {
|
||||
|
|
@ -114,6 +117,7 @@ async function clickhouseQuery(
|
|||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
and event_type = {eventType:UInt32}
|
||||
group by visit_id) x
|
||||
ON x.visit_id = website_event.visit_id
|
||||
and x.target_created_at = website_event.created_at`;
|
||||
|
|
@ -126,6 +130,7 @@ async function clickhouseQuery(
|
|||
${entryExitQuery}
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
and event_type = {eventType:UInt32}
|
||||
${excludeDomain}
|
||||
${filterQuery}
|
||||
group by x
|
||||
|
|
@ -138,7 +143,7 @@ async function clickhouseQuery(
|
|||
let columnQuery = `arrayJoin(${column})`;
|
||||
|
||||
if (column === 'referrer_domain') {
|
||||
excludeDomain = `and t != hostname and hostname != ''`;
|
||||
excludeDomain = `and t != hostname and t != ''`;
|
||||
columnQuery = `session_id s, arrayJoin(${column})`;
|
||||
}
|
||||
|
||||
|
|
@ -162,6 +167,7 @@ async function clickhouseQuery(
|
|||
from website_event_stats_hourly website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
and event_type = {eventType:UInt32}
|
||||
${excludeDomain}
|
||||
${filterQuery}
|
||||
${groupByQuery}) as g
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue