Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Fix chart of usage costs by using the right usage property

Vasek Mlejnskya29a6b27fd38
diff --git a/apps/docs/src/app/(dashboard)/dashboard/page.tsx b/apps/docs/src/app/(dashboard)/dashboard/page.tsx
index 382334e17..e07707fc8 100644
--- a/apps/docs/src/app/(dashboard)/dashboard/page.tsx
+++ b/apps/docs/src/app/(dashboard)/dashboard/page.tsx
@@ -171,7 +171,16 @@ const MenuItem = ({ icon: Icon, label, selected, onClick }: { icon: LucideIcon;
)
-const MainContent = ({ selectedItem, user, team, accessToken, currentApiKey, teams, setTeams, setCurrentTeam }: { selectedItem: MenuLabel, user: User, team: Team, accessToken: string, currentApiKey: string | null, teams: Team[], setTeams: (teams: Team[]) => void, setCurrentTeam: (team: Team) => void }) => {
+function MainContent({ selectedItem, user, team, accessToken, currentApiKey, teams, setTeams, setCurrentTeam }: {
+ selectedItem: MenuLabel,
+ user: User,
+ team: Team,
+ accessToken: string,
+ currentApiKey: string | null,
+ teams: Team[],
+ setTeams: (teams: Team[]) => void,
+ setCurrentTeam: (team: Team) => void
+}) {
switch (selectedItem) {
case 'personal':
return <PersonalContent user={user} accessToken={accessToken} />
diff --git a/apps/docs/src/components/Dashboard/Usage.tsx b/apps/docs/src/components/Dashboard/Usage.tsx
index 8aa70a608..227eeafaf 100644
--- a/apps/docs/src/components/Dashboard/Usage.tsx
+++ b/apps/docs/src/components/Dashboard/Usage.tsx
@@ -15,7 +15,7 @@ const usageUrl = `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/usage`
export const UsageContent = ({ currentApiKey }: { currentApiKey: string | null }) => {
const [vcpuData, setVcpuData] = useState<any>(null)
const [ramData, setRamData] = useState<any>(null)
- const [ costUsage, setUsage ] = useState<Usage[]>([])
+ const [costUsage, setUsage] = useState<Usage[]>([])
useEffect(() => {
const getUsage = async (apiKey: string) => {
@@ -31,8 +31,8 @@ export const UsageContent = ({ currentApiKey }: { currentApiKey: string | null }
if (!response.ok) {
// TODO: Add sentry event here
toast({
- title: 'An error occurred',
- description: 'We were unable to fetch the usage data',
+ title: 'An error occurred',
+ description: 'We were unable to fetch the usage data',
})
console.log(response)
return
@@ -106,7 +106,7 @@ const transformCostData = (usage: any) => {
return {
x: `${String(usage.month).padStart(2, '0')}/${usage.year}`,
y: usage.template_usage.length > 0
- ? usage.template_usage.reduce((acc: number, template: any) => acc + template.ram_gb_hours, 0)
+ ? usage.template_usage.reduce((acc: number, template: any) => acc + template.total_cost, 0)
: 0,
}
})