Skip to content

Remove unused account usage API and interface #7117

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

Merged
merged 1 commit into from
May 21, 2025
Merged
Show file tree
Hide file tree
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
21 changes: 0 additions & 21 deletions apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
Expand All @@ -39,7 +34,6 @@ const compactNumberFormatter = new Intl.NumberFormat("en-US", {
});

export const Usage: React.FC<UsageProps> = ({
usage: usageData,
subscriptions,
account,
team,
Expand All @@ -48,20 +42,18 @@ export const Usage: React.FC<UsageProps> = ({
rpcUsage,
}) => {
const gatewayMetrics = useMemo(() => {
if (!usageData) {
return {};
}

return {
title: "Unlimited Requests",
total: (
<span className="text-muted-foreground">
{compactNumberFormatter.format(usageData.rateLimits.storage)} Requests
Per Second
{compactNumberFormatter.format(
team.capabilities.storage.upload.rateLimit,
)}{" "}
Requests Per Second
</span>
),
};
}, [usageData]);
}, [team.capabilities.storage.upload.rateLimit]);

const usageSub = subscriptions.find((sub) => sub.type === "USAGE");

Expand Down Expand Up @@ -138,7 +130,7 @@ export const Usage: React.FC<UsageProps> = ({
<ThirdwebBarChart
header={{
title: "RPC Requests",
description: `Your plan allows for ${usageData.rateLimits.rpc} requests per second`,
description: `Your plan allows for ${team.capabilities.rpc.rateLimit} requests per second`,
titleClassName: "text-xl mb-0.5",
}}
data={rpcUsageData}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { getClientThirdwebClient } from "../../../../../../../@/constants/thirdw
import { getValidAccount } from "../../../../../account/settings/getAccount";
import { getAuthToken } from "../../../../../api/lib/getAuthToken";
import { loginRedirect } from "../../../../../login/loginRedirect";
import { getAccountUsage } from "./getAccountUsage";
import { Usage } from "./overview/components/Usage";

export default async function Page(props: {
Expand All @@ -31,8 +30,7 @@ export default async function Page(props: {
loginRedirect(`/team/${params.team_slug}/~/usage`);
}

const [accountUsage, subscriptions, projects, rpcUsage] = await Promise.all([
getAccountUsage(),
const [subscriptions, projects, rpcUsage] = await Promise.all([
getTeamSubscriptions(team.slug),
getProjects(team.slug),
fetchRPCUsage({
Expand All @@ -48,7 +46,7 @@ export default async function Page(props: {
}),
]);

if (!accountUsage || !subscriptions) {
if (!subscriptions) {
return (
<div className="flex min-h-[350px] items-center justify-center rounded-lg border p-4 text-destructive-text">
Something went wrong. Please try again later.
Expand All @@ -63,8 +61,6 @@ export default async function Page(props: {

return (
<Usage
// TODO - remove accountUsage when we have all the data available from team
usage={accountUsage}
subscriptions={subscriptions}
account={account}
team={team}
Expand Down
Loading