The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix the webhook tests
Kiran Kf88599b40d8f
diff --git a/apps/web/lib/webhook/sample-events/lead-created.json b/apps/web/lib/webhook/sample-events/lead-created.jsonindex 209cdedee9..0e0d83046f 100644--- a/apps/web/lib/webhook/sample-events/lead-created.json+++ b/apps/web/lib/webhook/sample-events/lead-created.json@@ -70,6 +70,9 @@"saleAmount": 290300,"createdAt": "2024-09-02T18:49:56.136Z","updatedAt": "2025-01-14T04:49:23.740Z",- "projectId": "clrei1gld0002vs9mzn93p8ik"+ "projectId": "clrei1gld0002vs9mzn93p8ik",+ "testVariants": null,+ "testCompletedAt": null,+ "testStartedAt": null}}diff --git a/apps/web/lib/webhook/sample-events/link-clicked.json b/apps/web/lib/webhook/sample-events/link-clicked.jsonindex 3341f60414..b88bec2681 100644--- a/apps/web/lib/webhook/sample-events/link-clicked.json+++ b/apps/web/lib/webhook/sample-events/link-clicked.json@@ -61,6 +61,9 @@"saleAmount": 290300,"createdAt": "2024-09-02T18:49:56.136Z","updatedAt": "2025-01-13T22:46:22.152Z",- "projectId": "clrei1gld0002vs9mzn93p8ik"+ "projectId": "clrei1gld0002vs9mzn93p8ik",+ "testVariants": null,+ "testCompletedAt": null,+ "testStartedAt": null}}diff --git a/apps/web/lib/webhook/sample-events/link-created.json b/apps/web/lib/webhook/sample-events/link-created.jsonindex 36b85a5b04..b8ef3d55b2 100644--- a/apps/web/lib/webhook/sample-events/link-created.json+++ b/apps/web/lib/webhook/sample-events/link-created.json@@ -44,5 +44,8 @@"saleAmount": 0,"createdAt": "2024-08-26T16:41:52.084Z","updatedAt": "2024-08-26T16:41:52.084Z",- "projectId": "cm022sis60003ikt1syy7kfhl"+ "projectId": "cm022sis60003ikt1syy7kfhl",+ "testVariants": null,+ "testCompletedAt": null,+ "testStartedAt": null}diff --git a/apps/web/lib/webhook/sample-events/link-deleted.json b/apps/web/lib/webhook/sample-events/link-deleted.jsonindex 36b85a5b04..b8ef3d55b2 100644--- a/apps/web/lib/webhook/sample-events/link-deleted.json+++ b/apps/web/lib/webhook/sample-events/link-deleted.json@@ -44,5 +44,8 @@"saleAmount": 0,"createdAt": "2024-08-26T16:41:52.084Z","updatedAt": "2024-08-26T16:41:52.084Z",- "projectId": "cm022sis60003ikt1syy7kfhl"+ "projectId": "cm022sis60003ikt1syy7kfhl",+ "testVariants": null,+ "testCompletedAt": null,+ "testStartedAt": null}diff --git a/apps/web/lib/webhook/sample-events/link-updated.json b/apps/web/lib/webhook/sample-events/link-updated.jsonindex 36b85a5b04..b8ef3d55b2 100644--- a/apps/web/lib/webhook/sample-events/link-updated.json+++ b/apps/web/lib/webhook/sample-events/link-updated.json@@ -44,5 +44,8 @@"saleAmount": 0,"createdAt": "2024-08-26T16:41:52.084Z","updatedAt": "2024-08-26T16:41:52.084Z",- "projectId": "cm022sis60003ikt1syy7kfhl"+ "projectId": "cm022sis60003ikt1syy7kfhl",+ "testVariants": null,+ "testCompletedAt": null,+ "testStartedAt": null}diff --git a/apps/web/lib/webhook/sample-events/partner-created.json b/apps/web/lib/webhook/sample-events/partner-created.jsonindex 8f3a1cefaa..4fc627ae0f 100644--- a/apps/web/lib/webhook/sample-events/partner-created.json+++ b/apps/web/lib/webhook/sample-events/partner-created.json@@ -1,35 +1,32 @@{- "id": "evt_BmAVZcjmXGfqQALqmDpzatEs6",- "event": "partner.created",- "createdAt": "2025-02-07T17:58:19.517Z",- "data": {- "id": "cm6v2l38p000zubyl5fly3i7w",- "name": "Matthew Hayden",- "email": "[email protected]",- "image": null,- "country": "MR",- "description": "I'm a content creator who works with brands to grow their business.",- "tenantId": "64dc9a8c-5cf9-4446-b53b-cdc15199fafc",- "programId": "prog_CYCu7IMAapjkRpTnr8F1azjN",- "status": "approved",- "clicks": 0,- "leads": 0,- "sales": 0,- "saleAmount": 0,- "earnings": 0,- "createdAt": "2025-02-07T17:58:18.793Z",- "links": [- {- "id": "link_5myDHLqhIQvUmUPjchVygF9R",- "domain": "refer.dub.co",- "key": "track-test",- "shortLink": "https://refer.dub.co/track-test",- "url": "https://refer.dub.co",- "clicks": 100,- "leads": 70,- "sales": 25,- "saleAmount": 2500- }- ]- }+ "id": "cm6v2l38p000zubyl5fly3i7w",+ "name": "Matthew Hayden",+ "email": "[email protected]",+ "image": null,+ "country": "MR",+ "description": "I'm a content creator who works with brands to grow their business.",+ "tenantId": "64dc9a8c-5cf9-4446-b53b-cdc15199fafc",+ "programId": "prog_CYCu7IMAapjkRpTnr8F1azjN",+ "status": "approved",+ "clicks": 0,+ "leads": 0,+ "sales": 0,+ "saleAmount": 0,+ "earnings": 0,+ "payoutsEnabledAt": "2025-03-11T04:32:56.308Z",+ "createdAt": "2025-02-07T17:58:18.793Z",+ "applicationId": null,+ "links": [+ {+ "id": "link_5myDHLqhIQvUmUPjchVygF9R",+ "domain": "refer.dub.co",+ "key": "track-test",+ "shortLink": "https://refer.dub.co/track-test",+ "url": "https://refer.dub.co",+ "clicks": 100,+ "leads": 70,+ "sales": 25,+ "saleAmount": 2500+ }+ ]}diff --git a/apps/web/lib/webhook/sample-events/sale-created.json b/apps/web/lib/webhook/sample-events/sale-created.jsonindex 27163a2f67..f49dee5b6c 100644--- a/apps/web/lib/webhook/sample-events/sale-created.json+++ b/apps/web/lib/webhook/sample-events/sale-created.json@@ -70,7 +70,10 @@"saleAmount": 290400,"createdAt": "2024-09-02T18:49:56.136Z","updatedAt": "2025-01-14T04:49:30.459Z",- "projectId": "clrei1gld0002vs9mzn93p8ik"+ "projectId": "clrei1gld0002vs9mzn93p8ik",+ "testVariants": null,+ "testCompletedAt": null,+ "testStartedAt": null},"sale": {"amount": 100,diff --git a/apps/web/tests/webhooks/index.test.ts b/apps/web/tests/webhooks/index.test.tsindex 0a95b77c27..fb2bb6ec7d 100644--- a/apps/web/tests/webhooks/index.test.ts+++ b/apps/web/tests/webhooks/index.test.ts@@ -34,7 +34,7 @@ const saleWebhookEventSchemaExtended = saleWebhookEventSchema.extend({const enrolledPartnerSchemaExtended = EnrolledPartnerSchema.extend({createdAt: z.string().transform((str) => new Date(str)),- updatedAt: z.string().transform((str) => new Date(str)),+ payoutsEnabledAt: z.string().transform((str) => new Date(str)),});const eventSchemas: Record<WebhookTrigger, z.ZodSchema> = {@@ -99,14 +99,7 @@ const assertQstashMessage = async (expect(receivedBody.event).toEqual(trigger);expect(receivedBody.data).toEqual(body);-- // TODO:- // Fix the partner.created schema not working on GH CI- if (trigger !== "partner.created") {- expect(eventSchemas[trigger].safeParse(receivedBody.data).success).toBe(- true,- );- }+ expect(eventSchemas[trigger].safeParse(receivedBody.data).success).toBe(true);};// TODO: