@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
package/README.md CHANGED
@@ -167,16 +167,12 @@ Sentry.captureEvent({
167
167
 
168
168
  ## Cloudflare D1 Instrumentation
169
169
 
170
- You can use the `instrumentD1WithSentry` method to instrument [Cloudflare D1](https://developers.cloudflare.com/d1/),
171
- Cloudflare's serverless SQL database with Sentry.
170
+ `withSentry()` automatically instruments all [Cloudflare D1](https://developers.cloudflare.com/d1/) bindings on `env`,
171
+ Cloudflare's serverless SQL database. Just use the binding as usual:
172
172
 
173
173
  ```javascript
174
- import * as Sentry from '@sentry/cloudflare';
175
-
176
174
  // env.DB is the D1 DB binding configured in your `wrangler.toml`
177
- const db = Sentry.instrumentD1WithSentry(env.DB);
178
- // Now you can use the database as usual
179
- await db.prepare('SELECT * FROM table WHERE id = ?').bind(1).run();
175
+ await env.DB.prepare('SELECT * FROM table WHERE id = ?').bind(1).run();
180
176
  ```
181
177
 
182
178
  ## Cron Monitoring (Cloudflare Workers)
@@ -3,9 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
3
  const core = require('@sentry/core');
4
4
  const client = require('./client.js');
5
5
  const flush = require('./flush.js');
6
- const httpServer = require('./integrations/httpServer.js');
7
6
  const fetch = require('./integrations/fetch.js');
8
- const hono = require('./integrations/hono.js');
7
+ const httpServer = require('./integrations/httpServer.js');
9
8
  const spotlight = require('./integrations/spotlight.js');
10
9
  const tracer = require('./opentelemetry/tracer.js');
11
10
  const transport = require('./transport.js');
@@ -15,23 +14,18 @@ function getRegisteredChannelIntegrations() {
15
14
  const registered = core.GLOBAL_OBJ.__SENTRY_ORCHESTRION__?.integrations;
16
15
  return registered ? [...registered.values()].map((factory) => factory()) : [];
17
16
  }
18
- function getDefaultIntegrations(options) {
19
- const cookiesEnabled = options.sendDefaultPii || options.dataCollection?.cookies != null;
17
+ function getBaseDefaultIntegrations(options) {
20
18
  return [
21
19
  // The Dedupe integration should not be used in workflows because we want to
22
20
  // capture all step failures, even if they are the same error.
23
21
  ...options.enableDedupe === false ? [] : [core.dedupeIntegration()],
24
- // TODO(v11): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`
25
- // eslint-disable-next-line typescript/no-deprecated
26
- core.inboundFiltersIntegration(),
22
+ core.eventFiltersIntegration(),
27
23
  core.functionToStringIntegration(),
28
24
  core.conversationIdIntegration(),
29
25
  core.linkedErrorsIntegration(),
30
26
  fetch.fetchIntegration(),
31
- // eslint-disable-next-line typescript/no-deprecated
32
- hono.honoIntegration(),
33
27
  httpServer.httpServerIntegration(),
34
- core.requestDataIntegration(cookiesEnabled ? void 0 : { include: { cookies: false } }),
28
+ core.requestDataIntegration(),
35
29
  core.consoleIntegration(),
36
30
  // The orchestrion diagnostics-channel subscribers (mysql, pg, …). The
37
31
  // `@sentry/cloudflare/vite` plugin injects the channels at build time and,
@@ -42,9 +36,9 @@ function getDefaultIntegrations(options) {
42
36
  ...getRegisteredChannelIntegrations()
43
37
  ];
44
38
  }
45
- function init(options) {
39
+ function initWithDefaultIntegrations(options, getDefaultIntegrationsImpl) {
46
40
  if (options.defaultIntegrations === void 0) {
47
- options.defaultIntegrations = getDefaultIntegrations(options);
41
+ options.defaultIntegrations = getDefaultIntegrationsImpl(options);
48
42
  }
49
43
  const flushLock = options.ctx ? flush.makeFlushLock(options.ctx) : void 0;
50
44
  delete options.ctx;
@@ -53,8 +47,12 @@ function init(options) {
53
47
  stackParser: core.stackParserFromStackParserOptions(options.stackParser || stacktrace.defaultStackParser),
54
48
  integrations: core.getIntegrationsToSetup(options),
55
49
  transport: options.transport || transport.makeCloudflareTransport,
50
+ // Like most Node-based SDKs, Cloudflare defaults to running without a Sentry OpenTelemetry tracer
51
+ // provider. Scope isolation is handled by the entrypoint wrappers' AsyncLocalStorage strategy.
52
+ enableOpenTelemetrySetup: options.enableOpenTelemetrySetup ?? false,
56
53
  flushLock
57
54
  };
55
+ /*! rollup-include-development-only */
58
56
  if (options.spotlight && !clientOptions.integrations.some(({ name }) => name === spotlight.INTEGRATION_NAME)) {
59
57
  clientOptions.integrations.push(
60
58
  spotlight.spotlightIntegration({
@@ -62,12 +60,24 @@ function init(options) {
62
60
  })
63
61
  );
64
62
  }
65
- if (!options.skipOpenTelemetrySetup) {
63
+ /*! rollup-include-development-only-end */
64
+ if (clientOptions.enableOpenTelemetrySetup) {
66
65
  tracer.setupOpenTelemetryTracer();
67
66
  }
68
- return core.initAndBind(client.CloudflareClient, clientOptions);
67
+ const client$1 = core.initAndBind(client.CloudflareClient, clientOptions);
68
+ client$1.on("orchestrion.module-injected", (moduleName) => {
69
+ const factory = core.GLOBAL_OBJ.__SENTRY_ORCHESTRION__?.integrations?.get(moduleName);
70
+ if (factory) {
71
+ client$1.addIntegration(factory());
72
+ }
73
+ });
74
+ return client$1;
75
+ }
76
+ function initBaseSdk(options) {
77
+ return initWithDefaultIntegrations(options, getBaseDefaultIntegrations);
69
78
  }
70
79
 
71
- exports.getDefaultIntegrations = getDefaultIntegrations;
72
- exports.init = init;
73
- //# sourceMappingURL=sdk.js.map
80
+ exports.getBaseDefaultIntegrations = getBaseDefaultIntegrations;
81
+ exports.initBaseSdk = initBaseSdk;
82
+ exports.initWithDefaultIntegrations = initWithDefaultIntegrations;
83
+ //# 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":["GLOBAL_OBJ","dedupeIntegration","eventFiltersIntegration","functionToStringIntegration","conversationIdIntegration","linkedErrorsIntegration","fetchIntegration","httpServerIntegration","requestDataIntegration","consoleIntegration","makeFlushLock","stackParserFromStackParserOptions","defaultStackParser","getIntegrationsToSetup","makeCloudflareTransport","SPOTLIGHT_INTEGRATION_NAME","spotlightIntegration","setupOpenTelemetryTracer","client","initAndBind","CloudflareClient"],"mappings":";;;;;;;;;;;;AAmCA,SAAS,gCAAA,GAAkD;AACzD,EAAA,MAAM,UAAA,GAAaA,gBAAW,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,CAACC,wBAAmB,CAAA;AAAA,IAC9DC,4BAAA,EAAwB;AAAA,IACxBC,gCAAA,EAA4B;AAAA,IAC5BC,8BAAA,EAA0B;AAAA,IAC1BC,4BAAA,EAAwB;AAAA,IACxBC,sBAAA,EAAiB;AAAA,IACjBC,gCAAA,EAAsB;AAAA,IACtBC,2BAAA,EAAuB;AAAA,IACvBC,uBAAA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOnB,GAAG,gCAAA;AAAiC,GACtC;AACF;AAUO,SAAS,2BAAA,CACd,SACA,0BAAA,EAC8B;AAC9B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,CAAA;AAC/E,IAAA,IAAI,OAAA,EAAS;AACX,MAAAkB,QAAA,CAAO,cAAA,CAAe,SAAS,CAAA;AAAA,IACjC;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAOA,QAAA;AACT;AAOO,SAAS,YAAY,OAAA,EAA0D;AACpF,EAAA,OAAO,2BAAA,CAA4B,SAAS,0BAA0B,CAAA;AACxE;;;;;;"}
@@ -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":["ServerRuntimeClient","applySdkMetadata","DEBUG_BUILD","debug","spanIsSampled","_INTERNAL_clearAiProviderSkips"],"mappings":";;;;;AAmBO,MAAM,yBAAyBA,wBAAA,CAAoB;AAAA;AAAA;AAAA;AAAA;AAAA,EAajD,YAAY,OAAA,EAAkC;AACnD,IAAAC,qBAAA,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;AAA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UAAA,CAAM,IAAI,wCAAwC,CAAA;AAEjE,IAAA,KAAA,CAAM,OAAA,EAAQ;AAEd,IAAA,IAAI,KAAK,qBAAA,EAAuB;AAC9B,MAAA,IAAA,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,IAAAE,mCAAA,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 @@
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 @@
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;;;;"}
@@ -1,19 +1,19 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const core = require('@sentry/core');
4
- const async = require('./async.js');
4
+ const noDiagnosticChannels = require('@sentry/server-utils/no-diagnostic-channels');
5
5
  const instrument = require('./instrument.js');
6
6
  const instrumentEnv = require('./instrumentations/worker/instrumentEnv.js');
7
7
  const options = require('./options.js');
8
8
  const request = require('./request.js');
9
+ const sdk = require('./sdk.js');
9
10
  const instrumentContext = require('./utils/instrumentContext.js');
10
11
  const rpcMeta = require('./utils/rpcMeta.js');
11
- const rpcOptions = require('./utils/rpcOptions.js');
12
12
  const index = require('./instrumentations/agents/index.js');
13
13
  const wrapMethodWithSentry = require('./wrapMethodWithSentry.js');
14
14
 
15
15
  function constructInstrumentedDurableObject(target, ctx, env, newTarget, optionsCallback) {
16
- async.setAsyncLocalStorageAsyncContextStrategy();
16
+ noDiagnosticChannels.setAsyncLocalStorageAsyncContextStrategy();
17
17
  const options$1 = options.getFinalOptions(optionsCallback(env), env);
18
18
  const context = instrumentContext.instrumentContext(ctx);
19
19
  const instrumentedEnv = instrumentEnv.instrumentEnv(env, options$1);
@@ -67,9 +67,13 @@ function instrumentDurableObjectHandlers(obj, options, context) {
67
67
  obj.fetch.bind(obj),
68
68
  (original) => new Proxy(original, {
69
69
  apply(target, thisArg, args) {
70
- return request.wrapRequestHandler({ options, request: args[0], context }, () => {
71
- return Reflect.apply(target, thisArg, args);
72
- });
70
+ return request.wrapRequestHandlerWithInit(
71
+ { options, request: args[0], context },
72
+ () => {
73
+ return Reflect.apply(target, thisArg, args);
74
+ },
75
+ sdk.init
76
+ );
73
77
  }
74
78
  })
75
79
  );
@@ -124,21 +128,15 @@ const RESERVED_RPC_METHOD_NAMES = /* @__PURE__ */ new Set([
124
128
  ]);
125
129
  const rpcInstanceStates = /* @__PURE__ */ new WeakMap();
126
130
  function finalizeWithRpcInstrumentation(obj, options, context, excludedMethods) {
127
- const rpcPropagation = rpcOptions.getEffectiveRpcPropagation(options);
128
- if (!rpcPropagation) {
131
+ if (options.enableRpcTracePropagation === false) {
129
132
  return obj;
130
133
  }
131
- const allowedMethods = Array.isArray(options.instrumentPrototypeMethods) ? (
132
- // eslint-disable-next-line typescript/no-deprecated
133
- new Set(options.instrumentPrototypeMethods)
134
- ) : void 0;
135
- const alwaysTrace = options.enableRpcTracePropagation === void 0;
136
- rpcInstanceStates.set(obj, { options, context, alwaysTrace });
137
- instrumentPrototypeRpcMethods(obj, excludedMethods, allowedMethods);
134
+ rpcInstanceStates.set(obj, { options, context });
135
+ instrumentPrototypeRpcMethods(obj, excludedMethods);
138
136
  return obj;
139
137
  }
140
- function getRpcMethodDescriptor(obj, prototype, methodName, excludedMethods, allowedMethods) {
141
- if (RESERVED_RPC_METHOD_NAMES.has(methodName) || Object.prototype.hasOwnProperty.call(obj, methodName) || excludedMethods?.has(methodName) || allowedMethods && !allowedMethods.has(methodName)) {
138
+ function getRpcMethodDescriptor(obj, prototype, methodName, excludedMethods) {
139
+ if (RESERVED_RPC_METHOD_NAMES.has(methodName) || Object.prototype.hasOwnProperty.call(obj, methodName) || excludedMethods?.has(methodName)) {
142
140
  return void 0;
143
141
  }
144
142
  const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
@@ -147,11 +145,11 @@ function getRpcMethodDescriptor(obj, prototype, methodName, excludedMethods, all
147
145
  }
148
146
  return descriptor;
149
147
  }
150
- function instrumentPrototypeRpcMethods(obj, excludedMethods, allowedMethods) {
148
+ function instrumentPrototypeRpcMethods(obj, excludedMethods) {
151
149
  let prototype = Object.getPrototypeOf(obj);
152
150
  while (prototype && prototype !== Object.prototype) {
153
151
  for (const methodName of Object.getOwnPropertyNames(prototype)) {
154
- const descriptor = getRpcMethodDescriptor(obj, prototype, methodName, excludedMethods, allowedMethods);
152
+ const descriptor = getRpcMethodDescriptor(obj, prototype, methodName, excludedMethods);
155
153
  if (!descriptor) {
156
154
  continue;
157
155
  }
@@ -167,8 +165,11 @@ function instrumentPrototypeRpcMethods(obj, excludedMethods, allowedMethods) {
167
165
  }
168
166
  function createRpcPrototypeWrapper(methodName, originalMethod) {
169
167
  const wrapper = function(...args) {
168
+ if (!rpcMeta.hasRpcMeta(args)) {
169
+ return Reflect.apply(originalMethod, this, args);
170
+ }
170
171
  const state = core.isObjectLike(this) ? rpcInstanceStates.get(this) : void 0;
171
- if (!state || !state.alwaysTrace && !rpcMeta.hasRpcMeta(args)) {
172
+ if (!state) {
172
173
  return Reflect.apply(originalMethod, this, args);
173
174
  }
174
175
  const tracedMethods = state.tracedMethods ?? (state.tracedMethods = /* @__PURE__ */ new Map());
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durableobject.js","sources":["../../../src/durableobject.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/unbound-method */\nimport { captureException, isObjectLike } from '@sentry/core';\nimport type { DurableObject } from 'cloudflare:workers';\nimport { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';\nimport type { CloudflareOptions } from './client';\nimport { ensureInstrumented, getInstrumented, markAsInstrumented } from './instrument';\nimport { instrumentEnv } from './instrumentations/worker/instrumentEnv';\nimport { getFinalOptions } from './options';\nimport { wrapRequestHandlerWithInit } from './request';\nimport { init } from './sdk';\nimport { instrumentContext } from './utils/instrumentContext';\nimport { hasRpcMeta } from './utils/rpcMeta';\nimport { instrumentCloudflareAgent } from './instrumentations/agents';\nimport type { DefaultEnv, ResolveEnv } from './types';\nimport { type UncheckedMethod, wrapMethodWithSentry } from './wrapMethodWithSentry';\n\n/**\n * The instrumented context passed between the shared construction helpers.\n *\n * This is intentionally `any` rather than `ReturnType<typeof instrumentContext<DurableObjectState>>`.\n * A concrete `DurableObjectState` here forces `tsc` to structurally relate its `storage: SqlStorage`\n * graph against the `ExecutionContext | InstrumentedDurableObjectState` parameter of\n * `wrapMethodWithSentry`, while the RPC-branded `DurableObject` from `cloudflare:workers` is also in\n * scope. That union comparison explodes (1296×1296) and hangs the type build. The original inline\n * implementation avoided this only incidentally, because `ctx` reached it as `any` through the Proxy\n * `construct` trap. Keeping the shared context `any` preserves that behavior.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype InstrumentedDurableObjectContext = any;\n\n/**\n * Constructs a Durable Object instance and instruments its built-in handler methods\n * (`fetch`, `alarm`, `webSocketMessage`, `webSocketClose`, `webSocketError`).\n *\n * This is the shared construction path used by both {@link instrumentDurableObjectWithSentry}\n * and {@link instrumentAgentWithSentry}. It intentionally does NOT apply the RPC prototype-method\n * instrumentation — callers apply that last via {@link finalizeWithRpcInstrumentation}, after any\n * additional per-instance instrumentation has been layered onto the returned object.\n *\n * @internal\n */\nexport function constructInstrumentedDurableObject<E, T extends DurableObject<E>>(\n target: new (state: DurableObjectState, env: E) => T,\n ctx: DurableObjectState,\n env: E,\n newTarget: NewableFunction,\n optionsCallback: (env: E) => CloudflareOptions,\n): {\n obj: T;\n options: CloudflareOptions;\n context: InstrumentedDurableObjectContext;\n frameworkManagedMethods: ReadonlySet<string>;\n} {\n setAsyncLocalStorageAsyncContextStrategy();\n const options = getFinalOptions(optionsCallback(env), env);\n // See InstrumentedDurableObjectContext — `ctx` is widened to `any` so the concrete\n // `DurableObjectState` type never enters the checker's relation graph in this module.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const context = instrumentContext(ctx as any);\n const instrumentedEnv = instrumentEnv(env as Record<string, unknown>, options);\n\n const prototype = (newTarget as unknown as { prototype?: object }).prototype ?? target.prototype;\n const cachedFrameworkManagedMethods = frameworkManagedMethodsCache.get(prototype);\n const methodsBeforeConstruction = cachedFrameworkManagedMethods ? undefined : resolvePrototypeMethods(prototype);\n\n // Pass `newTarget` so that subclasses of the instrumented class (e.g. the wrapper classes\n // created by wrangler's local dev tooling or `@cloudflare/vitest-pool-workers`) keep their\n // own prototype — otherwise subclass methods disappear and `instanceof` checks break.\n const obj = Reflect.construct(target, [context, instrumentedEnv], newTarget) as T;\n\n const frameworkManagedMethods = resolveFrameworkManagedMethods(\n prototype,\n obj,\n methodsBeforeConstruction,\n cachedFrameworkManagedMethods,\n );\n\n instrumentDurableObjectHandlers(obj, options, context);\n\n return { obj, options, context, frameworkManagedMethods };\n}\n\nconst frameworkManagedMethodsCache = new WeakMap<object, ReadonlySet<string>>();\n\n/**\n * Collects the methods visible from a prototype, using normal property lookup precedence.\n * Methods inherited from `Object.prototype` are excluded because they cannot be Durable Object RPC methods.\n */\nfunction resolvePrototypeMethods(prototype: object | null): Map<string, unknown> {\n const methods = new Map<string, unknown>();\n\n for (let current = prototype; current && current !== Object.prototype; current = Object.getPrototypeOf(current)) {\n for (const name of Object.getOwnPropertyNames(current)) {\n // The first occurrence wins, mirroring what a property lookup on the instance would find\n if (name === 'constructor' || methods.has(name)) {\n continue;\n }\n\n const descriptor = Object.getOwnPropertyDescriptor(current, name);\n\n if (descriptor && typeof descriptor.value === 'function') {\n methods.set(name, descriptor.value);\n }\n }\n }\n\n return methods;\n}\n\n/**\n * Finds methods that a framework replaced while constructing the first instance.\n *\n * Some frameworks register methods by function identity, so replacing one of their wrappers would\n * break dispatch. The result is cached because frameworks commonly install their wrappers only\n * once; later constructions would no longer reveal which methods they manage.\n */\nfunction resolveFrameworkManagedMethods(\n prototype: object,\n obj: object,\n methodsBeforeConstruction: Map<string, unknown> | undefined,\n cached: ReadonlySet<string> | undefined,\n): ReadonlySet<string> {\n if (cached) {\n return cached;\n }\n\n const methodsAfterConstruction = resolvePrototypeMethods(Object.getPrototypeOf(obj) as object);\n const managed = new Set<string>();\n\n for (const [name, method] of methodsAfterConstruction) {\n const before = methodsBeforeConstruction?.get(name);\n\n if (before && before !== method) {\n managed.add(name);\n }\n }\n\n frameworkManagedMethodsCache.set(prototype, managed);\n\n return managed;\n}\n\n/**\n * Instruments the built-in Durable Object handler methods on a constructed instance.\n *\n * These are the methods that are available on a Durable Object\n * ref: https://developers.cloudflare.com/durable-objects/api/base/\n * - obj.alarm\n * - obj.fetch\n * - obj.webSocketError\n * - obj.webSocketClose\n * - obj.webSocketMessage\n *\n * Any other public methods on the Durable Object instance are RPC calls.\n */\nfunction instrumentDurableObjectHandlers<E, T extends DurableObject<E>>(\n obj: T,\n options: CloudflareOptions,\n context: InstrumentedDurableObjectContext,\n): void {\n // Bind each built-in handler to this instance before wrapping.\n // See https://github.com/getsentry/sentry-javascript/issues/22328\n if (obj.fetch && typeof obj.fetch === 'function') {\n obj.fetch = ensureInstrumented(\n obj.fetch.bind(obj),\n original =>\n new Proxy(original, {\n apply(target, thisArg, args) {\n return wrapRequestHandlerWithInit(\n { options, request: args[0], context },\n () => {\n return Reflect.apply(target, thisArg, args);\n },\n init,\n );\n },\n }),\n );\n }\n\n if (obj.alarm && typeof obj.alarm === 'function') {\n // Alarms are independent invocations, so we start a new trace and link to the previous alarm\n obj.alarm = wrapMethodWithSentry(\n {\n options,\n context,\n spanName: 'alarm',\n spanOp: 'function',\n startNewTrace: true,\n origin: 'auto.faas.cloudflare.durable_object',\n },\n obj.alarm.bind(obj),\n );\n }\n\n if (obj.webSocketMessage && typeof obj.webSocketMessage === 'function') {\n obj.webSocketMessage = wrapMethodWithSentry(\n { options, context, spanName: 'webSocketMessage', origin: 'auto.faas.cloudflare.durable_object' },\n obj.webSocketMessage.bind(obj),\n );\n }\n\n if (obj.webSocketClose && typeof obj.webSocketClose === 'function') {\n obj.webSocketClose = wrapMethodWithSentry(\n { options, context, spanName: 'webSocketClose', origin: 'auto.faas.cloudflare.durable_object' },\n obj.webSocketClose.bind(obj),\n );\n }\n\n if (obj.webSocketError && typeof obj.webSocketError === 'function') {\n obj.webSocketError = wrapMethodWithSentry(\n { options, context, spanName: 'webSocketError', origin: 'auto.faas.cloudflare.durable_object' },\n obj.webSocketError.bind(obj),\n (_, error) =>\n captureException(error, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object_websocket',\n handled: false,\n },\n }),\n );\n }\n}\n\ntype RpcInstanceState = {\n options: CloudflareOptions;\n context: InstrumentedDurableObjectContext;\n /** Per-instance cache of the traced method wrappers, keyed by method name. Created on first use. */\n tracedMethods?: Map<string, UncheckedMethod>;\n};\n\n/**\n * Method names the runtime never dispatches over RPC, so wrapping them buys no tracing.\n *\n * Mirrors `isReservedName` in workerd (`src/workerd/api/worker-rpc.c++`): the runtime rejects these\n * before any property lookup happens. `fetch`, `alarm` and the `webSocket*` handlers are also\n * instrumented per-instance as own properties, and `constructor` is on every prototype.\n */\nconst RESERVED_RPC_METHOD_NAMES: ReadonlySet<string> = new Set([\n 'constructor',\n 'fetch',\n 'connect',\n 'alarm',\n 'webSocketMessage',\n 'webSocketClose',\n 'webSocketError',\n 'dup',\n]);\n\n// Prototype wrappers are shared by all instances, while SDK options and traced method caches are not.\nconst rpcInstanceStates = new WeakMap<object, RpcInstanceState>();\n\n/**\n * Adds trace propagation to a constructed Durable Object's RPC methods.\n *\n * RPC methods are wrapped on the prototype because Cloudflare dispatches them with the Durable\n * Object instance as the receiver. This preserves native private-field access and keeps the methods\n * visible to Cloudflare's RPC dispatcher. Built-in handlers, Agent handlers, and methods managed by\n * another framework are left untouched.\n *\n * Call this after all per-instance instrumentation has been applied. If RPC trace propagation is\n * disabled, the object is returned unchanged.\n *\n * @param obj The constructed Durable Object instance.\n * @param options The resolved SDK options for this instance.\n * @param context The instrumented execution context for this instance.\n * @param excludedMethods Method names owned by another framework and therefore not safe to wrap.\n * @returns The same Durable Object instance, with eligible prototype methods instrumented.\n * @internal\n */\nexport function finalizeWithRpcInstrumentation<T extends object>(\n obj: T,\n options: CloudflareOptions,\n context: InstrumentedDurableObjectContext,\n excludedMethods?: ReadonlySet<string>,\n): T {\n // Skip RPC instrumentation only when explicitly opted out (enabled by default)\n if (options.enableRpcTracePropagation === false) {\n return obj;\n }\n\n rpcInstanceStates.set(obj, { options, context });\n\n instrumentPrototypeRpcMethods(obj, excludedMethods);\n\n return obj;\n}\n\n/**\n * Returns a prototype method when it is eligible for RPC instrumentation.\n */\nfunction getRpcMethodDescriptor(\n obj: object,\n prototype: object,\n methodName: string,\n excludedMethods?: ReadonlySet<string>,\n): PropertyDescriptor | undefined {\n if (\n RESERVED_RPC_METHOD_NAMES.has(methodName) ||\n Object.prototype.hasOwnProperty.call(obj, methodName) ||\n excludedMethods?.has(methodName)\n ) {\n return undefined;\n }\n\n const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);\n\n if (!descriptor || typeof descriptor.value !== 'function' || getInstrumented(descriptor.value)) {\n return undefined;\n }\n\n return descriptor;\n}\n\n/**\n * Wraps eligible methods on the instance's prototype chain once per class.\n */\nfunction instrumentPrototypeRpcMethods(obj: object, excludedMethods?: ReadonlySet<string>): void {\n let prototype: object | null = Object.getPrototypeOf(obj);\n\n while (prototype && prototype !== Object.prototype) {\n for (const methodName of Object.getOwnPropertyNames(prototype)) {\n const descriptor = getRpcMethodDescriptor(obj, prototype, methodName, excludedMethods);\n\n if (!descriptor) {\n continue;\n }\n\n const wrapped = createRpcPrototypeWrapper(methodName, descriptor.value as UncheckedMethod);\n\n try {\n Object.defineProperty(prototype, methodName, { ...descriptor, value: wrapped });\n } catch {}\n\n // Only the wrapper is marked, not the original method: `wrapMethodWithSentry` resolves\n // through the same global map and must not resolve the original to this wrapper,\n // which would recurse.\n markAsInstrumented(wrapped);\n }\n\n prototype = Object.getPrototypeOf(prototype);\n }\n}\n\n/**\n * Creates a prototype wrapper that traces RPC calls carrying Sentry metadata.\n *\n * The wrapper looks up SDK state from its receiver, allowing one prototype function to serve every\n * instance. Calls without RPC metadata or instance state use the original method directly. The\n * original function name and arity are preserved because frameworks may inspect them for dispatch.\n */\nfunction createRpcPrototypeWrapper(methodName: string, originalMethod: UncheckedMethod): UncheckedMethod {\n const wrapper = function (this: unknown, ...args: unknown[]): unknown {\n // Untraced calls are the common case — every internal call the instance makes to one of its\n // own methods lands here too — so check the arguments before touching per-instance state.\n if (!hasRpcMeta(args)) {\n return Reflect.apply(originalMethod, this, args);\n }\n\n const state = isObjectLike(this) ? rpcInstanceStates.get(this) : undefined;\n\n if (!state) {\n return Reflect.apply(originalMethod, this, args);\n }\n\n const tracedMethods = (state.tracedMethods ??= new Map());\n let traced = tracedMethods.get(methodName);\n\n if (!traced) {\n traced = wrapMethodWithSentry(\n {\n options: state.options,\n context: state.context,\n spanName: methodName,\n spanOp: 'rpc',\n origin: 'auto.faas.cloudflare.durable_object',\n },\n originalMethod,\n undefined,\n true,\n );\n tracedMethods.set(methodName, traced);\n }\n\n return Reflect.apply(traced, this, args);\n };\n\n Object.defineProperties(wrapper, {\n name: { value: originalMethod.name, configurable: true },\n length: { value: originalMethod.length, configurable: true },\n });\n\n return wrapper as UncheckedMethod;\n}\n\n/**\n * Instruments a Durable Object class to capture errors and performance data.\n *\n * Instruments the following methods by default:\n * - fetch\n * - alarm\n * - webSocketMessage\n * - webSocketClose\n * - webSocketError\n *\n * RPC methods (prototype methods) are instrumented by default. Set `enableRpcTracePropagation`\n * to `false` to opt out.\n *\n * @param optionsCallback Function that returns the options for the SDK initialization.\n * @param DurableObjectClass The Durable Object class to instrument.\n * @returns The instrumented Durable Object class.\n *\n * @example\n * ```ts\n * class MyDurableObjectBase extends DurableObject {\n * constructor(ctx: DurableObjectState, env: Env) {\n * super(ctx, env);\n * }\n * }\n *\n * export const MyDurableObject = instrumentDurableObjectWithSentry(\n * env => ({\n * dsn: env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * }),\n * MyDurableObjectBase,\n * );\n * ```\n */\nexport function instrumentDurableObjectWithSentry<\n Env = DefaultEnv,\n // oxlint-disable-next-line typescript/no-explicit-any\n T extends DurableObject<any> = DurableObject<Env>,\n // oxlint-disable-next-line typescript/no-explicit-any\n C extends new (state: DurableObjectState, env: any) => T = new (state: DurableObjectState, env: any) => T,\n>(optionsCallback: (env: ResolveEnv<C, Env>) => CloudflareOptions, DurableObjectClass: C): C {\n return new Proxy(DurableObjectClass, {\n construct(target, [ctx, env], newTarget) {\n const { obj, options, context, frameworkManagedMethods } = constructInstrumentedDurableObject(\n target,\n ctx,\n env,\n newTarget,\n optionsCallback,\n );\n\n return finalizeWithRpcInstrumentation(obj, options, context, frameworkManagedMethods);\n },\n });\n}\n\n/**\n * Instruments a Cloudflare [`agents`](https://www.npmjs.com/package/agents) Agent class with Sentry.\n *\n * An `Agent` is a Durable Object under the hood, so this applies the same instrumentation as\n * {@link instrumentDurableObjectWithSentry} (request transactions, `alarm`, WebSocket handlers, RPC\n * trace propagation, SQL spans) and additionally captures Agent-specific telemetry via\n * `instrumentCloudflareAgent`:\n *\n * - **Callable RPC spans** — a span (op `rpc`) for each `@callable()` method invoked over WebSocket.\n * - **Breadcrumbs** — for every Agent observability event (`rpc`, `state:update`, `connect`,\n * `disconnect`, `schedule:*`, `queue:*`, `workflow:*`, `email:*`, `mcp:*`, ...).\n *\n * Cloudflare Workers cannot auto-instrument, so the Agent class must be wrapped manually.\n *\n * @param optionsCallback Function that returns the options for the SDK initialization.\n * @param AgentClass The Agent class to instrument.\n * @returns The instrumented Agent class.\n *\n * @example\n * ```ts\n * import { Agent, callable, routeAgentRequest } from 'agents';\n * import * as Sentry from '@sentry/cloudflare';\n *\n * class MyAgentBase extends Agent<Env> {\n * @callable()\n * async greet(name: string): Promise<string> {\n * return `Hello, ${name}!`;\n * }\n * }\n *\n * export const MyAgent = Sentry.instrumentAgentWithSentry(\n * env => ({\n * dsn: env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * }),\n * MyAgentBase,\n * );\n * ```\n */\nexport function instrumentAgentWithSentry<\n Env = DefaultEnv,\n // oxlint-disable-next-line typescript/no-explicit-any\n T extends DurableObject<any> = DurableObject<Env>,\n // oxlint-disable-next-line typescript/no-explicit-any\n C extends new (state: DurableObjectState, env: any) => T = new (state: DurableObjectState, env: any) => T,\n>(optionsCallback: (env: ResolveEnv<C, Env>) => CloudflareOptions, AgentClass: C): C {\n return new Proxy(AgentClass, {\n construct(target, [ctx, env], newTarget) {\n const { obj, options, context, frameworkManagedMethods } = constructInstrumentedDurableObject(\n target,\n ctx,\n env,\n newTarget,\n optionsCallback,\n );\n\n instrumentCloudflareAgent(obj);\n\n // Apply RPC prototype-method instrumentation last, so the Agent-specific own-property\n // handlers we just installed are excluded from RPC method tracing. Methods the Agent\n // framework installed itself are excluded too — `instrumentCloudflareAgent` traces those by\n // wrapping the dispatch instead of the method.\n return finalizeWithRpcInstrumentation(obj, options, context, frameworkManagedMethods);\n },\n });\n}\n"],"names":["setAsyncLocalStorageAsyncContextStrategy","options","getFinalOptions","instrumentContext","instrumentEnv","ensureInstrumented","wrapRequestHandlerWithInit","init","wrapMethodWithSentry","captureException","getInstrumented","markAsInstrumented","hasRpcMeta","isObjectLike","instrumentCloudflareAgent"],"mappings":";;;;;;;;;;;;;;AAyCO,SAAS,kCAAA,CACd,MAAA,EACA,GAAA,EACA,GAAA,EACA,WACA,eAAA,EAMA;AACA,EAAAA,6DAAA,EAAyC;AACzC,EAAA,MAAMC,SAAA,GAAUC,uBAAA,CAAgB,eAAA,CAAgB,GAAG,GAAG,GAAG,CAAA;AAIzD,EAAA,MAAM,OAAA,GAAUC,oCAAkB,GAAU,CAAA;AAC5C,EAAA,MAAM,eAAA,GAAkBC,2BAAA,CAAc,GAAA,EAAgCH,SAAO,CAAA;AAE7E,EAAA,MAAM,SAAA,GAAa,SAAA,CAAgD,SAAA,IAAa,MAAA,CAAO,SAAA;AACvF,EAAA,MAAM,6BAAA,GAAgC,4BAAA,CAA6B,GAAA,CAAI,SAAS,CAAA;AAChF,EAAA,MAAM,yBAAA,GAA4B,6BAAA,GAAgC,MAAA,GAAY,uBAAA,CAAwB,SAAS,CAAA;AAK/G,EAAA,MAAM,GAAA,GAAM,QAAQ,SAAA,CAAU,MAAA,EAAQ,CAAC,OAAA,EAAS,eAAe,GAAG,SAAS,CAAA;AAE3E,EAAA,MAAM,uBAAA,GAA0B,8BAAA;AAAA,IAC9B,SAAA;AAAA,IACA,GAAA;AAAA,IACA,yBAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,+BAAA,CAAgC,GAAA,EAAKA,WAAS,OAAO,CAAA;AAErD,EAAA,OAAO,EAAE,GAAA,WAAKA,SAAA,EAAS,OAAA,EAAS,uBAAA,EAAwB;AAC1D;AAEA,MAAM,4BAAA,uBAAmC,OAAA,EAAqC;AAM9E,SAAS,wBAAwB,SAAA,EAAgD;AAC/E,EAAA,MAAM,OAAA,uBAAc,GAAA,EAAqB;AAEzC,EAAA,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GAAA,EAAK,OAAA,EAAS,OAAA,EAAS,uBAAuB,CAAA;AAAA,IACtF;AAAA,GACD,CAAA;AACH;;;;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flush.js","sources":["../../../src/flush.ts"],"sourcesContent":["import type { ExecutionContext } from '@cloudflare/workers-types';\nimport type { Client } from '@sentry/core';\nimport { debug, flush } from '@sentry/core';\nimport { DEBUG_BUILD } from './debug-build';\nimport type { ExecutionContextCompat } from './executionContext';\n\ntype FlushLock = {\n readonly ready: Promise<void>;\n readonly finalize: () => Promise<void>;\n};\n\ntype FlushLockRegistry = {\n readonly locks: Set<FlushLockInternal>;\n readonly originalWaitUntil: ExecutionContext['waitUntil'];\n};\n\ntype FlushLockInternal = FlushLock & {\n readonly acquire: () => void;\n readonly release: () => void;\n};\n\nconst flushLockRegistries = new WeakMap<ExecutionContext['waitUntil'], FlushLockRegistry>();\n\n/**\n * Returns the original (un-instrumented) waitUntil function for a context.\n * This should be used when calling waitUntil with flushAndDispose to avoid deadlock.\n *\n * The flush lock mechanism wraps context.waitUntil to track pending tasks.\n * If we call waitUntil(flushAndDispose(client)) through the instrumented version,\n * it creates a deadlock because:\n * 1. The instrumented waitUntil acquires the flush lock\n * 2. flushAndDispose calls client.flush() which waits for the lock to be released\n * 3. The lock won't be released until the waitUntil promise completes\n * 4. The waitUntil promise won't complete until flush() returns\n *\n * By using the original waitUntil for flush operations, we bypass this issue.\n */\nexport function getOriginalWaitUntil(context: ExecutionContextCompat): ExecutionContext['waitUntil'] {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const currentWaitUntil = context.waitUntil;\n const original = flushLockRegistries.get(currentWaitUntil)?.originalWaitUntil;\n return original ?? currentWaitUntil;\n}\n\n/**\n * Enhances the given execution context by wrapping its `waitUntil` method with a proxy\n * to monitor pending tasks, and provides a flusher function to ensure all tasks\n * have been completed before executing any subsequent logic.\n *\n * @param {ExecutionContext} context - The execution context to be enhanced. If no context is provided, the function returns undefined.\n * @return {FlushLock} Returns a flusher function if a valid context is provided, otherwise undefined.\n */\nexport function makeFlushLock(context: ExecutionContextCompat): FlushLock {\n const registry = getOrCreateFlushLockRegistry(context);\n let resolveAllDone: () => void = () => undefined;\n const allDone = new Promise<void>(res => {\n resolveAllDone = res;\n });\n let pending = 0;\n\n const lock: FlushLockInternal = {\n ready: allDone,\n acquire: () => {\n pending++;\n },\n release: () => {\n if (--pending === 0) {\n registry.locks.delete(lock);\n resolveAllDone();\n }\n },\n finalize: () => {\n if (pending === 0) {\n registry.locks.delete(lock);\n resolveAllDone();\n }\n return allDone;\n },\n };\n\n registry.locks.add(lock);\n return Object.freeze(lock);\n}\n\nfunction getOrCreateFlushLockRegistry(context: ExecutionContextCompat): FlushLockRegistry {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const waitUntil = context.waitUntil;\n const existingRegistry = flushLockRegistries.get(waitUntil);\n\n if (existingRegistry) {\n return existingRegistry;\n }\n\n const originalWaitUntil = context.waitUntil.bind(context) as typeof context.waitUntil;\n const registry: FlushLockRegistry = { locks: new Set(), originalWaitUntil };\n const instrumentedWaitUntil: typeof context.waitUntil = promise => {\n // Snapshot active locks so locks created after this call do not wait for earlier waitUntil work.\n const locks = [...registry.locks];\n\n for (const lock of locks) {\n lock.acquire();\n }\n\n return originalWaitUntil(\n promise.finally(() => {\n for (const lock of locks) {\n lock.release();\n }\n }),\n );\n };\n\n flushLockRegistries.set(instrumentedWaitUntil, registry);\n context.waitUntil = instrumentedWaitUntil;\n\n return registry;\n}\n\n/**\n * Flushes the client and then disposes of it to allow garbage collection.\n * This should be called at the end of each request to prevent memory leaks.\n *\n * This function never rejects. On Workers, a rejected promise passed to\n * `ctx.waitUntil` marks the whole invocation as `outcome: exception` even when\n * the handler itself completed successfully. Since flush/dispose is internal\n * SDK housekeeping, a failure here must not fail the user's invocation.\n *\n * @param client - The CloudflareClient instance to flush and dispose\n * @param timeout - Timeout in milliseconds for the flush operation\n * @returns A promise that resolves when flush and dispose are complete\n */\nexport async function flushAndDispose(client: Client | undefined, timeout = 2000): Promise<void> {\n try {\n if (!client) {\n await flush(timeout);\n return;\n }\n await client.flush(timeout);\n } catch (e) {\n DEBUG_BUILD && debug.warn('Failed to flush client', e);\n } finally {\n try {\n client?.dispose();\n } catch (e) {\n DEBUG_BUILD && debug.warn('Failed to dispose client', e);\n }\n }\n}\n"],"names":["flush","DEBUG_BUILD","debug"],"mappings":";;;;;AAqBA,MAAM,mBAAA,uBAA0B,OAAA,EAA0D;AAgBnF,SAAS,qBAAqB,OAAA,EAAgE;AAEnG,EAAA,MAAM,mBAAmB,OAAA,CAAQ,SAAA;AACjC,EAAA,MAAM,QAAA,GAAW,mBAAA,CAAoB,GAAA,CAAI,gBAAgB,CAAA,EAAG,iBAAA;AAC5D,EAAA,OAAO,QAAA,IAAY,gBAAA;AACrB;AAUO,SAAS,cAAc,OAAA,EAA4C;AACxE,EAAA,MAAM,QAAA,GAAW,6BAA6B,OAAO,CAAA;AACrD,EAAA,IAAI,iBAA6B,MAAM,MAAA;AACvC,EAAA,MAAM,OAAA,GAAU,IAAI,OAAA,CAAc,CAAA,GAAA,KAAO;AACvC,IAAA,cAAA,GAAiB,GAAA;AAAA,EACnB,CAAC,CAAA;AACD,EAAA,IAAI,OAAA,GAAU,CAAA;AAEd,EAAA,MAAM,IAAA,GAA0B;AAAA,IAC9B,KAAA,EAAO,OAAA;AAAA,IACP,SAAS,MAAM;AACb,MAAA,OAAA,EAAA;AAAA,IACF,CAAA;AAAA,IACA,SAAS,MAAM;AACb,MAAA,IAAI,EAAE,YAAY,CAAA,EAAG;AACnB,QAAA,QAAA,CAAS,KAAA,CAAM,OAAO,IAAI,CAAA;AAC1B,QAAA,cAAA,EAAe;AAAA,MACjB;AAAA,IACF,CAAA;AAAA,IACA,UAAU,MAAM;AACd,MAAA,IAAI,YAAY,CAAA,EAAG;AACjB,QAAA,QAAA,CAAS,KAAA,CAAM,OAAO,IAAI,CAAA;AAC1B,QAAA,cAAA,EAAe;AAAA,MAC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AACnB,MAAA;AAAA,IACF;AACA,IAAA,MAAM,MAAA,CAAO,MAAM,OAAO,CAAA;AAAA,EAC5B,SAAS,CAAA,EAAG;AACV,IAAAC,sBAAA,IAAeC,UAAA,CAAM,IAAA,CAAK,wBAAA,EAA0B,CAAC,CAAA;AAAA,EACvD,CAAA,SAAE;AACA,IAAA,IAAI;AACF,MAAA,MAAA,EAAQ,OAAA,EAAQ;AAAA,IAClB,SAAS,CAAA,EAAG;AACV,MAAAD,sBAAA,IAAeC,UAAA,CAAM,IAAA,CAAK,0BAAA,EAA4B,CAAC,CAAA;AAAA,IACzD;AAAA,EACF;AACF;;;;;;"}
@@ -5,17 +5,15 @@ const withSentry = require('./withSentry.js');
5
5
  const defineCloudflareOptions = require('./defineCloudflareOptions.js');
6
6
  const durableobject = require('./durableobject.js');
7
7
  const pagesPlugin = require('./pages-plugin.js');
8
- const request = require('./request.js');
9
8
  const client = require('./client.js');
10
9
  const sdk = require('./sdk.js');
11
10
  const httpServer = require('./integrations/httpServer.js');
12
11
  const fetch = require('./integrations/fetch.js');
13
12
  const spotlight = require('./integrations/spotlight.js');
14
13
  const vercelai = require('./integrations/tracing/vercelai.js');
15
- const hono = require('./integrations/hono.js');
16
- const instrumentD1 = require('./instrumentations/worker/instrumentD1.js');
14
+ const serverUtils = require('@sentry/server-utils');
17
15
  const workflows = require('./workflows.js');
18
- const async = require('./async.js');
16
+ const noDiagnosticChannels = require('@sentry/server-utils/no-diagnostic-channels');
19
17
 
20
18
 
21
19
 
@@ -40,7 +38,6 @@ exports.consoleIntegration = core.consoleIntegration;
40
38
  exports.consoleLoggingIntegration = core.consoleLoggingIntegration;
41
39
  exports.continueTrace = core.continueTrace;
42
40
  exports.createConsolaReporter = core.createConsolaReporter;
43
- exports.createLangChainCallbackHandler = core.createLangChainCallbackHandler;
44
41
  exports.createTransport = core.createTransport;
45
42
  exports.dedupeIntegration = core.dedupeIntegration;
46
43
  exports.eventFiltersIntegration = core.eventFiltersIntegration;
@@ -59,15 +56,7 @@ exports.getSpanStatusFromHttpCode = core.getSpanStatusFromHttpCode;
59
56
  exports.getTraceData = core.getTraceData;
60
57
  exports.getTraceMetaTags = core.getTraceMetaTags;
61
58
  exports.growthbookIntegration = core.growthbookIntegration;
62
- exports.inboundFiltersIntegration = core.inboundFiltersIntegration;
63
- exports.instrumentAnthropicAiClient = core.instrumentAnthropicAiClient;
64
- exports.instrumentCreateReactAgent = core.instrumentCreateReactAgent;
65
- exports.instrumentGoogleGenAIClient = core.instrumentGoogleGenAIClient;
66
- exports.instrumentLangChainEmbeddings = core.instrumentLangChainEmbeddings;
67
- exports.instrumentLangGraph = core.instrumentLangGraph;
68
- exports.instrumentOpenAiClient = core.instrumentOpenAiClient;
69
59
  exports.instrumentPostgresJsSql = core.instrumentPostgresJsSql;
70
- exports.instrumentStateGraph = core.instrumentStateGraph;
71
60
  exports.instrumentSupabaseClient = core.instrumentSupabaseClient;
72
61
  exports.isEnabled = core.isEnabled;
73
62
  exports.isInitialized = core.isInitialized;
@@ -93,6 +82,7 @@ exports.setUser = core.setUser;
93
82
  exports.spanStreamingIntegration = core.spanStreamingIntegration;
94
83
  exports.spanToBaggageHeader = core.spanToBaggageHeader;
95
84
  exports.spanToJSON = core.spanToJSON;
85
+ exports.spanToStaticSpanJSON = core.spanToStaticSpanJSON;
96
86
  exports.spanToTraceHeader = core.spanToTraceHeader;
97
87
  exports.startInactiveSpan = core.startInactiveSpan;
98
88
  exports.startNewTrace = core.startNewTrace;
@@ -106,6 +96,7 @@ exports.withActiveSpan = core.withActiveSpan;
106
96
  exports.withIsolationScope = core.withIsolationScope;
107
97
  exports.withMonitor = core.withMonitor;
108
98
  exports.withScope = core.withScope;
99
+ exports.withStaticSpan = core.withStaticSpan;
109
100
  exports.withStreamedSpan = core.withStreamedSpan;
110
101
  exports.wrapMcpServerWithSentry = core.wrapMcpServerWithSentry;
111
102
  exports.zodErrorsIntegration = core.zodErrorsIntegration;
@@ -114,15 +105,23 @@ exports.defineCloudflareOptions = defineCloudflareOptions.defineCloudflareOption
114
105
  exports.instrumentAgentWithSentry = durableobject.instrumentAgentWithSentry;
115
106
  exports.instrumentDurableObjectWithSentry = durableobject.instrumentDurableObjectWithSentry;
116
107
  exports.sentryPagesPlugin = pagesPlugin.sentryPagesPlugin;
117
- exports.wrapRequestHandler = request.wrapRequestHandler;
118
108
  exports.CloudflareClient = client.CloudflareClient;
119
109
  exports.getDefaultIntegrations = sdk.getDefaultIntegrations;
120
110
  exports.httpServerIntegration = httpServer.httpServerIntegration;
121
111
  exports.fetchIntegration = fetch.fetchIntegration;
122
112
  exports.spotlightIntegration = spotlight.spotlightIntegration;
123
113
  exports.vercelAIIntegration = vercelai.vercelAIIntegration;
124
- exports.honoIntegration = hono.honoIntegration;
125
- exports.instrumentD1WithSentry = instrumentD1.instrumentD1WithSentry;
114
+ exports.createLangChainCallbackHandler = serverUtils.createLangChainCallbackHandler;
115
+ exports.getOtlpTracesEndpoint = serverUtils.getOtlpTracesEndpoint;
116
+ exports.instrumentAnthropicAiClient = serverUtils.instrumentAnthropicAiClient;
117
+ exports.instrumentCreateReactAgent = serverUtils.instrumentCreateReactAgent;
118
+ exports.instrumentGoogleGenAIClient = serverUtils.instrumentGoogleGenAIClient;
119
+ exports.instrumentLangChainEmbeddings = serverUtils.instrumentLangChainEmbeddings;
120
+ exports.instrumentOpenAiClient = serverUtils.instrumentOpenAiClient;
121
+ exports.instrumentStateGraph = serverUtils.instrumentStateGraph;
122
+ exports.instrumentWorkersAiClient = serverUtils.instrumentWorkersAiClient;
123
+ exports.otlpIntegration = serverUtils.otlpIntegration;
124
+ exports.prismaIntegration = serverUtils.prismaIntegration;
126
125
  exports.instrumentWorkflowWithSentry = workflows.instrumentWorkflowWithSentry;
127
- exports.setAsyncLocalStorageAsyncContextStrategy = async.setAsyncLocalStorageAsyncContextStrategy;
126
+ exports.setAsyncLocalStorageAsyncContextStrategy = noDiagnosticChannels.setAsyncLocalStorageAsyncContextStrategy;
128
127
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrument.js","sources":["../../../src/instrument.ts"],"sourcesContent":["// Use a global WeakMap to track instrumented objects across module instances.\n// This is important for Cloudflare Workers where the module may be bundled\n// separately for workers and Durable Objects, but they share the same global scope.\n// The WeakMap stores original -> instrumented mappings so we can retrieve the\n// instrumented version even if we only have a reference to the original.\nimport { isObjectLike } from '@sentry/core';\n\nconst GLOBAL_KEY = '__SENTRY_INSTRUMENTED_MAP__' as const;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction getInstrumentedMap(): WeakMap<any, any> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const globalObj = globalThis as typeof globalThis & { [GLOBAL_KEY]?: WeakMap<any, any> };\n if (!globalObj[GLOBAL_KEY]) {\n globalObj[GLOBAL_KEY] = new WeakMap();\n }\n return globalObj[GLOBAL_KEY];\n}\n\n/**\n * Check if a value can be used as a WeakMap key.\n * WeakMap keys must be objects or non-registered symbols.\n */\nfunction isWeakMapKey(value: unknown): value is object {\n return isObjectLike(value) || typeof value === 'function';\n}\n\n/**\n * Mark an object as instrumented, storing the instrumented version.\n * @param original The original uninstrumented object\n * @param instrumented The instrumented version (defaults to original if not provided)\n */\nexport function markAsInstrumented<T>(original: T, instrumented?: T): void {\n try {\n if (isWeakMapKey(original)) {\n // Store mapping from original to instrumented version\n // If instrumented is not provided, store original (for backwards compat)\n getInstrumentedMap().set(original, instrumented ?? original);\n }\n // Also mark the instrumented version itself so we recognize it\n if (isWeakMapKey(instrumented) && instrumented !== original) {\n getInstrumentedMap().set(instrumented, instrumented);\n }\n } catch {\n // ignore errors here\n }\n}\n\n/**\n * Get the instrumented version of an object, if available.\n * Returns the instrumented version if the object was previously instrumented,\n * or undefined if not found.\n */\nexport function getInstrumented<T>(obj: T): T | undefined {\n try {\n if (isWeakMapKey(obj)) {\n return getInstrumentedMap().get(obj) as T | undefined;\n }\n\n return undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Returns the already-instrumented version of `original` if one exists,\n * otherwise calls `instrumentFn` to create it, marks the mapping, and returns it.\n *\n * @param noMark - If true, skips storing the original→instrumented mapping.\n */\nexport function ensureInstrumented<T>(original: T, instrumentFn: (original: T) => T, noMark?: boolean): T {\n const existing = getInstrumented(original);\n\n if (existing) {\n return existing;\n }\n\n const instrumented = instrumentFn(original);\n\n if (!noMark) {\n markAsInstrumented(original, instrumented);\n }\n\n return instrumented;\n}\n"],"names":["isObjectLike"],"mappings":";;;;AAOA,MAAM,UAAA,GAAa,6BAAA;AAGnB,SAAS,kBAAA,GAAwC;AAE/C,EAAA,MAAM,SAAA,GAAY,UAAA;AAClB,EAAA,IAAI,CAAC,SAAA,CAAU,UAAU,CAAA,EAAG;AAC1B,IAAA,SAAA,CAAU,UAAU,CAAA,mBAAI,IAAI,OAAA,EAAQ;AAAA,EACtC;AACA,EAAA,OAAO,UAAU,UAAU,CAAA;AAC7B;AAMA,SAAS,aAAa,KAAA,EAAiC;AACrD,EAAA,OAAOA,iBAAA,CAAa,KAAK,CAAA,IAAK,OAAO,KAAA,KAAU,UAAA;AACjD;AAOO,SAAS,kBAAA,CAAsB,UAAa,YAAA,EAAwB;AACzE,EAAA,IAAI;AACF,IAAA,IAAI,YAAA,CAAa,QAAQ,CAAA,EAAG;AAG1B,MAAA,kBAAA,EAAmB,CAAE,GAAA,CAAI,QAAA,EAAU,YAAA,IAAgB,QAAQ,CAAA;AAAA,IAC7D;AAEA,IAAA,IAAI,YAAA,CAAa,YAAY,CAAA,IAAK,YAAA,KAAiB,QAAA,EAAU;AAC3D,MAAA,kBAAA,EAAmB,CAAE,GAAA,CAAI,YAAA,EAAc,YAAY,CAAA;AAAA,IACrD;AAAA,EACF,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;AAOO,SAAS,gBAAmB,GAAA,EAAuB;AACxD,EAAA,IAAI;AACF,IAAA,IAAI,YAAA,CAAa,GAAG,CAAA,EAAG;AACrB,MAAA,OAAO,kBAAA,EAAmB,CAAE,GAAA,CAAI,GAAG,CAAA;AAAA,IACrC;AAEA,IAAA,OAAO,KAAA,CAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAQO,SAAS,kBAAA,CAAsB,QAAA,EAAa,YAAA,EAAkC,MAAA,EAAqB;AACxG,EAAA,MAAM,QAAA,GAAW,gBAAgB,QAAQ,CAAA;AAEzC,EAAA,IAAI,QAAA,EAAU;AACZ,IAAA,OAAO,QAAA;AAAA,EACT;AAEA,EAAA,MAAM,YAAA,GAAe,aAAa,QAAQ,CAAA;AAE1C,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,kBAAA,CAAmB,UAAU,YAAY,CAAA;AAAA,EAC3C;AAEA,EAAA,OAAO,YAAA;AACT;;;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/instrumentations/agents/index.ts"],"sourcesContent":["import { instrumentAgentCallableRpc } from './instrumentAgentCallableRpc';\nimport { instrumentAgentRequestConversation } from './instrumentAgentRequestConversation';\nimport { instrumentChatAgentConversation } from './instrumentChatAgentConversation';\nimport type { AgentInternals } from './types';\n\n/**\n * Instruments an instance of a Cloudflare [`agents`](https://www.npmjs.com/package/agents) `Agent`\n * with Sentry, adding telemetry that is specific to the Agent's runtime behavior:\n *\n * - **Callable RPC spans** — a span (op `rpc`) for each `@callable()` method invoked over WebSocket.\n * - **Conversation correlation** — sets the conversation id on the scope for each unit of agent\n * work — chat turn, callable RPC call, or HTTP request — so `gen_ai` spans created within it are\n * correlated, for chat and plain agents alike. The id is minted once per agent instance and\n * rotated when the chat is cleared (the `message:clear` observability event); it is persisted to\n * Durable Object storage so it survives hibernation.\n *\n * It only hooks the `agents` package internals and uses Sentry's tracing primitives. On Cloudflare\n * Workers, prefer `instrumentAgentWithSentry`, which additionally instruments the Durable Object\n * handlers and initializes the SDK; that function calls this one internally.\n *\n * The hooks replace own-properties on the instance and defer to the original implementation, so\n * they compose with any other instrumentation applied to the same instance.\n *\n * @param agent The `agents` `Agent` instance to instrument.\n * @returns The same instance, instrumented.\n *\n * @internal Use `instrumentAgentWithSentry` instead — this is called internally by it.\n */\nexport function instrumentCloudflareAgent<T extends object>(agent: T): T {\n const internals = agent as T & AgentInternals;\n\n instrumentAgentCallableRpc(internals);\n instrumentChatAgentConversation(internals);\n instrumentAgentRequestConversation(internals);\n\n return agent;\n}\n"],"names":["instrumentAgentCallableRpc","instrumentChatAgentConversation","instrumentAgentRequestConversation"],"mappings":";;;;;;AA4BO,SAAS,0BAA4C,KAAA,EAAa;AACvE,EAAA,MAAM,SAAA,GAAY,KAAA;AAElB,EAAAA,qDAAA,CAA2B,SAAS,CAAA;AACpC,EAAAC,+DAAA,CAAgC,SAAS,CAAA;AACzC,EAAAC,qEAAA,CAAmC,SAAS,CAAA;AAE5C,EAAA,OAAO,KAAA;AACT;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrumentAgentCallableRpc.js","sources":["../../../../../src/instrumentations/agents/instrumentAgentCallableRpc.ts"],"sourcesContent":["import { debug, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, startSpan } from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { AGENT_SPAN_ORIGIN, type AgentInternals, getAgentAttributes, setAgentConversationId } from './types';\n\n/**\n * Wraps the Agent's `onMessage` handler to create a span for each `@callable()` RPC invocation.\n * RPC requests arrive as WebSocket messages, so this span nests under the active transaction for\n * the WebSocket message (on Cloudflare, the instrumented Durable Object `webSocketMessage` hook).\n *\n * Also sets the conversation id on the scope for the duration of the call: callable methods are the\n * unit of work for plain (non-chat) agents, which run LLM calls just like chat turns do. It is\n * awaited so the id is on the scope before the method body creates any span; the `agents`\n * `onMessage` own property this wraps is already `async`, so the promise return is nothing new to\n * the WebSocket dispatch upstream.\n */\nexport function instrumentAgentCallableRpc(obj: AgentInternals): void {\n const original = obj.onMessage;\n if (typeof original !== 'function') {\n DEBUG_BUILD && debug.log('[Sentry] Agent `onMessage` not found — callable RPC span instrumentation skipped.');\n return;\n }\n\n obj.onMessage = new Proxy(original, {\n apply(target, thisArg: AgentInternals, args: unknown[]): unknown {\n const method = extractCallableMethod(args[1]);\n\n if (!method) {\n return Reflect.apply(target, thisArg, args);\n }\n\n return startSpan(\n {\n name: method,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'rpc',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: AGENT_SPAN_ORIGIN,\n ...getAgentAttributes(thisArg),\n },\n },\n async () => {\n await setAgentConversationId(thisArg);\n return Reflect.apply(target, thisArg, args);\n },\n );\n },\n });\n}\n\n/** Extracts the RPC method name from a WebSocket message, mirroring the SDK's `isRPCRequest`. */\nfunction extractCallableMethod(message: unknown): string | undefined {\n const text =\n typeof message === 'string'\n ? message\n : message instanceof ArrayBuffer\n ? new TextDecoder().decode(message)\n : undefined;\n\n if (!text) {\n return undefined;\n }\n\n try {\n const parsed = JSON.parse(text) as { type?: unknown; method?: unknown; args?: unknown };\n if (parsed.type === 'rpc' && typeof parsed.method === 'string' && Array.isArray(parsed.args)) {\n return parsed.method;\n }\n } catch {\n // Not JSON, or not an RPC request — no span.\n }\n\n return undefined;\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,GACjB,IAAI,WAAA,EAAY,CAAE,MAAA,CAAO,OAAO,CAAA,GAChC,MAAA;AAER,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,IAAI;AACF,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,KAAA,CAAM,IAAI,CAAA;AAC9B,IAAA,IAAI,MAAA,CAAO,IAAA,KAAS,KAAA,IAAS,OAAO,MAAA,CAAO,MAAA,KAAW,QAAA,IAAY,KAAA,CAAM,OAAA,CAAQ,MAAA,CAAO,IAAI,CAAA,EAAG;AAC5F,MAAA,OAAO,MAAA,CAAO,MAAA;AAAA,IAChB;AAAA,EACF,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,MAAA;AACT;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrumentAgentRequestConversation.js","sources":["../../../../../src/instrumentations/agents/instrumentAgentRequestConversation.ts"],"sourcesContent":["import { type AgentInternals, setAgentConversationId } from './types';\n\n/**\n * Correlates the AI spans of an HTTP-driven agent turn with a conversation id on the active scope.\n *\n * `onRequest` is the third unit of agent work, alongside chat turns and `@callable()` RPC: the\n * `agents` router sends every non-WebSocket request to it, which is how REST endpoints and webhooks\n * reach an agent.\n *\n * `agents` installs `onRequest` as an own property in the `Agent` constructor (as it does\n * `onMessage`), and we instrument after construction, so wrapping the own property is what the\n * router ends up calling. That own property is already `async`, and partyserver's `fetch` awaits it,\n * so returning a promise from this wrapper — to get the conversation id onto the scope before the\n * request handler creates any span — keeps the existing contract.\n */\nexport function instrumentAgentRequestConversation(obj: AgentInternals): void {\n const original = obj.onRequest;\n\n if (typeof original !== 'function') {\n return;\n }\n\n obj.onRequest = new Proxy(original, {\n async apply(target, thisArg: AgentInternals, args: unknown[]): Promise<unknown> {\n await setAgentConversationId(thisArg);\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n}\n"],"names":["setAgentConversationId"],"mappings":";;;;AAeO,SAAS,mCAAmC,GAAA,EAA2B;AAC5E,EAAA,MAAM,WAAW,GAAA,CAAI,SAAA;AAErB,EAAA,IAAI,OAAO,aAAa,UAAA,EAAY;AAClC,IAAA;AAAA,EACF;AAEA,EAAA,GAAA,CAAI,SAAA,GAAY,IAAI,KAAA,CAAM,QAAA,EAAU;AAAA,IAClC,MAAM,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAyB,IAAA,EAAmC;AAC9E,MAAA,MAAMA,6BAAuB,OAAO,CAAA;AAEpC,MAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,IAAI,CAAA;AAAA,IAC5C;AAAA,GACD,CAAA;AACH;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrumentChatAgentConversation.js","sources":["../../../../../src/instrumentations/agents/instrumentChatAgentConversation.ts"],"sourcesContent":["import { uuid4 } from '@sentry/core';\nimport { type AgentInternals, setAgentConversationId, storeAgentConversationId } from './types';\n\n/**\n * For chat agents (`AIChatAgent` from `@cloudflare/ai-chat`), correlates each chat turn's AI spans\n * with a conversation id on the active scope.\n *\n * In the Agents model one agent instance is one long-lived conversation, so the conversation id is\n * minted once per instance and persisted to Durable Object storage, which is what carries it across\n * hibernation (that destroys the in-memory instance). When the user clears the chat, they expect a\n * fresh conversation — but recreating the Durable Object for that would also drop the MCP/OAuth\n * state stored per instance (GitHub/Sentry sign-in). To get a fresh conversation id *without*\n * losing that state, we rotate the persisted id when the SDK reports a cleared chat.\n *\n * The id itself is not attached to spans here — `setAgentConversationId` resolves it, and the SDK's\n * `conversationIdIntegration` picks it off the scope at `spanStart` to stamp\n * `gen_ai.conversation.id` onto the AI spans created inside the turn (e.g. by the Workers AI\n * instrumentation), which correlates a turn's model and tool calls.\n *\n * Plain (non-chat) `Agent`s do not define `onChatMessage`, so they are skipped here — their unit\n * of work is the callable RPC method, where `instrumentAgentCallableRpc` sets the conversation id\n * instead.\n */\nexport function instrumentChatAgentConversation(obj: AgentInternals): void {\n // Rotate the conversation id when the chat is cleared. `_emit` is the central choke-point through\n // which all `agents:*` observability events are published, and it already exists on the base\n // `Agent` class — so this hook composes with the RPC instrumentation, which keys off the same\n // surface. We shadow it with an own property so the original stays reachable on the prototype.\n const originalEmit = obj._emit;\n\n if (typeof originalEmit === 'function') {\n obj._emit = new Proxy(originalEmit, {\n apply(target, thisArg: AgentInternals, args: [string, Record<string, unknown>?]) {\n if (args[0] === 'message:clear') {\n storeAgentConversationId(thisArg, uuid4());\n }\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n }\n\n const original = obj.onChatMessage;\n\n if (typeof original !== 'function') {\n return;\n }\n\n obj.onChatMessage = new Proxy(original, {\n async apply(target, thisArg: AgentInternals, args: unknown[]): Promise<unknown> {\n await setAgentConversationId(thisArg);\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n}\n"],"names":["storeAgentConversationId","uuid4","setAgentConversationId"],"mappings":";;;;;AAuBO,SAAS,gCAAgC,GAAA,EAA2B;AAKzE,EAAA,MAAM,eAAe,GAAA,CAAI,KAAA;AAEzB,EAAA,IAAI,OAAO,iBAAiB,UAAA,EAAY;AACtC,IAAA,GAAA,CAAI,KAAA,GAAQ,IAAI,KAAA,CAAM,YAAA,EAAc;AAAA,MAClC,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAyB,IAAA,EAA0C;AAC/E,QAAA,IAAI,IAAA,CAAK,CAAC,CAAA,KAAM,eAAA,EAAiB;AAC/B,UAAAA,8BAAA,CAAyB,OAAA,EAASC,YAAO,CAAA;AAAA,QAC3C;AAEA,QAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,IAAI,CAAA;AAAA,MAC5C;AAAA,KACD,CAAA;AAAA,EACH;AAEA,EAAA,MAAM,WAAW,GAAA,CAAI,aAAA;AAErB,EAAA,IAAI,OAAO,aAAa,UAAA,EAAY;AAClC,IAAA;AAAA,EACF;AAEA,EAAA,GAAA,CAAI,aAAA,GAAgB,IAAI,KAAA,CAAM,QAAA,EAAU;AAAA,IACtC,MAAM,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAyB,IAAA,EAAmC;AAC9E,MAAA,MAAMC,6BAAuB,OAAO,CAAA;AAEpC,MAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,IAAI,CAAA;AAAA,IAC5C;AAAA,GACD,CAAA;AACH;;;;"}
@@ -1,20 +1,20 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
+ const attributes = require('@sentry/conventions/attributes');
3
4
  const core = require('@sentry/core');
4
5
  const debugBuild = require('../../debug-build.js');
5
6
 
6
- const GEN_AI_AGENT_NAME_ATTRIBUTE = "gen_ai.agent.name";
7
7
  const AGENT_SPAN_ORIGIN = "auto.faas.cloudflare.agents";
8
8
  const AGENT_CONVERSATION_ID_STORAGE_KEY = "__SENTRY_AGENT_CONVERSATION_ID__";
9
9
  const AGENT_CONVERSATION_ID_SYMBOL = /* @__PURE__ */ Symbol("sentryAgentConversationId");
10
10
  const AGENT_APPLIED_CONVERSATION_ID_SYMBOL = /* @__PURE__ */ Symbol("sentryAgentAppliedConversationId");
11
11
  function getAgentAttributes(instance) {
12
- const attributes = {};
12
+ const attributes$1 = {};
13
13
  const agentClass = instance._ParentClass?.name;
14
14
  if (typeof agentClass === "string" && agentClass) {
15
- attributes[GEN_AI_AGENT_NAME_ATTRIBUTE] = agentClass;
15
+ attributes$1[attributes.GEN_AI_AGENT_NAME] = agentClass;
16
16
  }
17
- return attributes;
17
+ return attributes$1;
18
18
  }
19
19
  function storeAgentConversationId(instance, conversationId) {
20
20
  instance[AGENT_CONVERSATION_ID_SYMBOL] = conversationId;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../../../../src/instrumentations/agents/types.ts"],"sourcesContent":["import { GEN_AI_AGENT_NAME } from '@sentry/conventions/attributes';\nimport type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport { debug, getCurrentScope, getIsolationScope, uuid4 } from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport type { InstrumentedDurableObjectState } from '../../wrapMethodWithSentry';\n\nexport const AGENT_SPAN_ORIGIN = 'auto.faas.cloudflare.agents';\n\n/** DO storage key under which the conversation id is persisted so it survives hibernation. */\nexport const AGENT_CONVERSATION_ID_STORAGE_KEY = '__SENTRY_AGENT_CONVERSATION_ID__';\n\n/**\n * Instance keys for our conversation-id bookkeeping, keyed by symbol so the state stays invisible\n * to anything enumerating the user-owned agent instance (`Object.keys`, `JSON.stringify`, spread).\n * Exported because the exported `AgentInternals` interface references them.\n */\nexport const AGENT_CONVERSATION_ID_SYMBOL: unique symbol = Symbol('sentryAgentConversationId');\nexport const AGENT_APPLIED_CONVERSATION_ID_SYMBOL: unique symbol = Symbol('sentryAgentAppliedConversationId');\n\n/**\n * The subset of the `agents` `Agent` instance internals that we instrument. These are runtime\n * implementation details of the `agents` package (v0.13.x) rather than part of its public type\n * surface, so every access is guarded and wrapping degrades gracefully if a name changes upstream.\n */\nexport interface AgentInternals {\n /** Central choke-point through which all `agents:*` observability events are published. */\n _emit?: (type: string, payload?: Record<string, unknown>) => void;\n /** WebSocket message handler; dispatches `@callable()` RPC requests. */\n onMessage?: (...args: unknown[]) => unknown;\n /**\n * Chat-turn handler. Only `AIChatAgent` (from `@cloudflare/ai-chat`) defines this; a plain `Agent`\n * does not, so its presence discriminates a chat agent.\n */\n onChatMessage?: (...args: unknown[]) => unknown;\n /** HTTP request handler; the router sends every non-WebSocket request here. */\n onRequest?: (...args: unknown[]) => unknown;\n /** The user's Agent class (used by the SDK for the observability event `agent` field). */\n _ParentClass?: { name?: string };\n /** The Agent instance name, reported as the `cloudflare.agent.name` span attribute. */\n name?: string;\n /**\n * The Durable Object state of the instance. Present on every real Agent; guarded like the other\n * internals so partially-mocked instances keep working.\n */\n ctx?: InstrumentedDurableObjectState;\n /**\n * The current conversation id for this agent instance. It is cached in memory after being loaded\n * from Durable Object storage and updated when the conversation rotates. `undefined` means storage\n * has not been read yet.\n */\n [AGENT_CONVERSATION_ID_SYMBOL]?: string;\n /**\n * The conversation id this instrumentation most recently applied to the isolation scope. It lets\n * subsequent units of work distinguish an SDK-applied id, which may be replaced after rotation,\n * from an id explicitly set by the user, which must be preserved.\n */\n [AGENT_APPLIED_CONVERSATION_ID_SYMBOL]?: string;\n}\n\n/** Reads best-effort agent identity attributes from the instance, tolerating missing internals. */\nexport function getAgentAttributes(instance: AgentInternals): Record<string, string> {\n const attributes: Record<string, string> = {};\n\n const agentClass = instance._ParentClass?.name;\n if (typeof agentClass === 'string' && agentClass) {\n attributes[GEN_AI_AGENT_NAME] = agentClass;\n }\n\n return attributes;\n}\n\n/**\n * Persists the conversation id to Durable Object storage, so it survives hibernation, and updates\n * the in-memory cache synchronously so the current wake is immediately consistent even if the\n * write fails. Uses the async storage API, which exists on KV- and SQLite-backed DOs alike.\n * The write is fire-and-forget: DO storage writes are tracked by the runtime and land without\n * awaiting (`waitUntil` is a no-op in Durable Objects), and the catch keeps a rejection from\n * surfacing as unhandled — a failed write just means the next wake starts a new conversation,\n * which must never throw into user code. Uses the original uninstrumented storage so internal\n * bookkeeping doesn't create spans.\n */\nexport function storeAgentConversationId(instance: AgentInternals, conversationId: string): void {\n instance[AGENT_CONVERSATION_ID_SYMBOL] = conversationId;\n\n const storage = resolveStorage(instance);\n if (!storage) {\n return;\n }\n\n try {\n storage\n .put(AGENT_CONVERSATION_ID_STORAGE_KEY, conversationId)\n .catch(error => DEBUG_BUILD && debug.log('[Sentry] Failed to persist agent conversation id', error));\n } catch (error) {\n DEBUG_BUILD && debug.log('[Sentry] Failed to persist agent conversation id', error);\n }\n}\n\n/**\n * Sets the agent instance's conversation id on the active scope for the duration of the\n * surrounding unit of work (chat turn, callable RPC call, HTTP request). In the Agents model one\n * instance is one long-lived conversation, so the id is minted once per instance and persisted to\n * DO storage — for chat and plain agents alike, since plain agents run LLM calls too (e.g. inside\n * `@callable()` methods). The instance `name` is deliberately not used: it is caller-chosen and can\n * be a stable, guessable, or shared value, whereas a conversation id should identify exactly one\n * conversation. Clearing the chat rotates it (see `storeAgentConversationId`) so subsequent LLM\n * calls group under the fresh conversation.\n *\n * Every handler wrapper awaits this before invoking the original, so the id is on the scope before\n * the unit of work — and any `gen_ai` span it creates — starts. Only the first unit of work per wake\n * pays the storage read; the rest resolve from the in-memory cache. Awaiting is safe on all three\n * paths because the `agents` `Agent` constructor already replaces `onMessage` and `onRequest` with\n * `async` wrappers of its own, and `onChatMessage` is async by contract, so every caller upstream\n * already handles a promise.\n *\n * An id the user set explicitly outranks this inferred one, in either order: a `setConversationId()`\n * call that already happened is detected here and left alone, and one made inside the handler lands\n * on the same scope afterwards and therefore wins. That is why the write targets the isolation scope\n * — it is the scope the public `Sentry.setConversationId()` writes to, and `conversationIdIntegration`\n * prefers the current scope over it, so writing there would make a user's call unoverridable.\n *\n * `conversationIdIntegration` reads the id off the scope at `spanStart` and stamps\n * `gen_ai.conversation.id` onto AI spans created within the unit of work, correlating its model and\n * tool calls.\n */\nexport async function setAgentConversationId(instance: AgentInternals): Promise<void> {\n const isolationScope = getIsolationScope();\n const existing = isolationScope.getScopeData().conversationId ?? getCurrentScope().getScopeData().conversationId;\n\n // An id that isn't the one we put there ourselves came from the user — never override it.\n if (existing && existing !== instance[AGENT_APPLIED_CONVERSATION_ID_SYMBOL]) {\n return;\n }\n\n const conversationId = instance[AGENT_CONVERSATION_ID_SYMBOL] ?? (await loadAgentConversationId(instance));\n\n instance[AGENT_APPLIED_CONVERSATION_ID_SYMBOL] = conversationId;\n isolationScope.setConversationId(conversationId);\n}\n\n/**\n * Reads the persisted id into the instance cache, minting and persisting a fresh one when storage\n * holds none, so subsequent units of work resolve from memory. The async `get` exists on KV- and\n * SQLite-backed DOs alike, so this one path covers both.\n *\n * Anything already cached by the time the read lands wins over the read: that covers a rotation\n * (cleared chat) racing the read, and a second concurrent unit of work that must not mint and\n * persist a competing id for the same conversation.\n */\nasync function loadAgentConversationId(instance: AgentInternals): Promise<string> {\n let stored: unknown;\n let readFailed = false;\n\n try {\n stored = await resolveStorage(instance)?.get<string>(AGENT_CONVERSATION_ID_STORAGE_KEY);\n } catch (error) {\n readFailed = true;\n DEBUG_BUILD && debug.log('[Sentry] Failed to read agent conversation id from storage', error);\n }\n\n const cached = instance[AGENT_CONVERSATION_ID_SYMBOL];\n\n if (cached !== undefined) {\n return cached;\n }\n\n if (typeof stored === 'string' && stored) {\n instance[AGENT_CONVERSATION_ID_SYMBOL] = stored;\n\n return stored;\n }\n\n const conversationId = uuid4();\n\n if (readFailed) {\n // Cache without persisting: a read that failed may still have an id behind it, and overwriting\n // it would split the conversation for good instead of just for this wake.\n instance[AGENT_CONVERSATION_ID_SYMBOL] = conversationId;\n } else {\n storeAgentConversationId(instance, conversationId);\n }\n\n return conversationId;\n}\n\n/**\n * Resolves the uninstrumented DO storage for internal reads/writes, so they don't create spans of\n * their own. Falls back to the instance's regular storage when the uninstrumented one isn't\n * exposed (e.g. when `instrumentCloudflareAgent` is used directly, without `instrumentContext`).\n */\nfunction resolveStorage(instance: AgentInternals): DurableObjectStorage | undefined {\n return instance.ctx?.originalStorage ?? instance.ctx?.storage;\n}\n"],"names":["attributes","GEN_AI_AGENT_NAME","DEBUG_BUILD","debug","getIsolationScope","getCurrentScope","uuid4"],"mappings":";;;;;;AAMO,MAAM,iBAAA,GAAoB;AAG1B,MAAM,iCAAA,GAAoC;AAO1C,MAAM,4BAAA,0BAAqD,2BAA2B;AACtF,MAAM,oCAAA,0BAA6D,kCAAkC;AA2CrG,SAAS,mBAAmB,QAAA,EAAkD;AACnF,EAAA,MAAMA,eAAqC,EAAC;AAE5C,EAAA,MAAM,UAAA,GAAa,SAAS,YAAA,EAAc,IAAA;AAC1C,EAAA,IAAI,OAAO,UAAA,KAAe,QAAA,IAAY,UAAA,EAAY;AAChD,IAAAA,YAAA,CAAWC,4BAAiB,CAAA,GAAI,UAAA;AAAA,EAClC;AAEA,EAAA,OAAO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,UAAA,GAAa,IAAA;AACb,IAAAH,sBAAA,IAAeC,UAAA,CAAM,GAAA,CAAI,4DAAA,EAA8D,KAAK,CAAA;AAAA,EAC9F;AAEA,EAAA,MAAM,MAAA,GAAS,SAAS,4BAA4B,CAAA;AAEpD,EAAA,IAAI,WAAW,MAAA,EAAW;AACxB,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,IAAI,OAAO,MAAA,KAAW,QAAA,IAAY,MAAA,EAAQ;AACxC,IAAA,QAAA,CAAS,4BAA4B,CAAA,GAAI,MAAA;AAEzC,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,MAAM,iBAAiBG,UAAA,EAAM;AAE7B,EAAA,IAAI,UAAA,EAAY;AAGd,IAAA,QAAA,CAAS,4BAA4B,CAAA,GAAI,cAAA;AAAA,EAC3C,CAAA,MAAO;AACL,IAAA,wBAAA,CAAyB,UAAU,cAAc,CAAA;AAAA,EACnD;AAEA,EAAA,OAAO,cAAA;AACT;AAOA,SAAS,eAAe,QAAA,EAA4D;AAClF,EAAA,OAAO,QAAA,CAAS,GAAA,EAAK,eAAA,IAAmB,QAAA,CAAS,GAAA,EAAK,OAAA;AACxD;;;;;;;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrumentDurableObjectNamespace.js","sources":["../../../../src/instrumentations/instrumentDurableObjectNamespace.ts"],"sourcesContent":["import type { DurableObjectNamespace, DurableObjectStub } from '@cloudflare/workers-types';\nimport { appendRpcMeta } from '../utils/rpcMeta';\nimport { instrumentFetcher } from './worker/instrumentFetcher';\n\n// Built-in DurableObjectStub methods that are not RPC calls.\nexport const STUB_NON_RPC_METHODS = new Set(['fetch', 'connect', 'dup']);\n\n/**\n * Instruments a DurableObjectNamespace binding to create spans for DO interactions.\n *\n * Wraps:\n * - `namespace.get(id)` / `namespace.getByName(name)` with a span + instruments returned stub\n * - `namespace.idFromName(name)` / `namespace.idFromString(id)` / `namespace.newUniqueId()` with breadcrumbs\n *\n * @param namespace - The DurableObjectNamespace to instrument\n */\nexport function instrumentDurableObjectNamespace(namespace: DurableObjectNamespace): DurableObjectNamespace {\n return new Proxy(namespace, {\n get(target, prop, _receiver) {\n const value = Reflect.get(target, prop) as unknown;\n\n if (typeof value !== 'function') {\n return value;\n }\n\n if (prop === 'get' || prop === 'getByName') {\n return function (this: unknown, ...args: unknown[]) {\n const stub = Reflect.apply(value, target, args);\n\n return instrumentDurableObjectStub(stub);\n };\n }\n\n return value.bind(target);\n },\n });\n}\n\n/**\n * Instruments a DurableObjectStub to create spans for outgoing fetch calls\n * and propagate trace context across RPC calls.\n *\n * @param stub - The DurableObjectStub to instrument\n */\nfunction instrumentDurableObjectStub(stub: DurableObjectStub): DurableObjectStub {\n return new Proxy(stub, {\n get(target, prop) {\n const value = Reflect.get(target, prop);\n\n if (prop === 'fetch' && typeof value === 'function') {\n return instrumentFetcher((...args) => Reflect.apply(value, target, args));\n }\n\n if (typeof value === 'function' && typeof prop === 'string' && !STUB_NON_RPC_METHODS.has(prop)) {\n return (...args: unknown[]) => Reflect.apply(value, target, appendRpcMeta(args));\n }\n\n return value;\n },\n });\n}\n"],"names":["instrumentFetcher","appendRpcMeta"],"mappings":";;;;;AAKO,MAAM,uCAAuB,IAAI,GAAA,CAAI,CAAC,OAAA,EAAS,SAAA,EAAW,KAAK,CAAC;AAWhE,SAAS,iCAAiC,SAAA,EAA2D;AAC1G,EAAA,OAAO,IAAI,MAAM,SAAA,EAAW;AAAA,IAC1B,GAAA,CAAI,MAAA,EAAQ,IAAA,EAAM,SAAA,EAAW;AAC3B,MAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,GAAA,CAAI,MAAA,EAAQ,IAAI,CAAA;AAEtC,MAAA,IAAI,OAAO,UAAU,UAAA,EAAY;AAC/B,QAAA,OAAO,KAAA;AAAA,MACT;AAEA,MAAA,IAAI,IAAA,KAAS,KAAA,IAAS,IAAA,KAAS,WAAA,EAAa;AAC1C,QAAA,OAAO,YAA4B,IAAA,EAAiB;AAClD,UAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,KAAA,CAAM,KAAA,EAAO,QAAQ,IAAI,CAAA;AAE9C,UAAA,OAAO,4BAA4B,IAAI,CAAA;AAAA,QACzC,CAAA;AAAA,MACF;AAEA,MAAA,OAAO,KAAA,CAAM,KAAK,MAAM,CAAA;AAAA,IAC1B;AAAA,GACD,CAAA;AACH;AAQA,SAAS,4BAA4B,IAAA,EAA4C;AAC/E,EAAA,OAAO,IAAI,MAAM,IAAA,EAAM;AAAA,IACrB,GAAA,CAAI,QAAQ,IAAA,EAAM;AAChB,MAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,GAAA,CAAI,MAAA,EAAQ,IAAI,CAAA;AAEtC,MAAA,IAAI,IAAA,KAAS,OAAA,IAAW,OAAO,KAAA,KAAU,UAAA,EAAY;AACnD,QAAA,OAAOA,mCAAA,CAAkB,IAAI,IAAA,KAAS,OAAA,CAAQ,MAAM,KAAA,EAAO,MAAA,EAAQ,IAAI,CAAC,CAAA;AAAA,MAC1E;AAEA,MAAA,IAAI,OAAO,KAAA,KAAU,UAAA,IAAc,OAAO,IAAA,KAAS,YAAY,CAAC,oBAAA,CAAqB,GAAA,CAAI,IAAI,CAAA,EAAG;AAC9F,QAAA,OAAO,CAAA,GAAI,SAAoB,OAAA,CAAQ,KAAA,CAAM,OAAO,MAAA,EAAQC,qBAAA,CAAc,IAAI,CAAC,CAAA;AAAA,MACjF;AAEA,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,GACD,CAAA;AACH;;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrumentDurableObjectStorage.js","sources":["../../../../src/instrumentations/instrumentDurableObjectStorage.ts"],"sourcesContent":["import type { DurableObjectStorage, SyncKvStorage, SqlStorage } from '@cloudflare/workers-types';\nimport { getClient, isThenable, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, startSpan } from '@sentry/core';\nimport type { CloudflareClientOptions } from '../client';\nimport { getStorageKeys, targetsCloudflareInternalKey } from '../utils/internalStorageKey';\nimport { storeSpanContext } from '../utils/traceLinks';\nimport { instrumentDurableObjectSyncKvStorage } from './instrumentDurableObjectSyncKvStorage';\nimport { instrumentSqlStorage } from './instrumentSqlStorage';\n\nconst STORAGE_METHODS_TO_INSTRUMENT = ['get', 'put', 'delete', 'list', 'setAlarm', 'getAlarm', 'deleteAlarm'] as const;\n\ntype StorageMethod = (typeof STORAGE_METHODS_TO_INSTRUMENT)[number];\n\ntype WaitUntil = (promise: Promise<unknown>) => void;\n\n/**\n * Instruments DurableObjectStorage methods with Sentry spans.\n *\n * Wraps the following async methods:\n * - get, put, delete, list (KV API)\n * - setAlarm, getAlarm, deleteAlarm (Alarm API)\n *\n * When setAlarm is called, it also stores the current span context so that when\n * the alarm fires later, it can link back to the trace that called setAlarm.\n *\n * @param storage - The DurableObjectStorage instance to instrument\n * @param waitUntil - Optional waitUntil function to defer span context storage\n * @returns An instrumented DurableObjectStorage instance\n */\nexport function instrumentDurableObjectStorage(\n storage: DurableObjectStorage,\n waitUntil?: WaitUntil,\n): DurableObjectStorage {\n return new Proxy(storage, {\n get(target, prop, _receiver) {\n // Use `target` as the receiver instead of the proxy (`_receiver`).\n // Native workerd getters (e.g., `storage.sql`) validate `this` via\n // internal slots. Passing the proxy as receiver breaks that check,\n // causing \"Illegal invocation: function called with incorrect `this`\n // reference\" errors.\n const original = Reflect.get(target, prop, target);\n\n if (prop === 'kv' && original != null && 'get' in original && 'put' in original) {\n return instrumentDurableObjectSyncKvStorage(original as SyncKvStorage);\n }\n\n if (prop === 'sql' && original != null && 'databaseSize' in original && 'exec' in original) {\n return instrumentSqlStorage(original as SqlStorage);\n }\n\n if (typeof original !== 'function') {\n return original;\n }\n\n const methodName = prop as string;\n if (!STORAGE_METHODS_TO_INSTRUMENT.includes(methodName as StorageMethod)) {\n return (original as (...args: unknown[]) => unknown).bind(target);\n }\n\n return function (this: unknown, ...args: unknown[]) {\n // KV entries managed by the DO framework itself (agents/partyserver state) are bookkeeping\n // rather than user work — skip the span, mirroring how `cf_` SQL tables are treated.\n // oxlint-disable-next-line typescript/no-unnecessary-type-assertion -- rule false positive: the cast reaches the Cloudflare-only `durableObjectStorageSpanAllowlist`; tsc errors without it\n const allowlist = (getClient()?.getOptions() as CloudflareClientOptions | undefined)\n ?.durableObjectStorageSpanAllowlist;\n const keys = getStorageKeys(methodName, args);\n if (keys && keys.length > 0 && keys.every(key => targetsCloudflareInternalKey(key, allowlist))) {\n return (original as (...a: unknown[]) => unknown).apply(target, args);\n }\n\n return startSpan(\n {\n // Use underscore naming to match Cloudflare's native instrumentation (e.g., \"durable_object_storage_get\")\n name: `durable_object_storage_${methodName}`,\n op: 'db',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.cloudflare.durable_object',\n 'db.system.name': 'cloudflare.durable_object.storage',\n 'db.operation.name': methodName,\n },\n },\n () => {\n const teardown = async (): Promise<void> => {\n // When setAlarm is called, store the current span context so that when the alarm\n // fires later, it can link back to the trace that called setAlarm.\n // We use the original (uninstrumented) storage (target) to avoid creating a span\n // for this internal operation. The storage is deferred via waitUntil to not block.\n if (methodName === 'setAlarm') {\n storeSpanContext(target, 'alarm');\n }\n };\n\n const result = (original as (...args: unknown[]) => unknown).apply(target, args);\n\n if (!isThenable(result)) {\n waitUntil?.(teardown());\n\n return result;\n }\n\n return result.then(\n res => {\n waitUntil?.(teardown());\n return res;\n },\n e => {\n throw e;\n },\n );\n },\n );\n };\n },\n });\n}\n"],"names":["instrumentDurableObjectSyncKvStorage","instrumentSqlStorage","getClient","getStorageKeys","targetsCloudflareInternalKey","startSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","storeSpanContext","isThenable"],"mappings":";;;;;;;;AAQA,MAAM,6BAAA,GAAgC,CAAC,KAAA,EAAO,KAAA,EAAO,UAAU,MAAA,EAAQ,UAAA,EAAY,YAAY,aAAa,CAAA;AAoBrG,SAAS,8BAAA,CACd,SACA,SAAA,EACsB;AACt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