diff --git a/apps/analytics/app/_components/errors/ErrorsTable/ErrorsTable.tsx b/apps/analytics/app/_components/errors/ErrorsTable/ErrorsTable.tsx index 449e07d9..80fd958c 100644 --- a/apps/analytics/app/_components/errors/ErrorsTable/ErrorsTable.tsx +++ b/apps/analytics/app/_components/errors/ErrorsTable/ErrorsTable.tsx @@ -2,7 +2,6 @@ import { DataTable } from "~/components/DataTable/data-table"; import getErrors from "~/db/getErrors"; import { columns } from "./Columns"; import ExportButton from "~/components/ExportButton"; -import { Card, CardHeader, CardContent } from "~/components/ui/card"; export default async function ErrorsTable() { const errors = await getErrors(); diff --git a/apps/analytics/app/api/event/route.ts b/apps/analytics/app/api/event/route.ts index efc7f23d..92066d0f 100644 --- a/apps/analytics/app/api/event/route.ts +++ b/apps/analytics/app/api/event/route.ts @@ -18,8 +18,16 @@ export async function POST(request: NextRequest) { // determine if this is an error and push it to the errors table if (event.type === "Error") { const errorPayload = event.error; + const errorDetails = event.metadata?.details; + const errorPath = event.metadata?.path; try { - await sql`INSERT INTO Errors (message, details, stacktrace, timestamp, installationid, path) VALUES (${errorPayload.message}, ${errorPayload.details}, ${errorPayload.stacktrace}, ${timestamp}, ${event.installationId}, ${errorPayload.path});`; + await sql`INSERT INTO Errors (message, details, stacktrace, timestamp, installationid, path) VALUES (${ + errorPayload.message + }, ${errorDetails ? JSON.stringify(errorDetails) : null}, ${ + errorPayload.stack + }, ${timestamp}, ${event.installationId}, ${ + errorPath ? JSON.stringify(errorPath) : null + });`; return NextResponse.json( { errorPayload }, { status: 200, headers: corsHeaders }