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.

FreeDotLinkBanner

Steven Teyd95804d409c5
diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/link/form.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/link/form.tsx
index 90f801400e..e3610c96a1 100644
--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/link/form.tsx
+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/link/form.tsx
@@ -153,6 +153,7 @@ export function Form() {
data={{ url, title: "", description: "" }}
saving={isSubmitting}
loading={loading}
+ onboarding
/>
)}
/>
diff --git a/apps/web/lib/zod/schemas/analytics-response.ts b/apps/web/lib/zod/schemas/analytics-response.ts
index 6fe221c30b..76c9048589 100644
--- a/apps/web/lib/zod/schemas/analytics-response.ts
+++ b/apps/web/lib/zod/schemas/analytics-response.ts
@@ -2,6 +2,30 @@ import { TRIGGER_TYPES } from "@/lib/analytics/constants";
import z from "@/lib/zod";
import { CONTINENT_CODES, COUNTRY_CODES } from "@dub/utils";
+const analyticsTriggersResponse = z
+ .object({
+ trigger: z
+ .enum(TRIGGER_TYPES)
+ .describe("The type of trigger method: link click or QR scan"),
+ clicks: z
+ .number()
+ .describe("The number of clicks from this trigger method")
+ .default(0),
+ leads: z
+ .number()
+ .describe("The number of leads from this trigger method")
+ .default(0),
+ sales: z
+ .number()
+ .describe("The number of sales from this trigger method")
+ .default(0),
+ saleAmount: z
+ .number()
+ .describe("The total amount of sales from this trigger method, in cents")
+ .default(0),
+ })
+ .openapi({ ref: "AnalyticsTriggers" });
+
export const analyticsResponse = {
count: z
.object({
@@ -174,31 +198,8 @@ export const analyticsResponse = {
})
.openapi({ ref: "AnalyticsOS" }),
- triggers: z
- .object({
- trigger: z
- .enum(TRIGGER_TYPES)
- .describe("The type of trigger method: link click or QR scan"),
- clicks: z
- .number()
- .describe("The number of clicks from this trigger method")
- .default(0),
- leads: z
- .number()
- .describe("The number of leads from this trigger method")
- .default(0),
- sales: z
- .number()
- .describe("The number of sales from this trigger method")
- .default(0),
- saleAmount: z
- .number()
- .describe(
- "The total amount of sales from this trigger method, in cents",
- )
- .default(0),
- })
- .openapi({ ref: "AnalyticsTriggers" }),
+ triggers: analyticsTriggersResponse,
+ trigger: analyticsTriggersResponse, // backwards compatibility
referers: z
.object({
diff --git a/apps/web/ui/domains/free-dot-link-banner.tsx b/apps/web/ui/domains/free-dot-link-banner.tsx
index e11c94b0ca..a0fc6c415b 100644
--- a/apps/web/ui/domains/free-dot-link-banner.tsx
+++ b/apps/web/ui/domains/free-dot-link-banner.tsx
@@ -5,54 +5,61 @@ import { useRegisterDomainModal } from "../modals/register-domain-modal";
import { X } from "../shared/icons";
export function FreeDotLinkBanner() {
- const { plan } = useWorkspace();
- const [hide, setHide] = useLocalStorage("free-dot-link-banner-hide", false);
+ const { id: workspaceId } = useWorkspace();
+ const [show, setShow] = useLocalStorage(
+ `show-free-dot-link-banner:${workspaceId}`,
+ true,
+ );
const { RegisterDomainModal, setShowRegisterDomainModal } =
useRegisterDomainModal();
- return hide ? null : (
- <>
- <RegisterDomainModal />
- <div className="relative isolate flex flex-col justify-between gap-3 overflow-hidden rounded-lg border border-green-600/15 bg-gradient-to-r from-lime-100/80 to-emerald-100/80 py-3 pl-4 pr-12 sm:flex-row sm:items-center sm:py-2">
- <Grid
- cellSize={13}
- patternOffset={[0, -1]}
- className="text-black/30 mix-blend-overlay [mask-image:linear-gradient(to_right,black,transparent)] md:[mask-image:linear-gradient(to_right,black_60%,transparent)]"
- />
+ return (
+ show && (
+ <>
+ <RegisterDomainModal />
+ <div className="relative isolate flex flex-col justify-between gap-3 overflow-hidden rounded-lg border border-green-600/15 bg-gradient-to-r from-lime-100/80 to-emerald-100/80 py-3 pl-4 pr-12 sm:flex-row sm:items-center sm:py-2">
+ <Grid
+ cellSize={13}
+ patternOffset={[0, -1]}
+ className="text-black/30 mix-blend-overlay [mask-image:linear-gradient(to_right,black,transparent)] md:[mask-image:linear-gradient(to_right,black_60%,transparent)]"
+ />
- <div className="flex items-center gap-3">
- <div className="hidden rounded-full border border-green-600/50 bg-white/50 p-1 shadow-[inset_0_0_1px_1px_#fff] sm:block">
- <LinkBroken className="m-px size-4 text-green-800" />
+ <div className="flex items-center gap-3">
+ <div className="hidden rounded-full border border-green-600/50 bg-white/50 p-1 shadow-[inset_0_0_1px_1px_#fff] sm:block">
+ <LinkBroken className="m-px size-4 text-green-800" />
+ </div>
+ <p className="text-sm text-gray-900">
+ Claim a free <span className="font-semibold">.link</span> domain,
+ free for 1 year.{" "}
+ <a
+ href="https://dub.co/help/article/free-dot-link-domain"
+ target="_blank"
+ className="text-gray-700 underline transition-colors hover:text-black"
+ >
+ Learn more
+ </a>
+ </p>
</div>
- <p className="text-sm text-gray-900">
- Claim a free <span className="font-semibold">.link</span> domain,
- free for 1 year{plan === "free" && " with any paid plan"}.{" "}
- <a
- href="https://dub.co/help/article/free-dot-link-domain"
- target="_blank"
- className="text-gray-700 underline transition-colors hover:text-black"
- >
- Learn more
- </a>
- </p>
- </div>
- <div className="flex items-center sm:-my-1">
+ <div className="flex items-center sm:-my-1">
+ <button
+ type="button"
+ className="whitespace-nowrap rounded-md border border-green-700/50 px-3 py-1 text-sm text-gray-800 transition-colors hover:bg-green-500/10"
+ onClick={() => setShowRegisterDomainModal(true)}
+ >
+ Claim Domain
+ </button>
+ </div>
<button
- className="whitespace-nowrap rounded-md border border-green-700/50 px-3 py-1 text-sm text-gray-800 transition-colors hover:bg-green-500/10"
- onClick={() => setShowRegisterDomainModal(true)}
+ type="button"
+ className="absolute inset-y-0 right-2.5 p-1 text-sm text-green-700 underline transition-colors hover:text-green-900"
+ onClick={() => setShow(false)}
>
- Claim Domain
+ <X className="size-[18px]" />
</button>
</div>
- <button
- className="absolute right-2.5 top-2 p-1 text-sm text-green-700 underline transition-colors hover:text-green-900"
- onClick={() => setHide(true)}
- >
- <X className="size-[18px]" />
- </button>
- </div>
- </>
+ </>
+ )
);
}
diff --git a/apps/web/ui/links/short-link-input.tsx b/apps/web/ui/links/short-link-input.tsx
index edf43d2638..7a2b294866 100644
--- a/apps/web/ui/links/short-link-input.tsx
+++ b/apps/web/ui/links/short-link-input.tsx
@@ -5,6 +5,7 @@ import { LinkProps } from "@/lib/types";
import { DOMAINS_MAX_PAGE_SIZE } from "@/lib/zod/schemas/domains";
import { Lock, Random } from "@/ui/shared/icons";
import {
+ AnimatedSizeContainer,
ButtonTooltip,
Combobox,
LinkedIn,
@@ -38,6 +39,7 @@ import {
} from "react";
import { toast } from "sonner";
import { useDebounce } from "use-debounce";
+import { FreeDotLinkBanner } from "../domains/free-dot-link-banner";
import { AlertCircleFill } from "../shared/icons";
import { UpgradeRequiredToast } from "../shared/upgrade-required-toast";
import { useAvailableDomains } from "./use-available-domains";
@@ -51,6 +53,7 @@ type ShortLinkInputProps = {
data: Pick<LinkProps, "url" | "title" | "description">;
saving: boolean;
loading: boolean;
+ onboarding?: boolean;
} & Omit<HTMLProps<HTMLInputElement>, "onChange" | "data">;
export const ShortLinkInput = forwardRef<HTMLInputElement, ShortLinkInputProps>(
@@ -64,6 +67,7 @@ export const ShortLinkInput = forwardRef<HTMLInputElement, ShortLinkInputProps>(
data,
saving,
loading,
+ onboarding,
...inputProps
}: ShortLinkInputProps,
ref,
@@ -79,6 +83,7 @@ export const ShortLinkInput = forwardRef<HTMLInputElement, ShortLinkInputProps>(
mutate: mutateWorkspace,
exceededAI,
nextPlan,
+ dotLinkClaimed,
} = useWorkspace();
const [lockKey, setLockKey] = useState(existingLink);
@@ -363,6 +368,15 @@ export const ShortLinkInput = forwardRef<HTMLInputElement, ShortLinkInputProps>(
onChange={(domain) => onChange({ domain })}
/>
)}
+ {!onboarding && !dotLinkClaimed && (
+ <AnimatedSizeContainer
+ height
+ transition={{ ease: "linear", duration: 0.1 }}
+ className="mt-2"
+ >
+ <FreeDotLinkBanner />
+ </AnimatedSizeContainer>
+ )}
</div>
);
},