MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / events

Function events

apps/api/src/controllers/export.controller.ts:106–146  ·  view source on GitHub ↗
(
  request: FastifyRequest<{
    Querystring: z.infer<typeof eventsScheme>;
  }>,
  reply: FastifyReply
)

Source from the content-addressed store, hash-verified

104});
105
106export 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
148export const chartSchemeFull = zReport
149 .pick({

Callers

nothing calls this directly

Calls 4

getEventListFunction · 0.90
getEventsCountFunction · 0.90
getProjectIdFunction · 0.70
sendMethod · 0.45

Tested by

no test coverage detected