Skip to content

πŸͺ’ Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

docs(skills): state the HIPAA compliance boundary in the Sentry PII rule (#15803)

Nikita Kabardin1f6fc5bf6bfa
diff --git a/.agents/skills/sentry-instrumentation/SKILL.md b/.agents/skills/sentry-instrumentation/SKILL.md
index a1d0528dba..29ff70810b 100644
--- a/.agents/skills/sentry-instrumentation/SKILL.md
+++ b/.agents/skills/sentry-instrumentation/SKILL.md
@@ -114,11 +114,25 @@ properly (below).
that only reads the exception value silently never fires on them (the reason
the original invalid-href filter never worked).
-7. **PII β€” never put user content in a message, `extra`, or tag.** No prompt
- text, trace content, tokens, share-link secrets, user/session ids. Respect
- the replay masking already configured for HIPAA/regions in
- `instrumentation-client.ts`. A message that interpolates user data both leaks
- and shatters grouping (Rule 5).
+7. **PII / HIPAA β€” never put user content in a message, `extra`, breadcrumb,
+ or tag.** No prompt text, trace content, tokens, share-link secrets,
+ user/session ids. This is not hygiene β€” it is the compliance boundary: ALL
+ cloud regions, **including HIPAA**, report to the **same US Sentry org**,
+ and error events are **never masked**, so this discipline is the only thing
+ keeping user content out of them. Session Replay is the one masked channel:
+ [`instrumentation-client.ts`](../../../web/instrumentation-client.ts) gates
+ `maskAllText`/`blockAllMedia` so replays are fully masked everywhere except
+ the EU/US non-HIPAA cloud regions. **Never remove or weaken that gate** β€”
+ the gate (`isEuOrUsRegionNonHipaa` β†’ the `replayIntegration` options) must
+ be covered by a CI regression test asserting the masked/unmasked regions on
+ the real module (the mask-guard
+ `instrumentation-client-replay-mask.clienttest.ts`; landing with #15802).
+ Reject any diff that touches the gate without that guard passing, and run
+ every diff touching `instrumentation-client.ts` or replay config through
+ the reviewer checklist in the
+ [reference](references/sentry-capture-contract.md#pii-and-the-hipaa-compliance-boundary).
+ A message that interpolates user data both leaks and shatters grouping
+ (Rule 5).
8. **VERIFY in the environment that actually fires the error.** Router/console
validations run only in the **real client runtime, not jsdom** β€” a green unit
@@ -154,6 +168,8 @@ properly (below).
that reads the wrong event field (Rule 6).
- Interpolating ids/user data into the message β†’ PII + grouping explosion
(Rules 5, 7).
+- Removing/weakening the region-gated replay mask, or "fixing" the mask-guard
+ test instead of the diff that tripped it (Rule 7).
- Trusting a green jsdom test as proof the noise is gone (Rule 8).
- An ad-hoc inline `beforeSend` check instead of a named, tested predicate in
`sentryFilters.ts`.
@@ -161,8 +177,10 @@ properly (below).
## References
- [references/sentry-capture-contract.md](references/sentry-capture-contract.md)
- β€” the capture contract in depth: the shared-helper APIs, the beforeSend /
+ β€” the capture contract in depth: the shared-helper APIs, the PII/HIPAA
+ compliance boundary (replay mask + reviewer checklist), the beforeSend /
denylist authoring protocol (field-reading, negative fixtures), fingerprinting
and `area` tagging, the known noise families, and the shipped-PR case studies
(#15145 / #15173 / #15174 / #15175 / #15238 / #15243 / #15245). Read when
- authoring a suppression rule, hardening a capture path, or triaging a family.
+ authoring a suppression rule, hardening a capture path, touching replay/region
+ config, or triaging a family.
diff --git a/.agents/skills/sentry-instrumentation/references/sentry-capture-contract.md b/.agents/skills/sentry-instrumentation/references/sentry-capture-contract.md
index edb479747c..3032d98f8a 100644
--- a/.agents/skills/sentry-instrumentation/references/sentry-capture-contract.md
+++ b/.agents/skills/sentry-instrumentation/references/sentry-capture-contract.md
@@ -7,6 +7,7 @@ the detail behind its rules.
## Contents
- [Where Sentry is wired](#where-sentry-is-wired)
+- [PII and the HIPAA compliance boundary](#pii-and-the-hipaa-compliance-boundary)
- [The shared capture helpers](#the-shared-capture-helpers)
- [beforeSend / denylist authoring protocol](#beforesend--denylist-authoring-protocol)
- [Fingerprinting, tagging, messages](#fingerprinting-tagging-messages)
@@ -35,6 +36,46 @@ the detail behind its rules.
`UNAUTHORIZED`) there with a breadcrumb and tags the rest
(`trpc.code` / `trpc.path`).
+## PII and the HIPAA compliance boundary
+
+ALL cloud regions β€” **including HIPAA** β€” report to the **same US Sentry org**.
+Two mechanisms keep user content (prompts, traces, PII/PHI) out of it, and they
+cover **different channels**. Do not conflate them.
+
+1. **Session Replay β†’ the region-gated mask.**
+ [`instrumentation-client.ts`](../../../../web/instrumentation-client.ts)
+ configures `replayIntegration({ maskAllText, blockAllMedia })` gated on the
+ cloud region via `isEuOrUsRegionNonHipaa`: replays are **fully masked
+ everywhere except the EU/US non-HIPAA cloud regions** (HIPAA, JP, STAGING,
+ DEV, and self-hosted/unset all mask β€” default-deny). The gate must never be
+ removed or weakened, and it must be covered by a CI regression test that
+ executes the real module per region and fails on any change to the gate
+ (the mask-guard `instrumentation-client-replay-mask.clienttest.ts`; landing
+ with #15802). A diff that trips that guard is a compliance change, not a
+ broken test; a diff that touches the gate without the guard passing must be
+ rejected.
+2. **Error events β†’ the capture discipline (SKILL rule 7).** The mask covers
+ Session Replay ONLY. Error-event payloads β€” message, breadcrumbs, `extra`,
+ tags β€” are **not masked in any region**. The rule "no user content in
+ messages/extra/tags" IS the compliance boundary for error events; there is
+ no downstream scrub to catch a leak. `sendDefaultPii` stays unset (false),
+ so the SDK attaches no cookies, headers, request/response bodies, or user
+ IP.
+
+**Reviewer checklist β€” any diff touching `instrumentation-client.ts`, the
+replay integration, or region gating:**
+
+- `maskAllText`/`blockAllMedia` still derive from the region gate (masked
+ unless the region is exactly `EU` or `US`), and the mask-guard clienttest
+ (landing with #15802) asserts against the real module β€” not a copy of the
+ config or an uncalled predicate.
+- No new replay option weakens masking for masked regions (e.g.
+ `maskAllInputs: false`, unmask/unblock selectors).
+- `sendDefaultPii` remains unset/false; no integration starts attaching
+ bodies, headers, or cookies.
+- Changes to the mask-guard test itself (skipped cases, loosened assertions,
+ region list edits) are reviewed as compliance changes.
+
## The shared capture helpers
Prefer these over a raw `captureException`: