Skip to content

feat(analytics): distinguish live from fallback learner-progress data - #1074

Merged
ayomideadeniran merged 1 commit into
StellarDevHub:mainfrom
mubby4:feat/analytics-data-source-transparency-888
Aug 3, 2026
Merged

feat(analytics): distinguish live from fallback learner-progress data#1074
ayomideadeniran merged 1 commit into
StellarDevHub:mainfrom
mubby4:feat/analytics-data-source-transparency-888

Conversation

@mubby4

@mubby4 mubby4 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #888

Learner-progress dashboards can now always tell the difference between live, cached, and fallback data. Instead of silently swapping in sample numbers when the analytics API is unavailable, the performance-metrics dashboard states exactly what it is showing.

What changed

Data-source transparency

  • usePerformanceMetrics now tracks a dataSource state: live | cached | fallback.
    • live — freshly verified from the analytics API.
    • cached — the most recent refresh failed, so the last verified snapshot is kept on screen (stale-but-real, never replaced with fake numbers).
    • fallback — no live snapshot has ever been verified; deterministic sample data is shown purely so the UI stays explorable.
  • Errors are normalised into a structured AnalyticsError (network/timeout/HTTP classification + retriability) via toAnalyticsError, and lastVerifiedAt provenance is surfaced.

UI (DataSourceNotice)

  • Non-blocking, screen-reader-friendly (role="status") indicator that distinguishes:
    • a subtle green Live data pill, or
    • an amber notice explaining the snapshot is the last verified one (with timestamp) or plain sample data — each with a Retry action.

Export integrity

  • Fallback (sample) values cannot be exported as learner progress — the export button is disabled.
  • Cached data is exportable but the payload is always labelled via createMetricsExport with source: "cached", isLive: false, and lastVerifiedAt, so a downstream consumer can never mistake non-live numbers for a verified record.

Tests

  • Hook tests cover live, empty, failed, cached, and recovered states (usePerformanceMetrics.test.ts).
  • Lib tests for toAnalyticsError and createMetricsExport labelling (performanceMetrics.test.ts).
  • Component tests for the notice (live/cached/fallback + retry) and export gating.

All new tests pass (26/26 in the touched suites); the only failing suites in the repo are pre-existing and unrelated (theme/keyboard/tutorial/editor/monaco).

Enhance the performance-metrics dashboard so users can always tell whether
displayed data is live, cached, or fallback:

- Track a dataSource state (live | cached | fallback) in usePerformanceMetrics.
  A failed refresh keeps the last verified live snapshot (cached) instead of
  silently showing fake numbers; only with no prior live data does it show
  deterministic sample (fallback) values.
- Surface structured AnalyticsError + lastVerifiedAt provenance.
- Add DataSourceNotice: an accessible (role=status) live/cached/fallback
  indicator with a retry action for non-live states.
- Export gating: fallback sample data cannot be exported; cached exports are
  clearly labelled non-live with provenance via createMetricsExport.

Adds unit tests covering live, empty, failed, cached, and recovered states.

Closes StellarDevHub#888
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

@mubby4 is attempting to deploy a commit to the Ayomide Adeniran's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jul 31, 2026

Copy link
Copy Markdown

@mubby4 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@ayomideadeniran

Copy link
Copy Markdown
Contributor

pr under review

@ayomideadeniran
ayomideadeniran merged commit a5a45d6 into StellarDevHub:main Aug 3, 2026
1 check failed
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.

[Learning Analytics] Make learner progress dashboards distinguish live data from fallback data

2 participants