Skip to content

Commit

Permalink
add formatting event to insert
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkarimoff committed Feb 1, 2024
1 parent f427a72 commit fddd0f6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 105 deletions.
10 changes: 8 additions & 2 deletions apps/analytics/app/api/event/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ export async function POST(request: NextRequest) {
);
}

const eventWithDate = {
const formattedEvent = {
...parsedEvent.data,
...(parsedEvent.data.type === "Error" && {
type: "Error",
message: parsedEvent.data.error.message,
name: parsedEvent.data.error.name,
stack: parsedEvent.data.error.stack,
}),
timestamp: new Date(parsedEvent.data.timestamp), // Convert back into a date object
};

const result = await insertEvent(eventWithDate);
const result = await insertEvent(formattedEvent);

if (result.error) {
return NextResponse.json(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CREATE TABLE IF NOT EXISTS "events" (
"type" text NOT NULL,
"installationId" text NOT NULL,
"timestamp" timestamp NOT NULL,
"isocode" text,
"countryISOCode" text NOT NULL,
"message" text,
"name" text,
"stack" text,
Expand Down
2 changes: 0 additions & 2 deletions apps/analytics/drizzle/0001_fine_randall_flagg.sql

This file was deleted.

8 changes: 4 additions & 4 deletions apps/analytics/drizzle/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "8314d6f3-51e8-44a2-a9ec-d3128c1a7775",
"id": "13cbb638-62c2-4e6a-aef8-a17910f27456",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "5",
"dialect": "pg",
Expand Down Expand Up @@ -32,11 +32,11 @@
"primaryKey": false,
"notNull": true
},
"isocode": {
"name": "isocode",
"countryISOCode": {
"name": "countryISOCode",
"type": "text",
"primaryKey": false,
"notNull": false
"notNull": true
},
"message": {
"name": "message",
Expand Down
87 changes: 0 additions & 87 deletions apps/analytics/drizzle/meta/0001_snapshot.json

This file was deleted.

11 changes: 2 additions & 9 deletions apps/analytics/drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,8 @@
{
"idx": 0,
"version": "5",
"when": 1706248816583,
"tag": "0000_yellow_the_watchers",
"breakpoints": true
},
{
"idx": 1,
"version": "5",
"when": 1706786115080,
"tag": "0001_fine_randall_flagg",
"when": 1706803795839,
"tag": "0000_uneven_madame_hydra",
"breakpoints": true
}
]
Expand Down

0 comments on commit fddd0f6

Please sign in to comment.