Skip to content

feat: vendor-neutral error-tracking adapter seam via logger sink#13

Open
zaxovaiko wants to merge 4 commits into
devfrom
feat/sentry-error-tracking
Open

feat: vendor-neutral error-tracking adapter seam via logger sink#13
zaxovaiko wants to merge 4 commits into
devfrom
feat/sentry-error-tracking

Conversation

@zaxovaiko

@zaxovaiko zaxovaiko commented Jul 15, 2026

Copy link
Copy Markdown
Member

What

Adds a vendor-neutral ERROR_TRACKING adapter seam so the runtime can report unhandled errors to a vendor (Sentry, PostHog, Rollbar, ...), wired entirely through the logger. Core ships no vendor SDK - the vendor is a consumer overlay.

  • Contract (contracts/adapters/error-tracking.ts): ErrorTrackingAdapter port + ERROR_TRACKING token. Fire-and-forget captureException(error, context?) - a reporter failure never breaks the calling path.
  • Report through the logger (server/kernel/error-sink.ts + logger.ts): createLogger's pino hook forwards any error-level log carrying err to a process-wide error sink. One logger.error({ err }) both logs and reports - no separate captureException call at each site, and every error log is covered rather than a hand-picked set of seams.
  • Bridged in createApp: after plugins load, the sink is wired to whatever ERROR_TRACKING an overlay bound. Unbound -> error logs stay logs-only; the engine imports no vendor SDK and has no SENTRY_DSN of its own.
  • Docs (docs/adapters/error-tracking.md) show the Sentry overlay recipe, mirroring the payment/KYC vendor overlays. Regenerated catalog.

Why

The platform had no error/crash reporting - unhandled errors only reached pino/stdout. This adds reporting while keeping core vendor-neutral: a consumer picks Sentry, PostHog, or anything else via an overlay, with zero vendor code shipped to shops that don't use it.

Acceptance

  • No overlay bound: error logs stay logs-only, platform unchanged, no vendor SDK loaded.
  • Overlay binds ERROR_TRACKING: every logger.error({ err }) is both logged and reported to the vendor.
  • Reporter failures are swallowed and never break the calling path.

Verify

pnpm verify green (typecheck + 60 unit tests + lint + module-shape + boundaries); catalog/openapi no-drift. Rebased on dev, conflicts resolved, lockfile unchanged.

@zaxovaiko zaxovaiko requested a review from agniev-a-hub as a code owner July 15, 2026 10:29
@zaxovaiko zaxovaiko marked this pull request as draft July 15, 2026 11:10
@zaxovaiko zaxovaiko self-assigned this Jul 15, 2026
Add the ERROR_TRACKING port + token so the runtime can report unhandled
errors to a vendor, replaceable via an overlay (PostHog, Rollbar, ...).

- new ErrorTrackingAdapter contract (fire-and-forget captureException)
- NoopErrorTracker default; createSentryErrorTracker auto-binds when
  SENTRY_DSN is set, dynamically importing @sentry/node (optional dep,
  tracing gated on SENTRY_TRACES_SAMPLE_RATE), falling back to no-op if
  the SDK is absent so boot never crashes
- capture at the three previously log-only seams: oRPC onError
  interceptor, event-subscriber failures, outbox-relay drops
- docs/adapters/error-tracking.md + regenerated catalog
…sink

Core named a specific vendor (Sentry) in the engine - createApp imported
createSentryErrorTracker and auto-bound on SENTRY_DSN. That ships Sentry
code to every consumer, even a PostHog shop. Make the seam truly neutral.

- drop the Sentry reference impl + @sentry/node optional dep from core; the
  engine imports no vendor SDK and has no SENTRY_DSN of its own
- report through the logger: createLogger's pino hook forwards any error-level
  log carrying `err` to a process-wide error sink, so one logger.error({ err })
  both logs and reports - no separate captureException at each site, and all
  error logs are covered (not just three seams)
- createApp bridges the sink to whatever ERROR_TRACKING an overlay bound, after
  plugins load; unbound -> error logs stay logs-only
- revert the createEventBus reporter param and the per-site capture calls
- vendors (Sentry, PostHog, ...) become consumer overlays - doc shows the
  Sentry overlay recipe, mirroring the payment/KYC vendor overlays
@zaxovaiko zaxovaiko changed the title feat: error-tracking adapter seam with sentry reference impl feat: vendor-neutral error-tracking adapter seam via logger sink Jul 15, 2026
@zaxovaiko zaxovaiko requested a review from Copilot July 15, 2026 21:24
@zaxovaiko zaxovaiko force-pushed the feat/sentry-error-tracking branch from d0bea38 to 7ffe93f Compare July 15, 2026 21:25
@zaxovaiko zaxovaiko marked this pull request as ready for review July 15, 2026 21:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a vendor-neutral error-tracking “seam” that reports errors via the existing logger pipeline, so consumers can bind a vendor SDK (Sentry/PostHog/Rollbar/…) without core depending on any vendor.

Changes:

  • Introduces an ERROR_TRACKING adapter contract (ErrorTrackingAdapter.captureException) and documents how to bind it via an overlay.
  • Adds a process-wide error sink (error-sink.ts) and wires createLogger to forward error-level logs containing { err } into that sink (including request context metadata).
  • Bridges the sink to the bound adapter in createApp after plugins/configure, and updates the docs catalog.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pnpm-lock.yaml Lockfile updated (includes @opentelemetry/api@1.9.1 optional peer entries).
packages/core/src/server/runtime/create-app.ts Wires the process-wide error sink to the ERROR_TRACKING adapter when present.
packages/core/src/server/kernel/logger.ts Adds a pino hook to mirror qualifying error logs to the error sink with request context.
packages/core/src/server/kernel/index.ts Exports setErrorSink/reportError and the ErrorSink type.
packages/core/src/server/kernel/error-sink.ts Implements the process-wide fire-and-forget error sink.
packages/core/src/server/kernel/tests/logger.test.ts Adds unit tests for the logger → sink forwarding behavior.
packages/core/src/contracts/adapters/index.ts Re-exports the error-tracking adapter types and token.
packages/core/src/contracts/adapters/error-tracking.ts Adds the ErrorTrackingAdapter contract and ERROR_TRACKING token.
docs/catalog.json Catalog entry for the new adapter seam.
docs/adapters/error-tracking.md Documentation and example overlay binding (Sentry).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/src/server/kernel/logger.ts
Comment thread packages/core/src/server/kernel/__tests__/logger.test.ts
Comment thread docs/adapters/error-tracking.md Outdated
@zaxovaiko zaxovaiko force-pushed the feat/sentry-error-tracking branch from 94eb95a to 7ffe93f Compare July 15, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants