import { setAsyncLocalStorageAsyncContextStrategy } from '../async.js'; import { instrumentWorkerEntrypointFetch } from './worker/instrumentFetch.js'; import { instrumentWorkerEntrypointQueue } from './worker/instrumentQueue.js'; import { instrumentWorkerEntrypointScheduled } from './worker/instrumentScheduled.js'; import { instrumentWorkerEntrypointTail } from './worker/instrumentTail.js'; import { getFinalOptions } from '../options.js'; import { instrumentContext } from '../utils/instrumentContext.js'; import { instrumentEnv } from './worker/instrumentEnv.js'; function instrumentWorkerEntrypoint(optionsCallback, WorkerEntrypointClass) { setAsyncLocalStorageAsyncContextStrategy(); return new Proxy(WorkerEntrypointClass, { construct(target, [ctx, env]) { const context = instrumentContext(ctx); const options = getFinalOptions(optionsCallback(env), env); const instrumentedEnv = instrumentEnv(env, options); const obj = new target(context, instrumentedEnv); if ("ctx" in obj) { Object.defineProperty(obj, "ctx", { value: context, writable: true, enumerable: true, configurable: true }); } if ("env" in obj) { Object.defineProperty(obj, "env", { value: instrumentedEnv, writable: true, enumerable: true, configurable: true }); } Object.defineProperty(obj, "__SENTRY_CONTEXT__", { value: context, enumerable: false, writable: false, configurable: false }); Object.defineProperty(obj, "__SENTRY_OPTIONS__", { value: options, enumerable: false, writable: false, configurable: false }); instrumentWorkerEntrypointFetch(obj, options, context); instrumentWorkerEntrypointScheduled(obj, options, context); instrumentWorkerEntrypointQueue(obj, options, context); instrumentWorkerEntrypointTail(obj, options, context); return obj; } }); } export { instrumentWorkerEntrypoint }; //# sourceMappingURL=instrumentWorkerEntrypoint.js.map