The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add partner.created webhook event support
Kiran K5c37bfd46fab
diff --git a/apps/web/lib/webhook/constants.ts b/apps/web/lib/webhook/constants.tsindex fc27600a2e..2d19667e97 100644--- a/apps/web/lib/webhook/constants.ts+++ b/apps/web/lib/webhook/constants.ts@@ -14,6 +14,7 @@ export const WORKSPACE_LEVEL_WEBHOOK_TRIGGERS = ["link.deleted","lead.created","sale.created",+ "partner.created",] as const;export const LINK_LEVEL_WEBHOOK_TRIGGERS = ["link.clicked"] as const;@@ -30,6 +31,7 @@ export const WEBHOOK_TRIGGER_DESCRIPTIONS = {"link.clicked": "Link clicked","lead.created": "Lead created","sale.created": "Sale created",+ "partner.created": "Partner created",} as const;export const WEBHOOK_FAILURE_NOTIFY_THRESHOLDS = [5, 10, 15] as const;diff --git a/apps/web/lib/webhook/sample-events/partner-created.json b/apps/web/lib/webhook/sample-events/partner-created.jsonnew file mode 100644index 0000000000..0967ef424b--- /dev/null+++ b/apps/web/lib/webhook/sample-events/partner-created.json@@ -0,0 +1 @@+{}diff --git a/apps/web/lib/webhook/sample-events/payload.ts b/apps/web/lib/webhook/sample-events/payload.tsindex 3c5e669c0c..df183f4978 100644--- a/apps/web/lib/webhook/sample-events/payload.ts+++ b/apps/web/lib/webhook/sample-events/payload.ts@@ -3,6 +3,7 @@ import linkClicked from "./link-clicked.json";import linkCreated from "./link-created.json";import linkDeleted from "./link-deleted.json";import linkUpdated from "./link-updated.json";+import partnerCreated from "./partner-created.json";import saleCreated from "./sale-created.json";// TODO:@@ -14,4 +15,5 @@ export const samplePayload = {"link.clicked": linkClicked,"lead.created": leadCreated,"sale.created": saleCreated,+ "partner.created": partnerCreated,} as any;diff --git a/apps/web/lib/webhook/schemas.ts b/apps/web/lib/webhook/schemas.tsindex af899e6bae..14787305fc 100644--- a/apps/web/lib/webhook/schemas.ts+++ b/apps/web/lib/webhook/schemas.ts@@ -2,6 +2,7 @@ import z from "@/lib/zod";import { clickEventSchema } from "../zod/schemas/clicks";import { CustomerSchema } from "../zod/schemas/customers";import { linkEventSchema } from "../zod/schemas/links";+import { PartnerSchema } from "../zod/schemas/partners";import { WEBHOOK_TRIGGERS } from "./constants";const saleSchema = z.object({@@ -31,6 +32,11 @@ export const saleWebhookEventSchema = z.object({sale: saleSchema,});+export const partnerWebhookEventSchema = z.object({+ eventName: z.string(),+ partner: PartnerSchema,+});+// Schema of the payload sent to the webhook endpoint by Dubexport const webhookPayloadSchema = z.object({id: z.string().describe("Unique identifier for the event."),@@ -97,6 +103,18 @@ export const webhookEventSchema = zref: "SaleCreatedEvent",description: "Triggered when a sale is created.",}),++ z+ .object({+ id: z.string(),+ event: z.literal("partner.created"),+ createdAt: z.string(),+ data: partnerWebhookEventSchema,+ })+ .openapi({+ ref: "PartnerCreatedEvent",+ description: "Triggered when a partner is created.",+ }),]).openapi({ref: "WebhookEvent",