@sentry/cloudflare 10.70.0 → 11.0.0-alpha.1

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 (756) hide show
  1. package/README.md +3 -7
  2. package/build/cjs/{sdk.js → dev/baseSdk.js} +27 -17
  3. package/build/cjs/dev/baseSdk.js.map +1 -0
  4. package/build/cjs/dev/client.js.map +1 -0
  5. package/build/cjs/dev/debug-build.js.map +1 -0
  6. package/build/cjs/dev/defineCloudflareOptions.js.map +1 -0
  7. package/build/cjs/{durableobject.js → dev/durableobject.js} +21 -20
  8. package/build/cjs/dev/durableobject.js.map +1 -0
  9. package/build/cjs/dev/flush.js.map +1 -0
  10. package/build/cjs/{index.js → dev/index.js} +16 -17
  11. package/build/cjs/{index.js.map → dev/index.js.map} +1 -1
  12. package/build/cjs/dev/instrument.js.map +1 -0
  13. package/build/cjs/dev/instrumentations/agents/index.js.map +1 -0
  14. package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
  15. package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
  16. package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
  17. package/build/cjs/{instrumentations → dev/instrumentations}/agents/types.js +4 -4
  18. package/build/cjs/dev/instrumentations/agents/types.js.map +1 -0
  19. package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
  20. package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
  21. package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
  22. package/build/cjs/dev/instrumentations/instrumentSqlStorage.js.map +1 -0
  23. package/build/cjs/{instrumentations → dev/instrumentations}/instrumentWorkerEntrypoint.js +3 -3
  24. package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
  25. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentD1.js +0 -4
  26. package/build/cjs/dev/instrumentations/worker/instrumentD1.js.map +1 -0
  27. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentEmail.js +3 -1
  28. package/build/cjs/dev/instrumentations/worker/instrumentEmail.js.map +1 -0
  29. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentEnv.js +3 -4
  30. package/build/cjs/dev/instrumentations/worker/instrumentEnv.js.map +1 -0
  31. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentFetch.js +9 -3
  32. package/build/cjs/dev/instrumentations/worker/instrumentFetch.js.map +1 -0
  33. package/build/cjs/dev/instrumentations/worker/instrumentFetcher.js.map +1 -0
  34. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentQueue.js +3 -2
  35. package/build/cjs/dev/instrumentations/worker/instrumentQueue.js.map +1 -0
  36. package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
  37. package/build/cjs/dev/instrumentations/worker/instrumentR2.js.map +1 -0
  38. package/build/cjs/dev/instrumentations/worker/instrumentRateLimit.js.map +1 -0
  39. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentScheduled.js +3 -1
  40. package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js.map +1 -0
  41. package/build/cjs/dev/instrumentations/worker/instrumentTail.js.map +1 -0
  42. package/build/cjs/{integrations → dev/integrations}/fetch.js +1 -1
  43. package/build/cjs/dev/integrations/fetch.js.map +1 -0
  44. package/build/cjs/{integrations → dev/integrations}/httpServer.js +5 -4
  45. package/build/cjs/dev/integrations/httpServer.js.map +1 -0
  46. package/build/cjs/dev/integrations/spotlight.js.map +1 -0
  47. package/build/cjs/{nodejs_compat → dev}/integrations/tracing/vercelai.js +6 -6
  48. package/build/cjs/dev/integrations/tracing/vercelai.js.map +1 -0
  49. package/build/cjs/dev/opentelemetry/tracer.js.map +1 -0
  50. package/build/cjs/{options.js → dev/options.js} +8 -0
  51. package/build/cjs/dev/options.js.map +1 -0
  52. package/build/cjs/{pages-plugin.js → dev/pages-plugin.js} +8 -3
  53. package/build/cjs/dev/pages-plugin.js.map +1 -0
  54. package/build/cjs/{request.js → dev/request.js} +20 -10
  55. package/build/cjs/dev/request.js.map +1 -0
  56. package/build/cjs/dev/scope-utils.js.map +1 -0
  57. package/build/cjs/dev/sdk.js +19 -0
  58. package/build/cjs/dev/sdk.js.map +1 -0
  59. package/build/cjs/dev/transport.js.map +1 -0
  60. package/build/cjs/{utils → dev/utils}/instrumentContext.js +8 -13
  61. package/build/cjs/dev/utils/instrumentContext.js.map +1 -0
  62. package/build/cjs/dev/utils/internalSqlQuery.js.map +1 -0
  63. package/build/cjs/dev/utils/internalStorageKey.js.map +1 -0
  64. package/build/cjs/dev/utils/invocationScope.js.map +1 -0
  65. package/build/cjs/dev/utils/isBinding.js.map +1 -0
  66. package/build/cjs/dev/utils/isCloudflareClass.js.map +1 -0
  67. package/build/cjs/dev/utils/rpcMeta.js.map +1 -0
  68. package/build/cjs/dev/utils/streaming.js.map +1 -0
  69. package/build/cjs/dev/utils/traceLinks.js.map +1 -0
  70. package/build/cjs/dev/vendor/stacktrace.js.map +1 -0
  71. package/build/cjs/dev/vite/agentClass.js.map +1 -0
  72. package/build/cjs/dev/vite/autoInstrument.js.map +1 -0
  73. package/build/cjs/{vite → dev/vite}/index.js +4 -2
  74. package/build/cjs/dev/vite/index.js.map +1 -0
  75. package/build/cjs/dev/vite/instrumentFile.js.map +1 -0
  76. package/build/cjs/dev/vite/moduleShape.js.map +1 -0
  77. package/build/cjs/dev/vite/transform.js.map +1 -0
  78. package/build/cjs/dev/vite/workerEntrypoint.js.map +1 -0
  79. package/build/cjs/dev/vite/wranglerConfig.js.map +1 -0
  80. package/build/cjs/{withSentry.js → dev/withSentry.js} +2 -19
  81. package/build/cjs/dev/withSentry.js.map +1 -0
  82. package/build/cjs/{workflows.js → dev/workflows.js} +8 -3
  83. package/build/cjs/dev/workflows.js.map +1 -0
  84. package/build/cjs/dev/wrapMethodWithSentry.js.map +1 -0
  85. package/build/cjs/prod/baseSdk.js +73 -0
  86. package/build/cjs/prod/baseSdk.js.map +1 -0
  87. package/build/cjs/prod/client.js +122 -0
  88. package/build/cjs/prod/client.js.map +1 -0
  89. package/build/cjs/prod/debug-build.js +6 -0
  90. package/build/cjs/prod/debug-build.js.map +1 -0
  91. package/build/cjs/prod/defineCloudflareOptions.js +11 -0
  92. package/build/cjs/prod/defineCloudflareOptions.js.map +1 -0
  93. package/build/cjs/prod/durableobject.js +234 -0
  94. package/build/cjs/prod/durableobject.js.map +1 -0
  95. package/build/cjs/prod/flush.js +87 -0
  96. package/build/cjs/prod/flush.js.map +1 -0
  97. package/build/cjs/{nodejs_compat → prod}/index.js +34 -37
  98. package/build/cjs/{nodejs_compat → prod}/index.js.map +1 -1
  99. package/build/cjs/prod/instrument.js +52 -0
  100. package/build/cjs/prod/instrument.js.map +1 -0
  101. package/build/cjs/prod/instrumentations/agents/index.js +16 -0
  102. package/build/cjs/prod/instrumentations/agents/index.js.map +1 -0
  103. package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js +52 -0
  104. package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
  105. package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js +19 -0
  106. package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
  107. package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js +31 -0
  108. package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
  109. package/build/cjs/prod/instrumentations/agents/types.js +77 -0
  110. package/build/cjs/prod/instrumentations/agents/types.js.map +1 -0
  111. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js +41 -0
  112. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
  113. package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js +72 -0
  114. package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
  115. package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +40 -0
  116. package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
  117. package/build/cjs/prod/instrumentations/instrumentSqlStorage.js +42 -0
  118. package/build/cjs/prod/instrumentations/instrumentSqlStorage.js.map +1 -0
  119. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js +139 -0
  120. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
  121. package/build/cjs/prod/instrumentations/worker/instrumentD1.js +161 -0
  122. package/build/cjs/prod/instrumentations/worker/instrumentD1.js.map +1 -0
  123. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js +63 -0
  124. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js.map +1 -0
  125. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js +90 -0
  126. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js.map +1 -0
  127. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js +54 -0
  128. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js.map +1 -0
  129. package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js +24 -0
  130. package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js.map +1 -0
  131. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js +82 -0
  132. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js.map +1 -0
  133. package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js +80 -0
  134. package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
  135. package/build/cjs/prod/instrumentations/worker/instrumentR2.js +124 -0
  136. package/build/cjs/prod/instrumentations/worker/instrumentR2.js.map +1 -0
  137. package/build/cjs/prod/instrumentations/worker/instrumentRateLimit.js +29 -0
  138. package/build/cjs/prod/instrumentations/worker/instrumentRateLimit.js.map +1 -0
  139. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js +78 -0
  140. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js.map +1 -0
  141. package/build/cjs/prod/instrumentations/worker/instrumentTail.js +60 -0
  142. package/build/cjs/prod/instrumentations/worker/instrumentTail.js.map +1 -0
  143. package/build/cjs/prod/integrations/fetch.js +119 -0
  144. package/build/cjs/prod/integrations/fetch.js.map +1 -0
  145. package/build/cjs/prod/integrations/httpServer.js +36 -0
  146. package/build/cjs/prod/integrations/httpServer.js.map +1 -0
  147. package/build/cjs/prod/integrations/spotlight.js +64 -0
  148. package/build/cjs/prod/integrations/spotlight.js.map +1 -0
  149. package/build/cjs/{integrations → prod/integrations}/tracing/vercelai.js +5 -5
  150. package/build/cjs/prod/integrations/tracing/vercelai.js.map +1 -0
  151. package/build/cjs/prod/opentelemetry/tracer.js +49 -0
  152. package/build/cjs/prod/opentelemetry/tracer.js.map +1 -0
  153. package/build/cjs/prod/options.js +33 -0
  154. package/build/cjs/prod/options.js.map +1 -0
  155. package/build/cjs/prod/pages-plugin.js +24 -0
  156. package/build/cjs/prod/pages-plugin.js.map +1 -0
  157. package/build/cjs/prod/request.js +132 -0
  158. package/build/cjs/prod/request.js.map +1 -0
  159. package/build/cjs/prod/scope-utils.js +22 -0
  160. package/build/cjs/prod/scope-utils.js.map +1 -0
  161. package/build/cjs/prod/sdk.js +19 -0
  162. package/build/cjs/prod/sdk.js.map +1 -0
  163. package/build/cjs/prod/transport.js +75 -0
  164. package/build/cjs/prod/transport.js.map +1 -0
  165. package/build/cjs/prod/utils/instrumentContext.js +63 -0
  166. package/build/cjs/prod/utils/instrumentContext.js.map +1 -0
  167. package/build/cjs/prod/utils/internalSqlQuery.js +25 -0
  168. package/build/cjs/prod/utils/internalSqlQuery.js.map +1 -0
  169. package/build/cjs/prod/utils/internalStorageKey.js +44 -0
  170. package/build/cjs/prod/utils/internalStorageKey.js.map +1 -0
  171. package/build/cjs/prod/utils/invocationScope.js +12 -0
  172. package/build/cjs/prod/utils/invocationScope.js.map +1 -0
  173. package/build/cjs/prod/utils/isBinding.js +37 -0
  174. package/build/cjs/prod/utils/isBinding.js.map +1 -0
  175. package/build/cjs/prod/utils/isCloudflareClass.js +23 -0
  176. package/build/cjs/prod/utils/isCloudflareClass.js.map +1 -0
  177. package/build/cjs/prod/utils/rpcMeta.js +39 -0
  178. package/build/cjs/prod/utils/rpcMeta.js.map +1 -0
  179. package/build/cjs/prod/utils/streaming.js +16 -0
  180. package/build/cjs/prod/utils/streaming.js.map +1 -0
  181. package/build/cjs/prod/utils/traceLinks.js +54 -0
  182. package/build/cjs/prod/utils/traceLinks.js.map +1 -0
  183. package/build/cjs/prod/vendor/stacktrace.js +28 -0
  184. package/build/cjs/prod/vendor/stacktrace.js.map +1 -0
  185. package/build/cjs/prod/vite/agentClass.js +114 -0
  186. package/build/cjs/prod/vite/agentClass.js.map +1 -0
  187. package/build/cjs/prod/vite/autoInstrument.js +94 -0
  188. package/build/cjs/prod/vite/autoInstrument.js.map +1 -0
  189. package/build/cjs/prod/vite/index.js +16 -0
  190. package/build/cjs/prod/vite/index.js.map +1 -0
  191. package/build/cjs/prod/vite/instrumentFile.js +31 -0
  192. package/build/cjs/prod/vite/instrumentFile.js.map +1 -0
  193. package/build/cjs/prod/vite/moduleShape.js +231 -0
  194. package/build/cjs/prod/vite/moduleShape.js.map +1 -0
  195. package/build/cjs/prod/vite/transform.js +149 -0
  196. package/build/cjs/prod/vite/transform.js.map +1 -0
  197. package/build/cjs/prod/vite/workerEntrypoint.js +66 -0
  198. package/build/cjs/prod/vite/workerEntrypoint.js.map +1 -0
  199. package/build/cjs/prod/vite/wranglerConfig.js +54 -0
  200. package/build/cjs/prod/vite/wranglerConfig.js.map +1 -0
  201. package/build/cjs/prod/withSentry.js +29 -0
  202. package/build/cjs/prod/withSentry.js.map +1 -0
  203. package/build/cjs/prod/workflows.js +139 -0
  204. package/build/cjs/prod/workflows.js.map +1 -0
  205. package/build/cjs/prod/wrapMethodWithSentry.js +134 -0
  206. package/build/cjs/prod/wrapMethodWithSentry.js.map +1 -0
  207. package/build/esm/{sdk.js → dev/baseSdk.js} +26 -17
  208. package/build/esm/dev/baseSdk.js.map +1 -0
  209. package/build/esm/dev/client.js.map +1 -0
  210. package/build/esm/dev/debug-build.js.map +1 -0
  211. package/build/esm/dev/defineCloudflareOptions.js.map +1 -0
  212. package/build/esm/{durableobject.js → dev/durableobject.js} +21 -20
  213. package/build/esm/dev/durableobject.js.map +1 -0
  214. package/build/esm/dev/flush.js.map +1 -0
  215. package/build/esm/dev/index.js +15 -0
  216. package/build/esm/{index.js.map → dev/index.js.map} +1 -1
  217. package/build/esm/dev/instrument.js.map +1 -0
  218. package/build/esm/dev/instrumentations/agents/index.js.map +1 -0
  219. package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
  220. package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
  221. package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
  222. package/build/esm/{instrumentations → dev/instrumentations}/agents/types.js +2 -2
  223. package/build/esm/dev/instrumentations/agents/types.js.map +1 -0
  224. package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
  225. package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
  226. package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
  227. package/build/esm/dev/instrumentations/instrumentSqlStorage.js.map +1 -0
  228. package/build/esm/{instrumentations → dev/instrumentations}/instrumentWorkerEntrypoint.js +2 -2
  229. package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
  230. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentD1.js +1 -4
  231. package/build/esm/dev/instrumentations/worker/instrumentD1.js.map +1 -0
  232. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentEmail.js +3 -1
  233. package/build/esm/dev/instrumentations/worker/instrumentEmail.js.map +1 -0
  234. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentEnv.js +3 -4
  235. package/build/esm/dev/instrumentations/worker/instrumentEnv.js.map +1 -0
  236. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentFetch.js +10 -4
  237. package/build/esm/dev/instrumentations/worker/instrumentFetch.js.map +1 -0
  238. package/build/esm/dev/instrumentations/worker/instrumentFetcher.js.map +1 -0
  239. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentQueue.js +4 -3
  240. package/build/esm/dev/instrumentations/worker/instrumentQueue.js.map +1 -0
  241. package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
  242. package/build/esm/dev/instrumentations/worker/instrumentR2.js.map +1 -0
  243. package/build/esm/dev/instrumentations/worker/instrumentRateLimit.js.map +1 -0
  244. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentScheduled.js +3 -1
  245. package/build/esm/dev/instrumentations/worker/instrumentScheduled.js.map +1 -0
  246. package/build/esm/dev/instrumentations/worker/instrumentTail.js.map +1 -0
  247. package/build/esm/{integrations → dev/integrations}/fetch.js +1 -1
  248. package/build/esm/dev/integrations/fetch.js.map +1 -0
  249. package/build/esm/{integrations → dev/integrations}/httpServer.js +5 -4
  250. package/build/esm/dev/integrations/httpServer.js.map +1 -0
  251. package/build/esm/dev/integrations/spotlight.js.map +1 -0
  252. package/build/esm/{integrations → dev/integrations}/tracing/vercelai.js +5 -5
  253. package/build/esm/dev/integrations/tracing/vercelai.js.map +1 -0
  254. package/build/esm/dev/opentelemetry/tracer.js.map +1 -0
  255. package/build/esm/{options.js → dev/options.js} +8 -0
  256. package/build/esm/dev/options.js.map +1 -0
  257. package/build/esm/dev/package.json +1 -0
  258. package/build/esm/{pages-plugin.js → dev/pages-plugin.js} +8 -3
  259. package/build/esm/dev/pages-plugin.js.map +1 -0
  260. package/build/esm/{request.js → dev/request.js} +21 -12
  261. package/build/esm/dev/request.js.map +1 -0
  262. package/build/esm/dev/scope-utils.js.map +1 -0
  263. package/build/esm/dev/sdk.js +16 -0
  264. package/build/esm/dev/sdk.js.map +1 -0
  265. package/build/esm/dev/transport.js.map +1 -0
  266. package/build/esm/{utils → dev/utils}/instrumentContext.js +8 -13
  267. package/build/esm/dev/utils/instrumentContext.js.map +1 -0
  268. package/build/esm/dev/utils/internalSqlQuery.js.map +1 -0
  269. package/build/esm/dev/utils/internalStorageKey.js.map +1 -0
  270. package/build/esm/dev/utils/invocationScope.js.map +1 -0
  271. package/build/esm/dev/utils/isBinding.js.map +1 -0
  272. package/build/esm/dev/utils/isCloudflareClass.js.map +1 -0
  273. package/build/esm/dev/utils/rpcMeta.js.map +1 -0
  274. package/build/esm/dev/utils/streaming.js.map +1 -0
  275. package/build/esm/{utils → dev/utils}/traceLinks.js +1 -1
  276. package/build/esm/dev/utils/traceLinks.js.map +1 -0
  277. package/build/esm/dev/vendor/stacktrace.js.map +1 -0
  278. package/build/esm/dev/vite/agentClass.js.map +1 -0
  279. package/build/esm/dev/vite/autoInstrument.js.map +1 -0
  280. package/build/esm/{vite → dev/vite}/index.js +4 -2
  281. package/build/esm/dev/vite/index.js.map +1 -0
  282. package/build/esm/dev/vite/instrumentFile.js.map +1 -0
  283. package/build/esm/dev/vite/moduleShape.js.map +1 -0
  284. package/build/esm/dev/vite/transform.js.map +1 -0
  285. package/build/esm/dev/vite/workerEntrypoint.js.map +1 -0
  286. package/build/esm/dev/vite/wranglerConfig.js.map +1 -0
  287. package/build/esm/{withSentry.js → dev/withSentry.js} +1 -18
  288. package/build/esm/dev/withSentry.js.map +1 -0
  289. package/build/esm/{workflows.js → dev/workflows.js} +7 -2
  290. package/build/esm/dev/workflows.js.map +1 -0
  291. package/build/esm/dev/wrapMethodWithSentry.js.map +1 -0
  292. package/build/esm/prod/baseSdk.js +69 -0
  293. package/build/esm/prod/baseSdk.js.map +1 -0
  294. package/build/esm/prod/client.js +120 -0
  295. package/build/esm/prod/client.js.map +1 -0
  296. package/build/esm/prod/debug-build.js +4 -0
  297. package/build/esm/prod/debug-build.js.map +1 -0
  298. package/build/esm/prod/defineCloudflareOptions.js +9 -0
  299. package/build/esm/prod/defineCloudflareOptions.js.map +1 -0
  300. package/build/esm/prod/durableobject.js +229 -0
  301. package/build/esm/prod/durableobject.js.map +1 -0
  302. package/build/esm/prod/flush.js +83 -0
  303. package/build/esm/prod/flush.js.map +1 -0
  304. package/build/esm/prod/index.js +15 -0
  305. package/build/esm/{nodejs_compat → prod}/index.js.map +1 -1
  306. package/build/esm/prod/instrument.js +48 -0
  307. package/build/esm/prod/instrument.js.map +1 -0
  308. package/build/esm/prod/instrumentations/agents/index.js +14 -0
  309. package/build/esm/prod/instrumentations/agents/index.js.map +1 -0
  310. package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js +50 -0
  311. package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
  312. package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js +17 -0
  313. package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
  314. package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js +29 -0
  315. package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
  316. package/build/esm/prod/instrumentations/agents/types.js +69 -0
  317. package/build/esm/prod/instrumentations/agents/types.js.map +1 -0
  318. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js +38 -0
  319. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
  320. package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js +70 -0
  321. package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
  322. package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +38 -0
  323. package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
  324. package/build/esm/prod/instrumentations/instrumentSqlStorage.js +40 -0
  325. package/build/esm/prod/instrumentations/instrumentSqlStorage.js.map +1 -0
  326. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js +137 -0
  327. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
  328. package/build/esm/prod/instrumentations/worker/instrumentD1.js +159 -0
  329. package/build/esm/prod/instrumentations/worker/instrumentD1.js.map +1 -0
  330. package/build/esm/prod/instrumentations/worker/instrumentEmail.js +61 -0
  331. package/build/esm/prod/instrumentations/worker/instrumentEmail.js.map +1 -0
  332. package/build/esm/prod/instrumentations/worker/instrumentEnv.js +88 -0
  333. package/build/esm/prod/instrumentations/worker/instrumentEnv.js.map +1 -0
  334. package/build/esm/prod/instrumentations/worker/instrumentFetch.js +51 -0
  335. package/build/esm/prod/instrumentations/worker/instrumentFetch.js.map +1 -0
  336. package/build/esm/prod/instrumentations/worker/instrumentFetcher.js +22 -0
  337. package/build/esm/prod/instrumentations/worker/instrumentFetcher.js.map +1 -0
  338. package/build/esm/prod/instrumentations/worker/instrumentQueue.js +79 -0
  339. package/build/esm/prod/instrumentations/worker/instrumentQueue.js.map +1 -0
  340. package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js +78 -0
  341. package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
  342. package/build/esm/prod/instrumentations/worker/instrumentR2.js +122 -0
  343. package/build/esm/prod/instrumentations/worker/instrumentR2.js.map +1 -0
  344. package/build/esm/prod/instrumentations/worker/instrumentRateLimit.js +27 -0
  345. package/build/esm/prod/instrumentations/worker/instrumentRateLimit.js.map +1 -0
  346. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js +75 -0
  347. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js.map +1 -0
  348. package/build/esm/prod/instrumentations/worker/instrumentTail.js +57 -0
  349. package/build/esm/prod/instrumentations/worker/instrumentTail.js.map +1 -0
  350. package/build/esm/prod/integrations/fetch.js +117 -0
  351. package/build/esm/prod/integrations/fetch.js.map +1 -0
  352. package/build/esm/prod/integrations/httpServer.js +33 -0
  353. package/build/esm/prod/integrations/httpServer.js.map +1 -0
  354. package/build/esm/prod/integrations/spotlight.js +61 -0
  355. package/build/esm/prod/integrations/spotlight.js.map +1 -0
  356. package/build/esm/prod/integrations/tracing/vercelai.js +16 -0
  357. package/build/esm/prod/integrations/tracing/vercelai.js.map +1 -0
  358. package/build/esm/prod/opentelemetry/tracer.js +47 -0
  359. package/build/esm/prod/opentelemetry/tracer.js.map +1 -0
  360. package/build/esm/prod/options.js +31 -0
  361. package/build/esm/prod/options.js.map +1 -0
  362. package/build/esm/prod/package.json +1 -0
  363. package/build/esm/prod/pages-plugin.js +22 -0
  364. package/build/esm/prod/pages-plugin.js.map +1 -0
  365. package/build/esm/prod/request.js +129 -0
  366. package/build/esm/prod/request.js.map +1 -0
  367. package/build/esm/prod/scope-utils.js +18 -0
  368. package/build/esm/prod/scope-utils.js.map +1 -0
  369. package/build/esm/prod/sdk.js +16 -0
  370. package/build/esm/prod/sdk.js.map +1 -0
  371. package/build/esm/prod/transport.js +72 -0
  372. package/build/esm/prod/transport.js.map +1 -0
  373. package/build/esm/prod/utils/instrumentContext.js +61 -0
  374. package/build/esm/prod/utils/instrumentContext.js.map +1 -0
  375. package/build/esm/prod/utils/internalSqlQuery.js +23 -0
  376. package/build/esm/prod/utils/internalSqlQuery.js.map +1 -0
  377. package/build/esm/prod/utils/internalStorageKey.js +41 -0
  378. package/build/esm/prod/utils/internalStorageKey.js.map +1 -0
  379. package/build/esm/prod/utils/invocationScope.js +10 -0
  380. package/build/esm/prod/utils/invocationScope.js.map +1 -0
  381. package/build/esm/prod/utils/isBinding.js +29 -0
  382. package/build/esm/prod/utils/isBinding.js.map +1 -0
  383. package/build/esm/prod/utils/isCloudflareClass.js +21 -0
  384. package/build/esm/prod/utils/isCloudflareClass.js.map +1 -0
  385. package/build/esm/prod/utils/rpcMeta.js +35 -0
  386. package/build/esm/prod/utils/rpcMeta.js.map +1 -0
  387. package/build/esm/prod/utils/streaming.js +14 -0
  388. package/build/esm/prod/utils/streaming.js.map +1 -0
  389. package/build/esm/prod/utils/traceLinks.js +49 -0
  390. package/build/esm/prod/utils/traceLinks.js.map +1 -0
  391. package/build/esm/prod/vendor/stacktrace.js +25 -0
  392. package/build/esm/prod/vendor/stacktrace.js.map +1 -0
  393. package/build/esm/prod/vite/agentClass.js +111 -0
  394. package/build/esm/prod/vite/agentClass.js.map +1 -0
  395. package/build/esm/prod/vite/autoInstrument.js +92 -0
  396. package/build/esm/prod/vite/autoInstrument.js.map +1 -0
  397. package/build/esm/prod/vite/index.js +14 -0
  398. package/build/esm/prod/vite/index.js.map +1 -0
  399. package/build/esm/prod/vite/instrumentFile.js +27 -0
  400. package/build/esm/prod/vite/instrumentFile.js.map +1 -0
  401. package/build/esm/prod/vite/moduleShape.js +227 -0
  402. package/build/esm/prod/vite/moduleShape.js.map +1 -0
  403. package/build/esm/prod/vite/transform.js +147 -0
  404. package/build/esm/prod/vite/transform.js.map +1 -0
  405. package/build/esm/prod/vite/workerEntrypoint.js +64 -0
  406. package/build/esm/prod/vite/workerEntrypoint.js.map +1 -0
  407. package/build/esm/prod/vite/wranglerConfig.js +52 -0
  408. package/build/esm/prod/vite/wranglerConfig.js.map +1 -0
  409. package/build/esm/prod/withSentry.js +27 -0
  410. package/build/esm/prod/withSentry.js.map +1 -0
  411. package/build/esm/prod/workflows.js +136 -0
  412. package/build/esm/prod/workflows.js.map +1 -0
  413. package/build/esm/prod/wrapMethodWithSentry.js +132 -0
  414. package/build/esm/prod/wrapMethodWithSentry.js.map +1 -0
  415. package/build/types/baseSdk.d.ts +28 -0
  416. package/build/types/baseSdk.d.ts.map +1 -0
  417. package/build/types/client.d.ts +12 -39
  418. package/build/types/client.d.ts.map +1 -1
  419. package/build/types/defineCloudflareOptions.d.ts +2 -2
  420. package/build/types/defineCloudflareOptions.d.ts.map +1 -1
  421. package/build/types/durableobject.d.ts +5 -4
  422. package/build/types/durableobject.d.ts.map +1 -1
  423. package/build/types/index.d.ts +3 -5
  424. package/build/types/index.d.ts.map +1 -1
  425. package/build/types/instrumentations/agents/types.d.ts.map +1 -1
  426. package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts.map +1 -1
  427. package/build/types/instrumentations/instrumentSqlStorage.d.ts.map +1 -1
  428. package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts +2 -1
  429. package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts.map +1 -1
  430. package/build/types/instrumentations/worker/instrumentD1.d.ts +0 -16
  431. package/build/types/instrumentations/worker/instrumentD1.d.ts.map +1 -1
  432. package/build/types/instrumentations/worker/instrumentEmail.d.ts +2 -2
  433. package/build/types/instrumentations/worker/instrumentEmail.d.ts.map +1 -1
  434. package/build/types/instrumentations/worker/instrumentEnv.d.ts.map +1 -1
  435. package/build/types/instrumentations/worker/instrumentFetch.d.ts +2 -2
  436. package/build/types/instrumentations/worker/instrumentFetch.d.ts.map +1 -1
  437. package/build/types/instrumentations/worker/instrumentQueue.d.ts +2 -2
  438. package/build/types/instrumentations/worker/instrumentQueue.d.ts.map +1 -1
  439. package/build/types/instrumentations/worker/instrumentScheduled.d.ts +2 -2
  440. package/build/types/instrumentations/worker/instrumentScheduled.d.ts.map +1 -1
  441. package/build/types/instrumentations/worker/instrumentTail.d.ts +2 -2
  442. package/build/types/instrumentations/worker/instrumentTail.d.ts.map +1 -1
  443. package/build/types/integrations/httpServer.d.ts.map +1 -1
  444. package/build/types/integrations/spotlight.d.ts +1 -1
  445. package/build/types/integrations/tracing/vercelai.d.ts +2 -10
  446. package/build/types/integrations/tracing/vercelai.d.ts.map +1 -1
  447. package/build/types/options.d.ts.map +1 -1
  448. package/build/types/pages-plugin.d.ts +1 -1
  449. package/build/types/pages-plugin.d.ts.map +1 -1
  450. package/build/types/request.d.ts +17 -2
  451. package/build/types/request.d.ts.map +1 -1
  452. package/build/types/sdk.d.ts +8 -3
  453. package/build/types/sdk.d.ts.map +1 -1
  454. package/build/types/transport.d.ts.map +1 -1
  455. package/build/types/types.d.ts +85 -0
  456. package/build/types/types.d.ts.map +1 -0
  457. package/build/types/utils/instrumentContext.d.ts.map +1 -1
  458. package/build/types/utils/isCloudflareClass.d.ts +1 -1
  459. package/build/types/utils/isCloudflareClass.d.ts.map +1 -1
  460. package/build/types/vite/autoInstrument.d.ts.map +1 -1
  461. package/build/types/vite/index.d.ts +37 -61
  462. package/build/types/vite/index.d.ts.map +1 -1
  463. package/build/types/withSentry.d.ts +2 -2
  464. package/build/types/withSentry.d.ts.map +1 -1
  465. package/build/types/workflows.d.ts +5 -4
  466. package/build/types/workflows.d.ts.map +1 -1
  467. package/package.json +28 -51
  468. package/build/cjs/async.js +0 -63
  469. package/build/cjs/async.js.map +0 -1
  470. package/build/cjs/client.js.map +0 -1
  471. package/build/cjs/debug-build.js.map +0 -1
  472. package/build/cjs/defineCloudflareOptions.js.map +0 -1
  473. package/build/cjs/durableobject.js.map +0 -1
  474. package/build/cjs/flush.js.map +0 -1
  475. package/build/cjs/instrument.js.map +0 -1
  476. package/build/cjs/instrumentations/agents/index.js.map +0 -1
  477. package/build/cjs/instrumentations/agents/instrumentAgentCallableRpc.js.map +0 -1
  478. package/build/cjs/instrumentations/agents/instrumentAgentRequestConversation.js.map +0 -1
  479. package/build/cjs/instrumentations/agents/instrumentChatAgentConversation.js.map +0 -1
  480. package/build/cjs/instrumentations/agents/types.js.map +0 -1
  481. package/build/cjs/instrumentations/instrumentDurableObjectNamespace.js.map +0 -1
  482. package/build/cjs/instrumentations/instrumentDurableObjectStorage.js.map +0 -1
  483. package/build/cjs/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +0 -1
  484. package/build/cjs/instrumentations/instrumentSqlStorage.js.map +0 -1
  485. package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js.map +0 -1
  486. package/build/cjs/instrumentations/worker/instrumentD1.js.map +0 -1
  487. package/build/cjs/instrumentations/worker/instrumentEmail.js.map +0 -1
  488. package/build/cjs/instrumentations/worker/instrumentEnv.js.map +0 -1
  489. package/build/cjs/instrumentations/worker/instrumentFetch.js.map +0 -1
  490. package/build/cjs/instrumentations/worker/instrumentFetcher.js.map +0 -1
  491. package/build/cjs/instrumentations/worker/instrumentQueue.js.map +0 -1
  492. package/build/cjs/instrumentations/worker/instrumentQueueProducer.js.map +0 -1
  493. package/build/cjs/instrumentations/worker/instrumentR2.js.map +0 -1
  494. package/build/cjs/instrumentations/worker/instrumentRateLimit.js.map +0 -1
  495. package/build/cjs/instrumentations/worker/instrumentScheduled.js.map +0 -1
  496. package/build/cjs/instrumentations/worker/instrumentTail.js.map +0 -1
  497. package/build/cjs/integrations/fetch.js.map +0 -1
  498. package/build/cjs/integrations/hono.js +0 -52
  499. package/build/cjs/integrations/hono.js.map +0 -1
  500. package/build/cjs/integrations/httpServer.js.map +0 -1
  501. package/build/cjs/integrations/spotlight.js.map +0 -1
  502. package/build/cjs/integrations/tracing/vercelai.js.map +0 -1
  503. package/build/cjs/nodejs_compat/integrations/tracing/vercelai.js.map +0 -1
  504. package/build/cjs/opentelemetry/tracer.js.map +0 -1
  505. package/build/cjs/options.js.map +0 -1
  506. package/build/cjs/pages-plugin.js.map +0 -1
  507. package/build/cjs/request.js.map +0 -1
  508. package/build/cjs/scope-utils.js.map +0 -1
  509. package/build/cjs/sdk.js.map +0 -1
  510. package/build/cjs/transport.js.map +0 -1
  511. package/build/cjs/utils/instrumentContext.js.map +0 -1
  512. package/build/cjs/utils/internalSqlQuery.js.map +0 -1
  513. package/build/cjs/utils/internalStorageKey.js.map +0 -1
  514. package/build/cjs/utils/invocationScope.js.map +0 -1
  515. package/build/cjs/utils/isBinding.js.map +0 -1
  516. package/build/cjs/utils/isCloudflareClass.js.map +0 -1
  517. package/build/cjs/utils/rpcMeta.js.map +0 -1
  518. package/build/cjs/utils/rpcOptions.js +0 -26
  519. package/build/cjs/utils/rpcOptions.js.map +0 -1
  520. package/build/cjs/utils/streaming.js.map +0 -1
  521. package/build/cjs/utils/traceLinks.js.map +0 -1
  522. package/build/cjs/vendor/stacktrace.js.map +0 -1
  523. package/build/cjs/vite/agentClass.js.map +0 -1
  524. package/build/cjs/vite/autoInstrument.js.map +0 -1
  525. package/build/cjs/vite/index.js.map +0 -1
  526. package/build/cjs/vite/instrumentFile.js.map +0 -1
  527. package/build/cjs/vite/moduleShape.js.map +0 -1
  528. package/build/cjs/vite/transform.js.map +0 -1
  529. package/build/cjs/vite/workerEntrypoint.js.map +0 -1
  530. package/build/cjs/vite/wranglerConfig.js.map +0 -1
  531. package/build/cjs/withSentry.js.map +0 -1
  532. package/build/cjs/workflows.js.map +0 -1
  533. package/build/cjs/wrapMethodWithSentry.js.map +0 -1
  534. package/build/esm/async.js +0 -61
  535. package/build/esm/async.js.map +0 -1
  536. package/build/esm/client.js.map +0 -1
  537. package/build/esm/debug-build.js.map +0 -1
  538. package/build/esm/defineCloudflareOptions.js.map +0 -1
  539. package/build/esm/durableobject.js.map +0 -1
  540. package/build/esm/flush.js.map +0 -1
  541. package/build/esm/index.js +0 -17
  542. package/build/esm/instrument.js.map +0 -1
  543. package/build/esm/instrumentations/agents/index.js.map +0 -1
  544. package/build/esm/instrumentations/agents/instrumentAgentCallableRpc.js.map +0 -1
  545. package/build/esm/instrumentations/agents/instrumentAgentRequestConversation.js.map +0 -1
  546. package/build/esm/instrumentations/agents/instrumentChatAgentConversation.js.map +0 -1
  547. package/build/esm/instrumentations/agents/types.js.map +0 -1
  548. package/build/esm/instrumentations/instrumentDurableObjectNamespace.js.map +0 -1
  549. package/build/esm/instrumentations/instrumentDurableObjectStorage.js.map +0 -1
  550. package/build/esm/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +0 -1
  551. package/build/esm/instrumentations/instrumentSqlStorage.js.map +0 -1
  552. package/build/esm/instrumentations/instrumentWorkerEntrypoint.js.map +0 -1
  553. package/build/esm/instrumentations/worker/instrumentD1.js.map +0 -1
  554. package/build/esm/instrumentations/worker/instrumentEmail.js.map +0 -1
  555. package/build/esm/instrumentations/worker/instrumentEnv.js.map +0 -1
  556. package/build/esm/instrumentations/worker/instrumentFetch.js.map +0 -1
  557. package/build/esm/instrumentations/worker/instrumentFetcher.js.map +0 -1
  558. package/build/esm/instrumentations/worker/instrumentQueue.js.map +0 -1
  559. package/build/esm/instrumentations/worker/instrumentQueueProducer.js.map +0 -1
  560. package/build/esm/instrumentations/worker/instrumentR2.js.map +0 -1
  561. package/build/esm/instrumentations/worker/instrumentRateLimit.js.map +0 -1
  562. package/build/esm/instrumentations/worker/instrumentScheduled.js.map +0 -1
  563. package/build/esm/instrumentations/worker/instrumentTail.js.map +0 -1
  564. package/build/esm/integrations/fetch.js.map +0 -1
  565. package/build/esm/integrations/hono.js +0 -49
  566. package/build/esm/integrations/hono.js.map +0 -1
  567. package/build/esm/integrations/httpServer.js.map +0 -1
  568. package/build/esm/integrations/spotlight.js.map +0 -1
  569. package/build/esm/integrations/tracing/vercelai.js.map +0 -1
  570. package/build/esm/nodejs_compat/index.js +0 -18
  571. package/build/esm/nodejs_compat/integrations/tracing/vercelai.js +0 -16
  572. package/build/esm/nodejs_compat/integrations/tracing/vercelai.js.map +0 -1
  573. package/build/esm/opentelemetry/tracer.js.map +0 -1
  574. package/build/esm/options.js.map +0 -1
  575. package/build/esm/package.json +0 -1
  576. package/build/esm/pages-plugin.js.map +0 -1
  577. package/build/esm/request.js.map +0 -1
  578. package/build/esm/scope-utils.js.map +0 -1
  579. package/build/esm/sdk.js.map +0 -1
  580. package/build/esm/transport.js.map +0 -1
  581. package/build/esm/utils/instrumentContext.js.map +0 -1
  582. package/build/esm/utils/internalSqlQuery.js.map +0 -1
  583. package/build/esm/utils/internalStorageKey.js.map +0 -1
  584. package/build/esm/utils/invocationScope.js.map +0 -1
  585. package/build/esm/utils/isBinding.js.map +0 -1
  586. package/build/esm/utils/isCloudflareClass.js.map +0 -1
  587. package/build/esm/utils/rpcMeta.js.map +0 -1
  588. package/build/esm/utils/rpcOptions.js +0 -24
  589. package/build/esm/utils/rpcOptions.js.map +0 -1
  590. package/build/esm/utils/streaming.js.map +0 -1
  591. package/build/esm/utils/traceLinks.js.map +0 -1
  592. package/build/esm/vendor/stacktrace.js.map +0 -1
  593. package/build/esm/vite/agentClass.js.map +0 -1
  594. package/build/esm/vite/autoInstrument.js.map +0 -1
  595. package/build/esm/vite/index.js.map +0 -1
  596. package/build/esm/vite/instrumentFile.js.map +0 -1
  597. package/build/esm/vite/moduleShape.js.map +0 -1
  598. package/build/esm/vite/transform.js.map +0 -1
  599. package/build/esm/vite/workerEntrypoint.js.map +0 -1
  600. package/build/esm/vite/wranglerConfig.js.map +0 -1
  601. package/build/esm/withSentry.js.map +0 -1
  602. package/build/esm/workflows.js.map +0 -1
  603. package/build/esm/wrapMethodWithSentry.js.map +0 -1
  604. package/build/types/async.d.ts +0 -11
  605. package/build/types/async.d.ts.map +0 -1
  606. package/build/types/integrations/hono.d.ts +0 -42
  607. package/build/types/integrations/hono.d.ts.map +0 -1
  608. package/build/types/nodejs_compat/index.d.ts +0 -4
  609. package/build/types/nodejs_compat/index.d.ts.map +0 -1
  610. package/build/types/nodejs_compat/integrations/tracing/vercelai.d.ts +0 -37
  611. package/build/types/nodejs_compat/integrations/tracing/vercelai.d.ts.map +0 -1
  612. package/build/types/utils/rpcOptions.d.ts +0 -13
  613. package/build/types/utils/rpcOptions.d.ts.map +0 -1
  614. package/build/types-ts3.8/async.d.ts +0 -11
  615. package/build/types-ts3.8/client.d.ts +0 -203
  616. package/build/types-ts3.8/debug-build.d.ts +0 -7
  617. package/build/types-ts3.8/defineCloudflareOptions.d.ts +0 -38
  618. package/build/types-ts3.8/durableobject.d.ts +0 -127
  619. package/build/types-ts3.8/executionContext.d.ts +0 -13
  620. package/build/types-ts3.8/flush.d.ts +0 -47
  621. package/build/types-ts3.8/index.d.ts +0 -19
  622. package/build/types-ts3.8/instrument.d.ts +0 -20
  623. package/build/types-ts3.8/instrumentations/agents/index.d.ts +0 -25
  624. package/build/types-ts3.8/instrumentations/agents/instrumentAgentCallableRpc.d.ts +0 -14
  625. package/build/types-ts3.8/instrumentations/agents/instrumentAgentRequestConversation.d.ts +0 -16
  626. package/build/types-ts3.8/instrumentations/agents/instrumentChatAgentConversation.d.ts +0 -23
  627. package/build/types-ts3.8/instrumentations/agents/types.d.ts +0 -94
  628. package/build/types-ts3.8/instrumentations/instrumentDurableObjectNamespace.d.ts +0 -13
  629. package/build/types-ts3.8/instrumentations/instrumentDurableObjectStorage.d.ts +0 -19
  630. package/build/types-ts3.8/instrumentations/instrumentDurableObjectSyncKvStorage.d.ts +0 -3
  631. package/build/types-ts3.8/instrumentations/instrumentSqlStorage.d.ts +0 -9
  632. package/build/types-ts3.8/instrumentations/instrumentWorkerEntrypoint.d.ts +0 -42
  633. package/build/types-ts3.8/instrumentations/worker/instrumentD1.d.ts +0 -19
  634. package/build/types-ts3.8/instrumentations/worker/instrumentEmail.d.ts +0 -8
  635. package/build/types-ts3.8/instrumentations/worker/instrumentEnv.d.ts +0 -18
  636. package/build/types-ts3.8/instrumentations/worker/instrumentFetch.d.ts +0 -12
  637. package/build/types-ts3.8/instrumentations/worker/instrumentFetcher.d.ts +0 -10
  638. package/build/types-ts3.8/instrumentations/worker/instrumentQueue.d.ts +0 -12
  639. package/build/types-ts3.8/instrumentations/worker/instrumentQueueProducer.d.ts +0 -10
  640. package/build/types-ts3.8/instrumentations/worker/instrumentR2.d.ts +0 -9
  641. package/build/types-ts3.8/instrumentations/worker/instrumentRateLimit.d.ts +0 -6
  642. package/build/types-ts3.8/instrumentations/worker/instrumentScheduled.d.ts +0 -12
  643. package/build/types-ts3.8/instrumentations/worker/instrumentTail.d.ts +0 -12
  644. package/build/types-ts3.8/integrations/fetch.d.ts +0 -19
  645. package/build/types-ts3.8/integrations/hono.d.ts +0 -42
  646. package/build/types-ts3.8/integrations/httpServer.d.ts +0 -63
  647. package/build/types-ts3.8/integrations/spotlight.d.ts +0 -22
  648. package/build/types-ts3.8/integrations/tracing/vercelai.d.ts +0 -47
  649. package/build/types-ts3.8/nodejs_compat/index.d.ts +0 -4
  650. package/build/types-ts3.8/nodejs_compat/integrations/tracing/vercelai.d.ts +0 -37
  651. package/build/types-ts3.8/opentelemetry/tracer.d.ts +0 -6
  652. package/build/types-ts3.8/options.d.ts +0 -17
  653. package/build/types-ts3.8/pages-plugin.d.ts +0 -34
  654. package/build/types-ts3.8/request.d.ts +0 -25
  655. package/build/types-ts3.8/scope-utils.d.ts +0 -15
  656. package/build/types-ts3.8/sdk.d.ts +0 -10
  657. package/build/types-ts3.8/transport.d.ts +0 -34
  658. package/build/types-ts3.8/utils/instrumentContext.d.ts +0 -16
  659. package/build/types-ts3.8/utils/internalSqlQuery.d.ts +0 -20
  660. package/build/types-ts3.8/utils/internalStorageKey.d.ts +0 -22
  661. package/build/types-ts3.8/utils/invocationScope.d.ts +0 -24
  662. package/build/types-ts3.8/utils/isBinding.d.ts +0 -77
  663. package/build/types-ts3.8/utils/isCloudflareClass.d.ts +0 -30
  664. package/build/types-ts3.8/utils/rpcMeta.d.ts +0 -23
  665. package/build/types-ts3.8/utils/rpcOptions.d.ts +0 -13
  666. package/build/types-ts3.8/utils/streaming.d.ts +0 -17
  667. package/build/types-ts3.8/utils/traceLinks.d.ts +0 -28
  668. package/build/types-ts3.8/vendor/stacktrace.d.ts +0 -11
  669. package/build/types-ts3.8/vite/agentClass.d.ts +0 -41
  670. package/build/types-ts3.8/vite/autoInstrument.d.ts +0 -22
  671. package/build/types-ts3.8/vite/index.d.ts +0 -98
  672. package/build/types-ts3.8/vite/instrumentFile.d.ts +0 -22
  673. package/build/types-ts3.8/vite/moduleShape.d.ts +0 -52
  674. package/build/types-ts3.8/vite/transform.d.ts +0 -65
  675. package/build/types-ts3.8/vite/workerEntrypoint.d.ts +0 -12
  676. package/build/types-ts3.8/vite/wranglerConfig.d.ts +0 -43
  677. package/build/types-ts3.8/withSentry.d.ts +0 -16
  678. package/build/types-ts3.8/workflows.d.ts +0 -25
  679. package/build/types-ts3.8/wrapMethodWithSentry.d.ts +0 -43
  680. /package/build/cjs/{client.js → dev/client.js} +0 -0
  681. /package/build/cjs/{debug-build.js → dev/debug-build.js} +0 -0
  682. /package/build/cjs/{defineCloudflareOptions.js → dev/defineCloudflareOptions.js} +0 -0
  683. /package/build/cjs/{flush.js → dev/flush.js} +0 -0
  684. /package/build/cjs/{instrument.js → dev/instrument.js} +0 -0
  685. /package/build/cjs/{instrumentations → dev/instrumentations}/agents/index.js +0 -0
  686. /package/build/cjs/{instrumentations → dev/instrumentations}/agents/instrumentAgentCallableRpc.js +0 -0
  687. /package/build/cjs/{instrumentations → dev/instrumentations}/agents/instrumentAgentRequestConversation.js +0 -0
  688. /package/build/cjs/{instrumentations → dev/instrumentations}/agents/instrumentChatAgentConversation.js +0 -0
  689. /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentDurableObjectNamespace.js +0 -0
  690. /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentDurableObjectStorage.js +0 -0
  691. /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentDurableObjectSyncKvStorage.js +0 -0
  692. /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentSqlStorage.js +0 -0
  693. /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentFetcher.js +0 -0
  694. /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentQueueProducer.js +0 -0
  695. /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentR2.js +0 -0
  696. /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentRateLimit.js +0 -0
  697. /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentTail.js +0 -0
  698. /package/build/cjs/{integrations → dev/integrations}/spotlight.js +0 -0
  699. /package/build/cjs/{opentelemetry → dev/opentelemetry}/tracer.js +0 -0
  700. /package/build/cjs/{scope-utils.js → dev/scope-utils.js} +0 -0
  701. /package/build/cjs/{transport.js → dev/transport.js} +0 -0
  702. /package/build/cjs/{utils → dev/utils}/internalSqlQuery.js +0 -0
  703. /package/build/cjs/{utils → dev/utils}/internalStorageKey.js +0 -0
  704. /package/build/cjs/{utils → dev/utils}/invocationScope.js +0 -0
  705. /package/build/cjs/{utils → dev/utils}/isBinding.js +0 -0
  706. /package/build/cjs/{utils → dev/utils}/isCloudflareClass.js +0 -0
  707. /package/build/cjs/{utils → dev/utils}/rpcMeta.js +0 -0
  708. /package/build/cjs/{utils → dev/utils}/streaming.js +0 -0
  709. /package/build/cjs/{utils → dev/utils}/traceLinks.js +0 -0
  710. /package/build/cjs/{vendor → dev/vendor}/stacktrace.js +0 -0
  711. /package/build/cjs/{vite → dev/vite}/agentClass.js +0 -0
  712. /package/build/cjs/{vite → dev/vite}/autoInstrument.js +0 -0
  713. /package/build/cjs/{vite → dev/vite}/instrumentFile.js +0 -0
  714. /package/build/cjs/{vite → dev/vite}/moduleShape.js +0 -0
  715. /package/build/cjs/{vite → dev/vite}/transform.js +0 -0
  716. /package/build/cjs/{vite → dev/vite}/workerEntrypoint.js +0 -0
  717. /package/build/cjs/{vite → dev/vite}/wranglerConfig.js +0 -0
  718. /package/build/cjs/{wrapMethodWithSentry.js → dev/wrapMethodWithSentry.js} +0 -0
  719. /package/build/esm/{client.js → dev/client.js} +0 -0
  720. /package/build/esm/{debug-build.js → dev/debug-build.js} +0 -0
  721. /package/build/esm/{defineCloudflareOptions.js → dev/defineCloudflareOptions.js} +0 -0
  722. /package/build/esm/{flush.js → dev/flush.js} +0 -0
  723. /package/build/esm/{instrument.js → dev/instrument.js} +0 -0
  724. /package/build/esm/{instrumentations → dev/instrumentations}/agents/index.js +0 -0
  725. /package/build/esm/{instrumentations → dev/instrumentations}/agents/instrumentAgentCallableRpc.js +0 -0
  726. /package/build/esm/{instrumentations → dev/instrumentations}/agents/instrumentAgentRequestConversation.js +0 -0
  727. /package/build/esm/{instrumentations → dev/instrumentations}/agents/instrumentChatAgentConversation.js +0 -0
  728. /package/build/esm/{instrumentations → dev/instrumentations}/instrumentDurableObjectNamespace.js +0 -0
  729. /package/build/esm/{instrumentations → dev/instrumentations}/instrumentDurableObjectStorage.js +0 -0
  730. /package/build/esm/{instrumentations → dev/instrumentations}/instrumentDurableObjectSyncKvStorage.js +0 -0
  731. /package/build/esm/{instrumentations → dev/instrumentations}/instrumentSqlStorage.js +0 -0
  732. /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentFetcher.js +0 -0
  733. /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentQueueProducer.js +0 -0
  734. /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentR2.js +0 -0
  735. /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentRateLimit.js +0 -0
  736. /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentTail.js +0 -0
  737. /package/build/esm/{integrations → dev/integrations}/spotlight.js +0 -0
  738. /package/build/esm/{opentelemetry → dev/opentelemetry}/tracer.js +0 -0
  739. /package/build/esm/{scope-utils.js → dev/scope-utils.js} +0 -0
  740. /package/build/esm/{transport.js → dev/transport.js} +0 -0
  741. /package/build/esm/{utils → dev/utils}/internalSqlQuery.js +0 -0
  742. /package/build/esm/{utils → dev/utils}/internalStorageKey.js +0 -0
  743. /package/build/esm/{utils → dev/utils}/invocationScope.js +0 -0
  744. /package/build/esm/{utils → dev/utils}/isBinding.js +0 -0
  745. /package/build/esm/{utils → dev/utils}/isCloudflareClass.js +0 -0
  746. /package/build/esm/{utils → dev/utils}/rpcMeta.js +0 -0
  747. /package/build/esm/{utils → dev/utils}/streaming.js +0 -0
  748. /package/build/esm/{vendor → dev/vendor}/stacktrace.js +0 -0
  749. /package/build/esm/{vite → dev/vite}/agentClass.js +0 -0
  750. /package/build/esm/{vite → dev/vite}/autoInstrument.js +0 -0
  751. /package/build/esm/{vite → dev/vite}/instrumentFile.js +0 -0
  752. /package/build/esm/{vite → dev/vite}/moduleShape.js +0 -0
  753. /package/build/esm/{vite → dev/vite}/transform.js +0 -0
  754. /package/build/esm/{vite → dev/vite}/workerEntrypoint.js +0 -0
  755. /package/build/esm/{vite → dev/vite}/wranglerConfig.js +0 -0
  756. /package/build/esm/{wrapMethodWithSentry.js → dev/wrapMethodWithSentry.js} +0 -0
@@ -1,11 +1,9 @@
1
- import { setAsyncLocalStorageAsyncContextStrategy } from './async.js';
2
- import { ensureInstrumented } from './instrument.js';
1
+ import { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';
3
2
  import { instrumentExportedHandlerEmail } from './instrumentations/worker/instrumentEmail.js';
4
3
  import { instrumentExportedHandlerFetch } from './instrumentations/worker/instrumentFetch.js';
5
4
  import { instrumentExportedHandlerQueue } from './instrumentations/worker/instrumentQueue.js';
6
5
  import { instrumentExportedHandlerScheduled } from './instrumentations/worker/instrumentScheduled.js';
7
6
  import { instrumentExportedHandlerTail } from './instrumentations/worker/instrumentTail.js';
8
- import { getHonoIntegration } from './integrations/hono.js';
9
7
  import { isCloudflareClass } from './utils/isCloudflareClass.js';
10
8
  import { instrumentWorkerEntrypoint } from './instrumentations/instrumentWorkerEntrypoint.js';
11
9
 
@@ -16,7 +14,6 @@ function withSentry(optionsCallback, handler) {
16
14
  setAsyncLocalStorageAsyncContextStrategy();
17
15
  try {
18
16
  instrumentExportedHandlerFetch(handler, optionsCallback);
19
- instrumentHonoErrorHandler(handler);
20
17
  instrumentExportedHandlerScheduled(handler, optionsCallback);
21
18
  instrumentExportedHandlerEmail(handler, optionsCallback);
22
19
  instrumentExportedHandlerQueue(handler, optionsCallback);
@@ -25,20 +22,6 @@ function withSentry(optionsCallback, handler) {
25
22
  }
26
23
  return handler;
27
24
  }
28
- function instrumentHonoErrorHandler(handler) {
29
- if ("onError" in handler && "errorHandler" in handler && typeof handler.errorHandler === "function") {
30
- handler.errorHandler = ensureInstrumented(
31
- handler.errorHandler,
32
- (original) => new Proxy(original, {
33
- apply(target, thisArg, args) {
34
- const [err, context] = args;
35
- getHonoIntegration()?.handleHonoException(err, context);
36
- return Reflect.apply(target, thisArg, args);
37
- }
38
- })
39
- );
40
- }
41
- }
42
25
 
43
26
  export { withSentry };
44
27
  //# sourceMappingURL=withSentry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withSentry.js","sources":["../../../src/withSentry.ts"],"sourcesContent":["import { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';\nimport type { CloudflareOptions } from './client';\nimport { instrumentExportedHandlerEmail } from './instrumentations/worker/instrumentEmail';\nimport { instrumentExportedHandlerFetch } from './instrumentations/worker/instrumentFetch';\nimport { instrumentExportedHandlerQueue } from './instrumentations/worker/instrumentQueue';\nimport { instrumentExportedHandlerScheduled } from './instrumentations/worker/instrumentScheduled';\nimport { instrumentExportedHandlerTail } from './instrumentations/worker/instrumentTail';\nimport { isCloudflareClass } from './utils/isCloudflareClass';\nimport type { AnyExportedHandler, DefaultEnv, ResolveEnv } from './types';\nimport {\n instrumentWorkerEntrypoint,\n type WorkerEntrypointConstructor,\n} from './instrumentations/instrumentWorkerEntrypoint';\n\n/**\n * Wrapper for Cloudflare handlers.\n *\n * Initializes the SDK and wraps the handler with Sentry instrumentation.\n *\n * Automatically instruments the `fetch` method of the handler.\n *\n * @param optionsCallback Function that returns the options for the SDK initialization.\n * @param handler {ExportedHandler} The handler to wrap.\n * @returns The wrapped handler.\n */\nexport function withSentry<\n Env = DefaultEnv,\n QueueHandlerMessage = unknown,\n CfHostMetadata = unknown,\n // oxlint-disable-next-line typescript/no-explicit-any\n T extends AnyExportedHandler | WorkerEntrypointConstructor<any, any> =\n | ExportedHandler<Env, QueueHandlerMessage, CfHostMetadata>\n | WorkerEntrypointConstructor<Env>,\n>(optionsCallback: (env: ResolveEnv<T, Env>) => CloudflareOptions | undefined, handler: T): T {\n if (isCloudflareClass(handler, 'WorkerEntrypoint')) {\n // oxlint-disable-next-line typescript/no-explicit-any\n return instrumentWorkerEntrypoint(optionsCallback as any, handler);\n }\n\n setAsyncLocalStorageAsyncContextStrategy();\n\n try {\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerFetch(handler, optionsCallback as any);\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerScheduled(handler, optionsCallback as any);\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerEmail(handler, optionsCallback as any);\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerQueue(handler, optionsCallback as any);\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerTail(handler, optionsCallback as any);\n // This is here because Miniflare sometimes cannot get instrumented\n } catch {\n // Do not console anything here, we don't want to spam the console with errors\n }\n\n return handler;\n}\n"],"names":[],"mappings":";;;;;;;;;AAyBO,SAAS,UAAA,CAQd,iBAA6E,OAAA,EAAe;AAC5F,EAAA,IAAI,iBAAA,CAAkB,OAAA,EAAS,kBAAkB,CAAA,EAAG;AAElD,IAAA,OAAO,0BAAA,CAA2B,iBAAwB,OAAO,CAAA;AAAA,EACnE;AAEA,EAAA,wCAAA,EAAyC;AAEzC,EAAA,IAAI;AAEF,IAAA,8BAAA,CAA+B,SAAS,eAAsB,CAAA;AAE9D,IAAA,kCAAA,CAAmC,SAAS,eAAsB,CAAA;AAElE,IAAA,8BAAA,CAA+B,SAAS,eAAsB,CAAA;AAE9D,IAAA,8BAAA,CAA+B,SAAS,eAAsB,CAAA;AAE9D,IAAA,6BAAA,CAA8B,SAAS,eAAsB,CAAA;AAAA,EAE/D,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,OAAA;AACT;;;;"}
@@ -1,5 +1,7 @@
1
+ import { CODE_FUNCTION_NAME, SENTRY_OP } from '@sentry/conventions/attributes';
2
+ import { GENERAL_FUNCTION_SPAN_OP } from '@sentry/conventions/op';
1
3
  import { withIsolationScope, withScope, getCurrentScope, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, captureException, flush } from '@sentry/core';
2
- import { setAsyncLocalStorageAsyncContextStrategy } from './async.js';
4
+ import { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';
3
5
  import { getOriginalWaitUntil, flushAndDispose } from './flush.js';
4
6
  import { instrumentEnv } from './instrumentations/worker/instrumentEnv.js';
5
7
  import { addCloudResourceContext } from './scope-utils.js';
@@ -40,10 +42,12 @@ class WrappedWorkflowStep {
40
42
  const isFinalAttempt = !hasStepContext || attempt > retryLimit;
41
43
  return startSpan(
42
44
  {
43
- op: "function.step.do",
44
45
  name,
45
46
  scope: scopeForStep,
46
47
  attributes: {
48
+ [SENTRY_OP]: GENERAL_FUNCTION_SPAN_OP,
49
+ [CODE_FUNCTION_NAME]: name,
50
+ "workflow.step.name": name,
47
51
  "cloudflare.workflow.timeout": config?.timeout,
48
52
  "cloudflare.workflow.retries.backoff": config?.retries?.backoff,
49
53
  // In workers-types v5, `delay` may be a `WorkflowDelayFunction`, which isn't a valid span attribute value.
@@ -87,6 +91,7 @@ class WrappedWorkflowStep {
87
91
  }
88
92
  function instrumentWorkflowWithSentry(optionsCallback, WorkFlowClass) {
89
93
  return new Proxy(WorkFlowClass, {
94
+ // oxlint-disable-next-line typescript/no-explicit-any
90
95
  construct(target, args, newTarget) {
91
96
  const [ctx, env] = args;
92
97
  const context = instrumentContext(ctx);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflows.js","sources":["../../../src/workflows.ts"],"sourcesContent":["import { CODE_FUNCTION_NAME, SENTRY_OP } from '@sentry/conventions/attributes';\nimport { GENERAL_FUNCTION_SPAN_OP } from '@sentry/conventions/op';\nimport type { PropagationContext } from '@sentry/core';\nimport {\n captureException,\n flush,\n getCurrentScope,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n startSpan,\n withIsolationScope,\n withScope,\n} from '@sentry/core';\nimport type {\n WorkflowDelayDuration,\n WorkflowEntrypoint,\n WorkflowEvent,\n WorkflowSleepDuration,\n WorkflowStep,\n WorkflowStepConfig,\n WorkflowStepContext,\n WorkflowStepEvent,\n WorkflowStepRollbackOptions,\n WorkflowTimeoutDuration,\n} from 'cloudflare:workers';\nimport { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';\nimport type { CloudflareOptions } from './client';\nimport { flushAndDispose, getOriginalWaitUntil } from './flush';\nimport { instrumentEnv } from './instrumentations/worker/instrumentEnv';\nimport { addCloudResourceContext } from './scope-utils';\nimport { init } from './sdk';\nimport { instrumentContext } from './utils/instrumentContext';\nimport type { DefaultEnv, ResolveEnv } from './types';\n\nconst UUID_REGEX = /^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$/i;\n\n/**\n * Hashes a string to a UUID using SHA-1.\n */\nexport async function deterministicTraceIdFromInstanceId(instanceId: string): Promise<string> {\n const buf = await crypto.subtle.digest('SHA-1', new TextEncoder().encode(instanceId));\n return (\n Array.from(new Uint8Array(buf))\n // We only need the first 16 bytes for the 32 characters\n .slice(0, 16)\n .map(b => b.toString(16).padStart(2, '0'))\n .join('')\n );\n}\n\nasync function propagationContextFromInstanceId(instanceId: string): Promise<PropagationContext> {\n const traceId = UUID_REGEX.test(instanceId)\n ? instanceId.replace(/-/g, '')\n : await deterministicTraceIdFromInstanceId(instanceId);\n\n // Derive sampleRand from last 4 characters of the random UUID\n //\n // We cannot store any state between workflow steps, so we derive the\n // sampleRand from the traceId itself. This ensures that the sampling is\n // consistent across all steps in the same workflow instance.\n const sampleRand = parseInt(traceId.slice(-4), 16) / 0xffff;\n\n return {\n traceId,\n sampleRand,\n };\n}\n\nclass WrappedWorkflowStep implements WorkflowStep {\n public constructor(\n private _instanceId: string,\n private _options: CloudflareOptions,\n private _step: WorkflowStep,\n private _waitUntil: ExecutionContext['waitUntil'],\n ) {}\n\n public async do<T extends Rpc.Serializable<T>>(\n name: string,\n callback: (ctx: WorkflowStepContext) => Promise<T>,\n rollbackOptions?: WorkflowStepRollbackOptions<T>,\n ): Promise<T>;\n public async do<T extends Rpc.Serializable<T>, const C extends WorkflowStepConfig>(\n name: string,\n config: C,\n callback: (\n ctx: WorkflowStepContext<C['retries'] extends { delay: infer D } ? D : WorkflowDelayDuration | number>,\n ) => Promise<T>,\n rollbackOptions?: WorkflowStepRollbackOptions<T>,\n ): Promise<T>;\n public async do<T extends Rpc.Serializable<T>>(\n name: string,\n configOrCallback: WorkflowStepConfig | ((ctx: WorkflowStepContext) => Promise<T>),\n callbackOrRollback?: ((ctx: WorkflowStepContext) => Promise<T>) | WorkflowStepRollbackOptions<T>,\n maybeRollback?: WorkflowStepRollbackOptions<T>,\n ): Promise<T> {\n // Capture the current scope, so parent span (e.g., a startSpan surrounding step.do) is preserved\n const scopeForStep = getCurrentScope();\n\n const hasConfig = typeof configOrCallback !== 'function';\n const config = hasConfig ? configOrCallback : undefined;\n const userCallback = (hasConfig ? callbackOrRollback : configOrCallback) as (\n ctx: WorkflowStepContext,\n ) => Promise<T>;\n const rollbackOptions = (hasConfig ? maybeRollback : callbackOrRollback) as\n | WorkflowStepRollbackOptions<T>\n | undefined;\n\n const instrumentedCallback = async (...args: unknown[]): Promise<T> => {\n // Feature detection: Cloudflare Workflows (April 2026+) pass a step context\n // with `attempt` and `config.retries.limit`. When available, we only capture\n // errors on the final attempt to avoid duplicates during retries.\n const stepContext = args[0] as { attempt?: number; config?: { retries?: { limit?: number } } } | undefined;\n const attempt = stepContext?.attempt;\n const retryLimit = stepContext?.config?.retries?.limit;\n const hasStepContext = typeof attempt === 'number' && typeof retryLimit === 'number';\n\n // Only capture error on final attempt (attempt > retryLimit means no more retries left)\n // or when step context is unavailable (legacy behavior - capture all errors)\n const isFinalAttempt = !hasStepContext || attempt > retryLimit;\n\n return startSpan(\n {\n name,\n scope: scopeForStep,\n attributes: {\n [SENTRY_OP]: GENERAL_FUNCTION_SPAN_OP,\n [CODE_FUNCTION_NAME]: name,\n 'workflow.step.name': name,\n 'cloudflare.workflow.timeout': config?.timeout,\n 'cloudflare.workflow.retries.backoff': config?.retries?.backoff,\n // In workers-types v5, `delay` may be a `WorkflowDelayFunction`, which isn't a valid span attribute value.\n 'cloudflare.workflow.retries.delay':\n typeof config?.retries?.delay === 'function' ? undefined : config?.retries?.delay,\n 'cloudflare.workflow.retries.limit': config?.retries?.limit,\n 'cloudflare.workflow.attempt': attempt,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.workflow',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',\n },\n },\n async span => {\n try {\n const result = await (userCallback as (...args: unknown[]) => Promise<T>)(...args);\n span.setStatus({ code: 1 });\n return result;\n } catch (error) {\n if (isFinalAttempt) {\n captureException(error, { mechanism: { handled: true, type: 'auto.faas.cloudflare.workflow' } });\n }\n throw error;\n } finally {\n this._waitUntil(flush(2000));\n }\n },\n );\n };\n\n if (config) {\n return rollbackOptions\n ? this._step.do(name, config, instrumentedCallback, rollbackOptions)\n : this._step.do(name, config, instrumentedCallback);\n }\n\n return rollbackOptions\n ? this._step.do(name, instrumentedCallback, rollbackOptions)\n : this._step.do(name, instrumentedCallback);\n }\n\n public async sleep(name: string, duration: WorkflowSleepDuration): Promise<void> {\n return this._step.sleep(name, duration);\n }\n\n public async sleepUntil(name: string, timestamp: Date | number): Promise<void> {\n return this._step.sleepUntil(name, timestamp);\n }\n\n public async waitForEvent<T extends Rpc.Serializable<T>>(\n name: string,\n options: { type: string; timeout?: WorkflowTimeoutDuration | number },\n ): Promise<WorkflowStepEvent<T>> {\n return this._step.waitForEvent<T>(name, options);\n }\n}\n\n/**\n * Instruments a Cloudflare Workflow class with Sentry.\n *\n * @example\n * ```typescript\n * const InstrumentedWorkflow = instrumentWorkflowWithSentry(\n * (env) => ({ dsn: env.SENTRY_DSN }),\n * MyWorkflowClass\n * );\n *\n * export default InstrumentedWorkflow;\n * ```\n *\n * @param optionsCallback - Function that returns Sentry options to initialize Sentry\n * @param WorkflowClass - The workflow class to instrument\n * @returns Instrumented workflow class with the same interface\n */\nexport function instrumentWorkflowWithSentry<\n E = DefaultEnv, // Environment type\n P = unknown, // Payload type\n // oxlint-disable-next-line typescript/no-explicit-any\n T extends WorkflowEntrypoint<any, any> = WorkflowEntrypoint<E, P>, // WorkflowEntrypoint type\n // The constraint must not route through `T`: workers-types defaults `WorkflowEntrypoint`'s\n // `Env` to `unknown` (unlike `WorkerEntrypoint`/`DurableObject`, which default to\n // `Cloudflare.Env`), so a bare subclass would be rejected in a `wrangler types` project.\n // The callback env is resolved from the inferred constructor via `ResolveEnv` instead.\n // oxlint-disable-next-line typescript/no-explicit-any\n C extends new (ctx: ExecutionContext, env: any) => WorkflowEntrypoint<any, any> = new (\n ctx: ExecutionContext,\n // oxlint-disable-next-line typescript/no-explicit-any\n env: any,\n ) => T, // Constructor type of the WorkflowEntrypoint class\n>(optionsCallback: (env: ResolveEnv<C, E>) => CloudflareOptions, WorkFlowClass: C): C {\n return new Proxy(WorkFlowClass, {\n // oxlint-disable-next-line typescript/no-explicit-any\n construct(target: C, args: [ctx: ExecutionContext, env: any], newTarget) {\n const [ctx, env] = args;\n const context = instrumentContext(ctx);\n const options = optionsCallback(env);\n args[0] = context;\n args[1] = instrumentEnv(env as Record<string, unknown>, options) as E;\n const instance = Reflect.construct(target, args, newTarget) as T;\n return new Proxy(instance, {\n get(obj, prop, receiver) {\n if (prop === 'run') {\n return async function (event: WorkflowEvent<P>, step: WorkflowStep): Promise<unknown> {\n setAsyncLocalStorageAsyncContextStrategy();\n\n return withIsolationScope(async isolationScope => {\n const waitUntil = getOriginalWaitUntil(context).bind(context);\n const client = init({ ...options, ctx: context, enableDedupe: false });\n isolationScope.setClient(client);\n\n addCloudResourceContext(isolationScope);\n\n return withScope(async scope => {\n const propagationContext = await propagationContextFromInstanceId(event.instanceId);\n scope.setPropagationContext(propagationContext);\n\n try {\n return await obj.run.call(\n obj,\n event,\n new WrappedWorkflowStep(event.instanceId, options, step, waitUntil),\n );\n } finally {\n waitUntil(flushAndDispose(client));\n }\n });\n });\n };\n }\n return Reflect.get(obj, prop, receiver);\n },\n });\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;AAkCA,MAAM,UAAA,GAAa,qEAAA;AAKnB,eAAsB,mCAAmC,U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,MAAM,gCAAA,CAAiC,KAAA,CAAM,UAAU,CAAA;AAClF,kBAAA,KAAA,CAAM,sBAAsB,kBAAkB,CAAA;AAE9C,kBAAA,IAAI;AACF,oBAAA,OAAO,MAAM,IAAI,GAAA,CAAI,IAAA;AAAA,sBACnB,GAAA;AAAA,sBACA,KAAA;AAAA,sBACA,IAAI,mBAAA,CAAoB,KAAA,CAAM,UAAA,EAAY,OAAA,EAAS,MAAM,SAAS;AAAA,qBACpE;AAAA,kBACF,CAAA,SAAE;AACA,oBAAA,SAAA,CAAU,eAAA,CAAgB,MAAM,CAAC,CAAA;AAAA,kBACnC;AAAA,gBACF,CAAC,CAAA;AAAA,cACH,CAAC,CAAA;AAAA,YACH,CAAA;AAAA,UACF;AACA,UAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,GAAA,EAAK,IAAA,EAAM,QAAQ,CAAA;AAAA,QACxC;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapMethodWithSentry.js","sources":["../../../src/wrapMethodWithSentry.ts"],"sourcesContent":["import type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport type { SerializedTraceData } from '@sentry/core';\nimport {\n isObjectLike,\n captureException,\n continueTrace,\n isThenable,\n type Scope,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startNewTrace as startNewTraceCore,\n startSpan,\n} from '@sentry/core';\nimport type { CloudflareOptions } from './client';\nimport type { ExecutionContextCompat } from './executionContext';\nimport { flushAndDispose, getOriginalWaitUntil } from './flush';\nimport { ensureInstrumented } from './instrument';\nimport { init } from './sdk';\nimport { withInvocationIsolationScope } from './utils/invocationScope';\nimport { extractRpcMeta } from './utils/rpcMeta';\nimport { buildSpanLinks, getStoredSpanContext, storeSpanContext } from './utils/traceLinks';\n\n/** Extended DurableObjectState with originalStorage exposed by instrumentContext */\nexport interface InstrumentedDurableObjectState extends DurableObjectState {\n originalStorage?: DurableObjectStorage;\n}\n\n/**\n * Resolves uninstrumented DO storage for the current invocation.\n * Prefer `thisArg.ctx` (the live Durable Object instance) over the context captured at\n * construction time to avoid cross-DO I/O errors in the same isolate.\n */\nfunction resolveOriginalStorage(\n context: ExecutionContext | InstrumentedDurableObjectState | undefined,\n thisArg: unknown,\n): DurableObjectStorage | undefined {\n if (isObjectLike(thisArg) && 'ctx' in thisArg) {\n const doCtx = (thisArg as { ctx: InstrumentedDurableObjectState }).ctx;\n if (doCtx?.originalStorage) {\n return doCtx.originalStorage;\n }\n }\n\n if (context && 'originalStorage' in context && context.originalStorage) {\n return context.originalStorage;\n }\n\n return undefined;\n}\n\ntype MethodWrapperOptions = {\n spanName?: string;\n spanOp?: string;\n options: CloudflareOptions;\n context: ExecutionContext | InstrumentedDurableObjectState;\n /**\n * If true, starts a fresh trace instead of inheriting from a parent trace.\n * Useful for scheduled/independent invocations like alarms.\n *\n * If true, it also stores the current span context and links to the previous invocation's span.\n * Uses Durable Object storage to persist the link. The link is set asynchronously via `span.addLinks()`\n * in a `waitUntil` to avoid blocking.\n *\n * @default false\n */\n startNewTrace?: boolean;\n /**\n * The trace origin identifying which instrumentation created the span, e.g. `auto.faas.cloudflare.durable_object`.\n * Used both as the span's `sentry.origin` attribute and as the `mechanism.type` for captured exceptions.\n */\n origin: string;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UncheckedMethod = (...args: any[]) => any;\ntype OriginalMethod = UncheckedMethod;\n\n/**\n * Wraps a method with Sentry error tracking and optional tracing.\n * Supports starting new traces and linking to previous invocations via Durable Object storage.\n *\n * @param wrapperOptions - The options for the wrapper.\n * @param handler - The method to wrap.\n * @param callback - The callback to call.\n * @param noMark - Whether to mark the method as instrumented.\n * @returns The wrapped method.\n */\nexport function wrapMethodWithSentry<T extends OriginalMethod>(\n wrapperOptions: MethodWrapperOptions,\n handler: T,\n callback?: (...args: Parameters<T>) => void,\n noMark?: true,\n): T {\n return ensureInstrumented(\n handler,\n original =>\n new Proxy(original, {\n apply(target, thisArg, rawArgs: Parameters<T>) {\n const { startNewTrace, origin } = wrapperOptions;\n\n // For RPC methods, extract Sentry trace context from the trailing argument.\n // The caller side (instrumentDurableObjectStub / JSRPC proxy) appends it;\n // we strip it here so the user's method never sees it.\n let args = rawArgs;\n let rpcMeta: SerializedTraceData | undefined;\n\n if (wrapperOptions.spanOp === 'rpc') {\n const extracted = extractRpcMeta(rawArgs);\n args = extracted.args;\n rpcMeta = extracted.rpcMeta;\n }\n\n const wrappedFunction = (scope: Scope): unknown | Promise<unknown> => {\n // In certain situations, the passed context can become undefined.\n // For example, for Astro while prerendering pages at build time.\n // see: https://github.com/getsentry/sentry-javascript/issues/13217\n const context: typeof wrapperOptions.context | undefined = wrapperOptions.context;\n\n // see: https://github.com/getsentry/sentry-javascript/issues/22328\n const waitUntil = context\n ? getOriginalWaitUntil(context as ExecutionContextCompat)?.bind(context)\n : undefined;\n const storage = resolveOriginalStorage(context, thisArg);\n\n let scopeClient = scope.getClient();\n // Check if client exists AND is still usable (transport not disposed)\n // This handles the case where a previous handler disposed the client\n // but the scope still holds a reference to it (e.g., alarm handlers in Durable Objects)\n // For startNewTrace, always create a fresh client\n if (startNewTrace || !scopeClient?.getTransport()) {\n const client = init({\n ...wrapperOptions.options,\n ctx: context as unknown as ExecutionContext | undefined,\n });\n scope.setClient(client);\n scopeClient = client;\n }\n\n const clientToDispose = scopeClient;\n const methodName = wrapperOptions.spanName || 'unknown';\n\n const teardown = async (): Promise<void> => {\n if (startNewTrace && storage) {\n storeSpanContext(storage, methodName);\n }\n await flushAndDispose(clientToDispose);\n };\n\n const onFulfilled = (res: unknown) => {\n waitUntil?.(teardown());\n return res;\n };\n\n const onRejected = (e: unknown) => {\n captureException(e, {\n mechanism: {\n type: origin,\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\n };\n\n if (!wrapperOptions.spanName) {\n try {\n if (callback) {\n callback(...args);\n }\n\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(onFulfilled, onRejected);\n } else {\n return onFulfilled(result);\n }\n } catch (e) {\n return onRejected(e);\n }\n }\n\n const attributes = wrapperOptions.spanOp\n ? {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin,\n }\n : {};\n\n const executeSpan = (): unknown => {\n return startSpan({ name: methodName, attributes }, span => {\n if (startNewTrace && storage) {\n const storedContext = getStoredSpanContext(storage, methodName);\n\n if (storedContext) {\n span.addLinks(buildSpanLinks(storedContext));\n // TODO: Remove this once EAP can store span links. We currently only set this attribute so that we\n // can obtain the previous trace information from the EAP store. Long-term, EAP will handle\n // span links and then we should remove this again. Also throwing in a TODO(v11), to remind us\n // to check this at v11 time :)\n const sampledFlag = storedContext.sampled ? '1' : '0';\n span.setAttribute(\n 'sentry.previous_trace',\n `${storedContext.traceId}-${storedContext.spanId}-${sampledFlag}`,\n );\n }\n }\n\n try {\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(onFulfilled, onRejected);\n } else {\n return onFulfilled(result);\n }\n } catch (e) {\n return onRejected(e);\n }\n });\n };\n\n if (rpcMeta) {\n return continueTrace(\n { sentryTrace: rpcMeta['sentry-trace'] || '', baggage: rpcMeta.baggage || '' },\n executeSpan,\n );\n }\n\n if (startNewTrace) {\n return startNewTraceCore(() => executeSpan());\n }\n\n return executeSpan();\n };\n\n return withInvocationIsolationScope(wrappedFunction);\n },\n }),\n noMark,\n );\n}\n"],"names":["startNewTrace","startNewTraceCore"],"mappings":";;;;;;;;AAgCA,SAAS,sBAAA,CACP,SACA,OAAA,EACkC;AAClC,EAAA,IAAI,YAAA,CAAa,OAAO,CAAA,IAAK,KAAA,IAAS,OAAA,EAAS;AAC7C,IAAA,MAAM,QAAS,OAAA,CAAoD,GAAA;AACnE,IAAA,IAAI,OAAO,eAAA,EAAi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X,YAAA,OAAO,aAAA;AAAA,cACL,EAAE,aAAa,OAAA,CAAQ,cAAc,KAAK,EAAA,EAAI,OAAA,EAAS,OAAA,CAAQ,OAAA,IAAW,EAAA,EAAG;AAAA,cAC7E;AAAA,aACF;AAAA,UACF;AAEA,UAAA,IAAIA,eAAA,EAAe;AACjB,YAAA,OAAOC,aAAA,CAAkB,MAAM,WAAA,EAAa,CAAA;AAAA,UAC9C;AAEA,UAAA,OAAO,WAAA,EAAY;AAAA,QACrB,CAAA;AAEA,QAAA,OAAO,6BAA6B,eAAe,CAAA;AAAA,MACrD;AAAA,KACD,CAAA;AAAA,IACH;AAAA,GACF;AACF;;;;"}
@@ -0,0 +1,69 @@
1
+ import { dedupeIntegration, eventFiltersIntegration, functionToStringIntegration, conversationIdIntegration, linkedErrorsIntegration, requestDataIntegration, consoleIntegration, GLOBAL_OBJ, getIntegrationsToSetup, stackParserFromStackParserOptions, initAndBind } from '@sentry/core';
2
+ import { CloudflareClient } from './client.js';
3
+ import { makeFlushLock } from './flush.js';
4
+ import { fetchIntegration } from './integrations/fetch.js';
5
+ import { httpServerIntegration } from './integrations/httpServer.js';
6
+ import { setupOpenTelemetryTracer } from './opentelemetry/tracer.js';
7
+ import { makeCloudflareTransport } from './transport.js';
8
+ import { defaultStackParser } from './vendor/stacktrace.js';
9
+
10
+ function getRegisteredChannelIntegrations() {
11
+ const registered = GLOBAL_OBJ.__SENTRY_ORCHESTRION__?.integrations;
12
+ return registered ? [...registered.values()].map((factory) => factory()) : [];
13
+ }
14
+ function getBaseDefaultIntegrations(options) {
15
+ return [
16
+ // The Dedupe integration should not be used in workflows because we want to
17
+ // capture all step failures, even if they are the same error.
18
+ ...options.enableDedupe === false ? [] : [dedupeIntegration()],
19
+ eventFiltersIntegration(),
20
+ functionToStringIntegration(),
21
+ conversationIdIntegration(),
22
+ linkedErrorsIntegration(),
23
+ fetchIntegration(),
24
+ httpServerIntegration(),
25
+ requestDataIntegration(),
26
+ consoleIntegration(),
27
+ // The orchestrion diagnostics-channel subscribers (mysql, pg, …). The
28
+ // `@sentry/cloudflare/vite` plugin injects the channels at build time and,
29
+ // next to each, a snippet that registers the matching subscriber factory on
30
+ // the global marker. Read from there instead of importing them so bundles
31
+ // built without the plugin — where the channels would never fire — don't
32
+ // ship the code.
33
+ ...getRegisteredChannelIntegrations()
34
+ ];
35
+ }
36
+ function initWithDefaultIntegrations(options, getDefaultIntegrationsImpl) {
37
+ if (options.defaultIntegrations === void 0) {
38
+ options.defaultIntegrations = getDefaultIntegrationsImpl(options);
39
+ }
40
+ const flushLock = options.ctx ? makeFlushLock(options.ctx) : void 0;
41
+ delete options.ctx;
42
+ const clientOptions = {
43
+ ...options,
44
+ stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),
45
+ integrations: getIntegrationsToSetup(options),
46
+ transport: options.transport || makeCloudflareTransport,
47
+ // Like most Node-based SDKs, Cloudflare defaults to running without a Sentry OpenTelemetry tracer
48
+ // provider. Scope isolation is handled by the entrypoint wrappers' AsyncLocalStorage strategy.
49
+ enableOpenTelemetrySetup: options.enableOpenTelemetrySetup ?? false,
50
+ flushLock
51
+ };
52
+ if (clientOptions.enableOpenTelemetrySetup) {
53
+ setupOpenTelemetryTracer();
54
+ }
55
+ const client = initAndBind(CloudflareClient, clientOptions);
56
+ client.on("orchestrion.module-injected", (moduleName) => {
57
+ const factory = GLOBAL_OBJ.__SENTRY_ORCHESTRION__?.integrations?.get(moduleName);
58
+ if (factory) {
59
+ client.addIntegration(factory());
60
+ }
61
+ });
62
+ return client;
63
+ }
64
+ function initBaseSdk(options) {
65
+ return initWithDefaultIntegrations(options, getBaseDefaultIntegrations);
66
+ }
67
+
68
+ export { getBaseDefaultIntegrations, initBaseSdk, initWithDefaultIntegrations };
69
+ //# sourceMappingURL=baseSdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseSdk.js","sources":["../../../src/baseSdk.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport {\n consoleIntegration,\n conversationIdIntegration,\n dedupeIntegration,\n eventFiltersIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n GLOBAL_OBJ,\n initAndBind,\n linkedErrorsIntegration,\n requestDataIntegration,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport type { CloudflareClientOptions, CloudflareOptions } from './client';\nimport { CloudflareClient } from './client';\nimport { makeFlushLock } from './flush';\nimport { fetchIntegration } from './integrations/fetch';\nimport { httpServerIntegration } from './integrations/httpServer';\nimport { INTEGRATION_NAME as SPOTLIGHT_INTEGRATION_NAME, spotlightIntegration } from './integrations/spotlight';\nimport { setupOpenTelemetryTracer } from './opentelemetry/tracer';\nimport { makeCloudflareTransport } from './transport';\nimport { defaultStackParser } from './vendor/stacktrace';\n\n/**\n * Instantiate the channel-subscriber factories the `@sentry/cloudflare/vite`\n * plugin registered on the global marker. The plugin splices a small snippet\n * into each instrumented module that `.set`s its factory here (keyed by module\n * name), so the marker holds one factory per package actually bundled.\n *\n * The marker is read directly instead of importing the factories, so a worker\n * built without the plugin — where the channels never fire — ships none of this\n * code.\n * TODO(v11): Use `@sentry/server-utils/orchestrion` once we move to `nodejs_compat` by default.\n */\nfunction getRegisteredChannelIntegrations(): Integration[] {\n const registered = GLOBAL_OBJ.__SENTRY_ORCHESTRION__?.integrations;\n\n return registered ? [...registered.values()].map(factory => factory()) : [];\n}\n\n/**\n * Get the default integrations that run on any Workers-compatible runtime, i.e. without the\n * `nodejs_compat` compatibility flag.\n *\n * `getDefaultIntegrations` in `sdk.ts` extends this set with the integrations that do depend on\n * Node.js APIs. Keeping the two apart is what allows `wrapRequestHandler` to stay usable on runtimes\n * that cannot enable `nodejs_compat`, such as Shopify Oxygen.\n */\nexport function getBaseDefaultIntegrations(options: CloudflareOptions): Integration[] {\n return [\n // The Dedupe integration should not be used in workflows because we want to\n // capture all step failures, even if they are the same error.\n ...(options.enableDedupe === false ? [] : [dedupeIntegration()]),\n eventFiltersIntegration(),\n functionToStringIntegration(),\n conversationIdIntegration(),\n linkedErrorsIntegration(),\n fetchIntegration(),\n httpServerIntegration(),\n requestDataIntegration(),\n consoleIntegration(),\n // The orchestrion diagnostics-channel subscribers (mysql, pg, …). The\n // `@sentry/cloudflare/vite` plugin injects the channels at build time and,\n // next to each, a snippet that registers the matching subscriber factory on\n // the global marker. Read from there instead of importing them so bundles\n // built without the plugin — where the channels would never fire — don't\n // ship the code.\n ...getRegisteredChannelIntegrations(),\n ];\n}\n\n/**\n * Initializes the Cloudflare SDK with the passed default integrations.\n *\n * The default integrations are injected rather than imported so that this module stays free of\n * Node.js-only code. `request.ts` — which backs both `wrapRequestHandler` and the\n * `@sentry/cloudflare/request` entry point, and therefore has to work on runtimes without the\n * `nodejs_compat` compatibility flag — creates its client from here instead of from `sdk.ts`.\n */\nexport function initWithDefaultIntegrations(\n options: CloudflareOptions,\n getDefaultIntegrationsImpl: (options: CloudflareOptions) => Integration[],\n): CloudflareClient | undefined {\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = getDefaultIntegrationsImpl(options);\n }\n\n const flushLock = options.ctx ? makeFlushLock(options.ctx) : undefined;\n delete options.ctx;\n\n const clientOptions: CloudflareClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: getIntegrationsToSetup(options),\n transport: options.transport || makeCloudflareTransport,\n // 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 enableOpenTelemetrySetup: options.enableOpenTelemetrySetup ?? false,\n flushLock,\n };\n\n /*! rollup-include-development-only */\n if (options.spotlight && !clientOptions.integrations.some(({ name }) => name === SPOTLIGHT_INTEGRATION_NAME)) {\n clientOptions.integrations.push(\n spotlightIntegration({\n sidecarUrl: typeof options.spotlight === 'string' ? options.spotlight : undefined,\n }),\n );\n }\n /*! rollup-include-development-only-end */\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 (clientOptions.enableOpenTelemetrySetup) {\n setupOpenTelemetryTracer();\n }\n\n const client = initAndBind(CloudflareClient, clientOptions) as CloudflareClient;\n\n // An instrumented module that first evaluates AFTER this init (e.g. a driver\n // lazily required on first use) stores its subscriber factory on the global\n // marker too late for the default-integrations snapshot above. Its injected\n // snippet emits this event right after storing the factory, so install the\n // integration on the live client here. `addIntegration` dedupes by\n // integration name, so already-installed integrations are no-ops.\n client.on('orchestrion.module-injected', moduleName => {\n const factory = GLOBAL_OBJ.__SENTRY_ORCHESTRION__?.integrations?.get(moduleName);\n if (factory) {\n client.addIntegration(factory());\n }\n });\n\n return client;\n}\n\n/**\n * Initializes the Cloudflare SDK with only the default integrations from\n * {@link getBaseDefaultIntegrations}, i.e. those that work without the `nodejs_compat`\n * compatibility flag.\n */\nexport function initBaseSdk(options: CloudflareOptions): CloudflareClient | undefined {\n return initWithDefaultIntegrations(options, getBaseDefaultIntegrations);\n}\n"],"names":[],"mappings":";;;;;;;;;AAmCA,SAAS,gCAAA,GAAkD;AACzD,EAAA,MAAM,UAAA,GAAa,WAAW,sBAAA,EAAwB,YAAA;AAEtD,EAAA,OAAO,UAAA,GAAa,CAAC,GAAG,UAAA,CAAW,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,CAAA,OAAA,KAAW,OAAA,EAAS,CAAA,GAAI,EAAC;AAC5E;AAUO,SAAS,2BAA2B,OAAA,EAA2C;AACpF,EAAA,OAAO;AAAA;AAAA;AAAA,IAGL,GAAI,QAAQ,YAAA,KAAiB,KAAA,GAAQ,EAAC,GAAI,CAAC,mBAAmB,CAAA;AAAA,IAC9D,uBAAA,EAAwB;AAAA,IACxB,2BAAA,EAA4B;AAAA,IAC5B,yBAAA,EAA0B;AAAA,IAC1B,uBAAA,EAAwB;AAAA,IACxB,gBAAA,EAAiB;AAAA,IACjB,qBAAA,EAAsB;AAAA,IACtB,sBAAA,EAAuB;AAA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4B,SAAS,0BAA0B,CAAA;AACxE;;;;"}
@@ -0,0 +1,120 @@
1
+ import { ServerRuntimeClient, applySdkMetadata, debug, spanIsSampled, _INTERNAL_clearAiProviderSkips } from '@sentry/core';
2
+ import { DEBUG_BUILD } from './debug-build.js';
3
+
4
+ class CloudflareClient extends ServerRuntimeClient {
5
+ /**
6
+ * Creates a new Cloudflare SDK instance.
7
+ * @param options Configuration options for this SDK.
8
+ */
9
+ constructor(options) {
10
+ applySdkMetadata(options, "cloudflare");
11
+ options._metadata = options._metadata || {};
12
+ const { flushLock, ...serverOptions } = options;
13
+ const clientOptions = {
14
+ ...serverOptions,
15
+ platform: "javascript",
16
+ // TODO: Grab version information
17
+ runtime: { name: "cloudflare" },
18
+ // TODO: Add server name
19
+ _flushInterval: 0
20
+ };
21
+ super(clientOptions);
22
+ this._pendingSpans = /* @__PURE__ */ new Set();
23
+ this._spanCompletionPromise = null;
24
+ this._resolveSpanCompletion = null;
25
+ this._unsubscribeSpanStart = null;
26
+ this._unsubscribeSpanEnd = null;
27
+ this._flushLock = flushLock;
28
+ this._unsubscribeSpanStart = this.on("spanStart", (span) => {
29
+ const spanId = span.spanContext().spanId;
30
+ DEBUG_BUILD && debug.log("[CloudflareClient] Span started:", spanId);
31
+ if (!spanIsSampled(span)) {
32
+ return;
33
+ }
34
+ this._pendingSpans.add(spanId);
35
+ if (!this._spanCompletionPromise) {
36
+ this._spanCompletionPromise = new Promise((resolve) => {
37
+ this._resolveSpanCompletion = resolve;
38
+ });
39
+ }
40
+ });
41
+ this._unsubscribeSpanEnd = this.on("spanEnd", (span) => {
42
+ const spanId = span.spanContext().spanId;
43
+ DEBUG_BUILD && debug.log("[CloudflareClient] Span ended:", spanId);
44
+ this._pendingSpans.delete(spanId);
45
+ if (this._pendingSpans.size === 0 && this._resolveSpanCompletion) {
46
+ DEBUG_BUILD && debug.log("[CloudflareClient] All spans completed, resolving promise");
47
+ this._resolveSpanCompletion();
48
+ this._resetSpanCompletionPromise();
49
+ }
50
+ });
51
+ }
52
+ /**
53
+ * Flushes pending operations and ensures all data is processed.
54
+ * If a timeout is provided, the operation will be completed within the specified time limit.
55
+ *
56
+ * It will wait for all pending spans to complete before flushing.
57
+ *
58
+ * @param {number} [timeout] - Optional timeout in milliseconds to force the completion of the flush operation.
59
+ * @return {Promise<boolean>} A promise that resolves to a boolean indicating whether the flush operation was successful.
60
+ */
61
+ async flush(timeout) {
62
+ if (this._flushLock) {
63
+ await this._flushLock.finalize();
64
+ }
65
+ if (this._pendingSpans.size > 0 && this._spanCompletionPromise) {
66
+ DEBUG_BUILD && debug.log("[CloudflareClient] Waiting for", this._pendingSpans.size, "pending spans to complete...");
67
+ const timeoutMs = timeout ?? 5e3;
68
+ const spanCompletionRace = Promise.race([
69
+ this._spanCompletionPromise,
70
+ new Promise(
71
+ (resolve) => setTimeout(() => {
72
+ DEBUG_BUILD && debug.log("[CloudflareClient] Span completion timeout after", timeoutMs, "ms, flushing anyway");
73
+ resolve(void 0);
74
+ }, timeoutMs)
75
+ )
76
+ ]);
77
+ await spanCompletionRace;
78
+ }
79
+ return super.flush(timeout);
80
+ }
81
+ /**
82
+ * Disposes of the client and releases all resources.
83
+ *
84
+ * This method clears all Cloudflare-specific state in addition to the base client cleanup.
85
+ * It unsubscribes from span lifecycle events and clears pending span tracking.
86
+ *
87
+ * Call this method after flushing to allow the client to be garbage collected.
88
+ * After calling dispose(), the client should not be used anymore.
89
+ */
90
+ dispose() {
91
+ DEBUG_BUILD && debug.log("[CloudflareClient] Disposing client...");
92
+ super.dispose();
93
+ if (this._unsubscribeSpanStart) {
94
+ this._unsubscribeSpanStart();
95
+ this._unsubscribeSpanStart = null;
96
+ }
97
+ if (this._unsubscribeSpanEnd) {
98
+ this._unsubscribeSpanEnd();
99
+ this._unsubscribeSpanEnd = null;
100
+ }
101
+ this._resetSpanCompletionPromise();
102
+ this._flushLock = void 0;
103
+ }
104
+ /** @inheritDoc */
105
+ _setupIntegrations() {
106
+ _INTERNAL_clearAiProviderSkips();
107
+ super._setupIntegrations();
108
+ }
109
+ /**
110
+ * Resets the span completion promise and resolve function.
111
+ */
112
+ _resetSpanCompletionPromise() {
113
+ this._pendingSpans.clear();
114
+ this._spanCompletionPromise = null;
115
+ this._resolveSpanCompletion = null;
116
+ }
117
+ }
118
+
119
+ export { CloudflareClient };
120
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sources":["../../../src/client.ts"],"sourcesContent":["import type { ClientOptions, Options, ServerRuntimeClientOptions } from '@sentry/core';\nimport {\n _INTERNAL_clearAiProviderSkips,\n applySdkMetadata,\n debug,\n ServerRuntimeClient,\n spanIsSampled,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from './debug-build';\nimport type { ExecutionContextCompat } from './executionContext';\nimport type { makeFlushLock } from './flush';\nimport type { CloudflareTransportOptions } from './transport';\n\n/**\n * The Sentry Cloudflare SDK Client.\n *\n * @see CloudflareClientOptions for documentation on configuration options.\n * @see ServerRuntimeClient for usage documentation.\n */\nexport class CloudflareClient extends ServerRuntimeClient {\n private readonly _flushLock: ReturnType<typeof makeFlushLock> | void;\n private _pendingSpans: Set<string> = new Set();\n private _spanCompletionPromise: Promise<void> | null = null;\n private _resolveSpanCompletion: (() => void) | null = null;\n\n private _unsubscribeSpanStart: (() => void) | null = null;\n private _unsubscribeSpanEnd: (() => void) | null = null;\n\n /**\n * Creates a new Cloudflare SDK instance.\n * @param options Configuration options for this SDK.\n */\n public constructor(options: CloudflareClientOptions) {\n applySdkMetadata(options, 'cloudflare');\n options._metadata = options._metadata || {};\n const { flushLock, ...serverOptions } = options;\n\n const clientOptions: ServerRuntimeClientOptions = {\n ...serverOptions,\n platform: 'javascript',\n // TODO: Grab version information\n runtime: { name: 'cloudflare' },\n // TODO: Add server name\n _flushInterval: 0,\n };\n\n super(clientOptions);\n this._flushLock = flushLock;\n\n // Track span lifecycle to know when to flush\n this._unsubscribeSpanStart = this.on('spanStart', span => {\n const spanId = span.spanContext().spanId;\n DEBUG_BUILD && debug.log('[CloudflareClient] Span started:', spanId);\n\n // Negatively sampled spans never emit spanEnd,\n // so tracking them would cause _pendingSpans to grow unboundedly.\n // We should fix the inconsistent behavior for NonRecordingSpans in the future but\n // for now, we just ignore them.\n if (!spanIsSampled(span)) {\n return;\n }\n\n this._pendingSpans.add(spanId);\n\n if (!this._spanCompletionPromise) {\n this._spanCompletionPromise = new Promise(resolve => {\n this._resolveSpanCompletion = resolve;\n });\n }\n });\n\n this._unsubscribeSpanEnd = this.on('spanEnd', span => {\n const spanId = span.spanContext().spanId;\n DEBUG_BUILD && debug.log('[CloudflareClient] Span ended:', spanId);\n this._pendingSpans.delete(spanId);\n\n // If no more pending spans, resolve the completion promise\n if (this._pendingSpans.size === 0 && this._resolveSpanCompletion) {\n DEBUG_BUILD && debug.log('[CloudflareClient] All spans completed, resolving promise');\n this._resolveSpanCompletion();\n this._resetSpanCompletionPromise();\n }\n });\n }\n\n /**\n * Flushes pending operations and ensures all data is processed.\n * If a timeout is provided, the operation will be completed within the specified time limit.\n *\n * It will wait for all pending spans to complete before flushing.\n *\n * @param {number} [timeout] - Optional timeout in milliseconds to force the completion of the flush operation.\n * @return {Promise<boolean>} A promise that resolves to a boolean indicating whether the flush operation was successful.\n */\n public async flush(timeout?: number): Promise<boolean> {\n if (this._flushLock) {\n await this._flushLock.finalize();\n }\n\n if (this._pendingSpans.size > 0 && this._spanCompletionPromise) {\n DEBUG_BUILD &&\n debug.log('[CloudflareClient] Waiting for', this._pendingSpans.size, 'pending spans to complete...');\n\n const timeoutMs = timeout ?? 5000;\n const spanCompletionRace = Promise.race([\n this._spanCompletionPromise,\n new Promise(resolve =>\n setTimeout(() => {\n DEBUG_BUILD &&\n debug.log('[CloudflareClient] Span completion timeout after', timeoutMs, 'ms, flushing anyway');\n resolve(undefined);\n }, timeoutMs),\n ),\n ]);\n\n await spanCompletionRace;\n }\n\n return super.flush(timeout);\n }\n\n /**\n * Disposes of the client and releases all resources.\n *\n * This method clears all Cloudflare-specific state in addition to the base client cleanup.\n * It unsubscribes from span lifecycle events and clears pending span tracking.\n *\n * Call this method after flushing to allow the client to be garbage collected.\n * After calling dispose(), the client should not be used anymore.\n */\n public override dispose(): void {\n DEBUG_BUILD && debug.log('[CloudflareClient] Disposing client...');\n\n super.dispose();\n\n if (this._unsubscribeSpanStart) {\n this._unsubscribeSpanStart();\n this._unsubscribeSpanStart = null;\n }\n if (this._unsubscribeSpanEnd) {\n this._unsubscribeSpanEnd();\n this._unsubscribeSpanEnd = null;\n }\n\n this._resetSpanCompletionPromise();\n (this as unknown as { _flushLock: ReturnType<typeof makeFlushLock> | void })._flushLock = undefined;\n }\n\n /** @inheritDoc */\n protected override _setupIntegrations(): void {\n // Clear AI provider skip registrations before setting up integrations.\n // The registry is module-global and Cloudflare calls `init()` per request, so without this a\n // single `ai` SDK call would suppress direct `env.AI.run` spans for the rest of the isolate's\n // life. Mirrors the same reset in the Node client.\n _INTERNAL_clearAiProviderSkips();\n super._setupIntegrations();\n }\n\n /**\n * Resets the span completion promise and resolve function.\n */\n private _resetSpanCompletionPromise(): void {\n this._pendingSpans.clear();\n this._spanCompletionPromise = null;\n this._resolveSpanCompletion = null;\n }\n}\n\ninterface BaseCloudflareOptions {\n /**\n * @ignore Used internally to disable the deDupeIntegration for workflows.\n * @hidden Used internally to disable the deDupeIntegration for workflows.\n * @default true\n */\n enableDedupe?: boolean;\n\n /**\n * The Cloudflare SDK is not OpenTelemetry native. By default (`false`) it does not set up a tracer\n * provider; spans are emitted via the SDK's own instrumentation and scopes are isolated with\n * AsyncLocalStorage.\n *\n * Set this to `true` to opt into the OpenTelemetry compatibility tracer, which captures spans\n * emitted via `@opentelemetry/api`. Big caveat: it does not handle custom context, always working\n * off the current scope. This is good enough for many, but not all, integrations.\n *\n * @default false\n */\n enableOpenTelemetrySetup?: boolean;\n\n /**\n * Enable trace propagation for RPC calls between Workers, Durable Objects, and Service Bindings.\n *\n * When enabled, trace context (sentry-trace + baggage) is propagated across:\n * - `stub.fetch()` calls to Durable Objects (via HTTP headers)\n * - Service binding `fetch()` calls (via HTTP headers)\n * - RPC method calls to Durable Objects and WorkerEntrypoints (via trailing argument)\n *\n * When enabled on the **receiver side** (DurableObject or WorkerEntrypoint), the SDK will also:\n * - Extract and continue traces from incoming RPC calls\n * - Create spans for each RPC method invocation\n * - Capture errors thrown by RPC methods\n *\n * **Important:** This option is enabled by default. Set it to `false` to opt out, e.g. if you\n * do not want trace context to leave your Worker via RPC calls.\n *\n * @default true\n * @example\n * ```ts\n * // Opt out of RPC trace propagation\n * export default Sentry.withSentry(\n * (env) => ({\n * dsn: env.SENTRY_DSN,\n * enableRpcTracePropagation: false,\n * }),\n * handler,\n * );\n * ```\n */\n enableRpcTracePropagation?: boolean;\n\n /**\n * Table names that should stay instrumented even though they match the reserved `cf_` prefix used\n * by Durable Object frameworks (`agents`, `partyserver`, ...) for their internal SQLite tables.\n *\n * By default, `exec` queries against `cf_`-prefixed tables are treated as framework noise and no\n * `db.query` span is created for them. If one of your own tables happens to use this prefix, add it\n * here to opt it back into instrumentation. Entries are matched against each table name in the\n * query summary — strings must match exactly, while regular expressions give you prefix/pattern\n * matching.\n *\n * @default []\n * @example\n * ```ts\n * export default Sentry.withSentry(\n * (env) => ({\n * dsn: env.SENTRY_DSN,\n * durableObjectSqlSpanAllowlist: ['cf_my_table', /^cf_reports_/],\n * }),\n * handler,\n * );\n * ```\n */\n durableObjectSqlSpanAllowlist?: Array<string | RegExp>;\n\n /**\n * KV keys that should stay instrumented even though they match a reserved prefix used by Durable\n * Object frameworks (`agents`, `partyserver`, ...) for their internal storage entries.\n *\n * By default, KV reads/writes (`get`, `put`, `delete`, `list`) of `cf_`- or `__ps_`-prefixed keys\n * are treated as framework noise and no `durable_object_storage_*` span is created for them,\n * mirroring how `cf_`-prefixed SQL tables are handled (see {@link durableObjectSqlSpanAllowlist}).\n * If one of your own keys happens to use such a prefix, add it here to opt it back into\n * instrumentation. Strings must match exactly, while regular expressions give you prefix/pattern\n * matching.\n *\n * @default []\n * @example\n * ```ts\n * export default Sentry.withSentry(\n * (env) => ({\n * dsn: env.SENTRY_DSN,\n * durableObjectStorageSpanAllowlist: ['cf_my_key', /^cf_reports_/],\n * }),\n * handler,\n * );\n * ```\n */\n durableObjectStorageSpanAllowlist?: Array<string | RegExp>;\n\n /**\n * If you use Spotlight by Sentry during development, use\n * this option to forward captured Sentry events to Spotlight.\n *\n * Either set it to true, or provide a specific Spotlight Sidecar URL.\n *\n * More details: https://spotlightjs.com/\n *\n * IMPORTANT: Only set this option to `true` while developing, not in production!\n */\n spotlight?: boolean | string;\n}\n\n/**\n * Configuration options for the Sentry Cloudflare SDK\n *\n * @see @sentry/core Options for more information.\n */\nexport interface CloudflareOptions extends Options<CloudflareTransportOptions>, BaseCloudflareOptions {\n ctx?: ExecutionContextCompat;\n}\n\n/**\n * Configuration options for the Sentry Cloudflare SDK Client class\n *\n * @see CloudflareClient for more information.\n */\nexport interface CloudflareClientOptions extends ClientOptions<CloudflareTransportOptions>, BaseCloudflareOptions {\n flushLock?: ReturnType<typeof makeFlushLock>;\n}\n"],"names":[],"mappings":";;;AAmBO,MAAM,yBAAyB,mBAAA,CAAoB;AAAA;AAAA;AAAA;AAAA;AAAA,EAajD,YAAY,OAAA,EAAkC;AACnD,IAAA,gBAAA,CAAiB,SAAS,YAAY,CAAA;AACtC,IAAA,OAAA,CAAQ,SAAA,GAAY,OAAA,CAAQ,SAAA,IAAa,EAAC;AAC1C,IAAA,MAAM,EAAE,SAAA,EAAW,GAAG,aAAA,EAAc,GAAI,OAAA;AAExC,IAAA,MAAM,aAAA,GAA4C;AAAA,MAChD,GAAG,aAAA;AAAA,MACH,QAAA,EAAU,YAAA;AAAA;AAAA,MAEV,OAAA,EAAS,EAAE,IAAA,EAAM,YAAA,EAAa;AAAA;AAAA,MAE9B,cAAA,EAAgB;AAAA,KAClB;AAEA,IAAA,KAAA,CAAM,aAAa,CAAA;AAzBrB,IAAA,IAAA,CAAQ,aA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AAA,CAAK,qBAAA,EAAsB;AAC3B,MAAA,IAAA,CAAK,qBAAA,GAAwB,IAAA;AAAA,IAC/B;AACA,IAAA,IAAI,KAAK,mBAAA,EAAqB;AAC5B,MAAA,IAAA,CAAK,mBAAA,EAAoB;AACzB,MAAA,IAAA,CAAK,mBAAA,GAAsB,IAAA;AAAA,IAC7B;AAEA,IAAA,IAAA,CAAK,2BAAA,EAA4B;AACjC,IAAC,KAA4E,UAAA,GAAa,MAAA;AAAA,EAC5F;AAAA;AAAA,EAGmB,kBAAA,GAA2B;AAK5C,IAAA,8BAAA,EAA+B;AAC/B,IAAA,KAAA,CAAM,kBAAA,EAAmB;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKQ,2BAAA,GAAoC;AAC1C,IAAA,IAAA,CAAK,cAAc,KAAA,EAAM;AACzB,IAAA,IAAA,CAAK,sBAAA,GAAyB,IAAA;AAC9B,IAAA,IAAA,CAAK,sBAAA,GAAyB,IAAA;AAAA,EAChC;AACF;;;;"}
@@ -0,0 +1,4 @@
1
+ const DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);
2
+
3
+ export { DEBUG_BUILD };
4
+ //# sourceMappingURL=debug-build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-build.js","sources":["../../../src/debug-build.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n"],"names":[],"mappings":"AAOO,MAAM,WAAA,IAAc,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA;;;;"}
@@ -0,0 +1,9 @@
1
+ function defineCloudflareOptions(optionsOrCallback) {
2
+ if (typeof optionsOrCallback === "function") {
3
+ return optionsOrCallback;
4
+ }
5
+ return () => optionsOrCallback;
6
+ }
7
+
8
+ export { defineCloudflareOptions };
9
+ //# sourceMappingURL=defineCloudflareOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineCloudflareOptions.js","sources":["../../../src/defineCloudflareOptions.ts"],"sourcesContent":["import type { CloudflareOptions } from './client';\nimport type { DefaultEnv } from './types';\n\n/**\n * Define the Sentry options for a Cloudflare Worker in a dedicated module.\n *\n * This is the recommended way to configure the SDK when using the Vite plugin's\n * auto-instrumentation: place an `instrument.server.{ts,js,mjs}` file next to\n * the worker entry whose **default export** is the result of this function. The\n * plugin picks it up automatically and hands it to `withSentry`.\n *\n * Unlike Node's `Sentry.init(...)`, the options cannot be applied at module\n * load time on Cloudflare: the DSN and other settings typically come from the\n * per-request `env`, which only exists inside the handler. Pass a callback to\n * read from `env`, or a static object when no `env` access is needed — either\n * way you get full type-checking and autocomplete on {@link CloudflareOptions}.\n *\n * At runtime this is a thin pass-through; it only normalizes a static object\n * into a callback so the plugin always imports a `(env) => options` function.\n *\n * @example\n * ```ts\n * // src/instrument.server.ts\n * import { defineCloudflareOptions } from '@sentry/cloudflare';\n *\n * export default defineCloudflareOptions((env) => ({\n * dsn: env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * }));\n * ```\n *\n * @example\n * ```ts\n * // Static options — no `env` access needed\n * export default defineCloudflareOptions({ tracesSampleRate: 1.0 });\n * ```\n */\nexport function defineCloudflareOptions<Env = DefaultEnv>(\n optionsOrCallback: CloudflareOptions | ((env: Env) => CloudflareOptions | undefined),\n): (env: Env) => CloudflareOptions | undefined {\n if (typeof optionsOrCallback === 'function') {\n return optionsOrCallback;\n }\n\n return () => optionsOrCallback;\n}\n"],"names":[],"mappings":"AAqCO,SAAS,wBACd,iBAAA,EAC6C;AAC7C,EAAA,IAAI,OAAO,sBAAsB,UAAA,EAAY;AAC3C,IAAA,OAAO,iBAAA;AAAA,EACT;AAEA,EAAA,OAAO,MAAM,iBAAA;AACf;;;;"}