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.

fixed bugs, nav tabs

Steven Teyb7ad8b8cf4a2
diff --git a/apps/web/lib/stats.ts b/apps/web/lib/stats.ts
index 8571eae93d..7e4b56c578 100644
--- a/apps/web/lib/stats.ts
+++ b/apps/web/lib/stats.ts
@@ -120,7 +120,9 @@ export const getStats = async ({
`https://api.us-east.tinybird.co/v0/pipes/${endpoint}_new.json`,
);
url.searchParams.append("domain", domain);
- url.searchParams.append("key", decodeURIComponent(key));
+ if (key) {
+ url.searchParams.append("key", decodeURIComponent(key));
+ }
if (interval) {
url.searchParams.append(
diff --git a/apps/web/ui/domains/domain-card.tsx b/apps/web/ui/domains/domain-card.tsx
index 6299f940f1..913b1dc714 100644
--- a/apps/web/ui/domains/domain-card.tsx
+++ b/apps/web/ui/domains/domain-card.tsx
@@ -61,7 +61,7 @@ export default function DomainCard({ props }: { props: DomainProps }) {
</a>
<NumberTooltip value={clicks}>
<Link
- href={`/${slug}/analytics?domain=${domain}`}
+ href={`/${slug}/analytics?domain=${domain}&key=_root`}
className="flex items-center space-x-1 rounded-md bg-gray-100 px-2 py-0.5 transition-all duration-75 hover:scale-105 active:scale-100"
>
<Chart className="h-4 w-4" />
diff --git a/apps/web/ui/layout/nav-tabs.tsx b/apps/web/ui/layout/nav-tabs.tsx
index 6d9b099b0d..11f2a9e90c 100644
--- a/apps/web/ui/layout/nav-tabs.tsx
+++ b/apps/web/ui/layout/nav-tabs.tsx
@@ -18,29 +18,14 @@ export default function NavTabs() {
const { loading, error } = useProject();
const tabs = useMemo(() => {
- const isDomainAnalytics =
- searchParams?.get("domain") && !searchParams?.get("key");
-
if (slug) {
- if (pathname?.endsWith("/analytics")) {
- return [
- {
- name: `← Back to all ${isDomainAnalytics ? "domains" : "links"}`,
- href: isDomainAnalytics ? `/${slug}/domains` : `/${slug}`,
- },
- ];
- }
return [
{ name: "Links", href: `/${slug}` },
- // { name: "Analytics", href: `/${slug}/analytics` },
+ { name: "Analytics", href: `/${slug}/analytics` },
{ name: "Domains", href: `/${slug}/domains` },
{ name: "Settings", href: `/${slug}/settings` },
];
}
- // home page (e.g. app.dub.co, app.dub.co/settings)
- if (pathname?.endsWith("/analytics")) {
- return [{ name: "← Back to all links", href: "/links" }];
- }
return [
{ name: "Projects", href: "/" },
{ name: "Dub.sh Links", href: "/links" },
diff --git a/apps/web/ui/stats/bar-list.tsx b/apps/web/ui/stats/bar-list.tsx
index e77842a8ab..7bb2d71431 100644
--- a/apps/web/ui/stats/bar-list.tsx
+++ b/apps/web/ui/stats/bar-list.tsx
@@ -6,13 +6,14 @@ import { motion } from "framer-motion";
import Fuse from "fuse.js";
import { Search } from "lucide-react";
import Link from "next/link";
-import { ReactNode, useMemo, useState } from "react";
+import { Dispatch, ReactNode, SetStateAction, useMemo, useState } from "react";
export default function BarList({
tab,
data,
barBackground,
totalClicks,
+ setShowModal,
limit,
}: {
tab: string;
@@ -24,6 +25,7 @@ export default function BarList({
}[];
totalClicks: number;
barBackground: string;
+ setShowModal: Dispatch<SetStateAction<boolean>>;
limit?: number;
}) {
const [search, setSearch] = useState("");
@@ -83,7 +85,12 @@ export default function BarList({
if (href) {
return (
- <Link key={idx} href={href} replace scroll={false}>
+ <Link
+ key={idx}
+ href={href}
+ scroll={false}
+ onClick={() => setShowModal(false)}
+ >
{bar}
</Link>
);
diff --git a/apps/web/ui/stats/devices.tsx b/apps/web/ui/stats/devices.tsx
index 257cc2e823..b092753594 100644
--- a/apps/web/ui/stats/devices.tsx
+++ b/apps/web/ui/stats/devices.tsx
@@ -34,6 +34,7 @@ export default function Devices() {
}
totalClicks={totalClicks || 0}
barBackground="bg-green-100"
+ setShowModal={setShowModal}
{...(limit && { limit })}
/>
);
diff --git a/apps/web/ui/stats/index.tsx b/apps/web/ui/stats/index.tsx
index 28129cb578..2b2d2a795b 100644
--- a/apps/web/ui/stats/index.tsx
+++ b/apps/web/ui/stats/index.tsx
@@ -55,11 +55,12 @@ export default function Stats({
const pathname = usePathname();
const router = useRouter();
- let { slug, key = "_root" } = useParams() as {
+ let { slug, key } = useParams() as {
slug?: string;
key?: string;
};
const domainSlug = searchParams?.get("domain");
+ // key can be a path param (public stats pages) or a query param (stats pages in app)
key = searchParams?.get("key") || key;
const interval = searchParams?.get("interval") || "24h";
diff --git a/apps/web/ui/stats/locations.tsx b/apps/web/ui/stats/locations.tsx
index a8e810bf67..c9e8f7cc4b 100644
--- a/apps/web/ui/stats/locations.tsx
+++ b/apps/web/ui/stats/locations.tsx
@@ -38,6 +38,7 @@ export default function Locations() {
}
totalClicks={totalClicks || 0}
barBackground="bg-orange-100"
+ setShowModal={setShowModal}
{...(limit && { limit })}
/>
);
diff --git a/apps/web/ui/stats/referer.tsx b/apps/web/ui/stats/referer.tsx
index cd90d96387..68fdba77ec 100644
--- a/apps/web/ui/stats/referer.tsx
+++ b/apps/web/ui/stats/referer.tsx
@@ -41,6 +41,7 @@ export default function Referer() {
}
totalClicks={totalClicks || 0}
barBackground="bg-red-100"
+ setShowModal={setShowModal}
{...(limit && { limit })}
/>
);
diff --git a/apps/web/ui/stats/toggle.tsx b/apps/web/ui/stats/toggle.tsx
index adb2e40e2d..848c9c18ba 100644
--- a/apps/web/ui/stats/toggle.tsx
+++ b/apps/web/ui/stats/toggle.tsx
@@ -118,7 +118,6 @@ export default function Toggle() {
interval: value,
}).toString()}`
}`}
- replace
scroll={false}
className="flex w-full items-center justify-between space-x-2 rounded-md p-2 hover:bg-gray-100 active:bg-gray-200"
>
diff --git a/apps/web/ui/stats/top-links.tsx b/apps/web/ui/stats/top-links.tsx
index 5bf839322d..88086346af 100644
--- a/apps/web/ui/stats/top-links.tsx
+++ b/apps/web/ui/stats/top-links.tsx
@@ -38,6 +38,7 @@ export default function TopLinks() {
}
totalClicks={totalClicks || 0}
barBackground="bg-blue-100"
+ setShowModal={setShowModal}
{...(limit && { limit })}
/>
);