@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.
Files changed (610) hide show
  1. package/build/cjs/dev/_virtual/_rolldown/runtime.js +22 -0
  2. package/build/cjs/dev/baseSdk.js +98 -103
  3. package/build/cjs/dev/baseSdk.js.map +1 -1
  4. package/build/cjs/dev/client.js +213 -237
  5. package/build/cjs/dev/client.js.map +1 -1
  6. package/build/cjs/dev/clientCache.js +8 -8
  7. package/build/cjs/dev/clientCache.js.map +1 -1
  8. package/build/cjs/dev/debug-build.js +9 -5
  9. package/build/cjs/dev/debug-build.js.map +1 -1
  10. package/build/cjs/dev/defineCloudflareOptions.js +5 -8
  11. package/build/cjs/dev/defineCloudflareOptions.js.map +1 -1
  12. package/build/cjs/dev/durableobject.js +287 -176
  13. package/build/cjs/dev/durableobject.js.map +1 -1
  14. package/build/cjs/dev/flush.js +104 -77
  15. package/build/cjs/dev/flush.js.map +1 -1
  16. package/build/cjs/dev/index.js +181 -182
  17. package/build/cjs/dev/instrument.js +53 -39
  18. package/build/cjs/dev/instrument.js.map +1 -1
  19. package/build/cjs/dev/instrumentations/agents/index.js +34 -13
  20. package/build/cjs/dev/instrumentations/agents/index.js.map +1 -1
  21. package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js +46 -49
  22. package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  23. package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js +23 -16
  24. package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
  25. package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js +36 -28
  26. package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
  27. package/build/cjs/dev/instrumentations/agents/types.js +103 -58
  28. package/build/cjs/dev/instrumentations/agents/types.js.map +1 -1
  29. package/build/cjs/dev/instrumentations/instrumentDurableObjectHandlers.js +87 -118
  30. package/build/cjs/dev/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
  31. package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js +46 -44
  32. package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  33. package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js +70 -71
  34. package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  35. package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -39
  36. package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  37. package/build/cjs/dev/instrumentations/instrumentSqlStorage.js +50 -52
  38. package/build/cjs/dev/instrumentations/instrumentSqlStorage.js.map +1 -1
  39. package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js +136 -123
  40. package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  41. package/build/cjs/dev/instrumentations/worker/instrumentD1.js +131 -146
  42. package/build/cjs/dev/instrumentations/worker/instrumentD1.js.map +1 -1
  43. package/build/cjs/dev/instrumentations/worker/instrumentEmail.js +63 -61
  44. package/build/cjs/dev/instrumentations/worker/instrumentEmail.js.map +1 -1
  45. package/build/cjs/dev/instrumentations/worker/instrumentEnv.js +83 -88
  46. package/build/cjs/dev/instrumentations/worker/instrumentEnv.js.map +1 -1
  47. package/build/cjs/dev/instrumentations/worker/instrumentFetch.js +41 -48
  48. package/build/cjs/dev/instrumentations/worker/instrumentFetch.js.map +1 -1
  49. package/build/cjs/dev/instrumentations/worker/instrumentFetcher.js +25 -21
  50. package/build/cjs/dev/instrumentations/worker/instrumentFetcher.js.map +1 -1
  51. package/build/cjs/dev/instrumentations/worker/instrumentKV.js +54 -67
  52. package/build/cjs/dev/instrumentations/worker/instrumentKV.js.map +1 -1
  53. package/build/cjs/dev/instrumentations/worker/instrumentQueue.js +98 -105
  54. package/build/cjs/dev/instrumentations/worker/instrumentQueue.js.map +1 -1
  55. package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js +88 -94
  56. package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  57. package/build/cjs/dev/instrumentations/worker/instrumentR2.js +128 -115
  58. package/build/cjs/dev/instrumentations/worker/instrumentR2.js.map +1 -1
  59. package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js +90 -94
  60. package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js.map +1 -1
  61. package/build/cjs/dev/instrumentations/worker/instrumentTail.js +100 -55
  62. package/build/cjs/dev/instrumentations/worker/instrumentTail.js.map +1 -1
  63. package/build/cjs/dev/integrations/cronTriggers.js +130 -85
  64. package/build/cjs/dev/integrations/cronTriggers.js.map +1 -1
  65. package/build/cjs/dev/integrations/fetch.js +9 -9
  66. package/build/cjs/dev/integrations/fetch.js.map +1 -1
  67. package/build/cjs/dev/integrations/httpServer.js +41 -22
  68. package/build/cjs/dev/integrations/httpServer.js.map +1 -1
  69. package/build/cjs/dev/integrations/spotlight.js +52 -55
  70. package/build/cjs/dev/integrations/spotlight.js.map +1 -1
  71. package/build/cjs/dev/opentelemetry/tracer.js +10 -8
  72. package/build/cjs/dev/opentelemetry/tracer.js.map +1 -1
  73. package/build/cjs/dev/options.js +55 -39
  74. package/build/cjs/dev/options.js.map +1 -1
  75. package/build/cjs/dev/orchestrion-deferred-channels.js +45 -29
  76. package/build/cjs/dev/orchestrion-deferred-channels.js.map +1 -1
  77. package/build/cjs/dev/orchestrion-diagnostics-channel.js +97 -72
  78. package/build/cjs/dev/orchestrion-diagnostics-channel.js.map +1 -1
  79. package/build/cjs/dev/pages-plugin.js +20 -21
  80. package/build/cjs/dev/pages-plugin.js.map +1 -1
  81. package/build/cjs/dev/request.js +16 -10
  82. package/build/cjs/dev/request.js.map +1 -1
  83. package/build/cjs/dev/scope-utils.js +12 -12
  84. package/build/cjs/dev/scope-utils.js.map +1 -1
  85. package/build/cjs/dev/sdk.js +24 -15
  86. package/build/cjs/dev/sdk.js.map +1 -1
  87. package/build/cjs/dev/transport.js +93 -86
  88. package/build/cjs/dev/transport.js.map +1 -1
  89. package/build/cjs/dev/utils/asyncContextStrategy.js +10 -10
  90. package/build/cjs/dev/utils/asyncContextStrategy.js.map +1 -1
  91. package/build/cjs/dev/utils/bindingPropagation.js +17 -11
  92. package/build/cjs/dev/utils/bindingPropagation.js.map +1 -1
  93. package/build/cjs/dev/utils/cloudflareTrace.js +34 -0
  94. package/build/cjs/dev/utils/cloudflareTrace.js.map +1 -0
  95. package/build/cjs/dev/utils/instrumentContext.js +74 -58
  96. package/build/cjs/dev/utils/instrumentContext.js.map +1 -1
  97. package/build/cjs/dev/utils/internalSqlQuery.js +38 -21
  98. package/build/cjs/dev/utils/internalSqlQuery.js.map +1 -1
  99. package/build/cjs/dev/utils/internalStorageKey.js +41 -38
  100. package/build/cjs/dev/utils/internalStorageKey.js.map +1 -1
  101. package/build/cjs/dev/utils/invocationContext.js +42 -32
  102. package/build/cjs/dev/utils/invocationContext.js.map +1 -1
  103. package/build/cjs/dev/utils/invocationScope.js +45 -21
  104. package/build/cjs/dev/utils/invocationScope.js.map +1 -1
  105. package/build/cjs/dev/utils/isBinding.js +47 -15
  106. package/build/cjs/dev/utils/isBinding.js.map +1 -1
  107. package/build/cjs/dev/utils/isCloudflareClass.js +11 -20
  108. package/build/cjs/dev/utils/isCloudflareClass.js.map +1 -1
  109. package/build/cjs/dev/utils/queueTraceMeta.js +24 -35
  110. package/build/cjs/dev/utils/queueTraceMeta.js.map +1 -1
  111. package/build/cjs/dev/utils/rpcMeta.js +37 -27
  112. package/build/cjs/dev/utils/rpcMeta.js.map +1 -1
  113. package/build/cjs/dev/utils/traceLinks.js +52 -42
  114. package/build/cjs/dev/utils/traceLinks.js.map +1 -1
  115. package/build/cjs/dev/vendor/stacktrace.js +32 -24
  116. package/build/cjs/dev/vendor/stacktrace.js.map +1 -1
  117. package/build/cjs/dev/vite/agentClass.js +105 -98
  118. package/build/cjs/dev/vite/agentClass.js.map +1 -1
  119. package/build/cjs/dev/vite/autoInstrument.js +121 -122
  120. package/build/cjs/dev/vite/autoInstrument.js.map +1 -1
  121. package/build/cjs/dev/vite/index.js +44 -21
  122. package/build/cjs/dev/vite/index.js.map +1 -1
  123. package/build/cjs/dev/vite/instrumentFile.js +37 -20
  124. package/build/cjs/dev/vite/instrumentFile.js.map +1 -1
  125. package/build/cjs/dev/vite/mastraObservability.js +19 -12
  126. package/build/cjs/dev/vite/mastraObservability.js.map +1 -1
  127. package/build/cjs/dev/vite/moduleShape.js +220 -201
  128. package/build/cjs/dev/vite/moduleShape.js.map +1 -1
  129. package/build/cjs/dev/vite/providedModulePlugin.js +62 -45
  130. package/build/cjs/dev/vite/providedModulePlugin.js.map +1 -1
  131. package/build/cjs/dev/vite/transform.js +333 -284
  132. package/build/cjs/dev/vite/transform.js.map +1 -1
  133. package/build/cjs/dev/vite/workerEntrypoint.js +66 -57
  134. package/build/cjs/dev/vite/workerEntrypoint.js.map +1 -1
  135. package/build/cjs/dev/vite/wranglerConfig.js +92 -67
  136. package/build/cjs/dev/vite/wranglerConfig.js.map +1 -1
  137. package/build/cjs/dev/withSentry.js +32 -26
  138. package/build/cjs/dev/withSentry.js.map +1 -1
  139. package/build/cjs/dev/workflows.js +164 -151
  140. package/build/cjs/dev/workflows.js.map +1 -1
  141. package/build/cjs/dev/wrapMethodWithSentry.js +148 -169
  142. package/build/cjs/dev/wrapMethodWithSentry.js.map +1 -1
  143. package/build/cjs/dev/wrapRequestHandlerWithInit.js +76 -78
  144. package/build/cjs/dev/wrapRequestHandlerWithInit.js.map +1 -1
  145. package/build/cjs/prod/_virtual/_rolldown/runtime.js +22 -0
  146. package/build/cjs/prod/baseSdk.js +94 -93
  147. package/build/cjs/prod/baseSdk.js.map +1 -1
  148. package/build/cjs/prod/client.js +213 -237
  149. package/build/cjs/prod/client.js.map +1 -1
  150. package/build/cjs/prod/clientCache.js +8 -8
  151. package/build/cjs/prod/clientCache.js.map +1 -1
  152. package/build/cjs/prod/debug-build.js +9 -5
  153. package/build/cjs/prod/debug-build.js.map +1 -1
  154. package/build/cjs/prod/defineCloudflareOptions.js +5 -8
  155. package/build/cjs/prod/defineCloudflareOptions.js.map +1 -1
  156. package/build/cjs/prod/durableobject.js +287 -176
  157. package/build/cjs/prod/durableobject.js.map +1 -1
  158. package/build/cjs/prod/flush.js +104 -77
  159. package/build/cjs/prod/flush.js.map +1 -1
  160. package/build/cjs/prod/index.js +181 -182
  161. package/build/cjs/prod/instrument.js +53 -39
  162. package/build/cjs/prod/instrument.js.map +1 -1
  163. package/build/cjs/prod/instrumentations/agents/index.js +34 -13
  164. package/build/cjs/prod/instrumentations/agents/index.js.map +1 -1
  165. package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js +46 -49
  166. package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  167. package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js +23 -16
  168. package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
  169. package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js +36 -28
  170. package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
  171. package/build/cjs/prod/instrumentations/agents/types.js +103 -58
  172. package/build/cjs/prod/instrumentations/agents/types.js.map +1 -1
  173. package/build/cjs/prod/instrumentations/instrumentDurableObjectHandlers.js +87 -118
  174. package/build/cjs/prod/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
  175. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js +46 -44
  176. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  177. package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js +70 -71
  178. package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  179. package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -39
  180. package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  181. package/build/cjs/prod/instrumentations/instrumentSqlStorage.js +50 -52
  182. package/build/cjs/prod/instrumentations/instrumentSqlStorage.js.map +1 -1
  183. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js +136 -123
  184. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  185. package/build/cjs/prod/instrumentations/worker/instrumentD1.js +131 -146
  186. package/build/cjs/prod/instrumentations/worker/instrumentD1.js.map +1 -1
  187. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js +63 -61
  188. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js.map +1 -1
  189. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js +83 -88
  190. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js.map +1 -1
  191. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js +41 -48
  192. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js.map +1 -1
  193. package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js +25 -21
  194. package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js.map +1 -1
  195. package/build/cjs/prod/instrumentations/worker/instrumentKV.js +54 -67
  196. package/build/cjs/prod/instrumentations/worker/instrumentKV.js.map +1 -1
  197. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js +98 -105
  198. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js.map +1 -1
  199. package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js +88 -94
  200. package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  201. package/build/cjs/prod/instrumentations/worker/instrumentR2.js +128 -115
  202. package/build/cjs/prod/instrumentations/worker/instrumentR2.js.map +1 -1
  203. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js +90 -94
  204. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js.map +1 -1
  205. package/build/cjs/prod/instrumentations/worker/instrumentTail.js +100 -55
  206. package/build/cjs/prod/instrumentations/worker/instrumentTail.js.map +1 -1
  207. package/build/cjs/prod/integrations/cronTriggers.js +130 -85
  208. package/build/cjs/prod/integrations/cronTriggers.js.map +1 -1
  209. package/build/cjs/prod/integrations/fetch.js +9 -9
  210. package/build/cjs/prod/integrations/fetch.js.map +1 -1
  211. package/build/cjs/prod/integrations/httpServer.js +41 -22
  212. package/build/cjs/prod/integrations/httpServer.js.map +1 -1
  213. package/build/cjs/prod/integrations/spotlight.js +52 -55
  214. package/build/cjs/prod/integrations/spotlight.js.map +1 -1
  215. package/build/cjs/prod/opentelemetry/tracer.js +10 -8
  216. package/build/cjs/prod/opentelemetry/tracer.js.map +1 -1
  217. package/build/cjs/prod/options.js +37 -24
  218. package/build/cjs/prod/options.js.map +1 -1
  219. package/build/cjs/prod/orchestrion-deferred-channels.js +45 -29
  220. package/build/cjs/prod/orchestrion-deferred-channels.js.map +1 -1
  221. package/build/cjs/prod/orchestrion-diagnostics-channel.js +97 -72
  222. package/build/cjs/prod/orchestrion-diagnostics-channel.js.map +1 -1
  223. package/build/cjs/prod/pages-plugin.js +20 -21
  224. package/build/cjs/prod/pages-plugin.js.map +1 -1
  225. package/build/cjs/prod/request.js +16 -10
  226. package/build/cjs/prod/request.js.map +1 -1
  227. package/build/cjs/prod/scope-utils.js +12 -12
  228. package/build/cjs/prod/scope-utils.js.map +1 -1
  229. package/build/cjs/prod/sdk.js +24 -15
  230. package/build/cjs/prod/sdk.js.map +1 -1
  231. package/build/cjs/prod/transport.js +93 -86
  232. package/build/cjs/prod/transport.js.map +1 -1
  233. package/build/cjs/prod/utils/asyncContextStrategy.js +10 -10
  234. package/build/cjs/prod/utils/asyncContextStrategy.js.map +1 -1
  235. package/build/cjs/prod/utils/bindingPropagation.js +17 -11
  236. package/build/cjs/prod/utils/bindingPropagation.js.map +1 -1
  237. package/build/cjs/prod/utils/cloudflareTrace.js +34 -0
  238. package/build/cjs/prod/utils/cloudflareTrace.js.map +1 -0
  239. package/build/cjs/prod/utils/instrumentContext.js +74 -58
  240. package/build/cjs/prod/utils/instrumentContext.js.map +1 -1
  241. package/build/cjs/prod/utils/internalSqlQuery.js +38 -21
  242. package/build/cjs/prod/utils/internalSqlQuery.js.map +1 -1
  243. package/build/cjs/prod/utils/internalStorageKey.js +41 -38
  244. package/build/cjs/prod/utils/internalStorageKey.js.map +1 -1
  245. package/build/cjs/prod/utils/invocationContext.js +42 -32
  246. package/build/cjs/prod/utils/invocationContext.js.map +1 -1
  247. package/build/cjs/prod/utils/invocationScope.js +45 -21
  248. package/build/cjs/prod/utils/invocationScope.js.map +1 -1
  249. package/build/cjs/prod/utils/isBinding.js +47 -15
  250. package/build/cjs/prod/utils/isBinding.js.map +1 -1
  251. package/build/cjs/prod/utils/isCloudflareClass.js +11 -20
  252. package/build/cjs/prod/utils/isCloudflareClass.js.map +1 -1
  253. package/build/cjs/prod/utils/queueTraceMeta.js +24 -35
  254. package/build/cjs/prod/utils/queueTraceMeta.js.map +1 -1
  255. package/build/cjs/prod/utils/rpcMeta.js +37 -27
  256. package/build/cjs/prod/utils/rpcMeta.js.map +1 -1
  257. package/build/cjs/prod/utils/traceLinks.js +52 -42
  258. package/build/cjs/prod/utils/traceLinks.js.map +1 -1
  259. package/build/cjs/prod/vendor/stacktrace.js +32 -24
  260. package/build/cjs/prod/vendor/stacktrace.js.map +1 -1
  261. package/build/cjs/prod/vite/agentClass.js +105 -98
  262. package/build/cjs/prod/vite/agentClass.js.map +1 -1
  263. package/build/cjs/prod/vite/autoInstrument.js +121 -122
  264. package/build/cjs/prod/vite/autoInstrument.js.map +1 -1
  265. package/build/cjs/prod/vite/index.js +44 -21
  266. package/build/cjs/prod/vite/index.js.map +1 -1
  267. package/build/cjs/prod/vite/instrumentFile.js +37 -20
  268. package/build/cjs/prod/vite/instrumentFile.js.map +1 -1
  269. package/build/cjs/prod/vite/mastraObservability.js +19 -12
  270. package/build/cjs/prod/vite/mastraObservability.js.map +1 -1
  271. package/build/cjs/prod/vite/moduleShape.js +220 -201
  272. package/build/cjs/prod/vite/moduleShape.js.map +1 -1
  273. package/build/cjs/prod/vite/providedModulePlugin.js +62 -45
  274. package/build/cjs/prod/vite/providedModulePlugin.js.map +1 -1
  275. package/build/cjs/prod/vite/transform.js +333 -284
  276. package/build/cjs/prod/vite/transform.js.map +1 -1
  277. package/build/cjs/prod/vite/workerEntrypoint.js +66 -57
  278. package/build/cjs/prod/vite/workerEntrypoint.js.map +1 -1
  279. package/build/cjs/prod/vite/wranglerConfig.js +92 -67
  280. package/build/cjs/prod/vite/wranglerConfig.js.map +1 -1
  281. package/build/cjs/prod/withSentry.js +32 -26
  282. package/build/cjs/prod/withSentry.js.map +1 -1
  283. package/build/cjs/prod/workflows.js +164 -151
  284. package/build/cjs/prod/workflows.js.map +1 -1
  285. package/build/cjs/prod/wrapMethodWithSentry.js +148 -169
  286. package/build/cjs/prod/wrapMethodWithSentry.js.map +1 -1
  287. package/build/cjs/prod/wrapRequestHandlerWithInit.js +76 -78
  288. package/build/cjs/prod/wrapRequestHandlerWithInit.js.map +1 -1
  289. package/build/esm/dev/baseSdk.js +98 -101
  290. package/build/esm/dev/baseSdk.js.map +1 -1
  291. package/build/esm/dev/client.js +213 -235
  292. package/build/esm/dev/client.js.map +1 -1
  293. package/build/esm/dev/clientCache.js +8 -6
  294. package/build/esm/dev/clientCache.js.map +1 -1
  295. package/build/esm/dev/debug-build.js +9 -3
  296. package/build/esm/dev/debug-build.js.map +1 -1
  297. package/build/esm/dev/defineCloudflareOptions.js +5 -6
  298. package/build/esm/dev/defineCloudflareOptions.js.map +1 -1
  299. package/build/esm/dev/durableobject.js +287 -174
  300. package/build/esm/dev/durableobject.js.map +1 -1
  301. package/build/esm/dev/flush.js +104 -75
  302. package/build/esm/dev/flush.js.map +1 -1
  303. package/build/esm/dev/index.js +19 -18
  304. package/build/esm/dev/instrument.js +53 -37
  305. package/build/esm/dev/instrument.js.map +1 -1
  306. package/build/esm/dev/instrumentations/agents/index.js +34 -11
  307. package/build/esm/dev/instrumentations/agents/index.js.map +1 -1
  308. package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js +46 -47
  309. package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  310. package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js +23 -14
  311. package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
  312. package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js +36 -26
  313. package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
  314. package/build/esm/dev/instrumentations/agents/types.js +103 -56
  315. package/build/esm/dev/instrumentations/agents/types.js.map +1 -1
  316. package/build/esm/dev/instrumentations/instrumentDurableObjectHandlers.js +87 -116
  317. package/build/esm/dev/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
  318. package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js +46 -42
  319. package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  320. package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js +70 -69
  321. package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  322. package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -37
  323. package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  324. package/build/esm/dev/instrumentations/instrumentSqlStorage.js +50 -50
  325. package/build/esm/dev/instrumentations/instrumentSqlStorage.js.map +1 -1
  326. package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js +136 -121
  327. package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  328. package/build/esm/dev/instrumentations/worker/instrumentD1.js +131 -144
  329. package/build/esm/dev/instrumentations/worker/instrumentD1.js.map +1 -1
  330. package/build/esm/dev/instrumentations/worker/instrumentEmail.js +63 -59
  331. package/build/esm/dev/instrumentations/worker/instrumentEmail.js.map +1 -1
  332. package/build/esm/dev/instrumentations/worker/instrumentEnv.js +83 -86
  333. package/build/esm/dev/instrumentations/worker/instrumentEnv.js.map +1 -1
  334. package/build/esm/dev/instrumentations/worker/instrumentFetch.js +41 -46
  335. package/build/esm/dev/instrumentations/worker/instrumentFetch.js.map +1 -1
  336. package/build/esm/dev/instrumentations/worker/instrumentFetcher.js +25 -19
  337. package/build/esm/dev/instrumentations/worker/instrumentFetcher.js.map +1 -1
  338. package/build/esm/dev/instrumentations/worker/instrumentKV.js +54 -65
  339. package/build/esm/dev/instrumentations/worker/instrumentKV.js.map +1 -1
  340. package/build/esm/dev/instrumentations/worker/instrumentQueue.js +98 -103
  341. package/build/esm/dev/instrumentations/worker/instrumentQueue.js.map +1 -1
  342. package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js +88 -92
  343. package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  344. package/build/esm/dev/instrumentations/worker/instrumentR2.js +128 -113
  345. package/build/esm/dev/instrumentations/worker/instrumentR2.js.map +1 -1
  346. package/build/esm/dev/instrumentations/worker/instrumentScheduled.js +90 -92
  347. package/build/esm/dev/instrumentations/worker/instrumentScheduled.js.map +1 -1
  348. package/build/esm/dev/instrumentations/worker/instrumentTail.js +100 -53
  349. package/build/esm/dev/instrumentations/worker/instrumentTail.js.map +1 -1
  350. package/build/esm/dev/integrations/cronTriggers.js +129 -82
  351. package/build/esm/dev/integrations/cronTriggers.js.map +1 -1
  352. package/build/esm/dev/integrations/fetch.js +9 -6
  353. package/build/esm/dev/integrations/fetch.js.map +1 -1
  354. package/build/esm/dev/integrations/httpServer.js +40 -19
  355. package/build/esm/dev/integrations/httpServer.js.map +1 -1
  356. package/build/esm/dev/integrations/spotlight.js +51 -52
  357. package/build/esm/dev/integrations/spotlight.js.map +1 -1
  358. package/build/esm/dev/opentelemetry/tracer.js +10 -6
  359. package/build/esm/dev/opentelemetry/tracer.js.map +1 -1
  360. package/build/esm/dev/options.js +55 -37
  361. package/build/esm/dev/options.js.map +1 -1
  362. package/build/esm/dev/orchestrion-deferred-channels.js +45 -27
  363. package/build/esm/dev/orchestrion-deferred-channels.js.map +1 -1
  364. package/build/esm/dev/orchestrion-diagnostics-channel.js +87 -66
  365. package/build/esm/dev/orchestrion-diagnostics-channel.js.map +1 -1
  366. package/build/esm/dev/package.json +1 -1
  367. package/build/esm/dev/pages-plugin.js +20 -19
  368. package/build/esm/dev/pages-plugin.js.map +1 -1
  369. package/build/esm/dev/request.js +14 -7
  370. package/build/esm/dev/request.js.map +1 -1
  371. package/build/esm/dev/scope-utils.js +12 -10
  372. package/build/esm/dev/scope-utils.js.map +1 -1
  373. package/build/esm/dev/sdk.js +23 -13
  374. package/build/esm/dev/sdk.js.map +1 -1
  375. package/build/esm/dev/transport.js +93 -84
  376. package/build/esm/dev/transport.js.map +1 -1
  377. package/build/esm/dev/utils/asyncContextStrategy.js +10 -8
  378. package/build/esm/dev/utils/asyncContextStrategy.js.map +1 -1
  379. package/build/esm/dev/utils/bindingPropagation.js +17 -9
  380. package/build/esm/dev/utils/bindingPropagation.js.map +1 -1
  381. package/build/esm/dev/utils/cloudflareTrace.js +34 -0
  382. package/build/esm/dev/utils/cloudflareTrace.js.map +1 -0
  383. package/build/esm/dev/utils/instrumentContext.js +74 -56
  384. package/build/esm/dev/utils/instrumentContext.js.map +1 -1
  385. package/build/esm/dev/utils/internalSqlQuery.js +38 -19
  386. package/build/esm/dev/utils/internalSqlQuery.js.map +1 -1
  387. package/build/esm/dev/utils/internalStorageKey.js +41 -36
  388. package/build/esm/dev/utils/internalStorageKey.js.map +1 -1
  389. package/build/esm/dev/utils/invocationContext.js +42 -30
  390. package/build/esm/dev/utils/invocationContext.js.map +1 -1
  391. package/build/esm/dev/utils/invocationScope.js +45 -19
  392. package/build/esm/dev/utils/invocationScope.js.map +1 -1
  393. package/build/esm/dev/utils/isBinding.js +47 -13
  394. package/build/esm/dev/utils/isBinding.js.map +1 -1
  395. package/build/esm/dev/utils/isCloudflareClass.js +11 -18
  396. package/build/esm/dev/utils/isCloudflareClass.js.map +1 -1
  397. package/build/esm/dev/utils/queueTraceMeta.js +24 -33
  398. package/build/esm/dev/utils/queueTraceMeta.js.map +1 -1
  399. package/build/esm/dev/utils/rpcMeta.js +37 -25
  400. package/build/esm/dev/utils/rpcMeta.js.map +1 -1
  401. package/build/esm/dev/utils/traceLinks.js +52 -40
  402. package/build/esm/dev/utils/traceLinks.js.map +1 -1
  403. package/build/esm/dev/vendor/stacktrace.js +31 -21
  404. package/build/esm/dev/vendor/stacktrace.js.map +1 -1
  405. package/build/esm/dev/vite/agentClass.js +105 -96
  406. package/build/esm/dev/vite/agentClass.js.map +1 -1
  407. package/build/esm/dev/vite/autoInstrument.js +121 -120
  408. package/build/esm/dev/vite/autoInstrument.js.map +1 -1
  409. package/build/esm/dev/vite/index.js +43 -19
  410. package/build/esm/dev/vite/index.js.map +1 -1
  411. package/build/esm/dev/vite/instrumentFile.js +37 -18
  412. package/build/esm/dev/vite/instrumentFile.js.map +1 -1
  413. package/build/esm/dev/vite/mastraObservability.js +19 -10
  414. package/build/esm/dev/vite/mastraObservability.js.map +1 -1
  415. package/build/esm/dev/vite/moduleShape.js +220 -199
  416. package/build/esm/dev/vite/moduleShape.js.map +1 -1
  417. package/build/esm/dev/vite/providedModulePlugin.js +60 -43
  418. package/build/esm/dev/vite/providedModulePlugin.js.map +1 -1
  419. package/build/esm/dev/vite/transform.js +331 -282
  420. package/build/esm/dev/vite/transform.js.map +1 -1
  421. package/build/esm/dev/vite/workerEntrypoint.js +66 -55
  422. package/build/esm/dev/vite/workerEntrypoint.js.map +1 -1
  423. package/build/esm/dev/vite/wranglerConfig.js +92 -65
  424. package/build/esm/dev/vite/wranglerConfig.js.map +1 -1
  425. package/build/esm/dev/withSentry.js +32 -24
  426. package/build/esm/dev/withSentry.js.map +1 -1
  427. package/build/esm/dev/workflows.js +164 -149
  428. package/build/esm/dev/workflows.js.map +1 -1
  429. package/build/esm/dev/wrapMethodWithSentry.js +148 -167
  430. package/build/esm/dev/wrapMethodWithSentry.js.map +1 -1
  431. package/build/esm/dev/wrapRequestHandlerWithInit.js +76 -76
  432. package/build/esm/dev/wrapRequestHandlerWithInit.js.map +1 -1
  433. package/build/esm/prod/baseSdk.js +94 -91
  434. package/build/esm/prod/baseSdk.js.map +1 -1
  435. package/build/esm/prod/client.js +213 -235
  436. package/build/esm/prod/client.js.map +1 -1
  437. package/build/esm/prod/clientCache.js +8 -6
  438. package/build/esm/prod/clientCache.js.map +1 -1
  439. package/build/esm/prod/debug-build.js +9 -3
  440. package/build/esm/prod/debug-build.js.map +1 -1
  441. package/build/esm/prod/defineCloudflareOptions.js +5 -6
  442. package/build/esm/prod/defineCloudflareOptions.js.map +1 -1
  443. package/build/esm/prod/durableobject.js +287 -174
  444. package/build/esm/prod/durableobject.js.map +1 -1
  445. package/build/esm/prod/flush.js +104 -75
  446. package/build/esm/prod/flush.js.map +1 -1
  447. package/build/esm/prod/index.js +19 -18
  448. package/build/esm/prod/instrument.js +53 -37
  449. package/build/esm/prod/instrument.js.map +1 -1
  450. package/build/esm/prod/instrumentations/agents/index.js +34 -11
  451. package/build/esm/prod/instrumentations/agents/index.js.map +1 -1
  452. package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js +46 -47
  453. package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  454. package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js +23 -14
  455. package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
  456. package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js +36 -26
  457. package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
  458. package/build/esm/prod/instrumentations/agents/types.js +103 -56
  459. package/build/esm/prod/instrumentations/agents/types.js.map +1 -1
  460. package/build/esm/prod/instrumentations/instrumentDurableObjectHandlers.js +87 -116
  461. package/build/esm/prod/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
  462. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js +46 -42
  463. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  464. package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js +70 -69
  465. package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  466. package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -37
  467. package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  468. package/build/esm/prod/instrumentations/instrumentSqlStorage.js +50 -50
  469. package/build/esm/prod/instrumentations/instrumentSqlStorage.js.map +1 -1
  470. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js +136 -121
  471. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  472. package/build/esm/prod/instrumentations/worker/instrumentD1.js +131 -144
  473. package/build/esm/prod/instrumentations/worker/instrumentD1.js.map +1 -1
  474. package/build/esm/prod/instrumentations/worker/instrumentEmail.js +63 -59
  475. package/build/esm/prod/instrumentations/worker/instrumentEmail.js.map +1 -1
  476. package/build/esm/prod/instrumentations/worker/instrumentEnv.js +83 -86
  477. package/build/esm/prod/instrumentations/worker/instrumentEnv.js.map +1 -1
  478. package/build/esm/prod/instrumentations/worker/instrumentFetch.js +41 -46
  479. package/build/esm/prod/instrumentations/worker/instrumentFetch.js.map +1 -1
  480. package/build/esm/prod/instrumentations/worker/instrumentFetcher.js +25 -19
  481. package/build/esm/prod/instrumentations/worker/instrumentFetcher.js.map +1 -1
  482. package/build/esm/prod/instrumentations/worker/instrumentKV.js +54 -65
  483. package/build/esm/prod/instrumentations/worker/instrumentKV.js.map +1 -1
  484. package/build/esm/prod/instrumentations/worker/instrumentQueue.js +98 -103
  485. package/build/esm/prod/instrumentations/worker/instrumentQueue.js.map +1 -1
  486. package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js +88 -92
  487. package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  488. package/build/esm/prod/instrumentations/worker/instrumentR2.js +128 -113
  489. package/build/esm/prod/instrumentations/worker/instrumentR2.js.map +1 -1
  490. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js +90 -92
  491. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js.map +1 -1
  492. package/build/esm/prod/instrumentations/worker/instrumentTail.js +100 -53
  493. package/build/esm/prod/instrumentations/worker/instrumentTail.js.map +1 -1
  494. package/build/esm/prod/integrations/cronTriggers.js +129 -82
  495. package/build/esm/prod/integrations/cronTriggers.js.map +1 -1
  496. package/build/esm/prod/integrations/fetch.js +9 -6
  497. package/build/esm/prod/integrations/fetch.js.map +1 -1
  498. package/build/esm/prod/integrations/httpServer.js +40 -19
  499. package/build/esm/prod/integrations/httpServer.js.map +1 -1
  500. package/build/esm/prod/integrations/spotlight.js +51 -52
  501. package/build/esm/prod/integrations/spotlight.js.map +1 -1
  502. package/build/esm/prod/opentelemetry/tracer.js +10 -6
  503. package/build/esm/prod/opentelemetry/tracer.js.map +1 -1
  504. package/build/esm/prod/options.js +37 -22
  505. package/build/esm/prod/options.js.map +1 -1
  506. package/build/esm/prod/orchestrion-deferred-channels.js +45 -27
  507. package/build/esm/prod/orchestrion-deferred-channels.js.map +1 -1
  508. package/build/esm/prod/orchestrion-diagnostics-channel.js +87 -66
  509. package/build/esm/prod/orchestrion-diagnostics-channel.js.map +1 -1
  510. package/build/esm/prod/package.json +1 -1
  511. package/build/esm/prod/pages-plugin.js +20 -19
  512. package/build/esm/prod/pages-plugin.js.map +1 -1
  513. package/build/esm/prod/request.js +14 -7
  514. package/build/esm/prod/request.js.map +1 -1
  515. package/build/esm/prod/scope-utils.js +12 -10
  516. package/build/esm/prod/scope-utils.js.map +1 -1
  517. package/build/esm/prod/sdk.js +23 -13
  518. package/build/esm/prod/sdk.js.map +1 -1
  519. package/build/esm/prod/transport.js +93 -84
  520. package/build/esm/prod/transport.js.map +1 -1
  521. package/build/esm/prod/utils/asyncContextStrategy.js +10 -8
  522. package/build/esm/prod/utils/asyncContextStrategy.js.map +1 -1
  523. package/build/esm/prod/utils/bindingPropagation.js +17 -9
  524. package/build/esm/prod/utils/bindingPropagation.js.map +1 -1
  525. package/build/esm/prod/utils/cloudflareTrace.js +34 -0
  526. package/build/esm/prod/utils/cloudflareTrace.js.map +1 -0
  527. package/build/esm/prod/utils/instrumentContext.js +74 -56
  528. package/build/esm/prod/utils/instrumentContext.js.map +1 -1
  529. package/build/esm/prod/utils/internalSqlQuery.js +38 -19
  530. package/build/esm/prod/utils/internalSqlQuery.js.map +1 -1
  531. package/build/esm/prod/utils/internalStorageKey.js +41 -36
  532. package/build/esm/prod/utils/internalStorageKey.js.map +1 -1
  533. package/build/esm/prod/utils/invocationContext.js +42 -30
  534. package/build/esm/prod/utils/invocationContext.js.map +1 -1
  535. package/build/esm/prod/utils/invocationScope.js +45 -19
  536. package/build/esm/prod/utils/invocationScope.js.map +1 -1
  537. package/build/esm/prod/utils/isBinding.js +47 -13
  538. package/build/esm/prod/utils/isBinding.js.map +1 -1
  539. package/build/esm/prod/utils/isCloudflareClass.js +11 -18
  540. package/build/esm/prod/utils/isCloudflareClass.js.map +1 -1
  541. package/build/esm/prod/utils/queueTraceMeta.js +24 -33
  542. package/build/esm/prod/utils/queueTraceMeta.js.map +1 -1
  543. package/build/esm/prod/utils/rpcMeta.js +37 -25
  544. package/build/esm/prod/utils/rpcMeta.js.map +1 -1
  545. package/build/esm/prod/utils/traceLinks.js +52 -40
  546. package/build/esm/prod/utils/traceLinks.js.map +1 -1
  547. package/build/esm/prod/vendor/stacktrace.js +31 -21
  548. package/build/esm/prod/vendor/stacktrace.js.map +1 -1
  549. package/build/esm/prod/vite/agentClass.js +105 -96
  550. package/build/esm/prod/vite/agentClass.js.map +1 -1
  551. package/build/esm/prod/vite/autoInstrument.js +121 -120
  552. package/build/esm/prod/vite/autoInstrument.js.map +1 -1
  553. package/build/esm/prod/vite/index.js +43 -19
  554. package/build/esm/prod/vite/index.js.map +1 -1
  555. package/build/esm/prod/vite/instrumentFile.js +37 -18
  556. package/build/esm/prod/vite/instrumentFile.js.map +1 -1
  557. package/build/esm/prod/vite/mastraObservability.js +19 -10
  558. package/build/esm/prod/vite/mastraObservability.js.map +1 -1
  559. package/build/esm/prod/vite/moduleShape.js +220 -199
  560. package/build/esm/prod/vite/moduleShape.js.map +1 -1
  561. package/build/esm/prod/vite/providedModulePlugin.js +60 -43
  562. package/build/esm/prod/vite/providedModulePlugin.js.map +1 -1
  563. package/build/esm/prod/vite/transform.js +331 -282
  564. package/build/esm/prod/vite/transform.js.map +1 -1
  565. package/build/esm/prod/vite/workerEntrypoint.js +66 -55
  566. package/build/esm/prod/vite/workerEntrypoint.js.map +1 -1
  567. package/build/esm/prod/vite/wranglerConfig.js +92 -65
  568. package/build/esm/prod/vite/wranglerConfig.js.map +1 -1
  569. package/build/esm/prod/withSentry.js +32 -24
  570. package/build/esm/prod/withSentry.js.map +1 -1
  571. package/build/esm/prod/workflows.js +164 -149
  572. package/build/esm/prod/workflows.js.map +1 -1
  573. package/build/esm/prod/wrapMethodWithSentry.js +148 -167
  574. package/build/esm/prod/wrapMethodWithSentry.js.map +1 -1
  575. package/build/esm/prod/wrapRequestHandlerWithInit.js +76 -76
  576. package/build/esm/prod/wrapRequestHandlerWithInit.js.map +1 -1
  577. package/build/types/client.d.ts +2 -1
  578. package/build/types/client.d.ts.map +1 -1
  579. package/build/types/index.d.ts +3 -2
  580. package/build/types/index.d.ts.map +1 -1
  581. package/build/types/instrumentations/worker/instrumentEmail.d.ts.map +1 -1
  582. package/build/types/instrumentations/worker/instrumentFetcher.d.ts.map +1 -1
  583. package/build/types/instrumentations/worker/instrumentQueue.d.ts.map +1 -1
  584. package/build/types/instrumentations/worker/instrumentScheduled.d.ts.map +1 -1
  585. package/build/types/instrumentations/worker/instrumentTail.d.ts +4 -2
  586. package/build/types/instrumentations/worker/instrumentTail.d.ts.map +1 -1
  587. package/build/types/utils/cloudflareTrace.d.ts +13 -0
  588. package/build/types/utils/cloudflareTrace.d.ts.map +1 -0
  589. package/build/types/vite/autoInstrument.d.ts.map +1 -1
  590. package/build/types/vite/index.d.ts.map +1 -1
  591. package/build/types/vite/providedModulePlugin.d.ts +15 -11
  592. package/build/types/vite/providedModulePlugin.d.ts.map +1 -1
  593. package/build/types/workflows.d.ts.map +1 -1
  594. package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
  595. package/build/types/wrapRequestHandlerWithInit.d.ts.map +1 -1
  596. package/package.json +10 -14
  597. package/build/cjs/dev/index.js.map +0 -1
  598. package/build/cjs/dev/vite/flueRuntime.js +0 -15
  599. package/build/cjs/dev/vite/flueRuntime.js.map +0 -1
  600. package/build/cjs/prod/index.js.map +0 -1
  601. package/build/cjs/prod/vite/flueRuntime.js +0 -15
  602. package/build/cjs/prod/vite/flueRuntime.js.map +0 -1
  603. package/build/esm/dev/index.js.map +0 -1
  604. package/build/esm/dev/vite/flueRuntime.js +0 -13
  605. package/build/esm/dev/vite/flueRuntime.js.map +0 -1
  606. package/build/esm/prod/index.js.map +0 -1
  607. package/build/esm/prod/vite/flueRuntime.js +0 -13
  608. package/build/esm/prod/vite/flueRuntime.js.map +0 -1
  609. package/build/types/vite/flueRuntime.d.ts +0 -12
  610. package/build/types/vite/flueRuntime.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrion-diagnostics-channel.js","sources":["../../../src/orchestrion-diagnostics-channel.ts"],"sourcesContent":["/**\n * A workerd-safe `diagnostics_channel` façade for the orchestrion EMIT side, and the\n * `dcModule` target for the Cloudflare orchestrion build (see `vite/index.ts`): orchestrion's\n * transformed code imports `tracingChannel` from here (its default export) instead of\n * `node:diagnostics_channel`.\n *\n * On workerd, `channel.publish()` and `channel.runStores()` throw at module/global scope\n * (\"Disallowed operation called within global scope …\"); only inside a request handler do they\n * work. `subscribe` and channel creation are fine anywhere. Orchestrion's transformed code emits\n * `start.runStores(...)` / `end.publish(...)` at each wrapped call site, so a library\n * instantiated at module scope (`const app = new Hono()`) throws the moment it is wrapped — or,\n * if no subscriber exists yet, is skipped by the wrapper's `if (!hasSubscribers) return\n * __apm$traced()` short-circuit and never instrumented.\n *\n * This façade delegates to the real `node:diagnostics_channel` singletons — so subscribers, which\n * keep subscribing through `node:diagnostics_channel`, are reached unchanged — and changes two\n * things:\n *\n * 1. `hasSubscribers` always reports `true`, so the wrapper never short-circuits. On Cloudflare a\n * channel is only injected for an integration that is actually bundled, so the short-circuit\n * buys nothing — and disabling it is what lets the wrapper run (and reach us) at module scope,\n * before the per-request cached `init()` has subscribed.\n * 2. When a delegated `publish`/`runStores` throws the global-scope error, the event is queued via\n * {@link deferChannelEvent} instead. {@link flushDeferredChannelEvents}, called at the top of\n * the request handler after `init()`, emits it via the real channel — now inside a request,\n * where publish works.\n *\n * In a request handler nothing throws, so every call is a transparent pass-through to the real\n * channel: lifecycle channels (spans, context binding) behave exactly as on Node.\n */\nimport * as realDc from 'node:diagnostics_channel';\nimport { deferChannelEvent, isGlobalScopeError } from './orchestrion-deferred-channels';\n\ntype Ctx = Record<string, unknown>;\n\n// One façade per channel name (node's `tracingChannel` is itself a per-name singleton), built\n// once when the transformed module declares `const CH = tracingChannel(name)`.\nconst cache = new Map<string, realDc.TracingChannel>();\n\n// `Channel.hasSubscribers` is a getter on Node but a method on workerd — normalize both to a\n// boolean. (This shape difference is also why the emit wrapper never short-circuits on workerd:\n// its `if (!ch.start.hasSubscribers)` guard reads a truthy method reference.)\nfunction channelHasSubscribers(ch: realDc.Channel): boolean {\n const value = (ch as { hasSubscribers: unknown }).hasSubscribers;\n return typeof value === 'function' ? Boolean((value as () => unknown).call(ch)) : Boolean(value);\n}\n\nfunction wrapSubChannel(tracing: realDc.TracingChannel, real: realDc.Channel): realDc.Channel {\n return {\n name: real.name,\n // A method (not a getter) so it reads truthy as a property in the emit guard *and* is callable,\n // matching workerd's native shape. Forced `true`: on Cloudflare a channel is only injected for a\n // bundled integration, so the wrapper's no-subscriber short-circuit buys nothing — and disabling\n // it is what lets the wrapper run (and reach us) at module scope before `init()` has subscribed.\n hasSubscribers(): boolean {\n return true;\n },\n publish(ctx: Ctx): void {\n // Snapshot subscriber presence before publishing — it decides whether to defer if the\n // global-scope error fires below.\n const hadSubscribers = channelHasSubscribers(real);\n try {\n real.publish(ctx);\n } catch (error) {\n if (!isGlobalScopeError(error)) {\n throw error;\n }\n // We're at module scope (workerd throws here even with no subscribers). If someone was\n // already subscribed — top-level `Sentry.init()` — workerd delivered to them before\n // throwing, so they got it exactly once; don't defer. Otherwise — the common per-request\n // cached-init case — nobody received it, so defer for a subscriber that registers later\n // (at `init()`), which then gets it exactly once. In a request `publish` doesn't throw,\n // so this path never defers a normal in-request event.\n if (!hadSubscribers) {\n deferChannelEvent(tracing, ctx);\n }\n }\n },\n runStores(ctx: Ctx, fn: (...args: unknown[]) => unknown, ...rest: unknown[]): unknown {\n try {\n return real.runStores(ctx, fn, ...rest);\n } catch (error) {\n if (!isGlobalScopeError(error)) {\n throw error;\n }\n // publish() is gated too, so the store can't be established — just run the wrapped call\n // so its return value (e.g. the constructed instance) is produced now. Its own\n // `end.publish` runs back through this façade and is deferred.\n return fn();\n }\n },\n subscribe: real.subscribe.bind(real),\n unsubscribe: real.unsubscribe.bind(real),\n bindStore: real.bindStore.bind(real),\n unbindStore: real.unbindStore.bind(real),\n } as unknown as realDc.Channel;\n}\n\nexport function tracingChannel<T = Ctx>(name: string): realDc.TracingChannel<T> {\n const cached = cache.get(name);\n if (cached) {\n return cached;\n }\n\n const real = realDc.tracingChannel(name);\n const facade = {\n start: wrapSubChannel(real, real.start),\n end: wrapSubChannel(real, real.end),\n asyncStart: wrapSubChannel(real, real.asyncStart),\n asyncEnd: wrapSubChannel(real, real.asyncEnd),\n error: wrapSubChannel(real, real.error),\n // Iterator (`:next`) channels call these on the tracingChannel itself; delegate to the real\n // implementation (they only run in-request, where publish/runStores are allowed).\n traceSync: real.traceSync.bind(real),\n tracePromise: real.tracePromise.bind(real),\n traceCallback: real.traceCallback.bind(real),\n subscribe: real.subscribe.bind(real),\n unsubscribe: real.unsubscribe.bind(real),\n } as unknown as realDc.TracingChannel<T>;\n\n cache.set(name, facade);\n return facade;\n}\n\nexport const channel = realDc.channel;\nexport const subscribe = realDc.subscribe;\nexport const unsubscribe = realDc.unsubscribe;\n\n// Orchestrion's emit imports the default and destructures `tracingChannel`.\nexport default { tracingChannel, channel, subscribe, unsubscribe };\n"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"orchestrion-diagnostics-channel.js","names":[],"sources":["../../../src/orchestrion-diagnostics-channel.ts"],"sourcesContent":["/**\n * A workerd-safe `diagnostics_channel` façade for the orchestrion EMIT side, and the\n * `dcModule` target for the Cloudflare orchestrion build (see `vite/index.ts`): orchestrion's\n * transformed code imports `tracingChannel` from here (its default export) instead of\n * `node:diagnostics_channel`.\n *\n * On workerd, `channel.publish()` and `channel.runStores()` throw at module/global scope\n * (\"Disallowed operation called within global scope …\"); only inside a request handler do they\n * work. `subscribe` and channel creation are fine anywhere. Orchestrion's transformed code emits\n * `start.runStores(...)` / `end.publish(...)` at each wrapped call site, so a library\n * instantiated at module scope (`const app = new Hono()`) throws the moment it is wrapped — or,\n * if no subscriber exists yet, is skipped by the wrapper's `if (!hasSubscribers) return\n * __apm$traced()` short-circuit and never instrumented.\n *\n * This façade delegates to the real `node:diagnostics_channel` singletons — so subscribers, which\n * keep subscribing through `node:diagnostics_channel`, are reached unchanged — and changes two\n * things:\n *\n * 1. `hasSubscribers` always reports `true`, so the wrapper never short-circuits. On Cloudflare a\n * channel is only injected for an integration that is actually bundled, so the short-circuit\n * buys nothing — and disabling it is what lets the wrapper run (and reach us) at module scope,\n * before the per-request cached `init()` has subscribed.\n * 2. When a delegated `publish`/`runStores` throws the global-scope error, the event is queued via\n * {@link deferChannelEvent} instead. {@link flushDeferredChannelEvents}, called at the top of\n * the request handler after `init()`, emits it via the real channel — now inside a request,\n * where publish works.\n *\n * In a request handler nothing throws, so every call is a transparent pass-through to the real\n * channel: lifecycle channels (spans, context binding) behave exactly as on Node.\n */\nimport * as realDc from 'node:diagnostics_channel';\nimport { deferChannelEvent, isGlobalScopeError } from './orchestrion-deferred-channels';\n\ntype Ctx = Record<string, unknown>;\n\n// One façade per channel name (node's `tracingChannel` is itself a per-name singleton), built\n// once when the transformed module declares `const CH = tracingChannel(name)`.\nconst cache = new Map<string, realDc.TracingChannel>();\n\n// `Channel.hasSubscribers` is a getter on Node but a method on workerd — normalize both to a\n// boolean. (This shape difference is also why the emit wrapper never short-circuits on workerd:\n// its `if (!ch.start.hasSubscribers)` guard reads a truthy method reference.)\nfunction channelHasSubscribers(ch: realDc.Channel): boolean {\n const value = (ch as { hasSubscribers: unknown }).hasSubscribers;\n return typeof value === 'function' ? Boolean((value as () => unknown).call(ch)) : Boolean(value);\n}\n\nfunction wrapSubChannel(tracing: realDc.TracingChannel, real: realDc.Channel): realDc.Channel {\n return {\n name: real.name,\n // A method (not a getter) so it reads truthy as a property in the emit guard *and* is callable,\n // matching workerd's native shape. Forced `true`: on Cloudflare a channel is only injected for a\n // bundled integration, so the wrapper's no-subscriber short-circuit buys nothing — and disabling\n // it is what lets the wrapper run (and reach us) at module scope before `init()` has subscribed.\n hasSubscribers(): boolean {\n return true;\n },\n publish(ctx: Ctx): void {\n // Snapshot subscriber presence before publishing — it decides whether to defer if the\n // global-scope error fires below.\n const hadSubscribers = channelHasSubscribers(real);\n try {\n real.publish(ctx);\n } catch (error) {\n if (!isGlobalScopeError(error)) {\n throw error;\n }\n // We're at module scope (workerd throws here even with no subscribers). If someone was\n // already subscribed — top-level `Sentry.init()` — workerd delivered to them before\n // throwing, so they got it exactly once; don't defer. Otherwise — the common per-request\n // cached-init case — nobody received it, so defer for a subscriber that registers later\n // (at `init()`), which then gets it exactly once. In a request `publish` doesn't throw,\n // so this path never defers a normal in-request event.\n if (!hadSubscribers) {\n deferChannelEvent(tracing, ctx);\n }\n }\n },\n runStores(ctx: Ctx, fn: (...args: unknown[]) => unknown, ...rest: unknown[]): unknown {\n try {\n return real.runStores(ctx, fn, ...rest);\n } catch (error) {\n if (!isGlobalScopeError(error)) {\n throw error;\n }\n // publish() is gated too, so the store can't be established — just run the wrapped call\n // so its return value (e.g. the constructed instance) is produced now. Its own\n // `end.publish` runs back through this façade and is deferred.\n return fn();\n }\n },\n subscribe: real.subscribe.bind(real),\n unsubscribe: real.unsubscribe.bind(real),\n bindStore: real.bindStore.bind(real),\n unbindStore: real.unbindStore.bind(real),\n } as unknown as realDc.Channel;\n}\n\nexport function tracingChannel<T = Ctx>(name: string): realDc.TracingChannel<T> {\n const cached = cache.get(name);\n if (cached) {\n return cached;\n }\n\n const real = realDc.tracingChannel(name);\n const facade = {\n start: wrapSubChannel(real, real.start),\n end: wrapSubChannel(real, real.end),\n asyncStart: wrapSubChannel(real, real.asyncStart),\n asyncEnd: wrapSubChannel(real, real.asyncEnd),\n error: wrapSubChannel(real, real.error),\n // Iterator (`:next`) channels call these on the tracingChannel itself; delegate to the real\n // implementation (they only run in-request, where publish/runStores are allowed).\n traceSync: real.traceSync.bind(real),\n tracePromise: real.tracePromise.bind(real),\n traceCallback: real.traceCallback.bind(real),\n subscribe: real.subscribe.bind(real),\n unsubscribe: real.unsubscribe.bind(real),\n } as unknown as realDc.TracingChannel<T>;\n\n cache.set(name, facade);\n return facade;\n}\n\nexport const channel = realDc.channel;\nexport const subscribe = realDc.subscribe;\nexport const unsubscribe = realDc.unsubscribe;\n\n// Orchestrion's emit imports the default and destructures `tracingChannel`.\nexport default { tracingChannel, channel, subscribe, unsubscribe };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,wBAAQ,IAAI,IAAmC;AAKrD,SAAS,sBAAsB,IAA6B;CAC1D,MAAM,QAAS,GAAmC;CAClD,OAAO,OAAO,UAAU,aAAa,QAAS,MAAwB,KAAK,EAAE,CAAC,IAAI,QAAQ,KAAK;AACjG;AAEA,SAAS,eAAe,SAAgC,MAAsC;CAC5F,OAAO;EACL,MAAM,KAAK;EAKX,iBAA0B;GACxB,OAAO;EACT;EACA,QAAQ,KAAgB;GAGtB,MAAM,iBAAiB,sBAAsB,IAAI;GACjD,IAAI;IACF,KAAK,QAAQ,GAAG;GAClB,SAAS,OAAO;IACd,IAAI,CAAC,mBAAmB,KAAK,GAC3B,MAAM;IAQR,IAAI,CAAC,gBACH,kBAAkB,SAAS,GAAG;GAElC;EACF;EACA,UAAU,KAAU,IAAqC,GAAG,MAA0B;GACpF,IAAI;IACF,OAAO,KAAK,UAAU,KAAK,IAAI,GAAG,IAAI;GACxC,SAAS,OAAO;IACd,IAAI,CAAC,mBAAmB,KAAK,GAC3B,MAAM;IAKR,OAAO,GAAG;GACZ;EACF;EACA,WAAW,KAAK,UAAU,KAAK,IAAI;EACnC,aAAa,KAAK,YAAY,KAAK,IAAI;EACvC,WAAW,KAAK,UAAU,KAAK,IAAI;EACnC,aAAa,KAAK,YAAY,KAAK,IAAI;CACzC;AACF;AAEA,SAAgB,eAAwB,MAAwC;CAC9E,MAAM,SAAS,MAAM,IAAI,IAAI;CAC7B,IAAI,QACF,OAAO;CAGT,MAAM,OAAO,OAAO,eAAe,IAAI;CACvC,MAAM,SAAS;EACb,OAAO,eAAe,MAAM,KAAK,KAAK;EACtC,KAAK,eAAe,MAAM,KAAK,GAAG;EAClC,YAAY,eAAe,MAAM,KAAK,UAAU;EAChD,UAAU,eAAe,MAAM,KAAK,QAAQ;EAC5C,OAAO,eAAe,MAAM,KAAK,KAAK;EAGtC,WAAW,KAAK,UAAU,KAAK,IAAI;EACnC,cAAc,KAAK,aAAa,KAAK,IAAI;EACzC,eAAe,KAAK,cAAc,KAAK,IAAI;EAC3C,WAAW,KAAK,UAAU,KAAK,IAAI;EACnC,aAAa,KAAK,YAAY,KAAK,IAAI;CACzC;CAEA,MAAM,IAAI,MAAM,MAAM;CACtB,OAAO;AACT;AAEA,MAAa,UAAU,OAAO;AAC9B,MAAa,YAAY,OAAO;AAChC,MAAa,cAAc,OAAO;AAGlC,IAAA,0CAAe;CAAE;CAAgB;CAAS;CAAW;AAAY"}
@@ -1 +1 @@
1
- {"type":"module","version":"11.12.0","sideEffects":false}
1
+ {"type":"module","version":"11.13.0","sideEffects":false}
@@ -1,22 +1,23 @@
1
- import { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';
2
- import { wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit.js';
3
- import { init } from './sdk.js';
4
-
1
+ import { wrapRequestHandlerWithInit } from "./wrapRequestHandlerWithInit.js";
2
+ import { init } from "./sdk.js";
3
+ import { setAsyncLocalStorageAsyncContextStrategy } from "@sentry/server-utils/no-diagnostic-channels";
4
+ // src/pages-plugin.ts
5
5
  function sentryPagesPlugin(handlerOrOptions) {
6
- setAsyncLocalStorageAsyncContextStrategy();
7
- return (context) => {
8
- if (context.request.method === "OPTIONS" || context.request.method === "HEAD") {
9
- return context.next();
10
- }
11
- const options = typeof handlerOrOptions === "function" ? handlerOrOptions(context) : handlerOrOptions;
12
- const executionContext = { ...context, props: {} };
13
- return wrapRequestHandlerWithInit(
14
- { options, request: context.request, context: executionContext },
15
- () => context.next(),
16
- init
17
- );
18
- };
6
+ setAsyncLocalStorageAsyncContextStrategy();
7
+ return (context) => {
8
+ if (context.request.method === "OPTIONS" || context.request.method === "HEAD") return context.next();
9
+ const options = typeof handlerOrOptions === "function" ? handlerOrOptions(context) : handlerOrOptions;
10
+ const executionContext = {
11
+ ...context,
12
+ props: {}
13
+ };
14
+ return wrapRequestHandlerWithInit({
15
+ options,
16
+ request: context.request,
17
+ context: executionContext
18
+ }, () => context.next(), init);
19
+ };
19
20
  }
20
-
21
21
  export { sentryPagesPlugin };
22
- //# sourceMappingURL=pages-plugin.js.map
22
+
23
+ //# sourceMappingURL=pages-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pages-plugin.js","sources":["../../../src/pages-plugin.ts"],"sourcesContent":["import { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';\nimport type { CloudflareOptions } from './client';\nimport type { ExecutionContextCompat } from './executionContext';\nimport { wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit';\nimport { init } from './sdk';\nimport type { StrictCloudflareOptions } from './types';\n\n/**\n * Plugin middleware for Cloudflare Pages.\n *\n * Initializes the SDK and wraps cloudflare pages requests with SDK instrumentation.\n *\n * @example Simple usage\n *\n * ```javascript\n * // functions/_middleware.js\n * import * as Sentry from '@sentry/cloudflare';\n *\n * export const onRequest = Sentry.sentryPagesPlugin({\n * dsn: process.env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * });\n * ```\n *\n * @example Usage with handler function to access context for environmental variables\n *\n * ```javascript\n * import * as Sentry from '@sentry/cloudflare';\n *\n * const const onRequest = Sentry.sentryPagesPlugin((context) => ({\n * dsn: context.env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * })\n * ```\n *\n * @param handlerOrOptions Configuration options or a function that returns configuration options.\n * @returns A plugin function that can be used in Cloudflare Pages.\n */\n// Overloads rather than a union parameter: TypeScript does not infer `O` out of a union member,\n// so a union signature falls back to the default and the unknown-key check never runs. The object\n// overload stays on plain `CloudflareOptions` — a direct object literal is still excess property\n// checked, and a callback cannot match it.\nexport function sentryPagesPlugin<\n // oxlint-disable-next-line typescript/no-explicit-any\n Env = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Params extends string = any,\n Data extends Record<string, unknown> = Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PluginParams = any,\n O = unknown,\n>(\n handler: (context: EventPluginContext<Env, Params, Data, PluginParams>) => StrictCloudflareOptions<O>,\n): PagesPluginFunction<Env, Params, Data, PluginParams>;\nexport function sentryPagesPlugin<\n // oxlint-disable-next-line typescript/no-explicit-any\n Env = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Params extends string = any,\n Data extends Record<string, unknown> = Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PluginParams = any,\n>(options: CloudflareOptions): PagesPluginFunction<Env, Params, Data, PluginParams>;\nexport function sentryPagesPlugin<\n // oxlint-disable-next-line typescript/no-explicit-any\n Env = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Params extends string = any,\n Data extends Record<string, unknown> = Record<string, unknown>,\n // Although it is not ideal to use `any` here, it makes usage more flexible for different setups.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PluginParams = any,\n>(\n handlerOrOptions:\n | CloudflareOptions\n | ((context: EventPluginContext<Env, Params, Data, PluginParams>) => CloudflareOptions),\n): PagesPluginFunction<Env, Params, Data, PluginParams> {\n setAsyncLocalStorageAsyncContextStrategy();\n return context => {\n if (context.request.method === 'OPTIONS' || context.request.method === 'HEAD') {\n return context.next();\n }\n\n const options = typeof handlerOrOptions === 'function' ? handlerOrOptions(context) : handlerOrOptions;\n // A Pages `EventPluginContext` is not a Workers `ExecutionContext`, but `wrapRequestHandler` only\n // uses `waitUntil` and a `'storage' in context` check, both of which this satisfies.\n const executionContext = { ...context, props: {} } as unknown as ExecutionContextCompat;\n return wrapRequestHandlerWithInit(\n { options, request: context.request, context: executionContext },\n () => context.next(),\n init,\n );\n };\n}\n"],"names":[],"mappings":";;;;AA+DO,SAAS,kBAUd,gBAAA,EAGsD;AACtD,EAAA,wCAAA,EAAyC;AACzC,EAAA,OAAO,CAAA,OAAA,KAAW;AAChB,IAAA,IAAI,QAAQ,OAAA,CAAQ,MAAA,KAAW,aAAa,OAAA,CAAQ,OAAA,CAAQ,WAAW,MAAA,EAAQ;AAC7E,MAAA,OAAO,QAAQ,IAAA,EAAK;AAAA,IACtB;AAEA,IAAA,MAAM,UAAU,OAAO,gBAAA,KAAqB,UAAA,GAAa,gBAAA,CAAiB,OAAO,CAAA,GAAI,gBAAA;AAGrF,IAAA,MAAM,mBAAmB,EAAE,GAAG,OAAA,EAAS,KAAA,EAAO,EAAC,EAAE;AACjD,IAAA,OAAO,0BAAA;AAAA,MACL,EAAE,OAAA,EAAS,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAS,SAAS,gBAAA,EAAiB;AAAA,MAC/D,MAAM,QAAQ,IAAA,EAAK;AAAA,MACnB;AAAA,KACF;AAAA,EACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"pages-plugin.js","names":[],"sources":["../../../src/pages-plugin.ts"],"sourcesContent":["import { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';\nimport type { CloudflareOptions } from './client';\nimport type { ExecutionContextCompat } from './executionContext';\nimport { wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit';\nimport { init } from './sdk';\nimport type { StrictCloudflareOptions } from './types';\n\n/**\n * Plugin middleware for Cloudflare Pages.\n *\n * Initializes the SDK and wraps cloudflare pages requests with SDK instrumentation.\n *\n * @example Simple usage\n *\n * ```javascript\n * // functions/_middleware.js\n * import * as Sentry from '@sentry/cloudflare';\n *\n * export const onRequest = Sentry.sentryPagesPlugin({\n * dsn: process.env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * });\n * ```\n *\n * @example Usage with handler function to access context for environmental variables\n *\n * ```javascript\n * import * as Sentry from '@sentry/cloudflare';\n *\n * const const onRequest = Sentry.sentryPagesPlugin((context) => ({\n * dsn: context.env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * })\n * ```\n *\n * @param handlerOrOptions Configuration options or a function that returns configuration options.\n * @returns A plugin function that can be used in Cloudflare Pages.\n */\n// Overloads rather than a union parameter: TypeScript does not infer `O` out of a union member,\n// so a union signature falls back to the default and the unknown-key check never runs. The object\n// overload stays on plain `CloudflareOptions` — a direct object literal is still excess property\n// checked, and a callback cannot match it.\nexport function sentryPagesPlugin<\n // oxlint-disable-next-line typescript/no-explicit-any\n Env = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Params extends string = any,\n Data extends Record<string, unknown> = Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PluginParams = any,\n O = unknown,\n>(\n handler: (context: EventPluginContext<Env, Params, Data, PluginParams>) => StrictCloudflareOptions<O>,\n): PagesPluginFunction<Env, Params, Data, PluginParams>;\nexport function sentryPagesPlugin<\n // oxlint-disable-next-line typescript/no-explicit-any\n Env = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Params extends string = any,\n Data extends Record<string, unknown> = Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PluginParams = any,\n>(options: CloudflareOptions): PagesPluginFunction<Env, Params, Data, PluginParams>;\nexport function sentryPagesPlugin<\n // oxlint-disable-next-line typescript/no-explicit-any\n Env = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Params extends string = any,\n Data extends Record<string, unknown> = Record<string, unknown>,\n // Although it is not ideal to use `any` here, it makes usage more flexible for different setups.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PluginParams = any,\n>(\n handlerOrOptions:\n | CloudflareOptions\n | ((context: EventPluginContext<Env, Params, Data, PluginParams>) => CloudflareOptions),\n): PagesPluginFunction<Env, Params, Data, PluginParams> {\n setAsyncLocalStorageAsyncContextStrategy();\n return context => {\n if (context.request.method === 'OPTIONS' || context.request.method === 'HEAD') {\n return context.next();\n }\n\n const options = typeof handlerOrOptions === 'function' ? handlerOrOptions(context) : handlerOrOptions;\n // A Pages `EventPluginContext` is not a Workers `ExecutionContext`, but `wrapRequestHandler` only\n // uses `waitUntil` and a `'storage' in context` check, both of which this satisfies.\n const executionContext = { ...context, props: {} } as unknown as ExecutionContextCompat;\n return wrapRequestHandlerWithInit(\n { options, request: context.request, context: executionContext },\n () => context.next(),\n init,\n );\n };\n}\n"],"mappings":";;;;AA+DA,SAAgB,kBAUd,kBAGsD;CACtD,yCAAyC;CACzC,QAAO,YAAW;EAChB,IAAI,QAAQ,QAAQ,WAAW,aAAa,QAAQ,QAAQ,WAAW,QACrE,OAAO,QAAQ,KAAK;EAGtB,MAAM,UAAU,OAAO,qBAAqB,aAAa,iBAAiB,OAAO,IAAI;EAGrF,MAAM,mBAAmB;GAAE,GAAG;GAAS,OAAO,CAAC;EAAE;EACjD,OAAO,2BACL;GAAE;GAAS,SAAS,QAAQ;GAAS,SAAS;EAAiB,SACzD,QAAQ,KAAK,GACnB,IACF;CACF;AACF"}
@@ -1,10 +1,17 @@
1
- import { initBaseSdk } from './baseSdk.js';
2
- import { wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit.js';
3
- export { httpServerIntegration } from './integrations/httpServer.js';
4
-
1
+ import { initBaseSdk } from "./baseSdk.js";
2
+ import { wrapRequestHandlerWithInit } from "./wrapRequestHandlerWithInit.js";
3
+ import { httpServerIntegration } from "./integrations/httpServer.js";
4
+ // src/request.ts
5
+ /**
6
+ * Wraps a cloudflare request handler in Sentry instrumentation.
7
+ *
8
+ * The client uses the same default integrations as `init`, without setting up an OpenTelemetry
9
+ * tracer provider. This entry point also works on runtimes that cannot enable the `nodejs_compat`
10
+ * compatibility flag, such as Shopify Oxygen.
11
+ */
5
12
  function wrapRequestHandler(wrapperOptions, handler) {
6
- return wrapRequestHandlerWithInit(wrapperOptions, handler, initBaseSdk);
13
+ return wrapRequestHandlerWithInit(wrapperOptions, handler, initBaseSdk);
7
14
  }
15
+ export { httpServerIntegration, wrapRequestHandler };
8
16
 
9
- export { wrapRequestHandler };
10
- //# sourceMappingURL=request.js.map
17
+ //# sourceMappingURL=request.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sources":["../../../src/request.ts"],"sourcesContent":["import { initBaseSdk } from './baseSdk';\nimport type { CloudflareOptions } from './client';\nimport { type RequestHandlerWrapperOptions, wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit';\n\n/**\n * Wraps a cloudflare request handler in Sentry instrumentation.\n *\n * The client uses the same default integrations as `init`, without setting up an OpenTelemetry\n * tracer provider. This entry point also works on runtimes that cannot enable the `nodejs_compat`\n * compatibility flag, such as Shopify Oxygen.\n */\nexport function wrapRequestHandler(\n wrapperOptions: Omit<RequestHandlerWrapperOptions, 'options'> & {\n // `enableOpenTelemetrySetup` is only honored by `init` from `sdk.ts`; this entry point\n // initializes the SDK via `initBaseSdk`, where setting it would have no effect.\n options: Omit<CloudflareOptions, 'enableOpenTelemetrySetup'>;\n },\n handler: (...args: unknown[]) => Response | Promise<Response>,\n): Promise<Response> {\n return wrapRequestHandlerWithInit(wrapperOptions, handler, initBaseSdk);\n}\n\nexport { httpServerIntegration } from './integrations/httpServer';\n"],"names":[],"mappings":";;;;AAWO,SAAS,kBAAA,CACd,gBAKA,OAAA,EACmB;AACnB,EAAA,OAAO,0BAAA,CAA2B,cAAA,EAAgB,OAAA,EAAS,WAAW,CAAA;AACxE;;;;"}
1
+ {"version":3,"file":"request.js","names":[],"sources":["../../../src/request.ts"],"sourcesContent":["import { initBaseSdk } from './baseSdk';\nimport type { CloudflareOptions } from './client';\nimport { type RequestHandlerWrapperOptions, wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit';\n\n/**\n * Wraps a cloudflare request handler in Sentry instrumentation.\n *\n * The client uses the same default integrations as `init`, without setting up an OpenTelemetry\n * tracer provider. This entry point also works on runtimes that cannot enable the `nodejs_compat`\n * compatibility flag, such as Shopify Oxygen.\n */\nexport function wrapRequestHandler(\n wrapperOptions: Omit<RequestHandlerWrapperOptions, 'options'> & {\n // `enableOpenTelemetrySetup` is only honored by `init` from `sdk.ts`; this entry point\n // initializes the SDK via `initBaseSdk`, where setting it would have no effect.\n options: Omit<CloudflareOptions, 'enableOpenTelemetrySetup'>;\n },\n handler: (...args: unknown[]) => Response | Promise<Response>,\n): Promise<Response> {\n return wrapRequestHandlerWithInit(wrapperOptions, handler, initBaseSdk);\n}\n\nexport { httpServerIntegration } from './integrations/httpServer';\n"],"mappings":";;;;;;;;;;;AAWA,SAAgB,mBACd,gBAKA,SACmB;CACnB,OAAO,2BAA2B,gBAAgB,SAAS,WAAW;AACxE"}
@@ -1,15 +1,17 @@
1
- import { CLOUD_PROVIDER } from '@sentry/conventions/attributes';
2
-
1
+ import { CLOUD_PROVIDER } from "@sentry/conventions/attributes";
2
+ // src/scope-utils.ts
3
+ /**
4
+ * Set cloud resource context on scope.
5
+ */
3
6
  function addCloudResourceContext(scope) {
4
- scope.setContext("cloud_resource", {
5
- [CLOUD_PROVIDER]: "cloudflare"
6
- });
7
+ scope.setContext("cloud_resource", { [CLOUD_PROVIDER]: "cloudflare" });
7
8
  }
9
+ /**
10
+ * Set culture context on scope
11
+ */
8
12
  function addCultureContext(scope, cf) {
9
- scope.setContext("culture", {
10
- timezone: cf.timezone
11
- });
13
+ scope.setContext("culture", { timezone: cf.timezone });
12
14
  }
13
-
14
15
  export { addCloudResourceContext, addCultureContext };
15
- //# sourceMappingURL=scope-utils.js.map
16
+
17
+ //# sourceMappingURL=scope-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scope-utils.js","sources":["../../../src/scope-utils.ts"],"sourcesContent":["import { CLOUD_PROVIDER } from '@sentry/conventions/attributes';\nimport type { CfProperties, IncomingRequestCfProperties } from '@cloudflare/workers-types';\nimport type { Scope } from '@sentry/core';\n\n/**\n * Set cloud resource context on scope.\n */\nexport function addCloudResourceContext(scope: Scope): void {\n scope.setContext('cloud_resource', {\n [CLOUD_PROVIDER]: 'cloudflare',\n });\n}\n\n/**\n * Set culture context on scope\n */\nexport function addCultureContext(scope: Scope, cf: IncomingRequestCfProperties | CfProperties): void {\n scope.setContext('culture', {\n timezone: cf.timezone,\n });\n}\n"],"names":[],"mappings":";;AAOO,SAAS,wBAAwB,KAAA,EAAoB;AAC1D,EAAA,KAAA,CAAM,WAAW,gBAAA,EAAkB;AAAA,IACjC,CAAC,cAAc,GAAG;AAAA,GACnB,CAAA;AACH;AAKO,SAAS,iBAAA,CAAkB,OAAc,EAAA,EAAsD;AACpG,EAAA,KAAA,CAAM,WAAW,SAAA,EAAW;AAAA,IAC1B,UAAU,EAAA,CAAG;AAAA,GACd,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"scope-utils.js","names":[],"sources":["../../../src/scope-utils.ts"],"sourcesContent":["import { CLOUD_PROVIDER } from '@sentry/conventions/attributes';\nimport type { CfProperties, IncomingRequestCfProperties } from '@cloudflare/workers-types';\nimport type { Scope } from '@sentry/core';\n\n/**\n * Set cloud resource context on scope.\n */\nexport function addCloudResourceContext(scope: Scope): void {\n scope.setContext('cloud_resource', {\n [CLOUD_PROVIDER]: 'cloudflare',\n });\n}\n\n/**\n * Set culture context on scope\n */\nexport function addCultureContext(scope: Scope, cf: IncomingRequestCfProperties | CfProperties): void {\n scope.setContext('culture', {\n timezone: cf.timezone,\n });\n}\n"],"mappings":";;;;;AAOA,SAAgB,wBAAwB,OAAoB;CAC1D,MAAM,WAAW,kBAAkB,GAChC,iBAAiB,aACpB,CAAC;AACH;;;;AAKA,SAAgB,kBAAkB,OAAc,IAAsD;CACpG,MAAM,WAAW,WAAW,EAC1B,UAAU,GAAG,SACf,CAAC;AACH"}
@@ -1,18 +1,28 @@
1
- import { initBaseSdk } from './baseSdk.js';
2
- export { getDefaultIntegrations } from './baseSdk.js';
3
- import { setupOpenTelemetryTracer } from './opentelemetry/tracer.js';
4
- import { wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit.js';
5
-
1
+ import { getDefaultIntegrations, initBaseSdk } from "./baseSdk.js";
2
+ import { setupOpenTelemetryTracer } from "./opentelemetry/tracer.js";
3
+ import { wrapRequestHandlerWithInit } from "./wrapRequestHandlerWithInit.js";
4
+ import "./clientCache.js";
5
+ // src/sdk.ts
6
+ /**
7
+ * Initializes the cloudflare SDK.
8
+ */
6
9
  function init(options) {
7
- options.enableOpenTelemetrySetup ?? (options.enableOpenTelemetrySetup = false);
8
- if (options.enableOpenTelemetrySetup) {
9
- setupOpenTelemetryTracer();
10
- }
11
- return initBaseSdk(options);
10
+ options.enableOpenTelemetrySetup ?? (options.enableOpenTelemetrySetup = false);
11
+ if (options.enableOpenTelemetrySetup) setupOpenTelemetryTracer();
12
+ return initBaseSdk(options);
12
13
  }
14
+ /**
15
+ * `wrapRequestHandler` backed by `init`, so the request honors `enableOpenTelemetrySetup`. The
16
+ * `@sentry/cloudflare/request` variant deliberately skips it to stay usable without `nodejs_compat`.
17
+ *
18
+ * For framework SDKs building on the main entry point, e.g. SvelteKit, whose OpenTelemetry spans
19
+ * need the tracer provider.
20
+ *
21
+ * @internal
22
+ */
13
23
  function _INTERNAL_wrapRequestHandler(wrapperOptions, handler) {
14
- return wrapRequestHandlerWithInit(wrapperOptions, handler, init);
24
+ return wrapRequestHandlerWithInit(wrapperOptions, handler, init);
15
25
  }
26
+ export { _INTERNAL_wrapRequestHandler, getDefaultIntegrations, init };
16
27
 
17
- export { _INTERNAL_wrapRequestHandler, init };
18
- //# sourceMappingURL=sdk.js.map
28
+ //# sourceMappingURL=sdk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../../src/sdk.ts"],"sourcesContent":["import { initBaseSdk } from './baseSdk';\nimport type { CloudflareClient, CloudflareOptions } from './client';\nimport { setupOpenTelemetryTracer } from './opentelemetry/tracer';\nimport { type RequestHandlerWrapperOptions, wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit';\n\n// Test-only helper, re-exported here so tests can reset the global client cache.\nexport { _clearGlobalClientCache } from './clientCache';\n\nexport { getDefaultIntegrations } from './baseSdk';\n\n/**\n * Initializes the cloudflare SDK.\n */\nexport function init(options: CloudflareOptions): CloudflareClient | undefined {\n // Like most Node-based SDKs, Cloudflare defaults to running without a Sentry OpenTelemetry tracer\n // provider. Scope isolation is handled by the entrypoint wrappers' AsyncLocalStorage strategy.\n options.enableOpenTelemetrySetup ??= false;\n\n // Opt-in only: when `enableOpenTelemetrySetup` is `true`, set up a custom trace provider so spans\n // emitted via `@opentelemetry/api` are captured by Sentry. See the option's docs for the caveats.\n if (options.enableOpenTelemetrySetup) {\n setupOpenTelemetryTracer();\n }\n\n return initBaseSdk(options);\n}\n\n/**\n * `wrapRequestHandler` backed by `init`, so the request honors `enableOpenTelemetrySetup`. The\n * `@sentry/cloudflare/request` variant deliberately skips it to stay usable without `nodejs_compat`.\n *\n * For framework SDKs building on the main entry point, e.g. SvelteKit, whose OpenTelemetry spans\n * need the tracer provider.\n *\n * @internal\n */\nexport function _INTERNAL_wrapRequestHandler(\n wrapperOptions: RequestHandlerWrapperOptions,\n handler: (...args: unknown[]) => Response | Promise<Response>,\n): Promise<Response> {\n return wrapRequestHandlerWithInit(wrapperOptions, handler, init);\n}\n"],"names":[],"mappings":";;;;;AAaO,SAAS,KAAK,OAAA,EAA0D;AAG7E,EAAA,OAAA,CAAQ,wBAAA,KAAR,QAAQ,wBAAA,GAA6B,KAAA,CAAA;AAIrC,EAAA,IAAI,QAAQ,wBAAA,EAA0B;AACpC,IAAA,wBAAA,EAAyB;AAAA,EAC3B;AAEA,EAAA,OAAO,YAAY,OAAO,CAAA;AAC5B;AAWO,SAAS,4BAAA,CACd,gBACA,OAAA,EACmB;AACnB,EAAA,OAAO,0BAAA,CAA2B,cAAA,EAAgB,OAAA,EAAS,IAAI,CAAA;AACjE;;;;"}
1
+ {"version":3,"file":"sdk.js","names":[],"sources":["../../../src/sdk.ts"],"sourcesContent":["import { initBaseSdk } from './baseSdk';\nimport type { CloudflareClient, CloudflareOptions } from './client';\nimport { setupOpenTelemetryTracer } from './opentelemetry/tracer';\nimport { type RequestHandlerWrapperOptions, wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit';\n\n// Test-only helper, re-exported here so tests can reset the global client cache.\nexport { _clearGlobalClientCache } from './clientCache';\n\nexport { getDefaultIntegrations } from './baseSdk';\n\n/**\n * Initializes the cloudflare SDK.\n */\nexport function init(options: CloudflareOptions): CloudflareClient | undefined {\n // Like most Node-based SDKs, Cloudflare defaults to running without a Sentry OpenTelemetry tracer\n // provider. Scope isolation is handled by the entrypoint wrappers' AsyncLocalStorage strategy.\n options.enableOpenTelemetrySetup ??= false;\n\n // Opt-in only: when `enableOpenTelemetrySetup` is `true`, set up a custom trace provider so spans\n // emitted via `@opentelemetry/api` are captured by Sentry. See the option's docs for the caveats.\n if (options.enableOpenTelemetrySetup) {\n setupOpenTelemetryTracer();\n }\n\n return initBaseSdk(options);\n}\n\n/**\n * `wrapRequestHandler` backed by `init`, so the request honors `enableOpenTelemetrySetup`. The\n * `@sentry/cloudflare/request` variant deliberately skips it to stay usable without `nodejs_compat`.\n *\n * For framework SDKs building on the main entry point, e.g. SvelteKit, whose OpenTelemetry spans\n * need the tracer provider.\n *\n * @internal\n */\nexport function _INTERNAL_wrapRequestHandler(\n wrapperOptions: RequestHandlerWrapperOptions,\n handler: (...args: unknown[]) => Response | Promise<Response>,\n): Promise<Response> {\n return wrapRequestHandlerWithInit(wrapperOptions, handler, init);\n}\n"],"mappings":";;;;;;;;AAaA,SAAgB,KAAK,SAA0D;CAG7E,QAAQ,6BAAR,QAAQ,2BAA6B;CAIrC,IAAI,QAAQ,0BACV,yBAAyB;CAG3B,OAAO,YAAY,OAAO;AAC5B;;;;;;;;;;AAWA,SAAgB,6BACd,gBACA,SACmB;CACnB,OAAO,2BAA2B,gBAAgB,SAAS,IAAI;AACjE"}
@@ -1,88 +1,97 @@
1
- import { createTransport, SENTRY_BUFFER_FULL_ERROR, suppressTracing } from '@sentry/core';
2
-
1
+ import { SENTRY_BUFFER_FULL_ERROR, createTransport, suppressTracing } from "@sentry/core";
2
+ // src/transport.ts
3
+ /**
4
+ * How many payloads the buffer holds before it starts rejecting new ones.
5
+ *
6
+ * With `cacheClient` a single client is reused across an isolate's invocations, so one buffer now has to absorb
7
+ * the payloads of many invocations rather than one. 256 is the size that held up under load testing that scenario.
8
+ */
3
9
  const DEFAULT_TRANSPORT_BUFFER_SIZE = 256;
4
- class IsolatedPromiseBuffer {
5
- constructor(_bufferSize = DEFAULT_TRANSPORT_BUFFER_SIZE) {
6
- this.$ = [];
7
- this._taskProducers = [];
8
- this._bufferSize = _bufferSize;
9
- }
10
- /**
11
- * @inheritdoc
12
- */
13
- add(taskProducer) {
14
- if (this._taskProducers.length >= this._bufferSize) {
15
- return Promise.reject(SENTRY_BUFFER_FULL_ERROR);
16
- }
17
- this._taskProducers.push(taskProducer);
18
- return Promise.resolve({});
19
- }
20
- /**
21
- * @inheritdoc
22
- */
23
- drain(timeout) {
24
- const oldTaskProducers = [...this._taskProducers];
25
- this._taskProducers = [];
26
- const drainController = new AbortController();
27
- this.drainSignal = drainController.signal;
28
- const tasks = oldTaskProducers.map((taskProducer) => {
29
- try {
30
- return taskProducer();
31
- } catch (error) {
32
- return Promise.reject(error);
33
- }
34
- });
35
- this.drainSignal = void 0;
36
- return new Promise((resolve) => {
37
- const timer = setTimeout(() => {
38
- if (timeout && timeout > 0) {
39
- drainController.abort();
40
- resolve(false);
41
- }
42
- }, timeout);
43
- Promise.all(
44
- tasks.map(
45
- (task) => task.then(null, () => {
46
- })
47
- )
48
- ).then(() => {
49
- clearTimeout(timer);
50
- resolve(true);
51
- });
52
- });
53
- }
54
- }
10
+ /**
11
+ * This is a modified promise buffer that collects tasks until drain is called.
12
+ * We need this in the edge runtime because edge function invocations may not share I/O objects, like fetch requests
13
+ * and responses, and the normal PromiseBuffer inherently buffers stuff inbetween incoming requests.
14
+ *
15
+ * A limitation we need to be aware of is that DEFAULT_TRANSPORT_BUFFER_SIZE is the maximum amount of payloads the
16
+ * SDK can send for a given edge function invocation.
17
+ */
18
+ var IsolatedPromiseBuffer = class {
19
+ constructor(_bufferSize = DEFAULT_TRANSPORT_BUFFER_SIZE) {
20
+ this.$ = [];
21
+ this._taskProducers = [];
22
+ this._bufferSize = _bufferSize;
23
+ }
24
+ /**
25
+ * @inheritdoc
26
+ */
27
+ add(taskProducer) {
28
+ if (this._taskProducers.length >= this._bufferSize) return Promise.reject(SENTRY_BUFFER_FULL_ERROR);
29
+ this._taskProducers.push(taskProducer);
30
+ return Promise.resolve({});
31
+ }
32
+ /**
33
+ * @inheritdoc
34
+ */
35
+ drain(timeout) {
36
+ const oldTaskProducers = [...this._taskProducers];
37
+ this._taskProducers = [];
38
+ const drainController = new AbortController();
39
+ this.drainSignal = drainController.signal;
40
+ const tasks = oldTaskProducers.map((taskProducer) => {
41
+ try {
42
+ return taskProducer();
43
+ } catch (error) {
44
+ return Promise.reject(error);
45
+ }
46
+ });
47
+ this.drainSignal = void 0;
48
+ return new Promise((resolve) => {
49
+ const timer = setTimeout(() => {
50
+ if (timeout && timeout > 0) {
51
+ drainController.abort();
52
+ resolve(false);
53
+ }
54
+ }, timeout);
55
+ Promise.all(tasks.map((task) => task.then(null, () => {}))).then(() => {
56
+ clearTimeout(timer);
57
+ resolve(true);
58
+ });
59
+ });
60
+ }
61
+ };
62
+ /**
63
+ * Creates a Transport that uses the native fetch API to send events to Sentry.
64
+ */
55
65
  function makeCloudflareTransport(options) {
56
- const buffer = new IsolatedPromiseBuffer(options.bufferSize);
57
- function makeRequest(request) {
58
- const drainSignal = buffer.drainSignal;
59
- const callerSignal = options.fetchOptions?.signal ?? void 0;
60
- const signal = drainSignal && callerSignal ? AbortSignal.any([drainSignal, callerSignal]) : drainSignal ?? callerSignal;
61
- const requestOptions = {
62
- body: request.body,
63
- method: "POST",
64
- headers: options.headers,
65
- ...options.fetchOptions,
66
- ...signal ? { signal } : {}
67
- };
68
- return suppressTracing(() => {
69
- return (options.fetch ?? fetch)(options.url, requestOptions).then(async (response) => {
70
- try {
71
- await response.text();
72
- } catch {
73
- }
74
- return {
75
- statusCode: response.status,
76
- headers: {
77
- "x-sentry-rate-limits": response.headers.get("X-Sentry-Rate-Limits"),
78
- "retry-after": response.headers.get("Retry-After")
79
- }
80
- };
81
- });
82
- });
83
- }
84
- return createTransport(options, makeRequest, buffer);
66
+ const buffer = new IsolatedPromiseBuffer(options.bufferSize);
67
+ function makeRequest(request) {
68
+ const drainSignal = buffer.drainSignal;
69
+ const callerSignal = options.fetchOptions?.signal ?? void 0;
70
+ const signal = drainSignal && callerSignal ? AbortSignal.any([drainSignal, callerSignal]) : drainSignal ?? callerSignal;
71
+ const requestOptions = {
72
+ body: request.body,
73
+ method: "POST",
74
+ headers: options.headers,
75
+ ...options.fetchOptions,
76
+ ...signal ? { signal } : {}
77
+ };
78
+ return suppressTracing(() => {
79
+ return (options.fetch ?? fetch)(options.url, requestOptions).then(async (response) => {
80
+ try {
81
+ await response.text();
82
+ } catch {}
83
+ return {
84
+ statusCode: response.status,
85
+ headers: {
86
+ "x-sentry-rate-limits": response.headers.get("X-Sentry-Rate-Limits"),
87
+ "retry-after": response.headers.get("Retry-After")
88
+ }
89
+ };
90
+ });
91
+ });
92
+ }
93
+ return createTransport(options, makeRequest, buffer);
85
94
  }
86
-
87
95
  export { IsolatedPromiseBuffer, makeCloudflareTransport };
88
- //# sourceMappingURL=transport.js.map
96
+
97
+ //# sourceMappingURL=transport.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transport.js","sources":["../../../src/transport.ts"],"sourcesContent":["import type { BaseTransportOptions, Transport, TransportMakeRequestResponse, TransportRequest } from '@sentry/core';\nimport { createTransport, SENTRY_BUFFER_FULL_ERROR, suppressTracing } from '@sentry/core';\n\nexport interface CloudflareTransportOptions extends BaseTransportOptions {\n /** Custom fetch function to use. This allows usage of things like Workers VPC */\n fetch?: typeof fetch;\n /** Fetch API init parameters. */\n fetchOptions?: RequestInit;\n}\n\n/**\n * How many payloads the buffer holds before it starts rejecting new ones.\n *\n * With `cacheClient` a single client is reused across an isolate's invocations, so one buffer now has to absorb\n * the payloads of many invocations rather than one. 256 is the size that held up under load testing that scenario.\n */\nconst DEFAULT_TRANSPORT_BUFFER_SIZE = 256;\n\n/**\n * This is a modified promise buffer that collects tasks until drain is called.\n * We need this in the edge runtime because edge function invocations may not share I/O objects, like fetch requests\n * and responses, and the normal PromiseBuffer inherently buffers stuff inbetween incoming requests.\n *\n * A limitation we need to be aware of is that DEFAULT_TRANSPORT_BUFFER_SIZE is the maximum amount of payloads the\n * SDK can send for a given edge function invocation.\n */\nexport class IsolatedPromiseBuffer {\n // We just have this field because the promise buffer interface requires it.\n // If we ever remove it from the interface we should also remove it here.\n public $: Array<PromiseLike<TransportMakeRequestResponse>>;\n\n /**\n * Abort signal of the drain that is starting its requests. It is set only while `drain()` runs the task\n * producers, so a request reads the signal of the drain that sends it.\n */\n public drainSignal: AbortSignal | undefined;\n\n private _taskProducers: (() => PromiseLike<TransportMakeRequestResponse>)[];\n\n private readonly _bufferSize: number;\n\n public constructor(_bufferSize = DEFAULT_TRANSPORT_BUFFER_SIZE) {\n this.$ = [];\n this._taskProducers = [];\n this._bufferSize = _bufferSize;\n }\n\n /**\n * @inheritdoc\n */\n public add(taskProducer: () => PromiseLike<TransportMakeRequestResponse>): PromiseLike<TransportMakeRequestResponse> {\n if (this._taskProducers.length >= this._bufferSize) {\n return Promise.reject(SENTRY_BUFFER_FULL_ERROR);\n }\n\n this._taskProducers.push(taskProducer);\n return Promise.resolve({});\n }\n\n /**\n * @inheritdoc\n */\n public drain(timeout?: number): PromiseLike<boolean> {\n const oldTaskProducers = [...this._taskProducers];\n this._taskProducers = [];\n\n const drainController = new AbortController();\n this.drainSignal = drainController.signal;\n const tasks = oldTaskProducers.map(taskProducer => {\n // A request that throws synchronously, such as a custom `fetch`, must not stop the other requests\n // or throw into the caller.\n try {\n return taskProducer();\n } catch (error) {\n return Promise.reject(error);\n }\n });\n this.drainSignal = undefined;\n\n return new Promise(resolve => {\n const timer = setTimeout(() => {\n if (timeout && timeout > 0) {\n // Requests still pending when the drain times out are aborted. Otherwise Cloudflare keeps them\n // until it cancels the invocation's `waitUntil` work and logs a warning.\n drainController.abort();\n resolve(false);\n }\n }, timeout);\n\n // This cannot reject\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.all(\n tasks.map(task =>\n task.then(null, () => {\n // catch all failed requests\n }),\n ),\n ).then(() => {\n // resolve to true if all fetch requests settled\n clearTimeout(timer);\n resolve(true);\n });\n });\n }\n}\n\n/**\n * Creates a Transport that uses the native fetch API to send events to Sentry.\n */\nexport function makeCloudflareTransport(options: CloudflareTransportOptions): Transport {\n const buffer = new IsolatedPromiseBuffer(options.bufferSize);\n\n function makeRequest(request: TransportRequest): PromiseLike<TransportMakeRequestResponse> {\n const drainSignal = buffer.drainSignal;\n const callerSignal = options.fetchOptions?.signal ?? undefined;\n const signal =\n drainSignal && callerSignal ? AbortSignal.any([drainSignal, callerSignal]) : (drainSignal ?? callerSignal);\n\n const requestOptions: RequestInit = {\n body: request.body as BodyInit,\n method: 'POST',\n headers: options.headers,\n ...options.fetchOptions,\n ...(signal ? { signal } : {}),\n };\n\n return suppressTracing(() => {\n return (options.fetch ?? fetch)(options.url, requestOptions).then(async response => {\n // Consume the response body to satisfy Cloudflare Workers' fetch requirements.\n // The runtime requires all fetch response bodies to be read or explicitly canceled\n // to prevent connection stalls and potential deadlocks. We read the body as text\n // even though we don't use the content, as Sentry's response information is in the headers.\n // See: https://github.com/getsentry/sentry-javascript/issues/18534\n try {\n await response.text();\n } catch {\n // no-op\n }\n\n return {\n statusCode: response.status,\n headers: {\n 'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),\n 'retry-after': response.headers.get('Retry-After'),\n },\n };\n });\n });\n }\n\n return createTransport(options, makeRequest, buffer);\n}\n"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"transport.js","names":[],"sources":["../../../src/transport.ts"],"sourcesContent":["import type { BaseTransportOptions, Transport, TransportMakeRequestResponse, TransportRequest } from '@sentry/core';\nimport { createTransport, SENTRY_BUFFER_FULL_ERROR, suppressTracing } from '@sentry/core';\n\nexport interface CloudflareTransportOptions extends BaseTransportOptions {\n /** Custom fetch function to use. This allows usage of things like Workers VPC */\n fetch?: typeof fetch;\n /** Fetch API init parameters. */\n fetchOptions?: RequestInit;\n}\n\n/**\n * How many payloads the buffer holds before it starts rejecting new ones.\n *\n * With `cacheClient` a single client is reused across an isolate's invocations, so one buffer now has to absorb\n * the payloads of many invocations rather than one. 256 is the size that held up under load testing that scenario.\n */\nconst DEFAULT_TRANSPORT_BUFFER_SIZE = 256;\n\n/**\n * This is a modified promise buffer that collects tasks until drain is called.\n * We need this in the edge runtime because edge function invocations may not share I/O objects, like fetch requests\n * and responses, and the normal PromiseBuffer inherently buffers stuff inbetween incoming requests.\n *\n * A limitation we need to be aware of is that DEFAULT_TRANSPORT_BUFFER_SIZE is the maximum amount of payloads the\n * SDK can send for a given edge function invocation.\n */\nexport class IsolatedPromiseBuffer {\n // We just have this field because the promise buffer interface requires it.\n // If we ever remove it from the interface we should also remove it here.\n public $: Array<PromiseLike<TransportMakeRequestResponse>>;\n\n /**\n * Abort signal of the drain that is starting its requests. It is set only while `drain()` runs the task\n * producers, so a request reads the signal of the drain that sends it.\n */\n public drainSignal: AbortSignal | undefined;\n\n private _taskProducers: (() => PromiseLike<TransportMakeRequestResponse>)[];\n\n private readonly _bufferSize: number;\n\n public constructor(_bufferSize = DEFAULT_TRANSPORT_BUFFER_SIZE) {\n this.$ = [];\n this._taskProducers = [];\n this._bufferSize = _bufferSize;\n }\n\n /**\n * @inheritdoc\n */\n public add(taskProducer: () => PromiseLike<TransportMakeRequestResponse>): PromiseLike<TransportMakeRequestResponse> {\n if (this._taskProducers.length >= this._bufferSize) {\n return Promise.reject(SENTRY_BUFFER_FULL_ERROR);\n }\n\n this._taskProducers.push(taskProducer);\n return Promise.resolve({});\n }\n\n /**\n * @inheritdoc\n */\n public drain(timeout?: number): PromiseLike<boolean> {\n const oldTaskProducers = [...this._taskProducers];\n this._taskProducers = [];\n\n const drainController = new AbortController();\n this.drainSignal = drainController.signal;\n const tasks = oldTaskProducers.map(taskProducer => {\n // A request that throws synchronously, such as a custom `fetch`, must not stop the other requests\n // or throw into the caller.\n try {\n return taskProducer();\n } catch (error) {\n return Promise.reject(error);\n }\n });\n this.drainSignal = undefined;\n\n return new Promise(resolve => {\n const timer = setTimeout(() => {\n if (timeout && timeout > 0) {\n // Requests still pending when the drain times out are aborted. Otherwise Cloudflare keeps them\n // until it cancels the invocation's `waitUntil` work and logs a warning.\n drainController.abort();\n resolve(false);\n }\n }, timeout);\n\n // This cannot reject\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.all(\n tasks.map(task =>\n task.then(null, () => {\n // catch all failed requests\n }),\n ),\n ).then(() => {\n // resolve to true if all fetch requests settled\n clearTimeout(timer);\n resolve(true);\n });\n });\n }\n}\n\n/**\n * Creates a Transport that uses the native fetch API to send events to Sentry.\n */\nexport function makeCloudflareTransport(options: CloudflareTransportOptions): Transport {\n const buffer = new IsolatedPromiseBuffer(options.bufferSize);\n\n function makeRequest(request: TransportRequest): PromiseLike<TransportMakeRequestResponse> {\n const drainSignal = buffer.drainSignal;\n const callerSignal = options.fetchOptions?.signal ?? undefined;\n const signal =\n drainSignal && callerSignal ? AbortSignal.any([drainSignal, callerSignal]) : (drainSignal ?? callerSignal);\n\n const requestOptions: RequestInit = {\n body: request.body as BodyInit,\n method: 'POST',\n headers: options.headers,\n ...options.fetchOptions,\n ...(signal ? { signal } : {}),\n };\n\n return suppressTracing(() => {\n return (options.fetch ?? fetch)(options.url, requestOptions).then(async response => {\n // Consume the response body to satisfy Cloudflare Workers' fetch requirements.\n // The runtime requires all fetch response bodies to be read or explicitly canceled\n // to prevent connection stalls and potential deadlocks. We read the body as text\n // even though we don't use the content, as Sentry's response information is in the headers.\n // See: https://github.com/getsentry/sentry-javascript/issues/18534\n try {\n await response.text();\n } catch {\n // no-op\n }\n\n return {\n statusCode: response.status,\n headers: {\n 'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),\n 'retry-after': response.headers.get('Retry-After'),\n },\n };\n });\n });\n }\n\n return createTransport(options, makeRequest, buffer);\n}\n"],"mappings":";;;;;;;;AAgBA,MAAM,gCAAgC;;;;;;;;;AAUtC,IAAa,wBAAb,MAAmC;CAe1B,YAAY,cAAc,+BAA+B;EAC9D,KAAK,IAAI,CAAC;EACV,KAAK,iBAAiB,CAAC;EACvB,KAAK,cAAc;CACrB;;;;CAKO,IAAI,cAA0G;EACnH,IAAI,KAAK,eAAe,UAAU,KAAK,aACrC,OAAO,QAAQ,OAAO,wBAAwB;EAGhD,KAAK,eAAe,KAAK,YAAY;EACrC,OAAO,QAAQ,QAAQ,CAAC,CAAC;CAC3B;;;;CAKO,MAAM,SAAwC;EACnD,MAAM,mBAAmB,CAAC,GAAG,KAAK,cAAc;EAChD,KAAK,iBAAiB,CAAC;EAEvB,MAAM,kBAAkB,IAAI,gBAAgB;EAC5C,KAAK,cAAc,gBAAgB;EACnC,MAAM,QAAQ,iBAAiB,KAAI,iBAAgB;GAGjD,IAAI;IACF,OAAO,aAAa;GACtB,SAAS,OAAO;IACd,OAAO,QAAQ,OAAO,KAAK;GAC7B;EACF,CAAC;EACD,KAAK,cAAc,KAAA;EAEnB,OAAO,IAAI,SAAQ,YAAW;GAC5B,MAAM,QAAQ,iBAAiB;IAC7B,IAAI,WAAW,UAAU,GAAG;KAG1B,gBAAgB,MAAM;KACtB,QAAQ,KAAK;IACf;GACF,GAAG,OAAO;GAIV,QAAQ,IACN,MAAM,KAAI,SACR,KAAK,KAAK,YAAY,CAEtB,CAAC,CACH,CACF,CAAC,CAAC,WAAW;IAEX,aAAa,KAAK;IAClB,QAAQ,IAAI;GACd,CAAC;EACH,CAAC;CACH;AACF;;;;AAKA,SAAgB,wBAAwB,SAAgD;CACtF,MAAM,SAAS,IAAI,sBAAsB,QAAQ,UAAU;CAE3D,SAAS,YAAY,SAAsE;EACzF,MAAM,cAAc,OAAO;EAC3B,MAAM,eAAe,QAAQ,cAAc,UAAU,KAAA;EACrD,MAAM,SACJ,eAAe,eAAe,YAAY,IAAI,CAAC,aAAa,YAAY,CAAC,IAAK,eAAe;EAE/F,MAAM,iBAA8B;GAClC,MAAM,QAAQ;GACd,QAAQ;GACR,SAAS,QAAQ;GACjB,GAAG,QAAQ;GACX,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;EAC7B;EAEA,OAAO,sBAAsB;GAC3B,QAAQ,QAAQ,SAAS,MAAA,CAAO,QAAQ,KAAK,cAAc,CAAC,CAAC,KAAK,OAAM,aAAY;IAMlF,IAAI;KACF,MAAM,SAAS,KAAK;IACtB,QAAQ,CAER;IAEA,OAAO;KACL,YAAY,SAAS;KACrB,SAAS;MACP,wBAAwB,SAAS,QAAQ,IAAI,sBAAsB;MACnE,eAAe,SAAS,QAAQ,IAAI,aAAa;KACnD;IACF;GACF,CAAC;EACH,CAAC;CACH;CAEA,OAAO,gBAAgB,SAAS,aAAa,MAAM;AACrD"}
@@ -1,11 +1,13 @@
1
- import { getAsyncContextStrategy, getMainCarrier } from '@sentry/core';
2
- import { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';
3
-
1
+ import { getAsyncContextStrategy, getMainCarrier } from "@sentry/core";
2
+ import { setAsyncLocalStorageAsyncContextStrategy } from "@sentry/server-utils/no-diagnostic-channels";
3
+ // src/utils/asyncContextStrategy.ts
4
+ /**
5
+ * Installs the AsyncLocalStorage strategy unless an OpenTelemetry strategy is installed. Both use the same storage,
6
+ * so a switch during a request breaks it (#24603).
7
+ */
4
8
  function setAsyncLocalStorageAsyncContextStrategyForWorker() {
5
- if (!getAsyncContextStrategy(getMainCarrier()).withActiveSpan) {
6
- setAsyncLocalStorageAsyncContextStrategy();
7
- }
9
+ if (!getAsyncContextStrategy(getMainCarrier()).withActiveSpan) setAsyncLocalStorageAsyncContextStrategy();
8
10
  }
9
-
10
11
  export { setAsyncLocalStorageAsyncContextStrategyForWorker };
11
- //# sourceMappingURL=asyncContextStrategy.js.map
12
+
13
+ //# sourceMappingURL=asyncContextStrategy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"asyncContextStrategy.js","sources":["../../../../src/utils/asyncContextStrategy.ts"],"sourcesContent":["import { getAsyncContextStrategy, getMainCarrier } from '@sentry/core';\nimport { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';\n\n/**\n * Installs the AsyncLocalStorage strategy unless an OpenTelemetry strategy is installed. Both use the same storage,\n * so a switch during a request breaks it (#24603).\n */\nexport function setAsyncLocalStorageAsyncContextStrategyForWorker(): void {\n if (!getAsyncContextStrategy(getMainCarrier()).withActiveSpan) {\n setAsyncLocalStorageAsyncContextStrategy();\n }\n}\n"],"names":[],"mappings":";;;AAOO,SAAS,iDAAA,GAA0D;AACxE,EAAA,IAAI,CAAC,uBAAA,CAAwB,cAAA,EAAgB,EAAE,cAAA,EAAgB;AAC7D,IAAA,wCAAA,EAAyC;AAAA,EAC3C;AACF;;;;"}
1
+ {"version":3,"file":"asyncContextStrategy.js","names":[],"sources":["../../../../src/utils/asyncContextStrategy.ts"],"sourcesContent":["import { getAsyncContextStrategy, getMainCarrier } from '@sentry/core';\nimport { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';\n\n/**\n * Installs the AsyncLocalStorage strategy unless an OpenTelemetry strategy is installed. Both use the same storage,\n * so a switch during a request breaks it (#24603).\n */\nexport function setAsyncLocalStorageAsyncContextStrategyForWorker(): void {\n if (!getAsyncContextStrategy(getMainCarrier()).withActiveSpan) {\n setAsyncLocalStorageAsyncContextStrategy();\n }\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,oDAA0D;CACxE,IAAI,CAAC,wBAAwB,eAAe,CAAC,CAAC,CAAC,gBAC7C,yCAAyC;AAE7C"}
@@ -1,15 +1,23 @@
1
- import { matchesTracePropagationTargets } from '@sentry/core';
2
-
1
+ import { matchesTracePropagationTargets } from "@sentry/core";
2
+ // src/utils/bindingPropagation.ts
3
3
  const PROPAGATE_TO_NONE = () => false;
4
+ /**
5
+ * Builds the per-binding predicate that decides whether a binding takes part in trace propagation.
6
+ */
4
7
  function createBindingPropagationResolver(bindings) {
5
- if (!bindings?.length) {
6
- return PROPAGATE_TO_NONE;
7
- }
8
- return (bindingName) => matchesTracePropagationTargets(bindingName, bindings, true);
8
+ if (!bindings?.length) return PROPAGATE_TO_NONE;
9
+ return (bindingName) => matchesTracePropagationTargets(bindingName, bindings, true);
9
10
  }
11
+ /**
12
+ * Builds the per-binding predicate that decides whether a binding takes part in RPC trace
13
+ * propagation.
14
+ *
15
+ * Callers only. Receivers continue an incoming trace whenever one arrives, so they have nothing to
16
+ * match against.
17
+ */
10
18
  function createRpcPropagationResolver(options) {
11
- return createBindingPropagationResolver(options?.rpcTracePropagationBindings);
19
+ return createBindingPropagationResolver(options?.rpcTracePropagationBindings);
12
20
  }
13
-
14
21
  export { createBindingPropagationResolver, createRpcPropagationResolver };
15
- //# sourceMappingURL=bindingPropagation.js.map
22
+
23
+ //# sourceMappingURL=bindingPropagation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bindingPropagation.js","sources":["../../../../src/utils/bindingPropagation.ts"],"sourcesContent":["import { matchesTracePropagationTargets, type TracePropagationTargets } from '@sentry/core';\nimport type { CloudflareOptions } from '../client';\n\nconst PROPAGATE_TO_NONE = () => false;\n\n/**\n * Builds the per-binding predicate that decides whether a binding takes part in trace propagation.\n */\nexport function createBindingPropagationResolver(\n bindings: TracePropagationTargets | undefined,\n): (bindingName: string) => boolean {\n if (!bindings?.length) {\n return PROPAGATE_TO_NONE;\n }\n\n // Strings must match a binding name exactly, without this, an entry of `DB` would also enable\n // propagation for a binding named `MY_DB`. Regular expressions still give pattern matching.\n return (bindingName: string) => matchesTracePropagationTargets(bindingName, bindings, true);\n}\n\n/**\n * Builds the per-binding predicate that decides whether a binding takes part in RPC trace\n * propagation.\n *\n * Callers only. Receivers continue an incoming trace whenever one arrives, so they have nothing to\n * match against.\n */\nexport function createRpcPropagationResolver(options: CloudflareOptions | undefined): (bindingName: string) => boolean {\n return createBindingPropagationResolver(options?.rpcTracePropagationBindings);\n}\n"],"names":[],"mappings":";;AAGA,MAAM,oBAAoB,MAAM,KAAA;AAKzB,SAAS,iCACd,QAAA,EACkC;AAClC,EAAA,IAAI,CAAC,UAAU,MAAA,EAAQ;AACrB,IAAA,OAAO,iBAAA;AAAA,EACT;AAIA,EAAA,OAAO,CAAC,WAAA,KAAwB,8BAAA,CAA+B,WAAA,EAAa,UAAU,IAAI,CAAA;AAC5F;AASO,SAAS,6BAA6B,OAAA,EAA0E;AACrH,EAAA,OAAO,gCAAA,CAAiC,SAAS,2BAA2B,CAAA;AAC9E;;;;"}
1
+ {"version":3,"file":"bindingPropagation.js","names":[],"sources":["../../../../src/utils/bindingPropagation.ts"],"sourcesContent":["import { matchesTracePropagationTargets, type TracePropagationTargets } from '@sentry/core';\nimport type { CloudflareOptions } from '../client';\n\nconst PROPAGATE_TO_NONE = () => false;\n\n/**\n * Builds the per-binding predicate that decides whether a binding takes part in trace propagation.\n */\nexport function createBindingPropagationResolver(\n bindings: TracePropagationTargets | undefined,\n): (bindingName: string) => boolean {\n if (!bindings?.length) {\n return PROPAGATE_TO_NONE;\n }\n\n // Strings must match a binding name exactly, without this, an entry of `DB` would also enable\n // propagation for a binding named `MY_DB`. Regular expressions still give pattern matching.\n return (bindingName: string) => matchesTracePropagationTargets(bindingName, bindings, true);\n}\n\n/**\n * Builds the per-binding predicate that decides whether a binding takes part in RPC trace\n * propagation.\n *\n * Callers only. Receivers continue an incoming trace whenever one arrives, so they have nothing to\n * match against.\n */\nexport function createRpcPropagationResolver(options: CloudflareOptions | undefined): (bindingName: string) => boolean {\n return createBindingPropagationResolver(options?.rpcTracePropagationBindings);\n}\n"],"mappings":";;AAGA,MAAM,0BAA0B;;;;AAKhC,SAAgB,iCACd,UACkC;CAClC,IAAI,CAAC,UAAU,QACb,OAAO;CAKT,QAAQ,gBAAwB,+BAA+B,aAAa,UAAU,IAAI;AAC5F;;;;;;;;AASA,SAAgB,6BAA6B,SAA0E;CACrH,OAAO,iCAAiC,SAAS,2BAA2B;AAC9E"}
@@ -0,0 +1,34 @@
1
+ import { _INTERNAL_safeMathRandom, getCurrentScope, hasSpansEnabled, isContinuingTrace } from "@sentry/core";
2
+ // src/utils/cloudflareTrace.ts
3
+ const TRACE_ID_REGEXP = /^(?!0{32})[0-9a-f]{32}$/;
4
+ const SPAN_ID_REGEXP = /^(?!0{16})[0-9a-f]{16}$/;
5
+ /**
6
+ * Sets the propagation context of the current scope to the Cloudflare trace of the invocation, so
7
+ * errors, logs and spans get the trace id of the spans that Cloudflare exports.
8
+ *
9
+ * Only runs when Sentry tracing is not set up (no `tracesSampleRate` or `tracesSampler`), so a trace
10
+ * has one source: either the SDK or Cloudflare, never a mix of both.
11
+ *
12
+ * Does nothing when the current scope already continues a trace, for example an incoming Sentry
13
+ * trace, when Cloudflare does not trace the invocation, or when the runtime does not expose
14
+ * `Span.spanContext()`.
15
+ */
16
+ function continueCloudflareTrace(context) {
17
+ if (hasSpansEnabled() || isContinuingTrace(getCurrentScope().getPropagationContext())) return;
18
+ let spanContext;
19
+ try {
20
+ const span = context?.tracing?.getActiveSpan?.();
21
+ spanContext = span?.isTraced ? span.spanContext?.() : void 0;
22
+ } catch {
23
+ return;
24
+ }
25
+ if (!spanContext || !TRACE_ID_REGEXP.test(spanContext.traceId) || !SPAN_ID_REGEXP.test(spanContext.spanId)) return;
26
+ getCurrentScope().setPropagationContext({
27
+ traceId: spanContext.traceId,
28
+ parentSpanId: spanContext.spanId,
29
+ sampleRand: _INTERNAL_safeMathRandom()
30
+ });
31
+ }
32
+ export { continueCloudflareTrace };
33
+
34
+ //# sourceMappingURL=cloudflareTrace.js.map