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 analytics cards

Tim Wilsonc25bc593bde8
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/page-client.tsx
index c2463b680e..eafb53cebf 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/page-client.tsx
@@ -4,6 +4,11 @@ import { DUB_PARTNERS_ANALYTICS_INTERVAL } from "@/lib/analytics/constants";
import { AnalyticsSaleUnit, IntervalOptions } from "@/lib/analytics/types";
import { editQueryString } from "@/lib/analytics/utils";
import useWorkspace from "@/lib/swr/use-workspace";
+import { AnalyticsContext } from "@/ui/analytics/analytics-provider";
+import Devices from "@/ui/analytics/devices";
+import Locations from "@/ui/analytics/locations";
+import Referer from "@/ui/analytics/referer";
+import TopLinks from "@/ui/analytics/top-links";
import { useAnalyticsFilters } from "@/ui/analytics/use-analytics-filters";
import { useAnalyticsQuery } from "@/ui/analytics/use-analytics-query";
import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";
@@ -116,6 +121,26 @@ export function ProgramAnalyticsPageClient() {
</div>
</div>
</ProgramAnalyticsContext.Provider>
+ <AnalyticsContext.Provider
+ value={{
+ basePath: "",
+ baseApiPath: "/api/analytics",
+ selectedTab: event,
+ saleUnit,
+ view: "timeseries",
+ queryString,
+ start: start ? new Date(start) : undefined,
+ end: end ? new Date(end) : undefined,
+ interval,
+ }}
+ >
+ <div className="grid grid-cols-1 gap-5 md:grid-cols-2">
+ <TopLinks filterLinks={false} />
+ <Referer />
+ <Locations />
+ <Devices />
+ </div>
+ </AnalyticsContext.Provider>
</div>
);
}
diff --git a/apps/web/ui/analytics/top-links.tsx b/apps/web/ui/analytics/top-links.tsx
index ae50c9a91c..80c2df500b 100644
--- a/apps/web/ui/analytics/top-links.tsx
+++ b/apps/web/ui/analytics/top-links.tsx
@@ -9,7 +9,11 @@ import { AnalyticsContext } from "./analytics-provider";
import BarList from "./bar-list";
import { useAnalyticsFilterOption } from "./utils";
-export default function TopLinks() {
+export default function TopLinks({
+ filterLinks = true,
+}: {
+ filterLinks?: boolean;
+}) {
const { queryParams, searchParams } = useRouterStuff();
const { selectedTab, saleUnit } = useContext(AnalyticsContext);
@@ -66,23 +70,31 @@ export default function TopLinks() {
),
title: shortLinkTitle(d as any),
// TODO: simplify this once we switch from domain+key to linkId
- href: queryParams({
- ...((tab === "links" &&
- searchParams.has("domain") &&
- searchParams.has("key")) ||
- (tab === "urls" && searchParams.has("url"))
- ? { del: tab === "links" ? ["domain", "key"] : "url" }
- : {
- set: {
- ...(tab === "links"
- ? { domain: d.domain, key: d.key || "_root" }
- : {
- url: d.url,
- }),
- },
- }),
- getNewPath: true,
- }) as string,
+ href: filterLinks
+ ? (queryParams({
+ ...((tab === "links" &&
+ searchParams.has("domain") &&
+ searchParams.has("key")) ||
+ (tab === "urls" && searchParams.has("url"))
+ ? {
+ del:
+ tab === "links" ? ["domain", "key"] : "url",
+ }
+ : {
+ set: {
+ ...(tab === "links"
+ ? {
+ domain: d.domain,
+ key: d.key || "_root",
+ }
+ : {
+ url: d.url,
+ }),
+ },
+ }),
+ getNewPath: true,
+ }) as string)
+ : undefined,
value: d[dataKey] || 0,
...(tab === "links" && { linkData: d }),
}))