The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
start improving onboarding to conversion flow
Steven Teycdd9f80d1d96
diff --git a/app/api/cron/import/route.ts b/app/api/cron/import/route.tsindex 8b2fd2069f..712ce7e7ea 100644--- a/app/api/cron/import/route.ts+++ b/app/api/cron/import/route.ts@@ -3,6 +3,8 @@ import { importLinksFromBitly } from "#/lib/cron/import";import { redis } from "#/lib/upstash";import { NextResponse } from "next/server";import { Receiver } from "@upstash/qstash";+import prisma from "#/lib/prisma";+import { randomBadgeColor } from "@/components/app/links/tag-badge";export const receiver = new Receiver({currentSigningKey: process.env.QSTASH_CURRENT_SIGNING_KEY || "",@@ -22,11 +24,51 @@ export async function POST(req: Request) {try {const data = await req.json();- const { provider, projectId } = data;+ const { provider, projectId, bitlyGroup, keepTags } = data;if (provider === "bitly") {const bitlyApiKey = await redis.get(`import:bitly:${projectId}`);+ let tagsToId;+ if (keepTags === true) {+ const tags = await fetch(+ `https://api-ssl.bitly.com/v4/groups/${bitlyGroup}/tags`,+ {+ headers: {+ "Content-Type": "application/json",+ Authorization: `Bearer ${bitlyApiKey}`,+ },+ },+ )+ .then((r) => r.json())+ .then((r) => r.tags);++ await prisma.tag.createMany({+ data: tags.map((tag) => ({+ name: tag,+ color: randomBadgeColor(),+ projectId,+ })),+ skipDuplicates: true,+ });+ tagsToId = await prisma.tag+ .findMany({+ where: {+ projectId,+ },+ select: {+ id: true,+ name: true,+ },+ })+ .then((tags) =>+ tags.reduce((acc, tag) => {+ acc[tag.name] = tag.id;+ return acc;+ }, {}),+ );+ }await importLinksFromBitly({...data,+ tagsToId,bitlyApiKey,});}diff --git a/app/ui/modal-provider.tsx b/app/ui/modal-provider.tsxindex 7a674a3df8..8f9825eb0f 100644--- a/app/ui/modal-provider.tsx+++ b/app/ui/modal-provider.tsx@@ -21,17 +21,20 @@ import { useGoogleOauthModal } from "@/components/app/modals/google-oauth-modal"import { mutate } from "swr";import { useRouter } from "next/router";import { getQueryString } from "#/lib/utils";+import { useUpgradePlanModal } from "@/components/app/modals/upgrade-plan-modal";export const ModalContext = createContext<{setShowAddProjectModal: Dispatch<SetStateAction<boolean>>;setShowAddEditDomainModal: Dispatch<SetStateAction<boolean>>;setShowAddEditLinkModal: Dispatch<SetStateAction<boolean>>;+ setShowUpgradePlanModal: Dispatch<SetStateAction<boolean>>;setShowImportLinksModal: Dispatch<SetStateAction<boolean>>;setPollLinks: Dispatch<SetStateAction<boolean>>;}>({setShowAddProjectModal: () => {},setShowAddEditDomainModal: () => {},setShowAddEditLinkModal: () => {},+ setShowUpgradePlanModal: () => {},setShowImportLinksModal: () => {},setPollLinks: () => {},});@@ -45,19 +48,23 @@ export default function ModalProvider({ children }: { children: ReactNode }) {useAddEditDomainModal({});const { setShowAddEditLinkModal, AddEditLinkModal } = useAddEditLinkModal();+ const { setShowUpgradePlanModal, UpgradePlanModal } = useUpgradePlanModal();const { setShowImportLinksModal, ImportLinksModal } = useImportLinksModal();const { error, loading } = useProject();const { data: session } = useSession();const router = useRouter();+ const { slug } = router.query;+ // special link polling setup to poll links as they're being created (for bitly import)const [pollLinks, setPollLinks] = useState(false);useEffect(() => {if (pollLinks) {- // if pollLinks is true, start polling links endpoint every 500 ms (stop after 30 seconds)+ // if pollLinks is true, start polling links endpoint every 500 ms (stop after 20 seconds)const pollingInterval = setInterval(() => {mutate(`/api/links${getQueryString(router)}`);+ mutate(`/api/projects/${slug}/tags`);mutate((key) =>typeof key === "string" && key.startsWith(`/api/links/_count`),@@ -68,7 +75,7 @@ export default function ModalProvider({ children }: { children: ReactNode }) {setTimeout(() => {setPollLinks(false);clearInterval(pollingInterval);- }, 30000);+ }, 20000);}}, [pollLinks]);@@ -95,6 +102,7 @@ export default function ModalProvider({ children }: { children: ReactNode }) {setShowAddProjectModal,setShowAddEditDomainModal,setShowAddEditLinkModal,+ setShowUpgradePlanModal,setShowImportLinksModal,setPollLinks,}}@@ -106,6 +114,7 @@ export default function ModalProvider({ children }: { children: ReactNode }) {)}<AddEditDomainModal /><AddEditLinkModal />+ <UpgradePlanModal /><ImportLinksModal />{children}</ModalContext.Provider>diff --git a/components/app/links/tag-badge.tsx b/components/app/links/tag-badge.tsxindex eb080ad1f6..1ce8288e8d 100644--- a/components/app/links/tag-badge.tsx+++ b/components/app/links/tag-badge.tsx@@ -25,7 +25,7 @@ export default function TagBadge({)}>{withIcon && <Tag className="h-3 w-3" />}- <p>{truncate(name || "", 15)}</p>+ <p>{truncate(name || "", 24)}</p></span>);}diff --git a/components/app/modals/add-project-modal.tsx b/components/app/modals/add-project-modal.tsxindex cf17986913..2fb0b1315a 100644--- a/components/app/modals/add-project-modal.tsx+++ b/components/app/modals/add-project-modal.tsx@@ -21,11 +21,11 @@ import { toast } from "sonner";function AddProjectModalHelper({showAddProjectModal,setShowAddProjectModal,- closeWithX,+ welcomeFlow,}: {showAddProjectModal: boolean;setShowAddProjectModal: Dispatch<SetStateAction<boolean>>;- closeWithX?: boolean;+ welcomeFlow?: boolean;}) {const router = useRouter();@@ -85,7 +85,7 @@ function AddProjectModalHelper({<ModalshowModal={showAddProjectModal}setShowModal={setShowAddProjectModal}- closeWithX={closeWithX}+ closeWithX={welcomeFlow}><div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200"><div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">@@ -114,9 +114,19 @@ function AddProjectModalHelper({// track project creation eventva.track("Created Project");mutate("/api/projects");- router.push(`/${slug}`);- toast.success("Successfully created project!");- setShowAddProjectModal(false);+ if (welcomeFlow) {+ router.push({+ pathname: "/welcome",+ query: {+ type: "upgrade",+ slug,+ },+ });+ } else {+ router.push(`/${slug}`);+ toast.success("Successfully created project!");+ setShowAddProjectModal(false);+ }} else if (res.status === 422) {const {slugError: slugErrorResponse,@@ -280,8 +290,8 @@ function AddProjectModalHelper({}export function useAddProjectModal({- closeWithX,-}: { closeWithX?: boolean } = {}) {+ welcomeFlow,+}: { welcomeFlow?: boolean } = {}) {const [showAddProjectModal, setShowAddProjectModal] = useState(false);const AddProjectModal = useCallback(() => {@@ -289,10 +299,10 @@ export function useAddProjectModal({<AddProjectModalHelpershowAddProjectModal={showAddProjectModal}setShowAddProjectModal={setShowAddProjectModal}- closeWithX={closeWithX}+ welcomeFlow={welcomeFlow}/>);- }, [showAddProjectModal, setShowAddProjectModal, closeWithX]);+ }, [showAddProjectModal, setShowAddProjectModal, welcomeFlow]);return useMemo(() => ({ setShowAddProjectModal, AddProjectModal }),diff --git a/components/app/modals/upgrade-plan-modal.tsx b/components/app/modals/upgrade-plan-modal.tsxnew file mode 100644index 0000000000..8325b36e1c--- /dev/null+++ b/components/app/modals/upgrade-plan-modal.tsx@@ -0,0 +1,85 @@+import {+ Dispatch,+ SetStateAction,+ useCallback,+ useMemo,+ useState,+} from "react";+import Modal from "@/components/shared/modal";+import BlurImage from "#/ui/blur-image";+import Button from "#/ui/button";+import { useRouter } from "next/router";+import Link from "next/link";++function UpgradePlanModal({+ showUpgradePlanModal,+ setShowUpgradePlanModal,+ welcomeFlow,+}: {+ showUpgradePlanModal: boolean;+ setShowUpgradePlanModal: Dispatch<SetStateAction<boolean>>;+ welcomeFlow?: boolean;+}) {+ const router = useRouter();+ const { slug } = router.query;+ return (+ <Modal+ showModal={showUpgradePlanModal}+ setShowModal={setShowUpgradePlanModal}+ closeWithX={welcomeFlow}+ >+ <div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">+ <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-8 sm:px-16">+ <BlurImage+ src="/_static/logo.png"+ alt="Dub logo"+ className="h-10 w-10 rounded-full border border-gray-200"+ width={20}+ height={20}+ />+ <h3 className="text-lg font-medium">Upgrade Plan</h3>+ </div>+ <div className="flex flex-col space-y-3 bg-gray-50 px-4 py-8 text-left sm:px-16">+ <Button+ text="Upgrade plan"+ onClick={() => {+ setShowUpgradePlanModal(false);+ }}+ />+ {welcomeFlow && (+ <Link+ href={`/${slug}`}+ className="text-center text-xs text-gray-500 underline underline-offset-4 transition-colors hover:text-gray-800"+ >+ Skip for now+ </Link>+ )}+ </div>+ </div>+ </Modal>+ );+}++export function useUpgradePlanModal({+ welcomeFlow,+}: { welcomeFlow?: boolean } = {}) {+ const [showUpgradePlanModal, setShowUpgradePlanModal] = useState(false);++ const UpgradePlanModalCallback = useCallback(() => {+ return (+ <UpgradePlanModal+ showUpgradePlanModal={showUpgradePlanModal}+ setShowUpgradePlanModal={setShowUpgradePlanModal}+ welcomeFlow={welcomeFlow}+ />+ );+ }, [showUpgradePlanModal, setShowUpgradePlanModal, welcomeFlow]);++ return useMemo(+ () => ({+ setShowUpgradePlanModal,+ UpgradePlanModal: UpgradePlanModalCallback,+ }),+ [setShowUpgradePlanModal, UpgradePlanModalCallback],+ );+}diff --git a/components/app/modals/upgrade-plan-modal/index.tsx b/components/app/modals/upgrade-plan-modal/index.tsxdeleted file mode 100644index 06e56612a8..0000000000--- a/components/app/modals/upgrade-plan-modal/index.tsx+++ /dev/null@@ -1,49 +0,0 @@-import {- Dispatch,- SetStateAction,- useCallback,- useMemo,- useState,-} from "react";-import Modal from "@/components/shared/modal";-import Pricing from "./pricing";--function UpgradePlanModal({- showUpgradePlanModal,- setShowUpgradePlanModal,-}: {- showUpgradePlanModal: boolean;- setShowUpgradePlanModal: Dispatch<SetStateAction<boolean>>;-}) {- return (- <Modal- showModal={showUpgradePlanModal}- setShowModal={setShowUpgradePlanModal}- >- <div className="inline-block max-h-[calc(100vh-150px)] w-full max-w-screen-xl transform overflow-scroll bg-white align-middle shadow-xl scrollbar-hide sm:rounded-2xl sm:border sm:border-gray-200">- <Pricing />- </div>- </Modal>- );-}--export function useUpgradePlanModal() {- const [showUpgradePlanModal, setShowUpgradePlanModal] = useState(false);-- const UpgradePlanModalCallback = useCallback(() => {- return (- <UpgradePlanModal- showUpgradePlanModal={showUpgradePlanModal}- setShowUpgradePlanModal={setShowUpgradePlanModal}- />- );- }, [showUpgradePlanModal, setShowUpgradePlanModal]);-- return useMemo(- () => ({- setShowUpgradePlanModal,- UpgradePlanModal: UpgradePlanModalCallback,- }),- [setShowUpgradePlanModal, UpgradePlanModalCallback],- );-}diff --git a/components/app/modals/upgrade-plan-modal/pricing.tsx b/components/app/modals/upgrade-plan-modal/pricing.tsxdeleted file mode 100644index 6b062bc8d3..0000000000--- a/components/app/modals/upgrade-plan-modal/pricing.tsx+++ /dev/null@@ -1,307 +0,0 @@-"use client";--import Link from "next/link";-import { useMemo, useState } from "react";-import Confetti from "react-dom-confetti";-import {- CheckCircleFill,- QuestionCircle,- XCircleFill,-} from "@/components/shared/icons";-import { LoadingDots } from "#/ui/icons";-import MaxWidthWrapper from "@/components/shared/max-width-wrapper";-import Switch from "#/ui/switch";-import Tooltip from "#/ui/tooltip";-import { getStripe } from "#/lib/stripe/client";-import { PLANS } from "#/lib/stripe/utils";-import { capitalize, nFormatter } from "#/lib/utils";-import useProject from "#/lib/swr/use-project";-import { MinusCircle } from "lucide-react";--const pricingItems = [- {- plan: "Free",- tagline: "For startups & side projects",- quota: 1000,- features: [- { text: "Unlimited branded links" },- {- text: "Unlimited custom domains",- },- {- text: "Free SSL certificates",- },- {- text: "Advanced link features",- footnote:- "Password protection, link expiration, device targeting, custom social media cards, etc.",- },- { text: "Up to 3 users", neutral: true },- {- text: "Root domain redirect",- footnote:- "Redirect vistors that land on the root of your domain (e.g. yourdomain.com) to a page of your choice.",- negative: true,- },- {- text: "Custom QR Code Logo",- negative: true,- },- { text: "SSO/SAML", negative: true },- { text: "Priority support", negative: true },- ],- cta: "Start for free",- },- {- plan: "Pro",- tagline: "For larger teams with increased usage",- quota: PLANS.find((p) => p.slug === "pro")!.quota,- features: [- { text: "Unlimited branded links" },- {- text: "Unlimited custom domains",- },- {- text: "Free SSL certificates",- },- {- text: "Advanced link features",- footnote:- "Password protection, link expiration, device targeting, custom social media cards, etc.",- },- { text: "Unlimited users" },- {- text: "Root domain redirect",- footnote:- "Redirect visitors that land on the root of your domain (e.g. yourdomain.com) to a page of your choice.",- },- {- text: "Custom QR Code Logo",- },- { text: "SSO/SAML", negative: true },- { text: "Priority support", negative: true },- ],- cta: "Get started",- },- {- plan: "Enterprise",- tagline: "For businesses with custom needs",- quota: PLANS.find((p) => p.slug === "enterprise")!.quota,- features: [- { text: "Unlimited branded links" },- {- text: "Unlimited custom domains",- },- {- text: "Free SSL certificates",- },- {- text: "Advanced link features",- footnote:- "Password protection, link expiration, device targeting, custom social media cards, etc.",- },- { text: "Unlimited users" },- {- text: "Root domain redirect",- footnote:- "Redirect visitors that land on the root of your domain (e.g. yourdomain.com) to a page of your choice.",- },- {- text: "Custom QR Code Logo",- },- { text: "SSO/SAML", footnote: "Under development. ETA: Q4 2023" },- {- text: "Priority support",- footnote: "Email & chat support within 24 hours.",- },- ],- cta: "Get started",- },-];--const Pricing = ({ homePage }: { homePage?: boolean }) => {- const [annualBilling, setAnnualBilling] = useState(homePage ? false : true);- const period = useMemo(- () => (annualBilling ? "yearly" : "monthly"),- [annualBilling],- );- const { plan: currentPlan, slug } = useProject();- const [clicked, setClicked] = useState(false);- const env =- process.env.NEXT_PUBLIC_VERCEL_ENV === "production" ? "production" : "test";-- return (- <MaxWidthWrapper className="my-20 text-center">- <div id="pricing" className="mx-auto my-10 sm:max-w-lg">- <h2 className="font-display text-4xl font-extrabold text-black sm:text-5xl">- Simple,{" "}- <span className="bg-gradient-to-r from-blue-600 to-cyan-600 bg-clip-text text-transparent">- affordable- </span>{" "}- pricing- </h2>- <p className="mt-5 text-gray-600 sm:text-lg">- Shorten your links without breaking your bank. <br />- Start for free, no credit card required.- </p>- </div>-- <div className="relative mx-auto mb-14 flex max-w-fit items-center space-x-2">- <p className="text-gray-600">Billed Monthly</p>- <Confetti- active={period === "yearly"}- config={{ elementCount: 200, spread: 90 }}- />- <Switch- fn={setAnnualBilling}- checked={annualBilling}- trackDimensions="h-6 w-12"- thumbDimensions="h-5 w-5"- thumbTranslate="translate-x-6"- />- <p className="text-gray-600">Billed Annually</p>- <span className="absolute -right-12 -top-8 rounded-full bg-purple-200 px-3 py-1 text-sm text-purple-700 sm:-right-[9.5rem] sm:-top-2">- 🎁 2 months FREE- </span>- </div>-- <div className="grid grid-cols-1 gap-10 lg:grid-cols-3">- {pricingItems.map(({ plan, tagline, quota, features, cta }) => {- const price =- PLANS.find((p) => p.slug === plan.toLowerCase())?.price[period]- .amount || 0;- const highlighted = currentPlan && currentPlan === plan.toLowerCase();- return (- <div- key={plan}- className={`relative rounded-2xl bg-white ${- highlighted- ? "border-2 border-blue-600 shadow-blue-200"- : "border border-gray-200"- } shadow-lg`}- >- {highlighted && (- <div className="absolute -top-5 left-0 right-0 mx-auto w-32 rounded-full bg-gradient-to-r from-blue-600 to-cyan-600 px-3 py-2 text-sm font-medium text-white">- {currentPlan ? "Current Plan" : "Popular"}- </div>- )}-- <div className="p-5">- <h3 className="my-3 text-center font-display text-3xl font-bold">- {plan}- </h3>- <p className="text-gray-500">{tagline}</p>- <p className="my-5 font-display text-6xl font-semibold">- ${period === "yearly" ? nFormatter(price / 12, 1) : price}- </p>- <p className="text-gray-500">- per {period === "yearly" ? "month, billed annually" : "month"}- </p>- </div>- <div className="flex h-20 items-center justify-center border-b border-t border-gray-200 bg-gray-50">- <div className="flex items-center">- <p className="text-gray-600">- {plan === "Enterprise"- ? "Unlimited link clicks"- : `Up to ${nFormatter(quota)} link clicks/mo`}- </p>- <Tooltip content="If you exceed your monthly usage, your existing links will still work, but you need to upgrade to view their stats/add more links.">- <div className="flex h-4 w-8 justify-center">- <QuestionCircle className="h-4 w-4 text-gray-600" />- </div>- </Tooltip>- </div>- </div>- <ul className="my-10 space-y-5 px-8">- {features.map(({ text, footnote, neutral, negative }) => (- <li key={text} className="flex space-x-5">- <div className="flex-shrink-0">- {neutral ? (- <MinusCircle- fill="#D4D4D8"- className="h-6 w-6 text-white"- />- ) : negative ? (- <XCircleFill className="h-6 w-6 text-gray-300" />- ) : (- <CheckCircleFill className="h-6 w-6 text-green-500" />- )}- </div>- {footnote ? (- <div className="flex items-center">- <p- className={- negative ? "text-gray-400" : "text-gray-600"- }- >- {text}- </p>- <Tooltip content={footnote}>- <div className="flex h-4 w-8 justify-center">- <QuestionCircle className="h-4 w-4 text-gray-600" />- </div>- </Tooltip>- </div>- ) : (- <p- className={negative ? "text-gray-400" : "text-gray-600"}- >- {text}- </p>- )}- </li>- ))}- </ul>- <div className="border-t border-gray-200" />- <div className="p-5">- <button- disabled={clicked || highlighted}- onClick={() => {- setClicked(true);- fetch(- `/api/projects/${slug}/billing/upgrade?priceId=${- PLANS.find((p) => p.slug === plan.toLowerCase())!.price[- period- ].priceIds[env]- }`,- {- method: "POST",- },- )- .then(async (res) => {- const data = await res.json();- const { id: sessionId } = data;- const stripe = await getStripe();- stripe?.redirectToCheckout({ sessionId });- })- .catch((err) => {- alert(err);- setClicked(false);- });- }}- className={`${- clicked || highlighted- ? "cursor-not-allowed border-gray-200 bg-gray-100 text-gray-400"- : "border-blue-500 bg-blue-500 text-white hover:bg-white hover:text-blue-500"- } mb-2 flex h-10 w-full items-center justify-center rounded-md border text-sm transition-all focus:outline-none`}- >- {clicked ? (- <LoadingDots color="#808080" />- ) : (- <p>- {highlighted- ? "Current Plan"- : `Upgrade to ${plan} ${capitalize(period)}`}- </p>- )}- </button>- </div>- </div>- );- })}- </div>- </MaxWidthWrapper>- );-};--export default Pricing;diff --git a/components/app/projects/settings/plan-usage.tsx b/components/app/projects/settings/plan-usage.tsxindex 2d317691e3..6cee554025 100644--- a/components/app/projects/settings/plan-usage.tsx+++ b/components/app/projects/settings/plan-usage.tsx@@ -1,23 +1,26 @@import { useRouter } from "next/router";-import { useEffect, useMemo, useState } from "react";+import { useContext, useEffect, useMemo, useState } from "react";import { motion } from "framer-motion";-import { useUpgradePlanModal } from "@/components/app/modals/upgrade-plan-modal";import { Infinity, Divider, QuestionCircle } from "@/components/shared/icons";import { LoadingDots } from "#/ui/icons";import Tooltip from "#/ui/tooltip";-import { getFirstAndLastDay, nFormatter } from "#/lib/utils";+import { fetcher, getFirstAndLastDay, nFormatter } from "#/lib/utils";import useProject from "#/lib/swr/use-project";-import useDomains from "#/lib/swr/use-domains";import PlanBadge from "./plan-badge";import { toast } from "sonner";-import { mutate } from "swr";+import useSWR, { mutate } from "swr";import va from "@vercel/analytics";+import { ModalContext } from "#/ui/modal-provider";export default function PlanUsage() {const router = useRouter();const { slug, plan, usage, usageLimit, billingCycleStart } = useProject();- const { domains } = useDomains();++ const { data: links } = useSWR<number>(+ `/api/links/_count?slug=${slug}`,+ fetcher,+ );const [clicked, setClicked] = useState(false);@@ -37,7 +40,7 @@ export default function PlanUsage() {return [];}, [billingCycleStart]);- const { UpgradePlanModal, setShowUpgradePlanModal } = useUpgradePlanModal();+ const { setShowUpgradePlanModal } = useContext(ModalContext);useEffect(() => {if (router.query.success) {@@ -54,7 +57,6 @@ export default function PlanUsage() {return (<div className="rounded-lg border border-gray-200 bg-white">- <UpgradePlanModal /><div className="flex flex-col space-y-3 p-10"><h2 className="text-xl font-medium">Plan & Usage</h2><p className="text-sm text-gray-500">@@ -84,7 +86,7 @@ export default function PlanUsage() {<div className="flex flex-col space-y-2 p-10"><div className="flex items-center"><h3 className="font-medium">Total Link Clicks</h3>- <Tooltip content="Number of billable link clicks across all your projects.">+ <Tooltip content="Number of billable link clicks across all your projects this billing cycle."><div className="flex h-4 w-8 justify-center"><QuestionCircle className="h-4 w-4 text-gray-600" /></div>@@ -117,11 +119,18 @@ export default function PlanUsage() {</div></div><div className="p-10">- <h3 className="font-medium">Number of Domains</h3>+ <div className="flex items-center">+ <h3 className="font-medium">Number of Links</h3>+ <Tooltip content="Total number of short links in your project.">+ <div className="flex h-4 w-8 justify-center">+ <QuestionCircle className="h-4 w-4 text-gray-600" />+ </div>+ </Tooltip>+ </div><div className="mt-4 flex items-center">- {domains ? (+ {links ? (<p className="text-2xl font-semibold text-black">- {nFormatter(domains.length)}+ {nFormatter(links)}</p>) : (<div className="h-8 w-8 animate-pulse rounded-md bg-gray-200" />diff --git a/lib/cron/import.tsx b/lib/cron/import.tsxindex 95c11d2f69..ae93388dcd 100644--- a/lib/cron/import.tsx+++ b/lib/cron/import.tsx@@ -1,6 +1,5 @@import prisma from "#/lib/prisma";import { redis } from "#/lib/upstash";-import { randomBadgeColor } from "@/components/app/links/tag-badge";import { sendEmail } from "emails";// recursive function to check if pagination.searchAfter is not an empty string, else break@@ -9,9 +8,18 @@ export const importLinksFromBitly = async ({projectId,bitlyGroup,domains,+ tagsToId,bitlyApiKey,searchAfter = null,count = 0,+}: {+ projectId: string;+ bitlyGroup: string;+ domains: string[];+ tagsToId?: Record<string, string>;+ bitlyApiKey: string;+ searchAfter?: string | null;+ count?: number;}) => {const data = await fetch(`https://api-ssl.bitly.com/v4/groups/${bitlyGroup}/bitlinks?size=100${@@ -32,7 +40,7 @@ export const importLinksFromBitly = async ({// convert links to format that can be imported into databaseconst importedLinks = links.map((link) => {- const { id, long_url: url, title, archived, created_at } = link;+ const { id, long_url: url, title, archived, created_at, tags } = link;const [domain, key] = id.split("/");// if domain is not in project domains, skip (could be a bit.ly link or old short domain)if (!domains.includes(domain)) {@@ -45,6 +53,7 @@ export const importLinksFromBitly = async ({// },// );const createdAt = new Date(created_at).toISOString();+ const tagId = tagsToId ? tagsToId[tags[0]] : null;return {projectId,domain,@@ -53,6 +62,7 @@ export const importLinksFromBitly = async ({title,archived,createdAt,+ ...(tagId ? { tagId } : {}),};}).filter((link) => link !== null);@@ -81,6 +91,17 @@ export const importLinksFromBitly = async ({await Promise.all([// delete key from redisredis.del(`import:bitly:${projectId}`),++ // delete tags that have no links+ prisma.tag.deleteMany({+ where: {+ projectId,+ links: {+ none: {},+ },+ },+ }),+// send email to user// sendEmail({// subject: `Your Bitly links have been imported!`,diff --git a/pages/api/projects/[slug]/import/bitly.ts b/pages/api/projects/[slug]/import/bitly.tsindex 895c93aea9..bb8d744c5c 100644--- a/pages/api/projects/[slug]/import/bitly.ts+++ b/pages/api/projects/[slug]/import/bitly.ts@@ -88,22 +88,23 @@ export default withProjectAuth(async (req, res, project, session) => {return result;}, []);- // const response = await Promise.all(- // groups- // // only add groups that have at least 1 domain selected for import- // .filter(({ domains }) => domains.length > 0)- // .map(({ bitlyGroup, domains }) =>- // qstash.publishJSON({- // url: "https://067b-2600-1700-b5e4-b50-8197-b987-5375-e928.ngrok-free.app/api/cron/import",- // body: {- // provider: "bitly",- // projectId: project.id,- // bitlyGroup,- // domains,- // },- // }),- // ),- // );+ const response = await Promise.all(+ groups+ // only add groups that have at least 1 domain selected for import+ .filter(({ domains }) => domains.length > 0)+ .map(({ bitlyGroup, domains, keepTags }) =>+ qstash.publishJSON({+ url: "https://067b-2600-1700-b5e4-b50-8197-b987-5375-e928.ngrok-free.app/api/cron/import",+ body: {+ provider: "bitly",+ projectId: project.id,+ bitlyGroup,+ domains,+ keepTags,+ },+ }),+ ),+ );console.log(groups);diff --git a/pages/app/[slug]/index.tsx b/pages/app/[slug]/index.tsxindex feee848957..ccd04da867 100644--- a/pages/app/[slug]/index.tsx+++ b/pages/app/[slug]/index.tsx@@ -22,17 +22,17 @@ export default function ProjectLinks() {const { verified, loading: loadingDomains } = useDomains();- // useEffect(() => {- // if (- // !verified &&- // !loadingProject &&- // !loadingDomains &&- // !error &&- // !document.getElementById("modal-backdrop")- // ) {- // setShowCompleteSetupModal(true);- // }- // }, [verified, loadingProject, loadingDomains, error]);+ useEffect(() => {+ if (+ !verified &&+ !loadingProject &&+ !loadingDomains &&+ !error &&+ !document.getElementById("modal-backdrop")+ ) {+ setShowCompleteSetupModal(true);+ }+ }, [verified, loadingProject, loadingDomains, error]);const [openPopover, setOpenPopover] = useState(false);diff --git a/pages/app/welcome.tsx b/pages/app/welcome.tsxindex e1c863b623..7d8478a47c 100644--- a/pages/app/welcome.tsx+++ b/pages/app/welcome.tsx@@ -3,20 +3,24 @@ import Background from "#/ui/home/background";import Intro from "@/components/app/welcome/intro";import Interim from "@/components/app/welcome/interim";import { AnimatePresence } from "framer-motion";-import { useEffect, useState } from "react";+import { useEffect } from "react";import { useAddProjectModal } from "@/components/app/modals/add-project-modal";import { useAddEditLinkModal } from "@/components/app/modals/add-edit-link-modal";import Meta from "@/components/layout/meta";import va from "@vercel/analytics";import { ArrowLeft } from "lucide-react";+import { useUpgradePlanModal } from "@/components/app/modals/upgrade-plan-modal";export default function Welcome() {const { setShowAddProjectModal, AddProjectModal } = useAddProjectModal({- closeWithX: true,+ welcomeFlow: true,});const { setShowAddEditLinkModal, AddEditLinkModal } = useAddEditLinkModal({welcomeFlow: true,});+ const { setShowUpgradePlanModal, UpgradePlanModal } = useUpgradePlanModal({+ welcomeFlow: true,+ });const router = useRouter();@@ -39,6 +43,13 @@ export default function Welcome() {} else {setShowAddEditLinkModal(false);}+ if (router.query.type === "upgrade") {+ setTimeout(() => {+ setShowUpgradePlanModal(true);+ }, 200);+ } else {+ setShowUpgradePlanModal(false);+ }}, [router.query.type]);return (@@ -47,6 +58,7 @@ export default function Welcome() {<Background /><AddProjectModal /><AddEditLinkModal />+ <UpgradePlanModal /><AnimatePresence mode="wait">{router.query.type ? (<button