Skip to content

Commit

Permalink
remove unused imports in ErrorsTable and add error details and path t…
Browse files Browse the repository at this point in the history
…o database
  • Loading branch information
mrkarimoff committed Jan 25, 2024
1 parent e820d6d commit c65d246
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 9 additions & 1 deletion apps/analytics/app/api/event/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit c65d246

Please sign in to comment.