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.

Add paywall content

Tim Wilson51c315f1523e
diff --git a/apps/web/ui/analytics/main.tsx b/apps/web/ui/analytics/main.tsx
index 8cf819814d..24e9723643 100644
--- a/apps/web/ui/analytics/main.tsx
+++ b/apps/web/ui/analytics/main.tsx
@@ -1,8 +1,15 @@
import { AnalyticsSaleUnit, EventType } from "@/lib/analytics/types";
-import { ChartLine, Filter2, ToggleGroup, useRouterStuff } from "@dub/ui";
+import useWorkspace from "@/lib/swr/use-workspace";
+import {
+ buttonVariants,
+ ChartLine,
+ Filter2,
+ ToggleGroup,
+ useRouterStuff,
+} from "@dub/ui";
import { cn } from "@dub/utils";
import NumberFlow, { NumberFlowGroup } from "@number-flow/react";
-import { ChevronRight, Lock } from "lucide-react";
+import { ChevronRight, Lock, Play } from "lucide-react";
import Link from "next/link";
import { useContext, useMemo } from "react";
import AnalyticsAreaChart from "./analytics-area-chart";
@@ -59,17 +66,19 @@ export default function Main() {
const tab = tabs.find(({ id }) => id === selectedTab) ?? tabs[0];
+ const showPaywall = tab.conversions && !conversionsEnabled;
+
return (
- <div className="w-full overflow-hidden border border-gray-200 bg-white sm:rounded-xl">
- <div className="scrollbar-hide grid w-full grid-cols-3 divide-x overflow-y-hidden border-b border-gray-200">
+ <div className="w-full overflow-hidden bg-white">
+ <div className="scrollbar-hide grid w-full grid-cols-3 divide-x overflow-y-hidden border border-neutral-200 sm:rounded-t-xl">
<NumberFlowGroup>
{tabs.map(({ id, label, colorClassName, conversions }, idx) => {
return (
<div key={id} className="relative z-0">
{idx > 0 && (
- <div className="absolute left-0 top-1/2 z-10 -translate-x-1/2 -translate-y-1/2 rounded-full border border-gray-200 bg-white p-1.5">
+ <div className="absolute left-0 top-1/2 z-10 -translate-x-1/2 -translate-y-1/2 rounded-full border border-neutral-200 bg-white p-1.5">
<ChevronRight
- className="h-3 w-3 text-gray-400"
+ className="h-3 w-3 text-neutral-400"
strokeWidth={2.5}
/>
</div>
@@ -100,8 +109,8 @@ export default function Main() {
<Link
className={cn(
"border-box relative block h-full min-w-[110px] flex-none px-4 py-3 sm:min-w-[240px] sm:px-8 sm:py-6",
- "transition-colors hover:bg-gray-50 focus:outline-none active:bg-gray-100",
- "ring-inset ring-gray-500 focus-visible:ring-1 sm:first:rounded-tl-xl",
+ "transition-colors hover:bg-neutral-50 focus:outline-none active:bg-neutral-100",
+ "ring-inset ring-neutral-500 focus-visible:ring-1 sm:first:rounded-tl-xl",
)}
href={
queryParams({
@@ -121,7 +130,7 @@ export default function Main() {
)}
/>
- <div className="flex items-center gap-2.5 text-sm text-gray-600">
+ <div className="flex items-center gap-2.5 text-sm text-neutral-600">
<div
className={cn(
"h-2 w-2 rounded-sm bg-current shadow-[inset_0_0_0_1px_#00000019]",
@@ -159,11 +168,11 @@ export default function Main() {
}
/>
) : requiresUpgrade ? (
- <div className="block rounded-full bg-gray-100 p-2.5">
- <Lock className="h-4 w-4 text-gray-500" />
+ <div className="block rounded-full bg-neutral-100 p-2.5">
+ <Lock className="h-4 w-4 text-neutral-500" />
</div>
) : (
- <div className="h-9 w-16 animate-pulse rounded-md bg-gray-200" />
+ <div className="h-9 w-16 animate-pulse rounded-md bg-neutral-200" />
)}
</div>
</Link>
@@ -173,12 +182,20 @@ export default function Main() {
</NumberFlowGroup>
</div>
<div className="relative">
- {view === "timeseries" && (
- <div className="p-5 pt-10 sm:p-10">
- <AnalyticsAreaChart resource={tab.id} />
- </div>
- )}
- {view === "funnel" && <AnalyticsFunnelChart />}
+ <div
+ className={cn(
+ "relative overflow-hidden border-x border-b border-neutral-200 sm:rounded-b-xl",
+ showPaywall &&
+ "[mask-image:linear-gradient(#000a,#000a_30%,transparent_50%)]",
+ )}
+ >
+ {view === "timeseries" && (
+ <div className="p-5 pt-10 sm:p-10">
+ <AnalyticsAreaChart resource={tab.id} />
+ </div>
+ )}
+ {view === "funnel" && <AnalyticsFunnelChart />}
+ </div>
<ToggleGroup
className="absolute right-3 top-3 flex w-fit shrink-0 items-center gap-1 border-neutral-100 bg-neutral-100"
optionClassName="size-8 p-0 flex items-center justify-center"
@@ -200,6 +217,57 @@ export default function Main() {
});
}}
/>
+ {showPaywall && <ConversionTrackingPaywall />}
+ </div>
+ </div>
+ );
+}
+
+function ConversionTrackingPaywall() {
+ const { slug } = useWorkspace();
+
+ return (
+ <div className="animate-slide-up-fade pointer-events-none absolute inset-0 flex items-center justify-center pt-20">
+ <div className="pointer-events-auto flex flex-col items-center">
+ <Link
+ href="https://dub.co/help/article/dub-conversions"
+ target="_blank"
+ className="group relative flex aspect-video w-full max-w-80 items-center justify-center overflow-hidden rounded-lg border border-neutral-200 bg-neutral-100"
+ >
+ {/* TODO: Add video thumbnail */}
+ {/* <Image
+ src=""
+ alt="Video thumbnail"
+ fill
+ className="object-cover"
+ /> */}
+ <div className="relative flex size-10 items-center justify-center rounded-full bg-neutral-900 ring-[6px] ring-black/5 transition-all duration-75 group-hover:ring-[8px] group-active:ring-[7px]">
+ <Play className="size-4 fill-current text-white" />
+ </div>
+ </Link>
+ <h2 className="mt-7 text-base font-semibold text-neutral-700">
+ Conversion Tracking
+ </h2>
+ <p className="mt-4 max-w-sm text-center text-sm text-neutral-500">
+ Upgrade to our Business Plan to get a detailed conversion tracking and
+ events in your workspace.{" "}
+ <Link
+ href="https://dub.co/help/article/dub-conversions"
+ target="_blank"
+ className="underline transition-colors duration-75 hover:text-neutral-700"
+ >
+ Learn more
+ </Link>
+ </p>
+ <Link
+ href={`/${slug}/upgrade`}
+ className={cn(
+ buttonVariants({ variant: "primary" }),
+ "mt-4 flex h-8 items-center justify-center whitespace-nowrap rounded-lg border px-3 text-sm",
+ )}
+ >
+ Upgrade to Business
+ </Link>
</div>
</div>
);