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.

Update events tab requirements and empty state

Tim Wilson828bf4f86b70
diff --git a/apps/web/app/api/analytics/events/export/route.ts b/apps/web/app/api/analytics/events/export/route.ts
index fb1995ec95..cc644362b1 100644
--- a/apps/web/app/api/analytics/events/export/route.ts
+++ b/apps/web/app/api/analytics/events/export/route.ts
@@ -96,6 +96,13 @@ export const GET = withWorkspace(
});
},
{
+ requiredPlan: [
+ "business",
+ "business plus",
+ "business extra",
+ "business max",
+ "enterprise",
+ ],
requiredPermissions: ["analytics.read"],
},
);
diff --git a/apps/web/app/api/analytics/events/route.ts b/apps/web/app/api/analytics/events/route.ts
index 3f3884376f..f543318ea9 100644
--- a/apps/web/app/api/analytics/events/route.ts
+++ b/apps/web/app/api/analytics/events/route.ts
@@ -50,7 +50,13 @@ export const GET = withWorkspace(
return NextResponse.json(response);
},
{
- featureFlag: "conversions",
+ requiredPlan: [
+ "business",
+ "business plus",
+ "business extra",
+ "business max",
+ "enterprise",
+ ],
requiredPermissions: ["analytics.read"],
},
);
diff --git a/apps/web/ui/analytics/events/empty-state.tsx b/apps/web/ui/analytics/events/empty-state.tsx
deleted file mode 100644
index b1948e1230..0000000000
--- a/apps/web/ui/analytics/events/empty-state.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import EmptyState from "@/ui/shared/empty-state";
-import { InvoiceDollar } from "@dub/ui/src/icons";
-
-export default function EventEmptyState() {
- return (
- <EmptyState
- icon={InvoiceDollar}
- title="Lead and sales analytics"
- description="Collect insights on lead generation and sales with metrics. Learn about top-converting leads and best-selling products."
- buttonText="Enable Sales Analytics"
- buttonLink="https://dub.co/docs"
- />
- );
-}
diff --git a/apps/web/ui/analytics/events/events-table.tsx b/apps/web/ui/analytics/events/events-table.tsx
index 987656e89a..95498f3374 100644
--- a/apps/web/ui/analytics/events/events-table.tsx
+++ b/apps/web/ui/analytics/events/events-table.tsx
@@ -1,19 +1,19 @@
"use client";
import { editQueryString } from "@/lib/analytics/utils";
+import useWorkspace from "@/lib/swr/use-workspace";
import { clickEventEnrichedSchema } from "@/lib/zod/schemas/clicks";
import { leadEventEnrichedSchema } from "@/lib/zod/schemas/leads";
import { saleEventEnrichedSchema } from "@/lib/zod/schemas/sales";
+import EmptyState from "@/ui/shared/empty-state";
+import { LinkLogo, Table, Tooltip, useRouterStuff, useTable } from "@dub/ui";
import {
CursorRays,
- LinkLogo,
+ FilterBars,
+ Magnifier,
+ Menu3,
QRCode,
- Table,
- Tooltip,
- useRouterStuff,
- useTable,
-} from "@dub/ui";
-import { FilterBars } from "@dub/ui/src/icons";
+} from "@dub/ui/src/icons";
import {
COUNTRIES,
capitalize,
@@ -29,7 +29,6 @@ import z from "zod";
import { AnalyticsContext } from "../analytics-provider";
import DeviceIcon from "../device-icon";
import EditColumnsButton from "./edit-columns-button";
-import EmptyState from "./empty-state";
import ExportButton from "./export-button";
import usePagination from "./use-pagination";
@@ -140,6 +139,7 @@ const FilterButton = ({ set }: { set: Record<string, any> }) => {
};
export default function EventsTable() {
+ const { id: workspaceId } = useWorkspace();
const { searchParams, queryParams } = useRouterStuff();
const tab = searchParams.get("tab") || "clicks";
@@ -410,13 +410,16 @@ export default function EventsTable() {
fetcher,
{
keepPreviousData: true,
+ shouldRetryOnError: (err) => !err?.message?.includes("Need higher plan"),
},
);
+ const needsHigherPlan = Boolean(error?.message?.includes("Need higher plan"));
+
const { table, ...tableProps } = useTable({
data: data ?? defaultData,
loading: isLoading,
- error: error ? "Failed to fetch events." : undefined,
+ error: error && !needsHigherPlan ? "Failed to fetch events." : undefined,
columns,
pagination,
onPaginationChange: setPagination,
@@ -441,7 +444,21 @@ export default function EventsTable() {
</>
);
},
- emptyState: <EmptyState />,
+ emptyState: needsHigherPlan ? (
+ <EmptyState
+ icon={Menu3}
+ title="Real-time Events Stream"
+ description={`Want more data on your ${tab === "clicks" ? "link clicks & QR code scans" : tab}? Upgrade to our Business Plan to get a detailed, real-time stream of events in your workspace.`}
+ buttonText="Upgrade to Business"
+ buttonLink={`/${workspaceId}/settings/billing?upgrade=business`}
+ />
+ ) : (
+ <EmptyState
+ icon={Magnifier}
+ title="No events recorded"
+ description="Events will appear here when your links are clicked."
+ />
+ ),
resourceName: (plural) => `event${plural ? "s" : ""}`,
});
diff --git a/apps/web/ui/analytics/events/index.tsx b/apps/web/ui/analytics/events/index.tsx
index b3437dd162..4d0a8cf247 100644
--- a/apps/web/ui/analytics/events/index.tsx
+++ b/apps/web/ui/analytics/events/index.tsx
@@ -2,7 +2,6 @@
import useWorkspace from "@/lib/swr/use-workspace";
import { useRouterStuff } from "@dub/ui";
-import { redirect } from "next/navigation";
import AnalyticsProvider from "../analytics-provider";
import Toggle from "../toggle";
import EventsTable from "./events-table";
@@ -23,10 +22,6 @@ export default function AnalyticsEvents({
const { searchParams } = useRouterStuff();
const tab = searchParams.get("tab");
- if (!flags?.conversions) {
- redirect(`/${slug}/analytics`);
- }
-
return (
<AnalyticsProvider
{...{ staticDomain, staticUrl, adminPage, demoPage }}
diff --git a/apps/web/ui/layout/nav-tabs.tsx b/apps/web/ui/layout/nav-tabs.tsx
index a2bded53e7..d4a325e54f 100644
--- a/apps/web/ui/layout/nav-tabs.tsx
+++ b/apps/web/ui/layout/nav-tabs.tsx
@@ -23,9 +23,7 @@ export default function NavTabs() {
() => [
{ name: "Links", href: `/${slug}` },
{ name: "Analytics", href: `/${slug}/analytics` },
- ...(flags?.conversions
- ? [{ name: "Events", href: `/${slug}/events` }]
- : []),
+ { name: "Events", href: `/${slug}/events` },
...(flags?.integrations
? [{ name: "Integrations", href: `/${slug}/integrations` }]
: []),
diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.ts
index 7e1f7d0a2f..1b0c6f6bfc 100644
--- a/packages/ui/src/icons/nucleo/index.ts
+++ b/packages/ui/src/icons/nucleo/index.ts
@@ -41,6 +41,7 @@ export * from "./invoice-dollar";
export * from "./key";
export * from "./lines-y";
export * from "./magnifier";
+export * from "./menu3";
export * from "./mobile-phone";
export * from "./office-building";
export * from "./page2";
diff --git a/packages/ui/src/icons/nucleo/menu3.tsx b/packages/ui/src/icons/nucleo/menu3.tsx
new file mode 100644
index 0000000000..0e691f6bcc
--- /dev/null
+++ b/packages/ui/src/icons/nucleo/menu3.tsx
@@ -0,0 +1,49 @@
+import { SVGProps } from "react";
+
+export function Menu3(props: SVGProps<SVGSVGElement>) {
+ return (
+ <svg
+ height="18"
+ width="18"
+ viewBox="0 0 18 18"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ >
+ <g fill="currentColor">
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="2.25"
+ x2="15.75"
+ y1="9"
+ y2="9"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="9.75"
+ x2="15.75"
+ y1="3.75"
+ y2="3.75"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="2.25"
+ x2="8.25"
+ y1="14.25"
+ y2="14.25"
+ />
+ </g>
+ </svg>
+ );
+}