import { setAsyncLocalStorageAsyncContextStrategy } from './async.js'; import { ensureInstrumented } from './instrument.js'; import { instrumentExportedHandlerEmail } from './instrumentations/worker/instrumentEmail.js'; import { instrumentExportedHandlerFetch } from './instrumentations/worker/instrumentFetch.js'; import { instrumentExportedHandlerQueue } from './instrumentations/worker/instrumentQueue.js'; import { instrumentExportedHandlerScheduled } from './instrumentations/worker/instrumentScheduled.js'; import { instrumentExportedHandlerTail } from './instrumentations/worker/instrumentTail.js'; import { getHonoIntegration } from './integrations/hono.js'; import { isCloudflareClass } from './utils/isCloudflareClass.js'; import { instrumentWorkerEntrypoint } from './instrumentations/instrumentWorkerEntrypoint.js'; function withSentry(optionsCallback, handler) { if (isCloudflareClass(handler, "WorkerEntrypoint")) { return instrumentWorkerEntrypoint(optionsCallback, handler); } setAsyncLocalStorageAsyncContextStrategy(); try { instrumentExportedHandlerFetch(handler, optionsCallback); instrumentHonoErrorHandler(handler); instrumentExportedHandlerScheduled(handler, optionsCallback); instrumentExportedHandlerEmail(handler, optionsCallback); instrumentExportedHandlerQueue(handler, optionsCallback); instrumentExportedHandlerTail(handler, optionsCallback); } catch { } return handler; } function instrumentHonoErrorHandler(handler) { if ("onError" in handler && "errorHandler" in handler && typeof handler.errorHandler === "function") { handler.errorHandler = ensureInstrumented( handler.errorHandler, (original) => new Proxy(original, { apply(target, thisArg, args) { const [err, context] = args; getHonoIntegration()?.handleHonoException(err, context); return Reflect.apply(target, thisArg, args); } }) ); } } export { withSentry }; //# sourceMappingURL=withSentry.js.map