feat: expand observability with advanced dashboards and client logging - #444
Open
NesiciCoding wants to merge 2 commits into
Conversation
Add two advanced Grafana dashboards reading domain tables and new pageview/metric client logging, plus the instrumentation to feed them. - client_logs migration adds a path column and composite indexes - clientLogger gains pageview/metric categories, path capture, and logPageView/logMetric helpers - PageViewLogger component emits a pageview per navigation; main.tsx reports Web Vitals (LCP, FCP, FID, CLS) and page-load time - New "Application Usage & Data Health" and "Performance & Web Vitals" dashboards; docs and bootstrap.sql regenerated 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
|
Important Review available on request
Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
Best-effort backfill of the path column added in 072, recovering the route only where it is derivable: meta->>'path' when present, essay_* events to /essay/<teacherKey> (the :code route param is the teacherKey), and test_* events to /test (their meta holds the testId, not the URL code). pageview/metric categories were never captured before 072, so the Performance & Web Vitals dashboard stays forward-looking; Application Usage covers history via the domain tables. Idempotent — only touches rows where path IS NULL and a value can be derived. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves the observability stack from two basic dashboards to a fuller picture of the application: two new advanced Grafana dashboards plus the client logging data endpoints and instrumentation needed to feed them.
What's included
New data endpoints (client logging)
supabase/migrations/072_client_logs_observability.sql— adds apathcolumn toclient_logsplus composite indexes on(category, created_at)and(path, created_at).supabase/migrations/073_client_logs_backfill.sql— best-effort backfill ofpathfor rows written before 072: recoversmeta->>'path'when present, mapsessay_*events to/essay/<teacherKey>(the:coderoute param is the teacherKey), andtest_*events to/test(theirmetaholds the testId, not the URL code). Idempotent — only touches rows wherepathIS NULL and a value can be derived.clientLogger.ts— two new categories (pageview,metric), automaticpathcapture from the hash router on every event, andlogPageView()/logMetric()helpers.PageViewLoggercomponent (rendered in both the teacher and student route trees inApp.tsx) emits a pageview per navigation, andmain.tsxreports Web Vitals (LCP, FCP, FID, CLS) and page-load time as metrics. Everything stays gated behindVITE_STRESS_TEST_LOGGING=trueand is a no-op otherwise.New advanced dashboards
application-usage.json— "Application Usage & Data Health", 24 panels reading the domain tables directly (teachers, schools, classes, students, rubrics, grades, tests, essays, flashcards, marketplace, messages, …): three rows of stat cards, daily activity/signup timeseries, entity-count ranking, per-school breakdowns, most-active teachers, and per-domain freshness. No app instrumentation needed — works against any reachable database, including legacy data.performance-web-vitals.json— "Performance & Web Vitals", 12 panels over the newpageview/metricrows: pageviews per page, LCP/FCP/FID/load p75 over time, slowest pages, web-vitals summary, sessions by role, recent pageviews.Provisioning & docs
docker-compose.observability.ymlmounts the wholedocker/observability/dashboards/directory andgrafana-dashboards-provider.ymlscans it every 30s, so no compose change was needed.README.mdanddocs/OBSERVABILITY_DASHBOARDS.md(documents all four dashboards, the new logging categories, and the backfill).supabase/bootstrap.sqlviascripts/generate-bootstrap.sh(74 migrations).Verification
npm run typecheck✅eslint0 errors (4 pre-existing warnings)prettier --check✅Notes / not run
pageview/metriccategories were never captured before 072, so the Performance & Web Vitals dashboard is forward-looking (data from the first deploy of the instrumented build); Application Usage covers history via the domain tables.npm run db:reset(wipes the local dev database) was not run. Both migrations are idempotent; if you want them verified against a live local stack,npm run db:resetis the project's documented check.