The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
AI-suggested tags
Steven Teye8fe12c3ad88
diff --git a/apps/web/app/action.tsx b/apps/web/app/action.tsxnew file mode 100644index 0000000000..07cfe3cfe4--- /dev/null+++ b/apps/web/app/action.tsx@@ -0,0 +1,139 @@+import { anthropic } from "@/lib/anthropic";+import prisma from "@/lib/prisma";+import { createAI, getMutableAIState, render } from "ai/rsc";+import { z } from "zod";++// An example of a spinner component. You can also import your own components,+// or 3rd party component libraries.+function Spinner() {+ return <div>Loading...</div>;+}++// An example of a flight card component.+function AvailableTags({ availableTags }) {+ return (+ <div>+ <h2>Available tags</h2>+ <ul>+ {availableTags.map((tag) => (+ <li key={tag.id}>{tag.name}</li>+ ))}+ </ul>+ </div>+ );+}++async function submitUserMessage(userInput: string) {+ "use server";++ const aiState = getMutableAIState<typeof AI>();++ // Update the AI state with the new user message.+ aiState.update([+ ...aiState.get(),+ {+ role: "user",+ content: userInput,+ },+ ]);++ // The `render()` creates a generated, streamable UI.+ const ui = render({+ model: "claude-3-sonnet-20240229",+ provider: anthropic,+ messages: aiState.get(),+ // `text` is called when an AI returns a text response (as opposed to a tool call).+ // Its content is streamed from the LLM, so this function will be called+ // multiple times with `content` being incremental.+ text: ({ content, done }) => {+ // When it's the final content, mark the state as done and ready for the client to access.+ if (done) {+ aiState.done([+ ...aiState.get(),+ {+ role: "assistant",+ content,+ },+ ]);+ }++ return <p>{content}</p>;+ },+ tools: {+ get_relevant_tags: {+ description: "Get relevant tags for a given link",+ parameters: z+ .object({+ workspaceId: z.string(),+ url: z.string(),+ title: z.string(),+ description: z.string(),+ })+ .required(),+ render: async function* ({ workspaceId, url, title, description }) {+ // Show a spinner on the client while we wait for the response.+ yield <Spinner />;++ // Get available tags for a given workspace+ const availableTags = await prisma.tag.findMany({+ where: {+ projectId: workspaceId,+ },+ select: {+ id: true,+ name: true,+ color: true,+ },+ orderBy: {+ name: "asc",+ },+ });++ // Update the final AI state.+ aiState.done([+ ...aiState.get(),+ {+ role: "function",+ name: "get_relevant_tags",+ // Content can be any string to provide context to the LLM in the rest of the conversation.+ content: JSON.stringify(availableTags),+ },+ ]);++ // Return the available tags to the client.+ return <AvailableTags availableTags={availableTags} />;+ },+ },+ },+ });++ return {+ id: Date.now(),+ display: ui,+ };+}++// Define the initial state of the AI. It can be any JSON object.+const initialAIState: {+ role: "user" | "assistant" | "system" | "function";+ content: string;+ id?: string;+ name?: string;+}[] = [];++// The initial UI state that the client will keep track of, which contains the message IDs and their UI nodes.+const initialUIState: {+ id: number;+ display: React.ReactNode;+}[] = [];++// AI is a provider you wrap your application with so you can access AI and UI state in your components.+export const AI = createAI({+ actions: {+ submitUserMessage,+ },+ // Each state can be any shape of object, but for chat applications+ // it makes sense to have an array of messages. Or you may prefer something like { id: number, messages: Message[] }+ initialUIState,+ initialAIState,+});diff --git a/apps/web/app/api/ai/completion/route.ts b/apps/web/app/api/ai/completion/route.tsindex 71445293a7..7b4b3f3ea0 100644--- a/apps/web/app/api/ai/completion/route.ts+++ b/apps/web/app/api/ai/completion/route.ts@@ -22,7 +22,7 @@ export async function POST(req: NextRequest) {if (workspace.aiUsage > workspace.aiLimit) {return new Response(- "Exceeded AI usage limit. Upgrade to a higher plan to get more AI credits.",+ "You've reached your AI usage limit. Upgrade to Pro to get unlimited AI credits.",{ status: 429 },);}diff --git a/apps/web/lib/swr/use-workspace.ts b/apps/web/lib/swr/use-workspace.tsindex 7f64bac9fb..cb8dcb4216 100644--- a/apps/web/lib/swr/use-workspace.ts+++ b/apps/web/lib/swr/use-workspace.ts@@ -24,6 +24,7 @@ export default function useWorkspace() {isOwner: workspace?.users && workspace.users[0].role === "owner",exceededClicks: workspace && workspace.usage >= workspace.usageLimit,exceededLinks: workspace && workspace.linksUsage >= workspace.linksLimit,+ exceededAI: workspace && workspace.aiUsage >= workspace.aiLimit,exceededDomains:workspace?.domains && workspace.domains.length >= workspace.domainsLimit,error,diff --git a/apps/web/ui/charts/simple-pie-chart.tsx b/apps/web/ui/charts/simple-pie-chart.tsxdeleted file mode 100644index 1233a51993..0000000000--- a/apps/web/ui/charts/simple-pie-chart.tsx+++ /dev/null@@ -1,42 +0,0 @@-import { Pie } from "@visx/shape";--type PieChartData = {- name: string;- value: number;- color: string;-};--export default function SimplePieChart({ data }: { data: PieChartData[] }) {- return (- <svg width={40} height={40}>- <g transform={`translate(20, 20)`}>- <Pie- data={data}- pieValue={(d) => d.value}- outerRadius={16}- innerRadius={10}- cornerRadius={2}- padAngle={0.02}- pieSortValues={() => -1}- >- {(pie) => {- return pie.arcs.map((arc, index) => {- return (- <g key={`arc-${arc.data.name.toLowerCase()}-${index}`}>- <path- d={pie.path(arc) || ""}- fill="currentColor"- className={arc.data.color}- stroke="white"- strokeWidth={1}- strokeLinecap="round"- />- </g>- );- });- }}- </Pie>- </g>- </svg>- );-}diff --git a/apps/web/ui/modals/add-edit-link-modal/index.tsx b/apps/web/ui/modals/add-edit-link-modal/index.tsxindex f6faba8f6c..8921c2db73 100644--- a/apps/web/ui/modals/add-edit-link-modal/index.tsx+++ b/apps/web/ui/modals/add-edit-link-modal/index.tsx@@ -5,8 +5,10 @@ import useWorkspace from "@/lib/swr/use-workspace";import { LinkWithTagsProps } from "@/lib/types";import LinkLogo from "@/ui/links/link-logo";import { AlertCircleFill, Lock, Random, X } from "@/ui/shared/icons";+import { UpgradeToProToast } from "@/ui/shared/upgrade-to-pro-toast";import {Button,+ ButtonTooltip,LinkedIn,LoadingCircle,Magic,@@ -31,8 +33,7 @@ import {truncate,} from "@dub/utils";import { useCompletion } from "ai/react";-import { Crown, TriangleAlert } from "lucide-react";-import Link from "next/link";+import { TriangleAlert } from "lucide-react";import {useParams,usePathname,@@ -62,7 +63,6 @@ import OGSection from "./og-section";import PasswordSection from "./password-section";import Preview from "./preview";import TagsSection from "./tags-section";-import { ButtonWithTooltip } from "./tooltip-button";import UTMSection from "./utm-section";function AddEditLinkModal({@@ -166,7 +166,11 @@ function AddEditLinkModal({} = useCompletion({api: `/api/ai/completion?workspaceId=${workspaceId}`,onError: (error) => {- toast.error(error.message);+ if (error.message.includes("Upgrade to Pro")) {+ toast.custom(() => <UpgradeToProToast message={error.message} />);+ } else {+ toast.error(error.message);+ }},onFinish: (_, completion) => {setGeneratedKeys((prev) => [...prev, completion]);@@ -429,68 +433,13 @@ function AddEditLinkModal({if (error) {if (error.message.includes("Upgrade to Pro")) {toast.custom(() => (- <div className="flex flex-col space-y-3 rounded-lg bg-white p-6 shadow-lg">- <div className="flex items-center space-x-1.5">- <Crown className="h-5 w-5 text-black" />{" "}- <p className="font-semibold">- You've discovered a Pro feature!- </p>- </div>- <p className="text-sm text-gray-600">- {error.message}- </p>- <Link- href={- queryParams({- set: {- upgrade: "pro",- },- getNewPath: true,- }) as string- }- className="w-full rounded-md border border-black bg-black px-3 py-1.5 text-center text-sm text-white transition-all hover:bg-white hover:text-black"- >- Upgrade to Pro- </Link>- </div>+ <UpgradeToProToast message={error.message} />));} else {toast.error(error.message);}const message = error.message.toLowerCase();- if (message === "social media cards need a pro plan.") {- toast.custom(- () => (- <div className="relative z-50 grid grid-cols-2 items-center gap-4 rounded-2xl border border-gray-200 bg-white p-4 shadow-md">- <div>- <p className="mb-1.5 text-sm text-gray-700">- Social media cards need a Pro plan.- </p>- <p className="text-xs text-gray-500">- Upgrade to Pro to get this feature.- </p>- </div>- <Button- text={`Upgrade to ${nextPlan.name}`}- onClick={() => {- queryParams({- set: {- upgrade: nextPlan.name.toLowerCase(),- },- });- }}- />- </div>- ),- {- duration: 10000,- },- );- } else {- toast.error(error.message);- }-if (message.includes("key") || message.includes("domain")) {setKeyError(error.message);} else if (message.includes("url")) {@@ -574,48 +523,34 @@ function AddEditLinkModal({</button>) : (<div className="flex items-center">- <ButtonWithTooltip- tooltip={{- content: "Generate a random key",- }}+ <ButtonTooltip+ tooltipContent="Generate a random key"onClick={generateRandomKey}disabled={generatingRandomKey || generatingAIKey}+ className="flex h-6 w-6 items-center justify-center rounded-md text-gray-500 transition-colors duration-75 hover:bg-gray-100 active:bg-gray-200 disabled:cursor-not-allowed">{generatingRandomKey ? (<LoadingCircle />) : (<Random className="h-3 w-3" />)}- </ButtonWithTooltip>- <ButtonWithTooltip+ </ButtonTooltip>+ <ButtonTooltiponClick={generateAIKey}disabled={generatingAIKey ||(aiLimit && aiUsage && aiUsage >= aiLimit) ||!url}- tooltip={{- ai:- url && aiLimit && aiUsage- ? {- data: {- limit: aiLimit,- usage: aiUsage,- },- title: "AI Usage",- }- : undefined,- content: url- ? "Generate AI key"- : "Enter a URL first",- }}+ tooltipContent="Generate a key using AI"+ className="flex h-6 w-6 items-center justify-center rounded-md text-gray-500 transition-colors duration-75 hover:bg-gray-100 active:bg-gray-200 disabled:cursor-not-allowed">{generatingAIKey ? (<LoadingCircle />) : (<Magic className="h-4 w-4" />)}- </ButtonWithTooltip>+ </ButtonTooltip></div>)}</div>@@ -763,11 +698,11 @@ function AddEditLinkModal({</div><div className="grid gap-5 px-4 md:px-16">- {slug && <TagsSection {...{ props, data, setData }} />}+ <TagsSection {...{ props, data, setData }} /><CommentsSection {...{ props, data, setData }} /><UTMSection {...{ props, data, setData }} /><OGSection- {...{ props, data, setData, aiUsage, revalidateAiUsage }}+ {...{ props, data, setData }}generatingMetatags={generatingMetatags}/><CloakingSection {...{ data, setData }} />diff --git a/apps/web/ui/modals/add-edit-link-modal/og-section.tsx b/apps/web/ui/modals/add-edit-link-modal/og-section.tsxindex ea7c1111ac..65aa0e821d 100644--- a/apps/web/ui/modals/add-edit-link-modal/og-section.tsx+++ b/apps/web/ui/modals/add-edit-link-modal/og-section.tsx@@ -2,8 +2,10 @@ import { resizeImage } from "@/lib/images";import useWorkspace from "@/lib/swr/use-workspace";import { LinkProps } from "@/lib/types";import { UploadCloud } from "@/ui/shared/icons";+import { UpgradeToProToast } from "@/ui/shared/upgrade-to-pro-toast";import {BadgeTooltip,+ ButtonTooltip,LoadingCircle,LoadingSpinner,Magic,@@ -19,25 +21,20 @@ import { Crown, Link2 } from "lucide-react";import { Dispatch, SetStateAction, useEffect, useState } from "react";import TextareaAutosize from "react-textarea-autosize";import { toast } from "sonner";-import { ButtonWithTooltip } from "./tooltip-button";import UnsplashSearch from "./unsplash-search";export default function OGSection({props,data,setData,- aiUsage,- revalidateAiUsage,generatingMetatags,}: {props?: LinkProps;data: LinkProps;setData: Dispatch<SetStateAction<LinkProps>>;- aiUsage?: number;- revalidateAiUsage: () => Promise<void>;generatingMetatags: boolean;}) {- const { id: workspaceId, aiLimit } = useWorkspace();+ const { id: workspaceId, exceededAI, mutate } = useWorkspace();const { title, description, image, proxy } = data;@@ -49,11 +46,13 @@ export default function OGSection({api: `/api/ai/completion?workspaceId=${workspaceId}`,id: "metatags-title-ai",onError: (error) => {- toast.error(error.message);- },- onFinish: () => {- revalidateAiUsage();+ if (error.message.includes("Upgrade to Pro")) {+ toast.custom(() => <UpgradeToProToast message={error.message} />);+ } else {+ toast.error(error.message);+ }},+ onFinish: () => mutate(),});const generateTitle = async () => {@@ -76,11 +75,13 @@ export default function OGSection({api: `/api/ai/completion?workspaceId=${workspaceId}`,id: "metatags-description-ai",onError: (error) => {- toast.error(error.message);- },- onFinish: () => {- revalidateAiUsage();+ if (error.message.includes("Upgrade to Pro")) {+ toast.custom(() => <UpgradeToProToast message={error.message} />);+ } else {+ toast.error(error.message);+ }},+ onFinish: () => mutate(),});const generateDescription = async () => {@@ -172,10 +173,8 @@ export default function OGSection({<div className="flex items-center justify-between"><p className="block text-sm font-medium text-gray-700">Image</p><div className="flex items-center justify-between">- <ButtonWithTooltip- tooltip={{- content: "Paste a URL to an image.",- }}+ <ButtonTooltip+ tooltipContent="Paste a URL to an image."onClick={() => {const image = window.prompt("Paste a URL to an image.",@@ -185,9 +184,10 @@ export default function OGSection({setData((prev) => ({ ...prev, image }));}}}+ className="flex h-6 w-6 items-center justify-center rounded-md text-gray-500 transition-colors duration-75 hover:bg-gray-100 active:bg-gray-200 disabled:cursor-not-allowed"><Link2 className="h-4 w-4 text-gray-500" />- </ButtonWithTooltip>+ </ButtonTooltip><Popovercontent={<UnsplashSearch@@ -198,14 +198,13 @@ export default function OGSection({openPopover={openPopover}setOpenPopover={handleSet}>- <ButtonWithTooltip+ <ButtonTooltip+ tooltipContent="Find high-resolution photos on Unsplash."onClick={handleSet}- tooltip={{- content: "Find high-resolution photos on Unsplash.",- }}+ className="flex h-6 w-6 items-center justify-center rounded-md text-gray-500 transition-colors duration-75 hover:bg-gray-100 active:bg-gray-200 disabled:cursor-not-allowed"><Unsplash className="h-3 w-3 text-gray-500" />- </ButtonWithTooltip>+ </ButtonTooltip></Popover></div></div>@@ -312,31 +311,18 @@ export default function OGSection({<p className="text-sm text-gray-500">{title?.length || 0}/120</p>- <ButtonWithTooltip+ <ButtonTooltip+ tooltipContent="Generate an optimized title using AI."onClick={generateTitle}- disabled={generatingTitle || !title}- tooltip={{- ai:- title && aiLimit && aiUsage- ? {- data: {- limit: aiLimit,- usage: aiUsage,- },- title: "Create a title using AI",- }- : undefined,- content: !title- ? "Please enter a title to generate one using AI."- : "Create an optimized title using AI.",- }}+ disabled={generatingTitle || !title || exceededAI}+ className="flex h-6 w-6 items-center justify-center rounded-md text-gray-500 transition-colors duration-75 hover:bg-gray-100 active:bg-gray-200 disabled:cursor-not-allowed">{generatingTitle ? (<LoadingCircle />) : (<Magic className="h-4 w-4" />)}- </ButtonWithTooltip>+ </ButtonTooltip></div></div><div className="relative mt-1 flex rounded-md shadow-sm">@@ -370,31 +356,18 @@ export default function OGSection({<p className="text-sm text-gray-500">{description?.length || 0}/240</p>- <ButtonWithTooltip+ <ButtonTooltip+ tooltipContent="Generate an optimized description using AI."onClick={generateDescription}disabled={generatingDescription || !description}- tooltip={{- ai:- description && aiLimit && aiUsage- ? {- data: {- limit: aiLimit,- usage: aiUsage,- },- title: "Create a description using AI",- }- : undefined,- content: !description- ? "Please enter a description to generate one using AI."- : "Create an optimized description using AI.",- }}+ className="flex h-6 w-6 items-center justify-center rounded-md text-gray-500 transition-colors duration-75 hover:bg-gray-100 active:bg-gray-200 disabled:cursor-not-allowed">{generatingDescription ? (<LoadingCircle />) : (<Magic className="h-4 w-4" />)}- </ButtonWithTooltip>+ </ButtonTooltip></div></div><div className="relative mt-1 flex rounded-md shadow-sm">diff --git a/apps/web/ui/modals/add-edit-link-modal/tags-section.tsx b/apps/web/ui/modals/add-edit-link-modal/tags-section.tsxindex df025b5f81..c2d73cbcd1 100644--- a/apps/web/ui/modals/add-edit-link-modal/tags-section.tsx+++ b/apps/web/ui/modals/add-edit-link-modal/tags-section.tsx@@ -1,8 +1,16 @@import useTags from "@/lib/swr/use-tags";import useWorkspace from "@/lib/swr/use-workspace";-import { LinkWithTagsProps } from "@/lib/types";+import { LinkWithTagsProps, TagProps } from "@/lib/types";import TagBadge from "@/ui/links/tag-badge";-import { LoadingCircle, SimpleTooltipContent, Tooltip } from "@dub/ui";+import { UpgradeToProToast } from "@/ui/shared/upgrade-to-pro-toast";+import {+ Badge,+ LoadingCircle,+ Magic,+ SimpleTooltipContent,+ Tooltip,+} from "@dub/ui";+import { useCompletion } from "ai/react";import { Command, useCommandState } from "cmdk";import { Check, ChevronDown, Tag, X } from "lucide-react";import { Dispatch, SetStateAction, useEffect, useRef, useState } from "react";@@ -18,9 +26,67 @@ export default function TagsSection({}) {const { id } = useWorkspace();const { tags: availableTags } = useTags();- const tags = data.tags;+ const { url, title, description, tags } = data;const [inputValue, setInputValue] = useState("");++ const {+ id: workspaceId,+ exceededAI,+ mutate: mutateWorkspace,+ } = useWorkspace();++ const [suggestedTags, setSuggestedTags] = useState<TagProps[]>([]);++ const { complete } = useCompletion({+ api: `/api/ai/completion?workspaceId=${workspaceId}`,+ onError: (error) => {+ if (error.message.includes("Upgrade to Pro")) {+ toast.custom(() => <UpgradeToProToast message={error.message} />);+ } else {+ toast.error(error.message);+ }+ },+ onFinish: (_, completion) => {+ mutateWorkspace();+ console.log({ completion });+ if (completion) {+ const completionArr = completion.split(", ");+ const suggestedTags = completionArr+ .map((tag: string) => {+ return availableTags?.find(({ name }) => name === tag) || null;+ })+ .filter(Boolean);+ setSuggestedTags(suggestedTags as TagProps[]);+ }+ },+ });++ useEffect(() => {+ // only show the completion if all the required fields are filled and not exceeded AI+ if (+ url &&+ title &&+ description &&+ !exceededAI &&+ suggestedTags.length === 0 &&+ availableTags &&+ availableTags.length > 0+ ) {+ complete(+ `From the list of avaialble tags below, suggest relevant tags for this link:++ - URL: ${url}+ - Meta title: ${title}+ - Meta description: ${description}.++ Only return the tag names, and nothing else. If there are no relevant tags, return an empty string.++ Available tags: ${availableTags.map(({ name }) => name).join(", ")}`,+ );+ }+ }, [url, title, description]);+const [creatingTag, setCreatingTag] = useState(false);const createTag = async (tag: string) => {@@ -103,7 +169,7 @@ export default function TagsSection({};return (- <div className="border-b border-gray-200 pb-5">+ <div className="border-b border-gray-200 pb-2"><Command ref={commandRef} className="relative" loop><div className="group rounded-md border border-gray-300 bg-white p-1 focus-within:border-gray-500 focus-within:ring-1 focus-within:ring-gray-500"><div className="absolute inset-y-0 left-0 flex items-center justify-center pl-3 text-gray-400">@@ -192,6 +258,40 @@ export default function TagsSection({</Command.List>)}</Command>+ <div className="flex h-10 items-center space-x-2">+ {suggestedTags.length > 0 && (+ <>+ <Tooltip content="AI-suggested tags based on the content of the link. Click to add.">+ <div className="group">+ <Magic className="h-4 w-4 transition-colors group-hover:text-gray-500" />+ </div>+ </Tooltip>+ {suggestedTags.map((tag) => (+ <button+ type="button"+ key={tag.id}+ onClick={() => {+ setData({+ ...data,+ tags: [...tags, tag],+ });+ setSuggestedTags((tags) =>+ tags.filter(({ id }) => id !== tag.id),+ );+ }}+ className="group flex items-center transition-all active:scale-95"+ >+ <Badge+ variant="neutral"+ className="transition-colors group-hover:border-gray-700 group-hover:text-gray-700"+ >+ {tag.name}+ </Badge>+ </button>+ ))}+ </>+ )}+ </div></div>);}diff --git a/apps/web/ui/modals/add-edit-link-modal/tooltip-button.tsx b/apps/web/ui/modals/add-edit-link-modal/tooltip-button.tsxdeleted file mode 100644index c220317588..0000000000--- a/apps/web/ui/modals/add-edit-link-modal/tooltip-button.tsx+++ /dev/null@@ -1,108 +0,0 @@-"use client";--import useWorkspace from "@/lib/swr/use-workspace";-import SimplePieChart from "@/ui/charts/simple-pie-chart";-import Infinity from "@/ui/shared/icons/infinity";-import { TooltipContent, useRouterStuff } from "@dub/ui";-import { Tooltip } from "@dub/ui/src/tooltip";-import { cn } from "@dub/utils";--// HOC to wrap a button with a tooltip and make it reusable-export default function TooltipButton() {- return function WrappedTooltipButton({- children,- tooltip: { content, cta, ai },- ...props- }: {- children: React.ReactNode;- tooltip: {- content: string;- cta?: string;- ai?: {- title: string;- data: {- usage: number;- limit: number;- };- };- };- [key: string]: any;- }) {- const { queryParams } = useRouterStuff();- const { plan, nextPlan } = useWorkspace();-- const showUsage = plan === "free" || plan === "pro";-- return (- <Tooltip- content={- ai ? (- ai.data.usage < ai.data.limit ? (- <div className="flex items-center gap-4 px-4 py-2">- <div>- <span className="block max-w-xs text-left text-sm text-gray-700">- {ai.title}- </span>- <span className="text-xs text-gray-500">- {showUsage &&- `${ai.data.limit - ai.data.usage} / ${ai.data.limit} AI credits left`}- </span>- </div>- {showUsage ? (- <SimplePieChart- data={[- {- name: "Remaining",- value: ai.data.limit - ai.data.usage,- color: "text-black",- },- {- name: "Used",- value: ai.data.usage,- color: "text-gray-200",- },- ]}- />- ) : (- <div className="rounded-full border-4 border-black p-1">- <Infinity className="h-6 w-6" />- </div>- )}- </div>- ) : (- <TooltipContent- title="You've reached your AI usage limit. Upgrade to Pro to get more AI credits."- cta={`Upgrade to ${nextPlan.name}`}- onClick={() => {- queryParams({- set: {- upgrade: nextPlan.name.toLowerCase(),- },- });- }}- />- )- ) : cta ? (- <TooltipContent title={content} cta={cta} />- ) : (- content- )- }- >- <button- {...props}- type="button"- disabled={props.disabled || (ai && ai?.data.usage >= ai?.data.limit)}- className={cn(- "flex h-6 w-6 items-center justify-center rounded-md text-gray-500 transition-colors duration-75 hover:bg-gray-100 active:bg-gray-200 disabled:cursor-not-allowed",- props.className,- )}- >- {children}- </button>- </Tooltip>- );- };-}--export const ButtonWithTooltip = TooltipButton();diff --git a/apps/web/ui/shared/upgrade-to-pro-toast.tsx b/apps/web/ui/shared/upgrade-to-pro-toast.tsxnew file mode 100644index 0000000000..cf679b94a7--- /dev/null+++ b/apps/web/ui/shared/upgrade-to-pro-toast.tsx@@ -0,0 +1,32 @@+"use client";++import { useRouterStuff } from "@dub/ui";+import { Crown } from "lucide-react";+import Link from "next/link";++export const UpgradeToProToast = ({ message }: { message: string }) => {+ const { queryParams } = useRouterStuff();++ return (+ <div className="flex flex-col space-y-3 rounded-lg bg-white p-6 shadow-lg">+ <div className="flex items-center space-x-1.5">+ <Crown className="h-5 w-5 text-black" />{" "}+ <p className="font-semibold">You've discovered a Pro feature!</p>+ </div>+ <p className="text-sm text-gray-600">{message}</p>+ <Link+ href={+ queryParams({+ set: {+ upgrade: "pro",+ },+ getNewPath: true,+ }) as string+ }+ className="w-full rounded-md border border-black bg-black px-3 py-1.5 text-center text-sm text-white transition-all hover:bg-white hover:text-black"+ >+ Upgrade to Pro+ </Link>+ </div>+ );+};diff --git a/packages/ui/src/tooltip.tsx b/packages/ui/src/tooltip.tsxindex 4e2fe4ebd9..56f3ba62e5 100644--- a/packages/ui/src/tooltip.tsx+++ b/packages/ui/src/tooltip.tsx@@ -7,6 +7,7 @@ import { HelpCircle } from "lucide-react";import Link from "next/link";import { ReactNode, useState } from "react";import { Badge } from "./badge";+import { ButtonProps } from "./button";export function TooltipProvider({ children }: { children: ReactNode }) {return (@@ -194,3 +195,22 @@ export function BadgeTooltip({ children, content, ...props }: TooltipProps) {</Tooltip>);}++export function ButtonTooltip({+ tooltipContent,+ children,+ ...props+}: {+ tooltipContent: ReactNode | string;+ children: ReactNode;+} & ButtonProps) {+ return (+ <Tooltip content={tooltipContent}>+ <div className="flex cursor-pointer items-center">+ <button type="button" {...props}>+ {children}+ </button>+ </div>+ </Tooltip>+ );+}diff --git a/packages/utils/src/constants/pricing.tsx b/packages/utils/src/constants/pricing.tsxindex 8fdfccf216..1d32dac944 100644--- a/packages/utils/src/constants/pricing.tsx+++ b/packages/utils/src/constants/pricing.tsx@@ -149,7 +149,7 @@ export const PLANS = [domains: 10,tags: 25,users: 5,- ai: 100,+ ai: 10000000,},colors: {bg: "bg-blue-500",@@ -170,7 +170,7 @@ export const PLANS = [{ text: "1-year analytics retention" },{ text: "10 custom domains" },{ text: "5 users" },- { text: "100 AI credits/mo" },+ { text: "Unlimited AI credits" },{ text: "Basic support", footnote: "Basic email support." },{text: "Root domain redirect",