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.

Add support for setting ?ref= tag in /links API

Steven Tey35e23f5418fb
diff --git a/apps/web/lib/zod/schemas/links.ts b/apps/web/lib/zod/schemas/links.ts
index 145807f6ea..463b38de8d 100644
--- a/apps/web/lib/zod/schemas/links.ts
+++ b/apps/web/lib/zod/schemas/links.ts
@@ -303,6 +303,12 @@ export const createLinkBodySchema = z.object({
.describe(
"The UTM content of the short link. If set, this will populate or override the UTM content in the destination URL.",
),
+ ref: z
+ .string()
+ .nullish()
+ .describe(
+ "The referral tag of the short link. If set, this will populate or override the `ref` query parameter in the destination URL.",
+ ),
});
export const updateLinkBodySchema = createLinkBodySchema.partial().optional();
diff --git a/packages/utils/src/functions/urls.ts b/packages/utils/src/functions/urls.ts
index 64c7a99d77..4b7a8fe9f5 100644
--- a/packages/utils/src/functions/urls.ts
+++ b/packages/utils/src/functions/urls.ts
@@ -65,6 +65,7 @@ export const UTMTags = [
"utm_campaign",
"utm_term",
"utm_content",
+ "ref",
] as const;
export const constructURLFromUTMParams = (
@@ -88,12 +89,12 @@ export const constructURLFromUTMParams = (
};
export const paramsMetadata = [
- { display: "Referral (ref)", key: "ref", examples: "twitter, facebook" },
{ display: "UTM Source", key: "utm_source", examples: "twitter, facebook" },
{ display: "UTM Medium", key: "utm_medium", examples: "social, email" },
{ display: "UTM Campaign", key: "utm_campaign", examples: "summer_sale" },
{ display: "UTM Term", key: "utm_term", examples: "blue_shoes" },
{ display: "UTM Content", key: "utm_content", examples: "logolink" },
+ { display: "Referral (ref)", key: "ref", examples: "twitter, facebook" },
];
export const getUrlWithoutUTMParams = (url: string) => {