@sentry/cloudflare 11.12.0 → 11.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/dev/_virtual/_rolldown/runtime.js +22 -0
- package/build/cjs/dev/baseSdk.js +98 -103
- package/build/cjs/dev/baseSdk.js.map +1 -1
- package/build/cjs/dev/client.js +213 -237
- package/build/cjs/dev/client.js.map +1 -1
- package/build/cjs/dev/clientCache.js +8 -8
- package/build/cjs/dev/clientCache.js.map +1 -1
- package/build/cjs/dev/debug-build.js +9 -5
- package/build/cjs/dev/debug-build.js.map +1 -1
- package/build/cjs/dev/defineCloudflareOptions.js +5 -8
- package/build/cjs/dev/defineCloudflareOptions.js.map +1 -1
- package/build/cjs/dev/durableobject.js +287 -176
- package/build/cjs/dev/durableobject.js.map +1 -1
- package/build/cjs/dev/flush.js +104 -77
- package/build/cjs/dev/flush.js.map +1 -1
- package/build/cjs/dev/index.js +181 -182
- package/build/cjs/dev/instrument.js +53 -39
- package/build/cjs/dev/instrument.js.map +1 -1
- package/build/cjs/dev/instrumentations/agents/index.js +34 -13
- package/build/cjs/dev/instrumentations/agents/index.js.map +1 -1
- package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js +46 -49
- package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
- package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js +23 -16
- package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
- package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js +36 -28
- package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
- package/build/cjs/dev/instrumentations/agents/types.js +103 -58
- package/build/cjs/dev/instrumentations/agents/types.js.map +1 -1
- package/build/cjs/dev/instrumentations/instrumentDurableObjectHandlers.js +87 -118
- package/build/cjs/dev/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
- package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js +46 -44
- package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
- package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js +70 -71
- package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -39
- package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
- package/build/cjs/dev/instrumentations/instrumentSqlStorage.js +50 -52
- package/build/cjs/dev/instrumentations/instrumentSqlStorage.js.map +1 -1
- package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js +136 -123
- package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentD1.js +131 -146
- package/build/cjs/dev/instrumentations/worker/instrumentD1.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentEmail.js +63 -61
- package/build/cjs/dev/instrumentations/worker/instrumentEmail.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentEnv.js +83 -88
- package/build/cjs/dev/instrumentations/worker/instrumentEnv.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentFetch.js +41 -48
- package/build/cjs/dev/instrumentations/worker/instrumentFetch.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentFetcher.js +25 -21
- package/build/cjs/dev/instrumentations/worker/instrumentFetcher.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentKV.js +54 -67
- package/build/cjs/dev/instrumentations/worker/instrumentKV.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentQueue.js +98 -105
- package/build/cjs/dev/instrumentations/worker/instrumentQueue.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js +88 -94
- package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentR2.js +128 -115
- package/build/cjs/dev/instrumentations/worker/instrumentR2.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js +90 -94
- package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentTail.js +100 -55
- package/build/cjs/dev/instrumentations/worker/instrumentTail.js.map +1 -1
- package/build/cjs/dev/integrations/cronTriggers.js +130 -85
- package/build/cjs/dev/integrations/cronTriggers.js.map +1 -1
- package/build/cjs/dev/integrations/fetch.js +9 -9
- package/build/cjs/dev/integrations/fetch.js.map +1 -1
- package/build/cjs/dev/integrations/httpServer.js +41 -22
- package/build/cjs/dev/integrations/httpServer.js.map +1 -1
- package/build/cjs/dev/integrations/spotlight.js +52 -55
- package/build/cjs/dev/integrations/spotlight.js.map +1 -1
- package/build/cjs/dev/opentelemetry/tracer.js +10 -8
- package/build/cjs/dev/opentelemetry/tracer.js.map +1 -1
- package/build/cjs/dev/options.js +55 -39
- package/build/cjs/dev/options.js.map +1 -1
- package/build/cjs/dev/orchestrion-deferred-channels.js +45 -29
- package/build/cjs/dev/orchestrion-deferred-channels.js.map +1 -1
- package/build/cjs/dev/orchestrion-diagnostics-channel.js +97 -72
- package/build/cjs/dev/orchestrion-diagnostics-channel.js.map +1 -1
- package/build/cjs/dev/pages-plugin.js +20 -21
- package/build/cjs/dev/pages-plugin.js.map +1 -1
- package/build/cjs/dev/request.js +16 -10
- package/build/cjs/dev/request.js.map +1 -1
- package/build/cjs/dev/scope-utils.js +12 -12
- package/build/cjs/dev/scope-utils.js.map +1 -1
- package/build/cjs/dev/sdk.js +24 -15
- package/build/cjs/dev/sdk.js.map +1 -1
- package/build/cjs/dev/transport.js +93 -86
- package/build/cjs/dev/transport.js.map +1 -1
- package/build/cjs/dev/utils/asyncContextStrategy.js +10 -10
- package/build/cjs/dev/utils/asyncContextStrategy.js.map +1 -1
- package/build/cjs/dev/utils/bindingPropagation.js +17 -11
- package/build/cjs/dev/utils/bindingPropagation.js.map +1 -1
- package/build/cjs/dev/utils/cloudflareTrace.js +34 -0
- package/build/cjs/dev/utils/cloudflareTrace.js.map +1 -0
- package/build/cjs/dev/utils/instrumentContext.js +74 -58
- package/build/cjs/dev/utils/instrumentContext.js.map +1 -1
- package/build/cjs/dev/utils/internalSqlQuery.js +38 -21
- package/build/cjs/dev/utils/internalSqlQuery.js.map +1 -1
- package/build/cjs/dev/utils/internalStorageKey.js +41 -38
- package/build/cjs/dev/utils/internalStorageKey.js.map +1 -1
- package/build/cjs/dev/utils/invocationContext.js +42 -32
- package/build/cjs/dev/utils/invocationContext.js.map +1 -1
- package/build/cjs/dev/utils/invocationScope.js +45 -21
- package/build/cjs/dev/utils/invocationScope.js.map +1 -1
- package/build/cjs/dev/utils/isBinding.js +47 -15
- package/build/cjs/dev/utils/isBinding.js.map +1 -1
- package/build/cjs/dev/utils/isCloudflareClass.js +11 -20
- package/build/cjs/dev/utils/isCloudflareClass.js.map +1 -1
- package/build/cjs/dev/utils/queueTraceMeta.js +24 -35
- package/build/cjs/dev/utils/queueTraceMeta.js.map +1 -1
- package/build/cjs/dev/utils/rpcMeta.js +37 -27
- package/build/cjs/dev/utils/rpcMeta.js.map +1 -1
- package/build/cjs/dev/utils/traceLinks.js +52 -42
- package/build/cjs/dev/utils/traceLinks.js.map +1 -1
- package/build/cjs/dev/vendor/stacktrace.js +32 -24
- package/build/cjs/dev/vendor/stacktrace.js.map +1 -1
- package/build/cjs/dev/vite/agentClass.js +105 -98
- package/build/cjs/dev/vite/agentClass.js.map +1 -1
- package/build/cjs/dev/vite/autoInstrument.js +121 -122
- package/build/cjs/dev/vite/autoInstrument.js.map +1 -1
- package/build/cjs/dev/vite/index.js +44 -21
- package/build/cjs/dev/vite/index.js.map +1 -1
- package/build/cjs/dev/vite/instrumentFile.js +37 -20
- package/build/cjs/dev/vite/instrumentFile.js.map +1 -1
- package/build/cjs/dev/vite/mastraObservability.js +19 -12
- package/build/cjs/dev/vite/mastraObservability.js.map +1 -1
- package/build/cjs/dev/vite/moduleShape.js +220 -201
- package/build/cjs/dev/vite/moduleShape.js.map +1 -1
- package/build/cjs/dev/vite/providedModulePlugin.js +62 -45
- package/build/cjs/dev/vite/providedModulePlugin.js.map +1 -1
- package/build/cjs/dev/vite/transform.js +333 -284
- package/build/cjs/dev/vite/transform.js.map +1 -1
- package/build/cjs/dev/vite/workerEntrypoint.js +66 -57
- package/build/cjs/dev/vite/workerEntrypoint.js.map +1 -1
- package/build/cjs/dev/vite/wranglerConfig.js +92 -67
- package/build/cjs/dev/vite/wranglerConfig.js.map +1 -1
- package/build/cjs/dev/withSentry.js +32 -26
- package/build/cjs/dev/withSentry.js.map +1 -1
- package/build/cjs/dev/workflows.js +164 -151
- package/build/cjs/dev/workflows.js.map +1 -1
- package/build/cjs/dev/wrapMethodWithSentry.js +148 -169
- package/build/cjs/dev/wrapMethodWithSentry.js.map +1 -1
- package/build/cjs/dev/wrapRequestHandlerWithInit.js +76 -78
- package/build/cjs/dev/wrapRequestHandlerWithInit.js.map +1 -1
- package/build/cjs/prod/_virtual/_rolldown/runtime.js +22 -0
- package/build/cjs/prod/baseSdk.js +94 -93
- package/build/cjs/prod/baseSdk.js.map +1 -1
- package/build/cjs/prod/client.js +213 -237
- package/build/cjs/prod/client.js.map +1 -1
- package/build/cjs/prod/clientCache.js +8 -8
- package/build/cjs/prod/clientCache.js.map +1 -1
- package/build/cjs/prod/debug-build.js +9 -5
- package/build/cjs/prod/debug-build.js.map +1 -1
- package/build/cjs/prod/defineCloudflareOptions.js +5 -8
- package/build/cjs/prod/defineCloudflareOptions.js.map +1 -1
- package/build/cjs/prod/durableobject.js +287 -176
- package/build/cjs/prod/durableobject.js.map +1 -1
- package/build/cjs/prod/flush.js +104 -77
- package/build/cjs/prod/flush.js.map +1 -1
- package/build/cjs/prod/index.js +181 -182
- package/build/cjs/prod/instrument.js +53 -39
- package/build/cjs/prod/instrument.js.map +1 -1
- package/build/cjs/prod/instrumentations/agents/index.js +34 -13
- package/build/cjs/prod/instrumentations/agents/index.js.map +1 -1
- package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js +46 -49
- package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
- package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js +23 -16
- package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
- package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js +36 -28
- package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
- package/build/cjs/prod/instrumentations/agents/types.js +103 -58
- package/build/cjs/prod/instrumentations/agents/types.js.map +1 -1
- package/build/cjs/prod/instrumentations/instrumentDurableObjectHandlers.js +87 -118
- package/build/cjs/prod/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
- package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js +46 -44
- package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
- package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js +70 -71
- package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -39
- package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
- package/build/cjs/prod/instrumentations/instrumentSqlStorage.js +50 -52
- package/build/cjs/prod/instrumentations/instrumentSqlStorage.js.map +1 -1
- package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js +136 -123
- package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentD1.js +131 -146
- package/build/cjs/prod/instrumentations/worker/instrumentD1.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentEmail.js +63 -61
- package/build/cjs/prod/instrumentations/worker/instrumentEmail.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentEnv.js +83 -88
- package/build/cjs/prod/instrumentations/worker/instrumentEnv.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentFetch.js +41 -48
- package/build/cjs/prod/instrumentations/worker/instrumentFetch.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js +25 -21
- package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentKV.js +54 -67
- package/build/cjs/prod/instrumentations/worker/instrumentKV.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentQueue.js +98 -105
- package/build/cjs/prod/instrumentations/worker/instrumentQueue.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js +88 -94
- package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentR2.js +128 -115
- package/build/cjs/prod/instrumentations/worker/instrumentR2.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js +90 -94
- package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentTail.js +100 -55
- package/build/cjs/prod/instrumentations/worker/instrumentTail.js.map +1 -1
- package/build/cjs/prod/integrations/cronTriggers.js +130 -85
- package/build/cjs/prod/integrations/cronTriggers.js.map +1 -1
- package/build/cjs/prod/integrations/fetch.js +9 -9
- package/build/cjs/prod/integrations/fetch.js.map +1 -1
- package/build/cjs/prod/integrations/httpServer.js +41 -22
- package/build/cjs/prod/integrations/httpServer.js.map +1 -1
- package/build/cjs/prod/integrations/spotlight.js +52 -55
- package/build/cjs/prod/integrations/spotlight.js.map +1 -1
- package/build/cjs/prod/opentelemetry/tracer.js +10 -8
- package/build/cjs/prod/opentelemetry/tracer.js.map +1 -1
- package/build/cjs/prod/options.js +37 -24
- package/build/cjs/prod/options.js.map +1 -1
- package/build/cjs/prod/orchestrion-deferred-channels.js +45 -29
- package/build/cjs/prod/orchestrion-deferred-channels.js.map +1 -1
- package/build/cjs/prod/orchestrion-diagnostics-channel.js +97 -72
- package/build/cjs/prod/orchestrion-diagnostics-channel.js.map +1 -1
- package/build/cjs/prod/pages-plugin.js +20 -21
- package/build/cjs/prod/pages-plugin.js.map +1 -1
- package/build/cjs/prod/request.js +16 -10
- package/build/cjs/prod/request.js.map +1 -1
- package/build/cjs/prod/scope-utils.js +12 -12
- package/build/cjs/prod/scope-utils.js.map +1 -1
- package/build/cjs/prod/sdk.js +24 -15
- package/build/cjs/prod/sdk.js.map +1 -1
- package/build/cjs/prod/transport.js +93 -86
- package/build/cjs/prod/transport.js.map +1 -1
- package/build/cjs/prod/utils/asyncContextStrategy.js +10 -10
- package/build/cjs/prod/utils/asyncContextStrategy.js.map +1 -1
- package/build/cjs/prod/utils/bindingPropagation.js +17 -11
- package/build/cjs/prod/utils/bindingPropagation.js.map +1 -1
- package/build/cjs/prod/utils/cloudflareTrace.js +34 -0
- package/build/cjs/prod/utils/cloudflareTrace.js.map +1 -0
- package/build/cjs/prod/utils/instrumentContext.js +74 -58
- package/build/cjs/prod/utils/instrumentContext.js.map +1 -1
- package/build/cjs/prod/utils/internalSqlQuery.js +38 -21
- package/build/cjs/prod/utils/internalSqlQuery.js.map +1 -1
- package/build/cjs/prod/utils/internalStorageKey.js +41 -38
- package/build/cjs/prod/utils/internalStorageKey.js.map +1 -1
- package/build/cjs/prod/utils/invocationContext.js +42 -32
- package/build/cjs/prod/utils/invocationContext.js.map +1 -1
- package/build/cjs/prod/utils/invocationScope.js +45 -21
- package/build/cjs/prod/utils/invocationScope.js.map +1 -1
- package/build/cjs/prod/utils/isBinding.js +47 -15
- package/build/cjs/prod/utils/isBinding.js.map +1 -1
- package/build/cjs/prod/utils/isCloudflareClass.js +11 -20
- package/build/cjs/prod/utils/isCloudflareClass.js.map +1 -1
- package/build/cjs/prod/utils/queueTraceMeta.js +24 -35
- package/build/cjs/prod/utils/queueTraceMeta.js.map +1 -1
- package/build/cjs/prod/utils/rpcMeta.js +37 -27
- package/build/cjs/prod/utils/rpcMeta.js.map +1 -1
- package/build/cjs/prod/utils/traceLinks.js +52 -42
- package/build/cjs/prod/utils/traceLinks.js.map +1 -1
- package/build/cjs/prod/vendor/stacktrace.js +32 -24
- package/build/cjs/prod/vendor/stacktrace.js.map +1 -1
- package/build/cjs/prod/vite/agentClass.js +105 -98
- package/build/cjs/prod/vite/agentClass.js.map +1 -1
- package/build/cjs/prod/vite/autoInstrument.js +121 -122
- package/build/cjs/prod/vite/autoInstrument.js.map +1 -1
- package/build/cjs/prod/vite/index.js +44 -21
- package/build/cjs/prod/vite/index.js.map +1 -1
- package/build/cjs/prod/vite/instrumentFile.js +37 -20
- package/build/cjs/prod/vite/instrumentFile.js.map +1 -1
- package/build/cjs/prod/vite/mastraObservability.js +19 -12
- package/build/cjs/prod/vite/mastraObservability.js.map +1 -1
- package/build/cjs/prod/vite/moduleShape.js +220 -201
- package/build/cjs/prod/vite/moduleShape.js.map +1 -1
- package/build/cjs/prod/vite/providedModulePlugin.js +62 -45
- package/build/cjs/prod/vite/providedModulePlugin.js.map +1 -1
- package/build/cjs/prod/vite/transform.js +333 -284
- package/build/cjs/prod/vite/transform.js.map +1 -1
- package/build/cjs/prod/vite/workerEntrypoint.js +66 -57
- package/build/cjs/prod/vite/workerEntrypoint.js.map +1 -1
- package/build/cjs/prod/vite/wranglerConfig.js +92 -67
- package/build/cjs/prod/vite/wranglerConfig.js.map +1 -1
- package/build/cjs/prod/withSentry.js +32 -26
- package/build/cjs/prod/withSentry.js.map +1 -1
- package/build/cjs/prod/workflows.js +164 -151
- package/build/cjs/prod/workflows.js.map +1 -1
- package/build/cjs/prod/wrapMethodWithSentry.js +148 -169
- package/build/cjs/prod/wrapMethodWithSentry.js.map +1 -1
- package/build/cjs/prod/wrapRequestHandlerWithInit.js +76 -78
- package/build/cjs/prod/wrapRequestHandlerWithInit.js.map +1 -1
- package/build/esm/dev/baseSdk.js +98 -101
- package/build/esm/dev/baseSdk.js.map +1 -1
- package/build/esm/dev/client.js +213 -235
- package/build/esm/dev/client.js.map +1 -1
- package/build/esm/dev/clientCache.js +8 -6
- package/build/esm/dev/clientCache.js.map +1 -1
- package/build/esm/dev/debug-build.js +9 -3
- package/build/esm/dev/debug-build.js.map +1 -1
- package/build/esm/dev/defineCloudflareOptions.js +5 -6
- package/build/esm/dev/defineCloudflareOptions.js.map +1 -1
- package/build/esm/dev/durableobject.js +287 -174
- package/build/esm/dev/durableobject.js.map +1 -1
- package/build/esm/dev/flush.js +104 -75
- package/build/esm/dev/flush.js.map +1 -1
- package/build/esm/dev/index.js +19 -18
- package/build/esm/dev/instrument.js +53 -37
- package/build/esm/dev/instrument.js.map +1 -1
- package/build/esm/dev/instrumentations/agents/index.js +34 -11
- package/build/esm/dev/instrumentations/agents/index.js.map +1 -1
- package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js +46 -47
- package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
- package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js +23 -14
- package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
- package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js +36 -26
- package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
- package/build/esm/dev/instrumentations/agents/types.js +103 -56
- package/build/esm/dev/instrumentations/agents/types.js.map +1 -1
- package/build/esm/dev/instrumentations/instrumentDurableObjectHandlers.js +87 -116
- package/build/esm/dev/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
- package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js +46 -42
- package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
- package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js +70 -69
- package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -37
- package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
- package/build/esm/dev/instrumentations/instrumentSqlStorage.js +50 -50
- package/build/esm/dev/instrumentations/instrumentSqlStorage.js.map +1 -1
- package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js +136 -121
- package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentD1.js +131 -144
- package/build/esm/dev/instrumentations/worker/instrumentD1.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentEmail.js +63 -59
- package/build/esm/dev/instrumentations/worker/instrumentEmail.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentEnv.js +83 -86
- package/build/esm/dev/instrumentations/worker/instrumentEnv.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentFetch.js +41 -46
- package/build/esm/dev/instrumentations/worker/instrumentFetch.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentFetcher.js +25 -19
- package/build/esm/dev/instrumentations/worker/instrumentFetcher.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentKV.js +54 -65
- package/build/esm/dev/instrumentations/worker/instrumentKV.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentQueue.js +98 -103
- package/build/esm/dev/instrumentations/worker/instrumentQueue.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js +88 -92
- package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentR2.js +128 -113
- package/build/esm/dev/instrumentations/worker/instrumentR2.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentScheduled.js +90 -92
- package/build/esm/dev/instrumentations/worker/instrumentScheduled.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentTail.js +100 -53
- package/build/esm/dev/instrumentations/worker/instrumentTail.js.map +1 -1
- package/build/esm/dev/integrations/cronTriggers.js +129 -82
- package/build/esm/dev/integrations/cronTriggers.js.map +1 -1
- package/build/esm/dev/integrations/fetch.js +9 -6
- package/build/esm/dev/integrations/fetch.js.map +1 -1
- package/build/esm/dev/integrations/httpServer.js +40 -19
- package/build/esm/dev/integrations/httpServer.js.map +1 -1
- package/build/esm/dev/integrations/spotlight.js +51 -52
- package/build/esm/dev/integrations/spotlight.js.map +1 -1
- package/build/esm/dev/opentelemetry/tracer.js +10 -6
- package/build/esm/dev/opentelemetry/tracer.js.map +1 -1
- package/build/esm/dev/options.js +55 -37
- package/build/esm/dev/options.js.map +1 -1
- package/build/esm/dev/orchestrion-deferred-channels.js +45 -27
- package/build/esm/dev/orchestrion-deferred-channels.js.map +1 -1
- package/build/esm/dev/orchestrion-diagnostics-channel.js +87 -66
- package/build/esm/dev/orchestrion-diagnostics-channel.js.map +1 -1
- package/build/esm/dev/package.json +1 -1
- package/build/esm/dev/pages-plugin.js +20 -19
- package/build/esm/dev/pages-plugin.js.map +1 -1
- package/build/esm/dev/request.js +14 -7
- package/build/esm/dev/request.js.map +1 -1
- package/build/esm/dev/scope-utils.js +12 -10
- package/build/esm/dev/scope-utils.js.map +1 -1
- package/build/esm/dev/sdk.js +23 -13
- package/build/esm/dev/sdk.js.map +1 -1
- package/build/esm/dev/transport.js +93 -84
- package/build/esm/dev/transport.js.map +1 -1
- package/build/esm/dev/utils/asyncContextStrategy.js +10 -8
- package/build/esm/dev/utils/asyncContextStrategy.js.map +1 -1
- package/build/esm/dev/utils/bindingPropagation.js +17 -9
- package/build/esm/dev/utils/bindingPropagation.js.map +1 -1
- package/build/esm/dev/utils/cloudflareTrace.js +34 -0
- package/build/esm/dev/utils/cloudflareTrace.js.map +1 -0
- package/build/esm/dev/utils/instrumentContext.js +74 -56
- package/build/esm/dev/utils/instrumentContext.js.map +1 -1
- package/build/esm/dev/utils/internalSqlQuery.js +38 -19
- package/build/esm/dev/utils/internalSqlQuery.js.map +1 -1
- package/build/esm/dev/utils/internalStorageKey.js +41 -36
- package/build/esm/dev/utils/internalStorageKey.js.map +1 -1
- package/build/esm/dev/utils/invocationContext.js +42 -30
- package/build/esm/dev/utils/invocationContext.js.map +1 -1
- package/build/esm/dev/utils/invocationScope.js +45 -19
- package/build/esm/dev/utils/invocationScope.js.map +1 -1
- package/build/esm/dev/utils/isBinding.js +47 -13
- package/build/esm/dev/utils/isBinding.js.map +1 -1
- package/build/esm/dev/utils/isCloudflareClass.js +11 -18
- package/build/esm/dev/utils/isCloudflareClass.js.map +1 -1
- package/build/esm/dev/utils/queueTraceMeta.js +24 -33
- package/build/esm/dev/utils/queueTraceMeta.js.map +1 -1
- package/build/esm/dev/utils/rpcMeta.js +37 -25
- package/build/esm/dev/utils/rpcMeta.js.map +1 -1
- package/build/esm/dev/utils/traceLinks.js +52 -40
- package/build/esm/dev/utils/traceLinks.js.map +1 -1
- package/build/esm/dev/vendor/stacktrace.js +31 -21
- package/build/esm/dev/vendor/stacktrace.js.map +1 -1
- package/build/esm/dev/vite/agentClass.js +105 -96
- package/build/esm/dev/vite/agentClass.js.map +1 -1
- package/build/esm/dev/vite/autoInstrument.js +121 -120
- package/build/esm/dev/vite/autoInstrument.js.map +1 -1
- package/build/esm/dev/vite/index.js +43 -19
- package/build/esm/dev/vite/index.js.map +1 -1
- package/build/esm/dev/vite/instrumentFile.js +37 -18
- package/build/esm/dev/vite/instrumentFile.js.map +1 -1
- package/build/esm/dev/vite/mastraObservability.js +19 -10
- package/build/esm/dev/vite/mastraObservability.js.map +1 -1
- package/build/esm/dev/vite/moduleShape.js +220 -199
- package/build/esm/dev/vite/moduleShape.js.map +1 -1
- package/build/esm/dev/vite/providedModulePlugin.js +60 -43
- package/build/esm/dev/vite/providedModulePlugin.js.map +1 -1
- package/build/esm/dev/vite/transform.js +331 -282
- package/build/esm/dev/vite/transform.js.map +1 -1
- package/build/esm/dev/vite/workerEntrypoint.js +66 -55
- package/build/esm/dev/vite/workerEntrypoint.js.map +1 -1
- package/build/esm/dev/vite/wranglerConfig.js +92 -65
- package/build/esm/dev/vite/wranglerConfig.js.map +1 -1
- package/build/esm/dev/withSentry.js +32 -24
- package/build/esm/dev/withSentry.js.map +1 -1
- package/build/esm/dev/workflows.js +164 -149
- package/build/esm/dev/workflows.js.map +1 -1
- package/build/esm/dev/wrapMethodWithSentry.js +148 -167
- package/build/esm/dev/wrapMethodWithSentry.js.map +1 -1
- package/build/esm/dev/wrapRequestHandlerWithInit.js +76 -76
- package/build/esm/dev/wrapRequestHandlerWithInit.js.map +1 -1
- package/build/esm/prod/baseSdk.js +94 -91
- package/build/esm/prod/baseSdk.js.map +1 -1
- package/build/esm/prod/client.js +213 -235
- package/build/esm/prod/client.js.map +1 -1
- package/build/esm/prod/clientCache.js +8 -6
- package/build/esm/prod/clientCache.js.map +1 -1
- package/build/esm/prod/debug-build.js +9 -3
- package/build/esm/prod/debug-build.js.map +1 -1
- package/build/esm/prod/defineCloudflareOptions.js +5 -6
- package/build/esm/prod/defineCloudflareOptions.js.map +1 -1
- package/build/esm/prod/durableobject.js +287 -174
- package/build/esm/prod/durableobject.js.map +1 -1
- package/build/esm/prod/flush.js +104 -75
- package/build/esm/prod/flush.js.map +1 -1
- package/build/esm/prod/index.js +19 -18
- package/build/esm/prod/instrument.js +53 -37
- package/build/esm/prod/instrument.js.map +1 -1
- package/build/esm/prod/instrumentations/agents/index.js +34 -11
- package/build/esm/prod/instrumentations/agents/index.js.map +1 -1
- package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js +46 -47
- package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
- package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js +23 -14
- package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
- package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js +36 -26
- package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
- package/build/esm/prod/instrumentations/agents/types.js +103 -56
- package/build/esm/prod/instrumentations/agents/types.js.map +1 -1
- package/build/esm/prod/instrumentations/instrumentDurableObjectHandlers.js +87 -116
- package/build/esm/prod/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
- package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js +46 -42
- package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
- package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js +70 -69
- package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -37
- package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
- package/build/esm/prod/instrumentations/instrumentSqlStorage.js +50 -50
- package/build/esm/prod/instrumentations/instrumentSqlStorage.js.map +1 -1
- package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js +136 -121
- package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentD1.js +131 -144
- package/build/esm/prod/instrumentations/worker/instrumentD1.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentEmail.js +63 -59
- package/build/esm/prod/instrumentations/worker/instrumentEmail.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentEnv.js +83 -86
- package/build/esm/prod/instrumentations/worker/instrumentEnv.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentFetch.js +41 -46
- package/build/esm/prod/instrumentations/worker/instrumentFetch.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentFetcher.js +25 -19
- package/build/esm/prod/instrumentations/worker/instrumentFetcher.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentKV.js +54 -65
- package/build/esm/prod/instrumentations/worker/instrumentKV.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentQueue.js +98 -103
- package/build/esm/prod/instrumentations/worker/instrumentQueue.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js +88 -92
- package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentR2.js +128 -113
- package/build/esm/prod/instrumentations/worker/instrumentR2.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentScheduled.js +90 -92
- package/build/esm/prod/instrumentations/worker/instrumentScheduled.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentTail.js +100 -53
- package/build/esm/prod/instrumentations/worker/instrumentTail.js.map +1 -1
- package/build/esm/prod/integrations/cronTriggers.js +129 -82
- package/build/esm/prod/integrations/cronTriggers.js.map +1 -1
- package/build/esm/prod/integrations/fetch.js +9 -6
- package/build/esm/prod/integrations/fetch.js.map +1 -1
- package/build/esm/prod/integrations/httpServer.js +40 -19
- package/build/esm/prod/integrations/httpServer.js.map +1 -1
- package/build/esm/prod/integrations/spotlight.js +51 -52
- package/build/esm/prod/integrations/spotlight.js.map +1 -1
- package/build/esm/prod/opentelemetry/tracer.js +10 -6
- package/build/esm/prod/opentelemetry/tracer.js.map +1 -1
- package/build/esm/prod/options.js +37 -22
- package/build/esm/prod/options.js.map +1 -1
- package/build/esm/prod/orchestrion-deferred-channels.js +45 -27
- package/build/esm/prod/orchestrion-deferred-channels.js.map +1 -1
- package/build/esm/prod/orchestrion-diagnostics-channel.js +87 -66
- package/build/esm/prod/orchestrion-diagnostics-channel.js.map +1 -1
- package/build/esm/prod/package.json +1 -1
- package/build/esm/prod/pages-plugin.js +20 -19
- package/build/esm/prod/pages-plugin.js.map +1 -1
- package/build/esm/prod/request.js +14 -7
- package/build/esm/prod/request.js.map +1 -1
- package/build/esm/prod/scope-utils.js +12 -10
- package/build/esm/prod/scope-utils.js.map +1 -1
- package/build/esm/prod/sdk.js +23 -13
- package/build/esm/prod/sdk.js.map +1 -1
- package/build/esm/prod/transport.js +93 -84
- package/build/esm/prod/transport.js.map +1 -1
- package/build/esm/prod/utils/asyncContextStrategy.js +10 -8
- package/build/esm/prod/utils/asyncContextStrategy.js.map +1 -1
- package/build/esm/prod/utils/bindingPropagation.js +17 -9
- package/build/esm/prod/utils/bindingPropagation.js.map +1 -1
- package/build/esm/prod/utils/cloudflareTrace.js +34 -0
- package/build/esm/prod/utils/cloudflareTrace.js.map +1 -0
- package/build/esm/prod/utils/instrumentContext.js +74 -56
- package/build/esm/prod/utils/instrumentContext.js.map +1 -1
- package/build/esm/prod/utils/internalSqlQuery.js +38 -19
- package/build/esm/prod/utils/internalSqlQuery.js.map +1 -1
- package/build/esm/prod/utils/internalStorageKey.js +41 -36
- package/build/esm/prod/utils/internalStorageKey.js.map +1 -1
- package/build/esm/prod/utils/invocationContext.js +42 -30
- package/build/esm/prod/utils/invocationContext.js.map +1 -1
- package/build/esm/prod/utils/invocationScope.js +45 -19
- package/build/esm/prod/utils/invocationScope.js.map +1 -1
- package/build/esm/prod/utils/isBinding.js +47 -13
- package/build/esm/prod/utils/isBinding.js.map +1 -1
- package/build/esm/prod/utils/isCloudflareClass.js +11 -18
- package/build/esm/prod/utils/isCloudflareClass.js.map +1 -1
- package/build/esm/prod/utils/queueTraceMeta.js +24 -33
- package/build/esm/prod/utils/queueTraceMeta.js.map +1 -1
- package/build/esm/prod/utils/rpcMeta.js +37 -25
- package/build/esm/prod/utils/rpcMeta.js.map +1 -1
- package/build/esm/prod/utils/traceLinks.js +52 -40
- package/build/esm/prod/utils/traceLinks.js.map +1 -1
- package/build/esm/prod/vendor/stacktrace.js +31 -21
- package/build/esm/prod/vendor/stacktrace.js.map +1 -1
- package/build/esm/prod/vite/agentClass.js +105 -96
- package/build/esm/prod/vite/agentClass.js.map +1 -1
- package/build/esm/prod/vite/autoInstrument.js +121 -120
- package/build/esm/prod/vite/autoInstrument.js.map +1 -1
- package/build/esm/prod/vite/index.js +43 -19
- package/build/esm/prod/vite/index.js.map +1 -1
- package/build/esm/prod/vite/instrumentFile.js +37 -18
- package/build/esm/prod/vite/instrumentFile.js.map +1 -1
- package/build/esm/prod/vite/mastraObservability.js +19 -10
- package/build/esm/prod/vite/mastraObservability.js.map +1 -1
- package/build/esm/prod/vite/moduleShape.js +220 -199
- package/build/esm/prod/vite/moduleShape.js.map +1 -1
- package/build/esm/prod/vite/providedModulePlugin.js +60 -43
- package/build/esm/prod/vite/providedModulePlugin.js.map +1 -1
- package/build/esm/prod/vite/transform.js +331 -282
- package/build/esm/prod/vite/transform.js.map +1 -1
- package/build/esm/prod/vite/workerEntrypoint.js +66 -55
- package/build/esm/prod/vite/workerEntrypoint.js.map +1 -1
- package/build/esm/prod/vite/wranglerConfig.js +92 -65
- package/build/esm/prod/vite/wranglerConfig.js.map +1 -1
- package/build/esm/prod/withSentry.js +32 -24
- package/build/esm/prod/withSentry.js.map +1 -1
- package/build/esm/prod/workflows.js +164 -149
- package/build/esm/prod/workflows.js.map +1 -1
- package/build/esm/prod/wrapMethodWithSentry.js +148 -167
- package/build/esm/prod/wrapMethodWithSentry.js.map +1 -1
- package/build/esm/prod/wrapRequestHandlerWithInit.js +76 -76
- package/build/esm/prod/wrapRequestHandlerWithInit.js.map +1 -1
- package/build/types/client.d.ts +2 -1
- package/build/types/client.d.ts.map +1 -1
- package/build/types/index.d.ts +3 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentEmail.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentFetcher.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentQueue.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentScheduled.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentTail.d.ts +4 -2
- package/build/types/instrumentations/worker/instrumentTail.d.ts.map +1 -1
- package/build/types/utils/cloudflareTrace.d.ts +13 -0
- package/build/types/utils/cloudflareTrace.d.ts.map +1 -0
- package/build/types/vite/autoInstrument.d.ts.map +1 -1
- package/build/types/vite/index.d.ts.map +1 -1
- package/build/types/vite/providedModulePlugin.d.ts +15 -11
- package/build/types/vite/providedModulePlugin.d.ts.map +1 -1
- package/build/types/workflows.d.ts.map +1 -1
- package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
- package/build/types/wrapRequestHandlerWithInit.d.ts.map +1 -1
- package/package.json +10 -14
- package/build/cjs/dev/index.js.map +0 -1
- package/build/cjs/dev/vite/flueRuntime.js +0 -15
- package/build/cjs/dev/vite/flueRuntime.js.map +0 -1
- package/build/cjs/prod/index.js.map +0 -1
- package/build/cjs/prod/vite/flueRuntime.js +0 -15
- package/build/cjs/prod/vite/flueRuntime.js.map +0 -1
- package/build/esm/dev/index.js.map +0 -1
- package/build/esm/dev/vite/flueRuntime.js +0 -13
- package/build/esm/dev/vite/flueRuntime.js.map +0 -1
- package/build/esm/prod/index.js.map +0 -1
- package/build/esm/prod/vite/flueRuntime.js +0 -13
- package/build/esm/prod/vite/flueRuntime.js.map +0 -1
- package/build/types/vite/flueRuntime.d.ts +0 -12
- package/build/types/vite/flueRuntime.d.ts.map +0 -1
|
@@ -1,327 +1,376 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_wranglerConfig = require("./wranglerConfig.js");
|
|
3
|
+
const require_workerEntrypoint = require("./workerEntrypoint.js");
|
|
4
|
+
let magic_string = require("magic-string");
|
|
5
|
+
magic_string = require_runtime.__toESM(magic_string);
|
|
6
|
+
// src/vite/transform.ts
|
|
7
7
|
const MERGED_OPTIONS_IDENTIFIER = "__SENTRY_OPTIONS__";
|
|
8
8
|
function isCallToMethod(node, methodName) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
if (node.type !== "CallExpression") return false;
|
|
10
|
+
const callee = node.callee;
|
|
11
|
+
if (!callee) return false;
|
|
12
|
+
if (callee.type === "Identifier" && callee.name === methodName) return true;
|
|
13
|
+
return callee.type === "MemberExpression" && callee.property?.type === "Identifier" && callee.property.name === methodName;
|
|
14
14
|
}
|
|
15
|
+
/** Specifier name a `export { default as X } from '...'` re-export uses for the source's default. */
|
|
15
16
|
const DEFAULT_IMPORT = "default";
|
|
17
|
+
/**
|
|
18
|
+
* The `@sentry/cloudflare` helper each wrapper kind emits. All share the same
|
|
19
|
+
* `(optionsCallback, Class)` signature. `WorkerEntrypoint` classes use
|
|
20
|
+
* `withSentry`, which runtime-detects the class type and routes accordingly.
|
|
21
|
+
*/
|
|
16
22
|
const WRAPPER_METHODS = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
durableObject: "instrumentDurableObjectWithSentry",
|
|
24
|
+
agent: "instrumentAgentWithSentry",
|
|
25
|
+
workflow: "instrumentWorkflowWithSentry",
|
|
26
|
+
workerEntrypoint: "withSentry"
|
|
21
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Rewrite the worker entry source to wrap its default export with `withSentry`
|
|
30
|
+
* and any configured class export with its matching Sentry wrapper (see
|
|
31
|
+
* {@link TransformContext.classWrappers}, e.g. Durable Object classes with
|
|
32
|
+
* `instrumentDurableObjectWithSentry`).
|
|
33
|
+
*
|
|
34
|
+
* Handles `export class MyDO {}`, the specifier form (`class MyDO {}` …
|
|
35
|
+
* `export { MyDO }` / `export { Foo as MyDO }`), and classes that live in
|
|
36
|
+
* another module (`import { MyDO } from './do'; export { MyDO }` or
|
|
37
|
+
* `export { MyDO } from './do'`). Only star re-exports (`export * from './do'`)
|
|
38
|
+
* are left alone — the plugin warns about those via
|
|
39
|
+
* {@link TransformResult.wrappedClasses}.
|
|
40
|
+
*
|
|
41
|
+
* Exported (rather than inlined into the plugin) so it can be unit-tested with a
|
|
42
|
+
* plain AST and no Vite context. Returns `undefined` when nothing was wrapped and
|
|
43
|
+
* there are no already-manually-wrapped classes to report.
|
|
44
|
+
*/
|
|
22
45
|
function applyAutoInstrumentTransforms(code, ast, ctx) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (ctx.optionsImport) ms.prepend(ctx.optionsImport);
|
|
60
|
-
ms.prepend(`import * as __SENTRY__ from '${ctx.sentryModule ?? "@sentry/cloudflare"}';
|
|
61
|
-
`);
|
|
62
|
-
return {
|
|
63
|
-
code: ms.toString(),
|
|
64
|
-
map: ms.generateMap({ hires: true }),
|
|
65
|
-
wrappedClasses
|
|
66
|
-
};
|
|
46
|
+
const ms = new magic_string.default(code);
|
|
47
|
+
const topLevelClasses = collectTopLevelClasses(ast);
|
|
48
|
+
const sameWorkerBindings = ctx.sameWorkerBindings ?? [];
|
|
49
|
+
const state = {
|
|
50
|
+
ms,
|
|
51
|
+
needsImport: false,
|
|
52
|
+
wrappedClasses: /* @__PURE__ */ new Set(),
|
|
53
|
+
topLevelClasses,
|
|
54
|
+
wrappedLocals: /* @__PURE__ */ new Map(),
|
|
55
|
+
classWrappers: ctx.classWrappers,
|
|
56
|
+
agentClasses: ctx.agentClasses ?? /* @__PURE__ */ new Set(),
|
|
57
|
+
workerEntrypointClasses: require_workerEntrypoint.detectWorkerEntrypointClasses(ast),
|
|
58
|
+
optionsFn: sameWorkerBindings.length > 0 ? MERGED_OPTIONS_IDENTIFIER : ctx.optionsFn,
|
|
59
|
+
autoWrapped: /* @__PURE__ */ new Set(),
|
|
60
|
+
manuallyWrappedLocals: collectManuallyWrappedLocals(ast),
|
|
61
|
+
declaringStatements: collectDeclaringStatements(ast)
|
|
62
|
+
};
|
|
63
|
+
const { wrappedClasses } = state;
|
|
64
|
+
for (const node of ast.body) if (node.type === "ExportNamedDeclaration") handleNamedExport(node, ctx, state);
|
|
65
|
+
for (const node of ast.body) if (node.type === "ExportDefaultDeclaration") wrapDefaultExport(node, ctx, state);
|
|
66
|
+
if (!state.needsImport) {
|
|
67
|
+
if (wrappedClasses.size === 0) return void 0;
|
|
68
|
+
return {
|
|
69
|
+
code,
|
|
70
|
+
map: ms.generateMap({ hires: true }),
|
|
71
|
+
wrappedClasses
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (sameWorkerBindings.length > 0) ms.prepend(buildMergedOptionsDeclaration(sameWorkerBindings, ctx.optionsFn, state));
|
|
75
|
+
if (ctx.optionsImport) ms.prepend(ctx.optionsImport);
|
|
76
|
+
ms.prepend(`import * as __SENTRY__ from '${ctx.sentryModule ?? "@sentry/cloudflare"}';\n`);
|
|
77
|
+
return {
|
|
78
|
+
code: ms.toString(),
|
|
79
|
+
map: ms.generateMap({ hires: true }),
|
|
80
|
+
wrappedClasses
|
|
81
|
+
};
|
|
67
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Builds the callback that merges same-worker binding names into `rpcTracePropagationBindings` at
|
|
85
|
+
* runtime, the options object only exists once the callback runs with `env`. Only bindings whose
|
|
86
|
+
* class this transform wrapped survive, a hand-wrapped class runs on its own options.
|
|
87
|
+
*/
|
|
68
88
|
function buildMergedOptionsDeclaration(sameWorkerBindings, optionsFn, state) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
`;
|
|
73
|
-
}
|
|
74
|
-
const names = bindingNames.map((name) => JSON.stringify(name)).join(", ");
|
|
75
|
-
return `const ${MERGED_OPTIONS_IDENTIFIER} = (env) => { const opts = (${optionsFn})(env); return { ...opts, rpcTracePropagationBindings: [${names}, ...(opts?.rpcTracePropagationBindings ?? [])] }; };
|
|
76
|
-
`;
|
|
89
|
+
const bindingNames = sameWorkerBindings.filter(({ className }) => state.autoWrapped.has(className)).map(({ bindingName }) => bindingName);
|
|
90
|
+
if (!bindingNames.length) return `const ${MERGED_OPTIONS_IDENTIFIER} = ${optionsFn};\n`;
|
|
91
|
+
const names = bindingNames.map((name) => JSON.stringify(name)).join(", ");
|
|
92
|
+
return `const ${MERGED_OPTIONS_IDENTIFIER} = (env) => { const opts = (${optionsFn})(env); return { ...opts, rpcTracePropagationBindings: [${names}, ...(opts?.rpcTracePropagationBindings ?? [])] }; };\n`;
|
|
77
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Resolve the wrapper kind for a class export.
|
|
96
|
+
*
|
|
97
|
+
* Config (`classWrappers`) wins — it's authoritative for Durable Objects and
|
|
98
|
+
* Workflows, and provides the self-binding fallback for WorkerEntrypoints whose
|
|
99
|
+
* base class this module can't see. Otherwise a structurally-detected
|
|
100
|
+
* `WorkerEntrypoint` subclass (matched by its *local* name) gets wrapped with
|
|
101
|
+
* `withSentry`.
|
|
102
|
+
*
|
|
103
|
+
* `localName` is the binding **in this module** the export refers to, and must be
|
|
104
|
+
* left undefined for `export { X } from '...'`: there the specifier's name belongs
|
|
105
|
+
* to the source module, so matching it against anything detected here would wrap a
|
|
106
|
+
* class that merely shares a name.
|
|
107
|
+
*
|
|
108
|
+
* The one case where config is refined rather than obeyed is an `agents` Agent:
|
|
109
|
+
* it *is* a Durable Object, so wrangler can only ever describe it as one, and
|
|
110
|
+
* only the detected base chain distinguishes the two.
|
|
111
|
+
*/
|
|
78
112
|
function resolveWrapperKind(exportedName, localName, state) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (configured) return configured;
|
|
84
|
-
if (localName && state.workerEntrypointClasses.has(localName)) return "workerEntrypoint";
|
|
85
|
-
return void 0;
|
|
113
|
+
const configured = state.classWrappers.get(exportedName);
|
|
114
|
+
if (configured === "durableObject" && (localName && state.agentClasses.has(localName) || state.agentClasses.has(exportedName))) return "agent";
|
|
115
|
+
if (configured) return configured;
|
|
116
|
+
if (localName && state.workerEntrypointClasses.has(localName)) return "workerEntrypoint";
|
|
86
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Top-level `const X = instrument*WithSentry(...)` bindings — a hand-wrapped class that is exported
|
|
120
|
+
* separately (`export { X }`) rather than inline.
|
|
121
|
+
*/
|
|
87
122
|
function collectManuallyWrappedLocals(ast) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
return locals;
|
|
123
|
+
const wrapperMethods = Object.values(WRAPPER_METHODS);
|
|
124
|
+
const locals = /* @__PURE__ */ new Set();
|
|
125
|
+
for (const node of ast.body) {
|
|
126
|
+
const declaration = declarationOf(node);
|
|
127
|
+
if (declaration?.type !== "VariableDeclaration") continue;
|
|
128
|
+
for (const declarator of declaration.declarations ?? []) {
|
|
129
|
+
const name = declarator.id?.type === "Identifier" ? declarator.id.name : void 0;
|
|
130
|
+
const init = declarator.init;
|
|
131
|
+
if (name && init && wrapperMethods.some((method) => isCallToMethod(init, method))) locals.add(name);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return locals;
|
|
102
135
|
}
|
|
103
136
|
function collectDeclaringStatements(ast) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
return statements;
|
|
137
|
+
const statements = /* @__PURE__ */ new Map();
|
|
138
|
+
for (const node of ast.body) {
|
|
139
|
+
const declaration = declarationOf(node);
|
|
140
|
+
if (!declaration) continue;
|
|
141
|
+
const ids = declaration.type === "VariableDeclaration" ? (declaration.declarations ?? []).map((declarator) => declarator.id) : declaration.type === "ImportDeclaration" ? (declaration.specifiers ?? []).map((specifier) => specifier.local) : [declaration.id];
|
|
142
|
+
for (const id of ids) if (id?.type === "Identifier" && id.name) statements.set(id.name, node);
|
|
143
|
+
}
|
|
144
|
+
return statements;
|
|
114
145
|
}
|
|
115
146
|
function collectTopLevelClasses(ast) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
147
|
+
const classes = /* @__PURE__ */ new Map();
|
|
148
|
+
for (const node of ast.body) {
|
|
149
|
+
const declaration = declarationOf(node);
|
|
150
|
+
if (declaration?.type !== "ClassDeclaration") continue;
|
|
151
|
+
const classNode = declaration;
|
|
152
|
+
if (classNode.id?.name) classes.set(classNode.id.name, classNode);
|
|
153
|
+
}
|
|
154
|
+
return classes;
|
|
124
155
|
}
|
|
156
|
+
/** The declaration a top-level statement makes, looking through `export` (`export const x = ...`). */
|
|
125
157
|
function declarationOf(node) {
|
|
126
|
-
|
|
158
|
+
return node.type === "ExportNamedDeclaration" ? node.declaration : node;
|
|
127
159
|
}
|
|
128
160
|
function wrapDefaultExport(node, ctx, state) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
state.ms.append(`
|
|
157
|
-
__SENTRY_DEFAULT_EXPORT__ = __SENTRY__.withSentry(${state.optionsFn}, ${wrapped});`);
|
|
158
|
-
state.needsImport = true;
|
|
159
|
-
state.autoWrapped.add(wranglerConfig.DEFAULT_EXPORT);
|
|
161
|
+
const decl = node.declaration;
|
|
162
|
+
if (isCallToMethod(decl, "withSentry")) return;
|
|
163
|
+
if (decl.type === "Identifier") {
|
|
164
|
+
const wrappedName = state.wrappedLocals.get(decl.name);
|
|
165
|
+
if (wrappedName) {
|
|
166
|
+
state.ms.overwrite(decl.start, decl.end, wrappedName);
|
|
167
|
+
state.autoWrapped.add(require_wranglerConfig.DEFAULT_EXPORT);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const source = state.ms.original;
|
|
172
|
+
const keywordsEnd = exportDefaultKeywordsEnd(source, node.start);
|
|
173
|
+
const declaredName = decl.type === "ClassDeclaration" || decl.type === "FunctionDeclaration" ? decl.id?.name : void 0;
|
|
174
|
+
let wrapped = "__SENTRY_DEFAULT_EXPORT__";
|
|
175
|
+
if (declaredName) {
|
|
176
|
+
state.ms.remove(node.start, decl.start);
|
|
177
|
+
state.ms.appendLeft(node.end, `\nvar __SENTRY_DEFAULT_EXPORT__ = ${declaredName};`);
|
|
178
|
+
wrapped = declaredName;
|
|
179
|
+
} else if (isAnonymousFunctionOrClass(decl)) {
|
|
180
|
+
const hasSemicolon = source[node.end - 1] === ";";
|
|
181
|
+
state.ms.overwrite(node.start, keywordsEnd, "var __SENTRY_DEFAULT_EXPORT__ = { default:");
|
|
182
|
+
state.ms.appendLeft(hasSemicolon ? node.end - 1 : node.end, hasSemicolon ? " }.default" : " }.default;");
|
|
183
|
+
} else state.ms.overwrite(node.start, keywordsEnd, "var __SENTRY_DEFAULT_EXPORT__ =");
|
|
184
|
+
state.ms.appendLeft(node.end, "\nexport { __SENTRY_DEFAULT_EXPORT__ as default };");
|
|
185
|
+
state.ms.append(`\n__SENTRY_DEFAULT_EXPORT__ = __SENTRY__.withSentry(${state.optionsFn}, ${wrapped});`);
|
|
186
|
+
state.needsImport = true;
|
|
187
|
+
state.autoWrapped.add(require_wranglerConfig.DEFAULT_EXPORT);
|
|
160
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Offset just past the `default` keyword of the `export default` statement at `start`. Comments can
|
|
191
|
+
* sit between `export`, `default` and the expression, and may themselves contain the word `default`.
|
|
192
|
+
*/
|
|
161
193
|
function exportDefaultKeywordsEnd(source, start) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
index++;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return index + "default".length;
|
|
194
|
+
let index = start + 6;
|
|
195
|
+
while (index < source.length && !source.startsWith("default", index)) if (source.startsWith("//", index)) {
|
|
196
|
+
const lineEnd = source.indexOf("\n", index);
|
|
197
|
+
index = lineEnd === -1 ? source.length : lineEnd;
|
|
198
|
+
} else if (source.startsWith("/*", index)) {
|
|
199
|
+
const commentEnd = source.indexOf("*/", index + 2);
|
|
200
|
+
index = commentEnd === -1 ? source.length : commentEnd + 2;
|
|
201
|
+
} else index++;
|
|
202
|
+
return index + 7;
|
|
175
203
|
}
|
|
176
204
|
function isAnonymousFunctionOrClass(node) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
return isFunctionOrClass && !node.id;
|
|
205
|
+
if (node.type === "ArrowFunctionExpression") return true;
|
|
206
|
+
return [
|
|
207
|
+
"FunctionExpression",
|
|
208
|
+
"FunctionDeclaration",
|
|
209
|
+
"ClassExpression",
|
|
210
|
+
"ClassDeclaration"
|
|
211
|
+
].includes(node.type) && !node.id;
|
|
185
212
|
}
|
|
186
213
|
function handleNamedExport(node, ctx, state) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
214
|
+
const decl = node.declaration;
|
|
215
|
+
if (decl?.type === "VariableDeclaration") {
|
|
216
|
+
collectManuallyWrappedClassExports(decl, ctx, state);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (decl?.type === "ClassDeclaration") {
|
|
220
|
+
wrapInlineClassExport(node, decl, ctx, state);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
wrapSpecifierExports(node, ctx, state);
|
|
197
224
|
}
|
|
198
225
|
function collectManuallyWrappedClassExports(varDecl, ctx, state) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
state.wrappedClasses.add(name);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
226
|
+
for (const declarator of varDecl.declarations ?? []) {
|
|
227
|
+
const name = declarator.id?.type === "Identifier" ? declarator.id.name : void 0;
|
|
228
|
+
const kind = name ? ctx.classWrappers.get(name) : void 0;
|
|
229
|
+
if (!name || !kind || !declarator.init) continue;
|
|
230
|
+
if ((kind === "durableObject" ? [WRAPPER_METHODS.durableObject, WRAPPER_METHODS.agent] : [WRAPPER_METHODS[kind]]).some((method) => isCallToMethod(declarator.init, method))) state.wrappedClasses.add(name);
|
|
231
|
+
}
|
|
208
232
|
}
|
|
209
233
|
function wrapInlineClassExport(exportNode, classDecl, ctx, state) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
state.autoWrapped.add(className);
|
|
234
|
+
const classId = classDecl.id;
|
|
235
|
+
const kind = classId ? resolveWrapperKind(classId.name, classId.name, state) : void 0;
|
|
236
|
+
if (!classId || !kind) return;
|
|
237
|
+
const className = classId.name;
|
|
238
|
+
state.ms.overwrite(exportNode.start, classDecl.start, "");
|
|
239
|
+
const wrappedName = wrapLocalClass(className, classDecl, kind, state);
|
|
240
|
+
state.ms.appendLeft(exportNode.end, `export { ${wrappedName} as ${className} };\n`);
|
|
241
|
+
state.wrappedClasses.add(className);
|
|
242
|
+
state.autoWrapped.add(className);
|
|
220
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Wrap a class declared in this module and return the binding that holds the wrapper.
|
|
246
|
+
*
|
|
247
|
+
* The declaration is left exactly as written. Only the *export* has to become the wrapper, so the
|
|
248
|
+
* wrapper gets its own binding and the export is aliased to it, the same shape as the documented
|
|
249
|
+
* manual `instrument*WithSentry` pattern and the cross-module re-export path below. Renaming the
|
|
250
|
+
* declaration instead (`class __SENTRY_ORIGINAL_MyAgent__`) would also rename what the class reports
|
|
251
|
+
* as `Function.prototype.name`, which libraries read to identify the user's class: `@cloudflare/think`
|
|
252
|
+
* hands `this.constructor.name` to the AI SDK as the telemetry `functionId`, and that surfaced as a
|
|
253
|
+
* `gen_ai.invoke_agent __SENTRY_ORIGINAL_MyAgent__` span.
|
|
254
|
+
*/
|
|
221
255
|
function wrapLocalClass(localName, localClass, kind, state) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const ${wrappedName} = __SENTRY__.${WRAPPER_METHODS[kind]}(${state.optionsFn}, ${localName});
|
|
230
|
-
`
|
|
231
|
-
);
|
|
232
|
-
state.needsImport = true;
|
|
233
|
-
return wrappedName;
|
|
256
|
+
const existing = state.wrappedLocals.get(localName);
|
|
257
|
+
if (existing) return existing;
|
|
258
|
+
const wrappedName = `__SENTRY_WRAPPED_${localName}__`;
|
|
259
|
+
state.wrappedLocals.set(localName, wrappedName);
|
|
260
|
+
state.ms.appendLeft(localClass.end, `\nconst ${wrappedName} = __SENTRY__.${WRAPPER_METHODS[kind]}(${state.optionsFn}, ${localName});\n`);
|
|
261
|
+
state.needsImport = true;
|
|
262
|
+
return wrappedName;
|
|
234
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Wrap the configured classes an `export { ... }` statement names.
|
|
266
|
+
*
|
|
267
|
+
* Each such specifier is re-pointed at a binding holding the wrapper, which means rebuilding the
|
|
268
|
+
* statement; specifiers this plugin has no business touching are carried over verbatim. For a class
|
|
269
|
+
* declared in this module the wrapper binding follows the declaration (see {@link wrapLocalClass}).
|
|
270
|
+
* A class that lives in **another** module — imported and re-exported, or re-exported directly — is
|
|
271
|
+
* first bound under a private name, since an import binding cannot be reassigned and the `from` form
|
|
272
|
+
* has no local binding at all.
|
|
273
|
+
*/
|
|
235
274
|
function wrapSpecifierExports(node, ctx, state) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
statements.push(sourceLiteral ? `${clause} from ${sourceLiteral};` : `${clause};`);
|
|
255
|
-
}
|
|
256
|
-
state.ms.overwrite(node.start, node.end, statements.join("\n"));
|
|
275
|
+
const specifiers = node.specifiers ?? [];
|
|
276
|
+
if (specifiers.length === 0) return;
|
|
277
|
+
const sourceLiteral = node.source ? state.ms.original.slice(node.source.start, node.source.end) : void 0;
|
|
278
|
+
const prelude = [];
|
|
279
|
+
const wrappedPairs = [];
|
|
280
|
+
const kept = [];
|
|
281
|
+
for (const specifier of specifiers) {
|
|
282
|
+
const pair = wrapSpecifier(specifier, sourceLiteral, ctx, state, prelude);
|
|
283
|
+
if (pair) wrappedPairs.push(pair);
|
|
284
|
+
else kept.push(state.ms.original.slice(specifier.start, specifier.end));
|
|
285
|
+
}
|
|
286
|
+
if (wrappedPairs.length === 0) return;
|
|
287
|
+
const statements = [...prelude, `export { ${wrappedPairs.join(", ")} };`];
|
|
288
|
+
if (kept.length > 0) {
|
|
289
|
+
const clause = `export { ${kept.join(", ")} }`;
|
|
290
|
+
statements.push(sourceLiteral ? `${clause} from ${sourceLiteral};` : `${clause};`);
|
|
291
|
+
}
|
|
292
|
+
state.ms.overwrite(node.start, node.end, statements.join("\n"));
|
|
257
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* `export { handler as default }`, the form bundlers emit for a default export. The export is set
|
|
296
|
+
* in two steps. Right after `handler` is declared, it is bound to `handler` as-is, so a circular
|
|
297
|
+
* import that reads it during module evaluation gets the handler, as before the transform. At the
|
|
298
|
+
* end of the module, it is rebound to the wrapper, so a handler assigned or given methods later is
|
|
299
|
+
* wrapped as it ends up. The binding is a `var`: a read before `handler` is declared gets
|
|
300
|
+
* `undefined`, as it would from the bundler's own `var`, where a `const` would throw and stop the
|
|
301
|
+
* Worker from starting.
|
|
302
|
+
*/
|
|
258
303
|
function wrapDefaultSpecifier(localName, state) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
`
|
|
272
|
-
${declaringStatement ? "" : "var "}__SENTRY_DEFAULT_EXPORT__ = __SENTRY__.withSentry(${state.optionsFn}, ${localName});`
|
|
273
|
-
);
|
|
274
|
-
state.needsImport = true;
|
|
275
|
-
state.autoWrapped.add(wranglerConfig.DEFAULT_EXPORT);
|
|
276
|
-
return "__SENTRY_DEFAULT_EXPORT__ as default";
|
|
304
|
+
if (state.manuallyWrappedLocals.has(localName)) return void 0;
|
|
305
|
+
const wrappedName = state.wrappedLocals.get(localName);
|
|
306
|
+
if (wrappedName) {
|
|
307
|
+
state.autoWrapped.add(require_wranglerConfig.DEFAULT_EXPORT);
|
|
308
|
+
return `${wrappedName} as default`;
|
|
309
|
+
}
|
|
310
|
+
const declaringStatement = state.declaringStatements.get(localName);
|
|
311
|
+
if (declaringStatement) state.ms.appendLeft(declaringStatement.end, `\nvar __SENTRY_DEFAULT_EXPORT__ = ${localName};`);
|
|
312
|
+
state.ms.append(`\n${declaringStatement ? "" : "var "}__SENTRY_DEFAULT_EXPORT__ = __SENTRY__.withSentry(${state.optionsFn}, ${localName});`);
|
|
313
|
+
state.needsImport = true;
|
|
314
|
+
state.autoWrapped.add(require_wranglerConfig.DEFAULT_EXPORT);
|
|
315
|
+
return "__SENTRY_DEFAULT_EXPORT__ as default";
|
|
277
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* `export { default } from './handler'`. The handler may already be wrapped in its own module,
|
|
319
|
+
* which this transform cannot see, so the emitted guard returns such a handler as-is.
|
|
320
|
+
*
|
|
321
|
+
* The original re-export is a live binding to the handler module's export, but the wrapper is not
|
|
322
|
+
* set until this module's body runs. A circular import that reads the default export before then
|
|
323
|
+
* gets `undefined` instead of the handler. The binding is a `var` so that the read does not throw,
|
|
324
|
+
* as a `const` would, and stop the Worker from starting. See `wrapDefaultSpecifier`.
|
|
325
|
+
*/
|
|
278
326
|
function wrapDefaultReexport(localName, sourceLiteral, state, prelude) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
state.needsImport = true;
|
|
285
|
-
state.autoWrapped.add(wranglerConfig.DEFAULT_EXPORT);
|
|
286
|
-
return "__SENTRY_DEFAULT_EXPORT__ as default";
|
|
327
|
+
const target = "__SENTRY_REEXPORT_default__";
|
|
328
|
+
prelude.push(localName === DEFAULT_IMPORT ? `import ${target} from ${sourceLiteral};` : `import { ${localName} as ${target} } from ${sourceLiteral};`, `var __SENTRY_DEFAULT_EXPORT__ = __SENTRY__._INTERNAL_wrapUnlessInstrumented(__SENTRY__.withSentry, ${state.optionsFn}, ${target});`);
|
|
329
|
+
state.needsImport = true;
|
|
330
|
+
state.autoWrapped.add(require_wranglerConfig.DEFAULT_EXPORT);
|
|
331
|
+
return "__SENTRY_DEFAULT_EXPORT__ as default";
|
|
287
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* Handle one export specifier, returning the `Wrapped as Exported` pair to emit for a class that
|
|
335
|
+
* gets wrapped. The import/wrapper statements a cross-module pair depends on are pushed onto
|
|
336
|
+
* `prelude`; a local class's wrapper binding is emitted after its declaration instead.
|
|
337
|
+
*
|
|
338
|
+
* Returns `undefined` when the specifier can stay exactly as written: it doesn't name a configured
|
|
339
|
+
* class, or the binding is already hand-wrapped.
|
|
340
|
+
*/
|
|
288
341
|
function wrapSpecifier(specifier, sourceLiteral, ctx, state, prelude) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
state.wrappedClasses.add(exportedName);
|
|
321
|
-
state.autoWrapped.add(exportedName);
|
|
322
|
-
state.needsImport = true;
|
|
323
|
-
return `${wrappedName} as ${exportedName}`;
|
|
342
|
+
const exportedName = specifier.type === "ExportSpecifier" && specifier.exported?.type === "Identifier" ? specifier.exported.name : void 0;
|
|
343
|
+
const localName = specifier.local?.type === "Identifier" ? specifier.local.name : void 0;
|
|
344
|
+
const kind = exportedName ? resolveWrapperKind(exportedName, sourceLiteral ? void 0 : localName, state) : void 0;
|
|
345
|
+
if (!exportedName || !localName) return void 0;
|
|
346
|
+
if (!kind) {
|
|
347
|
+
if (exportedName !== DEFAULT_IMPORT) return void 0;
|
|
348
|
+
return sourceLiteral ? wrapDefaultReexport(localName, sourceLiteral, state, prelude) : wrapDefaultSpecifier(localName, state);
|
|
349
|
+
}
|
|
350
|
+
if (!sourceLiteral) {
|
|
351
|
+
const localClass = state.topLevelClasses.get(localName);
|
|
352
|
+
if (localClass?.id) {
|
|
353
|
+
const wrappedName = wrapLocalClass(localName, localClass, kind, state);
|
|
354
|
+
state.wrappedClasses.add(exportedName);
|
|
355
|
+
return `${wrappedName} as ${exportedName}`;
|
|
356
|
+
}
|
|
357
|
+
if (state.manuallyWrappedLocals.has(localName)) {
|
|
358
|
+
state.wrappedClasses.add(exportedName);
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
let target = localName;
|
|
363
|
+
if (sourceLiteral) {
|
|
364
|
+
target = `__SENTRY_REEXPORT_${exportedName}__`;
|
|
365
|
+
prelude.push(localName === DEFAULT_IMPORT ? `import ${target} from ${sourceLiteral};` : `import { ${localName} as ${target} } from ${sourceLiteral};`);
|
|
366
|
+
}
|
|
367
|
+
const wrappedName = `__SENTRY_WRAPPED_${exportedName}__`;
|
|
368
|
+
prelude.push(`const ${wrappedName} = __SENTRY__._INTERNAL_wrapUnlessInstrumented(__SENTRY__.${WRAPPER_METHODS[kind]}, ${state.optionsFn}, ${target});`);
|
|
369
|
+
state.wrappedClasses.add(exportedName);
|
|
370
|
+
state.autoWrapped.add(exportedName);
|
|
371
|
+
state.needsImport = true;
|
|
372
|
+
return `${wrappedName} as ${exportedName}`;
|
|
324
373
|
}
|
|
325
|
-
|
|
326
374
|
exports.applyAutoInstrumentTransforms = applyAutoInstrumentTransforms;
|
|
327
|
-
|
|
375
|
+
|
|
376
|
+
//# sourceMappingURL=transform.js.map
|