The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
use domain id as link Id while creating links
Kiran Keda6030be169
diff --git a/apps/web/lib/api/links/process-link.ts b/apps/web/lib/api/links/process-link.tsindex 79a1c44a4c..8ea1fc289a 100644--- a/apps/web/lib/api/links/process-link.ts+++ b/apps/web/lib/api/links/process-link.ts@@ -64,11 +64,10 @@ export async function processLink<T extends Record<string, any>>({} = payload;let expiresAt: string | Date | null | undefined = payload.expiresAt;- const isRootDomain = key === "_root";const tagIds = combineTagIds(payload);// url checks- if (!isRootDomain && !url) {+ if (!url) {return {link: payload,error: "Missing destination url.",@@ -317,9 +316,16 @@ export async function processLink<T extends Record<string, any>>({delete payload["qrCode"];delete payload["prefix"];+ // Use domain ID for root links+ let linkId =+ key === "_root"+ ? workspace?.domains.find((d) => d.slug === domain)?.id+ : null;+return {link: {...payload,+ ...(linkId && { id: linkId }),domain,key,// we're redefining these fields because they're processed in the functiondiff --git a/apps/web/lib/auth/workspace.ts b/apps/web/lib/auth/workspace.tsindex fbd5860a65..82efda1ba2 100644--- a/apps/web/lib/auth/workspace.ts+++ b/apps/web/lib/auth/workspace.ts@@ -224,6 +224,7 @@ export const withWorkspace = (},domains: {select: {+ id: true,slug: true,primary: true,},diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.tsindex 3feab1bb78..c0b152a55c 100644--- a/apps/web/lib/types.ts+++ b/apps/web/lib/types.ts@@ -86,6 +86,7 @@ export interface WorkspaceProps {stripeConnectId: string | null;createdAt: Date;domains: {+ id: string;slug: string;primary: boolean;}[];