@sentry/cloudflare 11.0.0-alpha.1 → 11.0.0-beta.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 (415) hide show
  1. package/build/cjs/dev/baseSdk.js +20 -8
  2. package/build/cjs/dev/baseSdk.js.map +1 -1
  3. package/build/cjs/dev/client.js +118 -25
  4. package/build/cjs/dev/client.js.map +1 -1
  5. package/build/cjs/dev/clientCache.js +15 -0
  6. package/build/cjs/dev/clientCache.js.map +1 -0
  7. package/build/cjs/dev/defineCloudflareOptions.js.map +1 -1
  8. package/build/cjs/dev/durableobject.js +4 -62
  9. package/build/cjs/dev/durableobject.js.map +1 -1
  10. package/build/cjs/dev/flush.js +6 -4
  11. package/build/cjs/dev/flush.js.map +1 -1
  12. package/build/cjs/dev/index.js +8 -7
  13. package/build/cjs/dev/index.js.map +1 -1
  14. package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js +3 -1
  15. package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  16. package/build/cjs/dev/instrumentations/instrumentDurableObjectHandlers.js +123 -0
  17. package/build/cjs/dev/instrumentations/instrumentDurableObjectHandlers.js.map +1 -0
  18. package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js +4 -4
  19. package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  20. package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js +3 -1
  21. package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  22. package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js +3 -1
  23. package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  24. package/build/cjs/dev/instrumentations/instrumentSqlStorage.js +6 -3
  25. package/build/cjs/dev/instrumentations/instrumentSqlStorage.js.map +1 -1
  26. package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js +9 -16
  27. package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  28. package/build/cjs/dev/instrumentations/worker/instrumentD1.js +10 -3
  29. package/build/cjs/dev/instrumentations/worker/instrumentD1.js.map +1 -1
  30. package/build/cjs/dev/instrumentations/worker/instrumentEmail.js +4 -2
  31. package/build/cjs/dev/instrumentations/worker/instrumentEmail.js.map +1 -1
  32. package/build/cjs/dev/instrumentations/worker/instrumentEnv.js +5 -12
  33. package/build/cjs/dev/instrumentations/worker/instrumentEnv.js.map +1 -1
  34. package/build/cjs/dev/instrumentations/worker/instrumentFetch.js +8 -8
  35. package/build/cjs/dev/instrumentations/worker/instrumentFetch.js.map +1 -1
  36. package/build/cjs/dev/instrumentations/worker/instrumentQueue.js +4 -2
  37. package/build/cjs/dev/instrumentations/worker/instrumentQueue.js.map +1 -1
  38. package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js +3 -2
  39. package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  40. package/build/cjs/dev/instrumentations/worker/instrumentR2.js +21 -18
  41. package/build/cjs/dev/instrumentations/worker/instrumentR2.js.map +1 -1
  42. package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js +4 -2
  43. package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js.map +1 -1
  44. package/build/cjs/dev/instrumentations/worker/instrumentTail.js +2 -0
  45. package/build/cjs/dev/instrumentations/worker/instrumentTail.js.map +1 -1
  46. package/build/cjs/dev/integrations/fetch.js +1 -11
  47. package/build/cjs/dev/integrations/fetch.js.map +1 -1
  48. package/build/cjs/dev/opentelemetry/tracer.js +2 -40
  49. package/build/cjs/dev/opentelemetry/tracer.js.map +1 -1
  50. package/build/cjs/dev/pages-plugin.js +2 -2
  51. package/build/cjs/dev/pages-plugin.js.map +1 -1
  52. package/build/cjs/dev/request.js +2 -123
  53. package/build/cjs/dev/request.js.map +1 -1
  54. package/build/cjs/dev/sdk.js +11 -6
  55. package/build/cjs/dev/sdk.js.map +1 -1
  56. package/build/cjs/dev/transport.js +1 -1
  57. package/build/cjs/dev/transport.js.map +1 -1
  58. package/build/cjs/dev/utils/invocationContext.js +41 -0
  59. package/build/cjs/dev/utils/invocationContext.js.map +1 -0
  60. package/build/cjs/dev/utils/invocationScope.js +7 -2
  61. package/build/cjs/dev/utils/invocationScope.js.map +1 -1
  62. package/build/cjs/dev/utils/isBinding.js +0 -4
  63. package/build/cjs/dev/utils/isBinding.js.map +1 -1
  64. package/build/cjs/dev/utils/rpcPropagation.js +15 -0
  65. package/build/cjs/dev/utils/rpcPropagation.js.map +1 -0
  66. package/build/cjs/dev/vendor/stacktrace.js +2 -1
  67. package/build/cjs/dev/vendor/stacktrace.js.map +1 -1
  68. package/build/cjs/dev/vite/autoInstrument.js +2 -1
  69. package/build/cjs/dev/vite/autoInstrument.js.map +1 -1
  70. package/build/cjs/dev/vite/index.js.map +1 -1
  71. package/build/cjs/dev/vite/transform.js +30 -5
  72. package/build/cjs/dev/vite/transform.js.map +1 -1
  73. package/build/cjs/dev/vite/wranglerConfig.js +21 -1
  74. package/build/cjs/dev/vite/wranglerConfig.js.map +1 -1
  75. package/build/cjs/dev/withSentry.js.map +1 -1
  76. package/build/cjs/dev/workflows.js +45 -33
  77. package/build/cjs/dev/workflows.js.map +1 -1
  78. package/build/cjs/dev/wrapMethodWithSentry.js +51 -15
  79. package/build/cjs/dev/wrapMethodWithSentry.js.map +1 -1
  80. package/build/cjs/dev/wrapRequestHandlerWithInit.js +134 -0
  81. package/build/cjs/dev/wrapRequestHandlerWithInit.js.map +1 -0
  82. package/build/cjs/prod/baseSdk.js +20 -8
  83. package/build/cjs/prod/baseSdk.js.map +1 -1
  84. package/build/cjs/prod/client.js +118 -25
  85. package/build/cjs/prod/client.js.map +1 -1
  86. package/build/cjs/prod/clientCache.js +15 -0
  87. package/build/cjs/prod/clientCache.js.map +1 -0
  88. package/build/cjs/prod/defineCloudflareOptions.js.map +1 -1
  89. package/build/cjs/prod/durableobject.js +4 -62
  90. package/build/cjs/prod/durableobject.js.map +1 -1
  91. package/build/cjs/prod/flush.js +6 -4
  92. package/build/cjs/prod/flush.js.map +1 -1
  93. package/build/cjs/prod/index.js +8 -7
  94. package/build/cjs/prod/index.js.map +1 -1
  95. package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js +3 -1
  96. package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  97. package/build/cjs/prod/instrumentations/instrumentDurableObjectHandlers.js +123 -0
  98. package/build/cjs/prod/instrumentations/instrumentDurableObjectHandlers.js.map +1 -0
  99. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js +4 -4
  100. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  101. package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js +3 -1
  102. package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  103. package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +3 -1
  104. package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  105. package/build/cjs/prod/instrumentations/instrumentSqlStorage.js +6 -3
  106. package/build/cjs/prod/instrumentations/instrumentSqlStorage.js.map +1 -1
  107. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js +9 -16
  108. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  109. package/build/cjs/prod/instrumentations/worker/instrumentD1.js +10 -3
  110. package/build/cjs/prod/instrumentations/worker/instrumentD1.js.map +1 -1
  111. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js +4 -2
  112. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js.map +1 -1
  113. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js +5 -12
  114. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js.map +1 -1
  115. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js +8 -8
  116. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js.map +1 -1
  117. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js +4 -2
  118. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js.map +1 -1
  119. package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js +3 -2
  120. package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  121. package/build/cjs/prod/instrumentations/worker/instrumentR2.js +21 -18
  122. package/build/cjs/prod/instrumentations/worker/instrumentR2.js.map +1 -1
  123. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js +4 -2
  124. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js.map +1 -1
  125. package/build/cjs/prod/instrumentations/worker/instrumentTail.js +2 -0
  126. package/build/cjs/prod/instrumentations/worker/instrumentTail.js.map +1 -1
  127. package/build/cjs/prod/integrations/fetch.js +1 -11
  128. package/build/cjs/prod/integrations/fetch.js.map +1 -1
  129. package/build/cjs/prod/opentelemetry/tracer.js +2 -40
  130. package/build/cjs/prod/opentelemetry/tracer.js.map +1 -1
  131. package/build/cjs/prod/pages-plugin.js +2 -2
  132. package/build/cjs/prod/pages-plugin.js.map +1 -1
  133. package/build/cjs/prod/request.js +2 -123
  134. package/build/cjs/prod/request.js.map +1 -1
  135. package/build/cjs/prod/sdk.js +11 -6
  136. package/build/cjs/prod/sdk.js.map +1 -1
  137. package/build/cjs/prod/transport.js +1 -1
  138. package/build/cjs/prod/transport.js.map +1 -1
  139. package/build/cjs/prod/utils/invocationContext.js +41 -0
  140. package/build/cjs/prod/utils/invocationContext.js.map +1 -0
  141. package/build/cjs/prod/utils/invocationScope.js +7 -2
  142. package/build/cjs/prod/utils/invocationScope.js.map +1 -1
  143. package/build/cjs/prod/utils/isBinding.js +0 -4
  144. package/build/cjs/prod/utils/isBinding.js.map +1 -1
  145. package/build/cjs/prod/utils/rpcPropagation.js +15 -0
  146. package/build/cjs/prod/utils/rpcPropagation.js.map +1 -0
  147. package/build/cjs/prod/vendor/stacktrace.js +2 -1
  148. package/build/cjs/prod/vendor/stacktrace.js.map +1 -1
  149. package/build/cjs/prod/vite/autoInstrument.js +2 -1
  150. package/build/cjs/prod/vite/autoInstrument.js.map +1 -1
  151. package/build/cjs/prod/vite/index.js.map +1 -1
  152. package/build/cjs/prod/vite/transform.js +30 -5
  153. package/build/cjs/prod/vite/transform.js.map +1 -1
  154. package/build/cjs/prod/vite/wranglerConfig.js +21 -1
  155. package/build/cjs/prod/vite/wranglerConfig.js.map +1 -1
  156. package/build/cjs/prod/withSentry.js.map +1 -1
  157. package/build/cjs/prod/workflows.js +45 -33
  158. package/build/cjs/prod/workflows.js.map +1 -1
  159. package/build/cjs/prod/wrapMethodWithSentry.js +51 -15
  160. package/build/cjs/prod/wrapMethodWithSentry.js.map +1 -1
  161. package/build/cjs/prod/wrapRequestHandlerWithInit.js +134 -0
  162. package/build/cjs/prod/wrapRequestHandlerWithInit.js.map +1 -0
  163. package/build/esm/dev/baseSdk.js +21 -9
  164. package/build/esm/dev/baseSdk.js.map +1 -1
  165. package/build/esm/dev/client.js +118 -25
  166. package/build/esm/dev/client.js.map +1 -1
  167. package/build/esm/dev/clientCache.js +12 -0
  168. package/build/esm/dev/clientCache.js.map +1 -0
  169. package/build/esm/dev/defineCloudflareOptions.js.map +1 -1
  170. package/build/esm/dev/durableobject.js +5 -63
  171. package/build/esm/dev/durableobject.js.map +1 -1
  172. package/build/esm/dev/flush.js +6 -4
  173. package/build/esm/dev/flush.js.map +1 -1
  174. package/build/esm/dev/index.js +4 -4
  175. package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js +4 -2
  176. package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  177. package/build/esm/dev/instrumentations/instrumentDurableObjectHandlers.js +121 -0
  178. package/build/esm/dev/instrumentations/instrumentDurableObjectHandlers.js.map +1 -0
  179. package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js +4 -4
  180. package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  181. package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js +3 -1
  182. package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  183. package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js +3 -1
  184. package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  185. package/build/esm/dev/instrumentations/instrumentSqlStorage.js +5 -2
  186. package/build/esm/dev/instrumentations/instrumentSqlStorage.js.map +1 -1
  187. package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js +9 -16
  188. package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  189. package/build/esm/dev/instrumentations/worker/instrumentD1.js +11 -4
  190. package/build/esm/dev/instrumentations/worker/instrumentD1.js.map +1 -1
  191. package/build/esm/dev/instrumentations/worker/instrumentEmail.js +7 -5
  192. package/build/esm/dev/instrumentations/worker/instrumentEmail.js.map +1 -1
  193. package/build/esm/dev/instrumentations/worker/instrumentEnv.js +6 -13
  194. package/build/esm/dev/instrumentations/worker/instrumentEnv.js.map +1 -1
  195. package/build/esm/dev/instrumentations/worker/instrumentFetch.js +1 -1
  196. package/build/esm/dev/instrumentations/worker/instrumentFetch.js.map +1 -1
  197. package/build/esm/dev/instrumentations/worker/instrumentQueue.js +7 -5
  198. package/build/esm/dev/instrumentations/worker/instrumentQueue.js.map +1 -1
  199. package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js +4 -3
  200. package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  201. package/build/esm/dev/instrumentations/worker/instrumentR2.js +22 -19
  202. package/build/esm/dev/instrumentations/worker/instrumentR2.js.map +1 -1
  203. package/build/esm/dev/instrumentations/worker/instrumentScheduled.js +7 -5
  204. package/build/esm/dev/instrumentations/worker/instrumentScheduled.js.map +1 -1
  205. package/build/esm/dev/instrumentations/worker/instrumentTail.js +2 -0
  206. package/build/esm/dev/instrumentations/worker/instrumentTail.js.map +1 -1
  207. package/build/esm/dev/integrations/fetch.js +2 -12
  208. package/build/esm/dev/integrations/fetch.js.map +1 -1
  209. package/build/esm/dev/opentelemetry/tracer.js +2 -40
  210. package/build/esm/dev/opentelemetry/tracer.js.map +1 -1
  211. package/build/esm/dev/package.json +1 -1
  212. package/build/esm/dev/pages-plugin.js +1 -1
  213. package/build/esm/dev/pages-plugin.js.map +1 -1
  214. package/build/esm/dev/request.js +2 -122
  215. package/build/esm/dev/request.js.map +1 -1
  216. package/build/esm/dev/sdk.js +11 -7
  217. package/build/esm/dev/sdk.js.map +1 -1
  218. package/build/esm/dev/transport.js +1 -1
  219. package/build/esm/dev/transport.js.map +1 -1
  220. package/build/esm/dev/utils/invocationContext.js +37 -0
  221. package/build/esm/dev/utils/invocationContext.js.map +1 -0
  222. package/build/esm/dev/utils/invocationScope.js +7 -2
  223. package/build/esm/dev/utils/invocationScope.js.map +1 -1
  224. package/build/esm/dev/utils/isBinding.js +1 -4
  225. package/build/esm/dev/utils/isBinding.js.map +1 -1
  226. package/build/esm/dev/utils/rpcPropagation.js +13 -0
  227. package/build/esm/dev/utils/rpcPropagation.js.map +1 -0
  228. package/build/esm/dev/utils/traceLinks.js +1 -1
  229. package/build/esm/dev/vendor/stacktrace.js +2 -1
  230. package/build/esm/dev/vendor/stacktrace.js.map +1 -1
  231. package/build/esm/dev/vite/autoInstrument.js +2 -1
  232. package/build/esm/dev/vite/autoInstrument.js.map +1 -1
  233. package/build/esm/dev/vite/index.js.map +1 -1
  234. package/build/esm/dev/vite/transform.js +30 -5
  235. package/build/esm/dev/vite/transform.js.map +1 -1
  236. package/build/esm/dev/vite/wranglerConfig.js +21 -2
  237. package/build/esm/dev/vite/wranglerConfig.js.map +1 -1
  238. package/build/esm/dev/withSentry.js.map +1 -1
  239. package/build/esm/dev/workflows.js +48 -36
  240. package/build/esm/dev/workflows.js.map +1 -1
  241. package/build/esm/dev/wrapMethodWithSentry.js +53 -17
  242. package/build/esm/dev/wrapMethodWithSentry.js.map +1 -1
  243. package/build/esm/dev/wrapRequestHandlerWithInit.js +132 -0
  244. package/build/esm/dev/wrapRequestHandlerWithInit.js.map +1 -0
  245. package/build/esm/prod/baseSdk.js +21 -9
  246. package/build/esm/prod/baseSdk.js.map +1 -1
  247. package/build/esm/prod/client.js +118 -25
  248. package/build/esm/prod/client.js.map +1 -1
  249. package/build/esm/prod/clientCache.js +12 -0
  250. package/build/esm/prod/clientCache.js.map +1 -0
  251. package/build/esm/prod/defineCloudflareOptions.js.map +1 -1
  252. package/build/esm/prod/durableobject.js +5 -63
  253. package/build/esm/prod/durableobject.js.map +1 -1
  254. package/build/esm/prod/flush.js +6 -4
  255. package/build/esm/prod/flush.js.map +1 -1
  256. package/build/esm/prod/index.js +4 -4
  257. package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js +4 -2
  258. package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  259. package/build/esm/prod/instrumentations/instrumentDurableObjectHandlers.js +121 -0
  260. package/build/esm/prod/instrumentations/instrumentDurableObjectHandlers.js.map +1 -0
  261. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js +4 -4
  262. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  263. package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js +3 -1
  264. package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  265. package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +3 -1
  266. package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  267. package/build/esm/prod/instrumentations/instrumentSqlStorage.js +5 -2
  268. package/build/esm/prod/instrumentations/instrumentSqlStorage.js.map +1 -1
  269. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js +9 -16
  270. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  271. package/build/esm/prod/instrumentations/worker/instrumentD1.js +11 -4
  272. package/build/esm/prod/instrumentations/worker/instrumentD1.js.map +1 -1
  273. package/build/esm/prod/instrumentations/worker/instrumentEmail.js +7 -5
  274. package/build/esm/prod/instrumentations/worker/instrumentEmail.js.map +1 -1
  275. package/build/esm/prod/instrumentations/worker/instrumentEnv.js +6 -13
  276. package/build/esm/prod/instrumentations/worker/instrumentEnv.js.map +1 -1
  277. package/build/esm/prod/instrumentations/worker/instrumentFetch.js +1 -1
  278. package/build/esm/prod/instrumentations/worker/instrumentFetch.js.map +1 -1
  279. package/build/esm/prod/instrumentations/worker/instrumentQueue.js +7 -5
  280. package/build/esm/prod/instrumentations/worker/instrumentQueue.js.map +1 -1
  281. package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js +4 -3
  282. package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  283. package/build/esm/prod/instrumentations/worker/instrumentR2.js +22 -19
  284. package/build/esm/prod/instrumentations/worker/instrumentR2.js.map +1 -1
  285. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js +7 -5
  286. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js.map +1 -1
  287. package/build/esm/prod/instrumentations/worker/instrumentTail.js +2 -0
  288. package/build/esm/prod/instrumentations/worker/instrumentTail.js.map +1 -1
  289. package/build/esm/prod/integrations/fetch.js +2 -12
  290. package/build/esm/prod/integrations/fetch.js.map +1 -1
  291. package/build/esm/prod/opentelemetry/tracer.js +2 -40
  292. package/build/esm/prod/opentelemetry/tracer.js.map +1 -1
  293. package/build/esm/prod/package.json +1 -1
  294. package/build/esm/prod/pages-plugin.js +1 -1
  295. package/build/esm/prod/pages-plugin.js.map +1 -1
  296. package/build/esm/prod/request.js +2 -122
  297. package/build/esm/prod/request.js.map +1 -1
  298. package/build/esm/prod/sdk.js +11 -7
  299. package/build/esm/prod/sdk.js.map +1 -1
  300. package/build/esm/prod/transport.js +1 -1
  301. package/build/esm/prod/transport.js.map +1 -1
  302. package/build/esm/prod/utils/invocationContext.js +37 -0
  303. package/build/esm/prod/utils/invocationContext.js.map +1 -0
  304. package/build/esm/prod/utils/invocationScope.js +7 -2
  305. package/build/esm/prod/utils/invocationScope.js.map +1 -1
  306. package/build/esm/prod/utils/isBinding.js +1 -4
  307. package/build/esm/prod/utils/isBinding.js.map +1 -1
  308. package/build/esm/prod/utils/rpcPropagation.js +13 -0
  309. package/build/esm/prod/utils/rpcPropagation.js.map +1 -0
  310. package/build/esm/prod/utils/traceLinks.js +1 -1
  311. package/build/esm/prod/vendor/stacktrace.js +2 -1
  312. package/build/esm/prod/vendor/stacktrace.js.map +1 -1
  313. package/build/esm/prod/vite/autoInstrument.js +2 -1
  314. package/build/esm/prod/vite/autoInstrument.js.map +1 -1
  315. package/build/esm/prod/vite/index.js.map +1 -1
  316. package/build/esm/prod/vite/transform.js +30 -5
  317. package/build/esm/prod/vite/transform.js.map +1 -1
  318. package/build/esm/prod/vite/wranglerConfig.js +21 -2
  319. package/build/esm/prod/vite/wranglerConfig.js.map +1 -1
  320. package/build/esm/prod/withSentry.js.map +1 -1
  321. package/build/esm/prod/workflows.js +48 -36
  322. package/build/esm/prod/workflows.js.map +1 -1
  323. package/build/esm/prod/wrapMethodWithSentry.js +53 -17
  324. package/build/esm/prod/wrapMethodWithSentry.js.map +1 -1
  325. package/build/esm/prod/wrapRequestHandlerWithInit.js +132 -0
  326. package/build/esm/prod/wrapRequestHandlerWithInit.js.map +1 -0
  327. package/build/types/baseSdk.d.ts +8 -0
  328. package/build/types/baseSdk.d.ts.map +1 -1
  329. package/build/types/client.d.ts +91 -18
  330. package/build/types/client.d.ts.map +1 -1
  331. package/build/types/clientCache.d.ts +8 -0
  332. package/build/types/clientCache.d.ts.map +1 -0
  333. package/build/types/defineCloudflareOptions.d.ts +3 -2
  334. package/build/types/defineCloudflareOptions.d.ts.map +1 -1
  335. package/build/types/durableobject.d.ts +5 -7
  336. package/build/types/durableobject.d.ts.map +1 -1
  337. package/build/types/flush.d.ts +2 -0
  338. package/build/types/flush.d.ts.map +1 -1
  339. package/build/types/index.d.ts +4 -4
  340. package/build/types/index.d.ts.map +1 -1
  341. package/build/types/instrumentations/agents/instrumentAgentCallableRpc.d.ts.map +1 -1
  342. package/build/types/instrumentations/instrumentDurableObjectHandlers.d.ts +28 -0
  343. package/build/types/instrumentations/instrumentDurableObjectHandlers.d.ts.map +1 -0
  344. package/build/types/instrumentations/instrumentDurableObjectNamespace.d.ts +2 -1
  345. package/build/types/instrumentations/instrumentDurableObjectNamespace.d.ts.map +1 -1
  346. package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts.map +1 -1
  347. package/build/types/instrumentations/instrumentDurableObjectSyncKvStorage.d.ts.map +1 -1
  348. package/build/types/instrumentations/instrumentSqlStorage.d.ts.map +1 -1
  349. package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts +2 -3
  350. package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts.map +1 -1
  351. package/build/types/instrumentations/worker/instrumentD1.d.ts.map +1 -1
  352. package/build/types/instrumentations/worker/instrumentEmail.d.ts.map +1 -1
  353. package/build/types/instrumentations/worker/instrumentEnv.d.ts +0 -1
  354. package/build/types/instrumentations/worker/instrumentEnv.d.ts.map +1 -1
  355. package/build/types/instrumentations/worker/instrumentQueue.d.ts.map +1 -1
  356. package/build/types/instrumentations/worker/instrumentQueueProducer.d.ts.map +1 -1
  357. package/build/types/instrumentations/worker/instrumentR2.d.ts.map +1 -1
  358. package/build/types/instrumentations/worker/instrumentScheduled.d.ts.map +1 -1
  359. package/build/types/instrumentations/worker/instrumentTail.d.ts.map +1 -1
  360. package/build/types/integrations/fetch.d.ts.map +1 -1
  361. package/build/types/opentelemetry/tracer.d.ts.map +1 -1
  362. package/build/types/pages-plugin.d.ts +3 -1
  363. package/build/types/pages-plugin.d.ts.map +1 -1
  364. package/build/types/request.d.ts +5 -31
  365. package/build/types/request.d.ts.map +1 -1
  366. package/build/types/sdk.d.ts +13 -4
  367. package/build/types/sdk.d.ts.map +1 -1
  368. package/build/types/transport.d.ts.map +1 -1
  369. package/build/types/types.d.ts +28 -0
  370. package/build/types/types.d.ts.map +1 -1
  371. package/build/types/utils/invocationContext.d.ts +58 -0
  372. package/build/types/utils/invocationContext.d.ts.map +1 -0
  373. package/build/types/utils/invocationScope.d.ts +2 -1
  374. package/build/types/utils/invocationScope.d.ts.map +1 -1
  375. package/build/types/utils/isBinding.d.ts +1 -9
  376. package/build/types/utils/isBinding.d.ts.map +1 -1
  377. package/build/types/utils/rpcPropagation.d.ts +10 -0
  378. package/build/types/utils/rpcPropagation.d.ts.map +1 -0
  379. package/build/types/vendor/stacktrace.d.ts.map +1 -1
  380. package/build/types/vite/autoInstrument.d.ts.map +1 -1
  381. package/build/types/vite/index.d.ts +4 -0
  382. package/build/types/vite/index.d.ts.map +1 -1
  383. package/build/types/vite/transform.d.ts +3 -0
  384. package/build/types/vite/transform.d.ts.map +1 -1
  385. package/build/types/vite/wranglerConfig.d.ts +13 -0
  386. package/build/types/vite/wranglerConfig.d.ts.map +1 -1
  387. package/build/types/withSentry.d.ts +2 -3
  388. package/build/types/withSentry.d.ts.map +1 -1
  389. package/build/types/workflows.d.ts +3 -3
  390. package/build/types/workflows.d.ts.map +1 -1
  391. package/build/types/wrapMethodWithSentry.d.ts +6 -1
  392. package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
  393. package/build/types/wrapRequestHandlerWithInit.d.ts +31 -0
  394. package/build/types/wrapRequestHandlerWithInit.d.ts.map +1 -0
  395. package/package.json +6 -4
  396. package/build/cjs/dev/instrumentations/worker/instrumentRateLimit.js +0 -29
  397. package/build/cjs/dev/instrumentations/worker/instrumentRateLimit.js.map +0 -1
  398. package/build/cjs/dev/integrations/tracing/vercelai.js +0 -18
  399. package/build/cjs/dev/integrations/tracing/vercelai.js.map +0 -1
  400. package/build/cjs/prod/instrumentations/worker/instrumentRateLimit.js +0 -29
  401. package/build/cjs/prod/instrumentations/worker/instrumentRateLimit.js.map +0 -1
  402. package/build/cjs/prod/integrations/tracing/vercelai.js +0 -18
  403. package/build/cjs/prod/integrations/tracing/vercelai.js.map +0 -1
  404. package/build/esm/dev/instrumentations/worker/instrumentRateLimit.js +0 -27
  405. package/build/esm/dev/instrumentations/worker/instrumentRateLimit.js.map +0 -1
  406. package/build/esm/dev/integrations/tracing/vercelai.js +0 -16
  407. package/build/esm/dev/integrations/tracing/vercelai.js.map +0 -1
  408. package/build/esm/prod/instrumentations/worker/instrumentRateLimit.js +0 -27
  409. package/build/esm/prod/instrumentations/worker/instrumentRateLimit.js.map +0 -1
  410. package/build/esm/prod/integrations/tracing/vercelai.js +0 -16
  411. package/build/esm/prod/integrations/tracing/vercelai.js.map +0 -1
  412. package/build/types/instrumentations/worker/instrumentRateLimit.d.ts +0 -6
  413. package/build/types/instrumentations/worker/instrumentRateLimit.d.ts.map +0 -1
  414. package/build/types/integrations/tracing/vercelai.d.ts +0 -39
  415. package/build/types/integrations/tracing/vercelai.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.js","sources":["../../../../src/integrations/fetch.ts"],"sourcesContent":["import type {\n Client,\n FetchBreadcrumbData,\n FetchBreadcrumbHint,\n HandlerDataFetch,\n IntegrationFn,\n Span,\n} from '@sentry/core';\nimport {\n addBreadcrumb,\n addFetchInstrumentationHandler,\n defineIntegration,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n instrumentFetchRequest,\n isSentryRequestUrl,\n LRUMap,\n stringMatchesSomePattern,\n} from '@sentry/core';\n\nconst INTEGRATION_NAME = 'Fetch' as const;\n\nconst HAS_CLIENT_MAP = new WeakMap<Client, boolean>();\n\nexport interface Options {\n /**\n * Whether breadcrumbs should be recorded for requests\n * Defaults to true\n */\n breadcrumbs: boolean;\n\n /**\n * Function determining whether or not to create spans to track outgoing requests to the given URL.\n * By default, spans will be created for all outgoing requests.\n */\n shouldCreateSpanForRequest?: (url: string) => boolean;\n}\n\nconst _fetchIntegration = ((options: Partial<Options> = {}) => {\n const breadcrumbs = options.breadcrumbs === undefined ? true : options.breadcrumbs;\n const shouldCreateSpanForRequest = options.shouldCreateSpanForRequest;\n\n const _createSpanUrlMap = new LRUMap<string, boolean>(100);\n const _headersUrlMap = new LRUMap<string, boolean>(100);\n\n const spans: Record<string, Span> = {};\n\n /** Decides whether to attach trace data to the outgoing fetch request */\n function _shouldAttachTraceData(url: string): boolean {\n const client = getClient();\n\n if (!client) {\n return false;\n }\n\n const clientOptions = client.getOptions();\n\n if (clientOptions.tracePropagationTargets === undefined) {\n return true;\n }\n\n const cachedDecision = _headersUrlMap.get(url);\n if (cachedDecision !== undefined) {\n return cachedDecision;\n }\n\n const decision = stringMatchesSomePattern(url, clientOptions.tracePropagationTargets);\n _headersUrlMap.set(url, decision);\n return decision;\n }\n\n /** Helper that wraps shouldCreateSpanForRequest option */\n function _shouldCreateSpan(url: string): boolean {\n if (shouldCreateSpanForRequest === undefined) {\n return true;\n }\n\n const cachedDecision = _createSpanUrlMap.get(url);\n if (cachedDecision !== undefined) {\n return cachedDecision;\n }\n\n const decision = shouldCreateSpanForRequest(url);\n _createSpanUrlMap.set(url, decision);\n return decision;\n }\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n addFetchInstrumentationHandler(handlerData => {\n const client = getClient();\n const { propagateTraceparent } = client?.getOptions() || {};\n if (!client || !HAS_CLIENT_MAP.get(client)) {\n return;\n }\n\n if (isSentryRequestUrl(handlerData.fetchData.url, client)) {\n return;\n }\n\n instrumentFetchRequest(handlerData, _shouldCreateSpan, _shouldAttachTraceData, spans, {\n spanOrigin: 'auto.http.fetch',\n propagateTraceparent,\n });\n\n if (breadcrumbs) {\n createBreadcrumb(handlerData);\n }\n });\n },\n setup(client) {\n HAS_CLIENT_MAP.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Creates spans and attaches tracing headers to fetch requests.\n */\nexport const fetchIntegration = defineIntegration(_fetchIntegration);\n\nfunction createBreadcrumb(handlerData: HandlerDataFetch): void {\n const { startTimestamp, endTimestamp } = handlerData;\n\n // We only capture complete fetch requests\n if (!endTimestamp) {\n return;\n }\n\n const breadcrumbData: FetchBreadcrumbData = {\n method: handlerData.fetchData.method,\n url: handlerData.fetchData.url,\n };\n\n if (handlerData.error) {\n const hint: FetchBreadcrumbHint = {\n data: handlerData.error,\n input: handlerData.args,\n startTimestamp,\n endTimestamp,\n };\n\n addBreadcrumb(\n {\n category: 'fetch',\n data: breadcrumbData,\n level: 'error',\n type: 'http',\n },\n hint,\n );\n } else {\n const response = handlerData.response as Response | undefined;\n\n breadcrumbData.request_body_size = handlerData.fetchData.request_body_size;\n breadcrumbData.response_body_size = handlerData.fetchData.response_body_size;\n breadcrumbData.status_code = response?.status;\n\n const hint: FetchBreadcrumbHint = {\n input: handlerData.args,\n response,\n startTimestamp,\n endTimestamp,\n };\n const level = getBreadcrumbLogLevelFromHttpStatusCode(breadcrumbData.status_code);\n\n addBreadcrumb(\n {\n category: 'fetch',\n data: breadcrumbData,\n type: 'http',\n level,\n },\n hint,\n );\n }\n}\n"],"names":[],"mappings":";;AAoBA,MAAM,gBAAA,GAAmB,OAAA;AAEzB,MAAM,cAAA,uBAAqB,OAAA,EAAyB;AAgBpD,MAAM,iBAAA,IAAqB,CAAC,OAAA,GAA4B,EAAC,KAAM;AAC7D,EAAA,MAAM,WAAA,GAAc,OAAA,CAAQ,WAAA,KAAgB,MAAA,GAAY,OAAO,OAAA,CAAQ,WAAA;AACvE,EAAA,MAAM,6BAA6B,OAAA,CAAQ,0BAAA;AAE3C,EAAA,MAAM,iBAAA,GAAoB,IAAI,MAAA,CAAwB,GAAG,CAAA;AACzD,EAAA,MAAM,cAAA,GAAiB,IAAI,MAAA,CAAwB,GAAG,CAAA;AAEtD,EAAA,MAAM,QAA8B,EAAC;AAGrC,EAAA,SAAS,uBAAuB,GAAA,EAAsB;AACpD,IAAA,MAAM,SAAS,SAAA,EAAU;AAEzB,IAAA,IAAI,CAAC,MAAA,EAAQ;AACX,MAAA,OAAO,KAAA;AAAA,IACT;AAEA,IAAA,MAAM,aAAA,GAAg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U,iBAAA;AACzD,IAAA,cAAA,CAAe,kBAAA,GAAqB,YAAY,SAAA,CAAU,kBAAA;AAC1D,IAAA,cAAA,CAAe,cAAc,QAAA,EAAU,MAAA;AAEvC,IAAA,MAAM,IAAA,GAA4B;AAAA,MAChC,OAAO,WAAA,CAAY,IAAA;AAAA,MACnB,QAAA;AAAA,MACA,cAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA,MAAM,KAAA,GAAQ,uCAAA,CAAwC,cAAA,CAAe,WAAW,CAAA;AAEhF,IAAA,aAAA;AAAA,MACE;AAAA,QACE,QAAA,EAAU,OAAA;AAAA,QACV,IAAA,EAAM,cAAA;AAAA,QACN,IAAA,EAAM,MAAA;AAAA,QACN;AAAA,OACF;AAAA,MACA;AAAA,KACF;AAAA,EACF;AACF;;;;"}
1
+ {"version":3,"file":"fetch.js","sources":["../../../../src/integrations/fetch.ts"],"sourcesContent":["import type {\n Client,\n FetchBreadcrumbData,\n FetchBreadcrumbHint,\n HandlerDataFetch,\n IntegrationFn,\n Span,\n} from '@sentry/core';\nimport {\n addBreadcrumb,\n addFetchInstrumentationHandler,\n defineIntegration,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n instrumentFetchRequest,\n isSentryRequestUrl,\n LRUMap,\n shouldPropagateTraceForUrl,\n} from '@sentry/core';\n\nconst INTEGRATION_NAME = 'Fetch' as const;\n\nconst HAS_CLIENT_MAP = new WeakMap<Client, boolean>();\n\nexport interface Options {\n /**\n * Whether breadcrumbs should be recorded for requests\n * Defaults to true\n */\n breadcrumbs: boolean;\n\n /**\n * Function determining whether or not to create spans to track outgoing requests to the given URL.\n * By default, spans will be created for all outgoing requests.\n */\n shouldCreateSpanForRequest?: (url: string) => boolean;\n}\n\nconst _fetchIntegration = ((options: Partial<Options> = {}) => {\n const breadcrumbs = options.breadcrumbs === undefined ? true : options.breadcrumbs;\n const shouldCreateSpanForRequest = options.shouldCreateSpanForRequest;\n\n const _createSpanUrlMap = new LRUMap<string, boolean>(100);\n const _headersUrlMap = new LRUMap<string, boolean>(100);\n\n const spans: Record<string, Span> = {};\n\n /** Decides whether to attach trace data to the outgoing fetch request */\n function _shouldAttachTraceData(url: string): boolean {\n const client = getClient();\n\n if (!client) {\n return false;\n }\n\n return shouldPropagateTraceForUrl(url, client.getOptions().tracePropagationTargets, _headersUrlMap);\n }\n\n /** Helper that wraps shouldCreateSpanForRequest option */\n function _shouldCreateSpan(url: string): boolean {\n if (shouldCreateSpanForRequest === undefined) {\n return true;\n }\n\n const cachedDecision = _createSpanUrlMap.get(url);\n if (cachedDecision !== undefined) {\n return cachedDecision;\n }\n\n const decision = shouldCreateSpanForRequest(url);\n _createSpanUrlMap.set(url, decision);\n return decision;\n }\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n addFetchInstrumentationHandler(handlerData => {\n const client = getClient();\n const { propagateTraceparent } = client?.getOptions() || {};\n if (!client || !HAS_CLIENT_MAP.get(client)) {\n return;\n }\n\n if (isSentryRequestUrl(handlerData.fetchData.url, client)) {\n return;\n }\n\n instrumentFetchRequest(handlerData, _shouldCreateSpan, _shouldAttachTraceData, spans, {\n spanOrigin: 'auto.http.fetch',\n propagateTraceparent,\n });\n\n if (breadcrumbs) {\n createBreadcrumb(handlerData);\n }\n });\n },\n setup(client) {\n HAS_CLIENT_MAP.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Creates spans and attaches tracing headers to fetch requests.\n */\nexport const fetchIntegration = defineIntegration(_fetchIntegration);\n\nfunction createBreadcrumb(handlerData: HandlerDataFetch): void {\n const { startTimestamp, endTimestamp } = handlerData;\n\n // We only capture complete fetch requests\n if (!endTimestamp) {\n return;\n }\n\n const breadcrumbData: FetchBreadcrumbData = {\n method: handlerData.fetchData.method,\n url: handlerData.fetchData.url,\n };\n\n if (handlerData.error) {\n const hint: FetchBreadcrumbHint = {\n data: handlerData.error,\n input: handlerData.args,\n startTimestamp,\n endTimestamp,\n };\n\n addBreadcrumb(\n {\n category: 'fetch',\n data: breadcrumbData,\n level: 'error',\n type: 'http',\n },\n hint,\n );\n } else {\n const response = handlerData.response as Response | undefined;\n\n breadcrumbData.request_body_size = handlerData.fetchData.request_body_size;\n breadcrumbData.response_body_size = handlerData.fetchData.response_body_size;\n breadcrumbData.status_code = response?.status;\n\n const hint: FetchBreadcrumbHint = {\n input: handlerData.args,\n response,\n startTimestamp,\n endTimestamp,\n };\n const level = getBreadcrumbLogLevelFromHttpStatusCode(breadcrumbData.status_code);\n\n addBreadcrumb(\n {\n category: 'fetch',\n data: breadcrumbData,\n type: 'http',\n level,\n },\n hint,\n );\n }\n}\n"],"names":[],"mappings":";;AAoBA,MAAM,gBAAA,GAAmB,OAAA;AAEzB,MAAM,cAAA,uBAAqB,OAAA,EAAyB;AAgBpD,MAAM,iBAAA,IAAqB,CAAC,OAAA,GAA4B,EAAC,KAAM;AAC7D,EAAA,MAAM,WAAA,GAAc,OAAA,CAAQ,WAAA,KAAgB,MAAA,GAAY,OAAO,OAAA,CAAQ,WAAA;AACvE,EAAA,MAAM,6BAA6B,OAAA,CAAQ,0BAAA;AAE3C,EAAA,MAAM,iBAAA,GAAoB,IAAI,MAAA,CAAwB,GAAG,CAAA;AACzD,EAAA,MAAM,cAAA,GAAiB,IAAI,MAAA,CAAwB,GAAG,CAAA;AAEtD,EAAA,MAAM,QAA8B,EAAC;AAGrC,EAAA,SAAS,uBAAuB,GAAA,EAAsB;AACpD,IAAA,MAAM,SAAS,SAAA,EAAU;AAEzB,IAAA,IAAI,CAAC,MAAA,EAAQ;AACX,MAAA,OAAO,KAAA;AAAA,IACT;AAEA,IAAA,OAAO,2BAA2B,GAAA,EAAK,MAAA,CAAO,UAAA,EAAW,CAAE,yBAAyB,cAAc,CAAA;AAAA,EACpG;AAGA,EAAA,SAAS,kBAAkB,GAAA,EAAsB;AAC/C,IAAA,IAAI,+BAA+B,MAAA,EAAW;AAC5C,MAAA,OAAO,IAAA;AAAA,IACT;AAEA,IAAA,MAAM,cAAA,GAAiB,iB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} from '@sentry/core';
2
+ import { SentryTracerProvider } from '@sentry/opentelemetry';
3
3
 
4
4
  function setupOpenTelemetryTracer() {
5
- trace.setGlobalTracerProvider(new SentryCloudflareTraceProvider());
6
- }
7
- class SentryCloudflareTraceProvider {
8
- constructor() {
9
- this._tracers = /* @__PURE__ */ new Map();
10
- }
11
- getTracer(name, version, options) {
12
- const key = `${name}@${version || ""}:${options?.schemaUrl || ""}`;
13
- if (!this._tracers.has(key)) {
14
- this._tracers.set(key, new SentryCloudflareTracer());
15
- }
16
- return this._tracers.get(key);
17
- }
18
- }
19
- class SentryCloudflareTracer {
20
- startSpan(name, options) {
21
- return startInactiveSpan({
22
- ...options,
23
- name,
24
- attributes: {
25
- ...options?.attributes,
26
- "sentry.cloudflare_tracer": true
27
- }
28
- });
29
- }
30
- startActiveSpan(name, options, context, fn) {
31
- const opts = typeof options === "object" && options !== null ? options : {};
32
- const spanOpts = {
33
- ...opts,
34
- name,
35
- attributes: {
36
- ...opts.attributes,
37
- "sentry.cloudflare_tracer": true
38
- }
39
- };
40
- const callback = typeof options === "function" ? options : typeof context === "function" ? context : typeof fn === "function" ? fn : () => {
41
- };
42
- return startSpanManual(spanOpts, callback);
43
- }
5
+ trace.setGlobalTracerProvider(new SentryTracerProvider());
44
6
  }
45
7
 
46
8
  export { setupOpenTelemetryTracer };
@@ -1 +1 @@
1
- {"version":3,"file":"tracer.js","sources":["../../../../src/opentelemetry/tracer.ts"],"sourcesContent":["import type { Context, Span, SpanOptions, Tracer, TracerProvider } from '@opentelemetry/api';\nimport { trace } from '@opentelemetry/api';\nimport { startInactiveSpan, startSpanManual } from '@sentry/core';\n\n/**\n * Set up a mock OTEL tracer to allow inter-op with OpenTelemetry emitted spans.\n * This is not perfect but handles easy/common use cases.\n */\nexport function setupOpenTelemetryTracer(): void {\n trace.setGlobalTracerProvider(new SentryCloudflareTraceProvider());\n}\n\nclass SentryCloudflareTraceProvider implements TracerProvider {\n private readonly _tracers: Map<string, Tracer> = new Map();\n\n public getTracer(name: string, version?: string, options?: { schemaUrl?: string }): Tracer {\n const key = `${name}@${version || ''}:${options?.schemaUrl || ''}`;\n if (!this._tracers.has(key)) {\n this._tracers.set(key, new SentryCloudflareTracer());\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this._tracers.get(key)!;\n }\n}\n\nclass SentryCloudflareTracer implements Tracer {\n public startSpan(name: string, options?: SpanOptions): Span {\n return startInactiveSpan({\n ...options,\n name,\n attributes: {\n ...options?.attributes,\n 'sentry.cloudflare_tracer': true,\n },\n });\n }\n\n /**\n * NOTE: This does not handle `context` being passed in. It will always put spans on the current scope.\n */\n public startActiveSpan<F extends (span: Span) => unknown>(name: string, fn: F): ReturnType<F>;\n public startActiveSpan<F extends (span: Span) => unknown>(name: string, options: SpanOptions, fn: F): ReturnType<F>;\n public startActiveSpan<F extends (span: Span) => unknown>(\n name: string,\n options: SpanOptions,\n context: Context,\n fn: F,\n ): ReturnType<F>;\n public startActiveSpan<F extends (span: Span) => unknown>(\n name: string,\n options: unknown,\n context?: unknown,\n fn?: F,\n ): ReturnType<F> {\n const opts = (typeof options === 'object' && options !== null ? options : {}) as SpanOptions;\n\n const spanOpts = {\n ...opts,\n name,\n attributes: {\n ...opts.attributes,\n 'sentry.cloudflare_tracer': true,\n },\n };\n\n const callback = (\n typeof options === 'function'\n ? options\n : typeof context === 'function'\n ? context\n : typeof fn === 'function'\n ? fn\n : () => {}\n ) as F;\n\n // In OTEL the semantic matches `startSpanManual` because spans are not auto-ended\n return startSpanManual(spanOpts, callback) as ReturnType<F>;\n }\n}\n"],"names":[],"mappings":";;;AAQO,SAAS,wBAAA,GAAiC;AAC/C,EAAA,KAAA,CAAM,uBAAA,CAAwB,IAAI,6BAAA,EAA+B,CAAA;AACnE;AAEA,MAAM,6BAAA,CAAwD;AAAA,EAA9D,WAAA,GAAA;AACE,IAAA,IAAA,CAAiB,QAAA,uBAAoC,GAAA,EAAI;AAAA,EAAA;AAAA,EAElD,SAAA,CAA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AAA;AAAA,EAC3C;AACF;;;;"}
1
+ {"version":3,"file":"tracer.js","sources":["../../../../src/opentelemetry/tracer.ts"],"sourcesContent":["import { trace } from '@opentelemetry/api';\nimport { SentryTracerProvider } from '@sentry/opentelemetry';\n\n/**\n * Set up a mock OTEL tracer to allow inter-op with OpenTelemetry emitted spans.\n * This is not perfect but handles easy/common use cases.\n */\nexport function setupOpenTelemetryTracer(): void {\n trace.setGlobalTracerProvider(new SentryTracerProvider());\n}\n"],"names":[],"mappings":";;;AAOO,SAAS,wBAAA,GAAiC;AAC/C,EAAA,KAAA,CAAM,uBAAA,CAAwB,IAAI,oBAAA,EAAsB,CAAA;AAC1D;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"11.0.0-alpha.1","sideEffects":false}
1
+ {"type":"module","version":"11.0.0-beta.0","sideEffects":false}
@@ -1,5 +1,5 @@
1
1
  import { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';
2
- import { wrapRequestHandlerWithInit } from './request.js';
2
+ import { wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit.js';
3
3
  import { init } from './sdk.js';
4
4
 
5
5
  function sentryPagesPlugin(handlerOrOptions) {
@@ -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 './request';\nimport { init } from './sdk';\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 */\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":";;;;AAqCO,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","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,129 +1,9 @@
1
- import { parseStringToURLObject, getHttpSpanDetailsFromUrlObject, httpHeadersToSpanAttributes, winterCGHeadersToDict, SEMANTIC_ATTRIBUTE_SENTRY_OP, captureException, continueTrace, startSpanManual, setHttpStatus } from '@sentry/core';
2
- import { captureIncomingRequestBody } from './integrations/httpServer.js';
3
1
  import { initBaseSdk } from './baseSdk.js';
4
- import { getOriginalWaitUntil, flushAndDispose } from './flush.js';
5
- import { addCloudResourceContext, addRequest, addCultureContext } from './scope-utils.js';
6
- import { withInvocationIsolationScope } from './utils/invocationScope.js';
7
- import { classifyResponseStreaming } from './utils/streaming.js';
2
+ import { wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit.js';
8
3
 
9
- function getRequestErrorMechanismType(context) {
10
- return context && "storage" in context ? "auto.faas.cloudflare.durable_object" : "auto.http.cloudflare";
11
- }
12
4
  function wrapRequestHandler(wrapperOptions, handler) {
13
5
  return wrapRequestHandlerWithInit(wrapperOptions, handler, initBaseSdk);
14
6
  }
15
- function wrapRequestHandlerWithInit(wrapperOptions, handler, initSdk) {
16
- return withInvocationIsolationScope(async (isolationScope) => {
17
- const { options, request, captureErrors = true } = wrapperOptions;
18
- const context = wrapperOptions.context;
19
- const waitUntil = context ? getOriginalWaitUntil(context).bind(context) : void 0;
20
- const errorMechanismType = getRequestErrorMechanismType(context);
21
- const client = initSdk({ ...options, ctx: context });
22
- isolationScope.setClient(client);
23
- const urlObject = parseStringToURLObject(request.url);
24
- const [name, attributes] = getHttpSpanDetailsFromUrlObject(
25
- urlObject,
26
- "server",
27
- "auto.http.cloudflare",
28
- request,
29
- void 0,
30
- client
31
- );
32
- const contentLength = request.headers.get("content-length");
33
- if (contentLength) {
34
- attributes["http.request.body.size"] = parseInt(contentLength, 10);
35
- }
36
- const userAgentHeader = request.headers.get("user-agent");
37
- if (userAgentHeader) {
38
- attributes["user_agent.original"] = userAgentHeader;
39
- }
40
- if (client) {
41
- Object.assign(
42
- attributes,
43
- httpHeadersToSpanAttributes(winterCGHeadersToDict(request.headers), client.getDataCollectionOptions())
44
- );
45
- }
46
- attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] = "http.server";
47
- addCloudResourceContext(isolationScope);
48
- addRequest(isolationScope, request);
49
- if (request.cf) {
50
- addCultureContext(isolationScope, request.cf);
51
- if (typeof request.cf.httpProtocol === "string") {
52
- attributes["network.protocol.name"] = request.cf.httpProtocol;
53
- }
54
- }
55
- if (request.method === "OPTIONS" || request.method === "HEAD") {
56
- try {
57
- return await handler();
58
- } catch (e) {
59
- if (captureErrors) {
60
- captureException(e, { mechanism: { handled: false, type: errorMechanismType } });
61
- }
62
- throw e;
63
- } finally {
64
- waitUntil?.(flushAndDispose(client));
65
- }
66
- }
67
- if (client) {
68
- await captureIncomingRequestBody(client, request);
69
- }
70
- return continueTrace(
71
- { sentryTrace: request.headers.get("sentry-trace") || "", baggage: request.headers.get("baggage") },
72
- () => {
73
- return startSpanManual({ name, attributes }, async (span) => {
74
- let res;
75
- try {
76
- res = await handler();
77
- setHttpStatus(span, res.status);
78
- } catch (e) {
79
- span.end();
80
- if (captureErrors) {
81
- captureException(e, { mechanism: { handled: false, type: errorMechanismType } });
82
- }
83
- waitUntil?.(flushAndDispose(client));
84
- throw e;
85
- }
86
- const classification = classifyResponseStreaming(res);
87
- if (classification.isStreaming && res.body) {
88
- try {
89
- let ended = false;
90
- const endSpanOnce = () => {
91
- if (ended) return;
92
- ended = true;
93
- span.end();
94
- waitUntil?.(flushAndDispose(client));
95
- };
96
- const transform = new TransformStream({
97
- flush() {
98
- endSpanOnce();
99
- },
100
- cancel() {
101
- endSpanOnce();
102
- }
103
- });
104
- return new Response(res.body.pipeThrough(transform), {
105
- status: res.status,
106
- statusText: res.statusText,
107
- headers: res.headers
108
- });
109
- } catch {
110
- span.end();
111
- waitUntil?.(flushAndDispose(client));
112
- return res;
113
- }
114
- }
115
- span.end();
116
- if (res.status === 101) {
117
- waitUntil?.(client?.flush(2e3));
118
- } else {
119
- waitUntil?.(flushAndDispose(client));
120
- }
121
- return res;
122
- });
123
- }
124
- );
125
- });
126
- }
127
7
 
128
- export { wrapRequestHandler, wrapRequestHandlerWithInit };
8
+ export { wrapRequestHandler };
129
9
  //# sourceMappingURL=request.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sources":["../../../src/request.ts"],"sourcesContent":["import type { CfProperties, IncomingRequestCfProperties } from '@cloudflare/workers-types';\nimport {\n captureException,\n continueTrace,\n getHttpSpanDetailsFromUrlObject,\n httpHeadersToSpanAttributes,\n parseStringToURLObject,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n setHttpStatus,\n startSpanManual,\n winterCGHeadersToDict,\n} from '@sentry/core';\nimport { captureIncomingRequestBody } from './integrations/httpServer';\nimport { initBaseSdk } from './baseSdk';\nimport type { CloudflareClient, CloudflareOptions } from './client';\nimport type { ExecutionContextCompat } from './executionContext';\nimport { flushAndDispose, getOriginalWaitUntil } from './flush';\nimport { addCloudResourceContext, addCultureContext, addRequest } from './scope-utils';\nimport { withInvocationIsolationScope } from './utils/invocationScope';\nimport { classifyResponseStreaming } from './utils/streaming';\n\nfunction getRequestErrorMechanismType(context: ExecutionContextCompat | undefined): string {\n // Durable Object fetch handlers use DO state as context (see instrumentDurableObjectWithSentry)\n return context && 'storage' in context ? 'auto.faas.cloudflare.durable_object' : 'auto.http.cloudflare';\n}\n\ninterface RequestHandlerWrapperOptions {\n options: CloudflareOptions;\n request: Request<unknown, IncomingRequestCfProperties<unknown> | CfProperties<unknown>>;\n context: ExecutionContextCompat | undefined;\n /**\n * If true, errors will be captured, rethrown and sent to Sentry.\n * Otherwise, errors are rethrown but not captured.\n *\n * You most likely don't want to set this to `false`, if you use `wrapRequestHandler` directly.\n * This is primarily meant as an escape hatch for higher-level SDKs relying on additional error\n * capturing mechanisms where this wrapper captures errors too early or too generally.\n *\n * @default true\n */\n captureErrors?: boolean;\n}\n\ntype InitSdk = (options: CloudflareOptions) => CloudflareClient | undefined;\n\n/**\n * Wraps a cloudflare request handler in Sentry instrumentation.\n *\n * The client is set up with the default integrations that work without the `nodejs_compat`\n * compatibility flag, so that this also works on runtimes that cannot enable it (e.g. Shopify\n * Oxygen). On a runtime that has `nodejs_compat`, pass `defaultIntegrations:\n * getDefaultIntegrations(options)` in `options` to get the full set instead.\n */\nexport function wrapRequestHandler(\n wrapperOptions: RequestHandlerWrapperOptions,\n handler: (...args: unknown[]) => Response | Promise<Response>,\n): Promise<Response> {\n return wrapRequestHandlerWithInit(wrapperOptions, handler, initBaseSdk);\n}\n\n/**\n * Same as {@link wrapRequestHandler}, but with the SDK initialization injected.\n *\n * Wrappers that are only reachable from the main entry point — where `nodejs_compat` is a\n * requirement anyway — pass `init` from `sdk.ts` to get the full default integrations.\n *\n * @internal\n */\nexport function wrapRequestHandlerWithInit(\n wrapperOptions: RequestHandlerWrapperOptions,\n handler: (...args: unknown[]) => Response | Promise<Response>,\n initSdk: InitSdk,\n): Promise<Response> {\n return withInvocationIsolationScope(async isolationScope => {\n const { options, request, captureErrors = true } = wrapperOptions;\n const context = wrapperOptions.context;\n\n // Use getOriginalWaitUntil to get the un-instrumented waitUntil function.\n // This is crucial to avoid deadlock: the flush lock mechanism wraps waitUntil\n // to track pending tasks. If we use the instrumented version for flushAndDispose,\n // it acquires the lock, then flushAndDispose tries to wait for the same lock,\n // creating a deadlock.\n const waitUntil = context ? getOriginalWaitUntil(context).bind(context) : undefined;\n const errorMechanismType = getRequestErrorMechanismType(context);\n\n const client = initSdk({ ...options, ctx: context });\n isolationScope.setClient(client);\n\n const urlObject = parseStringToURLObject(request.url);\n const [name, attributes] = getHttpSpanDetailsFromUrlObject(\n urlObject,\n 'server',\n 'auto.http.cloudflare',\n request,\n undefined,\n client,\n );\n\n const contentLength = request.headers.get('content-length');\n if (contentLength) {\n attributes['http.request.body.size'] = parseInt(contentLength, 10);\n }\n\n const userAgentHeader = request.headers.get('user-agent');\n if (userAgentHeader) {\n attributes['user_agent.original'] = userAgentHeader;\n }\n\n if (client) {\n Object.assign(\n attributes,\n httpHeadersToSpanAttributes(winterCGHeadersToDict(request.headers), client.getDataCollectionOptions()),\n );\n }\n\n attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] = 'http.server';\n\n addCloudResourceContext(isolationScope);\n addRequest(isolationScope, request);\n if (request.cf) {\n addCultureContext(isolationScope, request.cf);\n\n if (typeof request.cf.httpProtocol === 'string') {\n attributes['network.protocol.name'] = request.cf.httpProtocol;\n }\n }\n\n // Do not capture spans for OPTIONS and HEAD requests\n if (request.method === 'OPTIONS' || request.method === 'HEAD') {\n try {\n return await handler();\n } catch (e) {\n if (captureErrors) {\n captureException(e, { mechanism: { handled: false, type: errorMechanismType } });\n }\n throw e;\n } finally {\n waitUntil?.(flushAndDispose(client));\n }\n }\n\n if (client) {\n await captureIncomingRequestBody(client, request);\n }\n\n return continueTrace(\n { sentryTrace: request.headers.get('sentry-trace') || '', baggage: request.headers.get('baggage') },\n () => {\n // Note: This span will not have a duration unless I/O happens in the handler. This is\n // because of how the cloudflare workers runtime works.\n // See: https://developers.cloudflare.com/workers/runtime-apis/performance/\n\n // Use startSpanManual to control when span ends (needed for streaming responses)\n return startSpanManual({ name, attributes }, async span => {\n let res: Response;\n\n try {\n res = await handler();\n setHttpStatus(span, res.status);\n\n // After the handler runs, the span name might have been updated by nested instrumentation\n // (e.g., Remix parameterizing routes). The span should already have the correct name\n // from that instrumentation, so we don't need to do anything here.\n } catch (e) {\n span.end();\n if (captureErrors) {\n captureException(e, { mechanism: { handled: false, type: errorMechanismType } });\n }\n waitUntil?.(flushAndDispose(client));\n throw e;\n }\n\n // Classify response to detect actual streaming\n const classification = classifyResponseStreaming(res);\n\n if (classification.isStreaming && res.body) {\n try {\n let ended = false;\n\n const endSpanOnce = (): void => {\n if (ended) return;\n\n ended = true;\n span.end();\n waitUntil?.(flushAndDispose(client));\n };\n\n const transform = new TransformStream({\n flush() {\n // Source stream completed normally.\n endSpanOnce();\n },\n cancel() {\n // Client disconnected (or downstream cancelled). The `cancel`\n // is being called while the response is still considered\n // active, so this is a safe place to end the span.\n endSpanOnce();\n },\n });\n\n return new Response(res.body.pipeThrough(transform), {\n status: res.status,\n statusText: res.statusText,\n headers: res.headers,\n });\n } catch {\n span.end();\n waitUntil?.(flushAndDispose(client));\n return res;\n }\n }\n\n // Non-streaming response - end span immediately and return original\n span.end();\n\n // Don't dispose for protocol upgrades (101 Switching Protocols) - the connection stays alive.\n // This includes WebSocket upgrades where webSocketMessage/webSocketClose handlers\n // will still be called and may need the client to capture errors.\n if (res.status === 101) {\n waitUntil?.(client?.flush(2000));\n } else {\n waitUntil?.(flushAndDispose(client));\n }\n return res;\n });\n },\n );\n });\n}\n"],"names":[],"mappings":";;;;;;;;AAqBA,SAAS,6BAA6B,OAAA,EAAqD;AAEzF,EAAA,OAAO,OAAA,IAAW,SAAA,IAAa,OAAA,GAAU,qCAAA,GAAwC,sBAAA;AACnF;AA6BO,SAAS,kBAAA,CACd,gBACA,OAAA,EACmB;AACnB,EAAA,OAAO,0BAAA,CAA2B,cAA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IAAA,CAAK,WAAA,CAAY,SAAS,CAAA,EAAG;AAAA,gBACnD,QAAQ,GAAA,CAAI,MAAA;AAAA,gBACZ,YAAY,GAAA,CAAI,UAAA;AAAA,gBAChB,SAAS,GAAA,CAAI;AAAA,eACd,CAAA;AAAA,YACH,CAAA,CAAA,MAAQ;AACN,cAAA,IAAA,CAAK,GAAA,EAAI;AACT,cAAA,SAAA,GAAY,eAAA,CAAgB,MAAM,CAAC,CAAA;AACnC,cAAA,OAAO,GAAA;AAAA,YACT;AAAA,UACF;AAGA,UAAA,IAAA,CAAK,GAAA,EAAI;AAKT,UAAA,IAAI,GAAA,CAAI,WAAW,GAAA,EAAK;AACtB,YAAA,SAAA,GAAY,MAAA,EAAQ,KAAA,CAAM,GAAI,CAAC,CAAA;AAAA,UACjC,CAAA,MAAO;AACL,YAAA,SAAA,GAAY,eAAA,CAAgB,MAAM,CAAC,CAAA;AAAA,UACrC;AACA,UAAA,OAAO,GAAA;AAAA,QACT,CAAC,CAAA;AAAA,MACH;AAAA,KACF;AAAA,EACF,CAAC,CAAA;AACH;;;;"}
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 is set up with the default integrations that work without the `nodejs_compat`\n * compatibility flag, so that this also works on runtimes that cannot enable it (e.g. Shopify\n * Oxygen). On a runtime that has `nodejs_compat`, pass `defaultIntegrations:\n * getDefaultIntegrations(options)` in `options` to get the full set instead.\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"],"names":[],"mappings":";;;AAYO,SAAS,kBAAA,CACd,gBAKA,OAAA,EACmB;AACnB,EAAA,OAAO,0BAAA,CAA2B,cAAA,EAAgB,OAAA,EAAS,WAAW,CAAA;AACxE;;;;"}
@@ -1,16 +1,20 @@
1
- import { vercelAIIntegration } from './integrations/tracing/vercelai.js';
2
1
  import { getBaseDefaultIntegrations, initWithDefaultIntegrations } from './baseSdk.js';
2
+ import { setupOpenTelemetryTracer } from './opentelemetry/tracer.js';
3
+ import { wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit.js';
3
4
 
4
5
  function getDefaultIntegrations(options) {
5
- return [
6
- ...getBaseDefaultIntegrations(options),
7
- // Subscribes to the `ai` SDK's native `node:diagnostics_channel` telemetry channel.
8
- vercelAIIntegration()
9
- ];
6
+ return getBaseDefaultIntegrations(options);
10
7
  }
11
8
  function init(options) {
9
+ options.enableOpenTelemetrySetup ?? (options.enableOpenTelemetrySetup = false);
10
+ if (options.enableOpenTelemetrySetup) {
11
+ setupOpenTelemetryTracer();
12
+ }
12
13
  return initWithDefaultIntegrations(options, getDefaultIntegrations);
13
14
  }
15
+ function _INTERNAL_wrapRequestHandler(wrapperOptions, handler) {
16
+ return wrapRequestHandlerWithInit(wrapperOptions, handler, init);
17
+ }
14
18
 
15
- export { getDefaultIntegrations, init };
19
+ export { _INTERNAL_wrapRequestHandler, getDefaultIntegrations, init };
16
20
  //# sourceMappingURL=sdk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../../src/sdk.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport { vercelAIIntegration } from './integrations/tracing/vercelai';\nimport { getBaseDefaultIntegrations, initWithDefaultIntegrations } from './baseSdk';\nimport type { CloudflareClient, CloudflareOptions } from './client';\n\n/**\n * Get the default integrations for the Cloudflare SDK.\n *\n * This is the full set and requires the `nodejs_compat` compatibility flag. Runtimes that cannot\n * enable it (e.g. Shopify Oxygen) go through `wrapRequestHandler`, which only sets up\n * `getBaseDefaultIntegrations`.\n */\nexport function getDefaultIntegrations(options: CloudflareOptions): Integration[] {\n return [\n ...getBaseDefaultIntegrations(options),\n // Subscribes to the `ai` SDK's native `node:diagnostics_channel` telemetry channel.\n vercelAIIntegration(),\n ];\n}\n\n/**\n * Initializes the cloudflare SDK.\n */\nexport function init(options: CloudflareOptions): CloudflareClient | undefined {\n return initWithDefaultIntegrations(options, getDefaultIntegrations);\n}\n"],"names":[],"mappings":";;;AAYO,SAAS,uBAAuB,OAAA,EAA2C;AAChF,EAAA,OAAO;AAAA,IACL,GAAG,2BAA2B,OAAO,CAAA;AAAA;AAAA,IAErC,mBAAA;AAAoB,GACtB;AACF;AAKO,SAAS,KAAK,OAAA,EAA0D;AAC7E,EAAA,OAAO,2BAAA,CAA4B,SAAS,sBAAsB,CAAA;AACpE;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../../src/sdk.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport { getBaseDefaultIntegrations, initWithDefaultIntegrations } 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\n/**\n * Get the default integrations for the Cloudflare SDK.\n */\nexport function getDefaultIntegrations(options: CloudflareOptions): Integration[] {\n return getBaseDefaultIntegrations(options);\n}\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 initWithDefaultIntegrations(options, getDefaultIntegrations);\n}\n\n/**\n * `wrapRequestHandler` backed by `init`, so the request gets the full default integrations and\n * honors `enableOpenTelemetrySetup`. The `@sentry/cloudflare/request` variant deliberately skips\n * both 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":";;;;AAYO,SAAS,uBAAuB,OAAA,EAA2C;AAChF,EAAA,OAAO,2BAA2B,OAAO,CAAA;AAC3C;AAKO,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,2BAAA,CAA4B,SAAS,sBAAsB,CAAA;AACpE;AAYO,SAAS,4BAAA,CACd,gBACA,OAAA,EACmB;AACnB,EAAA,OAAO,0BAAA,CAA2B,cAAA,EAAgB,OAAA,EAAS,IAAI,CAAA;AACjE;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { createTransport, suppressTracing, SENTRY_BUFFER_FULL_ERROR } from '@sentry/core';
2
2
 
3
- const DEFAULT_TRANSPORT_BUFFER_SIZE = 30;
3
+ const DEFAULT_TRANSPORT_BUFFER_SIZE = 256;
4
4
  class IsolatedPromiseBuffer {
5
5
  constructor(_bufferSize = DEFAULT_TRANSPORT_BUFFER_SIZE) {
6
6
  this.$ = [];
@@ -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\nconst DEFAULT_TRANSPORT_BUFFER_SIZE = 30;\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 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 return new Promise(resolve => {\n const timer = setTimeout(() => {\n if (timeout && timeout > 0) {\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 oldTaskProducers.map(taskProducer =>\n taskProducer().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 function makeRequest(request: TransportRequest): PromiseLike<TransportMakeRequestResponse> {\n const requestOptions: RequestInit = {\n body: request.body as BodyInit,\n method: 'POST',\n headers: options.headers,\n ...options.fetchOptions,\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, new IsolatedPromiseBuffer(options.bufferSize));\n}\n"],"names":[],"mappings":";;AAUA,MAAM,6BAAA,GAAgC,EAAA;AAU/B,MAAM,qBAAA,CAAsB;AAAA,EAS1B,WAAA,CAAY,cAAc,6BAAA,EAA+B;AAC9D,IAAA,IAAA,CAAK,IAAI,EAAC;AACV,IAAA,IAAA,CAAK,iBAAiB,EAAC;AACvB,IAAA,IAAA,CAAK,WAAA,GAAc,WAAA;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA,EAKO,IAAI,YAAA,EAA0G;AACnH,IAAA,IAAI,IAAA,CAAK,cAAA,CAAe,MAAA,IAAU,IAAA,CAAK,WAA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AO,OAAA,CAAQ,KAAK,cAAc,CAAA,CAAE,IAAA,CAAK,OAAM,QAAA,KAAY;AAMlF,QAAA,IAAI;AACF,UAAA,MAAM,SAAS,IAAA,EAAK;AAAA,QACtB,CAAA,CAAA,MAAQ;AAAA,QAER;AAEA,QAAA,OAAO;AAAA,UACL,YAAY,QAAA,CAAS,MAAA;AAAA,UACrB,OAAA,EAAS;AAAA,YACP,sBAAA,EAAwB,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,sBAAsB,CAAA;AAAA,YACnE,aAAA,EAAe,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,aAAa;AAAA;AACnD,SACF;AAAA,MACF,CAAC,CAAA;AAAA,IACH,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,OAAO,gBAAgB,OAAA,EAAS,WAAA,EAAa,IAAI,qBAAA,CAAsB,OAAA,CAAQ,UAAU,CAAC,CAAA;AAC5F;;;;"}
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 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 return new Promise(resolve => {\n const timer = setTimeout(() => {\n if (timeout && timeout > 0) {\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 oldTaskProducers.map(taskProducer =>\n taskProducer().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 function makeRequest(request: TransportRequest): PromiseLike<TransportMakeRequestResponse> {\n const requestOptions: RequestInit = {\n body: request.body as BodyInit,\n method: 'POST',\n headers: options.headers,\n ...options.fetchOptions,\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, new IsolatedPromiseBuffer(options.bufferSize));\n}\n"],"names":[],"mappings":";;AAgBA,MAAM,6BAAA,GAAgC,GAAA;AAU/B,MAAM,qBAAA,CAAsB;AAAA,EAS1B,WAAA,CAAY,cAAc,6BAAA,EAA+B;AAC9D,IAAA,IAAA,CAAK,IAAI,EAAC;AACV,IAAA,IAAA,CAAK,iBAAiB,EAAC;AACvB,IAAA,IAAA,CAAK,WAAA,GAAc,WAAA;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA,EAKO,IAAI,YAAA,EAA0G;AACnH,IAAA,IAAI,IAAA,CAAK,cAAA,CAAe,MAAA,IAAU,IAAA,CAAK,WAAA,EAAa;AAClD,MAAA,OAAO,OAAA,CAAQ,OAAO,wBAAwB,CAAA;AAAA,IAChD;AAEA,IAAA,IAAA,CAAK,cAAA,CAAe,KAAK,YAAY,CAAA;AACrC,IAAA,OAAO,OAAA,CAAQ,OAAA,CAAQ,EAAE,CAAA;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKO,MAAM,OAAA,EAAwC;AACnD,IAAA,MAAM,gBAAA,GAAmB,CAAC,GAAG,IAAA,CAAK,cAAc,CAAA;AAChD,IAAA,IAAA,CAAK,iBAAiB,EAAC;AAEvB,IAAA,OAAO,IAAI,QAAQ,CAAA,OAAA,KAAW;AAC5B,MAAA,MAAM,KAAA,GAAQ,WAAW,MAAM;AAC7B,QAAA,IAAI,OAAA,IAAW,UAAU,CAAA,EAAG;AAC1B,UAAA,OAAA,CAAQ,KAAK,CAAA;AAAA,QACf;AAAA,MACF,GAAG,OAAO,CAA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;;"}
@@ -0,0 +1,37 @@
1
+ import { getIsolationScope, getDefaultIsolationScope, debug } from '@sentry/core';
2
+ import { DEBUG_BUILD } from '../debug-build.js';
3
+ import { getOriginalWaitUntil } from '../flush.js';
4
+
5
+ const INVOCATION_STATE = /* @__PURE__ */ Symbol("sentryInvocationState");
6
+ function getInvocationWaitUntil(state) {
7
+ if (state.waitUntil === void 0) {
8
+ const ctx = state.ctx;
9
+ let resolved = null;
10
+ try {
11
+ const original = ctx && getOriginalWaitUntil(ctx);
12
+ resolved = original ? original.bind(ctx) : null;
13
+ } catch {
14
+ }
15
+ state.waitUntil = resolved;
16
+ }
17
+ return state.waitUntil ?? void 0;
18
+ }
19
+ function setInvocationState(scope, state) {
20
+ if (scope === getDefaultIsolationScope()) {
21
+ DEBUG_BUILD && debug.warn(
22
+ "[Sentry] Cannot track this invocation. Telemetry captured after the invocation ends may not be delivered."
23
+ );
24
+ return;
25
+ }
26
+ scope[INVOCATION_STATE] = state;
27
+ }
28
+ function getInvocationState() {
29
+ const isolationScope = getIsolationScope();
30
+ if (isolationScope === getDefaultIsolationScope()) {
31
+ return void 0;
32
+ }
33
+ return isolationScope[INVOCATION_STATE];
34
+ }
35
+
36
+ export { getInvocationState, getInvocationWaitUntil, setInvocationState };
37
+ //# sourceMappingURL=invocationContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invocationContext.js","sources":["../../../../src/utils/invocationContext.ts"],"sourcesContent":["import type { ExecutionContext } from '@cloudflare/workers-types';\nimport type { Scope } from '@sentry/core';\nimport { debug, getDefaultIsolationScope, getIsolationScope } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { ExecutionContextCompat } from '../executionContext';\nimport { getOriginalWaitUntil } from '../flush';\n\n/**\n * State owned by a single invocation (request, RPC call, cron, ...).\n *\n * A cached client (`cacheClient`) is shared by all invocations running in the same\n * isolate, so anything invocation-owned must not live on the client: two overlapping\n * requests would otherwise overwrite each other's state (e.g. the execution context\n * used to register eager flushes) and the earlier invocation's envelopes would be\n * suspended when the later invocation ends.\n *\n * The state rides on the invocation's forked isolation scope, which the async\n * context strategy (AsyncLocalStorage) hands back for exactly the async context that\n * owns the invocation — including detached continuations created inside it. A symbol\n * key keeps it off `Scope.clone()` and out of serialized event data.\n */\nexport interface InvocationState {\n /**\n * The execution context of the invocation that owns this scope. Eager envelope\n * sends are registered with this context's `waitUntil`, so they are attributed to\n * the invocation that captured the data even when invocations overlap.\n */\n readonly ctx: ExecutionContextCompat | undefined;\n /**\n * Set on the client's `flush` hook, the invocation's natural flush point.\n * Captures before it are drained by that flush; captures after it (in\n * `waitUntil` work or detached continuations) have no later flush to ride and\n * are delivered eagerly.\n */\n flushPointReached?: boolean;\n /**\n * `ctx.waitUntil` resolved once for this invocation (see `getInvocationWaitUntil`).\n * `null` once resolved to \"no usable waitUntil\".\n */\n waitUntil?: ExecutionContext['waitUntil'] | null;\n}\n\nconst INVOCATION_STATE: unique symbol = Symbol('sentryInvocationState');\n\n/**\n * Returns the invocation's original (un-instrumented) `waitUntil`, bound to its context,\n * resolving it on first use and caching it on the state. Reading `ctx.waitUntil` on a\n * native `ExecutionContext`/`DurableObjectState` goes through the runtime's property\n * getter every time; one read per invocation is enough.\n */\nexport function getInvocationWaitUntil(state: InvocationState): ExecutionContext['waitUntil'] | undefined {\n if (state.waitUntil === undefined) {\n const ctx = state.ctx;\n let resolved: ExecutionContext['waitUntil'] | null = null;\n try {\n const original = ctx && getOriginalWaitUntil(ctx);\n resolved = original ? original.bind(ctx) : null;\n } catch {\n // Accessing `waitUntil` can throw on foreign or already-torn-down contexts.\n }\n state.waitUntil = resolved;\n }\n return state.waitUntil ?? undefined;\n}\n\ntype ScopeWithInvocationState = Scope & {\n [INVOCATION_STATE]?: InvocationState;\n};\n\n/**\n * Attaches invocation state to a forked isolation scope. Only meaningful on a scope\n * that outlives nothing but this invocation — never attach to the default isolation\n * scope, which is shared by every invocation in the isolate.\n */\nexport function setInvocationState(scope: Scope, state: InvocationState): void {\n if (scope === getDefaultIsolationScope()) {\n DEBUG_BUILD &&\n debug.warn(\n '[Sentry] Cannot track this invocation. Telemetry captured after the invocation ends may not be delivered.',\n );\n return;\n }\n\n (scope as ScopeWithInvocationState)[INVOCATION_STATE] = state;\n}\n\n/**\n * Returns the state of the invocation that owns the current async context, or\n * `undefined` outside any instrumented invocation (the default isolation scope is\n * shared, so state read from it could not be attributed to one invocation — and it\n * is never attached there in the first place).\n */\nexport function getInvocationState(): InvocationState | undefined {\n const isolationScope = getIsolationScope() as ScopeWithInvocationState;\n if (isolationScope === getDefaultIsolationScope()) {\n return undefined;\n }\n return isolationScope[INVOCATION_STATE];\n}\n"],"names":[],"mappings":";;;;AA0CA,MAAM,gBAAA,0BAAyC,uBAAuB,CAAA;AAQ/D,SAAS,uBAAuB,KAAA,EAAmE;AACxG,EAAA,IAAI,KAAA,CAAM,cAAc,MAAA,EAAW;AACjC,IAAA,MAAM,MAAM,KAAA,CAAM,GAAA;AAClB,IAAA,IAAI,QAAA,GAAiD,IAAA;AACrD,IAAA,IAAI;AACF,MAAA,MAAM,QAAA,GAAW,GAAA,IAAO,oBAAA,CAAqB,GAAG,CAAA;AAChD,MAAA,QAAA,GAAW,QAAA,GAAW,QAAA,CAAS,IAAA,CAAK,GAAG,CAAA,GAAI,IAAA;AAAA,IAC7C,CAAA,CAAA,MAAQ;AAAA,IAER;AACA,IAAA,KAAA,CAAM,SAAA,GAAY,QAAA;AAAA,EACpB;AACA,EAAA,OAAO,MAAM,SAAA,IAAa,MAAA;AAC5B;AAWO,SAAS,kBAAA,CAAmB,OAAc,KAAA,EAA8B;AAC7E,EAAA,IAAI,KAAA,KAAU,0BAAyB,EAAG;AACxC,IAAA,WAAA,IACE,KAAA,CAAM,IAAA;AAAA,MACJ;AAAA,KACF;AACF,IAAA;AAAA,EACF;AAEA,EAAC,KAAA,CAAmC,gBAAgB,CAAA,GAAI,KAAA;AAC1D;AAQO,SAAS,kBAAA,GAAkD;AAChE,EAAA,MAAM,iBAAiB,iBAAA,EAAkB;AACzC,EAAA,IAAI,cAAA,KAAmB,0BAAyB,EAAG;AACjD,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,OAAO,eAAe,gBAAgB,CAAA;AACxC;;;;"}
@@ -1,8 +1,13 @@
1
1
  import { getIsolationScope, getDefaultIsolationScope, withIsolationScope } from '@sentry/core';
2
+ import { setInvocationState } from './invocationContext.js';
2
3
 
3
- function withInvocationIsolationScope(callback) {
4
+ function withInvocationIsolationScope(callback, context) {
4
5
  const isolationScope = getIsolationScope();
5
- const newIsolationScope = isolationScope === getDefaultIsolationScope() ? isolationScope.clone() : isolationScope;
6
+ const isEntryPoint = isolationScope === getDefaultIsolationScope();
7
+ const newIsolationScope = isEntryPoint ? isolationScope.clone() : isolationScope;
8
+ if (isEntryPoint) {
9
+ setInvocationState(newIsolationScope, { ctx: context });
10
+ }
6
11
  return withIsolationScope(newIsolationScope, () => callback(newIsolationScope));
7
12
  }
8
13
 
@@ -1 +1 @@
1
- {"version":3,"file":"invocationScope.js","sources":["../../../../src/utils/invocationScope.ts"],"sourcesContent":["import { getDefaultIsolationScope, getIsolationScope, type Scope, withIsolationScope } from '@sentry/core';\n\n/**\n * Runs `callback` on the isolation scope for the current invocation.\n *\n * An instrumented handler is either the entry point of an invocation or reentrant — reached from\n * another instrumented handler already serving the same invocation (a Durable Object method calling\n * its own `fetch`, an RPC method reaching a sibling method). Only the entry point may fork:\n *\n * - Forking at the entry point is mandatory. `setUser`/`setTag` write to the isolation scope, and a\n * Durable Object's isolation scope outlives the invocation that touched it, so without a fork one\n * invocation's user and tags reappear on the next invocation's events in the same isolate.\n * Forking clones, so request data set by an enclosing wrapper is still inherited.\n * - Forking again when reentrant would be wrong. Everything below the entry point is one logical\n * unit of work: a nested call must see what the caller set and be able to add to it, the way it\n * would if the SDK were not wrapping it at all.\n *\n * The AsyncLocalStorage strategy hands the default isolation scope back whenever no invocation is in\n * flight, and a forked one while inside `withIsolationScope`. Reference-comparing against the default\n * is therefore enough to tell the two cases apart. The stack fallback does not fork, so it reports the\n * default scope even inside an invocation; there the fork degrades to a no-op, which the stack strategy\n * tolerates. This matches the approach used by `patchEventHandler` in Nuxt.\n */\nexport function withInvocationIsolationScope<T>(callback: (scope: Scope) => T): T {\n const isolationScope = getIsolationScope();\n\n const newIsolationScope = isolationScope === getDefaultIsolationScope() ? isolationScope.clone() : isolationScope;\n\n return withIsolationScope(newIsolationScope, () => callback(newIsolationScope));\n}\n"],"names":[],"mappings":";;AAuBO,SAAS,6BAAgC,QAAA,EAAkC;AAChF,EAAA,MAAM,iBAAiB,iBAAA,EAAkB;AAEzC,EAAA,MAAM,oBAAoB,cAAA,KAAmB,wBAAA,EAAyB,GAAI,cAAA,CAAe,OAAM,GAAI,cAAA;AAEnG,EAAA,OAAO,kBAAA,CAAmB,iBAAA,EAAmB,MAAM,QAAA,CAAS,iBAAiB,CAAC,CAAA;AAChF;;;;"}
1
+ {"version":3,"file":"invocationScope.js","sources":["../../../../src/utils/invocationScope.ts"],"sourcesContent":["import { getDefaultIsolationScope, getIsolationScope, type Scope, withIsolationScope } from '@sentry/core';\nimport type { ExecutionContextCompat } from '../executionContext';\nimport { setInvocationState } from './invocationContext';\n\n/**\n * Runs `callback` on the isolation scope for the current invocation.\n *\n * An instrumented handler is either the entry point of an invocation or reentrant — reached from\n * another instrumented handler already serving the same invocation (a Durable Object method calling\n * its own `fetch`, an RPC method reaching a sibling method). Only the entry point may fork:\n *\n * - Forking at the entry point is mandatory. `setUser`/`setTag` write to the isolation scope, and a\n * Durable Object's isolation scope outlives the invocation that touched it, so without a fork one\n * invocation's user and tags reappear on the next invocation's events in the same isolate.\n * Forking clones, so request data set by an enclosing wrapper is still inherited.\n * - Forking again when reentrant would be wrong. Everything below the entry point is one logical\n * unit of work: a nested call must see what the caller set and be able to add to it, the way it\n * would if the SDK were not wrapping it at all.\n *\n * The AsyncLocalStorage strategy hands the default isolation scope back whenever no invocation is in\n * flight, and a forked one while inside `withIsolationScope`. Reference-comparing against the default\n * is therefore enough to tell the two cases apart. The stack fallback does not fork, so it reports the\n * default scope even inside an invocation; there the fork degrades to a no-op, which the stack strategy\n * tolerates. This matches the approach used by `patchEventHandler` in Nuxt.\n */\nexport function withInvocationIsolationScope<T>(callback: (scope: Scope) => T, context?: ExecutionContextCompat): T {\n const isolationScope = getIsolationScope();\n\n const isEntryPoint = isolationScope === getDefaultIsolationScope();\n const newIsolationScope = isEntryPoint ? isolationScope.clone() : isolationScope;\n\n if (isEntryPoint) {\n setInvocationState(newIsolationScope, { ctx: context });\n }\n\n return withIsolationScope(newIsolationScope, () => callback(newIsolationScope));\n}\n"],"names":[],"mappings":";;;AAyBO,SAAS,4BAAA,CAAgC,UAA+B,OAAA,EAAqC;AAClH,EAAA,MAAM,iBAAiB,iBAAA,EAAkB;AAEzC,EAAA,MAAM,YAAA,GAAe,mBAAmB,wBAAA,EAAyB;AACjE,EAAA,MAAM,iBAAA,GAAoB,YAAA,GAAe,cAAA,CAAe,KAAA,EAAM,GAAI,cAAA;AAElE,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,kBAAA,CAAmB,iBAAA,EAAmB,EAAE,GAAA,EAAK,OAAA,EAAS,CAAA;AAAA,EACxD;AAEA,EAAA,OAAO,kBAAA,CAAmB,iBAAA,EAAmB,MAAM,QAAA,CAAS,iBAAiB,CAAC,CAAA;AAChF;;;;"}
@@ -21,9 +21,6 @@ function isAiBinding(item) {
21
21
  function isR2Bucket(item) {
22
22
  return item != null && isNotJSRPC(item) && typeof item.head === "function" && typeof item.put === "function" && typeof item.createMultipartUpload === "function";
23
23
  }
24
- function isRateLimit(item) {
25
- return item != null && isNotJSRPC(item) && typeof item.limit === "function";
26
- }
27
24
 
28
- export { isAiBinding, isD1Database, isDurableObjectNamespace, isJSRPC, isQueue, isR2Bucket, isRateLimit };
25
+ export { isAiBinding, isD1Database, isDurableObjectNamespace, isJSRPC, isQueue, isR2Bucket };
29
26
  //# sourceMappingURL=isBinding.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"isBinding.js","sources":["../../../../src/utils/isBinding.ts"],"sourcesContent":["/**\n * Adapted from https://github.com/evanderkoogh/otel-cf-workers/blob/effeb549f0a4ed1c55ea0c4f0d8e8e37e5494fb3/src/instrumentation/env.ts\n *\n * BSD 3-Clause License\n *\n * Copyright (c) 2023, Erwin van der Koogh\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * 3. Neither the name of the copyright holder nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport type { Ai, D1Database, DurableObjectNamespace, Queue, R2Bucket, RateLimit } from '@cloudflare/workers-types';\n\n/**\n * Checks if a value is a JSRPC proxy (service binding).\n *\n * JSRPC proxies return a truthy value for ANY property access, including\n * properties that don't exist. This makes other duck-type checks unreliable\n * unless we exclude JSRPC first.\n *\n * Must be checked before other binding type checks.\n */\nexport function isJSRPC(item: unknown): item is Service {\n try {\n return !!(item as Record<string, unknown>)[`__some_property_that_will_never_exist__${Math.random()}`];\n } catch {\n return false;\n }\n}\n\nconst isNotJSRPC = (item: unknown): item is Record<string, unknown> => !isJSRPC(item);\n\n/**\n * Duck-type check for DurableObjectNamespace bindings.\n * DurableObjectNamespace has `idFromName`, `idFromString`, `get`, `newUniqueId`.\n */\nexport function isDurableObjectNamespace(item: unknown): item is DurableObjectNamespace {\n return item != null && isNotJSRPC(item) && typeof item.idFromName === 'function';\n}\n\n/**\n * Duck-type check for Queue producer bindings.\n * Queue has `send` and `sendBatch` async methods.\n */\nexport function isQueue(item: unknown): item is Queue {\n return item != null && isNotJSRPC(item) && typeof item.send === 'function' && typeof item.sendBatch === 'function';\n}\n\n/**\n * Duck-type check for D1Database bindings.\n * D1Database has `prepare`, `batch`, and `exec` methods.\n */\nexport function isD1Database(item: unknown): item is D1Database {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.prepare === 'function' &&\n typeof item.batch === 'function' &&\n typeof item.exec === 'function'\n );\n}\n\n/**\n * Duck-type check for Workers AI bindings.\n * The Ai binding has `run`, `gateway`, and `toMarkdown` methods.\n */\nexport function isAiBinding(item: unknown): item is Ai {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.run === 'function' &&\n typeof item.gateway === 'function' &&\n typeof item.toMarkdown === 'function'\n );\n}\n\n/**\n * Duck-type check for R2 Bucket bindings.\n * R2Bucket has `head`, `put`, and `createMultipartUpload` methods.\n */\nexport function isR2Bucket(item: unknown): item is R2Bucket {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.head === 'function' &&\n typeof item.put === 'function' &&\n typeof item.createMultipartUpload === 'function'\n );\n}\n\n/**\n * Duck-type check for RateLimit bindings.\n * RateLimit only exposes a single `limit` method. Because that is a fairly\n * common method name, this check is intentionally run after the more specific\n * binding checks (Queue, R2, D1) in `instrumentEnv`, so those win when a binding\n * also happens to expose `limit`.\n */\nexport function isRateLimit(item: unknown): item is RateLimit {\n return item != null && isNotJSRPC(item) && typeof item.limit === 'function';\n}\n"],"names":[],"mappings":"AA4CO,SAAS,QAAQ,IAAA,EAAgC;AACtD,EAAA,IAAI;AACF,IAAA,OAAO,CAAC,CAAE,IAAA,CAAiC,0CAA0C,IAAA,CAAK,MAAA,EAAQ,CAAA,CAAE,CAAA;AAAA,EACtG,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAEA,MAAM,UAAA,GAAa,CAAC,IAAA,KAAmD,CAAC,QAAQ,IAAI,CAAA;AAM7E,SAAS,yBAAyB,IAAA,EAA+C;AACtF,EAAA,OAAO,QAAQ,IAAA,IAAQ,UAAA,CAAW,IAAI,CAAA,IAAK,OAAO,KAAK,UAAA,KAAe,UAAA;AACxE;AAMO,SAAS,QAAQ,IAAA,EAA8B;AACpD,EAAA,OAAO,IAAA,IAAQ,IAAA,IAAQ,UAAA,CAAW,IAAI,CAAA,IAAK,OAAO,IAAA,CAAK,IAAA,KAAS,UAAA,IAAc,OAAO,IAAA,CAAK,SAAA,KAAc,UAAA;AAC1G;AAMO,SAAS,aAAa,IAAA,EAAmC;AAC9D,EAAA,OACE,IAAA,IAAQ,IAAA,IACR,UAAA,CAAW,IAAI,KACf,OAAO,IAAA,CAAK,OAAA,KAAY,UAAA,IACxB,OAAO,IAAA,CAAK,KAAA,KAAU,UAAA,IACtB,OAAO,KAAK,IAAA,KAAS,UAAA;AAEzB;AAMO,SAAS,YAAY,IAAA,EAA2B;AACrD,EAAA,OACE,IAAA,IAAQ,IAAA,IACR,UAAA,CAAW,IAAI,KACf,OAAO,IAAA,CAAK,GAAA,KAAQ,UAAA,IACpB,OAAO,IAAA,CAAK,OAAA,KAAY,UAAA,IACxB,OAAO,KAAK,UAAA,KAAe,UAAA;AAE/B;AAMO,SAAS,WAAW,IAAA,EAAiC;AAC1D,EAAA,OACE,IAAA,IAAQ,IAAA,IACR,UAAA,CAAW,IAAI,KACf,OAAO,IAAA,CAAK,IAAA,KAAS,UAAA,IACrB,OAAO,IAAA,CAAK,GAAA,KAAQ,UAAA,IACpB,OAAO,KAAK,qBAAA,KAA0B,UAAA;AAE1C;AASO,SAAS,YAAY,IAAA,EAAkC;AAC5D,EAAA,OAAO,QAAQ,IAAA,IAAQ,UAAA,CAAW,IAAI,CAAA,IAAK,OAAO,KAAK,KAAA,KAAU,UAAA;AACnE;;;;"}
1
+ {"version":3,"file":"isBinding.js","sources":["../../../../src/utils/isBinding.ts"],"sourcesContent":["/**\n * Adapted from https://github.com/evanderkoogh/otel-cf-workers/blob/effeb549f0a4ed1c55ea0c4f0d8e8e37e5494fb3/src/instrumentation/env.ts\n *\n * BSD 3-Clause License\n *\n * Copyright (c) 2023, Erwin van der Koogh\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * 3. Neither the name of the copyright holder nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport type { Ai, D1Database, DurableObjectNamespace, Queue, R2Bucket } from '@cloudflare/workers-types';\n\n/**\n * Checks if a value is a JSRPC proxy (service binding).\n *\n * JSRPC proxies return a truthy value for ANY property access, including\n * properties that don't exist. This makes other duck-type checks unreliable\n * unless we exclude JSRPC first.\n *\n * Must be checked before other binding type checks.\n */\nexport function isJSRPC(item: unknown): item is Service {\n try {\n return !!(item as Record<string, unknown>)[`__some_property_that_will_never_exist__${Math.random()}`];\n } catch {\n return false;\n }\n}\n\nconst isNotJSRPC = (item: unknown): item is Record<string, unknown> => !isJSRPC(item);\n\n/**\n * Duck-type check for DurableObjectNamespace bindings.\n * DurableObjectNamespace has `idFromName`, `idFromString`, `get`, `newUniqueId`.\n */\nexport function isDurableObjectNamespace(item: unknown): item is DurableObjectNamespace {\n return item != null && isNotJSRPC(item) && typeof item.idFromName === 'function';\n}\n\n/**\n * Duck-type check for Queue producer bindings.\n * Queue has `send` and `sendBatch` async methods.\n */\nexport function isQueue(item: unknown): item is Queue {\n return item != null && isNotJSRPC(item) && typeof item.send === 'function' && typeof item.sendBatch === 'function';\n}\n\n/**\n * Duck-type check for D1Database bindings.\n * D1Database has `prepare`, `batch`, and `exec` methods.\n */\nexport function isD1Database(item: unknown): item is D1Database {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.prepare === 'function' &&\n typeof item.batch === 'function' &&\n typeof item.exec === 'function'\n );\n}\n\n/**\n * Duck-type check for Workers AI bindings.\n * The Ai binding has `run`, `gateway`, and `toMarkdown` methods.\n */\nexport function isAiBinding(item: unknown): item is Ai {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.run === 'function' &&\n typeof item.gateway === 'function' &&\n typeof item.toMarkdown === 'function'\n );\n}\n\n/**\n * Duck-type check for R2 Bucket bindings.\n * R2Bucket has `head`, `put`, and `createMultipartUpload` methods.\n */\nexport function isR2Bucket(item: unknown): item is R2Bucket {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.head === 'function' &&\n typeof item.put === 'function' &&\n typeof item.createMultipartUpload === 'function'\n );\n}\n"],"names":[],"mappings":"AA4CO,SAAS,QAAQ,IAAA,EAAgC;AACtD,EAAA,IAAI;AACF,IAAA,OAAO,CAAC,CAAE,IAAA,CAAiC,0CAA0C,IAAA,CAAK,MAAA,EAAQ,CAAA,CAAE,CAAA;AAAA,EACtG,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAEA,MAAM,UAAA,GAAa,CAAC,IAAA,KAAmD,CAAC,QAAQ,IAAI,CAAA;AAM7E,SAAS,yBAAyB,IAAA,EAA+C;AACtF,EAAA,OAAO,QAAQ,IAAA,IAAQ,UAAA,CAAW,IAAI,CAAA,IAAK,OAAO,KAAK,UAAA,KAAe,UAAA;AACxE;AAMO,SAAS,QAAQ,IAAA,EAA8B;AACpD,EAAA,OAAO,IAAA,IAAQ,IAAA,IAAQ,UAAA,CAAW,IAAI,CAAA,IAAK,OAAO,IAAA,CAAK,IAAA,KAAS,UAAA,IAAc,OAAO,IAAA,CAAK,SAAA,KAAc,UAAA;AAC1G;AAMO,SAAS,aAAa,IAAA,EAAmC;AAC9D,EAAA,OACE,IAAA,IAAQ,IAAA,IACR,UAAA,CAAW,IAAI,KACf,OAAO,IAAA,CAAK,OAAA,KAAY,UAAA,IACxB,OAAO,IAAA,CAAK,KAAA,KAAU,UAAA,IACtB,OAAO,KAAK,IAAA,KAAS,UAAA;AAEzB;AAMO,SAAS,YAAY,IAAA,EAA2B;AACrD,EAAA,OACE,IAAA,IAAQ,IAAA,IACR,UAAA,CAAW,IAAI,KACf,OAAO,IAAA,CAAK,GAAA,KAAQ,UAAA,IACpB,OAAO,IAAA,CAAK,OAAA,KAAY,UAAA,IACxB,OAAO,KAAK,UAAA,KAAe,UAAA;AAE/B;AAMO,SAAS,WAAW,IAAA,EAAiC;AAC1D,EAAA,OACE,IAAA,IAAQ,IAAA,IACR,UAAA,CAAW,IAAI,KACf,OAAO,IAAA,CAAK,IAAA,KAAS,UAAA,IACrB,OAAO,IAAA,CAAK,GAAA,KAAQ,UAAA,IACpB,OAAO,KAAK,qBAAA,KAA0B,UAAA;AAE1C;;;;"}
@@ -0,0 +1,13 @@
1
+ import { matchesTracePropagationTargets } from '@sentry/core';
2
+
3
+ const PROPAGATE_TO_NONE = () => false;
4
+ function createRpcPropagationResolver(options) {
5
+ const bindings = options?.rpcTracePropagationBindings;
6
+ if (!bindings?.length) {
7
+ return PROPAGATE_TO_NONE;
8
+ }
9
+ return (bindingName) => matchesTracePropagationTargets(bindingName, bindings, true);
10
+ }
11
+
12
+ export { createRpcPropagationResolver };
13
+ //# sourceMappingURL=rpcPropagation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpcPropagation.js","sources":["../../../../src/utils/rpcPropagation.ts"],"sourcesContent":["import { matchesTracePropagationTargets } 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 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 const bindings = options?.rpcTracePropagationBindings;\n\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"],"names":[],"mappings":";;AAGA,MAAM,oBAAoB,MAAM,KAAA;AASzB,SAAS,6BAA6B,OAAA,EAA0E;AACrH,EAAA,MAAM,WAAW,OAAA,EAAS,2BAAA;AAE1B,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;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { TraceFlags } from '@opentelemetry/api';
2
- import { debug, SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE, getActiveSpan, spanIsSampled } from '@sentry/core';
2
+ import { getActiveSpan, spanIsSampled, debug, SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE } from '@sentry/core';
3
3
  import { DEBUG_BUILD } from '../debug-build.js';
4
4
 
5
5
  const SENTRY_TRACE_LINK_KEY_PREFIX = "__SENTRY_TRACE_LINK__";
@@ -1,4 +1,5 @@
1
- import { createStackParser, nodeStackLineParser, basename } from '@sentry/core';
1
+ import { createStackParser, basename } from '@sentry/core';
2
+ import { nodeStackLineParser } from '@sentry/core/server';
2
3
 
3
4
  function workersStackLineParser(getModule2) {
4
5
  const [arg1, arg2] = nodeStackLineParser(getModule2);
@@ -1 +1 @@
1
- {"version":3,"file":"stacktrace.js","sources":["../../../../src/vendor/stacktrace.ts"],"sourcesContent":["// Vendored from https://github.com/robertcepa/toucan-js/blob/036568729e49d0a937de527dc32d73580d9a41b3/packages/toucan-js/src/stacktrace.ts\n// Copyright (c) 2022 Robert Cepa\n// SPDX-License-Identifier: MIT\n\nimport type { StackLineParser, StackLineParserFn, StackParser } from '@sentry/core';\nimport { basename, createStackParser, nodeStackLineParser } from '@sentry/core';\n\ntype GetModuleFn = (filename: string | undefined) => string | undefined;\n\n/**\n * Stack line parser for Cloudflare Workers.\n * This wraps node stack parser and adjusts root paths to match with source maps.\n *\n */\nfunction workersStackLineParser(getModule?: GetModuleFn): StackLineParser {\n const [arg1, arg2] = nodeStackLineParser(getModule);\n\n const fn: StackLineParserFn = line => {\n const result = arg2(line);\n if (result) {\n const filename = result.filename;\n // Workers runtime runs a single bundled file that is always in a virtual root\n result.abs_path = filename !== undefined && !filename.startsWith('/') ? `/${filename}` : filename;\n // There is no way to tell what code is in_app and what comes from dependencies (node_modules), since we have one bundled file.\n // So everything is in_app, unless an error comes from runtime function (ie. JSON.parse), which is determined by the presence of filename.\n result.in_app = filename !== undefined;\n }\n return result;\n };\n\n return [arg1, fn];\n}\n\n/**\n * Gets the module from filename.\n *\n * @param filename\n * @returns Module name\n */\nexport function getModule(filename: string | undefined): string | undefined {\n if (!filename) {\n return;\n }\n\n // In Cloudflare Workers there is always only one bundled file\n return basename(filename, '.js');\n}\n\n/** Cloudflare Workers stack parser */\nexport const defaultStackParser: StackParser = createStackParser(workersStackLineParser(getModule));\n"],"names":["getModule"],"mappings":";;AAcA,SAAS,uBAAuBA,UAAAA,EAA0C;AACxE,EAAA,MAAM,CAAC,IAAA,EAAM,IAAI,CAAA,GAAI,oBAAoBA,UAAS,CAAA;AAElD,EAAA,MAAM,KAAwB,CAAA,IAAA,KAAQ;AACpC,IAAA,MAAM,MAAA,GAAS,KAAK,IAAI,CAAA;AACxB,IAAA,IAAI,MAAA,EAAQ;AACV,MAAA,MAAM,WAAW,MAAA,CAAO,QAAA;AAExB,MAAA,MAAA,CAAO,QAAA,GAAW,QAAA,KAAa,MAAA,IAAa,CAAC,QAAA,CAAS,WAAW,GAAG,CAAA,GAAI,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA,GAAK,QAAA;AAGzF,MAAA,MAAA,CAAO,SAAS,QAAA,KAAa,MAAA;AAAA,IAC/B;AACA,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AAEA,EAAA,OAAO,CAAC,MAAM,EAAE,CAAA;AAClB;AAQO,SAAS,UAAU,QAAA,EAAkD;AAC1E,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA;AAAA,EACF;AAGA,EAAA,OAAO,QAAA,CAAS,UAAU,KAAK,CAAA;AACjC;AAGO,MAAM,kBAAA,GAAkC,iBAAA,CAAkB,sBAAA,CAAuB,SAAS,CAAC;;;;"}
1
+ {"version":3,"file":"stacktrace.js","sources":["../../../../src/vendor/stacktrace.ts"],"sourcesContent":["// Vendored from https://github.com/robertcepa/toucan-js/blob/036568729e49d0a937de527dc32d73580d9a41b3/packages/toucan-js/src/stacktrace.ts\n// Copyright (c) 2022 Robert Cepa\n// SPDX-License-Identifier: MIT\n\nimport type { StackLineParser, StackLineParserFn, StackParser } from '@sentry/core';\nimport { basename, createStackParser } from '@sentry/core';\nimport { nodeStackLineParser } from '@sentry/core/server';\n\ntype GetModuleFn = (filename: string | undefined) => string | undefined;\n\n/**\n * Stack line parser for Cloudflare Workers.\n * This wraps node stack parser and adjusts root paths to match with source maps.\n *\n */\nfunction workersStackLineParser(getModule?: GetModuleFn): StackLineParser {\n const [arg1, arg2] = nodeStackLineParser(getModule);\n\n const fn: StackLineParserFn = line => {\n const result = arg2(line);\n if (result) {\n const filename = result.filename;\n // Workers runtime runs a single bundled file that is always in a virtual root\n result.abs_path = filename !== undefined && !filename.startsWith('/') ? `/${filename}` : filename;\n // There is no way to tell what code is in_app and what comes from dependencies (node_modules), since we have one bundled file.\n // So everything is in_app, unless an error comes from runtime function (ie. JSON.parse), which is determined by the presence of filename.\n result.in_app = filename !== undefined;\n }\n return result;\n };\n\n return [arg1, fn];\n}\n\n/**\n * Gets the module from filename.\n *\n * @param filename\n * @returns Module name\n */\nexport function getModule(filename: string | undefined): string | undefined {\n if (!filename) {\n return;\n }\n\n // In Cloudflare Workers there is always only one bundled file\n return basename(filename, '.js');\n}\n\n/** Cloudflare Workers stack parser */\nexport const defaultStackParser: StackParser = createStackParser(workersStackLineParser(getModule));\n"],"names":["getModule"],"mappings":";;;AAeA,SAAS,uBAAuBA,UAAAA,EAA0C;AACxE,EAAA,MAAM,CAAC,IAAA,EAAM,IAAI,CAAA,GAAI,oBAAoBA,UAAS,CAAA;AAElD,EAAA,MAAM,KAAwB,CAAA,IAAA,KAAQ;AACpC,IAAA,MAAM,MAAA,GAAS,KAAK,IAAI,CAAA;AACxB,IAAA,IAAI,MAAA,EAAQ;AACV,MAAA,MAAM,WAAW,MAAA,CAAO,QAAA;AAExB,MAAA,MAAA,CAAO,QAAA,GAAW,QAAA,KAAa,MAAA,IAAa,CAAC,QAAA,CAAS,WAAW,GAAG,CAAA,GAAI,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA,GAAK,QAAA;AAGzF,MAAA,MAAA,CAAO,SAAS,QAAA,KAAa,MAAA;AAAA,IAC/B;AACA,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AAEA,EAAA,OAAO,CAAC,MAAM,EAAE,CAAA;AAClB;AAQO,SAAS,UAAU,QAAA,EAAkD;AAC1E,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA;AAAA,EACF;AAGA,EAAA,OAAO,QAAA,CAAS,UAAU,KAAK,CAAA;AACjC;AAGO,MAAM,kBAAA,GAAkC,iBAAA,CAAkB,sBAAA,CAAuB,SAAS,CAAC;;;;"}
@@ -74,7 +74,8 @@ function sentryCloudflareAutoInstrumentPlugin(options = {}) {
74
74
  classWrappers,
75
75
  agentClasses,
76
76
  optionsFn,
77
- optionsImport
77
+ optionsImport,
78
+ sameWorkerBindings: wranglerConfig.sameWorkerBindings
78
79
  });
79
80
  const wrappedClasses = result?.wrappedClasses ?? /* @__PURE__ */ new Set();
80
81
  const missing = [...classWrappers.keys()].filter((name) => !wrappedClasses.has(name));