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

Function handler

apps/api/src/controllers/track.controller.ts:388–456  ·  view source on GitHub ↗
(
  request: FastifyRequest<{
    Body: ITrackHandlerPayload;
  }>,
  reply: FastifyReply
)

Source from the content-addressed store, hash-verified

386}
387
388export async function handler(
389 request: FastifyRequest<{
390 Body: ITrackHandlerPayload;
391 }>,
392 reply: FastifyReply
393) {
394 const validatedBody = request.body;
395
396 // Handle alias (not supported)
397 if (validatedBody.type === 'alias') {
398 return reply.status(400).send({
399 status: 400,
400 error: 'Bad Request',
401 message: 'Alias is not supported',
402 });
403 }
404
405 // Build request context
406 const context = await buildContext(request, validatedBody);
407
408 // Dispatch to appropriate handler
409 switch (validatedBody.type) {
410 case 'track':
411 await handleTrack(validatedBody.payload, context);
412 break;
413 case 'identify':
414 await handleIdentify(validatedBody.payload, context);
415 break;
416 case 'increment':
417 await handleIncrement(validatedBody.payload, context);
418 break;
419 case 'decrement':
420 await handleDecrement(validatedBody.payload, context);
421 break;
422 case 'replay': {
423 // BACKCOMPAT(replay-sessionid): TEMPORARY legacy branch, remove when new SDK is fully deployed
424 if (!validatedBody.payload.sessionId) {
425 await handleReplay(validatedBody.payload, {
426 projectId: context.projectId,
427 sessionId: context.sessionId,
428 });
429 break;
430 }
431
432 await handleReplay(validatedBody.payload, {
433 projectId: context.projectId,
434 sessionId: validatedBody.payload.sessionId,
435 });
436 break;
437 }
438 case 'group':
439 await handleGroup(validatedBody.payload, context);
440 break;
441 case 'assign_group':
442 await handleAssignGroup(validatedBody.payload, context);
443 break;
444 default:
445 return reply.status(400).send({

Callers 1

chatToolFunction · 0.50

Calls 9

buildContextFunction · 0.85
handleTrackFunction · 0.85
handleIdentifyFunction · 0.85
handleIncrementFunction · 0.85
handleDecrementFunction · 0.85
handleReplayFunction · 0.85
handleGroupFunction · 0.85
handleAssignGroupFunction · 0.85
sendMethod · 0.45

Tested by

no test coverage detected