Spec: PF-07 — Error Handling & MonitoringDocumentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
Last Updated: 2026-03-14
For operational procedures (alerting, dashboards, escalation), see MONITORING_RUNBOOK.md.
Structured Logger
All logging must use the platformlogger. Never use console.log in production code.
Rules
- NEVER log PHI/PII — only stable IDs (user_id, org_id, entity UUIDs)
- Always include
module(core prefix:pf,hr,fa, etc.) andaction - Use
logger.error()with anErrorobject for stack trace capture - Use
sanitizeErrorMessage(error)for any user-facing error text
Error Boundaries
Wrap components in<ErrorBoundary> to prevent crashes from propagating.
Levels
| Level | Use Case | Fallback |
|---|---|---|
global | App root (main.tsx, App.tsx) | Full-page error screen |
feature | Route modules (RouteLoader.tsx) | Module-level error screen |
component | Individual widgets | Custom or default inline fallback |
Suppressed Errors
The ErrorBoundary suppresses known non-actionable errors (WebSocket unavailable, insecure context) to prevent unnecessary UI crashes. SeeSUPPRESSED_PATTERNS in ErrorBoundary.tsx.
Performance Monitoring
Automatic Tracking
- Web Vitals (LCP, INP, CLS): Tracked by Sentry via
reactRouterV6BrowserTracingIntegration - Page load / DOM ready: Tracked by
performanceMonitor→pf_health_metrics
Custom Marks
API Metrics
API response times are tracked automatically viaapi-metrics.ts when enabled. Histograms are flushed to pf_health_metrics periodically.
Sentry Integration
Error Capture
Sentry captures unhandled errors automatically. For manual capture:Session Replay
Session replays are recorded at 100% for error sessions. All text is masked and media is blocked for HIPAA compliance. No configuration needed — this is handled insentry.ts.
PHI Safety
ThebeforeSend callback in sentry.ts scrubs potential PHI patterns (emails, phone numbers, SSNs, DOBs) from all events before they leave the browser. Only UUIDs are sent as user/org identifiers.
Correlation IDs
Auth state changes generate acorrelation_id (via crypto.randomUUID()) that is set in the logger context. This enables tracing all logs from a single auth session.
The correlation ID is automatically set in App.tsx for SIGNED_IN, TOKEN_REFRESHED, and SIGNED_OUT events.
Checklist for New Features
- Use
loggerinstead ofconsole.* - Include
moduleandactionin all log context - Never log PHI/PII
- Wrap route modules in
<ErrorBoundary level="feature"> - Use
sanitizeErrorMessage()for user-facing errors - Add
performanceMonitor.startMark()/endMark()for heavy operations