mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 15:47:13 +01:00
URL filter functionality.
This commit is contained in:
parent
6bc371352c
commit
4fded49b03
27 changed files with 251 additions and 117 deletions
|
|
@ -11,7 +11,7 @@ export default async (req, res) => {
|
|||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const { id, start_at, end_at, unit, tz } = req.query;
|
||||
const { id, start_at, end_at, unit, tz, url } = req.query;
|
||||
|
||||
if (!moment.tz.zone(tz) || !unitTypes.includes(unit)) {
|
||||
return badRequest(res);
|
||||
|
|
@ -21,7 +21,7 @@ export default async (req, res) => {
|
|||
const startDate = new Date(+start_at);
|
||||
const endDate = new Date(+end_at);
|
||||
|
||||
const events = await getEvents(websiteId, startDate, endDate, tz, unit);
|
||||
const events = await getEvents(websiteId, startDate, endDate, tz, unit, url);
|
||||
|
||||
return ok(res, events);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@ export default async (req, res) => {
|
|||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const { id, start_at, end_at } = req.query;
|
||||
const { id, start_at, end_at, url } = req.query;
|
||||
|
||||
const websiteId = +id;
|
||||
const startDate = new Date(+start_at);
|
||||
const endDate = new Date(+end_at);
|
||||
|
||||
const metrics = await getMetrics(websiteId, startDate, endDate);
|
||||
const metrics = await getMetrics(websiteId, startDate, endDate, url);
|
||||
|
||||
const stats = Object.keys(metrics[0]).reduce((obj, key) => {
|
||||
obj[key] = Number(metrics[0][key]) || 0;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export default async (req, res) => {
|
|||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const { id, start_at, end_at, unit, tz } = req.query;
|
||||
const { id, start_at, end_at, unit, tz, url } = req.query;
|
||||
|
||||
const websiteId = +id;
|
||||
const startDate = new Date(+start_at);
|
||||
|
|
@ -22,8 +22,8 @@ export default async (req, res) => {
|
|||
}
|
||||
|
||||
const [pageviews, uniques] = await Promise.all([
|
||||
getPageviews(websiteId, startDate, endDate, tz, unit, '*'),
|
||||
getPageviews(websiteId, startDate, endDate, tz, unit, 'distinct session_id'),
|
||||
getPageviews(websiteId, startDate, endDate, tz, unit, '*', url),
|
||||
getPageviews(websiteId, startDate, endDate, tz, unit, 'distinct session_id', url),
|
||||
]);
|
||||
|
||||
return ok(res, { pageviews, uniques });
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ export default async (req, res) => {
|
|||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const { id, type, start_at, end_at, domain } = req.query;
|
||||
const { id, type, start_at, end_at, domain, url } = req.query;
|
||||
|
||||
if (domain && !DOMAIN_REGEX.test(domain)) {
|
||||
return badRequest(res);
|
||||
|
|
@ -42,7 +42,7 @@ export default async (req, res) => {
|
|||
const endDate = new Date(+end_at);
|
||||
|
||||
if (sessionColumns.includes(type)) {
|
||||
const data = await getSessionMetrics(websiteId, startDate, endDate, type);
|
||||
const data = await getSessionMetrics(websiteId, startDate, endDate, type, url);
|
||||
|
||||
return ok(res, data);
|
||||
}
|
||||
|
|
@ -55,6 +55,7 @@ export default async (req, res) => {
|
|||
getColumn(type),
|
||||
getTable(type),
|
||||
domain,
|
||||
url,
|
||||
);
|
||||
|
||||
return ok(res, data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue