Merge pull request #4139 from seojcarlos/fix/pages-url-query
fix: include url_query in pages report display
This commit is contained in:
@@ -49,6 +49,7 @@ 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 != regexp_replace(website_event.hostname, '^www.', '')
|
||||
@@ -76,6 +77,14 @@ async function relationalQuery(
|
||||
`;
|
||||
}
|
||||
|
||||
const selectColumn = isPathType
|
||||
? `case when website_event.url_query != '' then website_event.url_path || '?' || website_event.url_query else website_event.url_path end`
|
||||
: column;
|
||||
|
||||
const groupByColumn = isPathType
|
||||
? `case when website_event.url_query != '' then website_event.url_path || '?' || website_event.url_query else website_event.url_path end`
|
||||
: column;
|
||||
|
||||
return rawQuery(
|
||||
`
|
||||
select
|
||||
@@ -87,7 +96,7 @@ async function relationalQuery(
|
||||
sum(${getTimestampDiffSQL('t.min_time', 't.max_time')}) as "totaltime"
|
||||
from (
|
||||
select
|
||||
${column} as "name",
|
||||
${selectColumn} as "name",
|
||||
website_event.session_id,
|
||||
website_event.visit_id,
|
||||
count(*) as "c",
|
||||
@@ -103,10 +112,10 @@ async function relationalQuery(
|
||||
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}
|
||||
@@ -131,27 +140,34 @@ async function clickhouseQuery(
|
||||
|
||||
let excludeDomain = '';
|
||||
let entryExitQuery = '';
|
||||
const isPathType = type === 'path' || type === 'entry' || type === 'exit';
|
||||
let selectColumn = column;
|
||||
|
||||
if (column === 'referrer_domain') {
|
||||
excludeDomain = `and referrer_domain != hostname and referrer_domain != ''`;
|
||||
if (type === 'domain') {
|
||||
column = toClickHouseGroupedReferrer(GROUPED_DOMAINS);
|
||||
selectColumn = column;
|
||||
}
|
||||
}
|
||||
|
||||
if (type === 'entry' || type === 'exit') {
|
||||
const aggregrate = type === 'entry' ? 'argMin' : 'argMax';
|
||||
column = `x.${column}`;
|
||||
|
||||
entryExitQuery = `
|
||||
JOIN (select visit_id,
|
||||
${aggregrate}(url_path, created_at) url_path
|
||||
${aggregrate}(url_path, created_at) url_path,
|
||||
${aggregrate}(url_query, created_at) url_query
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
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(
|
||||
@@ -165,7 +181,7 @@ async function clickhouseQuery(
|
||||
sum(max_time-min_time) as "totaltime"
|
||||
from (
|
||||
select
|
||||
${column} name,
|
||||
${selectColumn} name,
|
||||
session_id,
|
||||
visit_id,
|
||||
count(*) c,
|
||||
@@ -183,7 +199,7 @@ async function clickhouseQuery(
|
||||
${filterQuery}
|
||||
group by name, session_id, visit_id
|
||||
) as t
|
||||
group by name
|
||||
group by name
|
||||
order by visitors desc, visits desc
|
||||
limit ${limit}
|
||||
offset ${offset}
|
||||
|
||||
@@ -45,6 +45,7 @@ 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 != regexp_replace(website_event.hostname, '^www.', '')
|
||||
@@ -53,13 +54,13 @@ async function relationalQuery(
|
||||
|
||||
if (type === 'entry' || type === 'exit') {
|
||||
const order = type === 'entry' ? 'asc' : 'desc';
|
||||
column = `x.${column}`;
|
||||
|
||||
entryExitQuery = `
|
||||
join (
|
||||
select distinct on (visit_id)
|
||||
visit_id,
|
||||
url_path
|
||||
url_path,
|
||||
url_query
|
||||
from website_event
|
||||
where website_event.website_id = {{websiteId::uuid}}
|
||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||
@@ -68,11 +69,19 @@ async function relationalQuery(
|
||||
) x
|
||||
on x.visit_id = website_event.visit_id
|
||||
`;
|
||||
|
||||
column = isPathType
|
||||
? `case when x.url_query != '' then x.url_path || '?' || x.url_query else x.url_path end`
|
||||
: `x.${FILTER_COLUMNS[type] || type}`;
|
||||
}
|
||||
|
||||
const selectColumn = isPathType && type !== 'entry' && type !== 'exit'
|
||||
? `case when website_event.url_query != '' then website_event.url_path || '?' || website_event.url_query else website_event.url_path end`
|
||||
: column;
|
||||
|
||||
return rawQuery(
|
||||
`
|
||||
select ${column} x,
|
||||
select ${selectColumn} x,
|
||||
count(distinct website_event.session_id) as y
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
@@ -110,9 +119,11 @@ async function clickhouseQuery(
|
||||
|
||||
let sql = '';
|
||||
let excludeDomain = '';
|
||||
const isPathType = type === 'path' || type === 'entry' || type === 'exit';
|
||||
|
||||
if (EVENT_COLUMNS.some(item => Object.keys(filters).includes(item))) {
|
||||
let entryExitQuery = '';
|
||||
let selectColumn = column;
|
||||
|
||||
if (column === 'referrer_domain') {
|
||||
excludeDomain = `and referrer_domain != hostname and referrer_domain != ''`;
|
||||
@@ -120,21 +131,25 @@ async function clickhouseQuery(
|
||||
|
||||
if (type === 'entry' || type === 'exit') {
|
||||
const aggregrate = type === 'entry' ? 'argMin' : 'argMax';
|
||||
column = `x.${column}`;
|
||||
|
||||
entryExitQuery = `
|
||||
JOIN (select visit_id,
|
||||
${aggregrate}(url_path, created_at) url_path
|
||||
${aggregrate}(url_path, created_at) url_path,
|
||||
${aggregrate}(url_query, created_at) url_query
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
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 = `
|
||||
select ${column} x,
|
||||
select ${selectColumn} x,
|
||||
uniq(website_event.session_id) as y
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
@@ -175,7 +190,7 @@ async function clickhouseQuery(
|
||||
select g.t as x,
|
||||
uniq(s) as y
|
||||
from (
|
||||
select session_id s,
|
||||
select session_id s,
|
||||
${columnQuery} as t
|
||||
from website_event_stats_hourly as website_event
|
||||
${cohortQuery}
|
||||
|
||||
Reference in New Issue
Block a user