Analytics Dashboard
18. Analytics Dashboard
The analytics dashboard provides a comprehensive view of tenant-wide LLM usage, workflow performance, knowledge base growth, and project health. It is composed of 10 panels fed by a single tRPC query (dashboard.getAnalytics) that aggregates data from workflows, discussions, insights, projects, auto-fix runs, refactor runs, and personas. The query auto-refreshes every 60 seconds.
18.1 Architecture
The AnalyticsDashboard component (src/components/dashboard/analytics/analytics-dashboard.tsx) renders a skeleton loader during fetch, then arranges panels in a responsive grid layout.
18.2 Data Type Definition
The full shape of the analytics response is defined in src/types/analytics.ts as the AnalyticsDashboardData interface. Key sections:
| Field | Type | Description |
|---|---|---|
hero |
Object | Aggregate totals: spend, tokens, energy, time saved, workflows run, success rate |
activityTimeline |
Array | 30-day daily counts of workflows, discussions, and insights |
providerUsage |
Array | Per-provider token totals, cost, and call count |
insightPulse |
Object | Insight breakdown by type, severity, paired count, top 5 categories |
projectHealth |
Array | Per-project workflow count, insight count, total cost, last activity |
workflowPerformance |
Object | Status distribution, avg duration, retry stats, top 5 errors |
discussionStats |
Object | Total discussions, by mode, message count, message cost |
knowledgeBase |
Object | Memory entries, insights, consolidation/code patterns, blog posts, 7-day growth |
modelUsage |
Array | Per-provider+model token usage, cost, call count, avg duration, energy |
successRates |
Object | Workflow completion, auto-fix generate/apply rates, refactor generate/apply rates |
personaStats |
Array | Per-persona level, traits, specializations, usage count, success rate |
18.3 Hero Metrics
The hero section aggregates lifetime totals across all workflows and discussions for the tenant:
- Total Spend -- sum of
costEstimatefrom all workflow steps plus all discussion messages - Total Tokens -- accumulated from
tokenUsage.totalon each completed step - Total Energy (Wh) -- computed via
computeEnergy()fromsrc/lib/workflow-metrics - Time Saved (minutes) -- estimated via
computeWorkflowAggregates(), which models manual effort displacement - Workflows Run -- count of all workflows (any status)
- Success Rate --
completedWorkflows / allWorkflows.length * 100
18.4 Activity Timeline
A 30-day bar/area chart showing daily activity across three dimensions:
activityTimeline: Array<{
date: string; // "YYYY-MM-DD"
workflows: number; // Workflows created on this day
discussions: number; // Discussions created
insights: number; // Workflow insights created
}>
The backend pre-fills all 30 days (even days with zero activity) to ensure the chart renders a continuous timeline with no gaps. Dates are bucketed using toISOString().slice(0, 10).
18.5 Provider Usage
Aggregates token consumption and cost across all completed workflow steps and assistant discussion messages, grouped by provider name. Both sources contribute to the same provider bucket:
providerUsage: Array<{
provider: string; // "anthropic" | "openai" | "google" | "ollama" | "unknown"
totalTokens: number;
totalCost: number;
callCount: number;
}>
Results are sorted by totalTokens descending. Steps without a provider are grouped under "unknown".
18.6 Model Usage Table
The ModelUsageTable component (src/components/dashboard/analytics/model-usage-table.tsx) displays a sortable table with per-model breakdowns. It tracks seven columns:
| Column | Key | Formatting |
|---|---|---|
| Provider | provider |
Color-coded dot from PROVIDER_COLORS + capitalized name |
| Model | model |
Monospace font |
| Tokens | totalTokens |
Compact: 1.2M, 45.3K, or raw number |
| Cost | totalCost |
USD with 3 decimal places |
| Calls | callCount |
Raw count |
| Avg Duration | avgDurationMs |
ms if <1000, otherwise s with 1 decimal |
| Energy | energyWh |
Via formatEnergy() helper |
Sorting is client-side. Clicking a column header toggles between ascending and descending order. The active sort column's icon is highlighted with text-nyx-accent.
18.7 Insight Pulse
Breaks down workflow insights along multiple dimensions:
- By Type -- counts per
insightType(pain_point,solution,strength,pattern,decision) - By Severity -- counts per severity level (
blocker,high,medium,low) - Paired Count -- number of insights that have a non-null
pairedInsightId(pain points matched with solutions) - Top Categories -- top 5 categories (e.g. "Security", "Architecture", "Performance") by insight count
18.8 Workflow Performance
Operational health metrics for the workflow engine:
- By Status -- distribution across
pending,running,paused,completed,failed - Avg Duration (ms) -- mean step execution time across all completed steps with non-null
durationMs - Total Retries -- sum of
retryCountacross all steps - Steps With Retries -- count of steps where
retryCount > 0 - Total Steps -- overall step count
- Top Errors -- top 5 error messages from failed steps (truncated to 100 chars), with occurrence counts. Sourced from the most recent 200 failed steps.
18.9 Knowledge Base Stats
Counts across the tenant's knowledge stores, plus 7-day growth indicators:
| Metric | Source Table | Growth Window |
|---|---|---|
| Memory Entries | memory_entries |
Last 7 days |
| Insights | workflow_insights |
Last 7 days |
| Consolidation Patterns | consolidation_patterns |
-- |
| Code Patterns | code_patterns |
-- |
| Blog Posts | blog_posts |
-- |
18.10 Project Health (Project Portfolio)
Per-project summary rendered by the ProjectPortfolio component:
projectHealth: Array<{
id: string;
name: string;
status: string; // "active" | "archived"
workflowCount: number; // _count.workflows
insightCount: number; // _count.workflowInsights
totalCost: number; // Sum of workflow step costs for this project
lastActivity: Date; // project.updatedAt
}>
Project costs are computed by iterating all workflows, filtering by projectId, and summing computeWorkflowAggregates().totalCost. Projects are sorted by updatedAt descending (most recently active first).
18.11 Success Rates Panel
The SuccessRatesPanel component (src/components/dashboard/analytics/success-rates-panel.tsx) shows three progress-bar groups with color-coded thresholds:
| Rate | Color |
|---|---|
| >= 80% | bg-nyx-success (green) |
| >= 50% | bg-nyx-warning (yellow) |
| < 50% | bg-nyx-danger (red) |
Workflow: Single bar -- completed / total completion rate.
Auto-Fix: Two bars:
- Generate Rate:
(fix_generated + pr_created + resolved) / total_issues - Apply Rate:
(pr_created + resolved) / total_issues
Status grouping is done via autoFixIssue.groupBy({ by: ["fixStatus"] }).
Refactor: Two bars:
- Generate Rate:
(improved + applied) / total_opportunities - Apply Rate:
applied / total_opportunities
Status grouping is done via refactorItem.groupBy({ by: ["status"] }).
18.12 Persona Overview Panel
The PersonaOverviewPanel component (src/components/dashboard/analytics/persona-overview-panel.tsx) displays mini-cards for up to 20 personas (ordered by usageCount descending), including both tenant-specific and built-in personas.
Each PersonaMiniCard shows:
- Name and Level badge (
Lv.{n}) - XP progress bar -- fractional part of the level rendered as a percentage fill
- Traits -- displayed as default-variant badges
- Specializations -- displayed as accent-variant badges
- Three stats: Uses (total count), Success (percentage or
--), Last Used (relative time viaformatRelativeTimeor"Never")
Cards are arranged in a responsive 1-column (mobile) / 2-column (sm+) grid.
