(
request: FastifyRequest<{
Querystring: z.infer<typeof eventsScheme>;
}>,
reply: FastifyReply
)
| 104 | }); |
| 105 | |
| 106 | export async function events( |
| 107 | request: FastifyRequest<{ |
| 108 | Querystring: z.infer<typeof eventsScheme>; |
| 109 | }>, |
| 110 | reply: FastifyReply |
| 111 | ) { |
| 112 | const projectId = await getProjectId(request); |
| 113 | const { limit, page: rawPage, event, start, end, profileId, includes, filters } = request.query; |
| 114 | const take = Math.max(Math.min(limit, 1000), 1); |
| 115 | const cursor = Math.max(rawPage, 1) - 1; |
| 116 | const options: GetEventListOptions = { |
| 117 | projectId, |
| 118 | events: (Array.isArray(event) ? event : [event]).filter((s): s is string => typeof s === 'string'), |
| 119 | startDate: start ? new Date(start) : undefined, |
| 120 | endDate: end ? new Date(end) : undefined, |
| 121 | cursor, |
| 122 | take, |
| 123 | profileId, |
| 124 | filters, |
| 125 | select: { |
| 126 | profile: false, |
| 127 | meta: false, |
| 128 | ...includes?.reduce((acc, key) => ({ ...acc, [key]: true }), {}), |
| 129 | }, |
| 130 | }; |
| 131 | |
| 132 | const [data, totalCount] = await Promise.all([ |
| 133 | getEventList(options), |
| 134 | getEventsCount(options), |
| 135 | ]); |
| 136 | |
| 137 | reply.send({ |
| 138 | meta: { |
| 139 | count: data.length, |
| 140 | totalCount, |
| 141 | pages: Math.ceil(totalCount / options.take), |
| 142 | current: cursor + 1, |
| 143 | }, |
| 144 | data, |
| 145 | }); |
| 146 | } |
| 147 | |
| 148 | export const chartSchemeFull = zReport |
| 149 | .pick({ |
nothing calls this directly
no test coverage detected