Skip to content

fix(dashboard): surface analytics overview timeouts instead of empty stats - #421

Open
santhiprakash wants to merge 3 commits into
oblien:mainfrom
santhiprakash:fix/analytics-overview-timeout-and-error-ui
Open

fix(dashboard): surface analytics overview timeouts instead of empty stats#421
santhiprakash wants to merge 3 commits into
oblien:mainfrom
santhiprakash:fix/analytics-overview-timeout-and-error-ui

Conversation

@santhiprakash

Copy link
Copy Markdown
Contributor

Summary

Raise the /analytics/overview client timeout and show a retryable error in Overview/Monitoring when the fetch fails, instead of silently rendering 0/N/A empty states.

Motivation

Fixes #396. High-traffic projects can exceed the dashboard API client's 15s default while aggregating analytics. The abort was caught by useAnalyticsData but OverviewTab/MonitoringTab ignored error, so users saw zeros and "No traffic data yet" even though the endpoint returns real data when called directly.

Related issue

Closes #396

Changes

  • apps/dashboard/src/hooks/useProjectEndpoints.ts — use a 60s timeout for fetchOverview (same order of magnitude as other slow dashboard calls like deploy trigger).
  • apps/dashboard/src/app/(dashboard)/projects/[id]/components/OverviewTab.tsx — render error card with retry (invalidateProjectCaches) when analytics.error is set.
  • apps/dashboard/src/app/(dashboard)/projects/[id]/components/MonitoringTab.tsx — same error surface.
  • apps/dashboard/src/i18n/locales/*/projects.jsonanalytics.loadFailed string in all locales.

Verification

python3 ../scripts/preflight_ship.py --repo oblien/openship --local . --branch main \
  --file apps/dashboard/src/hooks/useProjectEndpoints.ts \
  --must-contain 'endpoints.analytics.overview' \
  --must-not-contain 'ANALYTICS_OVERVIEW_TIMEOUT_MS' --issue 396
# PREFLIGHT CLEAR

cd apps/dashboard && bun run test src/i18n/i18n-parity.test.ts
# 2 passed

Notes / Risks

  • Global network-error-handler still toasts on abort; this adds an inline, tab-local error so the empty-state widgets are not misleading.
  • 60s is a pragmatic ceiling; if aggregation routinely exceeds that, a follow-up could add server-side caching rather than raising the client timeout further.

Checklist

  • One change per PR — one bug, or one agreed feature, with nothing unrelated bundled in
  • The diff is scoped — no reformatting or lint fixes on lines I wasn't otherwise changing
  • A test fails without this change and passes with it (or I explained above why there isn't one)
  • bun run test, bun run --cwd <workspace> lint, and bun format all pass locally
  • I understand every line of this diff and can explain it in review

…stats

- Problem: /analytics/overview can exceed the 15s client default for high-traffic projects; the abort left Overview/Monitoring tabs showing 0/N/A with no error.
- Fix: request a 60s timeout for the overview fetch and render a retryable error state when analytics.error is set.
- Verification: bun run test src/i18n/i18n-parity.test.ts (pass); preflight_ship.py clear for oblien#396.
@Hydralerne

Copy link
Copy Markdown
Member

MonitoringTab blanks the whole tab (should-fix)
The MonitoringTab change is a full early return (MonitoringTab.tsx:309) that replaces the entire MonitoringView with the error card when /analytics/overview fails. But that view renders several independent data sources:

geo map + top paths → useAnalyticsGeo (separate cache)
CPU/memory resource charts → useProjectUsageHistory (a DB read, not edge aggregation)
live traffic feed → useProjectUsageStream (SSE, already has its own usageError/reconnect)
So an overview timeout now hides the resource charts and live feed that loaded fine. That's a resilience regression: before this PR, an overview failure left analytics null and the TrafficChart showed its empty state, but geo/usage/live still rendered. The fix should scope the error to the traffic chart/summary block — exactly the way OverviewTab already scopes it — not nuke the tab.

…itoringView

Address maintainer review on oblien#421: an /analytics/overview timeout was replacing the entire MonitoringTab via an early return, hiding the independent geo, usage, and history blocks. Move the error card into MonitoringView and scope it to the stats strip / traffic chart block (mirroring OverviewTab), so the rest of the tab still renders.
@santhiprakash

Copy link
Copy Markdown
Contributor Author

Pushed a follow-up commit to address the feedback.

The early return in MonitoringTab is gone. Instead, MonitoringView now accepts an analyticsError prop and scopes the retry card to the stats strip / traffic chart block only. The resources card, visitor map, live hits, top paths, response mix, and usage history all keep rendering when /analytics/overview fails, which matches the OverviewTab pattern.

What changed:

  • Removed the whole-tab if (showAnalyticsError) early return from MonitoringTab.
  • Added analyticsError and onRetryAnalytics props to MonitoringView.
  • When analyticsError is set and not loading, MonitoringView replaces the stats strip and CollapsibleCard traffic block with the existing error card + retry button.
  • The no-data prompt and traffic CollapsibleCard are suppressed while the error is shown.

Local verification:

  • bun run --cwd apps/dashboard lint (tsc --noEmit) passes.
  • bun run --cwd apps/dashboard test passes (447 tests, including MonitoringView.test.tsx).
  • bunx prettier --write applied to the two modified files.

Please take another look when you have a moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overview page shows 0 requests / no traffic data on some projects (silent AbortError in root layout)

2 participants