-
Notifications
You must be signed in to change notification settings - Fork 0
feat: analytics trends and budget forecast API endpoints #771
Copy link
Copy link
Closed
Labels
prio:highImportant, should be prioritizedImportant, should be prioritizedscope:medium1-3 days of work1-3 days of workspec:apitype:featureNew feature implementationNew feature implementationv0.5Minor version v0.5Minor version v0.5v0.5.0Patch release v0.5.0Patch release v0.5.0
Description
Phase 3.1 -- Analytics Trends & Forecast
Parent: #762
Context
The new dashboard needs sparkline trend data and budget forecast projections. The backend has the raw data (CostRecord, TaskMetricRecord) but no time-series aggregation endpoints.
Scope
GET /api/v1/analytics/trends
- Query params:
period(7d/30d/90d),metric(tasks_completed, spend, active_agents, success_rate) - Response: array of
{timestamp, value}datapoints bucketed by day (or hour for 7d) - Data sources: CostRecord (spend), TaskMetricRecord (tasks, success rate), agent status snapshots
GET /api/v1/analytics/forecast
- Query params:
horizon_days(7/14/30) - Response:
{projected_total, daily_projections: [{day, value}], days_until_budget_exhausted, confidence} - Data source: CostTracker's internal trending logic (needs to be exposed as public method)
Extend GET /api/v1/analytics/overview
- Add fields:
budget_remaining_usd,budget_used_percent,cost_7d_trend(sparkline array),active_agents_count,idle_agents_count
Deliverables
- Trends endpoint with 4 metric types
- Forecast endpoint with daily projections
- Extended overview response
- Unit tests with realistic test data
- OpenAPI schema updated
Notes
- Can start immediately -- no dependency on frontend work
- Expose CostTracker's trend logic via new public methods, don't duplicate
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
prio:highImportant, should be prioritizedImportant, should be prioritizedscope:medium1-3 days of work1-3 days of workspec:apitype:featureNew feature implementationNew feature implementationv0.5Minor version v0.5Minor version v0.5v0.5.0Patch release v0.5.0Patch release v0.5.0