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.

dclid → dubId

Steven Teya65fca20e00f
diff --git a/apps/web/app/api/stripe/connect/webhook/customer-created.ts b/apps/web/app/api/stripe/connect/webhook/customer-created.ts
index 08d7870926..72e2d6222c 100644
--- a/apps/web/app/api/stripe/connect/webhook/customer-created.ts
+++ b/apps/web/app/api/stripe/connect/webhook/customer-created.ts
@@ -14,7 +14,7 @@ export async function customerCreated(event: Stripe.Event) {
const externalId = stripeCustomer.metadata?.dubCustomerId;
const clickId = stripeCustomer.metadata?.dubClickId;
- // The client app should always send dclid via metadata
+ // The client app should always send dubClickId (dubId) via metadata
if (!clickId) {
return "Click ID not found in Stripe customer metadata, skipping...";
}
diff --git a/apps/web/lib/auth/options.ts b/apps/web/lib/auth/options.ts
index 2f35d10b85..b6b4188a49 100644
--- a/apps/web/lib/auth/options.ts
+++ b/apps/web/lib/auth/options.ts
@@ -453,7 +453,8 @@ export const authOptions: NextAuthOptions = {
);
}
- const clickId = cookies().get("dclid")?.value;
+ const clickId =
+ cookies().get("dubId")?.value || cookies().get("dclid")?.value;
if (clickId) {
// send lead event to Dub
waitUntil(
@@ -467,7 +468,7 @@ export const authOptions: NextAuthOptions = {
}),
);
// delete the clickId cookie
- cookies().delete("dclid");
+ cookies().delete("dubId");
}
}
// lazily backup user avatar to R2
diff --git a/apps/web/lib/middleware/link.ts b/apps/web/lib/middleware/link.ts
index 060194e214..ed6978973c 100644
--- a/apps/web/lib/middleware/link.ts
+++ b/apps/web/lib/middleware/link.ts
@@ -181,7 +181,8 @@ export default async function LinkMiddleware(
}
const cookieStore = cookies();
- let clickId = cookieStore.get("dclid")?.value;
+ let clickId =
+ cookieStore.get("dubId")?.value || cookieStore.get("dclid")?.value;
if (!clickId) {
clickId = nanoid(16);
}
diff --git a/apps/web/lib/middleware/utils/create-response-with-cookie.ts b/apps/web/lib/middleware/utils/create-response-with-cookie.ts
index 4de36ed7e9..7ccab0417d 100644
--- a/apps/web/lib/middleware/utils/create-response-with-cookie.ts
+++ b/apps/web/lib/middleware/utils/create-response-with-cookie.ts
@@ -4,7 +4,7 @@ export function createResponseWithCookie(
response: NextResponse,
{ clickId, path }: { clickId: string; path: string },
): NextResponse {
- response.cookies.set("dclid", clickId, {
+ response.cookies.set("dubId", clickId, {
path,
maxAge: 60 * 60, // 1 hour
});
diff --git a/apps/web/lib/middleware/utils/get-final-url.ts b/apps/web/lib/middleware/utils/get-final-url.ts
index cd4036cdb7..a7e067aaad 100644
--- a/apps/web/lib/middleware/utils/get-final-url.ts
+++ b/apps/web/lib/middleware/utils/get-final-url.ts
@@ -22,6 +22,7 @@ export const getFinalUrl = (
if (clickId) {
// add clickId to the final url if it exists
+ urlObj.searchParams.set("dubId", clickId);
urlObj.searchParams.set("dclid", clickId);
}
diff --git a/apps/web/lib/zod/schemas/leads.ts b/apps/web/lib/zod/schemas/leads.ts
index 8db19fe6ab..c675e02025 100644
--- a/apps/web/lib/zod/schemas/leads.ts
+++ b/apps/web/lib/zod/schemas/leads.ts
@@ -11,7 +11,7 @@ export const trackLeadRequestSchema = z.object({
.trim()
.min(1, "clickId is required")
.describe(
- "The ID of the click in th Dub. You can read this value from `dclid` cookie.",
+ "The ID of the click in th Dub. You can read this value from `dubId` cookie.",
),
eventName: z
.string({ required_error: "eventName is required" })