Bug #8
openCOVID Tracker Enhancement — Replace Defunct API, Fix Error Handling, Add ErrorBoundary & Modernise App Component
0%
Description
Ticket Metadata¶
| Field | Value |
|---|---|
| Project | ai-workbench |
| Tracker | Feature |
| Priority | High |
| Module | frontend · api-layer |
| Entity | covid-tracker |
| Feature Type | enhancement · bug-fix · modernisation |
| Source References |
01-code-analysis.md, 02-design-document.md, 03-task-list.md (run 20260817T163131_3bae6h) |
1. User Story¶
As a developer maintaining the COVID-19 tracker SPA,
I want to replace the defunct covidtracking.com API with disease.sh, normalise error handling across the entire data layer so that components receive thrown errors instead of raw Error objects, add a React ErrorBoundary to prevent blank-screen crashes, convert App.js to a functional component for paradigm consistency, and fix UX gaps (loading states, CountryPicker label, type bugs),
So that the application displays accurate real-time data, handles all failure modes gracefully with user-visible feedback, and follows modern React conventions throughout the codebase.
2. Background¶
The project_corona_tracker is a React 16.13.1 SPA that visualises global COVID-19 statistics using two external APIs. The covidtracking.com API — which powered the Line chart with US daily historical data — was permanently shut down in March 2021, making the Line chart non-functional for over three years.
Beyond the broken API, src/api/index.js silently returns raw Error objects from all three functions (fetchData, fetchDailyData, fetchCountries) instead of throwing. Downstream components call .map() or destructure these objects, producing TypeError crashes. There is no ErrorBoundary, so any uncaught exception yields a blank white screen. App.js is the only class component; all others use hooks. Chart.jsx initialises dailyData as {} (object) when [] (array) is required.
The design doc selected disease.sh (https://disease.sh) as the replacement — it provides both global and per-country historical time-series data, is actively maintained, and requires no authentication.
3. Scope¶
In Scope:
- Replace
covidtracking.cominfetchDailyData→ disease.sh (global + per-country historical) - Normalise all
catchblocks insrc/api/index.jsfromreturn errortothrow new Error(...) - Apply
encodeURIComponent(country)to all URL path construction - Move hardcoded API base URLs to
REACT_APP_COVID_API_URL/REACT_APP_DAILY_API_URLenv vars; add.env.example - Add
ErrorBoundaryclass component and wire intosrc/index.js - Convert
App.js→App.jsxfunctional component withuseState/useEffect,loading/errorstate, AbortController - Fix
Chart.jsx:useState([]),[country]in useEffect deps, Line chart for all views, loading spinner, error state, AbortController - Fix
CountryPicker.jsx: default label "Global", country name as React key - Update
Cards.jsx: acceptloading/errorprops; render MUI Skeleton/Alert - Unit and component tests for api layer, ErrorBoundary, Chart, Cards
- Lint and build verification gate
Out of Scope:
- React 18 / MUI v5 / Chart.js 4 major dependency upgrades
- TypeScript migration, backend, routing, authentication, CSP
4. Acceptance Criteria¶
-
fetchDailyDatacalls disease.sh and returns correct time-series data for global and per-country views -
All three api functions throw on error (never return raw
Errorobjects) -
ErrorBoundarywraps<App>inindex.js; uncaught render errors show a fallback UI instead of blank screen -
App.jsxis a functional component usinguseState/useEffectwithloading/errorstate and AbortController -
Chart.jsxinitialisesdailyDataas[], renders Line chart for all views, shows loading spinner and error state -
CountryPicker.jsxdefault label is "Global" -
Cards.jsxaccepts and rendersloading/errorprops - Unit and component tests pass for api layer, ErrorBoundary, Chart, Cards
- Lint and build gates pass
-
.env.exampledocumentsREACT_APP_COVID_API_URLandREACT_APP_DAILY_API_URL
Labels: ai-created, frontend, api-layer, enhancement, bug-fix, covid-tracker
Labels: ai-created, frontend, api-layer, enhancement, bug-fix, covid-tracker
No data to display