mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 15:23:38 +01:00
Merge branch 'dev' of https://github.com/mikecao/umami into dev
This commit is contained in:
commit
f12291eaf2
@ -465,15 +465,21 @@ export function getEventMetrics(
|
|||||||
filters = {},
|
filters = {},
|
||||||
) {
|
) {
|
||||||
const params = [website_id, start_at, end_at];
|
const params = [website_id, start_at, end_at];
|
||||||
const { url } = filters;
|
const { url, event_type } = filters;
|
||||||
|
|
||||||
let urlFilter = '';
|
let urlFilter = '';
|
||||||
|
let eventTypeFilter = '';
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
urlFilter = `and url=$${params.length + 1}`;
|
urlFilter = `and url=$${params.length + 1}`;
|
||||||
params.push(decodeURIComponent(url));
|
params.push(decodeURIComponent(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event_type) {
|
||||||
|
eventTypeFilter = `and event_type=$${params.length + 1}`;
|
||||||
|
params.push(event_type);
|
||||||
|
}
|
||||||
|
|
||||||
return rawQuery(
|
return rawQuery(
|
||||||
`
|
`
|
||||||
select
|
select
|
||||||
@ -484,6 +490,7 @@ export function getEventMetrics(
|
|||||||
where website_id=$1
|
where website_id=$1
|
||||||
and created_at between $2 and $3
|
and created_at between $2 and $3
|
||||||
${urlFilter}
|
${urlFilter}
|
||||||
|
${eventTypeFilter}
|
||||||
group by 1, 2
|
group by 1, 2
|
||||||
order by 2
|
order by 2
|
||||||
`,
|
`,
|
||||||
|
@ -11,7 +11,7 @@ export default async (req, res) => {
|
|||||||
return unauthorized(res);
|
return unauthorized(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { id, start_at, end_at, unit, tz, url } = req.query;
|
const { id, start_at, end_at, unit, tz, url, event_type } = req.query;
|
||||||
|
|
||||||
if (!moment.tz.zone(tz) || !unitTypes.includes(unit)) {
|
if (!moment.tz.zone(tz) || !unitTypes.includes(unit)) {
|
||||||
return badRequest(res);
|
return badRequest(res);
|
||||||
@ -21,7 +21,10 @@ export default async (req, res) => {
|
|||||||
const startDate = new Date(+start_at);
|
const startDate = new Date(+start_at);
|
||||||
const endDate = new Date(+end_at);
|
const endDate = new Date(+end_at);
|
||||||
|
|
||||||
const events = await getEventMetrics(websiteId, startDate, endDate, tz, unit, { url });
|
const events = await getEventMetrics(websiteId, startDate, endDate, tz, unit, {
|
||||||
|
url,
|
||||||
|
event_type,
|
||||||
|
});
|
||||||
|
|
||||||
return ok(res, events);
|
return ok(res, events);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user