@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
@@ -0,0 +1,234 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const noDiagnosticChannels = require('@sentry/server-utils/no-diagnostic-channels');
5
+ const instrument = require('./instrument.js');
6
+ const instrumentEnv = require('./instrumentations/worker/instrumentEnv.js');
7
+ const options = require('./options.js');
8
+ const request = require('./request.js');
9
+ const sdk = require('./sdk.js');
10
+ const instrumentContext = require('./utils/instrumentContext.js');
11
+ const rpcMeta = require('./utils/rpcMeta.js');
12
+ const index = require('./instrumentations/agents/index.js');
13
+ const wrapMethodWithSentry = require('./wrapMethodWithSentry.js');
14
+
15
+ function constructInstrumentedDurableObject(target, ctx, env, newTarget, optionsCallback) {
16
+ noDiagnosticChannels.setAsyncLocalStorageAsyncContextStrategy();
17
+ const options$1 = options.getFinalOptions(optionsCallback(env), env);
18
+ const context = instrumentContext.instrumentContext(ctx);
19
+ const instrumentedEnv = instrumentEnv.instrumentEnv(env, options$1);
20
+ const prototype = newTarget.prototype ?? target.prototype;
21
+ const cachedFrameworkManagedMethods = frameworkManagedMethodsCache.get(prototype);
22
+ const methodsBeforeConstruction = cachedFrameworkManagedMethods ? void 0 : resolvePrototypeMethods(prototype);
23
+ const obj = Reflect.construct(target, [context, instrumentedEnv], newTarget);
24
+ const frameworkManagedMethods = resolveFrameworkManagedMethods(
25
+ prototype,
26
+ obj,
27
+ methodsBeforeConstruction,
28
+ cachedFrameworkManagedMethods
29
+ );
30
+ instrumentDurableObjectHandlers(obj, options$1, context);
31
+ return { obj, options: options$1, context, frameworkManagedMethods };
32
+ }
33
+ const frameworkManagedMethodsCache = /* @__PURE__ */ new WeakMap();
34
+ function resolvePrototypeMethods(prototype) {
35
+ const methods = /* @__PURE__ */ new Map();
36
+ for (let current = prototype; current && current !== Object.prototype; current = Object.getPrototypeOf(current)) {
37
+ for (const name of Object.getOwnPropertyNames(current)) {
38
+ if (name === "constructor" || methods.has(name)) {
39
+ continue;
40
+ }
41
+ const descriptor = Object.getOwnPropertyDescriptor(current, name);
42
+ if (descriptor && typeof descriptor.value === "function") {
43
+ methods.set(name, descriptor.value);
44
+ }
45
+ }
46
+ }
47
+ return methods;
48
+ }
49
+ function resolveFrameworkManagedMethods(prototype, obj, methodsBeforeConstruction, cached) {
50
+ if (cached) {
51
+ return cached;
52
+ }
53
+ const methodsAfterConstruction = resolvePrototypeMethods(Object.getPrototypeOf(obj));
54
+ const managed = /* @__PURE__ */ new Set();
55
+ for (const [name, method] of methodsAfterConstruction) {
56
+ const before = methodsBeforeConstruction?.get(name);
57
+ if (before && before !== method) {
58
+ managed.add(name);
59
+ }
60
+ }
61
+ frameworkManagedMethodsCache.set(prototype, managed);
62
+ return managed;
63
+ }
64
+ function instrumentDurableObjectHandlers(obj, options, context) {
65
+ if (obj.fetch && typeof obj.fetch === "function") {
66
+ obj.fetch = instrument.ensureInstrumented(
67
+ obj.fetch.bind(obj),
68
+ (original) => new Proxy(original, {
69
+ apply(target, thisArg, args) {
70
+ return request.wrapRequestHandlerWithInit(
71
+ { options, request: args[0], context },
72
+ () => {
73
+ return Reflect.apply(target, thisArg, args);
74
+ },
75
+ sdk.init
76
+ );
77
+ }
78
+ })
79
+ );
80
+ }
81
+ if (obj.alarm && typeof obj.alarm === "function") {
82
+ obj.alarm = wrapMethodWithSentry.wrapMethodWithSentry(
83
+ {
84
+ options,
85
+ context,
86
+ spanName: "alarm",
87
+ spanOp: "function",
88
+ startNewTrace: true,
89
+ origin: "auto.faas.cloudflare.durable_object"
90
+ },
91
+ obj.alarm.bind(obj)
92
+ );
93
+ }
94
+ if (obj.webSocketMessage && typeof obj.webSocketMessage === "function") {
95
+ obj.webSocketMessage = wrapMethodWithSentry.wrapMethodWithSentry(
96
+ { options, context, spanName: "webSocketMessage", origin: "auto.faas.cloudflare.durable_object" },
97
+ obj.webSocketMessage.bind(obj)
98
+ );
99
+ }
100
+ if (obj.webSocketClose && typeof obj.webSocketClose === "function") {
101
+ obj.webSocketClose = wrapMethodWithSentry.wrapMethodWithSentry(
102
+ { options, context, spanName: "webSocketClose", origin: "auto.faas.cloudflare.durable_object" },
103
+ obj.webSocketClose.bind(obj)
104
+ );
105
+ }
106
+ if (obj.webSocketError && typeof obj.webSocketError === "function") {
107
+ obj.webSocketError = wrapMethodWithSentry.wrapMethodWithSentry(
108
+ { options, context, spanName: "webSocketError", origin: "auto.faas.cloudflare.durable_object" },
109
+ obj.webSocketError.bind(obj),
110
+ (_, error) => core.captureException(error, {
111
+ mechanism: {
112
+ type: "auto.faas.cloudflare.durable_object_websocket",
113
+ handled: false
114
+ }
115
+ })
116
+ );
117
+ }
118
+ }
119
+ const RESERVED_RPC_METHOD_NAMES = /* @__PURE__ */ new Set([
120
+ "constructor",
121
+ "fetch",
122
+ "connect",
123
+ "alarm",
124
+ "webSocketMessage",
125
+ "webSocketClose",
126
+ "webSocketError",
127
+ "dup"
128
+ ]);
129
+ const rpcInstanceStates = /* @__PURE__ */ new WeakMap();
130
+ function finalizeWithRpcInstrumentation(obj, options, context, excludedMethods) {
131
+ if (options.enableRpcTracePropagation === false) {
132
+ return obj;
133
+ }
134
+ rpcInstanceStates.set(obj, { options, context });
135
+ instrumentPrototypeRpcMethods(obj, excludedMethods);
136
+ return obj;
137
+ }
138
+ function getRpcMethodDescriptor(obj, prototype, methodName, excludedMethods) {
139
+ if (RESERVED_RPC_METHOD_NAMES.has(methodName) || Object.prototype.hasOwnProperty.call(obj, methodName) || excludedMethods?.has(methodName)) {
140
+ return void 0;
141
+ }
142
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
143
+ if (!descriptor || typeof descriptor.value !== "function" || instrument.getInstrumented(descriptor.value)) {
144
+ return void 0;
145
+ }
146
+ return descriptor;
147
+ }
148
+ function instrumentPrototypeRpcMethods(obj, excludedMethods) {
149
+ let prototype = Object.getPrototypeOf(obj);
150
+ while (prototype && prototype !== Object.prototype) {
151
+ for (const methodName of Object.getOwnPropertyNames(prototype)) {
152
+ const descriptor = getRpcMethodDescriptor(obj, prototype, methodName, excludedMethods);
153
+ if (!descriptor) {
154
+ continue;
155
+ }
156
+ const wrapped = createRpcPrototypeWrapper(methodName, descriptor.value);
157
+ try {
158
+ Object.defineProperty(prototype, methodName, { ...descriptor, value: wrapped });
159
+ } catch {
160
+ }
161
+ instrument.markAsInstrumented(wrapped);
162
+ }
163
+ prototype = Object.getPrototypeOf(prototype);
164
+ }
165
+ }
166
+ function createRpcPrototypeWrapper(methodName, originalMethod) {
167
+ const wrapper = function(...args) {
168
+ if (!rpcMeta.hasRpcMeta(args)) {
169
+ return Reflect.apply(originalMethod, this, args);
170
+ }
171
+ const state = core.isObjectLike(this) ? rpcInstanceStates.get(this) : void 0;
172
+ if (!state) {
173
+ return Reflect.apply(originalMethod, this, args);
174
+ }
175
+ const tracedMethods = state.tracedMethods ?? (state.tracedMethods = /* @__PURE__ */ new Map());
176
+ let traced = tracedMethods.get(methodName);
177
+ if (!traced) {
178
+ traced = wrapMethodWithSentry.wrapMethodWithSentry(
179
+ {
180
+ options: state.options,
181
+ context: state.context,
182
+ spanName: methodName,
183
+ spanOp: "rpc",
184
+ origin: "auto.faas.cloudflare.durable_object"
185
+ },
186
+ originalMethod,
187
+ void 0,
188
+ true
189
+ );
190
+ tracedMethods.set(methodName, traced);
191
+ }
192
+ return Reflect.apply(traced, this, args);
193
+ };
194
+ Object.defineProperties(wrapper, {
195
+ name: { value: originalMethod.name, configurable: true },
196
+ length: { value: originalMethod.length, configurable: true }
197
+ });
198
+ return wrapper;
199
+ }
200
+ function instrumentDurableObjectWithSentry(optionsCallback, DurableObjectClass) {
201
+ return new Proxy(DurableObjectClass, {
202
+ construct(target, [ctx, env], newTarget) {
203
+ const { obj, options, context, frameworkManagedMethods } = constructInstrumentedDurableObject(
204
+ target,
205
+ ctx,
206
+ env,
207
+ newTarget,
208
+ optionsCallback
209
+ );
210
+ return finalizeWithRpcInstrumentation(obj, options, context, frameworkManagedMethods);
211
+ }
212
+ });
213
+ }
214
+ function instrumentAgentWithSentry(optionsCallback, AgentClass) {
215
+ return new Proxy(AgentClass, {
216
+ construct(target, [ctx, env], newTarget) {
217
+ const { obj, options, context, frameworkManagedMethods } = constructInstrumentedDurableObject(
218
+ target,
219
+ ctx,
220
+ env,
221
+ newTarget,
222
+ optionsCallback
223
+ );
224
+ index.instrumentCloudflareAgent(obj);
225
+ return finalizeWithRpcInstrumentation(obj, options, context, frameworkManagedMethods);
226
+ }
227
+ });
228
+ }
229
+
230
+ exports.constructInstrumentedDurableObject = constructInstrumentedDurableObject;
231
+ exports.finalizeWithRpcInstrumentation = finalizeWithRpcInstrumentation;
232
+ exports.instrumentAgentWithSentry = instrumentAgentWithSentry;
233
+ exports.instrumentDurableObjectWithSentry = instrumentDurableObjectWithSentry;
234
+ //# sourceMappingURL=durableobject.js.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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,GAAG,SAAA,EAAW;AACvC,MAAA,MAAM,EAAE,GAAA,EAAK,OAAA,EAAS,OAAA,EAAS,yBAAwB,GAAI,kCAAA;AAAA,QACzD,MAAA;AAAA,QACA,GAAA;AAAA,QACA,GAAA;AAAA,QACA,SAAA;AAAA,QACA;AAAA,OACF;AAEA,MAAAM,+BAAA,CAA0B,GAAG,CAAA;AAM7B,MAAA,OAAO,8BAAA,CAA+B,GAAA,EAAK,OAAA,EAAS,OAAA,EAAS,uBAAuB,CAAA;AAAA,IACtF;AAAA,GACD,CAAA;AACH;;;;;;;"}
@@ -0,0 +1,87 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const debugBuild = require('./debug-build.js');
5
+
6
+ const flushLockRegistries = /* @__PURE__ */ new WeakMap();
7
+ function getOriginalWaitUntil(context) {
8
+ const currentWaitUntil = context.waitUntil;
9
+ const original = flushLockRegistries.get(currentWaitUntil)?.originalWaitUntil;
10
+ return original ?? currentWaitUntil;
11
+ }
12
+ function makeFlushLock(context) {
13
+ const registry = getOrCreateFlushLockRegistry(context);
14
+ let resolveAllDone = () => void 0;
15
+ const allDone = new Promise((res) => {
16
+ resolveAllDone = res;
17
+ });
18
+ let pending = 0;
19
+ const lock = {
20
+ ready: allDone,
21
+ acquire: () => {
22
+ pending++;
23
+ },
24
+ release: () => {
25
+ if (--pending === 0) {
26
+ registry.locks.delete(lock);
27
+ resolveAllDone();
28
+ }
29
+ },
30
+ finalize: () => {
31
+ if (pending === 0) {
32
+ registry.locks.delete(lock);
33
+ resolveAllDone();
34
+ }
35
+ return allDone;
36
+ }
37
+ };
38
+ registry.locks.add(lock);
39
+ return Object.freeze(lock);
40
+ }
41
+ function getOrCreateFlushLockRegistry(context) {
42
+ const waitUntil = context.waitUntil;
43
+ const existingRegistry = flushLockRegistries.get(waitUntil);
44
+ if (existingRegistry) {
45
+ return existingRegistry;
46
+ }
47
+ const originalWaitUntil = context.waitUntil.bind(context);
48
+ const registry = { locks: /* @__PURE__ */ new Set(), originalWaitUntil };
49
+ const instrumentedWaitUntil = (promise) => {
50
+ const locks = [...registry.locks];
51
+ for (const lock of locks) {
52
+ lock.acquire();
53
+ }
54
+ return originalWaitUntil(
55
+ promise.finally(() => {
56
+ for (const lock of locks) {
57
+ lock.release();
58
+ }
59
+ })
60
+ );
61
+ };
62
+ flushLockRegistries.set(instrumentedWaitUntil, registry);
63
+ context.waitUntil = instrumentedWaitUntil;
64
+ return registry;
65
+ }
66
+ async function flushAndDispose(client, timeout = 2e3) {
67
+ try {
68
+ if (!client) {
69
+ await core.flush(timeout);
70
+ return;
71
+ }
72
+ await client.flush(timeout);
73
+ } catch (e) {
74
+ debugBuild.DEBUG_BUILD && core.debug.warn("Failed to flush client", e);
75
+ } finally {
76
+ try {
77
+ client?.dispose();
78
+ } catch (e) {
79
+ debugBuild.DEBUG_BUILD && core.debug.warn("Failed to dispose client", e);
80
+ }
81
+ }
82
+ }
83
+
84
+ exports.flushAndDispose = flushAndDispose;
85
+ exports.getOriginalWaitUntil = getOriginalWaitUntil;
86
+ exports.makeFlushLock = makeFlushLock;
87
+ //# sourceMappingURL=flush.js.map
@@ -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,C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AAA,MAAM,KAAA,GAAQ,CAAC,GAAG,QAAA,CAAS,KAAK,CAAA;AAEhC,IAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,MAAA,IAAA,CAAK,OAAA,EAAQ;AAAA,IACf;AAEA,IAAA,OAAO,iBAAA;AAAA,MACL,OAAA,CAAQ,QAAQ,MAAM;AACpB,QAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,UAAA,IAAA,CAAK,OAAA,EAAQ;AAAA,QACf;AAAA,MACF,CAAC;AAAA,KACH;AAAA,EACF,CAAA;AAEA,EAAA,mBAAA,CAAoB,GAAA,CAAI,uBAAuB,QAAQ,CAAA;AACvD,EAAA,OAAA,CAAQ,SAAA,GAAY,qBAAA;AAEpB,EAAA,OAAO,QAAA;AACT;AAeA,eAAsB,eAAA,CAAgB,MAAA,EAA4B,OAAA,GAAU,GAAA,EAAqB;AAC/F,EAAA,IAAI;AACF,IAAA,IAAI,CAAC,MAAA,EAAQ;AACX,MAAA,MAAMA,WAAM,OAAO,CAAA;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;;;;;;"}
@@ -1,28 +1,22 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const serverUtils = require('@sentry/server-utils');
4
- const vercelai = require('./integrations/tracing/vercelai.js');
5
- const client = require('../client.js');
6
3
  const core = require('@sentry/core');
7
- const defineCloudflareOptions = require('../defineCloudflareOptions.js');
8
- const fetch = require('../integrations/fetch.js');
9
- const sdk = require('../sdk.js');
10
- const hono = require('../integrations/hono.js');
11
- const httpServer = require('../integrations/httpServer.js');
12
- const durableobject = require('../durableobject.js');
13
- const instrumentD1 = require('../instrumentations/worker/instrumentD1.js');
14
- const workflows = require('../workflows.js');
15
- const pagesPlugin = require('../pages-plugin.js');
16
- const async = require('../async.js');
17
- const spotlight = require('../integrations/spotlight.js');
18
- const withSentry = require('../withSentry.js');
19
- const request = require('../request.js');
4
+ const withSentry = require('./withSentry.js');
5
+ const defineCloudflareOptions = require('./defineCloudflareOptions.js');
6
+ const durableobject = require('./durableobject.js');
7
+ const pagesPlugin = require('./pages-plugin.js');
8
+ const client = require('./client.js');
9
+ const sdk = require('./sdk.js');
10
+ const httpServer = require('./integrations/httpServer.js');
11
+ const fetch = require('./integrations/fetch.js');
12
+ const spotlight = require('./integrations/spotlight.js');
13
+ const vercelai = require('./integrations/tracing/vercelai.js');
14
+ const serverUtils = require('@sentry/server-utils');
15
+ const workflows = require('./workflows.js');
16
+ const noDiagnosticChannels = require('@sentry/server-utils/no-diagnostic-channels');
20
17
 
21
18
 
22
19
 
23
- exports.prismaIntegration = serverUtils.prismaIntegration;
24
- exports.vercelAIIntegration = vercelai.vercelAIIntegration;
25
- exports.CloudflareClient = client.CloudflareClient;
26
20
  exports.SDK_VERSION = core.SDK_VERSION;
27
21
  exports.SEMANTIC_ATTRIBUTE_SENTRY_OP = core.SEMANTIC_ATTRIBUTE_SENTRY_OP;
28
22
  exports.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN;
@@ -44,7 +38,6 @@ exports.consoleIntegration = core.consoleIntegration;
44
38
  exports.consoleLoggingIntegration = core.consoleLoggingIntegration;
45
39
  exports.continueTrace = core.continueTrace;
46
40
  exports.createConsolaReporter = core.createConsolaReporter;
47
- exports.createLangChainCallbackHandler = core.createLangChainCallbackHandler;
48
41
  exports.createTransport = core.createTransport;
49
42
  exports.dedupeIntegration = core.dedupeIntegration;
50
43
  exports.eventFiltersIntegration = core.eventFiltersIntegration;
@@ -63,15 +56,7 @@ exports.getSpanStatusFromHttpCode = core.getSpanStatusFromHttpCode;
63
56
  exports.getTraceData = core.getTraceData;
64
57
  exports.getTraceMetaTags = core.getTraceMetaTags;
65
58
  exports.growthbookIntegration = core.growthbookIntegration;
66
- exports.inboundFiltersIntegration = core.inboundFiltersIntegration;
67
- exports.instrumentAnthropicAiClient = core.instrumentAnthropicAiClient;
68
- exports.instrumentCreateReactAgent = core.instrumentCreateReactAgent;
69
- exports.instrumentGoogleGenAIClient = core.instrumentGoogleGenAIClient;
70
- exports.instrumentLangChainEmbeddings = core.instrumentLangChainEmbeddings;
71
- exports.instrumentLangGraph = core.instrumentLangGraph;
72
- exports.instrumentOpenAiClient = core.instrumentOpenAiClient;
73
59
  exports.instrumentPostgresJsSql = core.instrumentPostgresJsSql;
74
- exports.instrumentStateGraph = core.instrumentStateGraph;
75
60
  exports.instrumentSupabaseClient = core.instrumentSupabaseClient;
76
61
  exports.isEnabled = core.isEnabled;
77
62
  exports.isInitialized = core.isInitialized;
@@ -97,6 +82,7 @@ exports.setUser = core.setUser;
97
82
  exports.spanStreamingIntegration = core.spanStreamingIntegration;
98
83
  exports.spanToBaggageHeader = core.spanToBaggageHeader;
99
84
  exports.spanToJSON = core.spanToJSON;
85
+ exports.spanToStaticSpanJSON = core.spanToStaticSpanJSON;
100
86
  exports.spanToTraceHeader = core.spanToTraceHeader;
101
87
  exports.startInactiveSpan = core.startInactiveSpan;
102
88
  exports.startNewTrace = core.startNewTrace;
@@ -110,21 +96,32 @@ exports.withActiveSpan = core.withActiveSpan;
110
96
  exports.withIsolationScope = core.withIsolationScope;
111
97
  exports.withMonitor = core.withMonitor;
112
98
  exports.withScope = core.withScope;
99
+ exports.withStaticSpan = core.withStaticSpan;
113
100
  exports.withStreamedSpan = core.withStreamedSpan;
114
101
  exports.wrapMcpServerWithSentry = core.wrapMcpServerWithSentry;
115
102
  exports.zodErrorsIntegration = core.zodErrorsIntegration;
103
+ exports.withSentry = withSentry.withSentry;
116
104
  exports.defineCloudflareOptions = defineCloudflareOptions.defineCloudflareOptions;
117
- exports.fetchIntegration = fetch.fetchIntegration;
118
- exports.getDefaultIntegrations = sdk.getDefaultIntegrations;
119
- exports.honoIntegration = hono.honoIntegration;
120
- exports.httpServerIntegration = httpServer.httpServerIntegration;
121
105
  exports.instrumentAgentWithSentry = durableobject.instrumentAgentWithSentry;
122
106
  exports.instrumentDurableObjectWithSentry = durableobject.instrumentDurableObjectWithSentry;
123
- exports.instrumentD1WithSentry = instrumentD1.instrumentD1WithSentry;
124
- exports.instrumentWorkflowWithSentry = workflows.instrumentWorkflowWithSentry;
125
107
  exports.sentryPagesPlugin = pagesPlugin.sentryPagesPlugin;
126
- exports.setAsyncLocalStorageAsyncContextStrategy = async.setAsyncLocalStorageAsyncContextStrategy;
108
+ exports.CloudflareClient = client.CloudflareClient;
109
+ exports.getDefaultIntegrations = sdk.getDefaultIntegrations;
110
+ exports.httpServerIntegration = httpServer.httpServerIntegration;
111
+ exports.fetchIntegration = fetch.fetchIntegration;
127
112
  exports.spotlightIntegration = spotlight.spotlightIntegration;
128
- exports.withSentry = withSentry.withSentry;
129
- exports.wrapRequestHandler = request.wrapRequestHandler;
113
+ exports.vercelAIIntegration = vercelai.vercelAIIntegration;
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;
125
+ exports.instrumentWorkflowWithSentry = workflows.instrumentWorkflowWithSentry;
126
+ exports.setAsyncLocalStorageAsyncContextStrategy = noDiagnosticChannels.setAsyncLocalStorageAsyncContextStrategy;
130
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,52 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+
5
+ const GLOBAL_KEY = "__SENTRY_INSTRUMENTED_MAP__";
6
+ function getInstrumentedMap() {
7
+ const globalObj = globalThis;
8
+ if (!globalObj[GLOBAL_KEY]) {
9
+ globalObj[GLOBAL_KEY] = /* @__PURE__ */ new WeakMap();
10
+ }
11
+ return globalObj[GLOBAL_KEY];
12
+ }
13
+ function isWeakMapKey(value) {
14
+ return core.isObjectLike(value) || typeof value === "function";
15
+ }
16
+ function markAsInstrumented(original, instrumented) {
17
+ try {
18
+ if (isWeakMapKey(original)) {
19
+ getInstrumentedMap().set(original, instrumented ?? original);
20
+ }
21
+ if (isWeakMapKey(instrumented) && instrumented !== original) {
22
+ getInstrumentedMap().set(instrumented, instrumented);
23
+ }
24
+ } catch {
25
+ }
26
+ }
27
+ function getInstrumented(obj) {
28
+ try {
29
+ if (isWeakMapKey(obj)) {
30
+ return getInstrumentedMap().get(obj);
31
+ }
32
+ return void 0;
33
+ } catch {
34
+ return void 0;
35
+ }
36
+ }
37
+ function ensureInstrumented(original, instrumentFn, noMark) {
38
+ const existing = getInstrumented(original);
39
+ if (existing) {
40
+ return existing;
41
+ }
42
+ const instrumented = instrumentFn(original);
43
+ if (!noMark) {
44
+ markAsInstrumented(original, instrumented);
45
+ }
46
+ return instrumented;
47
+ }
48
+
49
+ exports.ensureInstrumented = ensureInstrumented;
50
+ exports.getInstrumented = getInstrumented;
51
+ exports.markAsInstrumented = markAsInstrumented;
52
+ //# sourceMappingURL=instrument.js.map
@@ -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,16 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const instrumentAgentCallableRpc = require('./instrumentAgentCallableRpc.js');
4
+ const instrumentAgentRequestConversation = require('./instrumentAgentRequestConversation.js');
5
+ const instrumentChatAgentConversation = require('./instrumentChatAgentConversation.js');
6
+
7
+ function instrumentCloudflareAgent(agent) {
8
+ const internals = agent;
9
+ instrumentAgentCallableRpc.instrumentAgentCallableRpc(internals);
10
+ instrumentChatAgentConversation.instrumentChatAgentConversation(internals);
11
+ instrumentAgentRequestConversation.instrumentAgentRequestConversation(internals);
12
+ return agent;
13
+ }
14
+
15
+ exports.instrumentCloudflareAgent = instrumentCloudflareAgent;
16
+ //# sourceMappingURL=index.js.map
@@ -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;;;;"}