fix: add null checks to analytics charts to prevent crashes #80

Merged
jonas.hanisch merged 1 commit from fix/viewer-analytics-null-checks into main 2026-01-22 18:06:25 +00:00
Owner

Summary

  • Add defensive null checks to all analytics chart components
  • Prevent "cannot access property of undefined" errors when API returns incomplete data
  • Charts now gracefully show "No data available" instead of crashing

Changes

  • TimelineChart.tsx: Add !data || check
  • TypesChart.tsx: Add !data || check
  • ProjectsChart.tsx: Add !data || check
  • TokensChart.tsx: Add null coalescing for totals and byType
  • AnalyticsSection.tsx: Add null coalescing when setting data from API response

Test plan

  • Verified viewer loads without errors after fix
  • Test with empty database
  • Test with API errors

🤖 Generated with Claude Code

## Summary - Add defensive null checks to all analytics chart components - Prevent "cannot access property of undefined" errors when API returns incomplete data - Charts now gracefully show "No data available" instead of crashing ## Changes - `TimelineChart.tsx`: Add `!data ||` check - `TypesChart.tsx`: Add `!data ||` check - `ProjectsChart.tsx`: Add `!data ||` check - `TokensChart.tsx`: Add null coalescing for `totals` and `byType` - `AnalyticsSection.tsx`: Add null coalescing when setting data from API response ## Test plan - [x] Verified viewer loads without errors after fix - [ ] Test with empty database - [ ] Test with API errors --- 🤖 Generated with [Claude Code](https://claude.ai/code)
fix: add null checks to analytics charts to prevent crashes
All checks were successful
CI / build (pull_request) Successful in 20s
CI / validate-plugin (pull_request) Successful in 1s
45b3c8682e
Charts now gracefully handle undefined/null data from the API instead
of throwing "cannot access property of undefined" errors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
jonas.hanisch deleted branch fix/viewer-analytics-null-checks 2026-01-22 18:06:25 +00:00
Sign in to join this conversation.
No description provided.