feat(ST-vmc7vpps): insights page — TokenUsageCard integreren

Voeg getTokenStats + TokenUsageCard imports toe aan insights/page.tsx.
tokenStats apart awaiten na activeSprints (kan niet in dezelfde Promise.all).
TokenUsageCard-sectie toegevoegd na AgentThroughputCard.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scrum4Me Agent 2026-05-06 03:15:24 +02:00
parent a09f3b0604
commit 974889f9de

View file

@ -7,6 +7,7 @@ import { getBurndownData } from '@/lib/insights/burndown'
import { getSprintStatusBreakdown } from '@/lib/insights/sprint-status'
import { getVerifyResultStats, getAlignmentTrend } from '@/lib/insights/verify-stats'
import { getJobsPerDay } from '@/lib/insights/agent-throughput'
import { getTokenStats } from '@/lib/insights/token-stats'
import { getVelocity } from '@/lib/insights/velocity'
import { getBacklogHealth } from '@/lib/insights/backlog-health'
import { SprintInfoStrip } from './components/sprint-info-strip'
@ -15,6 +16,7 @@ import { SprintStatusDonut } from './components/sprint-status-donut'
import { PlanQualityCard } from './components/plan-quality'
import { AlignmentTrend } from './components/alignment-trend'
import { AgentThroughputCard } from './components/agent-throughput'
import { TokenUsageCard } from './components/token-usage'
import { VelocityChart } from './components/velocity-chart'
import { BacklogHealthCard } from './components/backlog-health'
@ -76,6 +78,11 @@ export default async function InsightsPage({ searchParams }: InsightsPageProps)
getBacklogHealth(userId),
])
const activeSprintId = activeSprints.find(s => s.product.id === filterProductId)?.id ?? ''
const tokenStats = await (activeSprints.length > 0 && filterProductId
? getTokenStats(userId, activeSprintId)
: Promise.resolve({ kpi: { totalTokens: 0, totalCostUsd: 0, avgCostPerJob: 0, jobCount: 0 }, jobs: [] }))
// Date.now is an impure call but used once per request — safe in a Server Component.
// eslint-disable-next-line react-hooks/purity
const nowMs = Date.now()
@ -142,6 +149,12 @@ export default async function InsightsPage({ searchParams }: InsightsPageProps)
/>
</section>
{/* Token usage */}
<section className="space-y-3">
<h2 className="text-lg font-medium text-foreground">Token gebruik</h2>
<TokenUsageCard kpi={tokenStats.kpi} jobs={tokenStats.jobs} />
</section>
{/* Velocity */}
<section className="space-y-3">
<h2 className="text-lg font-medium text-foreground">Velocity</h2>