mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 02:06:19 +01:00
Allow filtering of events with url.
This commit is contained in:
parent
1cff704379
commit
f69dbaeaf6
@ -64,7 +64,7 @@ export function getFilterQuery(table, filters = {}, params = []) {
|
||||
|
||||
switch (key) {
|
||||
case 'url':
|
||||
if (table === 'session' || table === 'pageview') {
|
||||
if (table === 'pageview' || table === 'event') {
|
||||
arr.push(`and ${table}.${key}=$${params.length + 1}`);
|
||||
params.push(decodeURIComponent(value));
|
||||
}
|
||||
@ -110,11 +110,11 @@ export function getFilterQuery(table, filters = {}, params = []) {
|
||||
}
|
||||
|
||||
export function parseFilters(table, filters = {}, params = []) {
|
||||
const { domain, url, referrer, os, browser, device, country, event_type } = filters;
|
||||
const { domain, url, event_url, referrer, os, browser, device, country, event_type } = filters;
|
||||
|
||||
const pageviewFilters = { domain, url, referrer };
|
||||
const sessionFilters = { os, browser, device, country };
|
||||
const eventFilters = { event_type };
|
||||
const eventFilters = { url: event_url, event_type };
|
||||
|
||||
return {
|
||||
pageviewFilters,
|
||||
@ -502,8 +502,11 @@ export function getSessionMetrics(website_id, start_at, end_at, field, filters =
|
||||
|
||||
export function getPageviewMetrics(website_id, start_at, end_at, field, table, filters = {}) {
|
||||
const params = [website_id, start_at, end_at];
|
||||
console.log({ table, filters });
|
||||
const { pageviewQuery, sessionQuery, joinSession } = parseFilters(table, filters, params);
|
||||
const { pageviewQuery, sessionQuery, eventQuery, joinSession } = parseFilters(
|
||||
table,
|
||||
filters,
|
||||
params,
|
||||
);
|
||||
|
||||
return rawQuery(
|
||||
`
|
||||
@ -514,6 +517,7 @@ export function getPageviewMetrics(website_id, start_at, end_at, field, table, f
|
||||
and ${table}.created_at between $2 and $3
|
||||
${pageviewQuery}
|
||||
${joinSession && sessionQuery}
|
||||
${eventQuery}
|
||||
group by 1
|
||||
order by 2 desc
|
||||
`,
|
||||
|
@ -83,12 +83,13 @@ export default async (req, res) => {
|
||||
|
||||
const data = await getPageviewMetrics(websiteId, startDate, endDate, column, table, {
|
||||
domain,
|
||||
url: type !== 'url' ? url : undefined,
|
||||
url: type !== 'url' && table !== 'event' ? url : undefined,
|
||||
referrer: type !== 'referrer' ? referrer : undefined,
|
||||
os: type !== 'os' ? os : undefined,
|
||||
browser: type !== 'browser' ? browser : undefined,
|
||||
device: type !== 'device' ? device : undefined,
|
||||
country: type !== 'country' ? country : undefined,
|
||||
event_url: type !== 'url' && table === 'event' ? url : undefined,
|
||||
});
|
||||
|
||||
return ok(res, data);
|
||||
|
Loading…
Reference in New Issue
Block a user