@sentry/cloudflare 11.0.0-alpha.0 → 11.0.0-alpha.2

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 (345) 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 +116 -24
  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 +24 -8
  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 +4 -3
  13. package/build/cjs/dev/index.js.map +1 -1
  14. package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js +4 -4
  15. package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  16. package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js +8 -16
  17. package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  18. package/build/cjs/dev/instrumentations/worker/instrumentD1.js +5 -1
  19. package/build/cjs/dev/instrumentations/worker/instrumentD1.js.map +1 -1
  20. package/build/cjs/dev/instrumentations/worker/instrumentEmail.js +4 -2
  21. package/build/cjs/dev/instrumentations/worker/instrumentEmail.js.map +1 -1
  22. package/build/cjs/dev/instrumentations/worker/instrumentEnv.js +5 -5
  23. package/build/cjs/dev/instrumentations/worker/instrumentEnv.js.map +1 -1
  24. package/build/cjs/dev/instrumentations/worker/instrumentFetch.js +8 -8
  25. package/build/cjs/dev/instrumentations/worker/instrumentFetch.js.map +1 -1
  26. package/build/cjs/dev/instrumentations/worker/instrumentQueue.js +4 -2
  27. package/build/cjs/dev/instrumentations/worker/instrumentQueue.js.map +1 -1
  28. package/build/cjs/dev/instrumentations/worker/instrumentR2.js +21 -18
  29. package/build/cjs/dev/instrumentations/worker/instrumentR2.js.map +1 -1
  30. package/build/cjs/dev/instrumentations/worker/instrumentRateLimit.js +6 -1
  31. package/build/cjs/dev/instrumentations/worker/instrumentRateLimit.js.map +1 -1
  32. package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js +4 -2
  33. package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js.map +1 -1
  34. package/build/cjs/dev/instrumentations/worker/instrumentTail.js +2 -0
  35. package/build/cjs/dev/instrumentations/worker/instrumentTail.js.map +1 -1
  36. package/build/cjs/dev/integrations/fetch.js +1 -11
  37. package/build/cjs/dev/integrations/fetch.js.map +1 -1
  38. package/build/cjs/dev/opentelemetry/tracer.js +2 -40
  39. package/build/cjs/dev/opentelemetry/tracer.js.map +1 -1
  40. package/build/cjs/dev/pages-plugin.js +2 -2
  41. package/build/cjs/dev/pages-plugin.js.map +1 -1
  42. package/build/cjs/dev/request.js +2 -123
  43. package/build/cjs/dev/request.js.map +1 -1
  44. package/build/cjs/dev/sdk.js +12 -6
  45. package/build/cjs/dev/sdk.js.map +1 -1
  46. package/build/cjs/dev/transport.js +1 -1
  47. package/build/cjs/dev/transport.js.map +1 -1
  48. package/build/cjs/dev/utils/invocationContext.js +41 -0
  49. package/build/cjs/dev/utils/invocationContext.js.map +1 -0
  50. package/build/cjs/dev/utils/invocationScope.js +7 -2
  51. package/build/cjs/dev/utils/invocationScope.js.map +1 -1
  52. package/build/cjs/dev/utils/rpcPropagation.js +15 -0
  53. package/build/cjs/dev/utils/rpcPropagation.js.map +1 -0
  54. package/build/cjs/dev/vite/autoInstrument.js +2 -1
  55. package/build/cjs/dev/vite/autoInstrument.js.map +1 -1
  56. package/build/cjs/dev/vite/index.js +1 -1
  57. package/build/cjs/dev/vite/index.js.map +1 -1
  58. package/build/cjs/dev/vite/transform.js +30 -5
  59. package/build/cjs/dev/vite/transform.js.map +1 -1
  60. package/build/cjs/dev/vite/wranglerConfig.js +21 -1
  61. package/build/cjs/dev/vite/wranglerConfig.js.map +1 -1
  62. package/build/cjs/dev/withSentry.js.map +1 -1
  63. package/build/cjs/dev/workflows.js +45 -33
  64. package/build/cjs/dev/workflows.js.map +1 -1
  65. package/build/cjs/dev/wrapMethodWithSentry.js +51 -15
  66. package/build/cjs/dev/wrapMethodWithSentry.js.map +1 -1
  67. package/build/cjs/dev/wrapRequestHandlerWithInit.js +133 -0
  68. package/build/cjs/dev/wrapRequestHandlerWithInit.js.map +1 -0
  69. package/build/cjs/prod/baseSdk.js +20 -8
  70. package/build/cjs/prod/baseSdk.js.map +1 -1
  71. package/build/cjs/prod/client.js +116 -24
  72. package/build/cjs/prod/client.js.map +1 -1
  73. package/build/cjs/prod/clientCache.js +15 -0
  74. package/build/cjs/prod/clientCache.js.map +1 -0
  75. package/build/cjs/prod/defineCloudflareOptions.js.map +1 -1
  76. package/build/cjs/prod/durableobject.js +24 -8
  77. package/build/cjs/prod/durableobject.js.map +1 -1
  78. package/build/cjs/prod/flush.js +6 -4
  79. package/build/cjs/prod/flush.js.map +1 -1
  80. package/build/cjs/prod/index.js +4 -3
  81. package/build/cjs/prod/index.js.map +1 -1
  82. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js +4 -4
  83. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  84. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js +8 -16
  85. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  86. package/build/cjs/prod/instrumentations/worker/instrumentD1.js +5 -1
  87. package/build/cjs/prod/instrumentations/worker/instrumentD1.js.map +1 -1
  88. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js +4 -2
  89. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js.map +1 -1
  90. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js +5 -5
  91. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js.map +1 -1
  92. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js +8 -8
  93. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js.map +1 -1
  94. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js +4 -2
  95. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js.map +1 -1
  96. package/build/cjs/prod/instrumentations/worker/instrumentR2.js +21 -18
  97. package/build/cjs/prod/instrumentations/worker/instrumentR2.js.map +1 -1
  98. package/build/cjs/prod/instrumentations/worker/instrumentRateLimit.js +6 -1
  99. package/build/cjs/prod/instrumentations/worker/instrumentRateLimit.js.map +1 -1
  100. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js +4 -2
  101. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js.map +1 -1
  102. package/build/cjs/prod/instrumentations/worker/instrumentTail.js +2 -0
  103. package/build/cjs/prod/instrumentations/worker/instrumentTail.js.map +1 -1
  104. package/build/cjs/prod/integrations/fetch.js +1 -11
  105. package/build/cjs/prod/integrations/fetch.js.map +1 -1
  106. package/build/cjs/prod/opentelemetry/tracer.js +2 -40
  107. package/build/cjs/prod/opentelemetry/tracer.js.map +1 -1
  108. package/build/cjs/prod/pages-plugin.js +2 -2
  109. package/build/cjs/prod/pages-plugin.js.map +1 -1
  110. package/build/cjs/prod/request.js +2 -123
  111. package/build/cjs/prod/request.js.map +1 -1
  112. package/build/cjs/prod/sdk.js +12 -6
  113. package/build/cjs/prod/sdk.js.map +1 -1
  114. package/build/cjs/prod/transport.js +1 -1
  115. package/build/cjs/prod/transport.js.map +1 -1
  116. package/build/cjs/prod/utils/invocationContext.js +41 -0
  117. package/build/cjs/prod/utils/invocationContext.js.map +1 -0
  118. package/build/cjs/prod/utils/invocationScope.js +7 -2
  119. package/build/cjs/prod/utils/invocationScope.js.map +1 -1
  120. package/build/cjs/prod/utils/rpcPropagation.js +15 -0
  121. package/build/cjs/prod/utils/rpcPropagation.js.map +1 -0
  122. package/build/cjs/prod/vite/autoInstrument.js +2 -1
  123. package/build/cjs/prod/vite/autoInstrument.js.map +1 -1
  124. package/build/cjs/prod/vite/index.js +1 -1
  125. package/build/cjs/prod/vite/index.js.map +1 -1
  126. package/build/cjs/prod/vite/transform.js +30 -5
  127. package/build/cjs/prod/vite/transform.js.map +1 -1
  128. package/build/cjs/prod/vite/wranglerConfig.js +21 -1
  129. package/build/cjs/prod/vite/wranglerConfig.js.map +1 -1
  130. package/build/cjs/prod/withSentry.js.map +1 -1
  131. package/build/cjs/prod/workflows.js +45 -33
  132. package/build/cjs/prod/workflows.js.map +1 -1
  133. package/build/cjs/prod/wrapMethodWithSentry.js +51 -15
  134. package/build/cjs/prod/wrapMethodWithSentry.js.map +1 -1
  135. package/build/cjs/prod/wrapRequestHandlerWithInit.js +133 -0
  136. package/build/cjs/prod/wrapRequestHandlerWithInit.js.map +1 -0
  137. package/build/esm/dev/baseSdk.js +21 -9
  138. package/build/esm/dev/baseSdk.js.map +1 -1
  139. package/build/esm/dev/client.js +117 -25
  140. package/build/esm/dev/client.js.map +1 -1
  141. package/build/esm/dev/clientCache.js +12 -0
  142. package/build/esm/dev/clientCache.js.map +1 -0
  143. package/build/esm/dev/defineCloudflareOptions.js.map +1 -1
  144. package/build/esm/dev/durableobject.js +23 -7
  145. package/build/esm/dev/durableobject.js.map +1 -1
  146. package/build/esm/dev/flush.js +6 -4
  147. package/build/esm/dev/flush.js.map +1 -1
  148. package/build/esm/dev/index.js +3 -4
  149. package/build/esm/dev/index.js.map +1 -1
  150. package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js +4 -4
  151. package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  152. package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js +8 -16
  153. package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  154. package/build/esm/dev/instrumentations/worker/instrumentD1.js +6 -2
  155. package/build/esm/dev/instrumentations/worker/instrumentD1.js.map +1 -1
  156. package/build/esm/dev/instrumentations/worker/instrumentEmail.js +7 -5
  157. package/build/esm/dev/instrumentations/worker/instrumentEmail.js.map +1 -1
  158. package/build/esm/dev/instrumentations/worker/instrumentEnv.js +5 -5
  159. package/build/esm/dev/instrumentations/worker/instrumentEnv.js.map +1 -1
  160. package/build/esm/dev/instrumentations/worker/instrumentFetch.js +1 -1
  161. package/build/esm/dev/instrumentations/worker/instrumentFetch.js.map +1 -1
  162. package/build/esm/dev/instrumentations/worker/instrumentQueue.js +7 -5
  163. package/build/esm/dev/instrumentations/worker/instrumentQueue.js.map +1 -1
  164. package/build/esm/dev/instrumentations/worker/instrumentR2.js +22 -19
  165. package/build/esm/dev/instrumentations/worker/instrumentR2.js.map +1 -1
  166. package/build/esm/dev/instrumentations/worker/instrumentRateLimit.js +6 -1
  167. package/build/esm/dev/instrumentations/worker/instrumentRateLimit.js.map +1 -1
  168. package/build/esm/dev/instrumentations/worker/instrumentScheduled.js +7 -5
  169. package/build/esm/dev/instrumentations/worker/instrumentScheduled.js.map +1 -1
  170. package/build/esm/dev/instrumentations/worker/instrumentTail.js +2 -0
  171. package/build/esm/dev/instrumentations/worker/instrumentTail.js.map +1 -1
  172. package/build/esm/dev/integrations/fetch.js +2 -12
  173. package/build/esm/dev/integrations/fetch.js.map +1 -1
  174. package/build/esm/dev/opentelemetry/tracer.js +2 -40
  175. package/build/esm/dev/opentelemetry/tracer.js.map +1 -1
  176. package/build/esm/dev/package.json +1 -1
  177. package/build/esm/dev/pages-plugin.js +1 -1
  178. package/build/esm/dev/pages-plugin.js.map +1 -1
  179. package/build/esm/dev/request.js +2 -122
  180. package/build/esm/dev/request.js.map +1 -1
  181. package/build/esm/dev/sdk.js +12 -7
  182. package/build/esm/dev/sdk.js.map +1 -1
  183. package/build/esm/dev/transport.js +1 -1
  184. package/build/esm/dev/transport.js.map +1 -1
  185. package/build/esm/dev/utils/invocationContext.js +37 -0
  186. package/build/esm/dev/utils/invocationContext.js.map +1 -0
  187. package/build/esm/dev/utils/invocationScope.js +7 -2
  188. package/build/esm/dev/utils/invocationScope.js.map +1 -1
  189. package/build/esm/dev/utils/rpcPropagation.js +13 -0
  190. package/build/esm/dev/utils/rpcPropagation.js.map +1 -0
  191. package/build/esm/dev/utils/traceLinks.js +1 -1
  192. package/build/esm/dev/vite/autoInstrument.js +2 -1
  193. package/build/esm/dev/vite/autoInstrument.js.map +1 -1
  194. package/build/esm/dev/vite/index.js +1 -1
  195. package/build/esm/dev/vite/index.js.map +1 -1
  196. package/build/esm/dev/vite/transform.js +30 -5
  197. package/build/esm/dev/vite/transform.js.map +1 -1
  198. package/build/esm/dev/vite/wranglerConfig.js +21 -2
  199. package/build/esm/dev/vite/wranglerConfig.js.map +1 -1
  200. package/build/esm/dev/withSentry.js.map +1 -1
  201. package/build/esm/dev/workflows.js +48 -36
  202. package/build/esm/dev/workflows.js.map +1 -1
  203. package/build/esm/dev/wrapMethodWithSentry.js +53 -17
  204. package/build/esm/dev/wrapMethodWithSentry.js.map +1 -1
  205. package/build/esm/dev/wrapRequestHandlerWithInit.js +131 -0
  206. package/build/esm/dev/wrapRequestHandlerWithInit.js.map +1 -0
  207. package/build/esm/prod/baseSdk.js +21 -9
  208. package/build/esm/prod/baseSdk.js.map +1 -1
  209. package/build/esm/prod/client.js +117 -25
  210. package/build/esm/prod/client.js.map +1 -1
  211. package/build/esm/prod/clientCache.js +12 -0
  212. package/build/esm/prod/clientCache.js.map +1 -0
  213. package/build/esm/prod/defineCloudflareOptions.js.map +1 -1
  214. package/build/esm/prod/durableobject.js +23 -7
  215. package/build/esm/prod/durableobject.js.map +1 -1
  216. package/build/esm/prod/flush.js +6 -4
  217. package/build/esm/prod/flush.js.map +1 -1
  218. package/build/esm/prod/index.js +3 -4
  219. package/build/esm/prod/index.js.map +1 -1
  220. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js +4 -4
  221. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  222. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js +8 -16
  223. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  224. package/build/esm/prod/instrumentations/worker/instrumentD1.js +6 -2
  225. package/build/esm/prod/instrumentations/worker/instrumentD1.js.map +1 -1
  226. package/build/esm/prod/instrumentations/worker/instrumentEmail.js +7 -5
  227. package/build/esm/prod/instrumentations/worker/instrumentEmail.js.map +1 -1
  228. package/build/esm/prod/instrumentations/worker/instrumentEnv.js +5 -5
  229. package/build/esm/prod/instrumentations/worker/instrumentEnv.js.map +1 -1
  230. package/build/esm/prod/instrumentations/worker/instrumentFetch.js +1 -1
  231. package/build/esm/prod/instrumentations/worker/instrumentFetch.js.map +1 -1
  232. package/build/esm/prod/instrumentations/worker/instrumentQueue.js +7 -5
  233. package/build/esm/prod/instrumentations/worker/instrumentQueue.js.map +1 -1
  234. package/build/esm/prod/instrumentations/worker/instrumentR2.js +22 -19
  235. package/build/esm/prod/instrumentations/worker/instrumentR2.js.map +1 -1
  236. package/build/esm/prod/instrumentations/worker/instrumentRateLimit.js +6 -1
  237. package/build/esm/prod/instrumentations/worker/instrumentRateLimit.js.map +1 -1
  238. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js +7 -5
  239. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js.map +1 -1
  240. package/build/esm/prod/instrumentations/worker/instrumentTail.js +2 -0
  241. package/build/esm/prod/instrumentations/worker/instrumentTail.js.map +1 -1
  242. package/build/esm/prod/integrations/fetch.js +2 -12
  243. package/build/esm/prod/integrations/fetch.js.map +1 -1
  244. package/build/esm/prod/opentelemetry/tracer.js +2 -40
  245. package/build/esm/prod/opentelemetry/tracer.js.map +1 -1
  246. package/build/esm/prod/package.json +1 -1
  247. package/build/esm/prod/pages-plugin.js +1 -1
  248. package/build/esm/prod/pages-plugin.js.map +1 -1
  249. package/build/esm/prod/request.js +2 -122
  250. package/build/esm/prod/request.js.map +1 -1
  251. package/build/esm/prod/sdk.js +12 -7
  252. package/build/esm/prod/sdk.js.map +1 -1
  253. package/build/esm/prod/transport.js +1 -1
  254. package/build/esm/prod/transport.js.map +1 -1
  255. package/build/esm/prod/utils/invocationContext.js +37 -0
  256. package/build/esm/prod/utils/invocationContext.js.map +1 -0
  257. package/build/esm/prod/utils/invocationScope.js +7 -2
  258. package/build/esm/prod/utils/invocationScope.js.map +1 -1
  259. package/build/esm/prod/utils/rpcPropagation.js +13 -0
  260. package/build/esm/prod/utils/rpcPropagation.js.map +1 -0
  261. package/build/esm/prod/utils/traceLinks.js +1 -1
  262. package/build/esm/prod/vite/autoInstrument.js +2 -1
  263. package/build/esm/prod/vite/autoInstrument.js.map +1 -1
  264. package/build/esm/prod/vite/index.js +1 -1
  265. package/build/esm/prod/vite/index.js.map +1 -1
  266. package/build/esm/prod/vite/transform.js +30 -5
  267. package/build/esm/prod/vite/transform.js.map +1 -1
  268. package/build/esm/prod/vite/wranglerConfig.js +21 -2
  269. package/build/esm/prod/vite/wranglerConfig.js.map +1 -1
  270. package/build/esm/prod/withSentry.js.map +1 -1
  271. package/build/esm/prod/workflows.js +48 -36
  272. package/build/esm/prod/workflows.js.map +1 -1
  273. package/build/esm/prod/wrapMethodWithSentry.js +53 -17
  274. package/build/esm/prod/wrapMethodWithSentry.js.map +1 -1
  275. package/build/esm/prod/wrapRequestHandlerWithInit.js +131 -0
  276. package/build/esm/prod/wrapRequestHandlerWithInit.js.map +1 -0
  277. package/build/types/baseSdk.d.ts +8 -0
  278. package/build/types/baseSdk.d.ts.map +1 -1
  279. package/build/types/client.d.ts +94 -21
  280. package/build/types/client.d.ts.map +1 -1
  281. package/build/types/clientCache.d.ts +8 -0
  282. package/build/types/clientCache.d.ts.map +1 -0
  283. package/build/types/defineCloudflareOptions.d.ts +3 -2
  284. package/build/types/defineCloudflareOptions.d.ts.map +1 -1
  285. package/build/types/durableobject.d.ts +5 -7
  286. package/build/types/durableobject.d.ts.map +1 -1
  287. package/build/types/flush.d.ts +2 -0
  288. package/build/types/flush.d.ts.map +1 -1
  289. package/build/types/index.d.ts +3 -4
  290. package/build/types/index.d.ts.map +1 -1
  291. package/build/types/instrumentations/instrumentDurableObjectNamespace.d.ts +2 -1
  292. package/build/types/instrumentations/instrumentDurableObjectNamespace.d.ts.map +1 -1
  293. package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts +2 -3
  294. package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts.map +1 -1
  295. package/build/types/instrumentations/worker/instrumentD1.d.ts.map +1 -1
  296. package/build/types/instrumentations/worker/instrumentEmail.d.ts.map +1 -1
  297. package/build/types/instrumentations/worker/instrumentEnv.d.ts.map +1 -1
  298. package/build/types/instrumentations/worker/instrumentQueue.d.ts.map +1 -1
  299. package/build/types/instrumentations/worker/instrumentR2.d.ts.map +1 -1
  300. package/build/types/instrumentations/worker/instrumentRateLimit.d.ts.map +1 -1
  301. package/build/types/instrumentations/worker/instrumentScheduled.d.ts.map +1 -1
  302. package/build/types/instrumentations/worker/instrumentTail.d.ts.map +1 -1
  303. package/build/types/integrations/fetch.d.ts.map +1 -1
  304. package/build/types/opentelemetry/tracer.d.ts.map +1 -1
  305. package/build/types/pages-plugin.d.ts +3 -1
  306. package/build/types/pages-plugin.d.ts.map +1 -1
  307. package/build/types/request.d.ts +5 -31
  308. package/build/types/request.d.ts.map +1 -1
  309. package/build/types/sdk.d.ts +13 -4
  310. package/build/types/sdk.d.ts.map +1 -1
  311. package/build/types/transport.d.ts.map +1 -1
  312. package/build/types/types.d.ts +28 -0
  313. package/build/types/types.d.ts.map +1 -1
  314. package/build/types/utils/invocationContext.d.ts +58 -0
  315. package/build/types/utils/invocationContext.d.ts.map +1 -0
  316. package/build/types/utils/invocationScope.d.ts +2 -1
  317. package/build/types/utils/invocationScope.d.ts.map +1 -1
  318. package/build/types/utils/rpcPropagation.d.ts +10 -0
  319. package/build/types/utils/rpcPropagation.d.ts.map +1 -0
  320. package/build/types/vite/autoInstrument.d.ts.map +1 -1
  321. package/build/types/vite/index.d.ts +24 -20
  322. package/build/types/vite/index.d.ts.map +1 -1
  323. package/build/types/vite/transform.d.ts +3 -0
  324. package/build/types/vite/transform.d.ts.map +1 -1
  325. package/build/types/vite/wranglerConfig.d.ts +13 -0
  326. package/build/types/vite/wranglerConfig.d.ts.map +1 -1
  327. package/build/types/withSentry.d.ts +2 -3
  328. package/build/types/withSentry.d.ts.map +1 -1
  329. package/build/types/workflows.d.ts +3 -3
  330. package/build/types/workflows.d.ts.map +1 -1
  331. package/build/types/wrapMethodWithSentry.d.ts +6 -1
  332. package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
  333. package/build/types/wrapRequestHandlerWithInit.d.ts +31 -0
  334. package/build/types/wrapRequestHandlerWithInit.d.ts.map +1 -0
  335. package/package.json +6 -4
  336. package/build/cjs/dev/integrations/tracing/vercelai.js +0 -18
  337. package/build/cjs/dev/integrations/tracing/vercelai.js.map +0 -1
  338. package/build/cjs/prod/integrations/tracing/vercelai.js +0 -18
  339. package/build/cjs/prod/integrations/tracing/vercelai.js.map +0 -1
  340. package/build/esm/dev/integrations/tracing/vercelai.js +0 -16
  341. package/build/esm/dev/integrations/tracing/vercelai.js.map +0 -1
  342. package/build/esm/prod/integrations/tracing/vercelai.js +0 -16
  343. package/build/esm/prod/integrations/tracing/vercelai.js.map +0 -1
  344. package/build/types/integrations/tracing/vercelai.d.ts +0 -40
  345. package/build/types/integrations/tracing/vercelai.d.ts.map +0 -1
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const noDiagnosticChannels = require('@sentry/server-utils/no-diagnostic-channels');
4
- const request = require('./request.js');
4
+ const wrapRequestHandlerWithInit = require('./wrapRequestHandlerWithInit.js');
5
5
  const sdk = require('./sdk.js');
6
6
 
7
7
  function sentryPagesPlugin(handlerOrOptions) {
@@ -12,7 +12,7 @@ function sentryPagesPlugin(handlerOrOptions) {
12
12
  }
13
13
  const options = typeof handlerOrOptions === "function" ? handlerOrOptions(context) : handlerOrOptions;
14
14
  const executionContext = { ...context, props: {} };
15
- return request.wrapRequestHandlerWithInit(
15
+ return wrapRequestHandlerWithInit.wrapRequestHandlerWithInit(
16
16
  { options, request: context.request, context: executionContext },
17
17
  () => context.next(),
18
18
  sdk.init
@@ -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":["setAsyncLocalStorageAsyncContextStrategy","wrapRequestHandlerWithInit","init"],"mappings":";;;;;;AAqCO,SAAS,kBAUd,gBAAA,EAGsD;AACtD,EAAAA,6DAAA,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,OAAOC,kCAAA;AAAA,MACL,EAAE,OAAA,EAAS,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAS,SAAS,gBAAA,EAAiB;AAAA,MAC/D,MAAM,QAAQ,IAAA,EAAK;AAAA,MACnBC;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":["setAsyncLocalStorageAsyncContextStrategy","wrapRequestHandlerWithInit","init"],"mappings":";;;;;;AA+DO,SAAS,kBAUd,gBAAA,EAGsD;AACtD,EAAAA,6DAAA,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,OAAOC,qDAAA;AAAA,MACL,EAAE,OAAA,EAAS,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAS,SAAS,gBAAA,EAAiB;AAAA,MAC/D,MAAM,QAAQ,IAAA,EAAK;AAAA,MACnBC;AAAA,KACF;AAAA,EACF,CAAA;AACF;;;;"}
@@ -1,132 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const core = require('@sentry/core');
4
- const httpServer = require('./integrations/httpServer.js');
5
3
  const baseSdk = require('./baseSdk.js');
6
- const flush = require('./flush.js');
7
- const scopeUtils = require('./scope-utils.js');
8
- const invocationScope = require('./utils/invocationScope.js');
9
- const streaming = require('./utils/streaming.js');
4
+ const wrapRequestHandlerWithInit = require('./wrapRequestHandlerWithInit.js');
10
5
 
11
- function getRequestErrorMechanismType(context) {
12
- return context && "storage" in context ? "auto.faas.cloudflare.durable_object" : "auto.http.cloudflare";
13
- }
14
6
  function wrapRequestHandler(wrapperOptions, handler) {
15
- return wrapRequestHandlerWithInit(wrapperOptions, handler, baseSdk.initBaseSdk);
16
- }
17
- function wrapRequestHandlerWithInit(wrapperOptions, handler, initSdk) {
18
- return invocationScope.withInvocationIsolationScope(async (isolationScope) => {
19
- const { options, request, captureErrors = true } = wrapperOptions;
20
- const context = wrapperOptions.context;
21
- const waitUntil = context ? flush.getOriginalWaitUntil(context).bind(context) : void 0;
22
- const errorMechanismType = getRequestErrorMechanismType(context);
23
- const client = initSdk({ ...options, ctx: context });
24
- isolationScope.setClient(client);
25
- const urlObject = core.parseStringToURLObject(request.url);
26
- const [name, attributes] = core.getHttpSpanDetailsFromUrlObject(
27
- urlObject,
28
- "server",
29
- "auto.http.cloudflare",
30
- request,
31
- void 0,
32
- client
33
- );
34
- const contentLength = request.headers.get("content-length");
35
- if (contentLength) {
36
- attributes["http.request.body.size"] = parseInt(contentLength, 10);
37
- }
38
- const userAgentHeader = request.headers.get("user-agent");
39
- if (userAgentHeader) {
40
- attributes["user_agent.original"] = userAgentHeader;
41
- }
42
- if (client) {
43
- Object.assign(
44
- attributes,
45
- core.httpHeadersToSpanAttributes(core.winterCGHeadersToDict(request.headers), client.getDataCollectionOptions())
46
- );
47
- }
48
- attributes[core.SEMANTIC_ATTRIBUTE_SENTRY_OP] = "http.server";
49
- scopeUtils.addCloudResourceContext(isolationScope);
50
- scopeUtils.addRequest(isolationScope, request);
51
- if (request.cf) {
52
- scopeUtils.addCultureContext(isolationScope, request.cf);
53
- if (typeof request.cf.httpProtocol === "string") {
54
- attributes["network.protocol.name"] = request.cf.httpProtocol;
55
- }
56
- }
57
- if (request.method === "OPTIONS" || request.method === "HEAD") {
58
- try {
59
- return await handler();
60
- } catch (e) {
61
- if (captureErrors) {
62
- core.captureException(e, { mechanism: { handled: false, type: errorMechanismType } });
63
- }
64
- throw e;
65
- } finally {
66
- waitUntil?.(flush.flushAndDispose(client));
67
- }
68
- }
69
- if (client) {
70
- await httpServer.captureIncomingRequestBody(client, request);
71
- }
72
- return core.continueTrace(
73
- { sentryTrace: request.headers.get("sentry-trace") || "", baggage: request.headers.get("baggage") },
74
- () => {
75
- return core.startSpanManual({ name, attributes }, async (span) => {
76
- let res;
77
- try {
78
- res = await handler();
79
- core.setHttpStatus(span, res.status);
80
- } catch (e) {
81
- span.end();
82
- if (captureErrors) {
83
- core.captureException(e, { mechanism: { handled: false, type: errorMechanismType } });
84
- }
85
- waitUntil?.(flush.flushAndDispose(client));
86
- throw e;
87
- }
88
- const classification = streaming.classifyResponseStreaming(res);
89
- if (classification.isStreaming && res.body) {
90
- try {
91
- let ended = false;
92
- const endSpanOnce = () => {
93
- if (ended) return;
94
- ended = true;
95
- span.end();
96
- waitUntil?.(flush.flushAndDispose(client));
97
- };
98
- const transform = new TransformStream({
99
- flush() {
100
- endSpanOnce();
101
- },
102
- cancel() {
103
- endSpanOnce();
104
- }
105
- });
106
- return new Response(res.body.pipeThrough(transform), {
107
- status: res.status,
108
- statusText: res.statusText,
109
- headers: res.headers
110
- });
111
- } catch {
112
- span.end();
113
- waitUntil?.(flush.flushAndDispose(client));
114
- return res;
115
- }
116
- }
117
- span.end();
118
- if (res.status === 101) {
119
- waitUntil?.(client?.flush(2e3));
120
- } else {
121
- waitUntil?.(flush.flushAndDispose(client));
122
- }
123
- return res;
124
- });
125
- }
126
- );
127
- });
7
+ return wrapRequestHandlerWithInit.wrapRequestHandlerWithInit(wrapperOptions, handler, baseSdk.initBaseSdk);
128
8
  }
129
9
 
130
10
  exports.wrapRequestHandler = wrapRequestHandler;
131
- exports.wrapRequestHandlerWithInit = wrapRequestHandlerWithInit;
132
11
  //# 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":["initBaseSdk","withInvocationIsolationScope","getOriginalWaitUntil","parseStringToURLObject","getHttpSpanDetailsFromUrlObject","httpHeadersToSpanAttributes","winterCGHeadersToDict","SEMANTIC_ATTRIBUTE_SENTRY_OP","addCloudResourceContext","addRequest","addCultureContext","captureException","flushAndDispose","captureIncomingRequestBody","continueTrace","startSpanManual","setHttpStatus","classifyResponseStreaming"],"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,cAAA,EAAgB,OAAA,EAASA,mBAAW,CAAA;AACxE;AAUO,SAAS,0BAAA,CACd,cAAA,EACA,OAAA,EACA,OAAA,EACmB;AACnB,EAAA,OAAOC,4CAAA,CAA6B,OAAM,cAAA,KAAkB;AAC1D,IAAA,MAAM,EAAE,OAAA,EAAS,OAAA,EAAS,aAAA,GAAgB,MAA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AA,MAAQ;AACN,cAAA,IAAA,CAAK,GAAA,EAAI;AACT,cAAA,SAAA,GAAYA,qBAAA,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,GAAYA,qBAAA,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":["wrapRequestHandlerWithInit","initBaseSdk"],"mappings":";;;;;AAYO,SAAS,kBAAA,CACd,gBAKA,OAAA,EACmB;AACnB,EAAA,OAAOA,qDAAA,CAA2B,cAAA,EAAgB,OAAA,EAASC,mBAAW,CAAA;AACxE;;;;"}
@@ -1,19 +1,25 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const vercelai = require('./integrations/tracing/vercelai.js');
4
3
  const baseSdk = require('./baseSdk.js');
4
+ const tracer = require('./opentelemetry/tracer.js');
5
+ const wrapRequestHandlerWithInit = require('./wrapRequestHandlerWithInit.js');
6
+ require('@sentry/core');
5
7
 
6
8
  function getDefaultIntegrations(options) {
7
- return [
8
- ...baseSdk.getBaseDefaultIntegrations(options),
9
- // Subscribes to the `ai` SDK's native `node:diagnostics_channel` telemetry channel.
10
- vercelai.vercelAIIntegration()
11
- ];
9
+ return baseSdk.getBaseDefaultIntegrations(options);
12
10
  }
13
11
  function init(options) {
12
+ options.enableOpenTelemetrySetup ?? (options.enableOpenTelemetrySetup = false);
13
+ if (options.enableOpenTelemetrySetup) {
14
+ tracer.setupOpenTelemetryTracer();
15
+ }
14
16
  return baseSdk.initWithDefaultIntegrations(options, getDefaultIntegrations);
15
17
  }
18
+ function _INTERNAL_wrapRequestHandler(wrapperOptions, handler) {
19
+ return wrapRequestHandlerWithInit.wrapRequestHandlerWithInit(wrapperOptions, handler, init);
20
+ }
16
21
 
22
+ exports._INTERNAL_wrapRequestHandler = _INTERNAL_wrapRequestHandler;
17
23
  exports.getDefaultIntegrations = getDefaultIntegrations;
18
24
  exports.init = init;
19
25
  //# 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":["getBaseDefaultIntegrations","vercelAIIntegration","initWithDefaultIntegrations"],"mappings":";;;;;AAYO,SAAS,uBAAuB,OAAA,EAA2C;AAChF,EAAA,OAAO;AAAA,IACL,GAAGA,mCAA2B,OAAO,CAAA;AAAA;AAAA,IAErCC,4BAAA;AAAoB,GACtB;AACF;AAKO,SAAS,KAAK,OAAA,EAA0D;AAC7E,EAAA,OAAOC,mCAAA,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":["getBaseDefaultIntegrations","setupOpenTelemetryTracer","initWithDefaultIntegrations","wrapRequestHandlerWithInit"],"mappings":";;;;;;;AAYO,SAAS,uBAAuB,OAAA,EAA2C;AAChF,EAAA,OAAOA,mCAA2B,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,IAAAC,+BAAA,EAAyB;AAAA,EAC3B;AAEA,EAAA,OAAOC,mCAAA,CAA4B,SAAS,sBAAsB,CAAA;AACpE;AAYO,SAAS,4BAAA,CACd,gBACA,OAAA,EACmB;AACnB,EAAA,OAAOC,qDAAA,CAA2B,cAAA,EAAgB,OAAA,EAAS,IAAI,CAAA;AACjE;;;;;;"}
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const core = require('@sentry/core');
4
4
 
5
- const DEFAULT_TRANSPORT_BUFFER_SIZE = 30;
5
+ const DEFAULT_TRANSPORT_BUFFER_SIZE = 256;
6
6
  class IsolatedPromiseBuffer {
7
7
  constructor(_bufferSize = DEFAULT_TRANSPORT_BUFFER_SIZE) {
8
8
  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":["SENTRY_BUFFER_FULL_ERROR","suppressTracing","createTransport"],"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,WA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OAAA,CAAQ,OAAA;AAAA,MACjB,GAAG,OAAA,CAAQ;AAAA,KACb;AAEA,IAAA,OAAOC,qBAAgB,MAAM;AAC3B,MAAA,OAAA,CAAQ,OAAA,CAAQ,SAAS,KAAA,EAAO,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,OAAOC,qBAAgB,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":["SENTRY_BUFFER_FULL_ERROR","suppressTracing","createTransport"],"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,OAAOA,6BAAwB,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,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CAAI,aAAa;AAAA;AACnD,SACF;AAAA,MACF,CAAC,CAAA;AAAA,IACH,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,OAAOC,qBAAgB,OAAA,EAAS,WAAA,EAAa,IAAI,qBAAA,CAAsB,OAAA,CAAQ,UAAU,CAAC,CAAA;AAC5F;;;;;"}
@@ -0,0 +1,41 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const debugBuild = require('../debug-build.js');
5
+ const flush = require('../flush.js');
6
+
7
+ const INVOCATION_STATE = /* @__PURE__ */ Symbol("sentryInvocationState");
8
+ function getInvocationWaitUntil(state) {
9
+ if (state.waitUntil === void 0) {
10
+ const ctx = state.ctx;
11
+ let resolved = null;
12
+ try {
13
+ const original = ctx && flush.getOriginalWaitUntil(ctx);
14
+ resolved = original ? original.bind(ctx) : null;
15
+ } catch {
16
+ }
17
+ state.waitUntil = resolved;
18
+ }
19
+ return state.waitUntil ?? void 0;
20
+ }
21
+ function setInvocationState(scope, state) {
22
+ if (scope === core.getDefaultIsolationScope()) {
23
+ debugBuild.DEBUG_BUILD && core.debug.warn(
24
+ "[Sentry] Cannot track this invocation. Telemetry captured after the invocation ends may not be delivered."
25
+ );
26
+ return;
27
+ }
28
+ scope[INVOCATION_STATE] = state;
29
+ }
30
+ function getInvocationState() {
31
+ const isolationScope = core.getIsolationScope();
32
+ if (isolationScope === core.getDefaultIsolationScope()) {
33
+ return void 0;
34
+ }
35
+ return isolationScope[INVOCATION_STATE];
36
+ }
37
+
38
+ exports.getInvocationState = getInvocationState;
39
+ exports.getInvocationWaitUntil = getInvocationWaitUntil;
40
+ exports.setInvocationState = setInvocationState;
41
+ //# 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":["getOriginalWaitUntil","getDefaultIsolationScope","DEBUG_BUILD","debug","getIsolationScope"],"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,IAAOA,0BAAA,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,KAAUC,+BAAyB,EAAG;AACxC,IAAAC,sBAAA,IACEC,UAAA,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,iBAAiBC,sBAAA,EAAkB;AACzC,EAAA,IAAI,cAAA,KAAmBH,+BAAyB,EAAG;AACjD,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,OAAO,eAAe,gBAAgB,CAAA;AACxC;;;;;;"}
@@ -1,10 +1,15 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const core = require('@sentry/core');
4
+ const invocationContext = require('./invocationContext.js');
4
5
 
5
- function withInvocationIsolationScope(callback) {
6
+ function withInvocationIsolationScope(callback, context) {
6
7
  const isolationScope = core.getIsolationScope();
7
- const newIsolationScope = isolationScope === core.getDefaultIsolationScope() ? isolationScope.clone() : isolationScope;
8
+ const isEntryPoint = isolationScope === core.getDefaultIsolationScope();
9
+ const newIsolationScope = isEntryPoint ? isolationScope.clone() : isolationScope;
10
+ if (isEntryPoint) {
11
+ invocationContext.setInvocationState(newIsolationScope, { ctx: context });
12
+ }
8
13
  return core.withIsolationScope(newIsolationScope, () => callback(newIsolationScope));
9
14
  }
10
15
 
@@ -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":["getIsolationScope","getDefaultIsolationScope","withIsolationScope"],"mappings":";;;;AAuBO,SAAS,6BAAgC,QAAA,EAAkC;AAChF,EAAA,MAAM,iBAAiBA,sBAAA,EAAkB;AAEzC,EAAA,MAAM,oBAAoB,cAAA,KAAmBC,6BAAA,EAAyB,GAAI,cAAA,CAAe,OAAM,GAAI,cAAA;AAEnG,EAAA,OAAOC,uBAAA,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":["getIsolationScope","getDefaultIsolationScope","setInvocationState","withIsolationScope"],"mappings":";;;;;AAyBO,SAAS,4BAAA,CAAgC,UAA+B,OAAA,EAAqC;AAClH,EAAA,MAAM,iBAAiBA,sBAAA,EAAkB;AAEzC,EAAA,MAAM,YAAA,GAAe,mBAAmBC,6BAAA,EAAyB;AACjE,EAAA,MAAM,iBAAA,GAAoB,YAAA,GAAe,cAAA,CAAe,KAAA,EAAM,GAAI,cAAA;AAElE,EAAA,IAAI,YAAA,EAAc;AAChB,IAAAC,oCAAA,CAAmB,iBAAA,EAAmB,EAAE,GAAA,EAAK,OAAA,EAAS,CAAA;AAAA,EACxD;AAEA,EAAA,OAAOC,uBAAA,CAAmB,iBAAA,EAAmB,MAAM,QAAA,CAAS,iBAAiB,CAAC,CAAA;AAChF;;;;"}
@@ -0,0 +1,15 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+
5
+ const PROPAGATE_TO_NONE = () => false;
6
+ function createRpcPropagationResolver(options) {
7
+ const bindings = options?.rpcTracePropagationBindings;
8
+ if (!bindings?.length) {
9
+ return PROPAGATE_TO_NONE;
10
+ }
11
+ return (bindingName) => core.matchesTracePropagationTargets(bindingName, bindings, true);
12
+ }
13
+
14
+ exports.createRpcPropagationResolver = createRpcPropagationResolver;
15
+ //# 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":["matchesTracePropagationTargets"],"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,KAAwBA,mCAAA,CAA+B,WAAA,EAAa,UAAU,IAAI,CAAA;AAC5F;;;;"}
@@ -76,7 +76,8 @@ function sentryCloudflareAutoInstrumentPlugin(options = {}) {
76
76
  classWrappers,
77
77
  agentClasses,
78
78
  optionsFn,
79
- optionsImport
79
+ optionsImport,
80
+ sameWorkerBindings: wranglerConfig$1.sameWorkerBindings
80
81
  });
81
82
  const wrappedClasses = result?.wrappedClasses ?? /* @__PURE__ */ new Set();
82
83
  const missing = [...classWrappers.keys()].filter((name) => !wrappedClasses.has(name));
@@ -1 +1 @@
1
- {"version":3,"file":"autoInstrument.js","sources":["../../../../src/vite/autoInstrument.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport { collectAgentCandidates, detectAgentClasses, type ModuleResolver } from './agentClass';\nimport { buildOptionsImport, ENV_FALLBACK_OPTIONS_FN, resolveInstrumentFile } from './instrumentFile';\nimport { applyAutoInstrumentTransforms, type ClassWrapperKind, type ProgramBody } from './transform';\nimport { resolveWranglerConfig, type WranglerConfig } from './wranglerConfig';\n\n// Vite normalizes module IDs to posix separators even on Windows, while\n// `path.resolve` yields backslashes there — normalize before comparing.\nfunction normalizePath(path: string): string {\n return path.replace(/\\\\/g, '/');\n}\n\n// Extensions the entry-module match may tolerate swapping (e.g. wrangler's\n// `main` says `.ts` but the served module is `.js`). Anything else — `.css`,\n// `.html`, … — sharing the entry's basename must never be treated as the entry.\nconst JS_EXTENSION_REGEX = /\\.[cm]?[jt]sx?$/;\n\nexport function sentryCloudflareAutoInstrumentPlugin(options: { wranglerConfigPath?: string } = {}) {\n let wranglerConfig: WranglerConfig | undefined;\n let entryFilePath: string | undefined;\n\n let optionsFn = ENV_FALLBACK_OPTIONS_FN;\n let optionsImport: string | undefined;\n\n return {\n name: 'sentry-cloudflare-auto-instrument',\n\n configResolved(config: { root: string; logger?: { warn(msg: string): void } }): void {\n const result = resolveWranglerConfig(config.root, options.wranglerConfigPath);\n if (!result) {\n // An explicit path that fails is a misconfiguration worth naming;\n // without one, hint at the option so custom-named configs (e.g. a\n // `configPath` handed to @cloudflare/vite-plugin) are discoverable.\n config.logger?.warn(\n options.wranglerConfigPath\n ? `[sentry] Could not find or parse the wrangler config \"${basename(options.wranglerConfigPath)}\" ` +\n '(resolved against the Vite root) — auto-instrumentation disabled.'\n : '[sentry] No parseable wrangler config found — auto-instrumentation disabled. ' +\n 'Set `wranglerConfigPath` if your config uses a custom name.',\n );\n return;\n }\n\n wranglerConfig = result.config;\n if (wranglerConfig.main) {\n // `main` is already absolute (wrangler resolves it); just normalize\n // separators so the entry-module comparison holds on Windows.\n entryFilePath = normalizePath(wranglerConfig.main);\n }\n\n if (entryFilePath) {\n const instrumentFilePath = resolveInstrumentFile(entryFilePath);\n if (instrumentFilePath) {\n const built = buildOptionsImport(entryFilePath, instrumentFilePath);\n optionsFn = built.optionsFn;\n optionsImport = built.importStmt;\n }\n }\n },\n\n async transform(\n this: ModuleResolver & { warn?(msg: string): void; environment?: { name?: string } },\n code: string,\n id: string,\n ): Promise<{ code: string; map: unknown } | undefined> {\n if (!wranglerConfig || !entryFilePath) return undefined;\n\n // The worker entry never belongs to the client (browser) environment.\n // Skipping it keeps a same-basename sibling (e.g. a `src/index.tsx`\n // client entry next to a `src/index.ts` worker) out of the browser bundle.\n if (this.environment?.name === 'client') return undefined;\n\n // Vite may append query/hash params to the module ID.\n const normalizedId = normalizePath(id.replace(/[?#].*$/, ''));\n if (normalizedId !== entryFilePath) {\n // Tolerate a differing JS-flavored extension (e.g. `.js` vs `.ts`).\n if (!JS_EXTENSION_REGEX.test(normalizedId) || !JS_EXTENSION_REGEX.test(entryFilePath)) return undefined;\n if (normalizedId.replace(JS_EXTENSION_REGEX, '') !== entryFilePath.replace(JS_EXTENSION_REGEX, '')) {\n return undefined;\n }\n }\n\n let ast: ProgramBody;\n try {\n ast = this.parse(code);\n } catch {\n // Raw TypeScript or syntax error — esbuild hasn't run yet (unlikely)\n // or the file is genuinely broken. Either way, skip silently.\n return undefined;\n }\n\n const classWrappers = new Map<string, ClassWrapperKind>();\n for (const { className } of wranglerConfig.durableObjects) {\n classWrappers.set(className, 'durableObject');\n }\n for (const { className } of wranglerConfig.workflows) {\n classWrappers.set(className, 'workflow');\n }\n for (const className of wranglerConfig.workerEntrypoints) {\n classWrappers.set(className, 'workerEntrypoint');\n }\n\n // An `agents` Agent is a Durable Object, so wrangler lists it among the DO bindings and only\n // its base-class chain tells the two apart. Detection walks the module graph (base classes\n // usually live in their own file), so it is limited to the configured DO classes.\n //\n // Only `resolve` is handed over — never `load`: awaiting `load()` from inside a transform\n // hook deadlocks the build, since the module can't finish loading while this transform is\n // still pending. `agentClass` reads sibling modules off disk instead.\n const agentCandidates = collectAgentCandidates(\n ast,\n [...classWrappers].filter(([, kind]) => kind === 'durableObject').map(([name]) => name),\n );\n const agentClasses =\n agentCandidates.size > 0\n ? await detectAgentClasses(ast, normalizedId, agentCandidates, {\n parse: code => this.parse(code),\n resolve: this.resolve ? (source, importer) => this.resolve!(source, importer) : undefined,\n })\n : undefined;\n\n // No registration import is injected here: the orchestrion plugin's\n // subscribe-injection makes each bundled package self-register its channel\n // subscriber on the global marker, so wrapping the entry with `withSentry`\n // is all this plugin needs to do.\n const result = applyAutoInstrumentTransforms(code, ast, {\n classWrappers,\n agentClasses,\n optionsFn,\n optionsImport,\n });\n\n const wrappedClasses = result?.wrappedClasses ?? new Set<string>();\n const missing = [...classWrappers.keys()].filter(name => !wrappedClasses.has(name));\n if (missing.length > 0) {\n this.warn?.(\n `[sentry] Could not auto-instrument class(es) ${missing.join(', ')}: no matching exported class ` +\n 'declaration found in the worker entry (re-exports from other modules cannot be wrapped ' +\n 'automatically). Wrap them manually with the matching `instrument*WithSentry` helper.',\n );\n }\n\n return result ?? undefined;\n },\n };\n}\n"],"names":["wranglerConfig","ENV_FALLBACK_OPTIONS_FN","resolveWranglerConfig","basename","resolveInstrumentFile","buildOptionsImport","collectAgentCandidates","detectAgentClasses","code","applyAutoInstrumentTransforms"],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oInstrument.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport { collectAgentCandidates, detectAgentClasses, type ModuleResolver } from './agentClass';\nimport { buildOptionsImport, ENV_FALLBACK_OPTIONS_FN, resolveInstrumentFile } from './instrumentFile';\nimport { applyAutoInstrumentTransforms, type ClassWrapperKind, type ProgramBody } from './transform';\nimport { resolveWranglerConfig, type WranglerConfig } from './wranglerConfig';\n\n// Vite normalizes module IDs to posix separators even on Windows, while\n// `path.resolve` yields backslashes there — normalize before comparing.\nfunction normalizePath(path: string): string {\n return path.replace(/\\\\/g, '/');\n}\n\n// Extensions the entry-module match may tolerate swapping (e.g. wrangler's\n// `main` says `.ts` but the served module is `.js`). Anything else — `.css`,\n// `.html`, … — sharing the entry's basename must never be treated as the entry.\nconst JS_EXTENSION_REGEX = /\\.[cm]?[jt]sx?$/;\n\nexport function sentryCloudflareAutoInstrumentPlugin(options: { wranglerConfigPath?: string } = {}) {\n let wranglerConfig: WranglerConfig | undefined;\n let entryFilePath: string | undefined;\n\n let optionsFn = ENV_FALLBACK_OPTIONS_FN;\n let optionsImport: string | undefined;\n\n return {\n name: 'sentry-cloudflare-auto-instrument',\n\n configResolved(config: { root: string; logger?: { warn(msg: string): void } }): void {\n const result = resolveWranglerConfig(config.root, options.wranglerConfigPath);\n if (!result) {\n // An explicit path that fails is a misconfiguration worth naming;\n // without one, hint at the option so custom-named configs (e.g. a\n // `configPath` handed to @cloudflare/vite-plugin) are discoverable.\n config.logger?.warn(\n options.wranglerConfigPath\n ? `[sentry] Could not find or parse the wrangler config \"${basename(options.wranglerConfigPath)}\" ` +\n '(resolved against the Vite root) — auto-instrumentation disabled.'\n : '[sentry] No parseable wrangler config found — auto-instrumentation disabled. ' +\n 'Set `wranglerConfigPath` if your config uses a custom name.',\n );\n return;\n }\n\n wranglerConfig = result.config;\n if (wranglerConfig.main) {\n // `main` is already absolute (wrangler resolves it); just normalize\n // separators so the entry-module comparison holds on Windows.\n entryFilePath = normalizePath(wranglerConfig.main);\n }\n\n if (entryFilePath) {\n const instrumentFilePath = resolveInstrumentFile(entryFilePath);\n if (instrumentFilePath) {\n const built = buildOptionsImport(entryFilePath, instrumentFilePath);\n optionsFn = built.optionsFn;\n optionsImport = built.importStmt;\n }\n }\n },\n\n async transform(\n this: ModuleResolver & { warn?(msg: string): void; environment?: { name?: string } },\n code: string,\n id: string,\n ): Promise<{ code: string; map: unknown } | undefined> {\n if (!wranglerConfig || !entryFilePath) return undefined;\n\n // The worker entry never belongs to the client (browser) environment.\n // Skipping it keeps a same-basename sibling (e.g. a `src/index.tsx`\n // client entry next to a `src/index.ts` worker) out of the browser bundle.\n if (this.environment?.name === 'client') return undefined;\n\n // Vite may append query/hash params to the module ID.\n const normalizedId = normalizePath(id.replace(/[?#].*$/, ''));\n if (normalizedId !== entryFilePath) {\n // Tolerate a differing JS-flavored extension (e.g. `.js` vs `.ts`).\n if (!JS_EXTENSION_REGEX.test(normalizedId) || !JS_EXTENSION_REGEX.test(entryFilePath)) return undefined;\n if (normalizedId.replace(JS_EXTENSION_REGEX, '') !== entryFilePath.replace(JS_EXTENSION_REGEX, '')) {\n return undefined;\n }\n }\n\n let ast: ProgramBody;\n try {\n ast = this.parse(code);\n } catch {\n // Raw TypeScript or syntax error — esbuild hasn't run yet (unlikely)\n // or the file is genuinely broken. Either way, skip silently.\n return undefined;\n }\n\n const classWrappers = new Map<string, ClassWrapperKind>();\n for (const { className } of wranglerConfig.durableObjects) {\n classWrappers.set(className, 'durableObject');\n }\n for (const { className } of wranglerConfig.workflows) {\n classWrappers.set(className, 'workflow');\n }\n for (const className of wranglerConfig.workerEntrypoints) {\n classWrappers.set(className, 'workerEntrypoint');\n }\n\n // An `agents` Agent is a Durable Object, so wrangler lists it among the DO bindings and only\n // its base-class chain tells the two apart. Detection walks the module graph (base classes\n // usually live in their own file), so it is limited to the configured DO classes.\n //\n // Only `resolve` is handed over — never `load`: awaiting `load()` from inside a transform\n // hook deadlocks the build, since the module can't finish loading while this transform is\n // still pending. `agentClass` reads sibling modules off disk instead.\n const agentCandidates = collectAgentCandidates(\n ast,\n [...classWrappers].filter(([, kind]) => kind === 'durableObject').map(([name]) => name),\n );\n const agentClasses =\n agentCandidates.size > 0\n ? await detectAgentClasses(ast, normalizedId, agentCandidates, {\n parse: code => this.parse(code),\n resolve: this.resolve ? (source, importer) => this.resolve!(source, importer) : undefined,\n })\n : undefined;\n\n // No registration import is injected here: the orchestrion plugin's\n // subscribe-injection makes each bundled package self-register its channel\n // subscriber on the global marker, so wrapping the entry with `withSentry`\n // is all this plugin needs to do.\n const result = applyAutoInstrumentTransforms(code, ast, {\n classWrappers,\n agentClasses,\n optionsFn,\n optionsImport,\n sameWorkerBindings: wranglerConfig.sameWorkerBindings,\n });\n\n const wrappedClasses = result?.wrappedClasses ?? new Set<string>();\n const missing = [...classWrappers.keys()].filter(name => !wrappedClasses.has(name));\n if (missing.length > 0) {\n this.warn?.(\n `[sentry] Could not auto-instrument class(es) ${missing.join(', ')}: no matching exported class ` +\n 'declaration found in the worker entry (re-exports from other modules cannot be wrapped ' +\n 'automatically). Wrap them manually with the matching `instrument*WithSentry` helper.',\n );\n }\n\n return result ?? undefined;\n },\n };\n}\n"],"names":["wranglerConfig","ENV_FALLBACK_OPTIONS_FN","resolveWranglerConfig","basename","resolveInstrumentFile","buildOptionsImport","collectAgentCandidates","detectAgentClasses","code","applyAutoInstrumentTransforms"],"mappings":";;;;;;;;AAQA,SAAS,cAAc,IAAA,EAAsB;AAC3C,EAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,GAAG,CAAA;AAChC;AAKA,MAAM,kBAAA,GAAqB,iBAAA;AAEpB,SAAS,oCAAA,CAAqC,OAAA,GAA2C,EAAC,EAAG;AAClG,EAAA,IAAIA,gBAAA;AACJ,EAAA,IAAI,aAAA;AAEJ,EAAA,IAAI,SAAA,GAAYC,sCAAA;AAChB,EAAA,IAAI,aAAA;AAEJ,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,mCAAA;A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AMA,KAAI,CAAA;AAAA,QAC9B,OAAA,EAAS,IAAA,CAAK,OAAA,GAAU,CAAC,MAAA,EAAQ,aAAa,IAAA,CAAK,OAAA,CAAS,MAAA,EAAQ,QAAQ,CAAA,GAAI;AAAA,OACjF,CAAA,GACD,MAAA;AAMN,MAAA,MAAM,MAAA,GAASC,uCAAA,CAA8B,IAAA,EAAM,GAAA,EAAK;AAAA,QACtD,aAAA;AAAA,QACA,YAAA;AAAA,QACA,SAAA;AAAA,QACA,aAAA;AAAA,QACA,oBAAoBT,gBAAA,CAAe;AAAA,OACpC,CAAA;AAED,MAAA,MAAM,cAAA,GAAiB,MAAA,EAAQ,cAAA,oBAAkB,IAAI,GAAA,EAAY;AACjE,MAAA,MAAM,OAAA,GAAU,CAAC,GAAG,aAAA,CAAc,IAAA,EAAM,CAAA,CAAE,MAAA,CAAO,CAAA,IAAA,KAAQ,CAAC,cAAA,CAAe,GAAA,CAAI,IAAI,CAAC,CAAA;AAClF,MAAA,IAAI,OAAA,CAAQ,SAAS,CAAA,EAAG;AACtB,QAAA,IAAA,CAAK,IAAA;AAAA,UACH,CAAA,6CAAA,EAAgD,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAC,CAAA,0MAAA;AAAA,SAGpE;AAAA,MACF;AAEA,MAAA,OAAO,MAAA,IAAU,MAAA;AAAA,IACnB;AAAA,GACF;AACF;;;;"}
@@ -8,7 +8,7 @@ function sentryCloudflareVitePlugin(options = {}) {
8
8
  vite.sentryOrchestrionPlugin({
9
9
  buildTimeInstrumentation: options.buildTimeInstrumentation
10
10
  }),
11
- ...options._experimental?.autoInstrumentation ? [autoInstrument.sentryCloudflareAutoInstrumentPlugin({ wranglerConfigPath: options.wranglerConfigPath })] : []
11
+ ...options.autoInstrumentation !== false ? [autoInstrument.sentryCloudflareAutoInstrumentPlugin({ wranglerConfigPath: options.wranglerConfigPath })] : []
12
12
  ];
13
13
  }
14
14
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/vite/index.ts"],"sourcesContent":["// Published ESM-only via the `@sentry/cloudflare/vite` subpath export:\n// `@sentry/server-utils/orchestrion/vite` exposes no `require` condition, so a\n// CJS entry here would fail at resolution time (ERR_PACKAGE_PATH_NOT_EXPORTED).\n// The CJS rollup variant still emits this file, but `package.json` doesn't\n// expose it — same setup as `@sentry/server-utils/orchestrion/vite` itself.\nimport { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/vite';\nimport { sentryCloudflareAutoInstrumentPlugin } from './autoInstrument';\n\n/**\n * Options for {@link sentryCloudflareVitePlugin}.\n */\nexport interface SentryCloudflareVitePluginOptions {\n /**\n * Path to the wrangler config, relative to the Vite root (or absolute).\n * Set this when your config doesn't use a default name — e.g. when you\n * pass `configPath: './wrangler.agent.jsonc'` to `@cloudflare/vite-plugin`,\n * which the Sentry plugin cannot see. When set, only this file is read\n * (no default-name probing), and a warning is emitted if it is missing or\n * unparseable.\n *\n * @default undefined (probes `wrangler.json`, `wrangler.jsonc`, `wrangler.toml` at the Vite root)\n */\n wranglerConfigPath?: string;\n /**\n * Build-time automatic instrumentation of supported dependencies (e.g.\n * database clients like `mysql`) so the Sentry Cloudflare SDK can trace them\n * without monkey-patching, which wouldn't work in workerd anyway.\n *\n * When enabled, the plugin injects `diagnostics_channel.tracingChannel` calls\n * into the bundled packages and, next to each, a snippet that registers the\n * matching Sentry channel-subscriber factory on the global marker, which the\n * SDK picks up in `Sentry.withSentry()`. Both `vite build` and `vite dev` are\n * instrumented. Set to `false` to opt out.\n *\n * @default true\n */\n buildTimeInstrumentation?: boolean;\n /**\n * Experimental options that may change or be removed without notice.\n */\n _experimental?: {\n /**\n * Automatically wraps your Worker at build time so you don't have to edit\n * your entry: the plugin reads your wrangler config, wraps the default\n * export with `Sentry.withSentry()` (sourcing options from a co-located\n * `instrument.*` file, falling back to env), and wraps any configured\n * Durable Object class with `instrumentDurableObjectWithSentry`. Both\n * `vite build` and `vite dev` are instrumented.\n *\n * @default false\n * @experimental May change or be removed in any release.\n */\n autoInstrumentation?: boolean;\n };\n}\n\n/**\n * Sentry Vite plugin for Cloudflare Workers.\n *\n * Add this plugin to your Vite configuration to enable additional Sentry\n * instrumentation for Cloudflare Workers built with Vite. Configure the Sentry\n * SDK in your Worker as usual with `Sentry.withSentry()`.\n *\n * By default, the plugin build-time instruments supported dependencies (such as\n * database clients) so they are traced without changing your application code.\n * Opt out with `buildTimeInstrumentation: false`.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { cloudflare } from '@cloudflare/vite-plugin';\n * import { sentryCloudflareVitePlugin } from '@sentry/cloudflare/vite';\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * plugins: [cloudflare(), sentryCloudflareVitePlugin()],\n * });\n * ```\n */\nexport function sentryCloudflareVitePlugin(options: SentryCloudflareVitePluginOptions = {}): Array<{ name: string }> {\n return [\n sentryOrchestrionPlugin({\n buildTimeInstrumentation: options.buildTimeInstrumentation,\n }),\n ...(options._experimental?.autoInstrumentation\n ? [sentryCloudflareAutoInstrumentPlugin({ wranglerConfigPath: options.wranglerConfigPath })]\n : []),\n ];\n}\n"],"names":["sentryOrchestrionPlugin","sentryCloudflareAutoInstrumentPlugin"],"mappings":";;;;;AA+EO,SAAS,0BAAA,CAA2B,OAAA,GAA6C,EAAC,EAA4B;AACnH,EAAA,OAAO;AAAA,IACLA,4BAAA,CAAwB;AAAA,MACtB,0BAA0B,OAAA,CAAQ;AAAA,KACnC,CAAA;AAAA,IACD,GAAI,OAAA,CAAQ,aAAA,EAAe,mBAAA,GACvB,CAACC,mDAAA,CAAqC,EAAE,kBAAA,EAAoB,OAAA,CAAQ,kBAAA,EAAoB,CAAC,IACzF;AAAC,GACP;AACF;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/vite/index.ts"],"sourcesContent":["// Published ESM-only via the `@sentry/cloudflare/vite` subpath export:\n// `@sentry/server-utils/orchestrion/vite` exposes no `require` condition, so a\n// CJS entry here would fail at resolution time (ERR_PACKAGE_PATH_NOT_EXPORTED).\n// The CJS rollup variant still emits this file, but `package.json` doesn't\n// expose it — same setup as `@sentry/server-utils/orchestrion/vite` itself.\nimport { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/vite';\nimport { sentryCloudflareAutoInstrumentPlugin } from './autoInstrument';\n\n/**\n * Options for {@link sentryCloudflareVitePlugin}.\n */\nexport interface SentryCloudflareVitePluginOptions {\n /**\n * Path to the wrangler config, relative to the Vite root (or absolute).\n * Set this when your config doesn't use a default name — e.g. when you\n * pass `configPath: './wrangler.agent.jsonc'` to `@cloudflare/vite-plugin`,\n * which the Sentry plugin cannot see. When set, only this file is read\n * (no default-name probing), and a warning is emitted if it is missing or\n * unparseable.\n *\n * @default undefined (probes `wrangler.json`, `wrangler.jsonc`, `wrangler.toml` at the Vite root)\n */\n wranglerConfigPath?: string;\n /**\n * Build-time automatic instrumentation of supported dependencies (e.g.\n * database clients like `mysql`) so the Sentry Cloudflare SDK can trace them\n * without monkey-patching, which wouldn't work in workerd anyway.\n *\n * When enabled, the plugin injects `diagnostics_channel.tracingChannel` calls\n * into the bundled packages and, next to each, a snippet that registers the\n * matching Sentry channel-subscriber factory on the global marker, which the\n * SDK picks up in `Sentry.withSentry()`. Both `vite build` and `vite dev` are\n * instrumented. Set to `false` to opt out.\n *\n * @default true\n */\n buildTimeInstrumentation?: boolean;\n /**\n * Automatically wraps your Worker at build time so you don't have to edit\n * your entry: the plugin reads your wrangler config, wraps the default\n * export with `Sentry.withSentry()` (sourcing options from a co-located\n * `instrument.*` file, falling back to env), and wraps any configured\n * Durable Object class with `instrumentDurableObjectWithSentry`. Both\n * `vite build` and `vite dev` are instrumented. Already-wrapped entries are\n * left alone, so this is safe alongside manual instrumentation. Set to\n * `false` to opt out.\n *\n * The plugin also adds the bindings that resolve to the wrapped classes (this worker's own\n * Durable Objects and self service bindings) to `rpcTracePropagationBindings`. Bindings to\n * other workers stay opt-in, their receivers may not run Sentry.\n *\n * @default true\n */\n autoInstrumentation?: boolean;\n}\n\n/**\n * Sentry Vite plugin for Cloudflare Workers.\n *\n * Add this plugin to your Vite configuration to enable additional Sentry\n * instrumentation for Cloudflare Workers built with Vite.\n *\n * By default, the plugin\n * - build-time instruments supported dependencies (such as database clients) so\n * they are traced without changing your application code — opt out with\n * `buildTimeInstrumentation: false`, and\n * - wraps your Worker entry (and any Durable Object, Workflow or\n * WorkerEntrypoint class in your wrangler config) with the matching Sentry\n * helper — opt out with `autoInstrumentation: false` and call\n * `Sentry.withSentry()` yourself.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { cloudflare } from '@cloudflare/vite-plugin';\n * import { sentryCloudflareVitePlugin } from '@sentry/cloudflare/vite';\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * plugins: [cloudflare(), sentryCloudflareVitePlugin()],\n * });\n * ```\n */\nexport function sentryCloudflareVitePlugin(options: SentryCloudflareVitePluginOptions = {}): Array<{ name: string }> {\n return [\n sentryOrchestrionPlugin({\n buildTimeInstrumentation: options.buildTimeInstrumentation,\n }),\n ...(options.autoInstrumentation !== false\n ? [sentryCloudflareAutoInstrumentPlugin({ wranglerConfigPath: options.wranglerConfigPath })]\n : []),\n ];\n}\n"],"names":["sentryOrchestrionPlugin","sentryCloudflareAutoInstrumentPlugin"],"mappings":";;;;;AAmFO,SAAS,0BAAA,CAA2B,OAAA,GAA6C,EAAC,EAA4B;AACnH,EAAA,OAAO;AAAA,IACLA,4BAAA,CAAwB;AAAA,MACtB,0BAA0B,OAAA,CAAQ;AAAA,KACnC,CAAA;AAAA,IACD,GAAI,OAAA,CAAQ,mBAAA,KAAwB,KAAA,GAChC,CAACC,mDAAA,CAAqC,EAAE,kBAAA,EAAoB,OAAA,CAAQ,kBAAA,EAAoB,CAAC,IACzF;AAAC,GACP;AACF;;;;"}