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.

fix backwards compatibility

Steven Tey4156922f9d50
diff --git a/apps/web/lib/api/links.ts b/apps/web/lib/api/links.ts
index 6129c80f40..8a9827d858 100644
--- a/apps/web/lib/api/links.ts
+++ b/apps/web/lib/api/links.ts
@@ -102,9 +102,13 @@ export async function getLinksForProject({
domain: link.domain,
key: link.key,
});
+
+ const tags = link.tags.map(({ tag }) => tag);
+
return {
...link,
- tags: link.tags.map(({ tag }) => tag),
+ tagId: tags?.[0]?.id ?? null, // backwards compatibility
+ tags,
shortLink,
qrCode: `https://api.dub.co/qr?url=${shortLink}`,
};
@@ -558,8 +562,10 @@ export async function addLink(link: LinkWithTagIdsProps) {
domain: response.domain,
key: response.key,
});
+ const tags = response.tags.map(({ tag }) => tag);
return {
...response,
+ tagId: tags?.[0]?.id ?? null, // backwards compatibility
tags: response.tags.map(({ tag }) => tag),
shortLink,
qrCode: `https://api.dub.co/qr?url=${shortLink}`,
@@ -822,9 +828,12 @@ export async function editLink({
key: response.key,
});
+ const tags = response.tags.map(({ tag }) => tag);
+
return {
...response,
- tags: response.tags.map(({ tag }) => tag),
+ tagId: tags?.[0]?.id ?? null, // backwards compatibility
+ tags,
shortLink,
qrCode: `https://api.dub.co/qr?url=${shortLink}`,
};
diff --git a/apps/web/lib/zod/schemas/links.ts b/apps/web/lib/zod/schemas/links.ts
index 95275bbf39..5d1bbab5a5 100644
--- a/apps/web/lib/zod/schemas/links.ts
+++ b/apps/web/lib/zod/schemas/links.ts
@@ -292,6 +292,13 @@ export const LinkSchema = z
.boolean()
.default(false)
.describe("Whether the short link's stats are publicly accessible."),
+ tagId: z
+ .string()
+ .nullable()
+ .describe(
+ "[DEPRECATED (use `tags` instead)]: The unique ID of the tag assigned to the short link.",
+ )
+ .openapi({ deprecated: true }),
tags: TagSchema.array()
.nullable()
.describe("The tags assigned to the short link."),