mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
clean up events/event-data endpoints
This commit is contained in:
parent
a7a7293d73
commit
f23d5694ec
10 changed files with 59 additions and 38 deletions
|
|
@ -3,16 +3,17 @@ import { getQueryFilters, parseRequest } from '@/lib/request';
|
|||
import { unauthorized, json } from '@/lib/response';
|
||||
import { canViewWebsite } from '@/permissions';
|
||||
import { getEventDataValues } from '@/queries/sql';
|
||||
import { dateRangeParams, filterParams } from '@/lib/schema';
|
||||
import { filterParams } from '@/lib/schema';
|
||||
|
||||
export async function GET(
|
||||
request: Request,
|
||||
{ params }: { params: Promise<{ websiteId: string }> },
|
||||
) {
|
||||
const schema = z.object({
|
||||
eventName: z.string().optional(),
|
||||
propertyName: z.string().optional(),
|
||||
...dateRangeParams,
|
||||
startAt: z.coerce.number().int(),
|
||||
endAt: z.coerce.number().int(),
|
||||
event: z.string(),
|
||||
propertyName: z.string(),
|
||||
...filterParams,
|
||||
});
|
||||
|
||||
|
|
@ -28,12 +29,11 @@ export async function GET(
|
|||
return unauthorized();
|
||||
}
|
||||
|
||||
const { eventName, propertyName } = query;
|
||||
const { propertyName } = query;
|
||||
const filters = await getQueryFilters(query, websiteId);
|
||||
|
||||
const data = await getEventDataValues(websiteId, {
|
||||
...filters,
|
||||
eventName,
|
||||
propertyName,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue