import type { Metadata } from 'next'; import Link from 'next/link'; import { AdminError, AdminHeader, SectionTitle, Tile, fmtBytes } from '@/components/admin/ui'; import { fmtDuration } from '@/components/meta/connectors-table'; import { adminApi, safeAdmin } from '@/lib/admin-api'; import { fmtDate, fmtInt, num } from '@/lib/format'; export const metadata: Metadata = { title: 'Costs' }; export default async function AdminCostsPage() { const res = await safeAdmin(adminApi.costs()); if (res.error !== null) { return ( <> ); } const d = res.data.data; const totalRuns = d.per_connector.reduce((a, c) => a + (num(c.runs_30d) ?? 0), 0); const totalMs = d.per_connector.reduce((a, c) => a + (num(c.total_ms) ?? 0), 0); const totalFailed = d.per_connector.reduce((a, c) => a + (num(c.failed) ?? 0), 0); return ( <>
0 ? 'warn' : undefined} />
Per connector · last 30 days {d.per_connector.length === 0 ? (

No runs in the last 30 days

) : (
{d.per_connector.map((c) => { const runs = num(c.runs_30d) ?? 0; const ms = num(c.total_ms) ?? 0; const failed = num(c.failed) ?? 0; return ( ); })}
Connector Runs Records Total time Avg / run Failed
{c.connector_name} {fmtInt(runs)} {fmtInt(c.records)} {fmtDuration(ms)} {runs > 0 ? fmtDuration(ms / runs) : '—'} 0 ? 'text-warn' : 'text-ink-2'}`}> {fmtInt(failed)}
)} Storage
Raw snapshot growth · 30 days {d.raw_growth.length === 0 ? (

No snapshots in the last 30 days

) : (
{d.raw_growth.map((g) => ( ))}
Day Snapshots Bytes
{fmtDate(g.day)} {fmtInt(g.snapshots)} {fmtBytes(g.bytes)}
)} Paid providers
    {Object.entries(d.paid_providers).map(([k, v]) => (
  • {k} {v}
  • ))}
); }