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.

Onboarding updates (#3335)

Tim Wilson6b88110fc5b7
diff --git a/apps/web/app/(ee)/api/cron/auto-approve-partner/route.ts b/apps/web/app/(ee)/api/cron/auto-approve-partner/route.ts
deleted file mode 100644
index 8adb196799..0000000000
--- a/apps/web/app/(ee)/api/cron/auto-approve-partner/route.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export const dynamic = "force-dynamic";
-
-// TODO: Remove in 5 mins
-export { POST } from "../partners/auto-approve/route";
diff --git a/apps/web/app/(ee)/api/cron/welcome-user/route.ts b/apps/web/app/(ee)/api/cron/welcome-user/route.ts
index f411b40f7a..794d2e1494 100644
--- a/apps/web/app/(ee)/api/cron/welcome-user/route.ts
+++ b/apps/web/app/(ee)/api/cron/welcome-user/route.ts
@@ -1,6 +1,7 @@
import { handleAndReturnErrorResponse } from "@/lib/api/errors";
import { verifyQstashSignature } from "@/lib/cron/verify-qstash";
import { generateUnsubscribeToken } from "@/lib/email/unsubscribe-token";
+import { getPlanCapabilities } from "@/lib/plan-capabilities";
import { sendEmail } from "@dub/email";
import WelcomeEmail from "@dub/email/templates/welcome-email";
import WelcomeEmailPartner from "@dub/email/templates/welcome-email-partner";
@@ -11,7 +12,7 @@ export const dynamic = "force-dynamic";
/*
This route is used to send a welcome email to new users + subscribe them to the corresponding Resend audience
- It is called by QStash 15 minutes after a user is created.
+ It is called by QStash 45 minutes after a user is created.
*/
export async function POST(req: Request) {
try {
@@ -28,6 +29,34 @@ export async function POST(req: Request) {
name: true,
email: true,
partners: true,
+
+ projects: {
+ select: {
+ project: {
+ select: {
+ slug: true,
+ name: true,
+ logo: true,
+ plan: true,
+ programs: {
+ select: {
+ slug: true,
+ name: true,
+ logo: true,
+ },
+ orderBy: {
+ createdAt: "desc",
+ },
+ take: 1,
+ },
+ },
+ },
+ },
+ orderBy: {
+ createdAt: "asc",
+ },
+ take: 1,
+ },
},
});
@@ -57,7 +86,11 @@ export async function POST(req: Request) {
})
: WelcomeEmail({
email: user.email,
- name: user.name,
+ workspace: user.projects?.[0]?.project,
+ hasDubPartners: getPlanCapabilities(
+ user.projects?.[0]?.project?.plan || "free",
+ ).canManageProgram,
+ program: user.projects?.[0]?.project?.programs?.[0],
unsubscribeUrl,
}),
variant: "marketing",
diff --git a/apps/web/app/(ee)/api/stripe/webhook/checkout-session-completed.ts b/apps/web/app/(ee)/api/stripe/webhook/checkout-session-completed.ts
index 944c28010f..9d8b6b46ef 100644
--- a/apps/web/app/(ee)/api/stripe/webhook/checkout-session-completed.ts
+++ b/apps/web/app/(ee)/api/stripe/webhook/checkout-session-completed.ts
@@ -1,17 +1,15 @@
+import { createProgram } from "@/lib/actions/partners/create-program";
import { claimDotLinkDomain } from "@/lib/api/domains/claim-dot-link-domain";
-import { inviteUser } from "@/lib/api/users";
import { onboardingStepCache } from "@/lib/api/workspaces/onboarding-step-cache";
import { tokenCache } from "@/lib/auth/token-cache";
-import { getPlanCapabilities } from "@/lib/plan-capabilities";
import { stripe } from "@/lib/stripe";
import { WorkspaceProps } from "@/lib/types";
import { redis } from "@/lib/upstash";
-import { Invite } from "@/lib/zod/schemas/invites";
import { sendBatchEmail } from "@dub/email";
import UpgradeEmail from "@dub/email/templates/upgrade-email";
import { prisma } from "@dub/prisma";
-import { User } from "@dub/prisma/client";
-import { getPlanAndTierFromPriceId, log } from "@dub/utils";
+import { Program, User } from "@dub/prisma/client";
+import { getPlanAndTierFromPriceId, log, prettyPrint } from "@dub/utils";
import Stripe from "stripe";
export async function checkoutSessionCompleted(event: Stripe.Event) {
@@ -140,21 +138,6 @@ export async function checkoutSessionCompleted(event: Stripe.Event) {
tokenCache.expireMany({
hashedKeys: workspace.restrictedTokens.map(({ hashedKey }) => hashedKey),
}),
-
- // enable program messaging if available
- ...(workspace.defaultProgramId &&
- getPlanCapabilities(workspace.plan).canMessagePartners
- ? [
- prisma.program.update({
- where: {
- id: workspace.defaultProgramId,
- },
- data: {
- messagingEnabledAt: new Date(),
- },
- }),
- ]
- : []),
]);
}
@@ -162,7 +145,7 @@ async function completeOnboarding({
users,
workspaceId,
}: {
- users: Pick<User, "id">[];
+ users: Pick<User, "id" | "email">[];
workspaceId: string;
}) {
const workspace = (await prisma.project.findUnique({
@@ -171,8 +154,9 @@ async function completeOnboarding({
},
include: {
users: true,
+ programs: true,
},
- })) as unknown as WorkspaceProps | null;
+ })) as unknown as (WorkspaceProps & { programs: Program[] }) | null;
if (!workspace) {
console.error("Failed to complete onboarding for workspace", workspaceId);
@@ -186,48 +170,48 @@ async function completeOnboarding({
step: "completed",
}),
- // Send saved invite emails
- (async () => {
- const invites = await redis.get<Invite[]>(`invites:${workspaceId}`);
-
- if (!invites?.length) return;
-
- if (!workspace) return;
-
- await Promise.allSettled(
- invites.map(({ email, role }) =>
- inviteUser({
- email,
- role,
- workspace,
- }),
- ),
- );
-
- await redis.del(`invites:${workspaceId}`);
- })(),
-
- // Register saved domain
(async () => {
+ // Register saved domain
const data = await redis.get<{ domain: string; userId: string }>(
`onboarding-domain:${workspaceId}`,
);
- if (!data || !data.domain || !data.userId) return;
- const { domain, userId } = data;
-
- try {
- await claimDotLinkDomain({
- domain,
- userId,
- workspace,
- });
- await redis.del(`onboarding-domain:${workspaceId}`);
- } catch (e) {
- console.error(
- "Failed to register saved domain from onboarding",
- { domain, userId, workspace },
- e,
- );
+ if (data && data.domain && data.userId) {
+ const { domain, userId } = data;
+
+ try {
+ await claimDotLinkDomain({
+ domain,
+ userId,
+ workspace,
+ });
+ await redis.del(`onboarding-domain:${workspaceId}`);
+ } catch (e) {
+ console.error(
+ "Failed to register saved domain from onboarding",
+ { domain, userId, workspace },
+ e,
+ );
+ }
+ }
+
+ // Create program
+ if (
+ users.length > 0 &&
+ workspace.programs.length === 0 &&
+ workspace.store?.programOnboarding
+ ) {
+ try {
+ await createProgram({
+ workspace,
+ user: users[0],
+ });
+ } catch (e) {
+ console.error(
+ "Failed to create program from onboarding",
+ prettyPrint({ workspace, user: users[0] }),
+ e,
+ );
+ }
}
})(),
]);
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/layout.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/layout.tsx
index bcfd556b14..290c46ef55 100644
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/layout.tsx
+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/layout.tsx
@@ -1,6 +1,6 @@
"use client";
-import { FormWrapper } from "./form-wrapper";
+import { ProgramOnboardingFormWrapper } from "@/ui/partners/program-onboarding-form-wrapper";
import { ProgramOnboardingHeader } from "./header";
import { SidebarProvider } from "./sidebar-context";
import { ProgramOnboardingSteps } from "./steps";
@@ -9,13 +9,13 @@ export default function Layout({ children }: { children: React.ReactNode }) {
return (
<SidebarProvider>
<div className="min-h-screen bg-white">
- <FormWrapper>
+ <ProgramOnboardingFormWrapper>
<ProgramOnboardingHeader />
<div className="md:grid md:grid-cols-[240px_minmax(0,1fr)]">
<ProgramOnboardingSteps />
<main className="px-4 py-6 md:px-8">{children}</main>
</div>
- </FormWrapper>
+ </ProgramOnboardingFormWrapper>
</div>
</SidebarProvider>
);
diff --git a/apps/web/app/api/workspaces/[idOrSlug]/billing/upgrade/route.ts b/apps/web/app/api/workspaces/[idOrSlug]/billing/upgrade/route.ts
index e9e2199af6..043a2564d3 100644
--- a/apps/web/app/api/workspaces/[idOrSlug]/billing/upgrade/route.ts
+++ b/apps/web/app/api/workspaces/[idOrSlug]/billing/upgrade/route.ts
@@ -94,7 +94,9 @@ export const POST = withWorkspace(
customer_email: session.user.email,
}),
billing_address_collection: "required",
- success_url: `${APP_DOMAIN}/${workspace.slug}?${onboarding ? "onboarded" : "upgraded"}=true&plan=${plan}&period=${period}`,
+ success_url: onboarding
+ ? `${APP_DOMAIN}/onboarding/success?workspace=${workspace.slug}`
+ : `${APP_DOMAIN}/${workspace.slug}?upgraded=true&plan=${plan}&period=${period}`,
cancel_url: baseUrl,
line_items: [{ price: prices.data[0].id, quantity: 1 }],
...(customer?.discount?.couponId
diff --git a/apps/web/app/api/workspaces/[idOrSlug]/invites/saved/route.ts b/apps/web/app/api/workspaces/[idOrSlug]/invites/saved/route.ts
deleted file mode 100644
index 373f6c98ed..0000000000
--- a/apps/web/app/api/workspaces/[idOrSlug]/invites/saved/route.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { DubApiError } from "@/lib/api/errors";
-import { withWorkspace } from "@/lib/auth";
-import { redis } from "@/lib/upstash";
-import { Invite, inviteTeammatesSchema } from "@/lib/zod/schemas/invites";
-import { NextResponse } from "next/server";
-
-// GET /api/workspaces/[idOrSlug]/invites – get invites for a specific workspace
-export const GET = withWorkspace(
- async ({ workspace }) => {
- const invites = (
- (await redis.get<Invite[]>(`invites:${workspace.id}`)) ?? []
- ).reverse();
- return NextResponse.json(invites);
- },
- {
- requiredPermissions: ["workspaces.read"],
- },
-);
-
-// POST /api/workspaces/[idOrSlug]/invites/saved – save a list of teammate invites
-export const POST = withWorkspace(
- async ({ req, workspace }) => {
- const { teammates } = inviteTeammatesSchema.parse(await req.json());
-
- if (teammates.length > 4) {
- throw new DubApiError({
- code: "bad_request",
- message: "You can only save up to 4 teammate invitations at a time.",
- });
- }
-
- await redis.set(`invites:${workspace.id}`, teammates, {
- ex: 60 * 60 * 24 * 15, // 15 days
- });
-
- return NextResponse.json({ message: "Invite(s) saved" });
- },
- {
- requiredPermissions: ["workspaces.write"],
- },
-);
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsx
index bb96479e3b..d25dd7bc34 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsx
@@ -5,6 +5,7 @@ import { AnalyticsResponseOptions } from "@/lib/analytics/types";
import { editQueryString } from "@/lib/analytics/utils";
import useWorkspace from "@/lib/swr/use-workspace";
import { AnalyticsContext } from "@/ui/analytics/analytics-provider";
+import { useAnalyticsConnectedStatus } from "@/ui/analytics/use-analytics-connected-status";
import { CommissionsBlock } from "@/ui/partners/overview/blocks/commissions-block";
import { ConversionBlock } from "@/ui/partners/overview/blocks/conversion-block";
import { CountriesBlock } from "@/ui/partners/overview/blocks/countries-block";
@@ -14,9 +15,10 @@ import { SaleTypeBlock } from "@/ui/partners/overview/blocks/sale-type-block";
import { TrafficSourcesBlock } from "@/ui/partners/overview/blocks/traffic-sources-block";
import { ProgramOverviewCard } from "@/ui/partners/overview/program-overview-card";
import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";
-import { useRouterStuff } from "@dub/ui";
-import { fetcher } from "@dub/utils";
-import { useMemo } from "react";
+import { Plug2, buttonVariants, useRouterStuff } from "@dub/ui";
+import { cn, fetcher } from "@dub/utils";
+import Link from "next/link";
+import { ReactNode, useMemo } from "react";
import useSWR from "swr";
import { OverviewChart } from "./overview-chart";
import { OverviewLinks } from "./overview-links";
@@ -99,12 +101,64 @@ export default function ProgramOverviewPageClient() {
<OverviewLinks />
</div>
</div>
- <div className="@2xl:grid-cols-2 @4xl:grid-cols-3 grid grid-cols-1 gap-6">
- {BLOCKS.map((Block, idx) => (
- <Block key={idx} />
- ))}
- </div>
+ <FinishSetupWrapper totalEvents={totalEvents}>
+ <div className="@2xl:grid-cols-2 @4xl:grid-cols-3 grid grid-cols-1 gap-6">
+ {BLOCKS.map((Block, idx) => (
+ <Block key={idx} />
+ ))}
+ </div>
+ </FinishSetupWrapper>
</AnalyticsContext.Provider>
</div>
);
}
+
+function FinishSetupWrapper({
+ totalEvents,
+ children,
+}: {
+ totalEvents?: {
+ clicks: number;
+ leads: number;
+ sales: number;
+ };
+ children: ReactNode;
+}) {
+ const { slug } = useWorkspace();
+ const { isFullyConnected } = useAnalyticsConnectedStatus();
+
+ if (
+ isFullyConnected ||
+ totalEvents === undefined ||
+ ["clicks", "leads", "sales"].some((event) => totalEvents[event] > 0)
+ )
+ return children;
+
+ return (
+ <div className="relative">
+ <div className="relative h-[28rem] overflow-hidden">{children}</div>
+ <div className="from-bg-default to-bg-default/30 absolute inset-0 flex flex-col items-center justify-center bg-gradient-to-t from-60% text-center">
+ <div className="flex size-12 items-center justify-center rounded-lg border border-blue-200 bg-blue-100">
+ <Plug2 className="size-6 text-blue-500" />
+ </div>
+
+ <h2 className="text-content-emphasis mt-6 text-xl font-semibold">
+ Finish setting up your program
+ </h2>
+ <p className="text-content-subtle mt-2 max-w-md text-pretty text-sm">
+ Install the Dub tracking script on your site to track conversions,
+ attribute sales, and measure partner performance.
+ </p>
+ <Link
+ href={`/${slug}/settings/analytics`}
+ className={cn(
+ buttonVariants({ variant: "primary" }),
+ "mt-6 flex h-9 items-center justify-center whitespace-nowrap rounded-lg border px-3 text-sm",
+ )}
+ >
+ Set up conversion tracking
+ </Link>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx
index 602f4d1c5f..7143774621 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx
@@ -33,9 +33,9 @@ import {
cn,
getFirstAndLastDay,
INFINITY_NUMBER,
+ isLegacyBusinessPlan,
nFormatter,
} from "@dub/utils";
-import { isLegacyBusinessPlan } from "@dub/utils/src/constants/pricing";
import NumberFlow from "@number-flow/react";
import Link from "next/link";
import { CSSProperties, useMemo } from "react";
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page-client.tsx
index ac5510d1d3..429edc4de6 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page-client.tsx
@@ -19,11 +19,11 @@ import {
cn,
getSuggestedPlan,
isDowngradePlan,
- PLAN_COMPARE_FEATURES,
+ isLegacyBusinessPlan,
PlanDetails,
PLANS,
+ PRICING_PLAN_COMPARE_FEATURES,
} from "@dub/utils";
-import { isLegacyBusinessPlan } from "@dub/utils/src/constants/pricing";
import NumberFlow from "@number-flow/react";
import { ChevronLeft, ChevronRight } from "lucide-react";
import { motion } from "motion/react";
@@ -33,7 +33,7 @@ import { CSSProperties, useEffect, useMemo, useState } from "react";
import { AdjustUsageRow } from "./adjust-usage-row";
const COMPARE_FEATURE_ICONS: Record<
- (typeof PLAN_COMPARE_FEATURES)[number]["category"],
+ (typeof PRICING_PLAN_COMPARE_FEATURES)[number]["category"],
Icon
> = {
Links: Hyperlink,
@@ -285,7 +285,7 @@ export function WorkspaceBillingUpgradePageClient() {
<div className="h-4 bg-gradient-to-b from-white" />
</div>
<div className="flex flex-col pb-12">
- {PLAN_COMPARE_FEATURES.map((section) => (
+ {PRICING_PLAN_COMPARE_FEATURES.map((section) => (
<BillingCompareSection
key={section.category}
category={section.category}
@@ -307,7 +307,7 @@ function BillingCompareSection({
features,
mobilePlanIndex,
plans,
-}: (typeof PLAN_COMPARE_FEATURES)[number] & {
+}: (typeof PRICING_PLAN_COMPARE_FEATURES)[number] & {
mobilePlanIndex: number;
plans: { plan: PlanDetails; planTier: number }[];
}) {
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/custom/form.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/custom/form.tsx
index 018e2f214b..6792380e6a 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/custom/form.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/custom/form.tsx
@@ -2,20 +2,24 @@
import { AddEditDomainForm } from "@/ui/domains/add-edit-domain-form";
import { LaterButton } from "../../../later-button";
+import { useOnboardingProduct } from "../../../use-onboarding-product";
import { useOnboardingProgress } from "../../../use-onboarding-progress";
export function Form() {
+ const product = useOnboardingProduct();
+
const { continueTo } = useOnboardingProgress();
return (
<div>
<AddEditDomainForm
onSuccess={() => {
- continueTo("invite");
+ continueTo(product === "partners" ? "program" : "plan");
}}
enableDomainConfig={false}
/>
- <LaterButton next="invite" className="mt-4" />
+
+ {product !== "partners" && <LaterButton next="plan" className="mt-4" />}
</div>
);
}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/custom/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/custom/page.tsx
index 52d04ab39c..f8e6c70005 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/custom/page.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/custom/page.tsx
@@ -9,7 +9,7 @@ export default function Custom() {
<a
href="https://dub.co/help/article/choosing-a-custom-domain"
target="_blank"
- className="underline transition-colors hover:text-neutral-700"
+ className="cursor-alias underline decoration-dotted underline-offset-2 transition-colors hover:text-neutral-700"
>
Read our guide for best practices
</a>
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/default-domain-selector.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/default-domain-selector.tsx
index fd181d413e..c51d5cc1ac 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/default-domain-selector.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/default-domain-selector.tsx
@@ -6,25 +6,27 @@ import Image from "next/image";
import { useSearchParams } from "next/navigation";
import { ReactNode } from "react";
import { LaterButton } from "../../later-button";
+import { useOnboardingProduct } from "../../use-onboarding-product";
import { useOnboardingProgress } from "../../use-onboarding-progress";
export function DefaultDomainSelector() {
const searchParams = useSearchParams();
const workspaceSlug = searchParams.get("workspace");
+ const product = useOnboardingProduct();
return (
<>
<div className="animate-fade-in mx-auto grid w-full max-w-[312px] gap-4 sm:max-w-[600px] sm:grid-cols-2">
<DomainOption
step="domain/custom"
- icon="https://assets.dub.co/icons/link.webp"
+ icon="https://assets.dub.co/icons/domain-sign.webp"
title="Connect a custom domain"
- description="Already have a domain? Connect it to Dub in just a few clicks"
+ description="Already have a domain? Connect it to your Dub workspace."
cta="Connect domain"
/>
<DomainOption
step="domain/register"
- icon="https://assets.dub.co/icons/crown.webp"
+ icon="https://assets.dub.co/icons/gift.webp"
title={
<>
Claim a free{" "}
@@ -47,12 +49,14 @@ export function DefaultDomainSelector() {
</>
}
cta="Claim .link domain"
- paidPlanRequired
+ paidPlanRequired={product !== "partners"}
/>
</div>
- <div className="mx-auto mt-8 w-full max-w-sm">
- <LaterButton next="invite" className="mt-4" />
- </div>
+ {product === "links" && (
+ <div className="mx-auto mt-8 w-full max-w-sm">
+ <LaterButton next="plan" className="mt-4" />
+ </div>
+ )}
</>
);
}
@@ -74,9 +78,9 @@ function DomainOption({
}) {
const { continueTo, isLoading, isSuccessful } = useOnboardingProgress();
return (
- <div className="relative flex h-full flex-col items-center gap-6 rounded-xl border border-neutral-300 p-8 pt-10 transition-all">
+ <div className="relative flex h-full flex-col items-center gap-6 rounded-xl border border-neutral-300 p-6 pt-12 transition-all">
{paidPlanRequired && (
- <div className="absolute right-2 top-2 flex items-center gap-2 rounded-full border border-neutral-200 bg-neutral-100 px-2.5 py-0.5 text-xs font-medium text-neutral-600">
+ <div className="absolute inset-x-2 top-2 flex items-center justify-center gap-2 rounded-md border border-neutral-200 bg-neutral-100 px-2.5 py-1 text-xs font-medium text-neutral-600">
<Crown className="size-3" />
Paid plan required
</div>
@@ -90,14 +94,17 @@ function DomainOption({
fetchPriority="high"
/>
</div>
- <div className="space-y-2 text-center text-sm">
- <span className="font-semibold text-neutral-900">{title}</span>
- <p className="text-neutral-500">{description}</p>
+ <div className="space-y-2 text-center">
+ <span className="text-base font-semibold text-neutral-900">
+ {title}
+ </span>
+ <p className="text-balance text-sm text-neutral-500">{description}</p>
</div>
<div className="flex w-full grow flex-col justify-end gap-2">
<Button
type="button"
variant="primary"
+ className="rounded-lg"
onClick={() => continueTo(step)}
loading={isLoading || isSuccessful}
text={cta}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/page.tsx
index 43a49a7ed6..5d75841dd2 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/page.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/page.tsx
@@ -7,8 +7,7 @@ export default function Domain() {
title="Add a custom domain"
description={
<>
- Make your links stand out and
- <br />
+ Make your links stand out and{" "}
<a
href="https://dub.co/blog/custom-domains"
target="_blank"
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/register/form.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/register/form.tsx
index 930cb58b09..cda907bb42 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/register/form.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/register/form.tsx
@@ -2,20 +2,23 @@
import { RegisterDomainForm } from "@/ui/domains/register-domain-form";
import { LaterButton } from "../../../later-button";
+import { useOnboardingProduct } from "../../../use-onboarding-product";
import { useOnboardingProgress } from "../../../use-onboarding-progress";
export function Form() {
const { continueTo } = useOnboardingProgress();
+ const product = useOnboardingProduct();
return (
<div>
<RegisterDomainForm
saveOnly
onSuccess={() => {
- continueTo("invite");
+ continueTo(product === "partners" ? "program" : "plan");
}}
/>
- <LaterButton next="invite" className="mt-4" />
+
+ {product !== "partners" && <LaterButton next="plan" className="mt-4" />}
</div>
);
}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/register/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/register/page.tsx
index 0089132e40..22ecdeedba 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/register/page.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/domain/register/page.tsx
@@ -1,12 +1,26 @@
+"use client";
+
+import { BoltFill } from "@dub/ui";
+import { useOnboardingProduct } from "../../../use-onboarding-product";
import { StepPage } from "../../step-page";
import { Form } from "./form";
export default function Register() {
+ const product = useOnboardingProduct();
+
return (
<StepPage
title="Claim your free .link domain"
paidPlanRequired={true}
- description="Exclusively free for a year"
+ badge={
+ product === "partners"
+ ? {
+ icon: BoltFill,
+ label: "Instant setup",
+ }
+ : undefined
+ }
+ description="Exclusively free for one year"
>
<Form />
</StepPage>
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/exit-button.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/exit-button.tsx
deleted file mode 100644
index ba3ac8c4ec..0000000000
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/exit-button.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-"use client";
-
-import { ExpandingArrow, LoadingSpinner } from "@dub/ui/icons";
-import { useOnboardingProgress } from "../use-onboarding-progress";
-
-export function ExitButton() {
- const { finish, isLoading, isSuccessful } = useOnboardingProgress();
-
- return (
- <button
- type="button"
- onClick={finish}
- disabled={isLoading || isSuccessful}
- className="group flex items-center gap-1 p-3 pr-7 text-sm text-black/50 transition-colors enabled:hover:text-black/80"
- >
- {(isLoading || isSuccessful) && (
- <LoadingSpinner className="mr-1 size-3" />
- )}
- Skip onboarding
- <ExpandingArrow className="size-3" />
- </button>
- );
-}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/invite/form.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/invite/form.tsx
deleted file mode 100644
index ff89d8c337..0000000000
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/invite/form.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-"use client";
-
-import { InviteTeammatesForm } from "@/ui/workspaces/invite-teammates-form";
-import { LaterButton } from "../../later-button";
-import { useOnboardingProgress } from "../../use-onboarding-progress";
-
-export function Form() {
- const { continueTo } = useOnboardingProgress();
-
- return (
- <div>
- <InviteTeammatesForm
- onSuccess={() => {
- continueTo("usage");
- }}
- saveOnly
- />
- <LaterButton next="usage" className="mt-4" />
- </div>
- );
-}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/invite/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/invite/page.tsx
deleted file mode 100644
index 083bb9b086..0000000000
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/invite/page.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import { StepPage } from "../step-page";
-import { Form } from "./form";
-
-export default function Invite() {
- return (
- <StepPage
- title="Invite teammates"
- description="Invite teammates to join your workspace. Invitations will be valid for 14 days."
- paidPlanRequired
- >
- <Form />
- </StepPage>
- );
-}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/free-plan-button.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/free-plan-button.tsx
index 2d8408d270..891efff3f0 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/free-plan-button.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/free-plan-button.tsx
@@ -10,12 +10,12 @@ export function FreePlanButton({
className,
...rest
}: Omit<HTMLProps<HTMLButtonElement>, "type">) {
- const { finish, isLoading, isSuccessful } = useOnboardingProgress();
+ const { continueTo, isLoading, isSuccessful } = useOnboardingProgress();
return (
<button
type="button"
- onClick={finish}
+ onClick={() => continueTo("success")}
className={cn(
"inline-block text-neutral-500 transition-colors enabled:hover:text-neutral-700",
className,
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/page.tsx
index 3dc952a685..ba00f99c29 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/page.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/page.tsx
@@ -1,37 +1,70 @@
+"use client";
+
+import { DubProductIcon } from "@dub/ui";
+import { capitalize } from "@dub/utils";
import { LaterButton } from "../../later-button";
+import { useOnboardingProduct } from "../../use-onboarding-product";
import { StepPage } from "../step-page";
import { EnterpriseLink } from "./enterprise-link";
import { FreePlanButton } from "./free-plan-button";
import { PlanSelector } from "./plan-selector";
export default function Plan() {
+ const product = useOnboardingProduct();
+
return (
<StepPage
- title="Choose your plan"
- description={
+ title={
<>
- <span className="inline-block">
- Find a plan that fits your needs, or
- </span>{" "}
- <FreePlanButton className="text-base underline underline-offset-2">
- stay on the free plan.
- </FreePlanButton>
+ Choose your{" "}
+ <a
+ href={`https://dub.co/${product}`}
+ target="_blank"
+ className="group inline-block"
+ >
+ <DubProductIcon
+ product={product}
+ className="mb-[3px] ml-1 inline-flex size-5 align-middle transition-transform group-hover:-rotate-12"
+ iconClassName="size-3"
+ />{" "}
+ Dub {capitalize(product)}
+ </a>{" "}
+ plan
</>
}
+ description={
+ product === "partners" ? (
+ <span className="inline-block">
+ Find a plan that fits your needs.
+ </span>
+ ) : (
+ <>
+ <span className="inline-block">
+ Find a plan that fits your needs, or
+ </span>{" "}
+ <FreePlanButton className="text-base underline decoration-dotted underline-offset-2">
+ start on the free plan.
+ </FreePlanButton>
+ </>
+ )
+ }
className="max-w-screen-lg"
>
- <PlanSelector />
+ <PlanSelector key={product} product={product} />
<div className="mx-auto mt-8 flex w-fit flex-col items-center justify-center gap-6 text-sm md:flex-row">
<EnterpriseLink />
- <LaterButton
- next="finish"
- className="underline-offset-4 hover:underline"
- >
- Start for free, pick a plan later
- </LaterButton>
+ {product === "links" && (
+ <LaterButton
+ next="success"
+ className="underline-offset-4 hover:underline"
+ >
+ Start for free, pick a plan later
+ </LaterButton>
+ )}
<a
- href="https://dub.co/pricing"
+ href={`https://dub.co/pricing/${product}`}
target="_blank"
+ rel="noopener noreferrer"
className="flex items-center text-neutral-500 underline-offset-4 transition-colors hover:text-neutral-800 hover:underline"
>
Compare all plans ↗
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/plan-selector.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/plan-selector.tsx
index d82a314587..87b748d570 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/plan-selector.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/plan/plan-selector.tsx
@@ -1,126 +1,267 @@
"use client";
-import { PlanFeatures } from "@/ui/workspaces/plan-features";
+import X from "@/ui/shared/icons/x";
import { UpgradePlanButton } from "@/ui/workspaces/upgrade-plan-button";
-import { Badge, ToggleGroup } from "@dub/ui";
-import { ADVANCED_PLAN, BUSINESS_PLAN, cn, PRO_PLAN } from "@dub/utils";
+import {
+ Badge,
+ Check,
+ DubProductIcon,
+ PLAN_FEATURE_ICONS,
+ Switch,
+ Tooltip,
+} from "@dub/ui";
+import {
+ ADVANCED_PLAN,
+ BUSINESS_PLAN,
+ cn,
+ PRICING_PLAN_MAIN_FEATURES,
+ PRICING_PLAN_TAGLINES,
+ PRO_PLAN,
+} from "@dub/utils";
import NumberFlow from "@number-flow/react";
import { ChevronLeft, ChevronRight } from "lucide-react";
-import { useSearchParams } from "next/navigation";
-import { CSSProperties, useState } from "react";
+import { CSSProperties, isValidElement, ReactNode, useState } from "react";
+import { OnboardingProduct } from "../../use-onboarding-product";
-export const PLAN_SELECTOR_PLANS = [PRO_PLAN, BUSINESS_PLAN, ADVANCED_PLAN];
+export function PlanSelector({ product }: { product: OnboardingProduct }) {
+ const plans =
+ product === "partners"
+ ? [BUSINESS_PLAN, ADVANCED_PLAN]
+ : [PRO_PLAN, BUSINESS_PLAN, ADVANCED_PLAN];
-export function PlanSelector() {
const [period, setPeriod] = useState<"monthly" | "yearly">("monthly");
const [mobilePlanIndex, setMobilePlanIndex] = useState(0);
- const searchParams = useSearchParams();
- const recommendedPlan = searchParams.get("plan");
-
return (
- <div>
- <div className="flex justify-center">
- <ToggleGroup
- options={[
- { value: "monthly", label: "Monthly" },
- {
- value: "yearly",
- label: "Yearly (Save 17%)",
- },
- ]}
- className="overflow-hidden rounded-lg bg-neutral-100 p-0.5"
- indicatorClassName="rounded-md bg-white shadow-md"
- optionClassName="text-xs py-2 px-5 normal-case"
- selected={period}
- selectAction={(period) => setPeriod(period as "monthly" | "yearly")}
- />
- </div>
- <div className="mt-5 overflow-hidden [container-type:inline-size]">
- <div
- className={cn(
- "grid grid-cols-3",
+ <div className="overflow-hidden [container-type:inline-size]">
+ <div
+ className={cn(
+ "mx-auto grid max-w-[calc(var(--cols)*342px)] grid-cols-[repeat(var(--cols),1fr)]",
- // Mobile
- "max-lg:w-[calc(300cqw+2*32px)] max-lg:translate-x-[calc(-1*var(--index)*(100cqw+32px))] max-lg:gap-x-8 max-lg:transition-transform",
- )}
- style={
- {
- "--index": mobilePlanIndex,
- } as CSSProperties
- }
- >
- {PLAN_SELECTOR_PLANS.map((plan) => (
+ // Mobile
+ "max-lg:w-[calc(var(--cols)*100cqw+(var(--cols)-1)*32px)] max-lg:max-w-none max-lg:translate-x-[calc(-1*var(--index)*(100cqw+32px))] max-lg:gap-x-8 max-lg:transition-transform",
+ )}
+ style={
+ {
+ "--cols": plans.length,
+ "--index": mobilePlanIndex,
+ } as CSSProperties
+ }
+ >
+ {plans.map((plan) => {
+ const features = PRICING_PLAN_MAIN_FEATURES[product][plan.name] || [];
+
+ return (
<div
key={plan.name}
className={cn(
- "flex flex-col border-y border-l border-neutral-200 bg-white p-6 pb-8 first:rounded-l-lg last:rounded-r-lg last:border-r",
- recommendedPlan === plan.name.toLowerCase() &&
- "bg-gradient-to-b from-[#eef9ff] to-white to-40%",
+ "flex flex-col border-y border-l border-neutral-200 bg-white first:rounded-l-lg last:rounded-r-lg last:border-r",
+ product === "links" &&
+ plan.name === "Business" &&
+ "bg-gradient-to-b from-orange-50 to-40%",
+ product === "partners" &&
+ plan.name === "Advanced" &&
+ "bg-gradient-to-b from-violet-50 to-40%",
)}
>
- <div className="flex items-center justify-between gap-2">
- <h2 className="text-xl font-semibold text-neutral-800">
- {plan.name}
- </h2>
- {recommendedPlan
- ? recommendedPlan === plan.name.toLowerCase() && (
+ <div className="flex grow flex-col gap-6 p-5 pb-3">
+ <div>
+ <div className="flex items-center gap-2">
+ <h2 className="text-xl font-semibold text-neutral-800">
+ {plan.name}
+ </h2>
+ {product === "links" && plan.name === "Business" && (
+ <div className="w-fit whitespace-nowrap rounded-full bg-orange-900 px-2 py-1.5 text-center text-[0.5rem] font-medium uppercase leading-none text-white">
+ Popular
+ </div>
+ )}
+ {product === "partners" && plan.name === "Advanced" && (
+ <div className="w-fit whitespace-nowrap rounded-full bg-violet-900 px-2 py-1.5 text-center text-[0.5rem] font-medium uppercase leading-none text-white">
+ Best Value
+ </div>
+ )}
+ </div>
+ <div className="mt-1">
+ <div>
+ <NumberFlow
+ value={plan.price[period]!}
+ className="text-base tabular-nums text-neutral-700"
+ format={{
+ style: "currency",
+ currency: "USD",
+ minimumFractionDigits: 0,
+ }}
+ continuous
+ />
+ <span className="text-sm text-neutral-400">
+ {" "}
+ per month
+ </span>
+ </div>
+ </div>
+
+ <label className="mt-4 flex items-center gap-1.5">
+ <Switch
+ checked={period === "yearly"}
+ fn={(checked) =>
+ setPeriod(checked ? "yearly" : "monthly")
+ }
+ trackDimensions="radix-state-checked:bg-black focus-visible:ring-black/20 w-7 h-4"
+ thumbDimensions="size-3"
+ thumbTranslate="translate-x-3"
+ />
+ <div className="flex items-center gap-1 text-sm font-medium text-neutral-600">
+ <span>Billed yearly</span>
<Badge
- variant="sky"
- className="px-1.5 py-0.5 text-[0.5rem] uppercase"
+ variant="outline"
+ size="sm"
+ className={cn(
+ "animate-in fade-in-0 slide-in-from-right-2 duration-150",
+ period === "monthly" && "-translate-x-2 opacity-0",
+ )}
>
- Recommended
+ Save 17%
</Badge>
- )
- : plan.name === "Business" && (
- <Badge variant="sky">Most popular</Badge>
- )}
- </div>
- <div className="mt-1 text-base font-medium text-neutral-400">
- <NumberFlow
- value={plan.price[period]!}
- className="tabular-nums text-neutral-700"
- format={{
- style: "currency",
- currency: "USD",
- maximumFractionDigits: 0,
- }}
- continuous
- />
- <span className="ml-1 font-medium">
- per month
- {period === "yearly" && ", billed yearly"}
- </span>
- </div>
- <div className="my-6 flex gap-2">
- <button
- type="button"
- className="h-full w-fit rounded-lg bg-neutral-100 px-2.5 transition-colors duration-75 hover:bg-neutral-200/80 enabled:active:bg-neutral-200 disabled:opacity-30 lg:hidden"
- disabled={mobilePlanIndex === 0}
- onClick={() => setMobilePlanIndex(mobilePlanIndex - 1)}
- >
- <ChevronLeft className="size-5 text-neutral-800" />
- </button>
- <UpgradePlanButton
- plan={plan.name.toLowerCase()}
- period={period}
- text="Get started"
- className="h-10 rounded-lg shadow-sm"
- />
- <button
- type="button"
- className="h-full w-fit rounded-lg bg-neutral-100 px-2.5 transition-colors duration-75 hover:bg-neutral-200/80 active:bg-neutral-200 disabled:opacity-30 lg:hidden"
- disabled={mobilePlanIndex >= PLAN_SELECTOR_PLANS.length - 1}
- onClick={() => setMobilePlanIndex(mobilePlanIndex + 1)}
- >
- <ChevronRight className="size-5 text-neutral-800" />
- </button>
+ </div>
+ </label>
+ </div>
+
+ <p className="min-h-10 text-sm text-neutral-600">
+ {PRICING_PLAN_TAGLINES[product][plan.name]}
+ </p>
+
+ <div className="flex gap-2">
+ <button
+ type="button"
+ className="h-full w-fit rounded-lg bg-neutral-100 px-2.5 transition-colors duration-75 hover:bg-neutral-200/80 enabled:active:bg-neutral-200 disabled:opacity-30 lg:hidden"
+ disabled={mobilePlanIndex === 0}
+ onClick={() => setMobilePlanIndex(mobilePlanIndex - 1)}
+ >
+ <ChevronLeft className="size-5 text-neutral-800" />
+ </button>
+ <UpgradePlanButton
+ plan={plan.name.toLowerCase()}
+ period={period}
+ text="Get started"
+ className="h-10 rounded-lg shadow-sm"
+ />
+ <button
+ type="button"
+ className="h-full w-fit rounded-lg bg-neutral-100 px-2.5 transition-colors duration-75 hover:bg-neutral-200/80 active:bg-neutral-200 disabled:opacity-30 lg:hidden"
+ disabled={mobilePlanIndex >= plans.length - 1}
+ onClick={() => setMobilePlanIndex(mobilePlanIndex + 1)}
+ >
+ <ChevronRight className="size-5 text-neutral-800" />
+ </button>
+ </div>
+ <div className="flex flex-col gap-3 text-sm">
+ {features.map(({ title, subtitle, features }, idx) => (
+ <div key={idx} className="relative flex flex-col">
+ {title && (
+ <h4 className="mb-3 font-medium text-neutral-700">
+ {title}
+ </h4>
+ )}
+ {subtitle && (
+ <p className="mb-2.5 text-neutral-500">{subtitle}</p>
+ )}
+ <ul className="flex flex-col gap-2.5 pb-3">
+ {features.map(
+ ({ id, text, tooltip, disabled }, idx) => {
+ const Icon =
+ id && PLAN_FEATURE_ICONS[id]
+ ? PLAN_FEATURE_ICONS[id]
+ : Check;
+
+ return (
+ <li
+ key={idx}
+ className={cn(
+ "flex items-center gap-2 text-neutral-600",
+ disabled && "opacity-40",
+ )}
+ >
+ {disabled ? (
+ <X className="size-3 shrink-0" />
+ ) : Icon ? (
+ <Icon className="size-4 shrink-0" />
+ ) : (
+ <Check className="size-3 shrink-0" />
+ )}
+ {tooltip ? (
+ <Tooltip
+ content={
+ typeof tooltip === "string" ||
+ isReactNode(tooltip)
+ ? tooltip
+ : `${tooltip.title} [${tooltip.cta}](${tooltip.href})`
+ }
+ >
+ <p className="cursor-help underline decoration-dotted underline-offset-2">
+ {text}
+ </p>
+ </Tooltip>
+ ) : (
+ <p>{text}</p>
+ )}
+ </li>
+ );
+ },
+ )}
+ </ul>
+ </div>
+ ))}
+ </div>
</div>
- <PlanFeatures className="mt-2" plan={plan.name} />
+
+ {Boolean(
+ (product === "links" && plan.limits.payouts) ||
+ product === "partners",
+ ) && (
+ <div className="flex grow flex-col justify-end">
+ <div className="relative z-0 bg-neutral-100">
+ <div className="border-border-subtle pointer-events-none relative z-10 -mx-px h-2.5 rounded-b-[0.625rem] border-x border-b bg-white" />
+ <a
+ href={`https://dub.co/${product === "links" ? "partners" : "links"}`}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="group peer relative z-10 flex items-center justify-center px-5 py-2.5 transition-transform duration-100 active:scale-[0.97]"
+ >
+ <div className="relative flex items-center gap-2 transition-[transform,opacity] group-hover:-translate-y-1 group-hover:opacity-0">
+ <DubProductIcon
+ product={product === "links" ? "partners" : "links"}
+ className="size-[1.125rem]"
+ />
+ <span className="text-content-default block text-sm">
+ Includes{" "}
+ <strong className="font-semibold">
+ Dub {product === "links" ? "Partners" : "Links"}
+ </strong>
+ </span>
+ </div>
+
+ <div className="absolute inset-0 flex translate-y-1 items-center justify-center opacity-0 transition-[transform,opacity] group-hover:translate-y-0 group-hover:opacity-100">
+ <span className="text-content-default block whitespace-nowrap text-sm font-medium">
+ Learn more ↗
+ </span>
+ </div>
+ </a>
+ <div
+ className={cn(
+ "pointer-events-none absolute inset-0 opacity-0 duration-100 peer-hover:opacity-5",
+ product === "links" ? "bg-violet-700" : "bg-orange-700",
+ )}
+ />
+ </div>
+ </div>
+ )}
</div>
- ))}
- </div>
+ );
+ })}
</div>
</div>
);
}
+
+const isReactNode = (element: any): element is ReactNode =>
+ isValidElement(element);
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/products/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/products/page.tsx
new file mode 100644
index 0000000000..faa7a9b26a
--- /dev/null
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/products/page.tsx
@@ -0,0 +1,14 @@
+import { StepPage } from "../step-page";
+import { ProductSelector } from "./product-selector";
+
+export default function Products() {
+ return (
+ <StepPage
+ title="What do you want to do with Dub?"
+ description="Choose how you'll use Dub to grow your business"
+ className="max-w-none"
+ >
+ <ProductSelector />
+ </StepPage>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/products/product-selector.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/products/product-selector.tsx
new file mode 100644
index 0000000000..3262536a30
--- /dev/null
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/products/product-selector.tsx
@@ -0,0 +1,111 @@
+"use client";
+
+import { MarkdownDescription } from "@/ui/shared/markdown-description";
+import { Button, Crown, DubProductIcon } from "@dub/ui";
+import Image from "next/image";
+import { ReactNode } from "react";
+import { useOnboardingProgress } from "../../use-onboarding-progress";
+
+const products = {
+ links: {
+ image: "https://assets.dub.co/icons/link.webp",
+ title: "Dub Links",
+ href: "https://dub.co/links",
+ description:
+ "[Short links](https://dub.co/help/category/link-management), [QR codes](https://dub.co/help/article/custom-qr-codes), [real-time analytics](https://dub.co/help/article/dub-analytics), and [conversion tracking](https://dub.co/docs/conversions/quickstart).",
+ paidPlanRequired: false,
+ },
+ partners: {
+ image: "https://assets.dub.co/icons/trophy.webp",
+ title: "Dub Partners",
+ href: "https://dub.co/partners",
+ description:
+ "Modern [affiliate programs](https://dub.co/partners) with [global payouts](https://dub.co/help/article/partner-payouts) and [accurate attribution](https://dub.co/help/article/program-analytics).",
+ paidPlanRequired: true,
+ },
+};
+
+export function ProductSelector() {
+ return (
+ <div className="animate-fade-in mx-auto grid w-full max-w-[312px] gap-4 sm:max-w-[600px] sm:grid-cols-2">
+ {Object.entries(products).map(([key, product]) => (
+ <ProductOption
+ key={key}
+ product={key as "links" | "partners"}
+ icon={product.image}
+ title={
+ <a
+ href={product.href}
+ target="_blank"
+ className="group flex items-center justify-center gap-2"
+ >
+ <DubProductIcon
+ product={key as "links" | "partners"}
+ className="transition-transform group-hover:-rotate-12 group-hover:scale-110"
+ />{" "}
+ {product.title}
+ </a>
+ }
+ description={product.description}
+ cta={`Continue with ${product.title}`}
+ paidPlanRequired={product.paidPlanRequired}
+ />
+ ))}
+ </div>
+ );
+}
+
+function ProductOption({
+ product,
+ icon,
+ title,
+ description,
+ cta,
+ paidPlanRequired,
+}: {
+ product: "links" | "partners";
+ icon: string;
+ title: ReactNode;
+ description: string;
+ cta: string;
+ paidPlanRequired?: boolean;
+}) {
+ const { continueTo, isLoading, isSuccessful } = useOnboardingProgress();
+ return (
+ <div className="relative flex h-full flex-col items-center gap-6 rounded-xl border border-neutral-300 p-6 pt-12 transition-all">
+ {paidPlanRequired && (
+ <div className="absolute inset-x-2 top-2 flex items-center justify-center gap-2 rounded-md border border-neutral-200 bg-neutral-100 px-2.5 py-1 text-xs font-medium text-neutral-600">
+ <Crown className="size-3" />
+ Paid plan required
+ </div>
+ )}
+ <div className="relative size-36">
+ <Image
+ src={icon}
+ alt=""
+ fill
+ className="object-contain"
+ fetchPriority="high"
+ />
+ </div>
+ <div className="space-y-2 text-center">
+ <span className="text-base font-semibold text-neutral-900">
+ {title}
+ </span>
+ <MarkdownDescription className="text-sm text-neutral-500">
+ {description}
+ </MarkdownDescription>
+ </div>
+ <div className="flex w-full grow flex-col justify-end gap-2">
+ <Button
+ type="button"
+ variant="primary"
+ className="rounded-lg"
+ onClick={() => continueTo("domain", { params: { product } })}
+ loading={isLoading || isSuccessful}
+ text={cta}
+ />
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/form.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/form.tsx
new file mode 100644
index 0000000000..234a929adb
--- /dev/null
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/form.tsx
@@ -0,0 +1,206 @@
+"use client";
+
+import { onboardProgramAction } from "@/lib/actions/partners/onboard-program";
+import useWorkspace from "@/lib/swr/use-workspace";
+import { ProgramData } from "@/lib/types";
+import { Button, FileUpload, Input, useMediaQuery } from "@dub/ui";
+import { Plus } from "lucide-react";
+import { useAction } from "next-safe-action/hooks";
+import { useState } from "react";
+import { Controller, useFormContext } from "react-hook-form";
+import { toast } from "sonner";
+import { useOnboardingProgress } from "../../use-onboarding-progress";
+
+export function Form() {
+ const { isMobile } = useMediaQuery();
+ const [isUploading, setIsUploading] = useState(false);
+ const [hasSubmitted, setHasSubmitted] = useState(false);
+ const { id: workspaceId, mutate } = useWorkspace();
+
+ const { continueTo } = useOnboardingProgress();
+
+ const {
+ register,
+ handleSubmit,
+ control,
+ setValue,
+ formState: { isSubmitting, errors },
+ } = useFormContext<ProgramData>();
+
+ const { executeAsync, isPending } = useAction(onboardProgramAction, {
+ onSuccess: () => {
+ continueTo("program/reward");
+ mutate();
+ },
+ onError: ({ error }) => {
+ toast.error(error.serverError as string);
+ setHasSubmitted(false);
+ },
+ });
+
+ const onSubmit = async (data: ProgramData) => {
+ if (!workspaceId) return;
+
+ setHasSubmitted(true);
+ await executeAsync({
+ ...data,
+ workspaceId,
+ step: "get-started",
+ });
+ };
+
+ // Handle logo upload
+ const handleUpload = async (file: File) => {
+ setIsUploading(true);
+
+ try {
+ const response = await fetch(
+ `/api/workspaces/${workspaceId}/upload-url`,
+ {
+ method: "POST",
+ body: JSON.stringify({
+ folder: "program-logos",
+ }),
+ },
+ );
+
+ if (!response.ok) {
+ throw new Error("Failed to get signed URL for upload.");
+ }
+
+ const { signedUrl, destinationUrl } = await response.json();
+
+ const uploadResponse = await fetch(signedUrl, {
+ method: "PUT",
+ body: file,
+ headers: {
+ "Content-Type": file.type,
+ "Content-Length": file.size.toString(),
+ },
+ });
+
+ if (!uploadResponse.ok) {
+ throw new Error("Failed to upload to signed URL");
+ }
+
+ setValue("logo", destinationUrl, { shouldDirty: true });
+ toast.success(`${file.name} uploaded!`);
+ } catch (e) {
+ toast.error("Failed to upload logo");
+ } finally {
+ setIsUploading(false);
+ }
+ };
+
+ return (
+ <form onSubmit={handleSubmit(onSubmit)} className="flex flex-col gap-6">
+ <label className="space-y-2">
+ <span className="text-content-emphasis block text-sm font-semibold">
+ Company name
+ </span>
+
+ <Input
+ {...register("name", { required: true })}
+ placeholder="Acme, Inc."
+ autoFocus={!isMobile}
+ className="max-w-full"
+ error={errors.name?.message}
+ />
+
+ <p className="text-content-subtle text-xs">
+ This will used as your program's public name
+ </p>
+ </label>
+
+ <label className="space-y-2">
+ <span className="text-content-emphasis block text-sm font-semibold">
+ Logo
+ </span>
+
+ <div className="flex w-full items-center justify-center gap-2 rounded-lg border border-neutral-200 p-1">
+ <Controller
+ control={control}
+ name="logo"
+ rules={{ required: true }}
+ render={({ field }) => (
+ <FileUpload
+ accept="images"
+ className="size-14 rounded-lg"
+ iconClassName="size-4 text-neutral-800"
+ icon={Plus}
+ variant="plain"
+ loading={isUploading}
+ imageSrc={field.value}
+ readFile
+ onChange={({ file }) => handleUpload(file)}
+ content={null}
+ maxFileSizeMB={2}
+ />
+ )}
+ />
+ </div>
+
+ <p className="text-content-subtle text-xs">
+ Recommended size: 160&times;160px
+ </p>
+ </label>
+
+ <label className="space-y-2">
+ <span className="text-content-emphasis block text-sm font-semibold">
+ Destination URL
+ </span>
+
+ <Controller
+ control={control}
+ name="url"
+ render={({ field }) => (
+ <Input
+ value={field.value || ""}
+ onChange={(e) => field.onChange(e.target.value)}
+ type="url"
+ placeholder="https://"
+ className="max-w-full"
+ error={errors.url?.message}
+ />
+ )}
+ />
+
+ <p className="text-content-subtle text-xs">
+ Where customers will be redirected to when they click on your
+ partners' referral links
+ </p>
+ </label>
+
+ <label className="space-y-2">
+ <span className="text-content-emphasis block text-sm font-semibold">
+ Support email
+ </span>
+
+ <Controller
+ control={control}
+ name="supportEmail"
+ render={({ field }) => (
+ <Input
+ value={field.value || ""}
+ onChange={(e) => field.onChange(e.target.value)}
+ type="email"
+ className="max-w-full"
+ error={errors.supportEmail?.message}
+ />
+ )}
+ />
+
+ <p className="text-content-subtle text-xs">
+ Displayed to your partners on their dashboard
+ </p>
+ </label>
+
+ <Button
+ type="submit"
+ loading={isSubmitting || isPending || hasSubmitted}
+ text="Continue"
+ className="w-full"
+ />
+ </form>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/page-client.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/page-client.tsx
new file mode 100644
index 0000000000..67ac4f7dbe
--- /dev/null
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/page-client.tsx
@@ -0,0 +1,33 @@
+"use client";
+
+import { ProgramOnboardingFormWrapper } from "@/ui/partners/program-onboarding-form-wrapper";
+import { cn } from "@dub/utils/src";
+import { StepPage } from "../step-page";
+import { Form } from "./form";
+import { useOnboardingProgram } from "./use-onboarding-program";
+
+export function ProgramPageClient({ domain }: { domain: string }) {
+ const { isLoading, formWrapperProps } = useOnboardingProgram({ domain });
+
+ return (
+ <StepPage
+ title="Create your partner program"
+ description="Set up your program in a few steps"
+ >
+ <div
+ className={cn(
+ "transition-opacity",
+ isLoading && "pointer-events-none opacity-50",
+ )}
+ inert={isLoading}
+ >
+ <ProgramOnboardingFormWrapper
+ key={isLoading ? "loading" : "loaded"}
+ {...formWrapperProps}
+ >
+ <Form />
+ </ProgramOnboardingFormWrapper>
+ </div>
+ </StepPage>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/page.tsx
new file mode 100644
index 0000000000..99c31ae5ba
--- /dev/null
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/page.tsx
@@ -0,0 +1,51 @@
+import { getSession } from "@/lib/auth";
+import { redis } from "@/lib/upstash";
+import { prisma } from "@dub/prisma";
+import { redirect } from "next/navigation";
+import { ProgramPageClient } from "./page-client";
+
+export default async function ProgramPage({
+ searchParams,
+}: {
+ searchParams: Promise<{ workspace?: string }>;
+}) {
+ const { workspace: slug } = await searchParams;
+
+ if (!slug) redirect("/onboarding");
+
+ const { user } = await getSession();
+
+ const workspace = await prisma.project.findUniqueOrThrow({
+ where: {
+ slug,
+ users: {
+ some: {
+ userId: user.id,
+ },
+ },
+ },
+ select: {
+ id: true,
+ domains: {
+ orderBy: {
+ createdAt: "desc",
+ },
+ take: 1,
+ },
+ },
+ });
+
+ const data = await redis.get<{ domain: string; userId: string }>(
+ `onboarding-domain:${workspace.id}`,
+ );
+
+ const onboardingDomain =
+ data && data.domain && data.userId === user.id ? data.domain : null;
+
+ const domain = onboardingDomain || workspace.domains[0]?.slug;
+
+ if (!domain)
+ redirect(`/onboarding/domain?workspace=${slug}&product=partners`);
+
+ return <ProgramPageClient domain={domain} />;
+}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/form.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/form.tsx
new file mode 100644
index 0000000000..d7230f7f46
--- /dev/null
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/form.tsx
@@ -0,0 +1,309 @@
+"use client";
+
+import { onboardProgramAction } from "@/lib/actions/partners/onboard-program";
+import { handleMoneyInputChange, handleMoneyKeyDown } from "@/lib/form-utils";
+import useWorkspace from "@/lib/swr/use-workspace";
+import { ProgramData } from "@/lib/types";
+import { RECURRING_MAX_DURATIONS } from "@/lib/zod/schemas/misc";
+import { COMMISSION_TYPES } from "@/lib/zod/schemas/rewards";
+import { AnimatedSizeContainer, Button, CircleCheckFill } from "@dub/ui";
+import { cn } from "@dub/utils";
+import { useAction } from "next-safe-action/hooks";
+import { useEffect, useState } from "react";
+import { useFormContext } from "react-hook-form";
+import { toast } from "sonner";
+import { useOnboardingProgress } from "../../../use-onboarding-progress";
+
+const DEFAULT_REWARD_TYPES = [
+ {
+ key: "sale",
+ label: "Sale",
+ description: "For purchases",
+ },
+ {
+ key: "lead",
+ label: "Lead",
+ description: "For sign ups",
+ },
+] as const;
+
+export function Form() {
+ const { continueTo } = useOnboardingProgress();
+
+ const [hasSubmitted, setHasSubmitted] = useState(false);
+ const { id: workspaceId, mutate } = useWorkspace();
+
+ const {
+ register,
+ handleSubmit,
+ watch,
+ setValue,
+ formState: { isSubmitting },
+ } = useFormContext<ProgramData>();
+
+ const [type, defaultRewardType, maxDuration] = watch([
+ "type",
+ "defaultRewardType",
+ "maxDuration",
+ ]);
+
+ const [commissionStructure, setCommissionStructure] = useState<
+ "one-off" | "recurring"
+ >("one-off");
+
+ useEffect(
+ () => setCommissionStructure(maxDuration ? "recurring" : "one-off"),
+ [maxDuration],
+ );
+
+ const { executeAsync, isPending } = useAction(onboardProgramAction, {
+ onSuccess: () => {
+ continueTo("plan");
+ mutate();
+ },
+ onError: ({ error }) => {
+ toast.error(error.serverError);
+ },
+ });
+
+ const onSubmit = async (data: ProgramData) => {
+ if (!workspaceId) {
+ return;
+ }
+
+ setHasSubmitted(true);
+
+ await executeAsync({
+ ...data,
+ amountInCents:
+ data.amountInCents != null && data.type === "flat"
+ ? Math.round(data.amountInCents * 100)
+ : null,
+ amountInPercentage:
+ data.amountInPercentage != null && data.type === "percentage"
+ ? data.amountInPercentage
+ : null,
+ workspaceId,
+ step: "configure-reward",
+ });
+ };
+
+ return (
+ <form
+ onSubmit={handleSubmit(onSubmit)}
+ className="flex flex-col gap-6 px-2"
+ >
+ <div className="grid grid-cols-1 gap-2">
+ <h2 className="text-content-emphasis text-sm font-semibold">
+ Reward type
+ </h2>
+
+ <div className="grid grid-cols-1 gap-3 lg:grid-cols-2">
+ {DEFAULT_REWARD_TYPES.map(({ key, label, description }) => {
+ const isSelected = key === defaultRewardType;
+
+ return (
+ <label
+ key={key}
+ className={cn(
+ "relative flex w-full cursor-pointer items-start gap-0.5 rounded-md border border-neutral-200 bg-white p-3 text-neutral-600 hover:bg-neutral-50",
+ "transition-all duration-150",
+ isSelected &&
+ "border-black bg-neutral-50 text-neutral-900 ring-1 ring-black",
+ )}
+ >
+ <input
+ type="radio"
+ value={key}
+ className="hidden"
+ checked={isSelected}
+ onChange={() => {
+ setValue("defaultRewardType", key, {
+ shouldDirty: true,
+ });
+
+ if (key === "lead") {
+ setValue("type", "flat", { shouldDirty: true });
+ setValue("maxDuration", 0, { shouldDirty: true });
+ }
+ }}
+ />
+ <div className="flex grow flex-col text-sm">
+ <span className="text-sm font-semibold text-neutral-900">
+ {label}
+ </span>
+ <span className="text-sm font-normal text-neutral-600">
+ {description}
+ </span>
+ </div>
+ <CircleCheckFill
+ className={cn(
+ "-mr-px -mt-px flex size-4 scale-75 items-center justify-center rounded-full opacity-0 transition-[transform,opacity] duration-150",
+ isSelected && "scale-100 opacity-100",
+ )}
+ />
+ </label>
+ );
+ })}
+ </div>
+ </div>
+
+ <div className="-m-1">
+ <AnimatedSizeContainer
+ height
+ transition={{ duration: 0.2, ease: "easeOut" }}
+ >
+ <div className="flex flex-col gap-6 p-1">
+ {defaultRewardType === "sale" && (
+ <div className="space-y-2">
+ <h2 className="text-content-emphasis text-sm font-semibold">
+ Commission structure
+ </h2>
+
+ <div className="grid grid-cols-1 gap-3 lg:grid-cols-2">
+ {COMMISSION_TYPES.map(
+ ({ value, label, shortDescription }) => {
+ const isSelected = value === commissionStructure;
+
+ return (
+ <label
+ key={value}
+ className={cn(
+ "relative flex w-full cursor-pointer items-start gap-0.5 rounded-md border border-neutral-200 bg-white p-3 text-neutral-600 hover:bg-neutral-50",
+ "transition-all duration-150",
+ isSelected &&
+ "border-black bg-neutral-50 text-neutral-900 ring-1 ring-black",
+ )}
+ >
+ <input
+ type="radio"
+ value={value}
+ className="hidden"
+ checked={isSelected}
+ onChange={(e) => {
+ if (value === "one-off") {
+ setCommissionStructure("one-off");
+ setValue("maxDuration", 0, {
+ shouldValidate: true,
+ });
+ }
+
+ if (value === "recurring") {
+ setCommissionStructure("recurring");
+ setValue("maxDuration", 12, {
+ shouldValidate: true,
+ });
+ }
+ }}
+ />
+ <div className="flex grow flex-col text-sm">
+ <span className="text-sm font-semibold text-neutral-900">
+ {label}
+ </span>
+ <span className="text-sm font-normal text-neutral-600">
+ {shortDescription}
+ </span>
+ </div>
+ <CircleCheckFill
+ className={cn(
+ "-mr-px -mt-px flex size-4 scale-75 items-center justify-center rounded-full opacity-0 transition-[transform,opacity] duration-150",
+ isSelected && "scale-100 opacity-100",
+ )}
+ />
+ </label>
+ );
+ },
+ )}
+ </div>
+ </div>
+ )}
+
+ {defaultRewardType === "sale" &&
+ commissionStructure === "recurring" && (
+ <label className="space-y-2">
+ <span className="block text-sm font-medium text-neutral-800">
+ Duration
+ </span>
+ <select
+ {...register("maxDuration", {
+ setValueAs: (v) => {
+ if (v === "" || v === null) {
+ return null;
+ }
+
+ return parseInt(v);
+ },
+ })}
+ className="block w-full rounded-md border border-neutral-300 bg-white py-2 pl-3 pr-10 text-sm text-neutral-900 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500"
+ >
+ {RECURRING_MAX_DURATIONS.filter(
+ (v) => v !== 0 && v !== 1, // filter out one-time and 1-month intervals (we only use 1-month for discounts)
+ ).map((duration) => (
+ <option key={duration} value={duration}>
+ {duration} {duration === 1 ? "month" : "months"}
+ </option>
+ ))}
+ <option value="">Lifetime</option>
+ </select>
+ </label>
+ )}
+
+ {defaultRewardType === "sale" && (
+ <label className="space-y-2">
+ <span className="text-content-emphasis block text-sm font-semibold">
+ Payout model
+ </span>
+ <select
+ {...register("type")}
+ className="block w-full rounded-md border border-neutral-300 bg-white py-2 pl-3 pr-10 text-sm text-neutral-900 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500"
+ >
+ <option value="flat">Flat</option>
+ <option value="percentage">Percentage</option>
+ </select>
+ </label>
+ )}
+
+ <label className="space-y-2">
+ <span className="text-content-emphasis block text-sm font-semibold">
+ Amount per {defaultRewardType}
+ </span>
+ <div className="relative rounded-md shadow-sm">
+ <span className="absolute inset-y-0 left-0 flex items-center pl-3 text-sm text-neutral-400">
+ {type === "flat" && "$"}
+ </span>
+ <input
+ className={cn(
+ "block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",
+ type === "flat" ? "pl-6 pr-12" : "pr-7",
+ )}
+ {...register(
+ type === "flat" ? "amountInCents" : "amountInPercentage",
+ {
+ required: true,
+ valueAsNumber: true,
+ min: 0,
+ max: type === "flat" ? 1000 : 100,
+ onChange: handleMoneyInputChange,
+ },
+ )}
+ onKeyDown={handleMoneyKeyDown}
+ />
+ <span className="absolute inset-y-0 right-0 flex items-center pr-3 text-sm text-neutral-400">
+ {type === "flat" ? "USD" : "%"}
+ </span>
+ </div>
+ </label>
+ </div>
+ </AnimatedSizeContainer>
+ </div>
+
+ <Button
+ text="Continue"
+ className="w-full"
+ loading={isSubmitting || isPending}
+ disabled={hasSubmitted}
+ type="submit"
+ />
+ </form>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/page.tsx
new file mode 100644
index 0000000000..2e50386808
--- /dev/null
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/page.tsx
@@ -0,0 +1,39 @@
+"use client";
+
+import { ProgramOnboardingFormWrapper } from "@/ui/partners/program-onboarding-form-wrapper";
+import { cn } from "@dub/utils";
+import { StepPage } from "../../step-page";
+import { useOnboardingProgram } from "../use-onboarding-program";
+import { Form } from "./form";
+
+export default function ProgramReward() {
+ const { isLoading, formWrapperProps } = useOnboardingProgram();
+
+ return (
+ <StepPage
+ title="Create your default reward"
+ description={
+ <>
+ The default reward offered to your partners.
+ <br />
+ You can change this at any time.
+ </>
+ }
+ >
+ <div
+ className={cn(
+ "transition-opacity",
+ isLoading && "pointer-events-none opacity-50",
+ )}
+ inert={isLoading}
+ >
+ <ProgramOnboardingFormWrapper
+ key={isLoading ? "loading" : "loaded"}
+ {...formWrapperProps}
+ >
+ <Form />
+ </ProgramOnboardingFormWrapper>
+ </div>
+ </StepPage>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/use-onboarding-program.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/use-onboarding-program.tsx
new file mode 100644
index 0000000000..6aa2b76dcd
--- /dev/null
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/use-onboarding-program.tsx
@@ -0,0 +1,19 @@
+"use client";
+
+import useWorkspace from "@/lib/swr/use-workspace";
+
+export function useOnboardingProgram({ domain }: { domain?: string } = {}) {
+ const { slug, name, logo } = useWorkspace();
+
+ return {
+ isLoading: slug === undefined,
+ formWrapperProps: {
+ defaultValues: {
+ name: name ?? undefined,
+ logo: logo ?? undefined,
+ domain,
+ maxDuration: 0,
+ },
+ },
+ };
+}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/step-page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/step-page.tsx
index 3fa8054708..bf930c7897 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/step-page.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/step-page.tsx
@@ -1,3 +1,4 @@
+import { Icon } from "@dub/ui";
import { cn } from "@dub/utils";
import { Crown } from "lucide-react";
import { PropsWithChildren, ReactNode } from "react";
@@ -7,13 +8,20 @@ export function StepPage({
title,
description,
paidPlanRequired,
+ badge,
className,
}: PropsWithChildren<{
title: ReactNode;
description: ReactNode;
paidPlanRequired?: boolean;
+ badge?: {
+ icon: Icon;
+ label: string;
+ };
className?: string;
}>) {
+ const BadgeIcon = badge?.icon ?? Crown;
+
return (
<div
className={cn(
@@ -22,10 +30,10 @@ export function StepPage({
className,
)}
>
- {paidPlanRequired && (
+ {Boolean(badge || paidPlanRequired) && (
<div className="mb-3 flex items-center gap-2 rounded-full border border-neutral-200 bg-neutral-100 px-2.5 py-0.5 text-xs font-medium text-neutral-600">
- <Crown className="size-3" />
- Paid plan required
+ <BadgeIcon className="size-3" />
+ {badge?.label ?? "Paid plan required"}
</div>
)}
<h1 className="text-center text-xl font-semibold">{title}</h1>
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/success/page-client.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/success/page-client.tsx
new file mode 100644
index 0000000000..95a2d7734c
--- /dev/null
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/success/page-client.tsx
@@ -0,0 +1,300 @@
+"use client";
+
+import { DIRECT_DEBIT_PAYMENT_METHOD_TYPES } from "@/lib/constants/payouts";
+import useDomains from "@/lib/swr/use-domains";
+import usePaymentMethods from "@/lib/swr/use-payment-methods";
+import useWorkspace from "@/lib/swr/use-workspace";
+import { WorkspaceProps } from "@/lib/types";
+import { useAnalyticsConnectedStatus } from "@/ui/analytics/use-analytics-connected-status";
+import { MarkdownDescription } from "@/ui/shared/markdown-description";
+import {
+ BlurImage,
+ Book2,
+ Button,
+ Check2,
+ CircleQuestion,
+ ConnectedDots4,
+ CursorRays,
+ Globe,
+ GreekTemple,
+ Hyperlink,
+ LinesY,
+ LoadingSpinner,
+ Msg,
+ Plug2,
+ Users,
+} from "@dub/ui";
+import { cn } from "@dub/utils";
+import Link from "next/link";
+import { useOnboardingProgress } from "../../use-onboarding-progress";
+
+export function SuccessPageClient({
+ workspace,
+}: {
+ workspace: Pick<
+ WorkspaceProps,
+ "name" | "slug" | "logo" | "defaultProgramId"
+ >;
+}) {
+ const { loading: isLoadingWorkspace } = useWorkspace();
+
+ const { finish, isLoading, isSuccessful } = useOnboardingProgress();
+
+ const hasProgram = Boolean(workspace.defaultProgramId);
+
+ const { allWorkspaceDomains, loading: isLoadingDomains } = useDomains();
+ const connectedDomain = Boolean(allWorkspaceDomains?.length);
+
+ const { isConnected: connectedAnalytics } = useAnalyticsConnectedStatus();
+ const { paymentMethods, loading: isLoadingPaymentMethods } =
+ usePaymentMethods({
+ enabled: hasProgram,
+ });
+ const connectedBankAccount = paymentMethods?.some((pm) =>
+ DIRECT_DEBIT_PAYMENT_METHOD_TYPES.includes(pm.type),
+ );
+
+ return (
+ <div className="mx-auto flex w-full max-w-sm flex-col items-center pb-10">
+ <div
+ className={cn(
+ "flex flex-col items-center",
+ "animate-slide-up-fade [--offset:10px] [animation-duration:1s] [animation-fill-mode:both]",
+ )}
+ >
+ {workspace.logo && (
+ <div className="relative mb-5">
+ <BlurImage
+ src={workspace.logo}
+ alt="workspace logo"
+ className="size-24 rounded-full"
+ width={96}
+ height={96}
+ />
+ <div className="absolute -bottom-1 -right-1 flex size-7 items-center justify-center rounded-full bg-green-400 ring-4 ring-white">
+ <Check2 className="size-4 text-green-800" />
+ </div>
+ </div>
+ )}
+ <h1 className="text-pretty text-center text-xl font-semibold">
+ The {workspace.name} workspace has been created
+ </h1>
+ <MarkdownDescription className="mt-2 text-pretty text-center text-base text-neutral-500">
+ {hasProgram
+ ? "Now you can manage your [partner program](https://dub.co/partners) and [short links](https://dub.co/links) all in one place"
+ : "Now you have one central, organized place to create and [manage all your short links](https://dub.co/help/category/link-management)."}
+ </MarkdownDescription>
+ <div className="mt-4 w-full">
+ <Button
+ onClick={() => finish({ hasProgram })}
+ loading={isLoading || isSuccessful}
+ text="Go to your dashboard"
+ className="h-9 rounded-lg"
+ />
+ </div>
+ </div>
+
+ <div
+ className={cn(
+ "mt-8 flex w-full max-w-[400px] flex-col gap-3",
+ "animate-slide-up-fade motion-reduce:animate-fade-in [--offset:10px] [animation-delay:250ms] [animation-duration:0.5s] [animation-fill-mode:both]",
+ )}
+ >
+ <h3 className="text-content-emphasis font-semibold">Complete setup</h3>
+
+ <div className="divide-border-subtle border-border-subtle bg-bg-muted flex flex-col divide-y overflow-hidden rounded-lg border">
+ {[
+ {
+ icon: Globe,
+ title: "Connect domain",
+ description: "Claim a free domain or connect your own",
+ href: `/${workspace.slug}/settings/domains`,
+ cta: connectedDomain ? "Manage" : "Connect",
+ loading: isLoadingDomains,
+ complete: Boolean(allWorkspaceDomains?.length),
+ },
+ ...(hasProgram
+ ? [
+ {
+ icon: ConnectedDots4,
+ title: "Create a program",
+ description: "Set up your Dub partner program",
+ href: `/${workspace.slug}/program`,
+ cta: "Manage",
+ complete: true,
+ },
+ {
+ icon: Plug2,
+ title: "Set up conversion tracking",
+ description: "Install the Dub tracking script",
+ href: `/${workspace.slug}/settings/analytics`,
+ cta: "Install",
+ loading: isLoadingWorkspace,
+ complete: connectedAnalytics,
+ },
+ {
+ icon: GreekTemple,
+ title: "Connect bank account",
+ description: "Connect a bank account for payouts",
+ href: `/${workspace.slug}/program/payouts`,
+ cta: "Connect",
+ loading: isLoadingWorkspace || isLoadingPaymentMethods,
+ complete: connectedBankAccount,
+ },
+ ]
+ : [
+ {
+ icon: Hyperlink,
+ title: "Create a short link",
+ description: "Create your first Dub short link",
+ href: `/${workspace.slug}/links?newLink=true`,
+ cta: "Create",
+ },
+ {
+ icon: LinesY,
+ title: "Explore analytics",
+ description: "View clicks and performance data",
+ href: `/${workspace.slug}/analytics`,
+ cta: "View",
+ },
+ {
+ icon: CursorRays,
+ title: "Explore events",
+ description: "View events for your short links",
+ href: `/${workspace.slug}/events`,
+ cta: "View",
+ },
+ ]),
+ ].map(
+ ({
+ icon: Icon,
+ title,
+ description,
+ href,
+ cta,
+ loading,
+ complete,
+ }) => (
+ <div
+ key={href}
+ className={cn(
+ "flex items-center justify-between gap-2 px-2.5 py-2",
+ complete && "bg-black/[0.02]",
+ )}
+ >
+ <div className="flex min-w-0 items-center gap-2">
+ <div
+ className={cn(
+ "flex size-8 items-center justify-center rounded-md bg-black/5",
+ complete && "bg-green-400",
+ )}
+ >
+ {loading ? (
+ <LoadingSpinner className="size-4" />
+ ) : complete ? (
+ <Check2 className="size-4 text-green-800" />
+ ) : (
+ <Icon className="size-4" />
+ )}
+ </div>
+ <div
+ className={cn(
+ "min-w-0",
+ (loading || complete) && "opacity-60",
+ )}
+ >
+ <div className="text-content-default text-sm font-medium">
+ {title}
+ </div>
+ <p className="text-content-subtle truncate text-xs font-medium">
+ {description}
+ </p>
+ </div>
+ </div>
+
+ <Link
+ href={href}
+ target="_blank"
+ className="border-subtle bg-bg-default hover:bg-bg-muted flex h-7 items-center rounded-lg border px-2.5 text-sm font-medium transition-transform active:scale-[0.98]"
+ >
+ {cta}
+ </Link>
+ </div>
+ ),
+ )}
+ </div>
+ </div>
+
+ <div
+ className={cn(
+ "mt-8 flex w-full max-w-[400px] flex-col gap-3",
+ "animate-slide-up-fade motion-reduce:animate-fade-in [--offset:10px] [animation-delay:250ms] [animation-duration:0.5s] [animation-fill-mode:both]",
+ )}
+ >
+ <h3 className="text-content-emphasis font-semibold">
+ Additional resources
+ </h3>
+
+ <div className="divide-border-subtle border-border-subtle bg-bg-muted flex flex-col divide-y rounded-lg border">
+ {[
+ {
+ icon: Users,
+ title: "Team members",
+ description: "Invite and manage team members",
+ href: `/${workspace.slug}/settings/members`,
+ cta: "Invite",
+ },
+ {
+ icon: CircleQuestion,
+ title: "Help center",
+ description: "Answers to your questions",
+ href: "https://dub.co/help",
+ cta: "Read",
+ },
+ {
+ icon: Book2,
+ title: "Docs",
+ description: "Platform documentation",
+ href: "https://dub.co/docs",
+ cta: "Learn",
+ },
+ {
+ icon: Msg,
+ title: "Support",
+ description: "Product support or help requests",
+ href: "https://dub.co/contact/support",
+ cta: "Chat",
+ },
+ ].map(({ icon: Icon, title, description, href, cta }) => (
+ <div
+ key={href}
+ className="flex items-center justify-between gap-2 px-2.5 py-2"
+ >
+ <div className="flex min-w-0 items-center gap-2">
+ <div className="flex size-8 items-center justify-center rounded-md bg-black/5">
+ <Icon className="size-4" />
+ </div>
+ <div className="min-w-0">
+ <div className="text-content-default text-sm font-medium">
+ {title}
+ </div>
+ <p className="text-content-subtle truncate text-xs font-medium">
+ {description}
+ </p>
+ </div>
+ </div>
+
+ <Link
+ href={href}
+ target="_blank"
+ className="border-subtle bg-bg-default hover:bg-bg-muted flex h-7 items-center rounded-lg border px-2.5 text-sm font-medium transition-transform active:scale-[0.98]"
+ >
+ {cta}
+ </Link>
+ </div>
+ ))}
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/success/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/success/page.tsx
new file mode 100644
index 0000000000..e82830b22c
--- /dev/null
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/success/page.tsx
@@ -0,0 +1,35 @@
+import { getSession } from "@/lib/auth";
+import { prisma } from "@dub/prisma";
+import { redirect } from "next/navigation";
+import { SuccessPageClient } from "./page-client";
+
+export default async function SuccessPage({
+ searchParams,
+}: {
+ searchParams: Promise<{ workspace: string }>;
+}) {
+ const { workspace: slug } = await searchParams;
+ if (!slug) redirect("/onboarding");
+
+ const { user } = await getSession();
+
+ const workspace = await prisma.project.findUnique({
+ select: {
+ slug: true,
+ name: true,
+ logo: true,
+ defaultProgramId: true,
+ },
+ where: {
+ slug,
+ users: {
+ some: {
+ userId: user.id,
+ },
+ },
+ },
+ });
+ if (!workspace) redirect("/onboarding");
+
+ return <SuccessPageClient workspace={workspace} />;
+}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/usage/form.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/usage/form.tsx
deleted file mode 100644
index b22a18b363..0000000000
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/usage/form.tsx
+++ /dev/null
@@ -1,191 +0,0 @@
-"use client";
-
-import useWorkspace from "@/lib/swr/use-workspace";
-import { useWorkspaceStore } from "@/lib/swr/use-workspace-store";
-import { OnboardingUsageSchema } from "@/lib/zod/schemas/workspaces";
-import { Markdown } from "@/ui/shared/markdown";
-import { Button } from "@dub/ui";
-import { LayoutGroup, motion } from "motion/react";
-import { useId } from "react";
-import { Controller, useForm } from "react-hook-form";
-import * as z from "zod/v4";
-import { useOnboardingProgress } from "../../use-onboarding-progress";
-import { getRecommendedPlan } from "./get-recommended-plan";
-
-type FormData = z.infer<typeof OnboardingUsageSchema>;
-
-export function Form() {
- const { continueTo } = useOnboardingProgress();
-
- const workspace = useWorkspace();
- const [_, setItem] = useWorkspaceStore<FormData>("onboardingUsage");
-
- const {
- control,
- handleSubmit,
- formState: { isSubmitting, isSubmitSuccessful },
- } = useForm<FormData>({
- defaultValues: {
- links: 1_000,
- clicks: 50_000,
- conversions: false,
- partners: false,
- },
- });
-
- return (
- <div>
- <form
- onSubmit={handleSubmit(async (data) => {
- let recommendedPlan: string | undefined;
- if (workspace) {
- try {
- await setItem(data);
- } catch (error) {
- console.error(
- "Failed to save usage answers to workspace store",
- error,
- );
- }
- }
-
- recommendedPlan = getRecommendedPlan(data);
- continueTo("plan", { params: { plan: recommendedPlan } });
- })}
- className="flex flex-col gap-8"
- >
- <Controller
- control={control}
- name="links"
- render={({ field }) => (
- <RadioGroup
- label="How many [links](https://dub.co/help/article/how-to-create-link) do you create per month?"
- options={[
- { id: 1_000, label: "1K or less" },
- { id: 10_000, label: "10K" },
- { id: 50_000, label: "50K" },
- ]}
- selectedId={field.value}
- onSelect={field.onChange}
- />
- )}
- />
-
- <Controller
- control={control}
- name="clicks"
- render={({ field }) => (
- <RadioGroup
- label="How many [clicks](https://dub.co/help/article/dub-analytics) do your links get per month?"
- options={[
- { id: 50_000, label: "50K or less" },
- { id: 250_000, label: "250K" },
- { id: 1_000_000, label: "1M" },
- ]}
- selectedId={field.value}
- onSelect={field.onChange}
- />
- )}
- />
-
- <Controller
- control={control}
- name="conversions"
- render={({ field }) => (
- <RadioGroup
- label="Do you want to [track conversions](https://dub.co/help/article/dub-conversions) on your links?"
- options={[
- { id: false, label: "No" },
- { id: true, label: "Yes" },
- ]}
- selectedId={field.value}
- onSelect={field.onChange}
- />
- )}
- />
-
- <Controller
- control={control}
- name="partners"
- render={({ field }) => (
- <RadioGroup
- label="Do you want to create a [partner program](https://dub.co/help/article/dub-partners)?"
- options={[
- { id: false, label: "No" },
- { id: true, label: "Yes" },
- ]}
- selectedId={field.value}
- onSelect={field.onChange}
- />
- )}
- />
-
- <Button
- type="submit"
- text="Continue"
- loading={isSubmitting || isSubmitSuccessful}
- />
- </form>
- </div>
- );
-}
-
-function RadioGroup<T extends string>({
- label,
- options,
- selectedId,
- onSelect,
-}: {
- label?: string;
- options: { id: T; label: string }[];
- selectedId: T;
- onSelect: (id: T) => void;
-}) {
- const id = useId();
-
- return (
- <div>
- {label && (
- <Markdown className="prose-a:underline-offset-2 mb-1.5 text-sm font-medium">
- {label}
- </Markdown>
- )}
- <div
- className="relative z-0 grid rounded-md border border-neutral-300 bg-neutral-100 p-0.5"
- style={{
- gridTemplateColumns: `repeat(${options.length}, minmax(0, 1fr))`,
- }}
- >
- <LayoutGroup id={`lg-${id}`}>
- {options.map((option) => (
- <label
- key={option.id}
- className="group relative flex cursor-pointer items-center justify-center gap-2 px-4 py-2"
- >
- <input
- type="radio"
- name={id}
- value={option.id}
- className="peer sr-only"
- checked={option.id === selectedId}
- onChange={() => onSelect(option.id)}
- />
- {option.id === selectedId && (
- <motion.div
- layoutId="indicator"
- transition={{
- duration: 0.1,
- }}
- className="absolute inset-0 rounded border border-neutral-300 bg-white"
- />
- )}
- <span className="relative z-10 text-sm font-medium text-neutral-500 transition-colors group-hover:text-neutral-700 peer-checked:text-neutral-900">
- {option.label}
- </span>
- </label>
- ))}
- </LayoutGroup>
- </div>
- </div>
- );
-}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/usage/get-recommended-plan.ts b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/usage/get-recommended-plan.ts
deleted file mode 100644
index dec0cf760a..0000000000
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/usage/get-recommended-plan.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { OnboardingUsageSchema } from "@/lib/zod/schemas/workspaces";
-import * as z from "zod/v4";
-import { PLAN_SELECTOR_PLANS } from "../plan/plan-selector";
-
-export function getRecommendedPlan({
- links,
- clicks,
- conversions,
- partners,
-}: z.infer<typeof OnboardingUsageSchema>) {
- const hasConversions = (plan: string) => plan !== "free" && plan !== "pro";
- const hasPartners = (plan: string) => plan !== "free" && plan !== "pro";
-
- const plans = PLAN_SELECTOR_PLANS.filter(
- (plan) =>
- (!conversions || hasConversions(plan.name.toLowerCase())) &&
- (!partners || hasPartners(plan.name.toLowerCase())) &&
- links <= plan.limits.links &&
- clicks <= plan.limits.clicks,
- ).sort((a, b) => (a.price.monthly ?? 0) - (b.price.monthly ?? 0));
-
- return plans?.[0]?.name?.toLowerCase() ?? "enterprise";
-}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/usage/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/usage/page.tsx
deleted file mode 100644
index b4fcb78a14..0000000000
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/usage/page.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import { StepPage } from "../step-page";
-import { Form } from "./form";
-
-export default function Usage() {
- return (
- <StepPage
- title="Estimate your usage"
- description="Give us a few details about your usage and we'll help recommend the best plan"
- >
- <Form />
- <p className="mt-8 text-center text-sm font-medium text-neutral-500">
- Need more usage?{" "}
- <a
- href="https://dub.co/contact/sales"
- target="_blank"
- className="text-neutral-800 transition-colors hover:text-neutral-950"
- >
- Chat with us about Enterprise ↗
- </a>
- </p>
- </StepPage>
- );
-}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/workspace/form.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/workspace/form.tsx
index ae6505118d..ad53d77da2 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/workspace/form.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/workspace/form.tsx
@@ -10,7 +10,7 @@ export function Form() {
<CreateWorkspaceForm
className="w-full"
onSuccess={({ slug }) => {
- continueTo("domain", { slug });
+ continueTo("products", { slug });
}}
/>
);
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/workspace/page.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/workspace/page.tsx
index 365c1c41e0..a1da0f42ef 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/workspace/page.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/workspace/page.tsx
@@ -7,7 +7,7 @@ export default function Workspace() {
title="Create your workspace"
description={
<>
- Set up a shared space to manage your links with your team.{" "}
+ Your shared space for links, partners, and your team.{" "}
<a
href="https://dub.co/help/article/what-is-a-workspace"
target="_blank"
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/later-button.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/later-button.tsx
index f932410b0b..0c1c2f0c07 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/later-button.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/later-button.tsx
@@ -10,14 +10,13 @@ export function LaterButton({
next,
className,
children,
-}: PropsWithChildren<{ next: OnboardingStep | "finish"; className?: string }>) {
- const { continueTo, finish, isLoading, isSuccessful } =
- useOnboardingProgress();
+}: PropsWithChildren<{ next: OnboardingStep; className?: string }>) {
+ const { continueTo, isLoading, isSuccessful } = useOnboardingProgress();
return (
<button
type="button"
- onClick={() => (next === "finish" ? finish() : continueTo(next))}
+ onClick={() => continueTo(next)}
className={cn(
"mx-auto flex w-fit items-center gap-2 text-center text-sm font-medium text-neutral-800 transition-colors enabled:hover:text-neutral-950",
className,
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/use-onboarding-product.ts b/apps/web/app/app.dub.co/(onboarding)/onboarding/use-onboarding-product.ts
new file mode 100644
index 0000000000..c2737940d3
--- /dev/null
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/use-onboarding-product.ts
@@ -0,0 +1,17 @@
+"use client";
+
+import { useSearchParams } from "next/navigation";
+import { useMemo } from "react";
+
+export const ONBOARDING_PRODUCTS = ["links", "partners"] as const;
+export type OnboardingProduct = (typeof ONBOARDING_PRODUCTS)[number];
+
+export function useOnboardingProduct(): OnboardingProduct {
+ const searchParams = useSearchParams();
+ const param = searchParams.get("product");
+
+ return useMemo(
+ () => ONBOARDING_PRODUCTS.find((p) => p === param) || "links",
+ [param],
+ );
+}
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/use-onboarding-progress.ts b/apps/web/app/app.dub.co/(onboarding)/onboarding/use-onboarding-progress.ts
index 79eb9180ed..bda93f1055 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/use-onboarding-progress.ts
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/use-onboarding-progress.ts
@@ -5,6 +5,7 @@ import { useAction } from "next-safe-action/hooks";
import { useRouter, useSearchParams } from "next/navigation";
import { useCallback } from "react";
import { toast } from "sonner";
+import { useOnboardingProduct } from "./use-onboarding-product";
const PRE_WORKSPACE_STEPS = ["workspace"];
@@ -13,6 +14,7 @@ export function useOnboardingProgress() {
const searchParams = useSearchParams();
const { slug: workspaceSlug } = useWorkspace();
const slug = workspaceSlug || searchParams.get("workspace");
+ const product = useOnboardingProduct();
const { execute, executeAsync, isPending, hasSucceeded } = useAction(
setOnboardingProgress,
@@ -40,6 +42,9 @@ export function useOnboardingProgress() {
});
const queryParams = new URLSearchParams({
+ ...(product && ["links", "partners"].includes(product)
+ ? { product }
+ : {}),
...(params || {}),
...(PRE_WORKSPACE_STEPS.includes(step)
? {}
@@ -48,16 +53,19 @@ export function useOnboardingProgress() {
router.push(`/onboarding/${step}?${queryParams}`);
},
- [execute, router, slug],
+ [execute, router, slug, product],
);
- const finish = useCallback(async () => {
- await executeAsync({
- onboardingStep: "completed",
- });
+ const finish = useCallback(
+ async ({ hasProgram }: { hasProgram?: boolean } = {}) => {
+ await executeAsync({
+ onboardingStep: "completed",
+ });
- router.push(slug ? `/${slug}?onboarded=true` : "/");
- }, [execute, router, slug]);
+ router.push(slug ? (hasProgram ? `/${slug}/program` : `/${slug}`) : "/");
+ },
+ [executeAsync, router, slug],
+ );
return {
continueTo,
diff --git a/apps/web/lib/actions/partners/create-program.ts b/apps/web/lib/actions/partners/create-program.ts
index 2bd0132305..dd8c4e2fa6 100644
--- a/apps/web/lib/actions/partners/create-program.ts
+++ b/apps/web/lib/actions/partners/create-program.ts
@@ -5,7 +5,7 @@ import { createAndEnrollPartner } from "@/lib/api/partners/create-and-enroll-par
import { getPartnerInviteRewardsAndBounties } from "@/lib/api/partners/get-partner-invite-rewards-and-bounties";
import { generateRandomString } from "@/lib/api/utils/generate-random-string";
import { getPlanCapabilities } from "@/lib/plan-capabilities";
-import { isStored, storage } from "@/lib/storage";
+import { storage } from "@/lib/storage";
import { PlanProps } from "@/lib/types";
import { redis } from "@/lib/upstash";
import {
@@ -19,7 +19,7 @@ import ProgramInvite from "@dub/email/templates/program-invite";
import ProgramWelcome from "@dub/email/templates/program-welcome";
import { prisma } from "@dub/prisma";
import { Program, Project, User } from "@dub/prisma/client";
-import { getDomainWithoutWWW, nanoid, R2_URL } from "@dub/utils";
+import { getDomainWithoutWWW, isLegacyBusinessPlan, nanoid } from "@dub/utils";
import { waitUntil } from "@vercel/functions";
import { redirect } from "next/navigation";
@@ -27,13 +27,39 @@ import { redirect } from "next/navigation";
export const createProgram = async ({
workspace,
user,
+ redirectTo,
+ sendProgramWelcomeEmail = false,
}: {
workspace: Pick<
Project,
- "id" | "slug" | "plan" | "store" | "webhookEnabled" | "invoicePrefix"
+ | "id"
+ | "slug"
+ | "plan"
+ | "payoutsLimit"
+ | "store"
+ | "webhookEnabled"
+ | "invoicePrefix"
>;
user: Pick<User, "id" | "email">;
+ redirectTo?: string;
+ sendProgramWelcomeEmail?: boolean;
}) => {
+ const { canManageProgram, canMessagePartners } = getPlanCapabilities(
+ workspace.plan,
+ );
+
+ if (
+ !canManageProgram ||
+ isLegacyBusinessPlan({
+ plan: workspace.plan,
+ payoutsLimit: workspace.payoutsLimit,
+ })
+ ) {
+ throw new Error(
+ "Your current plan does not have access to create a partner program. Please upgrade to a higher plan to proceed.",
+ );
+ }
+
const store = workspace.store as Record<string, any>;
if (!store.programOnboarding) {
throw new Error("Program onboarding data not found");
@@ -109,10 +135,7 @@ export const createProgram = async ({
supportEmail,
helpUrl,
termsUrl,
- messagingEnabledAt: getPlanCapabilities(workspace.plan)
- .canMessagePartners
- ? new Date()
- : null,
+ messagingEnabledAt: canMessagePartners ? new Date() : null,
...(type &&
(amountInCents != null || amountInPercentage != null) && {
rewards: {
@@ -215,21 +238,17 @@ export const createProgram = async ({
)
: []),
- // delete the temporary uploaded logo
- uploadedLogo &&
- isStored(uploadedLogo) &&
- storage.delete({ key: uploadedLogo.replace(`${R2_URL}/`, "") }),
-
// send email about the new program
- sendEmail({
- subject: `Your program ${program.name} is created and ready to share with your partners.`,
- to: user.email!,
- react: ProgramWelcome({
- email: user.email!,
- workspace,
- program,
+ sendProgramWelcomeEmail &&
+ sendEmail({
+ subject: `Your program ${program.name} is created and ready to share with your partners.`,
+ to: user.email!,
+ react: ProgramWelcome({
+ email: user.email!,
+ workspace,
+ program,
+ }),
}),
- }),
// delete the workspace product cache
redis.del(`workspace:product:${workspace.slug}`),
@@ -252,7 +271,7 @@ export const createProgram = async ({
]),
);
- redirect(`/${workspace.slug}/program?onboarded-program=true`);
+ if (redirectTo) redirect(redirectTo);
};
// Invite a partner to the program
diff --git a/apps/web/lib/actions/partners/onboard-program.ts b/apps/web/lib/actions/partners/onboard-program.ts
index e0116fcfc1..f86362017f 100644
--- a/apps/web/lib/actions/partners/onboard-program.ts
+++ b/apps/web/lib/actions/partners/onboard-program.ts
@@ -1,11 +1,9 @@
"use server";
import { createId } from "@/lib/api/create-id";
-import { getPlanCapabilities } from "@/lib/plan-capabilities";
import { onboardProgramSchema } from "@/lib/zod/schemas/program-onboarding";
import { prisma } from "@dub/prisma";
import { Project } from "@dub/prisma/client";
-import { isLegacyBusinessPlan } from "@dub/utils";
import { redirect } from "next/navigation";
import * as z from "zod/v4";
import { authActionClient } from "../safe-action";
@@ -28,19 +26,12 @@ export const onboardProgramAction = authActionClient
);
}
- if (
- !getPlanCapabilities(workspace.plan).canManageProgram ||
- isLegacyBusinessPlan(workspace)
- ) {
- throw new Error(
- "Your current plan does not support creating a program. Please upgrade to a higher plan to proceed.",
- );
- }
-
if (data.step === "create-program") {
await createProgram({
workspace,
user,
+ redirectTo: `/${workspace.slug}/program?onboarded-program=true`,
+ sendProgramWelcomeEmail: true,
});
return;
}
diff --git a/apps/web/lib/api/partners/create-and-enroll-partner.ts b/apps/web/lib/api/partners/create-and-enroll-partner.ts
index 30983dec8d..6361f2deb2 100644
--- a/apps/web/lib/api/partners/create-and-enroll-partner.ts
+++ b/apps/web/lib/api/partners/create-and-enroll-partner.ts
@@ -162,7 +162,7 @@ export const createAndEnrollPartner = async ({
const upsertedPartner = await prisma.partner.upsert({
where: {
- email: partner.email ?? "",
+ email: partner.email,
},
update: payload,
create: {
diff --git a/apps/web/lib/auth/options.ts b/apps/web/lib/auth/options.ts
index 9517ad8e6b..9709d584fa 100644
--- a/apps/web/lib/auth/options.ts
+++ b/apps/web/lib/auth/options.ts
@@ -587,10 +587,10 @@ export const authOptions: NextAuthOptions = {
Promise.allSettled([
// track lead if dub_id cookie is present
trackDubLead(user),
- // trigger welcome workflow 15 minutes after the user signed up
+ // trigger welcome workflow 45 minutes after the user signed up
qstash.publishJSON({
url: `${APP_DOMAIN_WITH_NGROK}/api/cron/welcome-user`,
- delay: 15 * 60,
+ delay: 45 * 60,
body: { userId: user.id },
}),
]),
diff --git a/apps/web/lib/onboarding/types.ts b/apps/web/lib/onboarding/types.ts
index 33dc3a35fa..639d276f5e 100644
--- a/apps/web/lib/onboarding/types.ts
+++ b/apps/web/lib/onboarding/types.ts
@@ -1,11 +1,13 @@
export const ONBOARDING_STEPS = [
"workspace",
+ "products",
"domain",
"domain/custom",
"domain/register",
- "invite",
- "usage",
+ "program",
+ "program/reward",
"plan",
+ "success",
"completed",
] as const;
diff --git a/apps/web/lib/swr/use-payment-methods.ts b/apps/web/lib/swr/use-payment-methods.ts
index 838aa4cade..bc080473b5 100644
--- a/apps/web/lib/swr/use-payment-methods.ts
+++ b/apps/web/lib/swr/use-payment-methods.ts
@@ -4,7 +4,9 @@ import useSWR from "swr";
import useWorkspace from "./use-workspace";
// Returns the Stripe payment methods for the business
-export default function usePaymentMethods() {
+export default function usePaymentMethods({
+ enabled = true,
+}: { enabled?: boolean } = {}) {
const { slug } = useWorkspace();
const {
@@ -12,7 +14,7 @@ export default function usePaymentMethods() {
isLoading,
error,
} = useSWR<Stripe.PaymentMethod[]>(
- slug && `/api/workspaces/${slug}/billing/payment-methods`,
+ enabled && slug && `/api/workspaces/${slug}/billing/payment-methods`,
fetcher,
);
diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.ts
index ee1ce9aee7..b77062a5f3 100644
--- a/apps/web/lib/types.ts
+++ b/apps/web/lib/types.ts
@@ -280,6 +280,7 @@ export interface DomainProps {
verified: boolean;
primary: boolean;
archived: boolean;
+ createdAt: Date;
placeholder?: string;
expiredUrl?: string;
notFoundUrl?: string;
diff --git a/apps/web/lib/zod/schemas/program-onboarding.ts b/apps/web/lib/zod/schemas/program-onboarding.ts
index eb1664bde1..bcc9ce4e6c 100644
--- a/apps/web/lib/zod/schemas/program-onboarding.ts
+++ b/apps/web/lib/zod/schemas/program-onboarding.ts
@@ -40,7 +40,7 @@ export const programInvitePartnersSchema = z.object({
PROGRAM_ONBOARDING_PARTNERS_LIMIT,
`You can only invite up to ${PROGRAM_ONBOARDING_PARTNERS_LIMIT} partners.`,
)
- .nullable()
+ .nullish()
.transform(
(partners) => partners?.filter((partner) => partner.email.trim()) || null,
),
diff --git a/apps/web/lib/zod/schemas/rewards.ts b/apps/web/lib/zod/schemas/rewards.ts
index 762526b3b2..97e4685739 100644
--- a/apps/web/lib/zod/schemas/rewards.ts
+++ b/apps/web/lib/zod/schemas/rewards.ts
@@ -7,11 +7,13 @@ export const COMMISSION_TYPES = [
value: "one-off",
label: "One-off",
description: "Pay a one-time payout",
+ shortDescription: "Single payouts",
},
{
value: "recurring",
label: "Recurring",
description: "Pay an ongoing payout",
+ shortDescription: "Ongoing payouts",
},
] as const;
diff --git a/apps/web/ui/analytics/use-analytics-connected-status.ts b/apps/web/ui/analytics/use-analytics-connected-status.ts
new file mode 100644
index 0000000000..cd75ea71d1
--- /dev/null
+++ b/apps/web/ui/analytics/use-analytics-connected-status.ts
@@ -0,0 +1,24 @@
+import { useWorkspaceStore } from "@/lib/swr/use-workspace-store";
+
+export function useAnalyticsConnectedStatus() {
+ const [connectionSetupComplete] = useWorkspaceStore<boolean>(
+ "analyticsSettingsConnectionSetupComplete",
+ );
+ const [leadTrackingSetupComplete] = useWorkspaceStore<boolean>(
+ "analyticsSettingsLeadTrackingSetupComplete",
+ );
+ const [saleTrackingSetupComplete] = useWorkspaceStore<boolean>(
+ "analyticsSettingsSaleTrackingSetupComplete",
+ );
+
+ const all = [
+ connectionSetupComplete,
+ leadTrackingSetupComplete,
+ saleTrackingSetupComplete,
+ ];
+
+ return {
+ isConnected: all.some(Boolean),
+ isFullyConnected: all.every(Boolean),
+ };
+}
diff --git a/apps/web/ui/domains/register-domain-form.tsx b/apps/web/ui/domains/register-domain-form.tsx
index bf125c0f89..db28213d0c 100644
--- a/apps/web/ui/domains/register-domain-form.tsx
+++ b/apps/web/ui/domains/register-domain-form.tsx
@@ -10,7 +10,6 @@ import {
import { LoadingSpinner } from "@dub/ui/icons";
import { cn, truncate } from "@dub/utils";
import { CircleCheck, Star } from "lucide-react";
-import Link from "next/link";
import { FormEvent, useEffect, useState } from "react";
import { toast } from "sonner";
import { useDebounce } from "use-debounce";
@@ -162,7 +161,7 @@ export function RegisterDomainForm({
"-m-1 rounded-[0.625rem] p-1",
searchedDomain
? searchedDomain.available
- ? "bg-[#def5c6]"
+ ? "bg-green-100"
: "bg-orange-100"
: "bg-neutral-100",
)}
@@ -178,7 +177,7 @@ export function RegisterDomainForm({
aria-invalid="true"
autoFocus={!isMobile}
placeholder={workspace.slug}
- value={slug}
+ value={slug || ""}
onChange={(e) => {
setSlug(e.target.value);
}}
@@ -290,12 +289,13 @@ export function RegisterDomainForm({
</div>
)}
- {searchedDomain && showTerms && (
+ {searchedDomain && showTerms && variant === "modal" && (
<p className="-my-2 text-pretty text-center text-xs text-neutral-500">
By claiming your .link domain, you agree to our{" "}
<a
href="https://dub.co/help/article/free-dot-link-domain#terms-and-conditions"
target="_blank"
+ rel="noopener noreferrer"
className="underline transition-colors hover:text-neutral-700"
>
terms
@@ -307,7 +307,7 @@ export function RegisterDomainForm({
</div>
<div
className={cn(
- "mt-4 flex justify-end gap-2",
+ "mt-6 flex justify-end gap-2",
variant === "modal" && "border-t border-neutral-200 p-4 sm:px-6",
)}
>
@@ -321,9 +321,10 @@ export function RegisterDomainForm({
/>
)}
{searchedDomain && searchedDomain.premium ? (
- <Link
+ <a
href={`https://www.dynadot.com/domain/search?domain=${searchedDomain.domain}`}
target="_blank"
+ rel="noopener noreferrer"
className={cn(
buttonVariants(),
"flex h-9 w-full items-center justify-center rounded-md border px-4 text-sm",
@@ -331,7 +332,7 @@ export function RegisterDomainForm({
)}
>
Register on Dynadot
- </Link>
+ </a>
) : (
<Button
type="submit"
@@ -347,6 +348,21 @@ export function RegisterDomainForm({
/>
)}
</div>
+ {searchedDomain && showTerms && variant !== "modal" && (
+ <p className="mt-4 text-pretty text-center text-xs text-neutral-500">
+ By claiming your .link domain, you agree to our{" "}
+ <a
+ href="https://dub.co/help/article/free-dot-link-domain#terms-and-conditions"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="underline transition-colors hover:text-neutral-700"
+ >
+ terms
+ </a>
+ .<br />
+ After the first year, your renewal is $12/year.
+ </p>
+ )}
</form>
);
}
@@ -367,10 +383,11 @@ function DomainSavedToast() {
<div className="flex items-center gap-1.5 rounded-lg bg-white p-4 text-sm shadow-[0_4px_12px_#0000001a]">
<CheckCircleFill className="size-5 shrink-0 text-black" />
<p className="text-[13px] font-medium text-neutral-900">
- Domain saved. You'll need a pro plan to complete the registration.{" "}
+ Domain saved. You'll need a paid plan to complete the registration.{" "}
<a
href="https://dub.co/help/article/free-dot-link-domain"
target="_blank"
+ rel="noopener noreferrer"
className="text-neutral-500 underline transition-colors hover:text-neutral-800"
>
Learn more
diff --git a/apps/web/ui/layout/sidebar/workspace-dropdown.tsx b/apps/web/ui/layout/sidebar/workspace-dropdown.tsx
index cbe8d588ec..5ecc27f370 100644
--- a/apps/web/ui/layout/sidebar/workspace-dropdown.tsx
+++ b/apps/web/ui/layout/sidebar/workspace-dropdown.tsx
@@ -11,8 +11,7 @@ import {
useScrollProgress,
} from "@dub/ui";
import { Check2, Gear, Plus, UserPlus } from "@dub/ui/icons";
-import { cn, pluralize } from "@dub/utils";
-import { isLegacyBusinessPlan } from "@dub/utils/src/constants/pricing";
+import { cn, isLegacyBusinessPlan, pluralize } from "@dub/utils";
import { useSession } from "next-auth/react";
import Link from "next/link";
import { useParams, usePathname } from "next/navigation";
diff --git a/apps/web/ui/layout/toolbar/onboarding/onboarding-button.tsx b/apps/web/ui/layout/toolbar/onboarding/onboarding-button.tsx
index 1bbc25c687..1441f16e82 100644
--- a/apps/web/ui/layout/toolbar/onboarding/onboarding-button.tsx
+++ b/apps/web/ui/layout/toolbar/onboarding/onboarding-button.tsx
@@ -1,10 +1,19 @@
"use client";
+import { DIRECT_DEBIT_PAYMENT_METHOD_TYPES } from "@/lib/constants/payouts";
import useDomainsCount from "@/lib/swr/use-domains-count";
+import usePaymentMethods from "@/lib/swr/use-payment-methods";
import useWorkspace from "@/lib/swr/use-workspace";
import useWorkspaceUsers from "@/lib/swr/use-workspace-users";
-import { CheckCircleFill, ThreeDots } from "@/ui/shared/icons";
-import { Button, Popover, useLocalStorage, useMediaQuery } from "@dub/ui";
+import { useAnalyticsConnectedStatus } from "@/ui/analytics/use-analytics-connected-status";
+import { CheckCircleFill } from "@/ui/shared/icons";
+import {
+ Button,
+ Popover,
+ ProgressCircle,
+ useLocalStorage,
+ useMediaQuery,
+} from "@dub/ui";
import { CircleDotted, ExpandingArrow } from "@dub/ui/icons";
import { ChevronDown } from "lucide-react";
import Link from "next/link";
@@ -29,45 +38,83 @@ function OnboardingButtonInner({
onHideForever: () => void;
}) {
const { slug } = useParams() as { slug: string };
- const { totalLinks } = useWorkspace();
+ const { totalLinks, defaultProgramId } = useWorkspace();
const { data: domainsCount, loading: domainsLoading } = useDomainsCount({
ignoreParams: true,
});
const { users, loading: usersLoading } = useWorkspaceUsers();
- const { users: invites, loading: invitesLoading } = useWorkspaceUsers({
- invites: true,
+
+ const { isConnected: connectedAnalytics } = useAnalyticsConnectedStatus();
+ const { paymentMethods, loading: paymentMethodsLoading } = usePaymentMethods({
+ enabled: Boolean(defaultProgramId),
});
+ const connectedBankAccount = paymentMethods?.some((pm) =>
+ DIRECT_DEBIT_PAYMENT_METHOD_TYPES.includes(pm.type),
+ );
- const loading = domainsLoading || usersLoading || invitesLoading;
+ const loading = domainsLoading || usersLoading || paymentMethodsLoading;
const tasks = useMemo(() => {
return [
{
- display: "Create your first short link",
- cta: `/${slug}/links`,
- checked: totalLinks === 0 ? false : true,
- recommended: true,
- },
- {
- display: "Set up your custom domain",
+ display: "Connect a domain",
cta: `/${slug}/settings/domains`,
checked: domainsCount && domainsCount > 0,
recommended: true,
},
- {
- display: "Invite your teammates",
- cta: `/${slug}/settings/people`,
- checked: (users && users.length > 1) || (invites && invites.length > 0),
- recommended: false,
- },
+ ...(defaultProgramId
+ ? [
+ {
+ display: "Create a program",
+ cta: `/${slug}/program`,
+ checked: true,
+ recommended: true,
+ },
+ {
+ display: "Set up conversion tracking",
+ cta: `/${slug}/settings/analytics`,
+ checked: connectedAnalytics,
+ recommended: true,
+ },
+ {
+ display: "Connect bank account for payouts",
+ cta: `/${slug}/program/payouts`,
+ checked: connectedBankAccount,
+ recommended: true,
+ },
+ ]
+ : [
+ {
+ display: "Create a short link",
+ cta: `/${slug}/links`,
+ checked: totalLinks === 0 ? false : true,
+ recommended: true,
+ },
+ {
+ display: "Invite your team",
+ cta: `/${slug}/settings/people`,
+ checked: users && users.length > 1,
+ recommended: false,
+ },
+ ]),
];
- }, [slug, domainsCount, totalLinks, users, invites]);
+ }, [
+ slug,
+ defaultProgramId,
+ connectedAnalytics,
+ paymentMethods,
+ domainsCount,
+ totalLinks,
+ users,
+ ]);
const [isOpen, setIsOpen] = useState(false);
- const remainingRecommendedTasks = tasks.filter(
- (task) => task.recommended && !task.checked,
+ const recommendedTasks = tasks.filter((task) => task.recommended);
+
+ const remainingRecommendedTasks = recommendedTasks.filter(
+ (task) => !task.checked,
).length;
return loading || remainingRecommendedTasks === 0 ? null : (
@@ -79,20 +126,14 @@ function OnboardingButtonInner({
<div className="rounded-t-xl bg-black p-4 text-white">
<div className="flex items-start justify-between gap-2">
<div>
- <span className="text-base font-medium">Getting Started</span>
+ <span className="text-base font-medium">Complete setup</span>
<p className="mt-1 text-sm text-neutral-300">
- Get familiar with Dub by completing the{" "}
+ Finish setting up your workspace
<br className="hidden sm:block" />
- following tasks
+ to get the most out of Dub
</p>
</div>
<div className="flex items-center gap-1">
- <OnboardingMenu
- onHideForever={() => {
- onHideForever();
- setIsOpen(false);
- }}
- />
<MiniButton onClick={() => setIsOpen(false)}>
<ChevronDown className="size-4" />
</MiniButton>
@@ -106,7 +147,7 @@ function OnboardingButtonInner({
<Link
key={display}
href={cta}
- onClick={() => setIsOpen(false)}
+ onClick={() => setTimeout(() => setIsOpen(false), 500)}
>
<div className="group flex items-center justify-between gap-3 p-3 sm:gap-10">
<div className="flex items-center gap-2">
@@ -125,6 +166,16 @@ function OnboardingButtonInner({
);
})}
</div>
+
+ <Button
+ text="Dismiss guide"
+ variant="outline"
+ onClick={() => {
+ onHideForever();
+ setIsOpen(false);
+ }}
+ className="mt-3 h-7 rounded-lg bg-black/[0.04] duration-75 hover:bg-black/[0.07] active:scale-[0.98]"
+ />
</div>
</div>
}
@@ -133,13 +184,14 @@ function OnboardingButtonInner({
>
<button
type="button"
- className="animate-slide-up-fade -mt-1 flex h-12 flex-col items-center justify-center rounded-full border border-neutral-950 bg-neutral-950 px-6 text-xs font-medium leading-tight text-white shadow-md transition-all [--offset:10px] hover:bg-neutral-800 hover:ring-4 hover:ring-neutral-200"
+ className="animate-slide-up-fade flex h-8 items-center justify-center gap-1.5 rounded-full border border-neutral-950 bg-neutral-950 px-3 text-xs font-medium leading-tight text-white shadow-md transition-all [--offset:10px] hover:bg-neutral-800 hover:ring-4 hover:ring-neutral-200"
>
- <span>Getting Started</span>
- <span className="text-neutral-400">
- {Math.round((remainingRecommendedTasks / tasks.length) * 100)}%
- complete
- </span>
+ <span>Complete setup</span>
+ <ProgressCircle
+ progress={1 - remainingRecommendedTasks / recommendedTasks.length}
+ className="size-3 text-white/80 [--track-color:#fff3]"
+ strokeWidth={14}
+ />
</button>
</Popover>
);
@@ -157,29 +209,3 @@ const MiniButton = forwardRef(
);
},
);
-
-function OnboardingMenu({ onHideForever }: { onHideForever: () => void }) {
- const [isOpen, setIsOpen] = useState(false);
-
- return (
- <Popover
- align="end"
- content={
- <div className="p-1">
- <Button
- onClick={onHideForever}
- variant="outline"
- text="Dismiss forever"
- className="h-9"
- />
- </div>
- }
- openPopover={isOpen}
- setOpenPopover={setIsOpen}
- >
- <MiniButton>
- <ThreeDots className="size-4" />
- </MiniButton>
- </Popover>
- );
-}
diff --git a/apps/web/ui/modals/invite-workspace-user-modal.tsx b/apps/web/ui/modals/invite-workspace-user-modal.tsx
index 5216a2b416..32eb4700fb 100644
--- a/apps/web/ui/modals/invite-workspace-user-modal.tsx
+++ b/apps/web/ui/modals/invite-workspace-user-modal.tsx
@@ -1,8 +1,4 @@
-import useWorkspace from "@/lib/swr/use-workspace";
-import { Invite } from "@/lib/zod/schemas/invites";
import { Modal } from "@dub/ui";
-import { LoadingSpinner } from "@dub/ui/icons";
-import { fetcher } from "@dub/utils";
import {
Dispatch,
SetStateAction,
@@ -10,7 +6,6 @@ import {
useMemo,
useState,
} from "react";
-import useSWR from "swr";
import { InviteTeammatesForm } from "../workspaces/invite-teammates-form";
function InviteWorkspaceUserModal({
@@ -22,19 +17,6 @@ function InviteWorkspaceUserModal({
setShowInviteWorkspaceUserModal: Dispatch<SetStateAction<boolean>>;
showSavedInvites: boolean;
}) {
- const { id: workspaceId, plan } = useWorkspace();
-
- // we only need to fetch saved invites if the workspace is on the free plan
- // (or else we would've already sent the invites)
- const { data: invites, isLoading } = useSWR<Invite[]>(
- showInviteWorkspaceUserModal &&
- workspaceId &&
- plan === "free" &&
- showSavedInvites &&
- `/api/workspaces/${workspaceId}/invites/saved`,
- fetcher,
- );
-
return (
<Modal
showModal={showInviteWorkspaceUserModal}
@@ -55,17 +37,10 @@ function InviteWorkspaceUserModal({
. Invitations will be valid for 14 days.
</p>
</div>
- {isLoading ? (
- <div className="flex items-center justify-center p-8">
- <LoadingSpinner />
- </div>
- ) : (
- <InviteTeammatesForm
- onSuccess={() => setShowInviteWorkspaceUserModal(false)}
- className="bg-neutral-50 px-4 py-4 sm:px-6"
- invites={invites}
- />
- )}
+ <InviteTeammatesForm
+ onSuccess={() => setShowInviteWorkspaceUserModal(false)}
+ className="bg-neutral-50 px-4 py-4 sm:px-6"
+ />
</Modal>
);
}
diff --git a/apps/web/ui/modals/modal-provider.tsx b/apps/web/ui/modals/modal-provider.tsx
index 9d58d39df0..cacc89380d 100644
--- a/apps/web/ui/modals/modal-provider.tsx
+++ b/apps/web/ui/modals/modal-provider.tsx
@@ -31,7 +31,6 @@ import { useImportToltModal } from "./import-tolt-modal";
import { useLinkBuilder } from "./link-builder";
import { useProgramWelcomeModal } from "./program-welcome-modal";
import { useUpgradedModal } from "./upgraded-modal";
-import { useWelcomeModal } from "./welcome-modal";
export const ModalContext = createContext<{
setShowAddWorkspaceModal: Dispatch<SetStateAction<boolean>>;
@@ -102,7 +101,6 @@ function ModalProviderClient({ children }: { children: ReactNode }) {
const { setShowImportRebrandlyModal, ImportRebrandlyModal } =
useImportRebrandlyModal();
const { setShowImportCsvModal, ImportCsvModal } = useImportCsvModal();
- const { setShowWelcomeModal, WelcomeModal } = useWelcomeModal();
const { setShowUpgradedModal, UpgradedModal } = useUpgradedModal();
const { setShowProgramWelcomeModal, ProgramWelcomeModal } =
useProgramWelcomeModal();
@@ -114,7 +112,6 @@ function ModalProviderClient({ children }: { children: ReactNode }) {
useEffect(() => {
setShowProgramWelcomeModal(searchParams.has("onboarded-program"));
- setShowWelcomeModal(searchParams.has("onboarded"));
if (searchParams.has("upgraded")) {
setShowUpgradedModal(true);
@@ -210,7 +207,6 @@ function ModalProviderClient({ children }: { children: ReactNode }) {
<ImportPartnerStackModal />
<ImportRewardfulModal />
<ImportToltModal />
- <WelcomeModal />
<UpgradedModal />
<ProgramWelcomeModal />
{children}
diff --git a/apps/web/ui/modals/welcome-modal.tsx b/apps/web/ui/modals/welcome-modal.tsx
deleted file mode 100644
index cf88c63400..0000000000
--- a/apps/web/ui/modals/welcome-modal.tsx
+++ /dev/null
@@ -1,148 +0,0 @@
-import { Button, Modal, useRouterStuff, useScrollProgress } from "@dub/ui";
-import { cn, getPlanDetails, PLANS, PRO_PLAN } from "@dub/utils";
-import { usePlausible } from "next-plausible";
-import { useSearchParams } from "next/navigation";
-import posthog from "posthog-js";
-import {
- Dispatch,
- SetStateAction,
- useCallback,
- useEffect,
- useMemo,
- useRef,
- useState,
-} from "react";
-import { ModalHero } from "../shared/modal-hero";
-import { PlanFeatures } from "../workspaces/plan-features";
-
-function WelcomeModal({
- showWelcomeModal,
- setShowWelcomeModal,
-}: {
- showWelcomeModal: boolean;
- setShowWelcomeModal: Dispatch<SetStateAction<boolean>>;
-}) {
- const { queryParams } = useRouterStuff();
- const searchParams = useSearchParams();
-
- const scrollRef = useRef<HTMLDivElement>(null);
- const { scrollProgress, updateScrollProgress } = useScrollProgress(scrollRef);
-
- const planId = searchParams.get("plan");
- const plausible = usePlausible();
-
- const handlePlanUpgrade = async () => {
- if (planId) {
- const currentPlan = getPlanDetails({ plan: planId });
- const period = searchParams.get("period");
- if (currentPlan && period) {
- plausible(`Upgraded to ${currentPlan.name}`);
- posthog.capture("plan_upgraded", {
- plan: currentPlan.name,
- period,
- revenue: currentPlan.price[period],
- });
- }
- }
- };
- useEffect(() => {
- handlePlanUpgrade();
- }, [searchParams, planId]);
-
- const plan = planId
- ? PLANS.find(
- (p) => p.name.toLowerCase() === planId.replace("+", " ").toLowerCase(),
- ) ?? PRO_PLAN
- : undefined;
-
- return (
- <Modal
- showModal={showWelcomeModal}
- setShowModal={setShowWelcomeModal}
- onClose={() =>
- queryParams({
- del: ["onboarded", "upgraded", "plan", "period"],
- })
- }
- >
- <div className="flex flex-col">
- <ModalHero />
- <div className="px-6 py-8 sm:px-12">
- <div className="relative">
- <div
- ref={scrollRef}
- onScroll={updateScrollProgress}
- className="scrollbar-hide max-h-[calc(100vh-350px)] overflow-y-auto pb-6"
- >
- <h1
- className={cn(
- "text-lg font-medium text-neutral-950",
- plan ? "text-left" : "text-center",
- )}
- >
- {plan
- ? `Dub ${plan.name} looks good on you!`
- : "Welcome to Dub!"}
- </h1>
- <p
- className={cn(
- "mt-2 text-sm text-neutral-500",
- plan ? "text-left" : "text-center",
- )}
- >
- Thanks for signing up – your account is ready to go! Now you
- have one central, organized place to build and manage all your
- short links.
- </p>
- {plan && (
- <>
- <h2 className="mb-2 mt-6 text-base font-medium text-neutral-950">
- Explore the benefits of your {plan.name} plan
- </h2>
- <PlanFeatures plan={plan.name} />
- </>
- )}
- </div>
- {/* Bottom scroll fade */}
- <div
- className="pointer-events-none absolute bottom-0 left-0 hidden h-16 w-full bg-gradient-to-t from-white sm:block"
- style={{ opacity: 1 - Math.pow(scrollProgress, 2) }}
- ></div>
- </div>
- <Button
- type="button"
- variant="primary"
- text="Get started"
- className="mt-2"
- onClick={() =>
- queryParams({
- del: ["onboarded"],
- })
- }
- />
- </div>
- </div>
- </Modal>
- );
-}
-
-export function useWelcomeModal() {
- const [showWelcomeModal, setShowWelcomeModal] = useState(false);
-
- const WelcomeModalCallback = useCallback(() => {
- return (
- <WelcomeModal
- showWelcomeModal={showWelcomeModal}
- setShowWelcomeModal={setShowWelcomeModal}
- />
- );
- }, [showWelcomeModal, setShowWelcomeModal]);
-
- return useMemo(
- () => ({
- setShowWelcomeModal,
- WelcomeModal: WelcomeModalCallback,
- }),
- [setShowWelcomeModal, WelcomeModalCallback],
- );
-}
diff --git a/apps/web/ui/partners/program-link-configuration.tsx b/apps/web/ui/partners/program-link-configuration.tsx
index 74654319ac..44a1fa716b 100644
--- a/apps/web/ui/partners/program-link-configuration.tsx
+++ b/apps/web/ui/partners/program-link-configuration.tsx
@@ -52,7 +52,7 @@ export function ProgramLinkConfiguration({
className="max-w-full"
/>
<p className="text-xs font-normal text-neutral-500">
- Where people will be redirected to when they click on your program's
+ Where people will be redirected to when they click on your partners'
referral links
</p>
</div>
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/form-wrapper.tsx b/apps/web/ui/partners/program-onboarding-form-wrapper.tsx
similarity index 86%
rename from apps/web/app/(ee)/app.dub.co/(new-program)/form-wrapper.tsx
rename to apps/web/ui/partners/program-onboarding-form-wrapper.tsx
index 5a98920482..f2d0e3d89d 100644
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/form-wrapper.tsx
+++ b/apps/web/ui/partners/program-onboarding-form-wrapper.tsx
@@ -4,7 +4,15 @@ import { useWorkspaceStore } from "@/lib/swr/use-workspace-store";
import { ProgramData } from "@/lib/types";
import { FormProvider, useForm } from "react-hook-form";
-export function FormWrapper({ children }: { children: React.ReactNode }) {
+export function ProgramOnboardingFormWrapper({
+ children,
+ defaultValues,
+ values,
+}: {
+ children: React.ReactNode;
+ defaultValues?: Partial<ProgramData>;
+ values?: Partial<ProgramData>;
+}) {
const [programOnboarding] =
useWorkspaceStore<ProgramData>("programOnboarding");
@@ -17,6 +25,7 @@ export function FormWrapper({ children }: { children: React.ReactNode }) {
amountInPercentage: null,
maxDuration: 12,
partners: [{ email: "" }],
+ ...defaultValues,
},
values: programOnboarding
? {
@@ -38,6 +47,7 @@ export function FormWrapper({ children }: { children: React.ReactNode }) {
supportEmail: programOnboarding.supportEmail || null,
helpUrl: programOnboarding.helpUrl || null,
termsUrl: programOnboarding.termsUrl || null,
+ ...values,
}
: undefined,
});
diff --git a/apps/web/ui/workspaces/create-workspace-form.tsx b/apps/web/ui/workspaces/create-workspace-form.tsx
index 8c18ade5f9..238845d636 100644
--- a/apps/web/ui/workspaces/create-workspace-form.tsx
+++ b/apps/web/ui/workspaces/create-workspace-form.tsx
@@ -133,6 +133,9 @@ export function CreateWorkspaceForm({
})}
/>
</div>
+ <p className="text-content-subtle mt-1.5 text-xs">
+ This is the name of your company or product.
+ </p>
</div>
<div>
@@ -195,8 +198,8 @@ export function CreateWorkspaceForm({
{errors.slug.message}
</p>
) : (
- <p className="mt-1.5 text-xs text-neutral-500">
- You can change this later in your workspace settings.
+ <p className="text-content-subtle mt-1.5 text-xs">
+ This is used for your workspace and partner program.
</p>
)}
</div>
diff --git a/apps/web/ui/workspaces/invite-teammates-form.tsx b/apps/web/ui/workspaces/invite-teammates-form.tsx
index 2651df27d4..0103665606 100644
--- a/apps/web/ui/workspaces/invite-teammates-form.tsx
+++ b/apps/web/ui/workspaces/invite-teammates-form.tsx
@@ -14,8 +14,6 @@ import posthog from "posthog-js";
import { useMemo } from "react";
import { useFieldArray, useForm } from "react-hook-form";
import { toast } from "sonner";
-import { CustomToast } from "../shared/custom-toast";
-import { CheckCircleFill } from "../shared/icons";
import { UpgradeRequiredToast } from "../shared/upgrade-required-toast";
type FormData = {
@@ -27,16 +25,14 @@ type FormData = {
export function InviteTeammatesForm({
onSuccess,
- saveOnly = false,
invites = [],
className,
}: {
onSuccess?: () => void;
- saveOnly?: boolean; // Whether to only save the data without actually sending invites
invites?: Invite[];
className?: string;
}) {
- const { id, slug, plan } = useWorkspace();
+ const { id, slug, plan, usersLimit } = useWorkspace();
const { isMobile } = useMediaQuery();
const { queryParams } = useRouterStuff();
@@ -44,8 +40,6 @@ export function InviteTeammatesForm({
return getAvailableRolesForPlan(plan);
}, [plan]);
- const maxTeammates = saveOnly ? 4 : 10;
-
const {
control,
register,
@@ -65,42 +59,28 @@ export function InviteTeammatesForm({
<form
onSubmit={handleSubmit(async (data) => {
const teammates = data.teammates.filter(({ email }) => email);
- const res = await fetch(
- `/api/workspaces/${id}/invites${saveOnly ? "/saved" : ""}`,
- {
- method: "POST",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ teammates }),
- },
- );
+ const res = await fetch(`/api/workspaces/${id}/invites`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ teammates }),
+ });
if (res.ok) {
await mutatePrefix(`/api/workspaces/${id}/invites`);
- if (saveOnly) {
- toast.custom(
- () => (
- <CustomToast icon={CheckCircleFill}>
- {`${pluralize("Invitation", teammates.length)} saved. You'll need a pro plan to invite teammates. [Learn more](https://dub.co/help/article/how-to-invite-teammates)`}
- </CustomToast>
- ),
- { duration: 7000 },
- );
- } else {
- toast.success(`${pluralize("Invitation", teammates.length)} sent!`);
- queryParams({
- set: {
- status: "invited",
- },
- });
+ toast.success(`${pluralize("Invitation", teammates.length)} sent!`);
+ queryParams({
+ set: {
+ status: "invited",
+ },
+ });
- teammates.forEach(({ email }) =>
- posthog.capture("teammate_invited", {
- workspace: slug,
- invitee_email: email,
- }),
- );
- }
+ teammates.forEach(({ email }) =>
+ posthog.capture("teammate_invited", {
+ workspace: slug,
+ invitee_email: email,
+ }),
+ );
onSuccess?.();
} else {
const { error } = await res.json();
@@ -181,14 +161,12 @@ export function InviteTeammatesForm({
icon={<Plus className="size-4" />}
text="Add email"
onClick={() => append({ email: "", role: "member" })}
- disabled={fields.length >= maxTeammates}
+ disabled={fields.length >= (usersLimit || Infinity)}
/>
</div>
<Button
loading={isSubmitting || isSubmitSuccessful}
- text={
- saveOnly ? "Continue" : `Send ${pluralize("invite", fields.length)}`
- }
+ text={`Send ${pluralize("invite", fields.length)}`}
/>
</form>
);
diff --git a/packages/email/src/templates/welcome-email.tsx b/packages/email/src/templates/welcome-email.tsx
index f5ae7c3777..4d2f309fc5 100644
--- a/packages/email/src/templates/welcome-email.tsx
+++ b/packages/email/src/templates/welcome-email.tsx
@@ -1,6 +1,7 @@
-import { DUB_WORDMARK } from "@dub/utils";
+import { DUB_THUMBNAIL, DUB_WORDMARK, getPrettyUrl } from "@dub/utils";
import {
Body,
+ Column,
Container,
Head,
Heading,
@@ -9,6 +10,7 @@ import {
Img,
Link,
Preview,
+ Row,
Section,
Tailwind,
Text,
@@ -16,14 +18,30 @@ import {
import { Footer } from "../components/footer";
export default function WelcomeEmail({
- name = "Brendon Urie",
email = "[email protected]",
+ workspace,
+ program,
+ hasDubPartners = true,
unsubscribeUrl,
}: {
- name: string | null;
email: string;
+ workspace?: {
+ slug: string;
+ name: string;
+ logo: string | null;
+ };
+ program?: {
+ slug: string;
+ name: string;
+ logo: string | null;
+ };
+ hasDubPartners?: boolean;
unsubscribeUrl: string;
}) {
+ const workspaceUrl = workspace
+ ? `https://app.dub.co/${workspace?.slug}`
+ : "https://app.dub.co";
+
return (
<Html>
<Head />
@@ -35,86 +53,247 @@ export default function WelcomeEmail({
<Img src={DUB_WORDMARK} height="32" alt="Dub" />
</Section>
<Heading className="mx-0 my-7 p-0 text-xl font-semibold text-black">
- Welcome {name || "to Dub"}!
+ Welcome to Dub!
</Heading>
- <Text className="mb-8 text-sm leading-6 text-gray-600">
- Thank you for signing up for Dub! You can now start creating short
- links, track conversions, and explore our API.
+ <Text className="mb-8 text-sm leading-6 text-neutral-600">
+ Thank you for signing up for Dub! You can now start creating and
+ managing short links and track their performance.
</Text>
- <Hr />
+ {workspace ? (
+ <>
+ <Heading className="mx-0 mb-2 p-0 text-base font-semibold text-black">
+ Your workspace
+ </Heading>
+ <Section className="mb-6 rounded-xl border border-solid border-neutral-200 bg-neutral-50 p-4">
+ <Row>
+ <Column width={10}>
+ <Img
+ src={workspace.logo || DUB_THUMBNAIL}
+ alt={workspace.name}
+ height="32"
+ width="32"
+ className="mr-4 rounded-md"
+ />
+ </Column>
+
+ <Column>
+ <Text className="text-md m-0 text-base font-semibold leading-none text-neutral-800">
+ {workspace.name}
+ </Text>
+
+ <Link
+ href={workspaceUrl}
+ className="m-0 text-xs font-medium text-neutral-600 underline"
+ >
+ {getPrettyUrl(workspaceUrl)}
+ </Link>
+ </Column>
+ </Row>
+ </Section>
+ </>
+ ) : (
+ <Hr />
+ )}
+
+ {program && (
+ <>
+ <Heading className="mx-0 mb-2 p-0 text-base font-semibold text-black">
+ Your program
+ </Heading>
+ <Section className="mb-6 rounded-xl border border-solid border-neutral-200 bg-neutral-50 p-4">
+ <Row>
+ <Column width={10}>
+ <Img
+ src={program.logo || DUB_THUMBNAIL}
+ alt={program.name}
+ height="32"
+ width="32"
+ className="mr-4 rounded-md"
+ />
+ </Column>
- <Heading className="mx-0 my-6 p-0 text-lg font-semibold text-black">
- Getting started
+ <Column>
+ <Text className="text-md m-0 text-base font-semibold leading-none text-neutral-800">
+ {program.name}
+ </Text>
+
+ <Link
+ href={`${workspaceUrl}/program`}
+ className="m-0 text-xs font-medium text-neutral-600 underline"
+ >
+ {getPrettyUrl(`${workspaceUrl}/program`)}
+ </Link>
+ </Column>
+ </Row>
+ </Section>
+ </>
+ )}
+
+ <Heading className="mx-0 mb-0 mt-6 p-0 text-base font-semibold text-black">
+ {hasDubPartners ? "Complete setup" : "Getting started"}
</Heading>
- <Text className="mb-4 text-sm leading-6 text-gray-600">
- <strong className="font-medium text-black">
- 1. Set up your domain
- </strong>
- :{" "}
- <Link
- href="https://dub.co/help/article/how-to-add-custom-domain"
- className="font-semibold text-black underline underline-offset-4"
- >
- Add a custom domain
- </Link>{" "}
- or{" "}
- <Link
- href="https://dub.co/help/article/free-dot-link-domain"
- className="font-semibold text-black underline underline-offset-4"
- >
- claim a free .link domain
- </Link>{" "}
- and start creating your short links.
+ <Text className="mb-6 mt-0 text-sm leading-6 text-neutral-600">
+ {program
+ ? "Finish setting up your program to get the most out of Dub Partners."
+ : "Get familiar with Dub by exploring the platform and features."}
</Text>
- <Text className="mb-4 text-sm leading-6 text-gray-600">
- <strong className="font-medium text-black">
- 2. View analytics
- </strong>
- : Monitor{" "}
- <Link
- href="https://dub.co/help/article/dub-analytics"
- className="font-semibold text-black underline underline-offset-4"
- >
- click data
- </Link>{" "}
- in real time to see what's working.
- </Text>
+ {program ? (
+ <>
+ <Text className="mb-4 text-sm leading-6 text-neutral-600">
+ 1. Set up conversion tracking:{" "}
+ <Link
+ href="https://dub.co/docs/conversions/quickstart"
+ className="text-neutral-600 underline underline-offset-2"
+ >
+ Follow our quickstart guide
+ </Link>{" "}
+ to set up conversion tracking for your program.
+ </Text>
- <Text className="mb-4 text-sm leading-6 text-gray-600">
- <strong className="font-medium text-black">
- 3. Track conversions
- </strong>
- : Measure how your links convert to signups and sales with our
- built-in{" "}
- <Link
- href="https://dub.co/help/article/dub-conversions"
- className="font-semibold text-black underline underline-offset-4"
- >
- conversion tracking API
- </Link>
- .
- </Text>
+ <Text className="mb-4 text-sm leading-6 text-neutral-600">
+ 2. Create your program application form: Use our{" "}
+ <Link
+ href="https://dub.co/help/article/program-application-form"
+ className="text-neutral-600 underline underline-offset-2"
+ >
+ interactive builder
+ </Link>{" "}
+ to create a beautiful, branded program application page to get
+ more partners applying to join your program.
+ </Text>
- <Text className="mb-8 text-sm leading-6 text-gray-600">
- <strong className="font-medium text-black">
- 4. Explore the API
- </strong>
- :{" "}
- <Link
- href="https://dub.co/docs/introduction"
- className="font-semibold text-black underline underline-offset-4"
- >
- Check out our docs
- </Link>{" "}
- for programmatic link creation.
- </Text>
+ <Text className="mb-4 text-sm leading-6 text-neutral-600">
+ 3. Connect your bank account:{" "}
+ <Link
+ href="https://dub.co/help/article/how-to-set-up-bank-account"
+ className="text-neutral-600 underline underline-offset-2"
+ >
+ Set up a bank account
+ </Link>{" "}
+ to start paying out commissions to your partners.
+ </Text>
+
+ <Text className="mb-4 text-sm leading-6 text-neutral-600">
+ 4. Invite your partners: Easily{" "}
+ <Link
+ href="https://dub.co/help/article/inviting-partners"
+ className="text-neutral-600 underline underline-offset-2"
+ >
+ Invite influencers, affiliates, and users
+ </Link>{" "}
+ to your program, or{" "}
+ <Link
+ href="https://dub.co/help/article/inviting-partners#enrolling-a-partner-automatically"
+ className="text-neutral-600 underline underline-offset-2"
+ >
+ enroll them automatically.
+ </Link>
+ </Text>
+
+ <Text className="mb-4 text-sm leading-6 text-neutral-600">
+ 5. Create more rewards: Set up{" "}
+ <Link
+ href="https://dub.co/help/article/partner-rewards"
+ className="text-neutral-600 underline underline-offset-2"
+ >
+ click, lead, and sale-based rewards
+ </Link>{" "}
+ to incentivize your partners to drive more traffic and
+ conversions.
+ </Text>
+ </>
+ ) : (
+ <>
+ <Text className="mb-4 text-sm leading-6 text-neutral-600">
+ 1. Set up your domain:{" "}
+ <Link
+ href="https://dub.co/help/article/how-to-add-custom-domain"
+ className="text-neutral-600 underline underline-offset-2"
+ >
+ Add a custom domain
+ </Link>{" "}
+ or{" "}
+ <Link
+ href="https://dub.co/help/article/free-dot-link-domain"
+ className="text-neutral-600 underline underline-offset-2"
+ >
+ claim a free .link domain
+ </Link>{" "}
+ and start creating your branded short links.
+ </Text>
+
+ {hasDubPartners ? (
+ <>
+ <Text className="mb-4 text-sm leading-6 text-neutral-600">
+ 2. Track conversions:{" "}
+ <Link
+ href="https://app.dub.co/settings/analytics"
+ className="text-neutral-600 underline underline-offset-2"
+ >
+ Install the Dub tracking script
+ </Link>{" "}
+ to track your short link and partner conversions.
+ </Text>
+
+ <Text className="mb-4 text-sm leading-6 text-neutral-600">
+ 3. Create a program:{" "}
+ <Link
+ href="https://dub.co/docs/partners/quickstart"
+ className="text-neutral-600 underline underline-offset-2"
+ >
+ Set up your Dub partner program
+ </Link>{" "}
+ to grow your revenue on autopilot with advanced reward
+ structures, dual-sided incentives, and real-time
+ attribution.
+ </Text>
+ </>
+ ) : (
+ <>
+ <Text className="mb-4 text-sm leading-6 text-neutral-600">
+ 2. Create a short link:{" "}
+ <Link
+ href="https://dub.co/help/article/how-to-create-link"
+ className="text-neutral-600 underline underline-offset-2"
+ >
+ Create your first Dub short link
+ </Link>{" "}
+ and explore the different features available.
+ </Text>
+
+ <Text className="mb-4 text-sm leading-6 text-neutral-600">
+ 3. Explore analytics:{" "}
+ <Link
+ href="https://dub.co/help/article/dub-analytics"
+ className="text-neutral-600 underline underline-offset-2"
+ >
+ View the performance
+ </Link>{" "}
+ of your short links with graphs and detailed analytics.
+ </Text>
+ </>
+ )}
+
+ <Text className="mb-4 text-sm leading-6 text-neutral-600">
+ 4. Explore the API:{" "}
+ <Link
+ href="https://dub.co/docs/introduction"
+ className="text-neutral-600 underline underline-offset-2"
+ >
+ Check out our docs
+ </Link>{" "}
+ for programmatic link creation
+ {hasDubPartners ? " and partner management" : ""}.
+ </Text>
+ </>
+ )}
- <Section className="mb-8">
+ <Section className="my-8">
<Link
- className="rounded-lg bg-black px-6 py-3 text-center text-[12px] font-semibold text-white no-underline"
+ className="rounded-lg bg-black px-4 py-2.5 text-center text-[14px] font-medium text-white no-underline"
href="https://app.dub.co"
>
Go to your dashboard
diff --git a/packages/prisma/schema/notification.prisma b/packages/prisma/schema/notification.prisma
index d3d81e37b2..43d8adae2c 100644
--- a/packages/prisma/schema/notification.prisma
+++ b/packages/prisma/schema/notification.prisma
@@ -50,7 +50,7 @@ model NotificationPreference {
linkUsageSummary Boolean @default(true)
domainConfigurationUpdates Boolean @default(true)
newPartnerSale Boolean @default(true)
- newPartnerApplication Boolean @default(true)
+ newPartnerApplication Boolean @default(false)
pendingApplicationsSummary Boolean @default(true)
newBountySubmitted Boolean @default(true)
newMessageFromPartner Boolean @default(true)
diff --git a/packages/utils/package.json b/packages/utils/package.json
index b7451fddca..b198bb557b 100644
--- a/packages/utils/package.json
+++ b/packages/utils/package.json
@@ -1,7 +1,7 @@
{
"name": "@dub/utils",
"description": "Utility functions and constants for Dub",
- "version": "0.1.48",
+ "version": "0.1.49",
"sideEffects": false,
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
diff --git a/packages/utils/src/constants/index.ts b/packages/utils/src/constants/index.ts
index f426146089..17def2340c 100644
--- a/packages/utils/src/constants/index.ts
+++ b/packages/utils/src/constants/index.ts
@@ -13,8 +13,12 @@ export * from "./main";
export * from "./middleware";
export * from "./misc";
export * from "./paypal-supported-countries";
-export * from "./plan-compare";
-export * from "./pricing";
export * from "./regions";
export * from "./reserved-slugs";
export * from "./saml";
+
+// pricing copy & values
+export * from "./pricing/pricing-plan-compare-features";
+export * from "./pricing/pricing-plan-main-features";
+export * from "./pricing/pricing-plan-taglines";
+export * from "./pricing/pricing-plans";
diff --git a/packages/utils/src/constants/plan-compare.tsx b/packages/utils/src/constants/pricing/pricing-plan-compare-features.tsx
similarity index 98%
rename from packages/utils/src/constants/plan-compare.tsx
rename to packages/utils/src/constants/pricing/pricing-plan-compare-features.tsx
index ec2d0af4a1..2175e513ae 100644
--- a/packages/utils/src/constants/plan-compare.tsx
+++ b/packages/utils/src/constants/pricing/pricing-plan-compare-features.tsx
@@ -1,9 +1,9 @@
import { ReactNode } from "react";
-import { nFormatter } from "../functions/nformatter";
-import { INFINITY_NUMBER } from "./misc";
-import { PLANS } from "./pricing";
+import { nFormatter } from "../../functions/nformatter";
+import { INFINITY_NUMBER } from "../misc";
+import { PLANS } from "./pricing-plans";
-export const PLAN_COMPARE_FEATURES: {
+export const PRICING_PLAN_COMPARE_FEATURES: {
category: string;
href: string;
features: {
diff --git a/packages/utils/src/constants/pricing/pricing-plan-main-features.ts b/packages/utils/src/constants/pricing/pricing-plan-main-features.ts
new file mode 100644
index 0000000000..7ead72b7c7
--- /dev/null
+++ b/packages/utils/src/constants/pricing/pricing-plan-main-features.ts
@@ -0,0 +1,309 @@
+import { ReactNode } from "react";
+import { nFormatter } from "../../functions/nformatter";
+import { PLANS } from "./pricing-plans";
+
+type Plan = (typeof PLANS)[number];
+
+type HeroFeature = {
+ id?: string;
+ text: string;
+ disabled?: boolean;
+ tooltip?:
+ | ReactNode
+ | {
+ title: string;
+ cta: string;
+ href: string;
+ };
+};
+
+const getLinksStandards = (plan: Plan): HeroFeature[] => {
+ return [
+ // Tracked clicks
+ {
+ id: "clicks",
+ text:
+ plan.name === "Enterprise"
+ ? "Unlimited tracked clicks"
+ : `${nFormatter(plan.limits.clicks)} tracked clicks/mo`,
+ },
+ // New links
+ {
+ id: "links",
+ text:
+ plan.name === "Enterprise"
+ ? "Unlimited new links"
+ : `${nFormatter(plan.limits.links)} new links/mo`,
+ },
+ {
+ id: "retention",
+ text: `${plan.limits.retention} analytics retention`,
+ },
+ ];
+};
+
+const getPartnersStandards = (plan: Plan): HeroFeature[] => [
+ {
+ id: "payouts",
+ text:
+ plan.name === "Enterprise"
+ ? "Unlimited partner payouts"
+ : `$${nFormatter(plan.limits.payouts / 100)} partner payouts/mo`,
+ tooltip: {
+ title:
+ "Send payouts to your partners with 1-click (or automate it completely) – all across the world.",
+ cta: "Learn more.",
+ href: "https://dub.co/help/article/partner-payouts",
+ },
+ },
+];
+
+export const PRICING_PLAN_MAIN_FEATURES = {
+ links: {
+ Pro: [
+ {
+ features: [
+ ...getLinksStandards(PLANS.find((p) => p.name === "Pro")!),
+ {
+ id: "advanced",
+ text: "Advanced link features",
+ },
+ {
+ id: "dotlink",
+ text: "Free .link domain",
+ tooltip: {
+ title:
+ "Get a free .link custom domain for 1 year with any of Dub's paid plans.",
+ cta: "Learn more.",
+ href: "https://dub.co/help/article/free-dot-link-domain",
+ },
+ },
+ {
+ id: "folders",
+ text: "Link folders",
+ tooltip: {
+ title:
+ "Organize and manage access to your links on Dub using folders.",
+ cta: "Learn more.",
+ href: "https://dub.co/help/article/link-folders",
+ },
+ },
+ {
+ id: "deeplinks",
+ text: "Deep links",
+ tooltip: {
+ title:
+ "Redirect users to a specific page within your mobile application using deep links.",
+ cta: "Learn more.",
+ href: "https://dub.co/docs/concepts/deep-links/quickstart",
+ },
+ },
+ ],
+ },
+ ],
+ Business: [
+ {
+ features: [
+ ...getLinksStandards(PLANS.find((p) => p.name === "Business")!),
+ {
+ id: "conversions",
+ text: "Conversion tracking",
+ },
+ {
+ id: "tests",
+ text: "A/B testing",
+ },
+ {
+ id: "roles",
+ text: "Customer insights",
+ tooltip: {
+ title:
+ "Get real-time insights into your customers' behavior and preferences.",
+ cta: "Learn more.",
+ href: "https://dub.co/help/article/customer-insights",
+ },
+ },
+ {
+ id: "webhooks",
+ text: "Event webhooks",
+ tooltip: {
+ title:
+ "Get real-time notifications when a link is clicked or a QR code is scanned using webhooks.",
+ cta: "Learn more.",
+ href: "https://dub.co/docs/concepts/webhooks/introduction",
+ },
+ },
+ ],
+ },
+ ],
+ Advanced: [
+ {
+ features: [
+ ...getLinksStandards(PLANS.find((p) => p.name === "Advanced")!),
+ {
+ id: "slack",
+ text: "Priority Slack support",
+ },
+ ],
+ },
+ ],
+ Enterprise: [
+ {
+ features: [
+ ...getLinksStandards(PLANS.find((p) => p.name === "Enterprise")!),
+ {
+ id: "sso",
+ text: "SSO/SAML",
+ },
+ {
+ id: "logs",
+ text: "Audit logs",
+ },
+ {
+ id: "sla",
+ text: "Custom SLA",
+ },
+ ],
+ },
+ ],
+ },
+ partners: {
+ Business: [
+ {
+ features: [
+ ...getPartnersStandards(PLANS.find((p) => p.name === "Business")!),
+ {
+ id: "basicrewards",
+ text: "Basic reward structures",
+ tooltip: {
+ title:
+ "Create custom click, lead, or sale-based rewards, tailored to each partner's needs.",
+ cta: "Learn more.",
+ href: "https://dub.co/help/article/partner-rewards",
+ },
+ },
+ {
+ id: "conversions",
+ text: "Dual-sided incentives",
+ tooltip: {
+ title:
+ "Offer dual-sided incentives to your partners and the users they refer.",
+ cta: "Learn more.",
+ href: "https://dub.co/help/article/dual-sided-incentives",
+ },
+ },
+ {
+ id: "ailandingpage",
+ text: "AI landing page generator",
+ tooltip: {
+ title:
+ "Generate compelling landing pages using Dub AI to attract high-quality partners to join your program.",
+ cta: "Learn more.",
+ href: "https://dub.co/help/article/program-landing-page",
+ },
+ },
+ {
+ id: "webhooks",
+ text: "Real-time event webhooks",
+ tooltip: {
+ title:
+ "Get real-time notifications when a link is clicked or a QR code is scanned using webhooks.",
+ cta: "Learn more.",
+ href: "https://dub.co/docs/concepts/webhooks/introduction",
+ },
+ },
+ {
+ id: "customerinsights",
+ text: "Basic email support",
+ },
+ ],
+ },
+ ],
+ Advanced: [
+ {
+ features: [
+ ...getPartnersStandards(PLANS.find((p) => p.name === "Advanced")!),
+ {
+ id: "flexiblerewards",
+ text: "Advanced reward structures",
+ tooltip: {
+ title:
+ "Create dynamic click, lead, or sale-based rewards with country and product-specific modifiers.",
+ cta: "Learn more.",
+ href: "https://dub.co/help/article/partner-rewards",
+ },
+ },
+ {
+ id: "embeddedreferrals",
+ text: "Embedded referral dashboard",
+ tooltip: {
+ title:
+ "Create an embedded referral dashboard directly in your app in just a few lines of code.",
+ cta: "Learn more.",
+ href: "https://dub.co/docs/partners/embedded-referrals",
+ },
+ },
+ {
+ id: "messages",
+ text: "Messaging center",
+ tooltip: {
+ title:
+ "Easily communicate with your partners using our messaging center.",
+ },
+ },
+ {
+ id: "api",
+ text: "Partners API",
+ tooltip: {
+ title:
+ "Leverage our partners API to build a bespoke, white-labeled referral program that lives within your app.",
+ cta: "Learn more.",
+ href: "https://dub.co/docs/api-reference/endpoint/create-a-partner",
+ },
+ },
+ {
+ id: "slack",
+ text: "Priority Slack support",
+ },
+ ],
+ },
+ ],
+ Enterprise: [
+ {
+ features: [
+ ...getPartnersStandards(PLANS.find((p) => p.name === "Enterprise")!),
+ {
+ id: "partners",
+ text: "Partner Network",
+ tooltip: {
+ title:
+ "Get access to our network of 5,000+ active affiliate partners.",
+ },
+ },
+ {
+ id: "sso",
+ text: "SSO/SAML",
+ tooltip: {
+ title:
+ "Enable single sign-on (SSO) for your entire organization using SAML.",
+ cta: "Learn more.",
+ href: "https://dub.co/help/category/saml-sso",
+ },
+ },
+ {
+ id: "logs",
+ text: "Audit logs",
+ },
+ {
+ id: "sla",
+ text: "Custom SLA",
+ },
+ {
+ id: "success",
+ text: "Dedicated success manager",
+ },
+ ],
+ },
+ ],
+ },
+};
diff --git a/packages/utils/src/constants/pricing/pricing-plan-taglines.ts b/packages/utils/src/constants/pricing/pricing-plan-taglines.ts
new file mode 100644
index 0000000000..ecad5aa620
--- /dev/null
+++ b/packages/utils/src/constants/pricing/pricing-plan-taglines.ts
@@ -0,0 +1,16 @@
+export const PRICING_PLAN_TAGLINES = {
+ links: {
+ Pro: "For small teams or creators needing advanced link features",
+ Business: "For fast-growing startups and businesses looking to scale",
+ Advanced: "For hyperscalers needing higher usage quotas",
+ Enterprise: "For large organizations and governments with custom needs",
+ },
+ partners: {
+ Business:
+ "For fast-growing startups looking to scale with affiliates and referrals",
+ Advanced:
+ "For scaling teams with high-volume affiliate traffic and white-labeling needs",
+ Enterprise:
+ "For large organizations looking for dedicated support and unlimited usage",
+ },
+};
diff --git a/packages/utils/src/constants/pricing.tsx b/packages/utils/src/constants/pricing/pricing-plans.tsx
similarity index 99%
rename from packages/utils/src/constants/pricing.tsx
rename to packages/utils/src/constants/pricing/pricing-plans.tsx
index e2a2bbad43..4b4c28649f 100644
--- a/packages/utils/src/constants/pricing.tsx
+++ b/packages/utils/src/constants/pricing/pricing-plans.tsx
@@ -1,5 +1,5 @@
-import { nFormatter } from "../functions";
-import { INFINITY_NUMBER } from "./misc";
+import { nFormatter } from "../../functions";
+import { INFINITY_NUMBER } from "../misc";
export type PlanFeature = {
id?: string;