Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit 8db0f31

Browse files
committed
fix: bring back safety to backend events (#442)
1 parent d41a10e commit 8db0f31

File tree

1 file changed

+7
-1
lines changed
  • apps/hub/src/domains/project/queries/backend

1 file changed

+7
-1
lines changed

apps/hub/src/domains/project/queries/backend/types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as Sentry from "@sentry/react";
12
import { z } from "zod";
23

34
function getModuleCallOrNull(event: Event, url: string) {
@@ -37,7 +38,7 @@ type Event = z.infer<typeof Event>;
3738

3839
export const BackendEvent = z
3940
.object({
40-
dispatchEnvironment: z.string(),
41+
dispatchEnvironment: z.string().optional(),
4142
event: Event,
4243
eventTimestamp: z.string(),
4344
logs: z
@@ -64,6 +65,11 @@ export const BackendEvent = z
6465
id: z.string(),
6566
}),
6667
})
68+
.catch((ctx) => {
69+
console.error(ctx.error);
70+
Sentry.captureException(ctx.error);
71+
return ctx.input;
72+
})
6773
.transform((data) => {
6874
const url = new URL(data.event.request.url);
6975

0 commit comments

Comments
 (0)