Merge pull request #7 from RooCodeInc/jr/events-error-codes

This commit is contained in:
John Richmond 2025-05-14 17:49:47 -07:00 committed by GitHub
commit 02b7e22729
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,16 +21,22 @@ export async function POST(request: NextRequest) {
const result = eventSchema.safeParse({ ...payload, id, userId, timestamp });
if (!result.success) {
return NextResponse.json({ success: false, error: result.error.message });
return NextResponse.json(
{ success: false, error: result.error.message },
{ status: 400 },
);
}
try {
await captureEvent(result.data);
} catch (error) {
return NextResponse.json({
success: false,
error: error instanceof Error ? error.message : 'Unknown error',
});
return NextResponse.json(
{
success: false,
error: error instanceof Error ? error.message : 'Unknown error',
},
{ status: 500 },
);
}
return NextResponse.json({ success: true, id });