Skip to content

Commit d34357e

Browse files
committed
[Dashboard] Fix: Cleanup dashboard UI (#5344)
CNCT-2282 <!-- start pr-codex --> --- ## PR-Codex overview This PR primarily focuses on refactoring components related to analytics and charts in the dashboard, removing unused components, improving data handling, and enhancing UI elements for better responsiveness and clarity. ### Detailed summary - Deleted `ConnectSDKCard.tsx` and `ConnectAnalyticsDashboard.tsx` files. - Removed the `Analytics` link from the sidebar. - Enhanced `PieChartCard` and `BarChart` components with better data mapping and UI adjustments. - Updated `RangeSelector` to handle local state for range and interval. - Removed unused API functions related to wallet usage. - Improved data filtering logic in `WalletDistributionCard` and `AuthMethodDistributionCard`. - Adjusted image rendering for better layout consistency in charts. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 03ce881 commit d34357e

File tree

11 files changed

+102
-370
lines changed

11 files changed

+102
-370
lines changed

apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts

Lines changed: 0 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -380,43 +380,6 @@ export function useAccountCredits() {
380380
});
381381
}
382382

383-
async function getWalletUsage(args: {
384-
clientId: string;
385-
from?: Date;
386-
to?: Date;
387-
period?: "day" | "week" | "month" | "year" | "all";
388-
}) {
389-
const { clientId, from, to, period } = args;
390-
391-
const searchParams = new URLSearchParams();
392-
searchParams.append("clientId", clientId);
393-
if (from) {
394-
searchParams.append("from", from.toISOString());
395-
}
396-
if (to) {
397-
searchParams.append("to", to.toISOString());
398-
}
399-
if (period) {
400-
searchParams.append("period", period);
401-
}
402-
const res = await fetch(
403-
`${THIRDWEB_ANALYTICS_API_HOST}/v1/wallets?${searchParams.toString()}`,
404-
{
405-
method: "GET",
406-
headers: {
407-
"Content-Type": "application/json",
408-
},
409-
},
410-
);
411-
const json = await res.json();
412-
413-
if (res.status !== 200) {
414-
throw new Error(json.message);
415-
}
416-
417-
return json.data;
418-
}
419-
420383
async function getUserOpUsage(args: {
421384
clientId: string;
422385
from?: Date;
@@ -454,43 +417,6 @@ async function getUserOpUsage(args: {
454417
return json.data;
455418
}
456419

457-
export async function getInAppWalletUsage(args: {
458-
clientId: string;
459-
from?: Date;
460-
to?: Date;
461-
period?: "day" | "week" | "month" | "year" | "all";
462-
}) {
463-
const { clientId, from, to, period } = args;
464-
465-
const searchParams = new URLSearchParams();
466-
searchParams.append("clientId", clientId);
467-
if (from) {
468-
searchParams.append("from", from.toISOString());
469-
}
470-
if (to) {
471-
searchParams.append("to", to.toISOString());
472-
}
473-
if (period) {
474-
searchParams.append("period", period);
475-
}
476-
const res = await fetch(
477-
`${THIRDWEB_ANALYTICS_API_HOST}/v1/wallets/in-app?${searchParams.toString()}`,
478-
{
479-
method: "GET",
480-
headers: {
481-
"Content-Type": "application/json",
482-
},
483-
},
484-
);
485-
const json = await res?.json();
486-
487-
if (!res || res.status !== 200) {
488-
throw new Error(json.message);
489-
}
490-
491-
return json.data;
492-
}
493-
494420
export function useUserOpUsageAggregate(args: {
495421
clientId: string;
496422
from?: Date;
@@ -574,63 +500,6 @@ export function useUserOpUsagePeriod(args: {
574500
});
575501
}
576502

577-
export function useWalletUsageAggregate(args: {
578-
clientId: string;
579-
from?: Date;
580-
to?: Date;
581-
}) {
582-
const { clientId, from, to } = args;
583-
const { user, isLoggedIn } = useLoggedInUser();
584-
585-
return useQuery({
586-
queryKey: accountKeys.walletStats(
587-
user?.address as string,
588-
clientId as string,
589-
from?.toISOString() || "",
590-
to?.toISOString() || "",
591-
"all",
592-
),
593-
queryFn: async () => {
594-
return getWalletUsage({
595-
clientId,
596-
from,
597-
to,
598-
period: "all",
599-
});
600-
},
601-
enabled: !!clientId && !!user?.address && isLoggedIn,
602-
});
603-
}
604-
605-
export function useWalletUsagePeriod(args: {
606-
clientId: string;
607-
from?: Date;
608-
to?: Date;
609-
period: "day" | "week" | "month" | "year";
610-
}) {
611-
const { clientId, from, to, period } = args;
612-
const { user, isLoggedIn } = useLoggedInUser();
613-
614-
return useQuery({
615-
queryKey: accountKeys.walletStats(
616-
user?.address as string,
617-
clientId as string,
618-
from?.toISOString() || "",
619-
to?.toISOString() || "",
620-
period,
621-
),
622-
queryFn: async () => {
623-
return getWalletUsage({
624-
clientId,
625-
from,
626-
to,
627-
period,
628-
});
629-
},
630-
enabled: !!clientId && !!user?.address && isLoggedIn,
631-
});
632-
}
633-
634503
export function useUpdateAccount() {
635504
const { user } = useLoggedInUser();
636505
const queryClient = useQueryClient();

apps/dashboard/src/app/team/[team_slug]/[project_slug]/components/BarChart.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function BarChart({
5959
}}
6060
/>
6161
<YAxis
62-
width={32}
62+
width={48}
6363
dataKey={activeKey}
6464
tickLine={false}
6565
axisLine={false}
@@ -68,7 +68,7 @@ export function BarChart({
6868
<ChartTooltip
6969
content={
7070
<ChartTooltipContent
71-
className="w-[150px]"
71+
className="w-[200px]"
7272
nameKey={activeKey}
7373
labelFormatter={(value) => {
7474
return new Date(value).toLocaleDateString("en-US", {
@@ -77,6 +77,7 @@ export function BarChart({
7777
year: "numeric",
7878
});
7979
}}
80+
valueFormatter={(v: unknown) => formatTickerNumber(v as number)}
8081
/>
8182
}
8283
/>

apps/dashboard/src/app/team/[team_slug]/[project_slug]/components/CombinedBarChartCard.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export function CombinedBarChartCard<
5353
usersChart: key,
5454
},
5555
}}
56+
prefetch
5657
scroll={false}
5758
key={chart}
5859
data-active={activeChart === chart}

apps/dashboard/src/app/team/[team_slug]/[project_slug]/components/PieChart.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
ChartTooltip,
77
ChartTooltipContent,
88
} from "@/components/ui/chart";
9+
import { formatTickerNumber } from "lib/format-utils";
910
import { Pie, PieChart as RechartsPieChart } from "recharts";
1011

1112
export function PieChart({
@@ -39,7 +40,12 @@ export function PieChart({
3940
<RechartsPieChart>
4041
<ChartTooltip
4142
cursor={false}
42-
content={<ChartTooltipContent hideLabel />}
43+
content={
44+
<ChartTooltipContent
45+
hideLabel
46+
valueFormatter={(v: unknown) => formatTickerNumber(v as number)}
47+
/>
48+
}
4349
/>
4450
<Pie data={data} dataKey="value" nameKey="label" innerRadius={60} />
4551
</RechartsPieChart>

apps/dashboard/src/app/team/[team_slug]/[project_slug]/components/PieChartCard.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export function PieChartCard({
2828
const sorted = [...data].sort((a, b) => b.value - a.value);
2929

3030
// Take top 9
31-
const top10 = sorted.slice(0, 9);
31+
const top10 = sorted.slice(0, 9).map((item) => ({
32+
...item,
33+
}));
3234

3335
// Aggregate the rest
3436
const otherValue = sorted
@@ -44,7 +46,11 @@ export function PieChartCard({
4446
}
4547

4648
return top10;
47-
})();
49+
})().map((item, index) => ({
50+
...item,
51+
fill: item.fill || `hsl(var(--chart-${index + 1}))`,
52+
}));
53+
4854
return (
4955
<Card className="flex flex-col">
5056
<CardHeader className="border-border border-b p-0">

apps/dashboard/src/app/team/[team_slug]/[project_slug]/connect/analytics/ConnectAnalyticsDashboard.tsx

Lines changed: 0 additions & 87 deletions
This file was deleted.

apps/dashboard/src/app/team/[team_slug]/[project_slug]/connect/layout.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ export default async function Layout(props: {
1212
const { team_slug, project_slug } = await props.params;
1313

1414
const links: SidebarLink[] = [
15-
{
16-
label: "Analytics",
17-
href: `/team/${team_slug}/${project_slug}/connect`,
18-
exactMatch: true,
19-
},
2015
{
2116
label: "In-App Wallets",
2217
href: `/team/${team_slug}/${project_slug}/connect/in-app-wallets`,
Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { getProject } from "@/api/projects";
2-
import { ConnectSDKCard } from "components/shared/ConnectSDKCard";
3-
import { notFound } from "next/navigation";
4-
import { ConnectAnalyticsDashboard } from "./analytics/ConnectAnalyticsDashboard";
2+
import { notFound, redirect } from "next/navigation";
53

64
export default async function Page(props: {
75
params: Promise<{
@@ -16,23 +14,7 @@ export default async function Page(props: {
1614
notFound();
1715
}
1816

19-
return (
20-
<div>
21-
<div>
22-
<h1 className="mb-1 font-semibold text-2xl tracking-tight md:text-3xl">
23-
Connect Analytics
24-
</h1>
25-
<p className="text-muted-foreground text-sm md:text-base">
26-
Visualize how your users are connecting to your app
27-
</p>
28-
</div>
29-
<div className="h-6 lg:h-8" />
30-
<ConnectAnalyticsDashboard
31-
clientId={project.publishableKey}
32-
connectLayoutSlug={`/team/${params.team_slug}/${params.project_slug}/connect`}
33-
/>
34-
<div className="h-4 lg:h-8" />
35-
<ConnectSDKCard description="Add the Connect SDK to your app to get started collecting analytics." />
36-
</div>
17+
redirect(
18+
`/team/${params.team_slug}/${params.project_slug}/connect/in-app-wallets`,
3719
);
3820
}

0 commit comments

Comments
 (0)