Skip to content

feat: expand observability with advanced dashboards and client logging - #444

Open
NesiciCoding wants to merge 2 commits into
mainfrom
freebuff/can-you-start-working-on-creating-more-advanced-gr-c6af1100-e5ee-4085-9dae-3e9a6a317226
Open

feat: expand observability with advanced dashboards and client logging#444
NesiciCoding wants to merge 2 commits into
mainfrom
freebuff/can-you-start-working-on-creating-more-advanced-gr-c6af1100-e5ee-4085-9dae-3e9a6a317226

Conversation

@NesiciCoding

@NesiciCoding NesiciCoding commented Aug 17, 2026

Copy link
Copy Markdown
Owner

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 a path column to client_logs plus composite indexes on (category, created_at) and (path, created_at).
  • supabase/migrations/073_client_logs_backfill.sql — best-effort backfill of path for rows written before 072: recovers meta->>'path' when present, maps 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). Idempotent — only touches rows where path IS NULL and a value can be derived.
  • clientLogger.ts — two new categories (pageview, metric), automatic path capture from the hash router on every event, and logPageView() / logMetric() helpers.
  • Instrumentation — a new PageViewLogger component (rendered in both the teacher and student route trees in App.tsx) emits a pageview per navigation, and main.tsx reports Web Vitals (LCP, FCP, FID, CLS) and page-load time as metrics. Everything stays gated behind VITE_STRESS_TEST_LOGGING=true and 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 new pageview/metric rows: pageviews per page, LCP/FCP/FID/load p75 over time, slowest pages, web-vitals summary, sessions by role, recent pageviews.

Provisioning & docs

  • The two dashboards auto-provision on stack startupdocker-compose.observability.yml mounts the whole docker/observability/dashboards/ directory and grafana-dashboards-provider.yml scans it every 30s, so no compose change was needed.
  • Updated README.md and docs/OBSERVABILITY_DASHBOARDS.md (documents all four dashboards, the new logging categories, and the backfill).
  • Regenerated supabase/bootstrap.sql via scripts/generate-bootstrap.sh (74 migrations).

Verification

  • npm run typecheck
  • eslint 0 errors (4 pre-existing warnings)
  • prettier --check
  • All four dashboard JSON files parse
  • Full unit suite: 249 files / 3202 tests pass

Notes / not run

  • pageview/metric categories 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:reset is the project's documented check.

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>
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Important

Review available on request

  • 🔍 Trigger review

Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment @coderabbitai review to review the latest changes. For a full review, comment @coderabbitai full review.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b8936177-3659-497e-b9de-2bd75aaf9b54


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 80.45% (🎯 65%) 11100 / 13797
🟢 Statements 78.41% (🎯 65%) 12699 / 16195
🟢 Functions 71% (🎯 60%) 3962 / 5580
🟢 Branches 69.46% (🎯 58%) 9370 / 13489
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/components/ui/PageViewLogger.tsx 0% 100% 0% 0% 7-11
Generated in workflow #1237 for commit 85d1211 by the Vitest Coverage Report Action

@NesiciCoding NesiciCoding added enhancement New feature or request database Pull request that change things regarding the database (migrations, bootstrap, edge functions) documentation Improvements or additions to documentation labels Aug 17, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

database Pull request that change things regarding the database (migrations, bootstrap, edge functions) documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant