← Writing
Healthcare Observability22 Jul 2026 · 6 min read

Configure Sentry Without Leaking PHI

A BAA is a prerequisite when Sentry will receive PHI. The SDK and every downstream integration still need an explicit data boundary.

Sentry is valuable because it collects context around a failure. In a healthcare application, that same context can include patient identity, appointment details, clinical responses, access tokens, or screen content. The goal is not to remove so much data that errors become impossible to debug. It is to make diagnostic context intentional.

For healthcare software development teams, the engineering target is a useful observability system that does not depend on raw patient identity, clinical text, appointment details, or production payloads to debug routine failures.

The right sequence is: confirm contractual coverage, define an allowed telemetry schema, prevent unsafe data from leaving the application, scrub again before storage, and test the complete route through alerts and integrations.

Scope: This guide assumes the organization has independently determined its HIPAA obligations and verified whether its Sentry agreement covers the intended service and features. It is not legal advice.
Gate 1

Confirm the BAA before PHI

Sentry publicly references BAA commitments, but the executed agreement controls. Confirm the legal entity, account, plan, service, region, subprocessors, retention, support, and incident terms. Verify whether errors, tracing, logs, profiling, replay, user feedback, attachments, AI features, and integrations are included.

If the BAA does not cover the intended data path, configure Sentry as a no-PHI service or do not deploy it in that workflow. A compliance page or HIPAA attestation is not a substitute for the agreement.

Gate 2

Inventory every capture surface

Errors

Messages, exception values, stack frames, local variables, causes, attachments, and manually added context.

Requests

URLs, query strings, headers, cookies, bodies, GraphQL variables, route parameters, and IP addresses.

Activity

Breadcrumbs, console logs, navigation, network calls, feature flags, and user feedback.

Rich telemetry

Traces, profiles, session replay, screenshots, AI inputs and outputs, and downstream integrations.

Do not rely on memory or SDK defaults. Trigger representative frontend, backend, mobile, API, and integration failures and inspect the stored event field by field.

SDK boundary

Filter before transmission

Keep default PII collection disabled unless a documented requirement and agreement support it. Use the SDK's event and breadcrumb hooks to remove unsafe fields, normalize URLs, replace exception text with controlled error codes, and drop events that cannot be made safe.

Sentry.init({
  dsn: SENTRY_DSN,
  sendDefaultPii: false,
  beforeBreadcrumb: sanitizeBreadcrumb,
  beforeSend(event) {
    return sanitizeAndValidate(event);
  }
});

This is an architectural sketch, not a complete sanitizer. The implementation should use explicit allowlists for tags, contexts, request fields, and extra data. A recursive list of suspicious field names is useful as a backstop, but it cannot understand every clinical value or free-text message.

High-risk fields

Normalize before you capture

FieldRiskSafer pattern
URLPatient IDs, emails, appointment IDs, search termsControlled route template such as /patients/:id/results
Error messageBackend or validation text may echo inputStable error code and component name
Request bodyForms and API payloads may contain full clinical recordsDo not attach; keep only approved metadata
User contextName, email, medical record number, account detailsOmit or use a narrowly governed opaque incident token
BreadcrumbClicked labels, navigation text, console outputAllowlisted action and route category
Local variablesApplication objects may contain credentials or PHIDisable unless a reviewed need justifies capture
Avoid: Failed to load labs for Jane Doe, MRN 48291
Prefer: LAB_RESULT_LOAD_FAILED | actor=patient | route=results_list
Second boundary

Enable server-side scrubbing

Sentry provides organization and project controls for server-side data scrubbing, default sensitive-field rules, custom sensitive fields, advanced scrubbing rules, and IP-address removal. Configure these as a second layer so a missed SDK path is less likely to be stored.

Prefer removal over masking when the field has no diagnostic value. Add application-specific names such as patient, member, appointment, encounter, medical record, date of birth, phone, email, token, and authorization fields. Test nested objects and alternative naming conventions.

Scrubbing usually applies to new incoming events. It does not retroactively clean data already stored, so define a deletion and incident process for accidental collection.

Session replay

Keep replay off until proven safe

Replay can expose rendered text, user input, DOM structure, network details, and interactions across a patient workflow. Default masking is helpful, but a healthcare review should not assume that every custom component, canvas, native view, third-party widget, or future screen is covered.

Start without replay. If the product case justifies it, confirm BAA scope, block sensitive routes and elements, mask text and inputs, block media, restrict network payload capture, lower sampling, restrict replay access, and test every patient-facing state. Repeat that review when the UI changes.

Logs and traces

Observability features share the same risk

Logs can capture formatted objects, prompts, responses, SQL parameters, and support details. Traces can record URLs, operation names, database statements, and service metadata. Profiles and local-variable capture may expose memory values that were never intended as telemetry.

Use structured, categorical fields. Disable input and output recording for AI integrations unless the exact workflow has been reviewed. Avoid raw database statements and dynamic transaction names containing identifiers. Apply the same allowlist across errors, logs, traces, and alerts.

Destinations

Review alerts, support, and integrations

A clean event can become an unsafe disclosure when an alert template includes the wrong field or an integration copies event data into email, chat, issue tracking, source control, or an AI assistant. Map each destination and confirm its agreement, access, retention, and purpose.

Keep notification content minimal. Link authorized staff back to Sentry instead of copying complete payloads into broader collaboration channels. Disable anonymous issue sharing and restrict who can view, export, delete, or administer production data.

Verification

Test the failure path, not just the happy path

  1. Create synthetic test values resembling names, emails, phone numbers, record numbers, dates, tokens, and clinical free text.
  2. Place them in URLs, headers, bodies, exception messages, breadcrumbs, logs, local variables, and replayed screens.
  3. Trigger frontend, backend, mobile, network, validation, and unhandled failures.
  4. Inspect the event received by Sentry, not only the application payload before sending.
  5. Inspect alerts, exports, replays, issue-tracker entries, and chat notifications.
  6. Verify deletion, access logs, retention, and incident escalation.
  7. Repeat the suite when SDKs, integrations, schemas, or product features change.
Related reading

Complete the review

Responding to Suspected PHI Exposure

Contain unsafe telemetry, preserve evidence, revoke access, assess scope, escalate the vendor, and recover safely.

Sentry vs Crashlytics

Compare vendor terms, PHI paths, and the appropriate use of each tool.

Healthcare Software Development

Connect observability, PHI handling, cloud architecture, integrations, and delivery planning.

HIPAA Vendor Checklist

Review BAA scope, features, subprocessors, retention, access, and incidents.

Official references: Sentry SDK options, Sentry replay privacy, and Sentry organization privacy and scrubbing controls.