From b6afc90485092d644c014a56aa40f54e9f51456b Mon Sep 17 00:00:00 2001 From: Jonas Daniels Date: Wed, 21 May 2025 14:26:40 -0700 Subject: [PATCH] Remove unused account usage API and interface --- .../src/@3rdweb-sdk/react/hooks/useApi.ts | 21 --------------- .../(team)/~/usage/getAccountUsage.ts | 26 ------------------- .../~/usage/overview/components/Usage.tsx | 22 +++++----------- .../team/[team_slug]/(team)/~/usage/page.tsx | 8 ++---- 4 files changed, 9 insertions(+), 68 deletions(-) delete mode 100644 apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/usage/getAccountUsage.ts diff --git a/apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts b/apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts index b74242a563b..77bea2b2855 100644 --- a/apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts +++ b/apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts @@ -53,27 +53,6 @@ interface ConfirmEmailInput { confirmationToken: string; } -interface UsageStorage { - sumFileSizeBytes: number; -} - -export interface UsageBillableByService { - usage: { - storage: UsageStorage; - }; - limits: { - storage: number; - }; - rateLimits: { - storage: number; - rpc: number; - }; - rateLimitedAt: { - storage?: string; - rpc?: string; - }; -} - interface BillingProduct { name: string; id: string; diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/usage/getAccountUsage.ts b/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/usage/getAccountUsage.ts deleted file mode 100644 index ebbf1a03177..00000000000 --- a/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/usage/getAccountUsage.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { NEXT_PUBLIC_THIRDWEB_API_HOST } from "@/constants/public-envs"; -import type { UsageBillableByService } from "@3rdweb-sdk/react/hooks/useApi"; -import { getAuthToken } from "../../../../../api/lib/getAuthToken"; - -export async function getAccountUsage() { - const token = await getAuthToken(); - - if (!token) { - return undefined; - } - - const res = await fetch(`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/account/usage`, { - method: "GET", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${token}`, - }, - }); - - if (!res.ok) { - return undefined; - } - - const json = await res.json(); - return json.data as UsageBillableByService; -} diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/usage/overview/components/Usage.tsx b/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/usage/overview/components/Usage.tsx index c31345b042b..7a0432b8f62 100644 --- a/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/usage/overview/components/Usage.tsx +++ b/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/usage/overview/components/Usage.tsx @@ -4,10 +4,7 @@ import type { TeamSubscription } from "@/api/team-subscription"; import type { RPCUsageDataItem } from "@/api/usage/rpc"; import { ThirdwebBarChart } from "@/components/blocks/charts/bar-chart"; import { Button } from "@/components/ui/button"; -import type { - Account, - UsageBillableByService, -} from "@3rdweb-sdk/react/hooks/useApi"; +import type { Account } from "@3rdweb-sdk/react/hooks/useApi"; import { InAppWalletUsersChartCardUI } from "components/embedded-wallets/Analytics/InAppWalletUsersChartCard"; import { subMonths } from "date-fns"; import Link from "next/link"; @@ -18,8 +15,6 @@ import { SponsoredTransactionsTable } from "./SponsoredTransactionsTable"; import { UsageCard } from "./UsageCard"; type UsageProps = { - // TODO - remove when we have all the data available from team - usage: UsageBillableByService; subscriptions: TeamSubscription[]; account: Account; team: Team; @@ -39,7 +34,6 @@ const compactNumberFormatter = new Intl.NumberFormat("en-US", { }); export const Usage: React.FC = ({ - usage: usageData, subscriptions, account, team, @@ -48,20 +42,18 @@ export const Usage: React.FC = ({ rpcUsage, }) => { const gatewayMetrics = useMemo(() => { - if (!usageData) { - return {}; - } - return { title: "Unlimited Requests", total: ( - {compactNumberFormatter.format(usageData.rateLimits.storage)} Requests - Per Second + {compactNumberFormatter.format( + team.capabilities.storage.upload.rateLimit, + )}{" "} + Requests Per Second ), }; - }, [usageData]); + }, [team.capabilities.storage.upload.rateLimit]); const usageSub = subscriptions.find((sub) => sub.type === "USAGE"); @@ -138,7 +130,7 @@ export const Usage: React.FC = ({ Something went wrong. Please try again later. @@ -63,8 +61,6 @@ export default async function Page(props: { return (