Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Fix click webhook issue

Steven Teyb226c9cf8051
diff --git a/apps/web/lib/webhook/transform.ts b/apps/web/lib/webhook/transform.ts
index e772388045..cc29e337d0 100644
--- a/apps/web/lib/webhook/transform.ts
+++ b/apps/web/lib/webhook/transform.ts
@@ -37,11 +37,16 @@ export const transformClickEventData = (
Object.entries(data).map(([key, value]) => [toCamelCase(key), value]),
);
+ const parsedTimestamp = new Date(click.timestamp ?? Date.now());
+ const validTimestamp = Number.isNaN(parsedTimestamp.getTime())
+ ? new Date()
+ : parsedTimestamp;
+
return clickWebhookEventSchema.parse({
...click,
click: clickEventSchema.parse({
...click,
- timestamp: new Date(click.timestamp),
+ timestamp: validTimestamp,
id: click.clickId,
}),
});