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.

Remove identifier

Steven Tey84bd21432384
diff --git a/apps/web/app/api/links/[linkId]/route.ts b/apps/web/app/api/links/[linkId]/route.ts
index e9e3924cb5..8aa4d2304b 100644
--- a/apps/web/app/api/links/[linkId]/route.ts
+++ b/apps/web/app/api/links/[linkId]/route.ts
@@ -110,10 +110,6 @@ export const PATCH = withWorkspace(
const skipExternalIdChecks =
link.externalId?.toLowerCase() === updatedLink.externalId?.toLowerCase();
- // if identifier is the same, we don't need to check if it exists
- const skipIdentifierChecks =
- link.identifier?.toLowerCase() === updatedLink.identifier?.toLowerCase();
-
const {
link: processedLink,
error,
@@ -123,7 +119,6 @@ export const PATCH = withWorkspace(
workspace,
skipKeyChecks,
skipExternalIdChecks,
- skipIdentifierChecks,
});
if (error) {
diff --git a/apps/web/app/api/links/bulk/route.ts b/apps/web/app/api/links/bulk/route.ts
index d94feeeda4..d0fdd3131b 100644
--- a/apps/web/app/api/links/bulk/route.ts
+++ b/apps/web/app/api/links/bulk/route.ts
@@ -75,7 +75,6 @@ export const POST = withWorkspace(
userId: session.user.id,
bulk: true,
skipExternalIdChecks: true,
- skipIdentifierChecks: true,
}),
),
);
@@ -291,7 +290,6 @@ export const PATCH = withWorkspace(
bulk: true,
skipKeyChecks: true,
skipExternalIdChecks: true,
- skipIdentifierChecks: true,
}),
),
);
diff --git a/apps/web/app/api/links/upsert/route.ts b/apps/web/app/api/links/upsert/route.ts
index 78ab53b675..a571c0678e 100644
--- a/apps/web/app/api/links/upsert/route.ts
+++ b/apps/web/app/api/links/upsert/route.ts
@@ -85,11 +85,6 @@ export const PUT = withWorkspace(
link.externalId?.toLowerCase() ===
updatedLink.externalId?.toLowerCase();
- // if identifier is the same, we don't need to check if it exists
- const skipIdentifierChecks =
- link.identifier?.toLowerCase() ===
- updatedLink.identifier?.toLowerCase();
-
const {
link: processedLink,
error,
@@ -99,7 +94,6 @@ export const PUT = withWorkspace(
workspace,
skipKeyChecks,
skipExternalIdChecks,
- skipIdentifierChecks,
});
if (error) {
diff --git a/apps/web/lib/api/links/process-link.ts b/apps/web/lib/api/links/process-link.ts
index ab2b8a1609..0b1210fe73 100644
--- a/apps/web/lib/api/links/process-link.ts
+++ b/apps/web/lib/api/links/process-link.ts
@@ -27,7 +27,6 @@ export async function processLink<T extends Record<string, any>>({
userId,
bulk = false,
skipKeyChecks = false, // only skip when key doesn't change (e.g. when editing a link)
- skipIdentifierChecks = false, // only skip when identifier doesn't change (e.g. when editing a link)
skipExternalIdChecks = false, // only skip when externalId doesn't change (e.g. when editing a link)
}: {
payload: NewLinkProps & T;
@@ -38,7 +37,6 @@ export async function processLink<T extends Record<string, any>>({
userId?: string;
bulk?: boolean;
skipKeyChecks?: boolean;
- skipIdentifierChecks?: boolean;
skipExternalIdChecks?: boolean;
}): Promise<
| {
@@ -70,7 +68,6 @@ export async function processLink<T extends Record<string, any>>({
doIndex,
tagNames,
externalId,
- identifier,
programId,
webhookIds,
} = payload;
@@ -308,25 +305,6 @@ export async function processLink<T extends Record<string, any>>({
}
}
- if (identifier && workspace && !skipIdentifierChecks) {
- const link = await prisma.link.findUnique({
- where: {
- projectId_identifier: {
- projectId: workspace.id,
- identifier,
- },
- },
- });
-
- if (link) {
- return {
- link: payload,
- error: "A link with this identifier already exists in this workspace.",
- code: "conflict",
- };
- }
- }
-
if (bulk) {
if (proxy && image && !isStored(image)) {
return {
diff --git a/apps/web/lib/zod/schemas/links.ts b/apps/web/lib/zod/schemas/links.ts
index 532f9c251e..ce8b0ac23c 100644
--- a/apps/web/lib/zod/schemas/links.ts
+++ b/apps/web/lib/zod/schemas/links.ts
@@ -174,12 +174,6 @@ export const createLinkBodySchema = z.object({
.optional()
.default(false)
.describe("Whether to track conversions for the short link."),
- identifier: z
- .string()
- .nullish()
- .describe(
- "The identifier of the short link that is unique across your workspace. If set, it can be used to identify your short link for client-side click tracking.",
- ),
archived: z
.boolean()
.optional()
@@ -362,7 +356,6 @@ export const bulkUpdateLinksBodySchema = z.object({
domain: true,
key: true,
externalId: true,
- identifier: true,
prefix: true,
})
.merge(
@@ -401,12 +394,6 @@ export const LinkSchema = z
.describe(
"This is the ID of the link in your database that is unique across your workspace. If set, it can be used to identify the link in future API requests. Must be prefixed with 'ext_' when passed as a query parameter.",
),
- identifier: z
- .string()
- .nullable()
- .describe(
- "The identifier of the short link that is unique across your workspace. If set, it can be used to identify your short link for client-side click tracking.",
- ),
archived: z
.boolean()
.default(false)
diff --git a/apps/web/prisma/schema/link.prisma b/apps/web/prisma/schema/link.prisma
index f451510a0e..9f0a6dc15e 100644
--- a/apps/web/prisma/schema/link.prisma
+++ b/apps/web/prisma/schema/link.prisma
@@ -9,7 +9,6 @@ model Link {
expiredUrl String? @db.LongText // URL to redirect the user to when the link is expired
password String? // password to access the link
externalId String?
- identifier String?
trackConversion Boolean @default(false) // whether to track conversions or not
proxy Boolean @default(false) // Proxy to use custom OG tags (stored on redis) – if false, will use OG tags from target url
@@ -72,7 +71,6 @@ model Link {
@@unique([domain, key])
@@unique([projectId, externalId])
- @@unique([projectId, identifier])
@@index(trackConversion)
@@index(proxy)
@@index(password)
diff --git a/apps/web/tests/utils/schema.ts b/apps/web/tests/utils/schema.ts
index 20396adbcc..a000df56d9 100644
--- a/apps/web/tests/utils/schema.ts
+++ b/apps/web/tests/utils/schema.ts
@@ -43,7 +43,6 @@ export const expectedLink: Partial<Link> & {
updatedAt: expect.any(String),
expiredUrl: null,
externalId: null,
- identifier: null,
programId: null,
};
diff --git a/apps/web/ui/modals/link-builder/advanced-modal.tsx b/apps/web/ui/modals/link-builder/advanced-modal.tsx
index 0ba84e60e9..33d6567783 100644
--- a/apps/web/ui/modals/link-builder/advanced-modal.tsx
+++ b/apps/web/ui/modals/link-builder/advanced-modal.tsx
@@ -114,7 +114,7 @@ function AdvancedModal({
<SimpleTooltipContent
title="A unique identifier for this link in your system."
cta="Learn more about external IDs."
- href="https://dub.co/help/article/external-ids"
+ href="https://d.to/externalId"
/>
}
/>
diff --git a/apps/web/ui/modals/link-builder/more-dropdown.tsx b/apps/web/ui/modals/link-builder/more-dropdown.tsx
index 921d3faf5f..ef9ce5974b 100644
--- a/apps/web/ui/modals/link-builder/more-dropdown.tsx
+++ b/apps/web/ui/modals/link-builder/more-dropdown.tsx
@@ -133,7 +133,7 @@ export function MoreDropdown() {
<Settings
className={cn(
"mr-1 size-4 text-gray-950",
- (data.externalId || data.identifier) && "text-blue-500",
+ data.externalId && "text-blue-500",
)}
/>
Advanced Settings