obs: New Relic browser agent + VITE_COMMIT_ID + ErrorBoundary (track 8/8)#37
Merged
Merged
Conversation
…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>
8 tasks
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
Track 8 of 8 in the observability rollout. Adds
@newrelic/browser-agentfor SPA error reporting, AJAX failure tracking, and SPA route navigation tracking. Every NR event is stamped withcommit_id(the dashboard's build SHA injected at build time), mirroring what the Go services do via-ldflags.vite.config.ts—defineblock injectsVITE_COMMIT_ID(fromGIT_SHAenv, defaults to"dev") plus the New Relic keyssrc/main.tsx— bootsBrowserAgentbefore React mount, fail-open when license key absent (matches Go services on emptyNEW_RELIC_LICENSE_KEY)src/components/ErrorBoundary.tsx(NEW) — catches render errors, ships them viawindow.newrelic.noticeErrorwithcommit_id, renders an inline fallbacksrc/components/ErrorBoundary.test.tsx(NEW) — 5 unit tests.github/workflows/deploy-pages.yml— exportsGIT_SHA=$(git rev-parse --short HEAD)beforenpm run buildand surfacesVITE_NEWRELIC_LICENSE_KEY+VITE_NEWRELIC_APP_IDfrom repo secretsTest plan
npm test— 209 passed | 3 skipped (was 204 | 3); 5 new ErrorBoundary testsnpm run buildclean with TypeScript strict modeGIT_SHA=test123abc npm run build→dist/assets/index-*.jscontainscommit_id:"test123abc"(grep confirmed)VITE_NEWRELIC_LICENSE_KEY+VITE_NEWRELIC_APP_IDare populatedwindow.newrelicis defined andNewRelicJSerrors appear in NR Browser with the expectedcommit_idcustom attribute🤖 Generated with Claude Code