> ## 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.

# Error Handling & Monitoring — Integration Document

> Status: ✅ Complete Last Updated: 2026-03-14

**Status:** ✅ Complete\
**Last Updated:** 2026-03-14

***

## Overview

PF-07 provides platform-wide error handling, structured logging, and performance monitoring infrastructure. All cores consume these services through the `@/platform/monitoring` barrel.

***

## Exported APIs

| Export               | Type      | Description                                                       |
| -------------------- | --------- | ----------------------------------------------------------------- |
| `ErrorBoundary`      | Component | React error boundary with `global`, `feature`, `component` levels |
| `logger`             | Singleton | Structured logger (info/warn/error/critical) with context         |
| `performanceMonitor` | Singleton | Custom marks, page load timing, API histograms                    |
| `initSentry`         | Function  | One-time Sentry SDK initialization (called in `instrument.ts`)    |

**Import path:** `@/platform/monitoring`

***

## Integration Points

### All Cores → PF-07

Every core uses:

* `logger` for structured logging (module prefix identifies the core)
* `ErrorBoundary` for crash isolation
* `sanitizeErrorMessage()` (from `@/shared/lib/error-utils`) for user-facing errors

### PF-07 → Sentry

* Errors, traces, replays, and structured logs are sent to Sentry
* PHI is scrubbed in `beforeSend` before events leave the browser
* Source maps are uploaded via `@sentry/vite-plugin` during CI/CD

### PF-07 → pf\_health\_metrics

* `performanceMonitor` flushes page load, custom mark, and API metrics to `pf_health_metrics` in Supabase

***

## Cross-Core Dependencies

| Core        | Dependency                      | Direction                           |
| ----------- | ------------------------------- | ----------------------------------- |
| All cores   | `@/platform/monitoring`         | Consumer                            |
| PF (auth)   | `logger` + `correlation_id`     | Auth events logged with correlation |
| PF (routes) | `ErrorBoundary level="feature"` | Route-level crash isolation         |

***

## Related Documents

* [MONITORING\_RUNBOOK.md](../../operations/MONITORING_RUNBOOK.md) — Operational procedures
* [Developer Guide: monitoring.md](../../development/monitoring.md) — Developer usage guide
* [PF-07 Spec](../../../specs/pf/specs/PF-07-PHASE-2-3-EXPANSION.md) — Expansion spec
