Use this to confirm the React app is sending errors and messages to Sentry after setup or deploy.Documentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
VITE_SENTRY_DSNset in env (e.g..env.local) for the build you are testing.- Access to the Sentry project dashboard.
- Do not hardcode DSNs in source files. Keep DSNs in environment variables only.
Configuration checklist
Verify these before or after running manual tests:| Variable | Required for | Where | How to confirm |
|---|---|---|---|
VITE_SENTRY_DSN | Sentry enabled | .env.local (dev) or deploy env | If unset, Sentry init sets enabled: false; no events sent. Check Sentry project Settings → Client Keys (DSN) and set in env. |
VITE_APP_VERSION | Release attribution | Injected at build in vite.config.ts as buildId | No env needed. In Sentry Issue details, check Release equals your build id (e.g. build-YYYYMMDD-xxxx). |
SENTRY_AUTH_TOKEN, SENTRY_ORG, SENTRY_PROJECT | Source map upload | CI/build env only | When all three are set, Vite build enables sentryVitePlugin and sourcemap: true. Omit for local builds if you do not need source map upload. |
Document-Policy: js-profiling | Browser profiling (Chromium) | Response headers for HTML navigations | Required by Sentry browser profiling (browserProfilingIntegration). On Vercel this is set in vercel.json on the catch-all route. Local vite dev does not set this header unless you configure the dev server; profiling may be limited in dev. |
VITE_SENTRY_DSN must be set for Production and Preview or the client will have Sentry disabled. For readable stack traces, also set SENTRY_AUTH_TOKEN, SENTRY_ORG (encore-health-os), and SENTRY_PROJECT (sentry-rose-bucket) so the Vercel build uploads source maps. See VERCEL_INTEGRATION.md for the full checklist.
Runtime: Init runs from src/instrument.ts (imported first in main.tsx). Integrations: replayIntegration, reactRouterV6BrowserTracingIntegration, browserProfilingIntegration; enableLogs / enableMetrics are on; sendDefaultPii is enabled; beforeSend still applies breadcrumb/data scrubbing and message truncation. Replay sampling is replaysSessionSampleRate: 1.0 in development, 0.1 outside development, and replaysOnErrorSampleRate: 1.0 in all environments. See src/platform/monitoring/sentry.ts.
PHI-scrubbing verification
The init flow (src/instrument.ts, imported first inmain.tsx) calls initSentry() from src/platform/monitoring/sentry.ts. The beforeSend callback and integrations (replayIntegration, reactRouterV6BrowserTracingIntegration, browserProfilingIntegration) must not send PHI. Verify as follows:
- Trigger simulated errors with PHI-like patterns: In a test or staging build, trigger errors whose messages or breadcrumbs contain sample PHI patterns (e.g. email, phone, SSN-like digits, medical record IDs). Ensure these events are sent through
beforeSend(init is already loaded). - Verify redaction in Sentry: In the Sentry UI (or by inspecting the raw event payload), confirm that fields are redacted or masked per
beforeSendbehavior (e.g. message/exception value truncation toMAX_MESSAGE_LENGTH, breadcrumbdatacleared forui.inputcategory). Check that no PHI appears in event message, exception value, or breadcrumb data. - Expected redaction examples and failure indicators: Document in tests or runbook: a) Good: Event message shows truncated text with
[truncated]; breadcrumbs forui.inputhave nodata. b) Bad: Full email, phone, SSN, or MRN visible in event or breadcrumbs. If you see PHI in Sentry,beforeSendis not applied or was bypassed — fix before going live. - Automated test checklist: Add unit or integration tests that invoke the same
beforeSendlogic (or the init path that sets it) with sample events containing PHI-like strings; assert that output events have those strings removed or truncated. ReferencebeforeSendinsrc/platform/monitoring/sentry.tsand the integrationsreplayIntegration,reactRouterV6BrowserTracingIntegration, andbrowserProfilingIntegrationwhen adding or reviewing these tests.
Master verification sequence
Repeatable 4-step flow for manual verification:- Set DSN: Add
VITE_SENTRY_DSNto.env.local(from Sentry project → Settings → Client Keys). Restart the dev server if it is already running. - Open app: Start the app (
npm run dev), log in if required, and go to System Health at/settings/system-health. - Trigger events: In the Sentry verification card (visible only in development), click Test Message, Test Metrics, then Test Error. For “Test Error” the app will show the error boundary; you can reload to continue.
- Confirm in Sentry: In the Sentry project dashboard, open Issues. Within a few seconds you should see the test error and the test message. Then open Metrics and query
dev_verification_button_click,dev_verification_page_load_time_ms, anddev_verification_response_time_ms. Optionally check Traces (page load/navigation) and Replays (session around the error).
1.0, so every local test session should be visible in Replays.
Manual verification (any environment)
1. Test error capture
Option A — Browser console (quick):- Open the app in the browser.
- Open DevTools → Console.
- Run:
throw new Error('Sentry verification test'); - In Sentry: Issues → the error should appear within seconds.
/settings/system-health when import.meta.env.DEV is true), click Test Error. Otherwise use Option A.
2. Test message capture
In the browser console:3. Test metrics capture
Use the dev-only Test Metrics button (preferred) or run this in the browser console:4. Check dashboard
| Area | What to check |
|---|---|
| Issues | New test error and/or message events |
| Metrics | dev_verification_button_click, dev_verification_page_load_time_ms, dev_verification_response_time_ms appear in Metrics Explorer |
| Traces | Page load and navigation transactions (if tracing on) |
| Replays | Session replay for the tab where you triggered the error (if replay on error) |
| Logs | Structured log entry if you used Sentry.logger.* |
5. Debug mode
If nothing appears:- In
src/platform/monitoring/sentry.ts, temporarily setdebug: trueinSentry.init(). - Reload and trigger a test event; check the browser console for Sentry SDK logs.
- Confirm DSN is set and not empty; confirm
enabled: Boolean(dsn)is true. - Set
debug: falseagain before committing.
Source map verification
To confirm production stack traces are readable (source file names and line numbers instead of minified code):- Build with Sentry env: Run a production build with
SENTRY_AUTH_TOKEN,SENTRY_ORG, andSENTRY_PROJECTset (e.g. in CI). This enablessentryVitePluginand source map upload invite.config.ts. - Deploy or serve: Deploy the built app or run
npm run preview(or equivalent) so the app is served from the production build. - Trigger a test error: Use the runbook steps above (e.g. console throw or a test button) to send one error to Sentry.
- Inspect in Sentry: Open the error in Sentry Issues and expand the stack trace. It should show source file names (e.g.
sentry.ts,SentryVerificationButtons.tsx) and line numbers. If you see only minified filenames and a single line number, the build likely did not have all three Sentry env vars set, or the event’s Release does not match the release used when uploading source maps (the build id).
Dev-only test component
For one-click verification in development, the platform exportsSentryVerificationButtons from @/platform/monitoring. Render it only when import.meta.env.DEV is true (e.g. on a system health or debug page) so it never ships to production.
Example:
Post-deploy checklist
- Trigger test error (console or button).
- Trigger test message (console or button).
- Confirm events in Sentry Issues (and Logs if used).
- Confirm Replay behavior: development captures all sessions (
1.0), production/preview samples sessions at0.1, and error sessions are always captured (replaysOnErrorSampleRate: 1.0). - Confirm source maps: stack traces show source files and line numbers when
SENTRY_AUTH_TOKEN+ org/project are set in CI build. - Vercel: If deploying via Vercel, ensure
VITE_SENTRY_DSNis set for Production and Preview (Vercel Dashboard → Project → Settings → Environment Variables). Optionally setSENTRY_AUTH_TOKEN,SENTRY_ORG,SENTRY_PROJECTfor source map upload during Vercel builds.