The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update track-lead.ts
Kiran Kef51f5c4200a
diff --git a/apps/web/lib/api/conversions/track-lead.ts b/apps/web/lib/api/conversions/track-lead.tsindex 0e10ada83e..e2c13897c1 100644--- a/apps/web/lib/api/conversions/track-lead.ts+++ b/apps/web/lib/api/conversions/track-lead.ts@@ -99,6 +99,29 @@ export const trackLead = async ({});}+ const link = await prisma.link.findUnique({+ where: {+ id: clickData.link_id,+ },+ select: {+ projectId: true,+ },+ });++ if (!link) {+ throw new DubApiError({+ code: "not_found",+ message: `Link not found for clickId: ${clickId}`,+ });+ }++ if (link.projectId !== workspace.id) {+ throw new DubApiError({+ code: "not_found",+ message: `Link does not belong to the workspace`,+ });+ }+const leadEventId = nanoid(16);// Create a function to handle customer upsert to avoid duplication