// ---------------------------------------------------------------------------// 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); const eventId = Sentry.captureException(squashed, (scope) => { scope.setExtra("cause", Cause.pretty(cause)); return scope; }); return eventId ?? ""; }), }),);
// ---------------------------------------------------------------------------
// 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);
const eventId = Sentry.captureException(squashed, (scope) => {
scope.setExtra("cause", Cause.pretty(cause));
return scope;
});
return eventId ?? "";
}),
}),
);