@sentry/cloudflare 10.47.0 → 10.49.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.
Files changed (171) hide show
  1. package/build/cjs/client.js.map +1 -1
  2. package/build/cjs/durableobject.js +42 -16
  3. package/build/cjs/durableobject.js.map +1 -1
  4. package/build/cjs/index.js +3 -0
  5. package/build/cjs/index.js.map +1 -1
  6. package/build/cjs/instrument.js +72 -8
  7. package/build/cjs/instrument.js.map +1 -1
  8. package/build/cjs/instrumentations/instrumentDurableObjectNamespace.js +56 -0
  9. package/build/cjs/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
  10. package/build/cjs/instrumentations/instrumentDurableObjectStorage.js +38 -3
  11. package/build/cjs/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  12. package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js +101 -0
  13. package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
  14. package/build/cjs/instrumentations/worker/instrumentEmail.js +16 -13
  15. package/build/cjs/instrumentations/worker/instrumentEmail.js.map +1 -1
  16. package/build/cjs/instrumentations/worker/instrumentEnv.js +83 -0
  17. package/build/cjs/instrumentations/worker/instrumentEnv.js.map +1 -0
  18. package/build/cjs/instrumentations/worker/instrumentFetch.js +36 -10
  19. package/build/cjs/instrumentations/worker/instrumentFetch.js.map +1 -1
  20. package/build/cjs/instrumentations/worker/instrumentFetcher.js +38 -0
  21. package/build/cjs/instrumentations/worker/instrumentFetcher.js.map +1 -0
  22. package/build/cjs/instrumentations/worker/instrumentQueue.js +36 -10
  23. package/build/cjs/instrumentations/worker/instrumentQueue.js.map +1 -1
  24. package/build/cjs/instrumentations/worker/instrumentScheduled.js +36 -13
  25. package/build/cjs/instrumentations/worker/instrumentScheduled.js.map +1 -1
  26. package/build/cjs/instrumentations/worker/instrumentTail.js +34 -10
  27. package/build/cjs/instrumentations/worker/instrumentTail.js.map +1 -1
  28. package/build/cjs/integrations/tracing/vercelai.js +2 -1
  29. package/build/cjs/integrations/tracing/vercelai.js.map +1 -1
  30. package/build/cjs/request.js +5 -6
  31. package/build/cjs/request.js.map +1 -1
  32. package/build/cjs/scope-utils.js.map +1 -1
  33. package/build/cjs/sdk.js +6 -1
  34. package/build/cjs/sdk.js.map +1 -1
  35. package/build/cjs/utils/instrumentContext.js +2 -1
  36. package/build/cjs/utils/instrumentContext.js.map +1 -1
  37. package/build/cjs/utils/isBinding.js +32 -0
  38. package/build/cjs/utils/isBinding.js.map +1 -0
  39. package/build/cjs/utils/isCloudflareClass.js +29 -0
  40. package/build/cjs/utils/isCloudflareClass.js.map +1 -0
  41. package/build/cjs/utils/rpcOptions.js +84 -0
  42. package/build/cjs/utils/rpcOptions.js.map +1 -0
  43. package/build/cjs/utils/traceLinks.js +78 -0
  44. package/build/cjs/utils/traceLinks.js.map +1 -0
  45. package/build/cjs/withSentry.js +31 -20
  46. package/build/cjs/withSentry.js.map +1 -1
  47. package/build/cjs/workflows.js +3 -2
  48. package/build/cjs/workflows.js.map +1 -1
  49. package/build/cjs/wrapMethodWithSentry.js +157 -112
  50. package/build/cjs/wrapMethodWithSentry.js.map +1 -1
  51. package/build/esm/client.js.map +1 -1
  52. package/build/esm/durableobject.js +43 -17
  53. package/build/esm/durableobject.js.map +1 -1
  54. package/build/esm/index.js +1 -1
  55. package/build/esm/instrument.js +71 -8
  56. package/build/esm/instrument.js.map +1 -1
  57. package/build/esm/instrumentations/instrumentDurableObjectNamespace.js +54 -0
  58. package/build/esm/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
  59. package/build/esm/instrumentations/instrumentDurableObjectStorage.js +39 -4
  60. package/build/esm/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  61. package/build/esm/instrumentations/instrumentWorkerEntrypoint.js +99 -0
  62. package/build/esm/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
  63. package/build/esm/instrumentations/worker/instrumentEmail.js +17 -14
  64. package/build/esm/instrumentations/worker/instrumentEmail.js.map +1 -1
  65. package/build/esm/instrumentations/worker/instrumentEnv.js +81 -0
  66. package/build/esm/instrumentations/worker/instrumentEnv.js.map +1 -0
  67. package/build/esm/instrumentations/worker/instrumentFetch.js +37 -12
  68. package/build/esm/instrumentations/worker/instrumentFetch.js.map +1 -1
  69. package/build/esm/instrumentations/worker/instrumentFetcher.js +36 -0
  70. package/build/esm/instrumentations/worker/instrumentFetcher.js.map +1 -0
  71. package/build/esm/instrumentations/worker/instrumentQueue.js +37 -12
  72. package/build/esm/instrumentations/worker/instrumentQueue.js.map +1 -1
  73. package/build/esm/instrumentations/worker/instrumentScheduled.js +37 -15
  74. package/build/esm/instrumentations/worker/instrumentScheduled.js.map +1 -1
  75. package/build/esm/instrumentations/worker/instrumentTail.js +35 -12
  76. package/build/esm/instrumentations/worker/instrumentTail.js.map +1 -1
  77. package/build/esm/integrations/tracing/vercelai.js +2 -1
  78. package/build/esm/integrations/tracing/vercelai.js.map +1 -1
  79. package/build/esm/package.json +1 -1
  80. package/build/esm/request.js +5 -6
  81. package/build/esm/request.js.map +1 -1
  82. package/build/esm/scope-utils.js.map +1 -1
  83. package/build/esm/sdk.js +7 -2
  84. package/build/esm/sdk.js.map +1 -1
  85. package/build/esm/utils/instrumentContext.js +2 -1
  86. package/build/esm/utils/instrumentContext.js.map +1 -1
  87. package/build/esm/utils/isBinding.js +29 -0
  88. package/build/esm/utils/isBinding.js.map +1 -0
  89. package/build/esm/utils/isCloudflareClass.js +27 -0
  90. package/build/esm/utils/isCloudflareClass.js.map +1 -0
  91. package/build/esm/utils/rpcOptions.js +81 -0
  92. package/build/esm/utils/rpcOptions.js.map +1 -0
  93. package/build/esm/utils/traceLinks.js +73 -0
  94. package/build/esm/utils/traceLinks.js.map +1 -0
  95. package/build/esm/withSentry.js +32 -21
  96. package/build/esm/withSentry.js.map +1 -1
  97. package/build/esm/workflows.js +3 -2
  98. package/build/esm/workflows.js.map +1 -1
  99. package/build/esm/wrapMethodWithSentry.js +159 -114
  100. package/build/esm/wrapMethodWithSentry.js.map +1 -1
  101. package/build/types/client.d.ts +39 -10
  102. package/build/types/client.d.ts.map +1 -1
  103. package/build/types/durableobject.d.ts.map +1 -1
  104. package/build/types/index.d.ts +1 -1
  105. package/build/types/index.d.ts.map +1 -1
  106. package/build/types/instrument.d.ts +15 -4
  107. package/build/types/instrument.d.ts.map +1 -1
  108. package/build/types/instrumentations/instrumentDurableObjectNamespace.d.ts +12 -0
  109. package/build/types/instrumentations/instrumentDurableObjectNamespace.d.ts.map +1 -0
  110. package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts +8 -1
  111. package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts.map +1 -1
  112. package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts +42 -0
  113. package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts.map +1 -0
  114. package/build/types/instrumentations/worker/instrumentEmail.d.ts +2 -1
  115. package/build/types/instrumentations/worker/instrumentEmail.d.ts.map +1 -1
  116. package/build/types/instrumentations/worker/instrumentEnv.d.ts +16 -0
  117. package/build/types/instrumentations/worker/instrumentEnv.d.ts.map +1 -0
  118. package/build/types/instrumentations/worker/instrumentFetch.d.ts +6 -1
  119. package/build/types/instrumentations/worker/instrumentFetch.d.ts.map +1 -1
  120. package/build/types/instrumentations/worker/instrumentFetcher.d.ts +10 -0
  121. package/build/types/instrumentations/worker/instrumentFetcher.d.ts.map +1 -0
  122. package/build/types/instrumentations/worker/instrumentQueue.d.ts +6 -1
  123. package/build/types/instrumentations/worker/instrumentQueue.d.ts.map +1 -1
  124. package/build/types/instrumentations/worker/instrumentScheduled.d.ts +6 -1
  125. package/build/types/instrumentations/worker/instrumentScheduled.d.ts.map +1 -1
  126. package/build/types/instrumentations/worker/instrumentTail.d.ts +6 -1
  127. package/build/types/instrumentations/worker/instrumentTail.d.ts.map +1 -1
  128. package/build/types/integrations/tracing/vercelai.d.ts +9 -1
  129. package/build/types/integrations/tracing/vercelai.d.ts.map +1 -1
  130. package/build/types/request.d.ts +3 -3
  131. package/build/types/request.d.ts.map +1 -1
  132. package/build/types/scope-utils.d.ts +2 -2
  133. package/build/types/scope-utils.d.ts.map +1 -1
  134. package/build/types/sdk.d.ts.map +1 -1
  135. package/build/types/utils/instrumentContext.d.ts.map +1 -1
  136. package/build/types/utils/isBinding.d.ts +49 -0
  137. package/build/types/utils/isBinding.d.ts.map +1 -0
  138. package/build/types/utils/isCloudflareClass.d.ts +30 -0
  139. package/build/types/utils/isCloudflareClass.d.ts.map +1 -0
  140. package/build/types/utils/rpcOptions.d.ts +24 -0
  141. package/build/types/utils/rpcOptions.d.ts.map +1 -0
  142. package/build/types/utils/traceLinks.d.ts +27 -0
  143. package/build/types/utils/traceLinks.d.ts.map +1 -0
  144. package/build/types/withSentry.d.ts +3 -2
  145. package/build/types/withSentry.d.ts.map +1 -1
  146. package/build/types/workflows.d.ts.map +1 -1
  147. package/build/types/wrapMethodWithSentry.d.ts +19 -2
  148. package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
  149. package/build/types-ts3.8/client.d.ts +39 -10
  150. package/build/types-ts3.8/index.d.ts +1 -1
  151. package/build/types-ts3.8/instrument.d.ts +15 -4
  152. package/build/types-ts3.8/instrumentations/instrumentDurableObjectNamespace.d.ts +12 -0
  153. package/build/types-ts3.8/instrumentations/instrumentDurableObjectStorage.d.ts +8 -1
  154. package/build/types-ts3.8/instrumentations/instrumentWorkerEntrypoint.d.ts +42 -0
  155. package/build/types-ts3.8/instrumentations/worker/instrumentEmail.d.ts +2 -1
  156. package/build/types-ts3.8/instrumentations/worker/instrumentEnv.d.ts +16 -0
  157. package/build/types-ts3.8/instrumentations/worker/instrumentFetch.d.ts +6 -1
  158. package/build/types-ts3.8/instrumentations/worker/instrumentFetcher.d.ts +10 -0
  159. package/build/types-ts3.8/instrumentations/worker/instrumentQueue.d.ts +6 -1
  160. package/build/types-ts3.8/instrumentations/worker/instrumentScheduled.d.ts +6 -1
  161. package/build/types-ts3.8/instrumentations/worker/instrumentTail.d.ts +6 -1
  162. package/build/types-ts3.8/integrations/tracing/vercelai.d.ts +9 -1
  163. package/build/types-ts3.8/request.d.ts +3 -3
  164. package/build/types-ts3.8/scope-utils.d.ts +2 -2
  165. package/build/types-ts3.8/utils/isBinding.d.ts +49 -0
  166. package/build/types-ts3.8/utils/isCloudflareClass.d.ts +30 -0
  167. package/build/types-ts3.8/utils/rpcOptions.d.ts +24 -0
  168. package/build/types-ts3.8/utils/traceLinks.d.ts +27 -0
  169. package/build/types-ts3.8/withSentry.d.ts +3 -2
  170. package/build/types-ts3.8/wrapMethodWithSentry.d.ts +19 -2
  171. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport {\n consoleIntegration,\n conversationIdIntegration,\n dedupeIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n inboundFiltersIntegration,\n initAndBind,\n linkedErrorsIntegration,\n requestDataIntegration,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport type { CloudflareClientOptions, CloudflareOptions } from './client';\nimport { CloudflareClient } from './client';\nimport { makeFlushLock } from './flush';\nimport { fetchIntegration } from './integrations/fetch';\nimport { honoIntegration } from './integrations/hono';\nimport { setupOpenTelemetryTracer } from './opentelemetry/tracer';\nimport { makeCloudflareTransport } from './transport';\nimport { defaultStackParser } from './vendor/stacktrace';\n\n/** Get the default integrations for the Cloudflare SDK. */\nexport function getDefaultIntegrations(options: CloudflareOptions): Integration[] {\n const sendDefaultPii = options.sendDefaultPii ?? false;\n return [\n // The Dedupe integration should not be used in workflows because we want to\n // capture all step failures, even if they are the same error.\n ...(options.enableDedupe === false ? [] : [dedupeIntegration()]),\n // TODO(v11): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n // eslint-disable-next-line deprecation/deprecation\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n conversationIdIntegration(),\n linkedErrorsIntegration(),\n fetchIntegration(),\n honoIntegration(),\n // TODO(v11): the `include` object should be defined directly in the integration based on `sendDefaultPii`\n requestDataIntegration(sendDefaultPii ? undefined : { include: { cookies: false } }),\n consoleIntegration(),\n ];\n}\n\n/**\n * Initializes the cloudflare SDK.\n */\nexport function init(options: CloudflareOptions): CloudflareClient | undefined {\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = getDefaultIntegrations(options);\n }\n\n const flushLock = options.ctx ? makeFlushLock(options.ctx) : undefined;\n delete options.ctx;\n\n const clientOptions: CloudflareClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: getIntegrationsToSetup(options),\n transport: options.transport || makeCloudflareTransport,\n flushLock,\n };\n\n /**\n * The Cloudflare SDK is not OpenTelemetry native, however, we set up some OpenTelemetry compatibility\n * via a custom trace provider.\n * This ensures that any spans emitted via `@opentelemetry/api` will be captured by Sentry.\n * HOWEVER, big caveat: This does not handle custom context handling, it will always work off the current scope.\n * This should be good enough for many, but not all integrations.\n */\n if (!options.skipOpenTelemetrySetup) {\n setupOpenTelemetryTracer();\n }\n\n return initAndBind(CloudflareClient, clientOptions) as CloudflareClient;\n}\n"],"names":[],"mappings":";;;;;;;;;AAsBA;AACO,SAAS,sBAAsB,CAAC,OAAO,EAAoC;AAClF,EAAE,MAAM,cAAA,GAAiB,OAAO,CAAC,cAAA,IAAkB,KAAK;AACxD,EAAE,OAAO;AACT;AACA;AACA,IAAI,IAAI,OAAO,CAAC,YAAA,KAAiB,KAAA,GAAQ,EAAC,GAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;AACpE;AACA;AACA,IAAI,yBAAyB,EAAE;AAC/B,IAAI,2BAA2B,EAAE;AACjC,IAAI,yBAAyB,EAAE;AAC/B,IAAI,uBAAuB,EAAE;AAC7B,IAAI,gBAAgB,EAAE;AACtB,IAAI,eAAe,EAAE;AACrB;AACA,IAAI,sBAAsB,CAAC,cAAA,GAAiB,YAAY,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,KAAA,EAAM,EAAG,CAAC;AACxF,IAAI,kBAAkB,EAAE;AACxB,GAAG;AACH;;AAEA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAmD;AAC/E,EAAE,IAAI,OAAO,CAAC,mBAAA,KAAwB,SAAS,EAAE;AACjD,IAAI,OAAO,CAAC,mBAAA,GAAsB,sBAAsB,CAAC,OAAO,CAAC;AACjE,EAAE;;AAEF,EAAE,MAAM,SAAA,GAAY,OAAO,CAAC,GAAA,GAAM,aAAa,CAAC,OAAO,CAAC,GAAG,CAAA,GAAI,SAAS;AACxE,EAAE,OAAO,OAAO,CAAC,GAAG;;AAEpB,EAAE,MAAM,aAAa,GAA4B;AACjD,IAAI,GAAG,OAAO;AACd,IAAI,WAAW,EAAE,iCAAiC,CAAC,OAAO,CAAC,WAAA,IAAe,kBAAkB,CAAC;AAC7F,IAAI,YAAY,EAAE,sBAAsB,CAAC,OAAO,CAAC;AACjD,IAAI,SAAS,EAAE,OAAO,CAAC,SAAA,IAAa,uBAAuB;AAC3D,IAAI,SAAS;AACb,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE;AACvC,IAAI,wBAAwB,EAAE;AAC9B,EAAE;;AAEF,EAAE,OAAO,WAAW,CAAC,gBAAgB,EAAE,aAAa,CAAA;AACpD;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport {\n consoleIntegration,\n conversationIdIntegration,\n dedupeIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n inboundFiltersIntegration,\n initAndBind,\n linkedErrorsIntegration,\n requestDataIntegration,\n spanStreamingIntegration,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport type { CloudflareClientOptions, CloudflareOptions } from './client';\nimport { CloudflareClient } from './client';\nimport { makeFlushLock } from './flush';\nimport { fetchIntegration } from './integrations/fetch';\nimport { honoIntegration } from './integrations/hono';\nimport { setupOpenTelemetryTracer } from './opentelemetry/tracer';\nimport { makeCloudflareTransport } from './transport';\nimport { defaultStackParser } from './vendor/stacktrace';\n\n/** Get the default integrations for the Cloudflare SDK. */\nexport function getDefaultIntegrations(options: CloudflareOptions): Integration[] {\n const sendDefaultPii = options.sendDefaultPii ?? false;\n return [\n // The Dedupe integration should not be used in workflows because we want to\n // capture all step failures, even if they are the same error.\n ...(options.enableDedupe === false ? [] : [dedupeIntegration()]),\n // TODO(v11): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n // eslint-disable-next-line deprecation/deprecation\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n conversationIdIntegration(),\n linkedErrorsIntegration(),\n fetchIntegration(),\n honoIntegration(),\n // TODO(v11): the `include` object should be defined directly in the integration based on `sendDefaultPii`\n requestDataIntegration(sendDefaultPii ? undefined : { include: { cookies: false } }),\n consoleIntegration(),\n ];\n}\n\n/**\n * Initializes the cloudflare SDK.\n */\nexport function init(options: CloudflareOptions): CloudflareClient | undefined {\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = getDefaultIntegrations(options);\n }\n\n const flushLock = options.ctx ? makeFlushLock(options.ctx) : undefined;\n delete options.ctx;\n\n const resolvedIntegrations = getIntegrationsToSetup(options);\n if (options.traceLifecycle === 'stream' && !resolvedIntegrations.some(i => i.name === 'SpanStreaming')) {\n resolvedIntegrations.push(spanStreamingIntegration());\n }\n\n const clientOptions: CloudflareClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: resolvedIntegrations,\n transport: options.transport || makeCloudflareTransport,\n flushLock,\n };\n\n /**\n * The Cloudflare SDK is not OpenTelemetry native, however, we set up some OpenTelemetry compatibility\n * via a custom trace provider.\n * This ensures that any spans emitted via `@opentelemetry/api` will be captured by Sentry.\n * HOWEVER, big caveat: This does not handle custom context handling, it will always work off the current scope.\n * This should be good enough for many, but not all integrations.\n */\n if (!options.skipOpenTelemetrySetup) {\n setupOpenTelemetryTracer();\n }\n\n return initAndBind(CloudflareClient, clientOptions) as CloudflareClient;\n}\n"],"names":[],"mappings":";;;;;;;;;AAuBA;AACO,SAAS,sBAAsB,CAAC,OAAO,EAAoC;AAClF,EAAE,MAAM,cAAA,GAAiB,OAAO,CAAC,cAAA,IAAkB,KAAK;AACxD,EAAE,OAAO;AACT;AACA;AACA,IAAI,IAAI,OAAO,CAAC,YAAA,KAAiB,KAAA,GAAQ,EAAC,GAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;AACpE;AACA;AACA,IAAI,yBAAyB,EAAE;AAC/B,IAAI,2BAA2B,EAAE;AACjC,IAAI,yBAAyB,EAAE;AAC/B,IAAI,uBAAuB,EAAE;AAC7B,IAAI,gBAAgB,EAAE;AACtB,IAAI,eAAe,EAAE;AACrB;AACA,IAAI,sBAAsB,CAAC,cAAA,GAAiB,YAAY,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,KAAA,EAAM,EAAG,CAAC;AACxF,IAAI,kBAAkB,EAAE;AACxB,GAAG;AACH;;AAEA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAmD;AAC/E,EAAE,IAAI,OAAO,CAAC,mBAAA,KAAwB,SAAS,EAAE;AACjD,IAAI,OAAO,CAAC,mBAAA,GAAsB,sBAAsB,CAAC,OAAO,CAAC;AACjE,EAAE;;AAEF,EAAE,MAAM,SAAA,GAAY,OAAO,CAAC,GAAA,GAAM,aAAa,CAAC,OAAO,CAAC,GAAG,CAAA,GAAI,SAAS;AACxE,EAAE,OAAO,OAAO,CAAC,GAAG;;AAEpB,EAAE,MAAM,oBAAA,GAAuB,sBAAsB,CAAC,OAAO,CAAC;AAC9D,EAAE,IAAI,OAAO,CAAC,mBAAmB,QAAA,IAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAA,KAAS,eAAe,CAAC,EAAE;AAC1G,IAAI,oBAAoB,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC;AACzD,EAAE;;AAEF,EAAE,MAAM,aAAa,GAA4B;AACjD,IAAI,GAAG,OAAO;AACd,IAAI,WAAW,EAAE,iCAAiC,CAAC,OAAO,CAAC,WAAA,IAAe,kBAAkB,CAAC;AAC7F,IAAI,YAAY,EAAE,oBAAoB;AACtC,IAAI,SAAS,EAAE,OAAO,CAAC,SAAA,IAAa,uBAAuB;AAC3D,IAAI,SAAS;AACb,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE;AACvC,IAAI,wBAAwB,EAAE;AAC9B,EAAE;;AAEF,EAAE,OAAO,WAAW,CAAC,gBAAgB,EAAE,aAAa,CAAA;AACpD;;;;"}
@@ -37,13 +37,14 @@ function instrumentContext(ctx) {
37
37
  // If so, wrap the storage with instrumentation
38
38
  if ('storage' in ctx && ctx.storage) {
39
39
  const originalStorage = ctx.storage;
40
+ const waitUntil = 'waitUntil' in ctx && typeof ctx.waitUntil === 'function' ? ctx.waitUntil.bind(ctx) : undefined;
40
41
  let instrumentedStorage;
41
42
  descriptors.storage = {
42
43
  configurable: true,
43
44
  enumerable: true,
44
45
  get: () => {
45
46
  if (!instrumentedStorage) {
46
- instrumentedStorage = instrumentDurableObjectStorage(originalStorage);
47
+ instrumentedStorage = instrumentDurableObjectStorage(originalStorage, waitUntil);
47
48
  }
48
49
  return instrumentedStorage;
49
50
  },
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentContext.js","sources":["../../../src/utils/instrumentContext.ts"],"sourcesContent":["import { type DurableObjectState, type DurableObjectStorage, type ExecutionContext } from '@cloudflare/workers-types';\nimport { instrumentDurableObjectStorage } from '../instrumentations/instrumentDurableObjectStorage';\n\ntype ContextType = ExecutionContext | DurableObjectState;\ntype OverridesStore<T extends ContextType> = Map<keyof T, (...args: unknown[]) => unknown>;\n\n/**\n * Instruments an execution context or DurableObjectState with Sentry tracing.\n *\n * Creates a copy of the context that:\n * - Allows overriding of methods (e.g., waitUntil)\n * - For DurableObjectState: instruments storage operations (get, put, delete, list, etc.)\n * to create Sentry spans automatically\n *\n * @param ctx - The execution context or DurableObjectState to instrument\n * @returns An instrumented copy of the context\n */\nexport function instrumentContext<T extends ContextType>(ctx: T): T {\n if (!ctx) return ctx;\n\n const overrides: OverridesStore<T> = new Map();\n const contextPrototype = Object.getPrototypeOf(ctx);\n const prototypeMethodNames = Object.getOwnPropertyNames(contextPrototype) as unknown as (keyof T)[];\n const ownPropertyNames = Object.getOwnPropertyNames(ctx) as unknown as (keyof T)[];\n const instrumented = new Set<unknown>(['constructor']);\n const descriptors: PropertyDescriptorMap = [...ownPropertyNames, ...prototypeMethodNames].reduce(\n (prevDescriptors, methodName) => {\n if (instrumented.has(methodName)) return prevDescriptors;\n if (typeof ctx[methodName] !== 'function') return prevDescriptors;\n instrumented.add(methodName);\n const overridableDescriptor = makeOverridableDescriptor(overrides, ctx, methodName);\n return {\n ...prevDescriptors,\n [methodName]: overridableDescriptor,\n };\n },\n {} as PropertyDescriptorMap,\n );\n\n // Check if this is a DurableObjectState context with a storage property\n // If so, wrap the storage with instrumentation\n if ('storage' in ctx && ctx.storage) {\n const originalStorage = ctx.storage;\n let instrumentedStorage: DurableObjectStorage | undefined;\n descriptors.storage = {\n configurable: true,\n enumerable: true,\n get: () => {\n if (!instrumentedStorage) {\n instrumentedStorage = instrumentDurableObjectStorage(originalStorage);\n }\n return instrumentedStorage;\n },\n };\n // Expose the original uninstrumented storage for internal Sentry operations\n // This avoids creating spans for internal storage operations\n descriptors.originalStorage = {\n configurable: true,\n enumerable: false,\n get: () => originalStorage,\n };\n }\n\n return Object.create(ctx, descriptors);\n}\n\n/**\n * Creates a property descriptor that allows overriding of a method on the given context object.\n *\n * This descriptor supports property overriding with functions only. It delegates method calls to\n * the provided store if an override exists or to the original method on the context otherwise.\n *\n * @param {OverridesStore<ContextType>} store - The storage for overridden methods specific to the context type.\n * @param {ContextType} ctx - The context object that contains the method to be overridden.\n * @param {keyof ContextType} method - The method on the context object to create the overridable descriptor for.\n * @return {PropertyDescriptor} A property descriptor enabling the overriding of the specified method.\n */\nfunction makeOverridableDescriptor<T extends ContextType>(\n store: OverridesStore<T>,\n ctx: T,\n method: keyof T,\n): PropertyDescriptor {\n return {\n configurable: true,\n enumerable: true,\n set: newValue => {\n if (typeof newValue == 'function') {\n store.set(method, newValue);\n return;\n }\n Reflect.set(ctx, method, newValue);\n },\n\n get: () => {\n if (store.has(method)) return store.get(method);\n const methodFunction = Reflect.get(ctx, method);\n if (typeof methodFunction !== 'function') return methodFunction;\n // We should do bind() to make sure that the method is bound to the context object - otherwise it will not work\n return methodFunction.bind(ctx);\n },\n };\n}\n"],"names":[],"mappings":";;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAwB,GAAG,EAAQ;AACpE,EAAE,IAAI,CAAC,GAAG,EAAE,OAAO,GAAG;;AAEtB,EAAE,MAAM,SAAS,GAAsB,IAAI,GAAG,EAAE;AAChD,EAAE,MAAM,mBAAmB,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC;AACrD,EAAE,MAAM,uBAAuB,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,CAAA;AAC1E,EAAE,MAAM,mBAAmB,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAA;AACzD,EAAE,MAAM,eAAe,IAAI,GAAG,CAAU,CAAC,aAAa,CAAC,CAAC;AACxD,EAAE,MAAM,WAAW,GAA0B,CAAC,GAAG,gBAAgB,EAAE,GAAG,oBAAoB,CAAC,CAAC,MAAM;AAClG,IAAI,CAAC,eAAe,EAAE,UAAU,KAAK;AACrC,MAAM,IAAI,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,OAAO,eAAe;AAC9D,MAAM,IAAI,OAAO,GAAG,CAAC,UAAU,CAAA,KAAM,UAAU,EAAE,OAAO,eAAe;AACv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UAAU,EAAE;AACzC,QAAQ,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC;AACnC,QAAQ;AACR,MAAM;AACN,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC;AACxC,IAAI,CAAC;;AAEL,IAAI,GAAG,EAAE,MAAM;AACf,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC;AACrD,MAAM,MAAM,cAAA,GAAiB,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC;AACrD,MAAM,IAAI,OAAO,cAAA,KAAmB,UAAU,EAAE,OAAO,cAAc;AACrE;AACA,MAAM,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC;AACrC,IAAI,CAAC;AACL,GAAG;AACH;;;;"}
1
+ {"version":3,"file":"instrumentContext.js","sources":["../../../src/utils/instrumentContext.ts"],"sourcesContent":["import { type DurableObjectState, type DurableObjectStorage, type ExecutionContext } from '@cloudflare/workers-types';\nimport { instrumentDurableObjectStorage } from '../instrumentations/instrumentDurableObjectStorage';\n\ntype ContextType = ExecutionContext | DurableObjectState;\ntype OverridesStore<T extends ContextType> = Map<keyof T, (...args: unknown[]) => unknown>;\n\n/**\n * Instruments an execution context or DurableObjectState with Sentry tracing.\n *\n * Creates a copy of the context that:\n * - Allows overriding of methods (e.g., waitUntil)\n * - For DurableObjectState: instruments storage operations (get, put, delete, list, etc.)\n * to create Sentry spans automatically\n *\n * @param ctx - The execution context or DurableObjectState to instrument\n * @returns An instrumented copy of the context\n */\nexport function instrumentContext<T extends ContextType>(ctx: T): T {\n if (!ctx) return ctx;\n\n const overrides: OverridesStore<T> = new Map();\n const contextPrototype = Object.getPrototypeOf(ctx);\n const prototypeMethodNames = Object.getOwnPropertyNames(contextPrototype) as unknown as (keyof T)[];\n const ownPropertyNames = Object.getOwnPropertyNames(ctx) as unknown as (keyof T)[];\n const instrumented = new Set<unknown>(['constructor']);\n const descriptors: PropertyDescriptorMap = [...ownPropertyNames, ...prototypeMethodNames].reduce(\n (prevDescriptors, methodName) => {\n if (instrumented.has(methodName)) return prevDescriptors;\n if (typeof ctx[methodName] !== 'function') return prevDescriptors;\n instrumented.add(methodName);\n const overridableDescriptor = makeOverridableDescriptor(overrides, ctx, methodName);\n return {\n ...prevDescriptors,\n [methodName]: overridableDescriptor,\n };\n },\n {} as PropertyDescriptorMap,\n );\n\n // Check if this is a DurableObjectState context with a storage property\n // If so, wrap the storage with instrumentation\n if ('storage' in ctx && ctx.storage) {\n const originalStorage = ctx.storage;\n const waitUntil = 'waitUntil' in ctx && typeof ctx.waitUntil === 'function' ? ctx.waitUntil.bind(ctx) : undefined;\n let instrumentedStorage: DurableObjectStorage | undefined;\n descriptors.storage = {\n configurable: true,\n enumerable: true,\n get: () => {\n if (!instrumentedStorage) {\n instrumentedStorage = instrumentDurableObjectStorage(originalStorage, waitUntil);\n }\n return instrumentedStorage;\n },\n };\n // Expose the original uninstrumented storage for internal Sentry operations\n // This avoids creating spans for internal storage operations\n descriptors.originalStorage = {\n configurable: true,\n enumerable: false,\n get: () => originalStorage,\n };\n }\n\n return Object.create(ctx, descriptors);\n}\n\n/**\n * Creates a property descriptor that allows overriding of a method on the given context object.\n *\n * This descriptor supports property overriding with functions only. It delegates method calls to\n * the provided store if an override exists or to the original method on the context otherwise.\n *\n * @param {OverridesStore<ContextType>} store - The storage for overridden methods specific to the context type.\n * @param {ContextType} ctx - The context object that contains the method to be overridden.\n * @param {keyof ContextType} method - The method on the context object to create the overridable descriptor for.\n * @return {PropertyDescriptor} A property descriptor enabling the overriding of the specified method.\n */\nfunction makeOverridableDescriptor<T extends ContextType>(\n store: OverridesStore<T>,\n ctx: T,\n method: keyof T,\n): PropertyDescriptor {\n return {\n configurable: true,\n enumerable: true,\n set: newValue => {\n if (typeof newValue == 'function') {\n store.set(method, newValue);\n return;\n }\n Reflect.set(ctx, method, newValue);\n },\n\n get: () => {\n if (store.has(method)) return store.get(method);\n const methodFunction = Reflect.get(ctx, method);\n if (typeof methodFunction !== 'function') return methodFunction;\n // We should do bind() to make sure that the method is bound to the context object - otherwise it will not work\n return methodFunction.bind(ctx);\n },\n };\n}\n"],"names":[],"mappings":";;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAwB,GAAG,EAAQ;AACpE,EAAE,IAAI,CAAC,GAAG,EAAE,OAAO,GAAG;;AAEtB,EAAE,MAAM,SAAS,GAAsB,IAAI,GAAG,EAAE;AAChD,EAAE,MAAM,mBAAmB,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC;AACrD,EAAE,MAAM,uBAAuB,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,CAAA;AAC1E,EAAE,MAAM,mBAAmB,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAA;AACzD,EAAE,MAAM,eAAe,IAAI,GAAG,CAAU,CAAC,aAAa,CAAC,CAAC;AACxD,EAAE,MAAM,WAAW,GAA0B,CAAC,GAAG,gBAAgB,EAAE,GAAG,oBAAoB,CAAC,CAAC,MAAM;AAClG,IAAI,CAAC,eAAe,EAAE,UAAU,KAAK;AACrC,MAAM,IAAI,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,OAAO,eAAe;AAC9D,MAAM,IAAI,OAAO,GAAG,CAAC,UAAU,CAAA,KAAM,UAAU,EAAE,OAAO,eAAe;AACvE,MAAM,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC;AAClC,MAAM,MAAM,qBAAA,GAAwB,yBAAyB,CAAC,SAAS,EAAE,GAAG,EAAE,UAAU,CAAC;AACzF,MAAM,OAAO;AACb,QAAQ,GAAG,eAAe;AAC1B,QAAQ,CAAC,UAAU,GAAG,qBAAqB;AAC3C,OAAO;AACP,IAAI,CAAC;AACL,IAAI,EAAC;AACL,GAAG;;AAEH;AACA;AACA,EAAE,IAAI,SA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E,MAAM,EAAE,QAAQ,CAAC;AACxC,IAAI,CAAC;;AAEL,IAAI,GAAG,EAAE,MAAM;AACf,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC;AACrD,MAAM,MAAM,cAAA,GAAiB,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC;AACrD,MAAM,IAAI,OAAO,cAAA,KAAmB,UAAU,EAAE,OAAO,cAAc;AACrE;AACA,MAAM,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC;AACrC,IAAI,CAAC;AACL,GAAG;AACH;;;;"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Checks if a value is a JSRPC proxy (service binding).
3
+ *
4
+ * JSRPC proxies return a truthy value for ANY property access, including
5
+ * properties that don't exist. This makes other duck-type checks unreliable
6
+ * unless we exclude JSRPC first.
7
+ *
8
+ * Must be checked before other binding type checks.
9
+ */
10
+ function isJSRPC(item) {
11
+ try {
12
+ return !!(item )[`__some_property_that_will_never_exist__${Math.random()}`];
13
+ } catch {
14
+ return false;
15
+ }
16
+ }
17
+
18
+ const isNotJSRPC = (item) => !isJSRPC(item);
19
+
20
+ /**
21
+ * Duck-type check for DurableObjectNamespace bindings.
22
+ * DurableObjectNamespace has `idFromName`, `idFromString`, `get`, `newUniqueId`.
23
+ */
24
+ function isDurableObjectNamespace(item) {
25
+ return item != null && isNotJSRPC(item) && typeof item.idFromName === 'function';
26
+ }
27
+
28
+ export { isDurableObjectNamespace, isJSRPC };
29
+ //# sourceMappingURL=isBinding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isBinding.js","sources":["../../../src/utils/isBinding.ts"],"sourcesContent":["/**\n * Adapted from https://github.com/evanderkoogh/otel-cf-workers/blob/effeb549f0a4ed1c55ea0c4f0d8e8e37e5494fb3/src/instrumentation/env.ts\n *\n * BSD 3-Clause License\n *\n * Copyright (c) 2023, Erwin van der Koogh\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * 3. Neither the name of the copyright holder nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport type { DurableObjectNamespace } from '@cloudflare/workers-types';\n\n/**\n * Checks if a value is a JSRPC proxy (service binding).\n *\n * JSRPC proxies return a truthy value for ANY property access, including\n * properties that don't exist. This makes other duck-type checks unreliable\n * unless we exclude JSRPC first.\n *\n * Must be checked before other binding type checks.\n */\nexport function isJSRPC(item: unknown): item is Service {\n try {\n return !!(item as Record<string, unknown>)[`__some_property_that_will_never_exist__${Math.random()}`];\n } catch {\n return false;\n }\n}\n\nconst isNotJSRPC = (item: unknown): item is Record<string, unknown> => !isJSRPC(item);\n\n/**\n * Duck-type check for DurableObjectNamespace bindings.\n * DurableObjectNamespace has `idFromName`, `idFromString`, `get`, `newUniqueId`.\n */\nexport function isDurableObjectNamespace(item: unknown): item is DurableObjectNamespace {\n return item != null && isNotJSRPC(item) && typeof item.idFromName === 'function';\n}\n"],"names":[],"mappings":"AAmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,OAAO,CAAC,IAAI,EAA4B;AACxD,EAAE,IAAI;AACN,IAAI,OAAO,CAAC,CAAC,CAAC,IAAA,GAAiC,CAAC,uCAAuC,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA,CAAA;AACA,EAAA,CAAA,CAAA,MAAA;AACA,IAAA,OAAA,KAAA;AACA,EAAA;AACA;;AAEA,MAAA,UAAA,GAAA,CAAA,IAAA,KAAA,CAAA,OAAA,CAAA,IAAA,CAAA;;AAEA;AACA;AACA;AACA;AACA,SAAA,wBAAA,CAAA,IAAA,EAAA;AACA,EAAA,OAAA,IAAA,IAAA,IAAA,IAAA,UAAA,CAAA,IAAA,CAAA,IAAA,OAAA,IAAA,CAAA,UAAA,KAAA,UAAA;AACA;;;;"}
@@ -0,0 +1,27 @@
1
+ function isCloudflareClass(value, className) {
2
+ if (!value || typeof value !== 'function') {
3
+ return false;
4
+ }
5
+
6
+ if (value.name === className) {
7
+ return false;
8
+ }
9
+
10
+ let proto = value.prototype;
11
+
12
+ while (proto) {
13
+ const ctor = (proto ).constructor;
14
+ const constructorName = ctor?.name;
15
+
16
+ if (constructorName === className) {
17
+ return true;
18
+ }
19
+
20
+ proto = Object.getPrototypeOf(proto);
21
+ }
22
+
23
+ return false;
24
+ }
25
+
26
+ export { isCloudflareClass };
27
+ //# sourceMappingURL=isCloudflareClass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isCloudflareClass.js","sources":["../../../src/utils/isCloudflareClass.ts"],"sourcesContent":["import type { DurableObject, WorkflowEntrypoint } from 'cloudflare:workers';\nimport type { WorkerEntrypointConstructor } from '../instrumentations/instrumentWorkerEntrypoint';\ntype CloudflareClassName = 'WorkerEntrypoint' | 'DurableObject' | 'WorkflowEntrypoint';\n\n/**\n * Checks if a class constructor extends a specific Cloudflare base class.\n *\n * Uses prototype chain walking with constructor names rather than instanceof,\n * so it works in Node at build time without requiring the cloudflare:workers\n * module (which only exists in the Workers runtime).\n *\n * This is used to differentiate between different Cloudflare worker types:\n * - WorkerEntrypoint: Class-based workers (used with instrumentWorkerEntrypoint)\n * - DurableObject: Durable Object classes\n * - Workflow: Workflow classes\n *\n * For ExportedHandler (plain objects), this will return false for all types.\n *\n * @param value - The value to check (typically a class constructor)\n * @param className - The Cloudflare base class name to check against\n * @returns true if the value is a class that extends the specified Cloudflare class\n *\n * @example\n * ```ts\n * isCloudflareClass(MyWorker, 'WorkerEntrypoint') // true if MyWorker extends WorkerEntrypoint\n * isCloudflareClass(MyDO, 'DurableObject') // true if MyDO extends DurableObject\n * ```\n */\nexport function isCloudflareClass(value: unknown, className: 'WorkerEntrypoint'): value is WorkerEntrypointConstructor;\nexport function isCloudflareClass(\n value: unknown,\n className: 'DurableObject',\n): value is new (...args: unknown[]) => DurableObject;\nexport function isCloudflareClass(\n value: unknown,\n className: 'WorkflowEntrypoint',\n): value is new (...args: unknown[]) => WorkflowEntrypoint;\nexport function isCloudflareClass(value: unknown, className: CloudflareClassName): boolean {\n if (!value || typeof value !== 'function') {\n return false;\n }\n\n if (value.name === className) {\n return false;\n }\n\n let proto: object | null = value.prototype;\n\n while (proto) {\n const ctor = (proto as { constructor?: { name?: string } }).constructor;\n const constructorName = ctor?.name;\n\n if (constructorName === className) {\n return true;\n }\n\n proto = Object.getPrototypeOf(proto);\n }\n\n return false;\n}\n"],"names":[],"mappings":"AAqCO,SAAS,iBAAiB,CAAC,KAAK,EAAW,SAAS,EAAgC;AAC3F,EAAE,IAAI,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,UAAU,EAAE;AAC7C,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,IAAI,KAAK,CAAC,IAAA,KAAS,SAAS,EAAE;AAChC,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,IAAI,KAAK,GAAkB,KAAK,CAAC,SAAS;;AAE5C,EAAE,OAAO,KAAK,EAAE;AAChB,IAAI,MAAM,IAAA,GAAO,CAAC,KAAA,GAA8C,WAAW;AAC3E,IAAI,MAAM,eAAA,GAAkB,IAAI,EAAE,IAAI;;AAEtC,IAAI,IAAI,eAAA,KAAoB,SAAS,EAAE;AACvC,MAAM,OAAO,IAAI;AACjB,IAAI;;AAEJ,IAAI,QAAQ,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC;AACxC,EAAE;;AAEF,EAAE,OAAO,KAAK;AACd;;;;"}
@@ -0,0 +1,81 @@
1
+ import { debug } from '@sentry/core';
2
+ import { DEBUG_BUILD } from '../debug-build.js';
3
+
4
+ /**
5
+ * Gets the effective RPC propagation setting, handling deprecation of `instrumentPrototypeMethods`.
6
+ *
7
+ * Priority:
8
+ * 1. If `enableRpcTracePropagation` is set, use it (ignore `instrumentPrototypeMethods`)
9
+ * 2. If only `instrumentPrototypeMethods` is set, use it with deprecation warning (converted to boolean)
10
+ * 3. If neither is set, return `false`
11
+ *
12
+ * @returns The effective setting for RPC trace propagation
13
+ */
14
+ function getEffectiveRpcPropagation(options) {
15
+ const { enableRpcTracePropagation, instrumentPrototypeMethods } = options;
16
+
17
+ // If the new option is explicitly set, use it
18
+ if (enableRpcTracePropagation !== undefined) {
19
+ if (instrumentPrototypeMethods !== undefined) {
20
+ DEBUG_BUILD &&
21
+ debug.warn(
22
+ '[Sentry] Both `enableRpcTracePropagation` and `instrumentPrototypeMethods` are set. ' +
23
+ 'Using `enableRpcTracePropagation` and ignoring `instrumentPrototypeMethods`.',
24
+ );
25
+ }
26
+ return enableRpcTracePropagation;
27
+ }
28
+
29
+ // Fall back to deprecated option with warning
30
+ if (instrumentPrototypeMethods !== undefined) {
31
+ DEBUG_BUILD &&
32
+ debug.warn(
33
+ '[Sentry] `instrumentPrototypeMethods` is deprecated and will be removed in a future major version. ' +
34
+ 'Please use `enableRpcTracePropagation` instead.',
35
+ );
36
+ // instrumentPrototypeMethods can be boolean or string[], convert to boolean
37
+ return (
38
+ instrumentPrototypeMethods === true ||
39
+ (Array.isArray(instrumentPrototypeMethods) && instrumentPrototypeMethods.length > 0)
40
+ );
41
+ }
42
+
43
+ return false;
44
+ }
45
+
46
+ /**
47
+ * Gets the method filter for prototype method instrumentation.
48
+ *
49
+ * Returns:
50
+ * - `null` if no instrumentation should occur
51
+ * - `true` if all methods should be instrumented
52
+ * - `string[]` if only specific methods should be instrumented (deprecated behavior)
53
+ *
54
+ * @returns The method filter or null if no instrumentation
55
+ */
56
+ function getPrototypeMethodFilter(options) {
57
+ const { enableRpcTracePropagation, instrumentPrototypeMethods } = options;
58
+
59
+ // If the new option is explicitly set, use it (boolean only, no filtering)
60
+ if (enableRpcTracePropagation !== undefined) {
61
+ return !!enableRpcTracePropagation;
62
+ }
63
+
64
+ // Fall back to deprecated option - preserve array filtering behavior
65
+ if (instrumentPrototypeMethods !== undefined) {
66
+ if (instrumentPrototypeMethods === true) {
67
+ return true;
68
+ }
69
+
70
+ if (Array.isArray(instrumentPrototypeMethods) && instrumentPrototypeMethods.length > 0) {
71
+ return instrumentPrototypeMethods;
72
+ }
73
+
74
+ return false;
75
+ }
76
+
77
+ return false;
78
+ }
79
+
80
+ export { getEffectiveRpcPropagation, getPrototypeMethodFilter };
81
+ //# sourceMappingURL=rpcOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpcOptions.js","sources":["../../../src/utils/rpcOptions.ts"],"sourcesContent":["import { debug } from '@sentry/core';\nimport type { CloudflareOptions } from '../client';\nimport { DEBUG_BUILD } from '../debug-build';\n\n/**\n * Gets the effective RPC propagation setting, handling deprecation of `instrumentPrototypeMethods`.\n *\n * Priority:\n * 1. If `enableRpcTracePropagation` is set, use it (ignore `instrumentPrototypeMethods`)\n * 2. If only `instrumentPrototypeMethods` is set, use it with deprecation warning (converted to boolean)\n * 3. If neither is set, return `false`\n *\n * @returns The effective setting for RPC trace propagation\n */\nexport function getEffectiveRpcPropagation(options: CloudflareOptions): boolean {\n const { enableRpcTracePropagation, instrumentPrototypeMethods } = options;\n\n // If the new option is explicitly set, use it\n if (enableRpcTracePropagation !== undefined) {\n if (instrumentPrototypeMethods !== undefined) {\n DEBUG_BUILD &&\n debug.warn(\n '[Sentry] Both `enableRpcTracePropagation` and `instrumentPrototypeMethods` are set. ' +\n 'Using `enableRpcTracePropagation` and ignoring `instrumentPrototypeMethods`.',\n );\n }\n return enableRpcTracePropagation;\n }\n\n // Fall back to deprecated option with warning\n if (instrumentPrototypeMethods !== undefined) {\n DEBUG_BUILD &&\n debug.warn(\n '[Sentry] `instrumentPrototypeMethods` is deprecated and will be removed in a future major version. ' +\n 'Please use `enableRpcTracePropagation` instead.',\n );\n // instrumentPrototypeMethods can be boolean or string[], convert to boolean\n return (\n instrumentPrototypeMethods === true ||\n (Array.isArray(instrumentPrototypeMethods) && instrumentPrototypeMethods.length > 0)\n );\n }\n\n return false;\n}\n\n/**\n * Gets the method filter for prototype method instrumentation.\n *\n * Returns:\n * - `null` if no instrumentation should occur\n * - `true` if all methods should be instrumented\n * - `string[]` if only specific methods should be instrumented (deprecated behavior)\n *\n * @returns The method filter or null if no instrumentation\n */\nexport function getPrototypeMethodFilter(options: CloudflareOptions): boolean | string[] {\n const { enableRpcTracePropagation, instrumentPrototypeMethods } = options;\n\n // If the new option is explicitly set, use it (boolean only, no filtering)\n if (enableRpcTracePropagation !== undefined) {\n return !!enableRpcTracePropagation;\n }\n\n // Fall back to deprecated option - preserve array filtering behavior\n if (instrumentPrototypeMethods !== undefined) {\n if (instrumentPrototypeMethods === true) {\n return true;\n }\n\n if (Array.isArray(instrumentPrototypeMethods) && instrumentPrototypeMethods.length > 0) {\n return instr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BAA0B,CAAA,IAAK,0BAA0B,CAAC,MAAA,GAAS,CAAC,EAAE;AAC5F,MAAM,OAAO,0BAA0B;AACvC,IAAI;;AAEJ,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,OAAO,KAAK;AACd;;;;"}
@@ -0,0 +1,73 @@
1
+ import { TraceFlags } from '@opentelemetry/api';
2
+ import { getActiveSpan, spanIsSampled, debug, SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE } from '@sentry/core';
3
+ import { DEBUG_BUILD } from '../debug-build.js';
4
+
5
+ /** Storage key prefix for the span context that links consecutive method invocations */
6
+ const SENTRY_TRACE_LINK_KEY_PREFIX = '__SENTRY_TRACE_LINK__';
7
+
8
+ /** Stored span context for creating span links */
9
+
10
+ /**
11
+ * Gets the storage key for a specific method's trace link.
12
+ */
13
+ function getTraceLinkKey(methodName) {
14
+ return `${SENTRY_TRACE_LINK_KEY_PREFIX}${methodName}`;
15
+ }
16
+
17
+ /**
18
+ * Stores the current span context in Durable Object storage for trace linking.
19
+ * Uses the original uninstrumented storage to avoid creating spans for internal operations.
20
+ * Errors are silently ignored to prevent internal storage failures from propagating to user code.
21
+ */
22
+ async function storeSpanContext(originalStorage, methodName) {
23
+ try {
24
+ const activeSpan = getActiveSpan();
25
+ if (activeSpan) {
26
+ const spanContext = activeSpan.spanContext();
27
+ const storedContext = {
28
+ traceId: spanContext.traceId,
29
+ spanId: spanContext.spanId,
30
+ sampled: spanIsSampled(activeSpan),
31
+ };
32
+ await originalStorage.put(getTraceLinkKey(methodName), storedContext);
33
+ }
34
+ } catch (error) {
35
+ // Silently ignore storage errors to prevent internal failures from affecting user code
36
+ DEBUG_BUILD && debug.log(`[CloudflareClient] Error storing span context for method ${methodName}`, error);
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Retrieves a stored span context from Durable Object storage.
42
+ */
43
+ async function getStoredSpanContext(
44
+ originalStorage,
45
+ methodName,
46
+ ) {
47
+ try {
48
+ return await originalStorage.get(getTraceLinkKey(methodName));
49
+ } catch {
50
+ return undefined;
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Builds span links from a stored span context.
56
+ */
57
+ function buildSpanLinks(storedContext) {
58
+ return [
59
+ {
60
+ context: {
61
+ traceId: storedContext.traceId,
62
+ spanId: storedContext.spanId,
63
+ traceFlags: storedContext.sampled ? TraceFlags.SAMPLED : TraceFlags.NONE,
64
+ },
65
+ attributes: {
66
+ [SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE]: 'previous_trace',
67
+ },
68
+ },
69
+ ];
70
+ }
71
+
72
+ export { buildSpanLinks, getStoredSpanContext, getTraceLinkKey, storeSpanContext };
73
+ //# sourceMappingURL=traceLinks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traceLinks.js","sources":["../../../src/utils/traceLinks.ts"],"sourcesContent":["import type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport { TraceFlags } from '@opentelemetry/api';\nimport type { SpanLink } from '@sentry/core';\nimport { debug, getActiveSpan, SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE, spanIsSampled } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\n/** Storage key prefix for the span context that links consecutive method invocations */\nconst SENTRY_TRACE_LINK_KEY_PREFIX = '__SENTRY_TRACE_LINK__';\n\n/** Stored span context for creating span links */\nexport interface StoredSpanContext {\n traceId: string;\n spanId: string;\n sampled: boolean;\n}\n\n/**\n * Gets the storage key for a specific method's trace link.\n */\nexport function getTraceLinkKey(methodName: string): string {\n return `${SENTRY_TRACE_LINK_KEY_PREFIX}${methodName}`;\n}\n\n/**\n * Stores the current span context in Durable Object storage for trace linking.\n * Uses the original uninstrumented storage to avoid creating spans for internal operations.\n * Errors are silently ignored to prevent internal storage failures from propagating to user code.\n */\nexport async function storeSpanContext(originalStorage: DurableObjectStorage, methodName: string): Promise<void> {\n try {\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n const spanContext = activeSpan.spanContext();\n const storedContext: StoredSpanContext = {\n traceId: spanContext.traceId,\n spanId: spanContext.spanId,\n sampled: spanIsSampled(activeSpan),\n };\n await originalStorage.put(getTraceLinkKey(methodName), storedContext);\n }\n } catch (error) {\n // Silently ignore storage errors to prevent internal failures from affecting user code\n DEBUG_BUILD && debug.log(`[CloudflareClient] Error storing span context for method ${methodName}`, error);\n }\n}\n\n/**\n * Retrieves a stored span context from Durable Object storage.\n */\nexport async function getStoredSpanContext(\n originalStorage: DurableObjectStorage,\n methodName: string,\n): Promise<StoredSpanContext | undefined> {\n try {\n return await originalStorage.get<StoredSpanContext>(getTraceLinkKey(methodName));\n } catch {\n return undefined;\n }\n}\n\n/**\n * Builds span links from a stored span context.\n */\nexport function buildSpanLinks(storedContext: StoredSpanContext): SpanLink[] {\n return [\n {\n context: {\n traceId: storedContext.traceId,\n spanId: storedContext.spanId,\n traceFlags: storedContext.sampled ? TraceFlags.SAMPLED : TraceFlags.NONE,\n },\n attributes: {\n [SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE]: 'previous_trace',\n },\n },\n ];\n}\n"],"names":[],"mappings":";;;;AAMA;AACA,MAAM,4BAAA,GAA+B,uBAAuB;;AAE5D;;AAOA;AACA;AACA;AACO,SAAS,eAAe,CAAC,UAAU,EAAkB;AAC5D,EAAE,OAAO,CAAC,EAAA,4BAAA,CAAA,EAAA,UAAA,CAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAA,gBAAA,CAAA,eAAA,EAAA,UAAA,EAAA;AACA,EAAA,IAAA;AACA,IAAA,MAAA,UAAA,GAAA,aAAA,EAAA;AACA,IAAA,IAAA,UAAA,EAAA;AACA,MAAA,MAAA,WAAA,GAAA,UAAA,CAAA,WAAA,EAAA;AACA,MAAA,MAAA,aAAA,GAAA;AACA,QAAA,OAAA,EAAA,WAAA,CAAA,OAAA;AACA,QAAA,MAAA,EAAA,WAAA,CAAA,MAAA;AACA,QAAA,OAAA,EAAA,aAAA,CAAA,UAAA,CAAA;AACA,OAAA;AACA,MAAA,MAAA,eAAA,CAAA,GAAA,CAAA,eAAA,CAAA,UAAA,CAAA,EAAA,aAAA,CAAA;AACA,IAAA;AACA,EAAA,CAAA,CAAA,OAAA,KAAA,EAAA;AACA;AACA,IAAA,WAAA,IAAA,KAAA,CAAA,GAAA,CAAA,CAAA,yDAAA,EAAA,UAAA,CAAA,CAAA,EAAA,KAAA,CAAA;AACA,EAAA;AACA;;AAEA;AACA;AACA;AACA,eAAA,oBAAA;AACA,EAAA,eAAA;AACA,EAAA,UAAA;AACA,EAAA;AACA,EAAA,IAAA;AACA,IAAA,OAAA,MAAA,eAAA,CAAA,GAAA,CAAA,eAAA,CAAA,UAAA,CAAA,CAAA;AACA,EAAA,CAAA,CAAA,MAAA;AACA,IAAA,OAAA,SAAA;AACA,EAAA;AACA;;AAEA;AACA;AACA;AACA,SAAA,cAAA,CAAA,aAAA,EAAA;AACA,EAAA,OAAA;AACA,IAAA;AACA,MAAA,OAAA,EAAA;AACA,QAAA,OAAA,EAAA,aAAA,CAAA,OAAA;AACA,QAAA,MAAA,EAAA,aAAA,CAAA,MAAA;AACA,QAAA,UAAA,EAAA,aAAA,CAAA,OAAA,GAAA,UAAA,CAAA,OAAA,GAAA,UAAA,CAAA,IAAA;AACA,OAAA;AACA,MAAA,UAAA,EAAA;AACA,QAAA,CAAA,iCAAA,GAAA,gBAAA;AACA,OAAA;AACA,KAAA;AACA,GAAA;AACA;;;;"}
@@ -1,11 +1,13 @@
1
1
  import { setAsyncLocalStorageAsyncContextStrategy } from './async.js';
2
- import { isInstrumented, markAsInstrumented } from './instrument.js';
2
+ import { ensureInstrumented } from './instrument.js';
3
3
  import { instrumentExportedHandlerEmail } from './instrumentations/worker/instrumentEmail.js';
4
4
  import { instrumentExportedHandlerFetch } from './instrumentations/worker/instrumentFetch.js';
5
5
  import { instrumentExportedHandlerQueue } from './instrumentations/worker/instrumentQueue.js';
6
6
  import { instrumentExportedHandlerScheduled } from './instrumentations/worker/instrumentScheduled.js';
7
7
  import { instrumentExportedHandlerTail } from './instrumentations/worker/instrumentTail.js';
8
8
  import { getHonoIntegration } from './integrations/hono.js';
9
+ import { isCloudflareClass } from './utils/isCloudflareClass.js';
10
+ import { instrumentWorkerEntrypoint } from './instrumentations/instrumentWorkerEntrypoint.js';
9
11
 
10
12
  /**
11
13
  * Wrapper for Cloudflare handlers.
@@ -18,18 +20,30 @@ import { getHonoIntegration } from './integrations/hono.js';
18
20
  * @param handler {ExportedHandler} The handler to wrap.
19
21
  * @returns The wrapped handler.
20
22
  */
23
+ // TODO(v11): The generic types need to be rewritten to following to improve type safety:
24
+ // T extends ExportedHandler<any, any, any> | WorkerEntrypointConstructor<any, any>
21
25
  function withSentry
22
26
 
23
27
  (optionsCallback, handler) {
28
+ if (isCloudflareClass(handler, 'WorkerEntrypoint')) {
29
+ // oxlint-disable-next-line typescript/no-explicit-any
30
+ return instrumentWorkerEntrypoint(optionsCallback , handler);
31
+ }
32
+
24
33
  setAsyncLocalStorageAsyncContextStrategy();
25
34
 
26
35
  try {
27
- instrumentExportedHandlerFetch(handler, optionsCallback);
36
+ // oxlint-disable-next-line typescript/no-explicit-any
37
+ instrumentExportedHandlerFetch(handler, optionsCallback );
28
38
  instrumentHonoErrorHandler(handler);
29
- instrumentExportedHandlerScheduled(handler, optionsCallback);
30
- instrumentExportedHandlerEmail(handler, optionsCallback);
31
- instrumentExportedHandlerQueue(handler, optionsCallback);
32
- instrumentExportedHandlerTail(handler, optionsCallback);
39
+ // oxlint-disable-next-line typescript/no-explicit-any
40
+ instrumentExportedHandlerScheduled(handler, optionsCallback );
41
+ // oxlint-disable-next-line typescript/no-explicit-any
42
+ instrumentExportedHandlerEmail(handler, optionsCallback );
43
+ // oxlint-disable-next-line typescript/no-explicit-any
44
+ instrumentExportedHandlerQueue(handler, optionsCallback );
45
+ // oxlint-disable-next-line typescript/no-explicit-any
46
+ instrumentExportedHandlerTail(handler, optionsCallback );
33
47
  // This is here because Miniflare sometimes cannot get instrumented
34
48
  } catch {
35
49
  // Do not console anything here, we don't want to spam the console with errors
@@ -40,23 +54,20 @@ function withSentry
40
54
 
41
55
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
56
  function instrumentHonoErrorHandler(handler) {
43
- if (
44
- 'onError' in handler &&
45
- 'errorHandler' in handler &&
46
- typeof handler.errorHandler === 'function' &&
47
- !isInstrumented(handler.errorHandler)
48
- ) {
49
- handler.errorHandler = new Proxy(handler.errorHandler, {
50
- apply(target, thisArg, args) {
51
- const [err, context] = args;
52
-
53
- getHonoIntegration()?.handleHonoException(err, context);
57
+ if ('onError' in handler && 'errorHandler' in handler && typeof handler.errorHandler === 'function') {
58
+ handler.errorHandler = ensureInstrumented(
59
+ handler.errorHandler,
60
+ original =>
61
+ new Proxy(original, {
62
+ apply(target, thisArg, args) {
63
+ const [err, context] = args;
54
64
 
55
- return Reflect.apply(target, thisArg, args);
56
- },
57
- });
65
+ getHonoIntegration()?.handleHonoException(err, context);
58
66
 
59
- markAsInstrumented(handler.errorHandler);
67
+ return Reflect.apply(target, thisArg, args);
68
+ },
69
+ }),
70
+ );
60
71
  }
61
72
  }
62
73
 
@@ -1 +1 @@
1
- {"version":3,"file":"withSentry.js","sources":["../../src/withSentry.ts"],"sourcesContent":["import type { env } from 'cloudflare:workers';\nimport { setAsyncLocalStorageAsyncContextStrategy } from './async';\nimport type { CloudflareOptions } from './client';\nimport { isInstrumented, markAsInstrumented } from './instrument';\nimport { instrumentExportedHandlerEmail } from './instrumentations/worker/instrumentEmail';\nimport { instrumentExportedHandlerFetch } from './instrumentations/worker/instrumentFetch';\nimport { instrumentExportedHandlerQueue } from './instrumentations/worker/instrumentQueue';\nimport { instrumentExportedHandlerScheduled } from './instrumentations/worker/instrumentScheduled';\nimport { instrumentExportedHandlerTail } from './instrumentations/worker/instrumentTail';\nimport { getHonoIntegration } from './integrations/hono';\n\n/**\n * Wrapper for Cloudflare handlers.\n *\n * Initializes the SDK and wraps the handler with Sentry instrumentation.\n *\n * Automatically instruments the `fetch` method of the handler.\n *\n * @param optionsCallback Function that returns the options for the SDK initialization.\n * @param handler {ExportedHandler} The handler to wrap.\n * @returns The wrapped handler.\n */\nexport function withSentry<\n Env = typeof env,\n QueueHandlerMessage = unknown,\n CfHostMetadata = unknown,\n T extends ExportedHandler<Env, QueueHandlerMessage, CfHostMetadata> = ExportedHandler<\n Env,\n QueueHandlerMessage,\n CfHostMetadata\n >,\n>(optionsCallback: (env: Env) => CloudflareOptions | undefined, handler: T): T {\n setAsyncLocalStorageAsyncContextStrategy();\n\n try {\n instrumentExportedHandlerFetch(handler, optionsCallback);\n instrumentHonoErrorHandler(handler);\n instrumentExportedHandlerScheduled(handler, optionsCallback);\n instrumentExportedHandlerEmail(handler, optionsCallback);\n instrumentExportedHandlerQueue(handler, optionsCallback);\n instrumentExportedHandlerTail(handler, optionsCallback);\n // This is here because Miniflare sometimes cannot get instrumented\n } catch {\n // Do not console anything here, we don't want to spam the console with errors\n }\n\n return handler;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction instrumentHonoErrorHandler<T extends ExportedHandler<any, any, any>>(handler: T): void {\n if (\n 'onError' in handler &&\n 'errorHandler' in handler &&\n typeof handler.errorHandler === 'function' &&\n !isInstrumented(handler.errorHandler)\n ) {\n handler.errorHandler = new Proxy(handler.errorHandler, {\n apply(target, thisArg, args) {\n const [err, context] = args;\n\n getHonoIntegration()?.handleHonoException(err, context);\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n\n markAsInstrumented(handler.errorHandler);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS;;AAShB,CAAE,eAAe,EAA+C,OAAO,EAAQ;AAC/E,EAAE,wCAAwC,EAAE;;AAE5C,EAAE,IAAI;AACN,IAAI,8BAA8B,CAAC,OAAO,EAAE,eAAe,CAAC;AAC5D,IAAI,0BAA0B,CAAC,OAAO,CAAC;AACvC,IAAI,kCAAkC,CAAC,OAAO,EAAE,eAAe,CAAC;AAChE,IAAI,8BAA8B,CAAC,OAAO,EAAE,eAAe,CAAC;AAC5D,IAAI,8BAA8B,CAAC,OAAO,EAAE,eAAe,CAAC;AAC5D,IAAI,6BAA6B,CAAC,OAAO,EAAE,eAAe,CAAC;AAC3D;AACA,EAAE,EAAE,MAAM;AACV;AACA,EAAE;;AAEF,EAAE,OAAO,OAAO;AAChB;;AAEA;AACA,SAAS,0BAA0B,CAA2C,OAAO,EAAW;AAChG,EAAE;AACF,IAAI,SAAA,IAAa,OAAA;AACjB,IAAI,cAAA,IAAkB,OAAA;AACtB,IAAI,OAAO,OAAO,CAAC,YAAA,KAAiB,UAAA;AACpC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,YAAY;AACxC,IAAI;AACJ,IAAI,OAAO,CAAC,YAAA,GAAe,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE;AAC3D,MAAM,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE;AACnC,QAAQ,MAAM,CAAC,GAAG,EAAE,OAAO,CAAA,GAAI,IAAI;;AAEnC,QAAQ,kBAAkB,EAAE,EAAE,mBAAmB,CAAC,GAAG,EAAE,OAAO,CAAC;;AAE/D,QAAQ,OAAO,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;AACnD,MAAM,CAAC;AACP,KAAK,CAAC;;AAEN,IAAI,kBAAkB,CAAC,OAAO,CAAC,YAAY,CAAC;AAC5C,EAAE;AACF;;;;"}
1
+ {"version":3,"file":"withSentry.js","sources":["../../src/withSentry.ts"],"sourcesContent":["import type { env as cloudflareEnv } from 'cloudflare:workers';\nimport { setAsyncLocalStorageAsyncContextStrategy } from './async';\nimport type { CloudflareOptions } from './client';\nimport { ensureInstrumented } from './instrument';\nimport { instrumentExportedHandlerEmail } from './instrumentations/worker/instrumentEmail';\nimport { instrumentExportedHandlerFetch } from './instrumentations/worker/instrumentFetch';\nimport { instrumentExportedHandlerQueue } from './instrumentations/worker/instrumentQueue';\nimport { instrumentExportedHandlerScheduled } from './instrumentations/worker/instrumentScheduled';\nimport { instrumentExportedHandlerTail } from './instrumentations/worker/instrumentTail';\nimport { getHonoIntegration } from './integrations/hono';\nimport { isCloudflareClass } from './utils/isCloudflareClass';\nimport {\n instrumentWorkerEntrypoint,\n type WorkerEntrypointConstructor,\n} from './instrumentations/instrumentWorkerEntrypoint';\n\n/**\n * Wrapper for Cloudflare handlers.\n *\n * Initializes the SDK and wraps the handler with Sentry instrumentation.\n *\n * Automatically instruments the `fetch` method of the handler.\n *\n * @param optionsCallback Function that returns the options for the SDK initialization.\n * @param handler {ExportedHandler} The handler to wrap.\n * @returns The wrapped handler.\n */\n// TODO(v11): The generic types need to be rewritten to following to improve type safety:\n// T extends ExportedHandler<any, any, any> | WorkerEntrypointConstructor<any, any>\nexport function withSentry<\n Env = typeof cloudflareEnv,\n QueueHandlerMessage = unknown,\n CfHostMetadata = unknown,\n T extends ExportedHandler<Env, QueueHandlerMessage, CfHostMetadata> | WorkerEntrypointConstructor = ExportedHandler<\n Env,\n QueueHandlerMessage,\n CfHostMetadata\n >,\n>(optionsCallback: (env: Env) => CloudflareOptions | undefined, handler: T): T {\n if (isCloudflareClass(handler, 'WorkerEntrypoint')) {\n // oxlint-disable-next-line typescript/no-explicit-any\n return instrumentWorkerEntrypoint(optionsCallback as any, handler);\n }\n\n setAsyncLocalStorageAsyncContextStrategy();\n\n try {\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerFetch(handler, optionsCallback as any);\n instrumentHonoErrorHandler(handler);\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerScheduled(handler, optionsCallback as any);\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerEmail(handler, optionsCallback as any);\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerQueue(handler, optionsCallback as any);\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerTail(handler, optionsCallback as any);\n // This is here because Miniflare sometimes cannot get instrumented\n } catch {\n // Do not console anything here, we don't want to spam the console with errors\n }\n\n return handler;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction instrumentHonoErrorHandler<T extends ExportedHandler<any, any, any>>(handler: T): void {\n if ('onError' in handler && 'errorHandler' in handler && typeof handler.errorHandler === 'function') {\n handler.errorHandler = ensureInstrumented(\n handler.errorHandler,\n original =>\n new Proxy(original, {\n apply(target, thisArg, args) {\n const [err, context] = args;\n\n getHonoIntegration()?.handleHonoException(err, context);\n\n return Reflect.apply(target, thisArg, args);\n },\n }),\n );\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS;;AAShB,CAAE,eAAe,EAA+C,OAAO,EAAQ;AAC/E,EAAE,IAAI,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,CAAC,EAAE;AACtD;AACA,IAAI,OAAO,0BAA0B,CAAC,eAAA,GAAwB,OAAO,CAAC;AACtE,EAAE;;AAEF,EAAE,wCAAwC,EAAE;;AAE5C,EAAE,IAAI;AACN;AACA,IAAI,8BAA8B,CAAC,OAAO,EAAE,iBAAuB;AACnE,IAAI,0BAA0B,CAAC,OAAO,CAAC;AACvC;AACA,IAAI,kCAAkC,CAAC,OAAO,EAAE,iBAAuB;AACvE;AACA,IAAI,8BAA8B,CAAC,OAAO,EAAE,iBAAuB;AACnE;AACA,IAAI,8BAA8B,CAAC,OAAO,EAAE,iBAAuB;AACnE;AACA,IAAI,6BAA6B,CAAC,OAAO,EAAE,iBAAuB;AAClE;AACA,EAAE,EAAE,MAAM;AACV;AACA,EAAE;;AAEF,EAAE,OAAO,OAAO;AAChB;;AAEA;AACA,SAAS,0BAA0B,CAA2C,OAAO,EAAW;AAChG,EAAE,IAAI,SAAA,IAAa,OAAA,IAAW,cAAA,IAAkB,OAAA,IAAW,OAAO,OAAO,CAAC,YAAA,KAAiB,UAAU,EAAE;AACvG,IAAI,OAAO,CAAC,YAAA,GAAe,kBAAkB;AAC7C,MAAM,OAAO,CAAC,YAAY;AAC1B,MAAM,QAAA;AACN,QAAQ,IAAI,KAAK,CAAC,QAAQ,EAAE;AAC5B,UAAU,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE;AACvC,YAAY,MAAM,CAAC,GAAG,EAAE,OAAO,CAAA,GAAI,IAAI;;AAEvC,YAAY,kBAAkB,EAAE,EAAE,mBAAmB,CAAC,GAAG,EAAE,OAAO,CAAC;;AAEnE,YAAY,OAAO,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;AACvD,UAAU,CAAC;AACX,SAAS,CAAC;AACV,KAAK;AACL,EAAE;AACF;;;;"}
@@ -1,6 +1,7 @@
1
1
  import { withIsolationScope, withScope, getCurrentScope, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, captureException, flush } from '@sentry/core';
2
2
  import { setAsyncLocalStorageAsyncContextStrategy } from './async.js';
3
3
  import { flushAndDispose } from './flush.js';
4
+ import { instrumentEnv } from './instrumentations/worker/instrumentEnv.js';
4
5
  import { addCloudResourceContext } from './scope-utils.js';
5
6
  import { init } from './sdk.js';
6
7
  import { instrumentContext } from './utils/instrumentContext.js';
@@ -131,9 +132,9 @@ function instrumentWorkflowWithSentry
131
132
  construct(target, args, newTarget) {
132
133
  const [ctx, env] = args;
133
134
  const context = instrumentContext(ctx);
134
- args[0] = context;
135
-
136
135
  const options = optionsCallback(env);
136
+ args[0] = context;
137
+ args[1] = instrumentEnv(env , options) ;
137
138
  const instance = Reflect.construct(target, args, newTarget) ;
138
139
  return new Proxy(instance, {
139
140
  get(obj, prop, receiver) {
@@ -1 +1 @@
1
- {"version":3,"file":"workflows.js","sources":["../../src/workflows.ts"],"sourcesContent":["import type { PropagationContext } from '@sentry/core';\nimport {\n captureException,\n flush,\n getCurrentScope,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n startSpan,\n withIsolationScope,\n withScope,\n} from '@sentry/core';\nimport type {\n WorkflowEntrypoint,\n WorkflowEvent,\n WorkflowSleepDuration,\n WorkflowStep,\n WorkflowStepConfig,\n WorkflowStepEvent,\n WorkflowTimeoutDuration,\n} from 'cloudflare:workers';\nimport { setAsyncLocalStorageAsyncContextStrategy } from './async';\nimport type { CloudflareOptions } from './client';\nimport { flushAndDispose } from './flush';\nimport { addCloudResourceContext } from './scope-utils';\nimport { init } from './sdk';\nimport { instrumentContext } from './utils/instrumentContext';\n\nconst UUID_REGEX = /^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$/i;\n\n/**\n * Hashes a string to a UUID using SHA-1.\n */\nexport async function deterministicTraceIdFromInstanceId(instanceId: string): Promise<string> {\n const buf = await crypto.subtle.digest('SHA-1', new TextEncoder().encode(instanceId));\n return (\n Array.from(new Uint8Array(buf))\n // We only need the first 16 bytes for the 32 characters\n .slice(0, 16)\n .map(b => b.toString(16).padStart(2, '0'))\n .join('')\n );\n}\n\nasync function propagationContextFromInstanceId(instanceId: string): Promise<PropagationContext> {\n const traceId = UUID_REGEX.test(instanceId)\n ? instanceId.replace(/-/g, '')\n : await deterministicTraceIdFromInstanceId(instanceId);\n\n // Derive sampleRand from last 4 characters of the random UUID\n //\n // We cannot store any state between workflow steps, so we derive the\n // sampleRand from the traceId itself. This ensures that the sampling is\n // consistent across all steps in the same workflow instance.\n const sampleRand = parseInt(traceId.slice(-4), 16) / 0xffff;\n\n return {\n traceId,\n sampleRand,\n };\n}\n\nclass WrappedWorkflowStep implements WorkflowStep {\n public constructor(\n private _instanceId: string,\n private _ctx: ExecutionContext,\n private _options: CloudflareOptions,\n private _step: WorkflowStep,\n ) {}\n\n public async do<T extends Rpc.Serializable<T>>(\n name: string,\n callback: (...args: unknown[]) => Promise<T>,\n ): Promise<T>;\n public async do<T extends Rpc.Serializable<T>>(\n name: string,\n config: WorkflowStepConfig,\n callback: (...args: unknown[]) => Promise<T>,\n ): Promise<T>;\n public async do<T extends Rpc.Serializable<T>>(\n name: string,\n configOrCallback: WorkflowStepConfig | (() => Promise<T>),\n maybeCallback?: (...args: unknown[]) => Promise<T>,\n ): Promise<T> {\n // Capture the current scope, so parent span (e.g., a startSpan surrounding step.do) is preserved\n const scopeForStep = getCurrentScope();\n\n const userCallback = (maybeCallback || configOrCallback) as (...args: unknown[]) => Promise<T>;\n const config = typeof configOrCallback === 'function' ? undefined : configOrCallback;\n\n const instrumentedCallback = async (...args: unknown[]): Promise<T> => {\n return startSpan(\n {\n op: 'function.step.do',\n name,\n scope: scopeForStep,\n attributes: {\n 'cloudflare.workflow.timeout': config?.timeout,\n 'cloudflare.workflow.retries.backoff': config?.retries?.backoff,\n 'cloudflare.workflow.retries.delay': config?.retries?.delay,\n 'cloudflare.workflow.retries.limit': config?.retries?.limit,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.workflow',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',\n },\n },\n async span => {\n try {\n const result = await userCallback(...args);\n span.setStatus({ code: 1 });\n return result;\n } catch (error) {\n captureException(error, { mechanism: { handled: true, type: 'auto.faas.cloudflare.workflow' } });\n throw error;\n } finally {\n this._ctx.waitUntil(flush(2000));\n }\n },\n );\n };\n\n return config ? this._step.do(name, config, instrumentedCallback) : this._step.do(name, instrumentedCallback);\n }\n\n public async sleep(name: string, duration: WorkflowSleepDuration): Promise<void> {\n return this._step.sleep(name, duration);\n }\n\n public async sleepUntil(name: string, timestamp: Date | number): Promise<void> {\n return this._step.sleepUntil(name, timestamp);\n }\n\n public async waitForEvent<T extends Rpc.Serializable<T>>(\n name: string,\n options: { type: string; timeout?: WorkflowTimeoutDuration | number },\n ): Promise<WorkflowStepEvent<T>> {\n return this._step.waitForEvent<T>(name, options);\n }\n}\n\n/**\n * Instruments a Cloudflare Workflow class with Sentry.\n *\n * @example\n * ```typescript\n * const InstrumentedWorkflow = instrumentWorkflowWithSentry(\n * (env) => ({ dsn: env.SENTRY_DSN }),\n * MyWorkflowClass\n * );\n *\n * export default InstrumentedWorkflow;\n * ```\n *\n * @param optionsCallback - Function that returns Sentry options to initialize Sentry\n * @param WorkflowClass - The workflow class to instrument\n * @returns Instrumented workflow class with the same interface\n */\nexport function instrumentWorkflowWithSentry<\n E, // Environment type\n P, // Payload type\n T extends WorkflowEntrypoint<E, P>, // WorkflowEntrypoint type\n C extends new (ctx: ExecutionContext, env: E) => T, // Constructor type of the WorkflowEntrypoint class\n>(optionsCallback: (env: E) => CloudflareOptions, WorkFlowClass: C): C {\n return new Proxy(WorkFlowClass, {\n construct(target: C, args: [ctx: ExecutionContext, env: E], newTarget) {\n const [ctx, env] = args;\n const context = instrumentContext(ctx);\n args[0] = context;\n\n const options = optionsCallback(env);\n const instance = Reflect.construct(target, args, newTarget) as T;\n return new Proxy(instance, {\n get(obj, prop, receiver) {\n if (prop === 'run') {\n return async function (event: WorkflowEvent<P>, step: WorkflowStep): Promise<unknown> {\n setAsyncLocalStorageAsyncContextStrategy();\n\n return withIsolationScope(async isolationScope => {\n const client = init({ ...options, enableDedupe: false });\n isolationScope.setClient(client);\n\n addCloudResourceContext(isolationScope);\n\n return withScope(async scope => {\n const propagationContext = await propagationContextFromInstanceId(event.instanceId);\n scope.setPropagationContext(propagationContext);\n\n try {\n return await obj.run.call(\n obj,\n event,\n new WrappedWorkflowStep(event.instanceId, context, options, step),\n );\n } finally {\n context.waitUntil(flushAndDispose(client));\n }\n });\n });\n };\n }\n return Reflect.get(obj, prop, receiver);\n },\n });\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;AA2BA,MAAM,UAAA,GAAa,qEAAqE;;AAExF;AACA;AACA;AACO,eAAe,kCAAkC,CAAC,UAAU,EAA2B;AAC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ows.ts"],"sourcesContent":["import type { PropagationContext } from '@sentry/core';\nimport {\n captureException,\n flush,\n getCurrentScope,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n startSpan,\n withIsolationScope,\n withScope,\n} from '@sentry/core';\nimport type {\n WorkflowEntrypoint,\n WorkflowEvent,\n WorkflowSleepDuration,\n WorkflowStep,\n WorkflowStepConfig,\n WorkflowStepEvent,\n WorkflowTimeoutDuration,\n} from 'cloudflare:workers';\nimport { setAsyncLocalStorageAsyncContextStrategy } from './async';\nimport type { CloudflareOptions } from './client';\nimport { flushAndDispose } from './flush';\nimport { instrumentEnv } from './instrumentations/worker/instrumentEnv';\nimport { addCloudResourceContext } from './scope-utils';\nimport { init } from './sdk';\nimport { instrumentContext } from './utils/instrumentContext';\n\nconst UUID_REGEX = /^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$/i;\n\n/**\n * Hashes a string to a UUID using SHA-1.\n */\nexport async function deterministicTraceIdFromInstanceId(instanceId: string): Promise<string> {\n const buf = await crypto.subtle.digest('SHA-1', new TextEncoder().encode(instanceId));\n return (\n Array.from(new Uint8Array(buf))\n // We only need the first 16 bytes for the 32 characters\n .slice(0, 16)\n .map(b => b.toString(16).padStart(2, '0'))\n .join('')\n );\n}\n\nasync function propagationContextFromInstanceId(instanceId: string): Promise<PropagationContext> {\n const traceId = UUID_REGEX.test(instanceId)\n ? instanceId.replace(/-/g, '')\n : await deterministicTraceIdFromInstanceId(instanceId);\n\n // Derive sampleRand from last 4 characters of the random UUID\n //\n // We cannot store any state between workflow steps, so we derive the\n // sampleRand from the traceId itself. This ensures that the sampling is\n // consistent across all steps in the same workflow instance.\n const sampleRand = parseInt(traceId.slice(-4), 16) / 0xffff;\n\n return {\n traceId,\n sampleRand,\n };\n}\n\nclass WrappedWorkflowStep implements WorkflowStep {\n public constructor(\n private _instanceId: string,\n private _ctx: ExecutionContext,\n private _options: CloudflareOptions,\n private _step: WorkflowStep,\n ) {}\n\n public async do<T extends Rpc.Serializable<T>>(\n name: string,\n callback: (...args: unknown[]) => Promise<T>,\n ): Promise<T>;\n public async do<T extends Rpc.Serializable<T>>(\n name: string,\n config: WorkflowStepConfig,\n callback: (...args: unknown[]) => Promise<T>,\n ): Promise<T>;\n public async do<T extends Rpc.Serializable<T>>(\n name: string,\n configOrCallback: WorkflowStepConfig | (() => Promise<T>),\n maybeCallback?: (...args: unknown[]) => Promise<T>,\n ): Promise<T> {\n // Capture the current scope, so parent span (e.g., a startSpan surrounding step.do) is preserved\n const scopeForStep = getCurrentScope();\n\n const userCallback = (maybeCallback || configOrCallback) as (...args: unknown[]) => Promise<T>;\n const config = typeof configOrCallback === 'function' ? undefined : configOrCallback;\n\n const instrumentedCallback = async (...args: unknown[]): Promise<T> => {\n return startSpan(\n {\n op: 'function.step.do',\n name,\n scope: scopeForStep,\n attributes: {\n 'cloudflare.workflow.timeout': config?.timeout,\n 'cloudflare.workflow.retries.backoff': config?.retries?.backoff,\n 'cloudflare.workflow.retries.delay': config?.retries?.delay,\n 'cloudflare.workflow.retries.limit': config?.retries?.limit,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.workflow',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',\n },\n },\n async span => {\n try {\n const result = await userCallback(...args);\n span.setStatus({ code: 1 });\n return result;\n } catch (error) {\n captureException(error, { mechanism: { handled: true, type: 'auto.faas.cloudflare.workflow' } });\n throw error;\n } finally {\n this._ctx.waitUntil(flush(2000));\n }\n },\n );\n };\n\n return config ? this._step.do(name, config, instrumentedCallback) : this._step.do(name, instrumentedCallback);\n }\n\n public async sleep(name: string, duration: WorkflowSleepDuration): Promise<void> {\n return this._step.sleep(name, duration);\n }\n\n public async sleepUntil(name: string, timestamp: Date | number): Promise<void> {\n return this._step.sleepUntil(name, timestamp);\n }\n\n public async waitForEvent<T extends Rpc.Serializable<T>>(\n name: string,\n options: { type: string; timeout?: WorkflowTimeoutDuration | number },\n ): Promise<WorkflowStepEvent<T>> {\n return this._step.waitForEvent<T>(name, options);\n }\n}\n\n/**\n * Instruments a Cloudflare Workflow class with Sentry.\n *\n * @example\n * ```typescript\n * const InstrumentedWorkflow = instrumentWorkflowWithSentry(\n * (env) => ({ dsn: env.SENTRY_DSN }),\n * MyWorkflowClass\n * );\n *\n * export default InstrumentedWorkflow;\n * ```\n *\n * @param optionsCallback - Function that returns Sentry options to initialize Sentry\n * @param WorkflowClass - The workflow class to instrument\n * @returns Instrumented workflow class with the same interface\n */\nexport function instrumentWorkflowWithSentry<\n E, // Environment type\n P, // Payload type\n T extends WorkflowEntrypoint<E, P>, // WorkflowEntrypoint type\n C extends new (ctx: ExecutionContext, env: E) => T, // Constructor type of the WorkflowEntrypoint class\n>(optionsCallback: (env: E) => CloudflareOptions, WorkFlowClass: C): C {\n return new Proxy(WorkFlowClass, {\n construct(target: C, args: [ctx: ExecutionContext, env: E], newTarget) {\n const [ctx, env] = args;\n const context = instrumentContext(ctx);\n const options = optionsCallback(env);\n args[0] = context;\n args[1] = instrumentEnv(env as Record<string, unknown>, options) as E;\n const instance = Reflect.construct(target, args, newTarget) as T;\n return new Proxy(instance, {\n get(obj, prop, receiver) {\n if (prop === 'run') {\n return async function (event: WorkflowEvent<P>, step: WorkflowStep): Promise<unknown> {\n setAsyncLocalStorageAsyncContextStrategy();\n\n return withIsolationScope(async isolationScope => {\n const client = init({ ...options, enableDedupe: false });\n isolationScope.setClient(client);\n\n addCloudResourceContext(isolationScope);\n\n return withScope(async scope => {\n const propagationContext = await propagationContextFromInstanceId(event.instanceId);\n scope.setPropagationContext(propagationContext);\n\n try {\n return await obj.run.call(\n obj,\n event,\n new WrappedWorkflowStep(event.instanceId, context, options, step),\n );\n } finally {\n context.waitUntil(flushAndDispose(client));\n }\n });\n });\n };\n }\n return Reflect.get(obj, prop, receiver);\n },\n });\n },\n });\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