The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Dub Conversions GA
Steven Tey6e5877a41085
diff --git a/apps/web/app/api/customers/[id]/route.ts b/apps/web/app/api/customers/[id]/route.tsindex 4ce232557a..dc8a194f17 100644--- a/apps/web/app/api/customers/[id]/route.ts+++ b/apps/web/app/api/customers/[id]/route.ts@@ -29,7 +29,13 @@ export const GET = withWorkspace(return NextResponse.json(CustomerSchema.parse(transformCustomer(customer)));},{- requiredAddOn: "conversion",+ requiredPlan: [+ "business",+ "business plus",+ "business extra",+ "business max",+ "enterprise",+ ],},);@@ -91,7 +97,13 @@ export const PATCH = withWorkspace(}},{- requiredAddOn: "conversion",+ requiredPlan: [+ "business",+ "business plus",+ "business extra",+ "business max",+ "enterprise",+ ],},);@@ -116,6 +128,12 @@ export const DELETE = withWorkspace(});},{- requiredAddOn: "conversion",+ requiredPlan: [+ "business",+ "business plus",+ "business extra",+ "business max",+ "enterprise",+ ],},);diff --git a/apps/web/app/api/customers/route.ts b/apps/web/app/api/customers/route.tsindex 6031583b52..ebc5cba3db 100644--- a/apps/web/app/api/customers/route.ts+++ b/apps/web/app/api/customers/route.ts@@ -50,7 +50,13 @@ export const GET = withWorkspace();},{- requiredAddOn: "conversion",+ requiredPlan: [+ "business",+ "business plus",+ "business extra",+ "business max",+ "enterprise",+ ],},);@@ -96,6 +102,12 @@ export const POST = withWorkspace(}},{- requiredAddOn: "conversion",+ requiredPlan: [+ "business",+ "business plus",+ "business extra",+ "business max",+ "enterprise",+ ],},);diff --git a/apps/web/app/api/shopify/integration/callback/route.ts b/apps/web/app/api/shopify/integration/callback/route.tsindex 564bd6da2d..8015512048 100644--- a/apps/web/app/api/shopify/integration/callback/route.ts+++ b/apps/web/app/api/shopify/integration/callback/route.ts@@ -86,6 +86,12 @@ export const PATCH = withWorkspace(},{requiredPermissions: ["workspaces.write"],- requiredAddOn: "conversion",+ requiredPlan: [+ "business",+ "business plus",+ "business extra",+ "business max",+ "enterprise",+ ],},);diff --git a/apps/web/app/api/stripe/integration/route.ts b/apps/web/app/api/stripe/integration/route.tsindex 94625456ec..54386384f2 100644--- a/apps/web/app/api/stripe/integration/route.ts+++ b/apps/web/app/api/stripe/integration/route.ts@@ -95,7 +95,13 @@ export const PATCH = withWorkspace(},{requiredPermissions: ["workspaces.write"],- requiredAddOn: "conversion",+ requiredPlan: [+ "business",+ "business plus",+ "business extra",+ "business max",+ "enterprise",+ ],},);diff --git a/apps/web/app/api/tokens/embed/route.ts b/apps/web/app/api/tokens/embed/route.tsindex 743883516a..ec44dc422b 100644--- a/apps/web/app/api/tokens/embed/route.ts+++ b/apps/web/app/api/tokens/embed/route.ts@@ -25,6 +25,12 @@ export const POST = withWorkspace(},{requiredPermissions: ["links.write"],- requiredAddOn: "conversion",+ requiredPlan: [+ "business",+ "business plus",+ "business extra",+ "business max",+ "enterprise",+ ],},);diff --git a/apps/web/app/api/track/sale/route.ts b/apps/web/app/api/track/sale/route.tsindex 3c9fd83b6c..6a7fcee829 100644--- a/apps/web/app/api/track/sale/route.ts+++ b/apps/web/app/api/track/sale/route.ts@@ -220,7 +220,13 @@ export const POST = withWorkspaceEdge(});},{- requiredAddOn: "conversion",+ requiredPlan: [+ "business",+ "business plus",+ "business extra",+ "business max",+ "enterprise",+ ],requiredPermissions: ["conversions.write"],},);diff --git a/apps/web/lib/auth/workspace-edge.ts b/apps/web/lib/auth/workspace-edge.tsindex 72fd195535..3cb06ae69e 100644--- a/apps/web/lib/auth/workspace-edge.ts+++ b/apps/web/lib/auth/workspace-edge.ts@@ -3,7 +3,7 @@ import {exceededLimitError,handleAndReturnErrorResponse,} from "@/lib/api/errors";-import { AddOns, BetaFeatures, PlanProps, WorkspaceProps } from "@/lib/types";+import { BetaFeatures, PlanProps, WorkspaceProps } from "@/lib/types";import { ratelimit } from "@/lib/upstash";import { prismaEdge } from "@dub/prisma/edge";import { API_DOMAIN, getSearchParams } from "@dub/utils";@@ -54,13 +54,11 @@ export const withWorkspaceEdge = ("business extra","enterprise",], // if the action needs a specific plan- requiredAddOn,needNotExceededAI, // if the action needs the user to not have exceeded their AI usagefeatureFlag, // if the action needs a specific feature flagrequiredPermissions = [],}: {requiredPlan?: Array<PlanProps>;- requiredAddOn?: AddOns;needNotExceededAI?: boolean;featureFlag?: BetaFeatures;requiredPermissions?: PermissionAction[];@@ -370,28 +368,13 @@ export const withWorkspaceEdge = (const url = new URL(req.url || "", API_DOMAIN);// plan checks- // special scenario – /events API is available for conversionEnabled workspaces- // (even if they're on a Pro plan)- if (- !requiredPlan.includes(workspace.plan) &&- url.pathname.includes("/events") &&- !workspace.conversionEnabled- ) {+ if (!requiredPlan.includes(workspace.plan)) {throw new DubApiError({code: "forbidden",message: "Unauthorized: Need higher plan.",});}- // add-ons checks- if (requiredAddOn && !workspace[`${requiredAddOn}Enabled`]) {- throw new DubApiError({- code: "forbidden",- message:- "Unauthorized: This feature is not available on your plan.",- });- }-// analytics API checksif (workspace.plan === "free" &&diff --git a/apps/web/lib/auth/workspace.ts b/apps/web/lib/auth/workspace.tsindex 28b3f4cd6d..db7c64e08b 100644--- a/apps/web/lib/auth/workspace.ts+++ b/apps/web/lib/auth/workspace.ts@@ -1,10 +1,5 @@import { DubApiError, handleAndReturnErrorResponse } from "@/lib/api/errors";-import {- AddOns,- BetaFeatures,- PlanProps,- WorkspaceWithUsers,-} from "@/lib/types";+import { BetaFeatures, PlanProps, WorkspaceWithUsers } from "@/lib/types";import { ratelimit } from "@/lib/upstash";import { prisma } from "@dub/prisma";import { API_DOMAIN, getSearchParams } from "@dub/utils";@@ -52,13 +47,11 @@ export const withWorkspace = ("business extra","enterprise",], // if the action needs a specific plan- requiredAddOn,featureFlag, // if the action needs a specific feature flagrequiredPermissions = [],skipPermissionChecks, // if the action doesn't need to check for required permission(s)}: {requiredPlan?: Array<PlanProps>;- requiredAddOn?: AddOns;featureFlag?: BetaFeatures;requiredPermissions?: PermissionAction[];skipPermissionChecks?: boolean;@@ -349,28 +342,13 @@ export const withWorkspace = (const url = new URL(req.url || "", API_DOMAIN);// plan checks- // special scenario – /events and /webhooks API is available for conversionEnabled workspaces (even if they're on a Pro plan)- if (- !requiredPlan.includes(workspace.plan) &&- (url.pathname.includes("/events") ||- url.pathname.includes("/webhooks")) &&- !workspace.conversionEnabled- ) {+ if (!requiredPlan.includes(workspace.plan)) {throw new DubApiError({code: "forbidden",message: "Unauthorized: Need higher plan.",});}- // add-ons checks- if (requiredAddOn && !workspace[`${requiredAddOn}Enabled`]) {- throw new DubApiError({- code: "forbidden",- message:- "Unauthorized: This feature is not available on your plan.",- });- }-// analytics API checksif (workspace.plan === "free" &&diff --git a/apps/web/ui/modals/link-builder/index.tsx b/apps/web/ui/modals/link-builder/index.tsxindex 68a51d8e5e..6852e1fb55 100644--- a/apps/web/ui/modals/link-builder/index.tsx+++ b/apps/web/ui/modals/link-builder/index.tsx@@ -89,8 +89,13 @@ export function LinkBuilder(props: LinkBuilderProps) {}function LinkBuilderOuter(props: LinkBuilderProps) {+ const { conversionEnabled } = useWorkspace();const form = useForm<LinkFormData>({- defaultValues: props.props || props.duplicateProps || DEFAULT_LINK_PROPS,+ defaultValues: props.props ||+ props.duplicateProps || {+ ...DEFAULT_LINK_PROPS,+ trackConversion: conversionEnabled || false,+ },});return (