Scrum4Me/app/(app)/insights/components
Janpeter Visser a1e6ec35e5
feat(PBI-78): cost-analysis widget on insights page (#187)
* feat(PBI-78): cost-analysis data layer (T-902)

- New lib/insights/cost-analysis.ts with 5 query functions:
  getCostKpi, getCostByDay, getCostByModel, getCostByKind, getCacheEfficiency
- Period type: 7d | 30d | 90d | mtd
- Cost formula reused from token-stats.ts (input + output + cache + thinking)
- Cache savings: cache_read_tokens × (input_price - cache_read_price) / 1M
- Plan: docs/plans/PBI-78-cost-analysis-widget.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(PBI-78): cost-analysis UI component (T-903)

- New app/(app)/insights/components/cost-analysis.tsx
- Period selector (7d/30d/90d/MTD) via URL ?period= with useTransition + router.replace
- KPI strip: total cost, avg per day, cache savings, top model
- 2x2 chart grid: daily cost (BarChart), per-model + per-kind (vertical BarCharts), cache efficiency (PieChart)
- Empty state for kpi.jobCount === 0
- Uses MD3 tokens (var(--chart-N), var(--status-done))

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(PBI-78): wire CostAnalysisCard onto insights page (T-904)

- Parse ?period= from searchParams (default 30d, validates against 7d/30d/90d/mtd)
- Parallel-fetch 5 cost queries via Promise.all alongside existing widgets
- New "Cost analyse" section between Sprint Health and Plan-quality
- Existing TokenUsageCard ("Token gebruik" section) stays as sprint detail

verify (lint+typecheck+test) and build pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-10 12:59:45 +02:00
..
agent-throughput.tsx PBI-56 + ST-1275: PLAN_READY → GRILLING re-grill + SKIPPED status rendering (#147) 2026-05-07 17:36:44 +02:00
alignment-trend.tsx feat(PBI-59): Sprint.code (SP-N sequentieel per product) (#153) 2026-05-07 20:10:16 +02:00
backlog-health.tsx fix(insights): integrate all 5 sections in /insights + add missing components (#50) 2026-05-02 17:23:03 +02:00
burndown-chart.tsx Component: BurndownChart (Recharts LineChart) (#35) 2026-05-01 16:41:15 +02:00
cost-analysis.tsx feat(PBI-78): cost-analysis widget on insights page (#187) 2026-05-10 12:59:45 +02:00
plan-quality.tsx Component: VerifyResultDonut + Top-5 tabellen (#39) 2026-05-01 16:41:25 +02:00
sprint-info-strip.tsx feat(PBI-59): Sprint.code (SP-N sequentieel per product) (#153) 2026-05-07 20:10:16 +02:00
sprint-status-donut.tsx Component: SprintStatusDonut (Recharts PieChart) (#36) 2026-05-01 16:41:18 +02:00
token-usage.tsx ST-1216: Insights sprint-widget — token KPI-kaartjes & per-job tabel (#114) 2026-05-06 03:19:30 +02:00
velocity-chart.tsx feat(PBI-59): Sprint.code (SP-N sequentieel per product) (#153) 2026-05-07 20:10:16 +02:00