Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DASH-643] Improve Project overview page load perf #5774

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 94 additions & 71 deletions apps/dashboard/src/app/team/[team_slug]/[project_slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type Project, getProject } from "@/api/projects";
import { GenericLoadingPage } from "@/components/blocks/skeletons/GenericLoadingPage";
import { notFound } from "next/navigation";

import { getProject } from "@/api/projects";

import {
type DurationId,
type Range,
Expand All @@ -22,6 +22,7 @@ import {
isProjectActive,
} from "@/api/analytics";
import { EmptyStateCard } from "app/team/components/Analytics/EmptyStateCard";
import { Suspense } from "react";
import {
type ChainMetadata,
defineChain,
Expand Down Expand Up @@ -69,6 +70,43 @@ export default async function ProjectOverviewPage(props: PageProps) {

const isActive = await isProjectActive({ clientId: project.publishableKey });

return (
<div className="flex grow flex-col">
<div className="w-full border-border border-b">
<AnalyticsHeader
title={project.name}
interval={interval}
range={range}
/>
</div>
{!isActive ? (
<div className="container p-6">
<EmptyState />
</div>
) : (
<div className="container flex grow flex-col py-6">
<Suspense fallback={<GenericLoadingPage />}>
<ProjectAnalytics
project={project}
range={range}
interval={interval}
searchParams={searchParams}
/>
</Suspense>
</div>
)}
</div>
);
}

async function ProjectAnalytics(props: {
project: Project;
range: Range;
interval: "day" | "week";
searchParams: PageSearchParams;
}) {
const { project, range, interval, searchParams } = props;

// Fetch all analytics data in parallel
const [
walletConnections,
Expand Down Expand Up @@ -114,79 +152,64 @@ export default async function ProjectOverviewPage(props: PageProps) {
]);

return (
<div className="md:pb-16">
<div className="w-full border-border-800 border-b px-6 dark:bg-muted/50">
<AnalyticsHeader
title={project.name}
interval={interval}
range={range}
/>
</div>
{!isActive ? (
<div className="container p-6">
<EmptyState />
<div className="flex grow flex-col gap-6">
{walletUserStatsTimeSeries.some((w) => w.totalUsers !== 0) ? (
<div className="">
<UsersChartCard
chartKey={
(searchParams.usersChart as
| "totalUsers"
| "activeUsers"
| "newUsers"
| "returningUsers") ?? "activeUsers"
}
userStats={walletUserStatsTimeSeries}
searchParams={searchParams}
/>
</div>
) : (
<div className="space-y-6 md:container md:p-6">
{walletUserStatsTimeSeries.some((w) => w.totalUsers !== 0) ? (
<div className="">
<UsersChartCard
chartKey={
(searchParams.usersChart as
| "totalUsers"
| "activeUsers"
| "newUsers"
| "returningUsers") ?? "activeUsers"
}
userStats={walletUserStatsTimeSeries}
searchParams={searchParams}
/>
</div>
) : (
<EmptyStateCard
metric="Connect"
link="https://portal.thirdweb.com/connect/quickstart"
/>
)}
<RpcMethodBarChartCard
from={range.from}
to={range.to}
period={interval}
clientId={project.publishableKey}
<EmptyStateCard
metric="Connect"
link="https://portal.thirdweb.com/connect/quickstart"
/>
)}
<RpcMethodBarChartCard
from={range.from}
to={range.to}
period={interval}
clientId={project.publishableKey}
/>
<div className="grid gap-6 max-md:px-6 md:grid-cols-2">
{walletConnections.length > 0 ? (
<WalletDistributionCard data={walletConnections} />
) : (
<EmptyStateCard
metric="Connect"
link="https://portal.thirdweb.com/connect/quickstart"
/>
)}
{inAppWalletUsage.length > 0 ? (
<AuthMethodDistributionCard data={inAppWalletUsage} />
) : (
<EmptyStateCard
metric="In-App Wallets"
link="https://portal.thirdweb.com/typescript/v5/inAppWallet"
/>
)}
</div>
{userOpUsage.length > 0 ? (
<div className="">
<TotalSponsoredCard
searchParams={searchParams}
data={userOpUsageTimeSeries}
aggregatedData={userOpUsage}
/>
<div className="grid gap-6 max-md:px-6 md:grid-cols-2">
{walletConnections.length > 0 ? (
<WalletDistributionCard data={walletConnections} />
) : (
<EmptyStateCard
metric="Connect"
link="https://portal.thirdweb.com/connect/quickstart"
/>
)}
{inAppWalletUsage.length > 0 ? (
<AuthMethodDistributionCard data={inAppWalletUsage} />
) : (
<EmptyStateCard
metric="In-App Wallets"
link="https://portal.thirdweb.com/typescript/v5/inAppWallet"
/>
)}
</div>
{userOpUsage.length > 0 ? (
<div className="">
<TotalSponsoredCard
searchParams={searchParams}
data={userOpUsageTimeSeries}
aggregatedData={userOpUsage}
/>
</div>
) : (
<EmptyStateCard
metric="Sponsored Transactions"
link="https://portal.thirdweb.com/typescript/v5/account-abstraction/get-started"
/>
)}
</div>
) : (
<EmptyStateCard
metric="Sponsored Transactions"
link="https://portal.thirdweb.com/typescript/v5/account-abstraction/get-started"
/>
)}
</div>
);
Expand Down
Loading