docs(agents): bring agent-facing docs in line with the R44 fix
Six docs lagged after the post-merge R44 fix added withCapture + reported-flag.ts. They mentioned withSpan only and described the capture story as if it were inline in use-case / controller bodies. This commit aligns them with what shipped. CLAUDE.md (Key Conventions): - "Spans applied at DI bind time" → "Spans + capture composed at DI bind time" with the withSpan(withCapture(factory)) sandwich and the outermost-span ordering note. - "Capture at throw sites only" expanded to mention the __sentryReported flag, the three flag-checking sites (withCapture, SentryLogger, RecordingLogger), and where the helper lives. AGENTS.md (Instrumentation conventions): - Use case + controller wrapping example shows the full sandwich. - Capture-rules table now explicitly says "via withCapture" for use cases and controllers, and "flag set, withCapture bails" for the bubbled cases. packages/core-shared/AGENTS.md: - "with-span.ts" entry split into a paired with-span + with-capture block, including the actual sandwich code. - New entry for reported-flag.ts explaining the helper and why RecordingLogger inlines the check (boundary rule). - Barrel re-export list updated. docs/architecture/vertical-feature-spec.md (§16): - The bind-production line now describes the withSpan(withCapture(...)) sandwich, the outermost-span rationale, and the bubbled-error bail. docs/architecture/dependency-flow.md (TRACER/LOGGER subsection): - bindAll diagram updated: real repo line annotates inline calls; use case + controller lines show withSpan(withCapture(...)). docs/guides/tdd-workflow.md (Asserting spans and captures): - Direct-injection example shows the binder sandwich. - Capture-assertion example explains the flag-bail behaviour and links to the new tests/r44-no-double-capture.test.ts e2e example. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -46,16 +46,24 @@ Covered areas:
|
||||
- `SentryTracer` / `SentryLogger` — adapters over `@sentry/nextjs`. Live in `sentry/` subfolder. **The `sentry/` subfolder is the only path in `packages/` permitted to import `@sentry/*`** (R40), with the additional exception of `instrumentation/di/bind-sentry-instrumentation.{ts,test.ts}`.
|
||||
- `RecordingTracer` / `RecordingLogger` — in `@repo/core-testing/instrumentation`, not here.
|
||||
|
||||
**`with-span.ts`:** higher-order helper used at DI binding time to wrap use case + controller factory results in a span. Pattern:
|
||||
**`with-span.ts` + `with-capture.ts`:** two higher-order helpers used at DI binding time to wrap use case + controller factory results. The binders apply them as a sandwich — `withSpan` outermost, `withCapture` between span and factory:
|
||||
|
||||
```ts
|
||||
const wrapped = withSpan(
|
||||
tracer,
|
||||
{ name: "blog.getArticles", op: "use-case" },
|
||||
factory(deps),
|
||||
withCapture(
|
||||
logger,
|
||||
{ feature: "blog", layer: "use-case", name: "blog.getArticles" },
|
||||
factory(deps),
|
||||
),
|
||||
);
|
||||
```
|
||||
|
||||
`withSpan` is pure delegation to `tracer.startSpan`. `withCapture` catches thrown errors, calls `logger.captureException(err, { tags })`, marks the `__sentryReported` flag, and re-throws — but bails if the flag is already set so the inner-most layer wins.
|
||||
|
||||
**`reported-flag.ts`:** small module exporting `markReported(err)` and `isReported(err)`. Used by `withCapture` and `SentryLogger`. `RecordingLogger` carries an inlined copy (tooling → core import is disallowed by the boundary rule).
|
||||
|
||||
**Symbols:** `INSTRUMENTATION_SYMBOLS.TRACER`, `INSTRUMENTATION_SYMBOLS.LOGGER` (both `Symbol.for(...)` so cross-realm equality holds).
|
||||
|
||||
**`sentry/scrub.ts`:** PII scrubbers used by every `Sentry.init()` call across the monorepo. Substring-based key matching catches derived names (`userEmail`, `accessToken`, `apiKey`, `ipAddress`). IPv4/IPv6 are also redacted from string values via the `[redacted-ip]` token.
|
||||
@@ -68,7 +76,7 @@ const wrapped = withSpan(
|
||||
|
||||
**Subpath exports** (`package.json#exports`):
|
||||
|
||||
- `./instrumentation` — barrel (interfaces + Noops + withSpan + symbols + binders + node/react init helpers)
|
||||
- `./instrumentation` — barrel (interfaces + Noops + withSpan + withCapture + reported-flag helpers + symbols + binders + node/react init helpers)
|
||||
- `./instrumentation/sentry/init-server` — Next.js server init helper
|
||||
- `./instrumentation/sentry/init-client` — Next.js client init helper
|
||||
- `./instrumentation/sentry/init-server-node` — `@sentry/node` server init (TanStack Start)
|
||||
|
||||
Reference in New Issue
Block a user