Skip to content

obs: New Relic browser agent + VITE_COMMIT_ID + ErrorBoundary (track 8/8)#37

Merged
mastermanas805 merged 1 commit into
mainfrom
obs/dashboard-browser-fresh
May 12, 2026
Merged

obs: New Relic browser agent + VITE_COMMIT_ID + ErrorBoundary (track 8/8)#37
mastermanas805 merged 1 commit into
mainfrom
obs/dashboard-browser-fresh

Conversation

@mastermanas805
Copy link
Copy Markdown
Member

Summary

Track 8 of 8 in the observability rollout. Adds @newrelic/browser-agent for SPA error reporting, AJAX failure tracking, and SPA route navigation tracking. Every NR event is stamped with commit_id (the dashboard's build SHA injected at build time), mirroring what the Go services do via -ldflags.

  • vite.config.tsdefine block injects VITE_COMMIT_ID (from GIT_SHA env, defaults to "dev") plus the New Relic keys
  • src/main.tsx — boots BrowserAgent before React mount, fail-open when license key absent (matches Go services on empty NEW_RELIC_LICENSE_KEY)
  • src/components/ErrorBoundary.tsx (NEW) — catches render errors, ships them via window.newrelic.noticeError with commit_id, renders an inline fallback
  • src/components/ErrorBoundary.test.tsx (NEW) — 5 unit tests
  • .github/workflows/deploy-pages.yml — exports GIT_SHA=$(git rev-parse --short HEAD) before npm run build and surfaces VITE_NEWRELIC_LICENSE_KEY + VITE_NEWRELIC_APP_ID from repo secrets

Test plan

  • npm test — 209 passed | 3 skipped (was 204 | 3); 5 new ErrorBoundary tests
  • npm run build clean with TypeScript strict mode
  • Build smoke: GIT_SHA=test123abc npm run builddist/assets/index-*.js contains commit_id:"test123abc" (grep confirmed)
  • Post-merge: GH Pages deploy runs, repo secrets VITE_NEWRELIC_LICENSE_KEY + VITE_NEWRELIC_APP_ID are populated
  • Post-merge: open the deployed dashboard, confirm window.newrelic is defined and NewRelicJS errors appear in NR Browser with the expected commit_id custom attribute

🤖 Generated with Claude Code

…8/8)

Adds @newrelic/browser-agent for SPA error reporting, AJAX failure tracking,
and SPA route navigation tracking. Stamps every event with the dashboard's
build SHA (VITE_COMMIT_ID) so frontend errors correlate to the same commit
identifier the api/worker/provisioner Go services emit via -ldflags.

- vite.config.ts: define VITE_COMMIT_ID from GIT_SHA env (defaults "dev"),
  plus VITE_NEWRELIC_LICENSE_KEY + VITE_NEWRELIC_APP_ID at build time
- src/main.tsx: init BrowserAgent before React mount, fail-open when license
  key absent (mirrors Go services on empty NEW_RELIC_LICENSE_KEY)
- src/components/ErrorBoundary.tsx: top-level boundary that catches render
  errors, ships them via window.newrelic.noticeError with commit_id attr,
  renders an inline fallback so users can reload
- src/components/ErrorBoundary.test.tsx: 5 unit tests (happy path, error
  catch + fallback, NR noticeError with commit_id, no-crash when agent
  absent, custom fallback override)
- .github/workflows/deploy-pages.yml: export GIT_SHA before npm run build
  and expose VITE_NEWRELIC_* secrets

Tests: 209 passed | 3 skipped (was 204 | 3). Build smoke verified —
GIT_SHA=test123abc produces `commit_id:"test123abc"` in dist/assets/index-*.js.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mastermanas805 mastermanas805 merged commit 954889c into main May 12, 2026
1 of 2 checks passed
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.

1 participant