clean up events/event-data endpoints
Some checks are pending
Create docker images (cloud) / Build, push, and deploy (push) Waiting to run
Node.js CI / build (postgresql, 18.18, 10) (push) Waiting to run

This commit is contained in:
Francis Cao 2025-10-15 16:44:14 -07:00
parent a7a7293d73
commit f23d5694ec
10 changed files with 59 additions and 38 deletions

View file

@ -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,
});