mirror of
https://github.com/umami-software/umami.git
synced 2026-02-11 16:17:13 +01:00
More updates to event data report.
This commit is contained in:
parent
7c467db27e
commit
2f4d669836
13 changed files with 202 additions and 173 deletions
|
|
@ -4,27 +4,39 @@ import { NextApiRequestQueryBody } from 'lib/types';
|
|||
import { NextApiResponse } from 'next';
|
||||
import { ok, methodNotAllowed, unauthorized } from 'next-basics';
|
||||
import { getEventDataFields } from 'queries/analytics/eventData/getEventDataFields';
|
||||
import { getEventData } from 'queries';
|
||||
|
||||
export interface EventDataRequestBody {
|
||||
websiteId: string;
|
||||
urls: string[];
|
||||
window: number;
|
||||
dateRange: {
|
||||
startDate: string;
|
||||
endDate: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface EventDataResponse {
|
||||
urls: string[];
|
||||
window: number;
|
||||
startAt: number;
|
||||
endAt: number;
|
||||
fields: [
|
||||
{
|
||||
name: string;
|
||||
type: string;
|
||||
value: string;
|
||||
},
|
||||
];
|
||||
filters: [
|
||||
{
|
||||
name: string;
|
||||
type: string;
|
||||
value: string;
|
||||
},
|
||||
];
|
||||
groups: [
|
||||
{
|
||||
name: string;
|
||||
type: string;
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export default async (
|
||||
req: NextApiRequestQueryBody<any, EventDataRequestBody>,
|
||||
res: NextApiResponse<EventDataResponse>,
|
||||
res: NextApiResponse<any>,
|
||||
) => {
|
||||
await useCors(req, res);
|
||||
await useAuth(req, res);
|
||||
|
|
@ -45,13 +57,19 @@ export default async (
|
|||
const {
|
||||
websiteId,
|
||||
dateRange: { startDate, endDate },
|
||||
...criteria
|
||||
} = req.body;
|
||||
|
||||
if (!(await canViewWebsite(req.auth, websiteId))) {
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const data = {};
|
||||
const data = await getEventData(
|
||||
websiteId,
|
||||
new Date(startDate),
|
||||
new Date(endDate),
|
||||
criteria as any,
|
||||
);
|
||||
|
||||
return ok(res, data);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue