34 lines · 1.5 KB · TypeScript
RawDownload
// ---------------------------------------------------------------------------// Cloud-app implementation of the shared `ErrorCapture` service. This is the// only file in the cloud-app that imports `@sentry/cloudflare` for error// capture — handlers, plugin SDKs, and storage code all stay// Sentry-agnostic and request the `ErrorCapture` tag instead.//// `withObservability` (in @executor/api) wraps every handler effect; when// it sees an unmapped cause it asks `ErrorCapture.captureException` for a// trace id and fails with `InternalError({ traceId })`. The client gets// the opaque id, we get the full cause + stack in Sentry.// --------------------------------------------------------------------------- import * as Sentry from "@sentry/cloudflare";import { Cause, Effect, Layer } from "effect"; import { ErrorCapture } from "@executor/api"; export const ErrorCaptureLive: Layer.Layer<ErrorCapture> = Layer.succeed(  ErrorCapture,  ErrorCapture.of({    captureException: (cause) =>      Effect.sync(() => {        const squashed = Cause.squash(cause);        // Mirror to console so dev terminals see the defect; Sentry gets the        // full structured cause for production correlation.        console.error("[api] unhandled cause:", Cause.pretty(cause));        const eventId = Sentry.captureException(squashed, (scope) => {          scope.setExtra("cause", Cause.pretty(cause));          return scope;        });        return eventId ?? "";      }),  }),);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t