mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +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,
|
referrer_query as query,
|
||||||
count(distinct session_id) as visitors
|
count(distinct session_id) as visitors
|
||||||
from website_event
|
from website_event
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {{websiteId::uuid}}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${dateQuery}
|
${dateQuery}
|
||||||
group by 1, 2
|
group by 1, 2
|
||||||
|
|
|
||||||
|
|
@ -32,15 +32,17 @@ async function relationalQuery(
|
||||||
websiteId,
|
websiteId,
|
||||||
{
|
{
|
||||||
...filters,
|
...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 entryExitQuery = '';
|
||||||
let excludeDomain = '';
|
let excludeDomain = '';
|
||||||
|
|
||||||
if (column === 'referrer_domain') {
|
if (column === 'referrer_domain') {
|
||||||
excludeDomain = `and website_event.referrer_domain != website_event.hostname
|
excludeDomain = `and website_event.referrer_domain != session.hostname
|
||||||
and website_event.referrer_domain is not null`;
|
and website_event.referrer_domain != ''`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'entry' || type === 'exit') {
|
if (type === 'entry' || type === 'exit') {
|
||||||
|
|
@ -53,6 +55,7 @@ async function relationalQuery(
|
||||||
from website_event
|
from website_event
|
||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||||
|
and event_type = {{eventType}}
|
||||||
group by visit_id
|
group by visit_id
|
||||||
) x
|
) x
|
||||||
on x.visit_id = website_event.visit_id
|
on x.visit_id = website_event.visit_id
|
||||||
|
|
@ -63,7 +66,7 @@ async function relationalQuery(
|
||||||
return rawQuery(
|
return rawQuery(
|
||||||
`
|
`
|
||||||
select ${column} x,
|
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
|
from website_event
|
||||||
${joinSession}
|
${joinSession}
|
||||||
${entryExitQuery}
|
${entryExitQuery}
|
||||||
|
|
@ -102,7 +105,7 @@ async function clickhouseQuery(
|
||||||
let entryExitQuery = '';
|
let entryExitQuery = '';
|
||||||
|
|
||||||
if (column === 'referrer_domain') {
|
if (column === 'referrer_domain') {
|
||||||
excludeDomain = `and referrer_domain != hostname and hostname != ''`;
|
excludeDomain = `and referrer_domain != hostname and referrer_domain != ''`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'entry' || type === 'exit') {
|
if (type === 'entry' || type === 'exit') {
|
||||||
|
|
@ -114,6 +117,7 @@ async function clickhouseQuery(
|
||||||
from website_event
|
from website_event
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
|
and event_type = {eventType:UInt32}
|
||||||
group by visit_id) x
|
group by visit_id) x
|
||||||
ON x.visit_id = website_event.visit_id
|
ON x.visit_id = website_event.visit_id
|
||||||
and x.target_created_at = website_event.created_at`;
|
and x.target_created_at = website_event.created_at`;
|
||||||
|
|
@ -126,6 +130,7 @@ async function clickhouseQuery(
|
||||||
${entryExitQuery}
|
${entryExitQuery}
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
|
and event_type = {eventType:UInt32}
|
||||||
${excludeDomain}
|
${excludeDomain}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
group by x
|
group by x
|
||||||
|
|
@ -138,7 +143,7 @@ async function clickhouseQuery(
|
||||||
let columnQuery = `arrayJoin(${column})`;
|
let columnQuery = `arrayJoin(${column})`;
|
||||||
|
|
||||||
if (column === 'referrer_domain') {
|
if (column === 'referrer_domain') {
|
||||||
excludeDomain = `and t != hostname and hostname != ''`;
|
excludeDomain = `and t != hostname and t != ''`;
|
||||||
columnQuery = `session_id s, arrayJoin(${column})`;
|
columnQuery = `session_id s, arrayJoin(${column})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,6 +167,7 @@ async function clickhouseQuery(
|
||||||
from website_event_stats_hourly website_event
|
from website_event_stats_hourly website_event
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
|
and event_type = {eventType:UInt32}
|
||||||
${excludeDomain}
|
${excludeDomain}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${groupByQuery}) as g
|
${groupByQuery}) as g
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue