Skip to content

Export dashboard metrics to CSV/JSON #34

@alexh

Description

@alexh

Summary

Export success rates, failure analysis, and trends for external analysis.

Key Features

  • Export metrics to CSV and JSON formats
  • Date range selection for exports
  • Per-agent and aggregate exports
  • CLI and UI export options

Implementation Phases

Phase 1: Export Module

  • Create src/core/export.ts:
    interface ExportOptions {
      format: 'csv' | 'json';
      dateRange?: { start: string; end: string };
      agents?: AgentType[];
      includeLoopDetails?: boolean;
    }
    
    function exportMetrics(loops: Loop[], options: ExportOptions): string;
    function exportToFile(data: string, path: string): void;

Phase 2: CSV Formatter

  • Flatten metrics into tabular format
  • Headers: date, agent, loops_run, completed, failed, avg_iterations, avg_duration, cost_usd
  • One row per agent per day
  • Aggregate row option

Phase 3: JSON Formatter

  • Already exists: exportMetricsToJson() in src/core/metrics.ts
  • Extend with date filtering
  • Add loop-level detail option (full loop objects)

Phase 4: CLI Commands

# Export all metrics as CSV
alex export --format csv --output metrics.csv

# Export last 7 days as JSON
alex export --format json --days 7

# Export specific agent
alex export --format csv --agent claude

# Export to stdout
alex export --format json

Phase 5: UI Integration

  • Add "Export" button in metrics tab
  • Modal with options:
    • Format selector (CSV/JSON)
    • Date range picker
    • Agent filter checkboxes
  • Save file dialog or copy to clipboard

Export Schema

CSV Format

date,agent,loops_run,completed,failed,success_rate,avg_iterations,avg_duration_min,cost_usd
2024-01-15,claude,5,4,1,0.80,12.5,45.2,2.50
2024-01-15,codex,3,3,0,1.00,8.0,30.1,1.20

JSON Format

{
  "exportedAt": "2024-01-15T10:00:00Z",
  "dateRange": { "start": "2024-01-08", "end": "2024-01-15" },
  "summary": { ... },
  "agentMetrics": [ ... ],
  "dailyTrends": [ ... ],
  "loops": [ ... ]  // optional detail
}

Files to Create/Modify

  • src/core/export.ts - New export module
  • src/core/metrics.ts - Extend with date filtering
  • src/cli.ts - Add export subcommand
  • src/ui/layout.ts - Export button in metrics tab

Acceptance Criteria

  • Export button in metrics tab
  • CSV and JSON format options
  • Date range selection
  • Per-agent and aggregate exports

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions