@sentry/cloudflare 11.11.0 → 11.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (628) hide show
  1. package/build/cjs/dev/_virtual/_rolldown/runtime.js +22 -0
  2. package/build/cjs/dev/baseSdk.js +98 -103
  3. package/build/cjs/dev/baseSdk.js.map +1 -1
  4. package/build/cjs/dev/client.js +213 -237
  5. package/build/cjs/dev/client.js.map +1 -1
  6. package/build/cjs/dev/clientCache.js +8 -8
  7. package/build/cjs/dev/clientCache.js.map +1 -1
  8. package/build/cjs/dev/debug-build.js +9 -5
  9. package/build/cjs/dev/debug-build.js.map +1 -1
  10. package/build/cjs/dev/defineCloudflareOptions.js +5 -8
  11. package/build/cjs/dev/defineCloudflareOptions.js.map +1 -1
  12. package/build/cjs/dev/durableobject.js +290 -163
  13. package/build/cjs/dev/durableobject.js.map +1 -1
  14. package/build/cjs/dev/flush.js +104 -77
  15. package/build/cjs/dev/flush.js.map +1 -1
  16. package/build/cjs/dev/index.js +181 -182
  17. package/build/cjs/dev/instrument.js +53 -39
  18. package/build/cjs/dev/instrument.js.map +1 -1
  19. package/build/cjs/dev/instrumentations/agents/index.js +34 -13
  20. package/build/cjs/dev/instrumentations/agents/index.js.map +1 -1
  21. package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js +46 -49
  22. package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  23. package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js +23 -16
  24. package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
  25. package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js +36 -28
  26. package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
  27. package/build/cjs/dev/instrumentations/agents/types.js +103 -58
  28. package/build/cjs/dev/instrumentations/agents/types.js.map +1 -1
  29. package/build/cjs/dev/instrumentations/instrumentDurableObjectHandlers.js +87 -118
  30. package/build/cjs/dev/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
  31. package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js +46 -44
  32. package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  33. package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js +70 -71
  34. package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  35. package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -39
  36. package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  37. package/build/cjs/dev/instrumentations/instrumentSqlStorage.js +50 -52
  38. package/build/cjs/dev/instrumentations/instrumentSqlStorage.js.map +1 -1
  39. package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js +136 -123
  40. package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  41. package/build/cjs/dev/instrumentations/worker/instrumentD1.js +131 -146
  42. package/build/cjs/dev/instrumentations/worker/instrumentD1.js.map +1 -1
  43. package/build/cjs/dev/instrumentations/worker/instrumentEmail.js +63 -61
  44. package/build/cjs/dev/instrumentations/worker/instrumentEmail.js.map +1 -1
  45. package/build/cjs/dev/instrumentations/worker/instrumentEnv.js +83 -87
  46. package/build/cjs/dev/instrumentations/worker/instrumentEnv.js.map +1 -1
  47. package/build/cjs/dev/instrumentations/worker/instrumentFetch.js +41 -48
  48. package/build/cjs/dev/instrumentations/worker/instrumentFetch.js.map +1 -1
  49. package/build/cjs/dev/instrumentations/worker/instrumentFetcher.js +25 -21
  50. package/build/cjs/dev/instrumentations/worker/instrumentFetcher.js.map +1 -1
  51. package/build/cjs/dev/instrumentations/worker/instrumentKV.js +54 -67
  52. package/build/cjs/dev/instrumentations/worker/instrumentKV.js.map +1 -1
  53. package/build/cjs/dev/instrumentations/worker/instrumentQueue.js +100 -76
  54. package/build/cjs/dev/instrumentations/worker/instrumentQueue.js.map +1 -1
  55. package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js +91 -75
  56. package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  57. package/build/cjs/dev/instrumentations/worker/instrumentR2.js +128 -115
  58. package/build/cjs/dev/instrumentations/worker/instrumentR2.js.map +1 -1
  59. package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js +90 -94
  60. package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js.map +1 -1
  61. package/build/cjs/dev/instrumentations/worker/instrumentTail.js +100 -55
  62. package/build/cjs/dev/instrumentations/worker/instrumentTail.js.map +1 -1
  63. package/build/cjs/dev/integrations/cronTriggers.js +130 -85
  64. package/build/cjs/dev/integrations/cronTriggers.js.map +1 -1
  65. package/build/cjs/dev/integrations/fetch.js +9 -9
  66. package/build/cjs/dev/integrations/fetch.js.map +1 -1
  67. package/build/cjs/dev/integrations/httpServer.js +41 -22
  68. package/build/cjs/dev/integrations/httpServer.js.map +1 -1
  69. package/build/cjs/dev/integrations/spotlight.js +52 -55
  70. package/build/cjs/dev/integrations/spotlight.js.map +1 -1
  71. package/build/cjs/dev/opentelemetry/tracer.js +10 -8
  72. package/build/cjs/dev/opentelemetry/tracer.js.map +1 -1
  73. package/build/cjs/dev/options.js +55 -39
  74. package/build/cjs/dev/options.js.map +1 -1
  75. package/build/cjs/dev/orchestrion-deferred-channels.js +45 -29
  76. package/build/cjs/dev/orchestrion-deferred-channels.js.map +1 -1
  77. package/build/cjs/dev/orchestrion-diagnostics-channel.js +97 -72
  78. package/build/cjs/dev/orchestrion-diagnostics-channel.js.map +1 -1
  79. package/build/cjs/dev/pages-plugin.js +20 -21
  80. package/build/cjs/dev/pages-plugin.js.map +1 -1
  81. package/build/cjs/dev/request.js +16 -10
  82. package/build/cjs/dev/request.js.map +1 -1
  83. package/build/cjs/dev/scope-utils.js +12 -12
  84. package/build/cjs/dev/scope-utils.js.map +1 -1
  85. package/build/cjs/dev/sdk.js +24 -15
  86. package/build/cjs/dev/sdk.js.map +1 -1
  87. package/build/cjs/dev/transport.js +93 -86
  88. package/build/cjs/dev/transport.js.map +1 -1
  89. package/build/cjs/dev/utils/asyncContextStrategy.js +10 -10
  90. package/build/cjs/dev/utils/asyncContextStrategy.js.map +1 -1
  91. package/build/cjs/dev/utils/bindingPropagation.js +24 -0
  92. package/build/cjs/dev/utils/bindingPropagation.js.map +1 -0
  93. package/build/cjs/dev/utils/cloudflareTrace.js +34 -0
  94. package/build/cjs/dev/utils/cloudflareTrace.js.map +1 -0
  95. package/build/cjs/dev/utils/instrumentContext.js +74 -58
  96. package/build/cjs/dev/utils/instrumentContext.js.map +1 -1
  97. package/build/cjs/dev/utils/internalSqlQuery.js +38 -21
  98. package/build/cjs/dev/utils/internalSqlQuery.js.map +1 -1
  99. package/build/cjs/dev/utils/internalStorageKey.js +41 -38
  100. package/build/cjs/dev/utils/internalStorageKey.js.map +1 -1
  101. package/build/cjs/dev/utils/invocationContext.js +42 -32
  102. package/build/cjs/dev/utils/invocationContext.js.map +1 -1
  103. package/build/cjs/dev/utils/invocationScope.js +45 -21
  104. package/build/cjs/dev/utils/invocationScope.js.map +1 -1
  105. package/build/cjs/dev/utils/isBinding.js +47 -15
  106. package/build/cjs/dev/utils/isBinding.js.map +1 -1
  107. package/build/cjs/dev/utils/isCloudflareClass.js +11 -20
  108. package/build/cjs/dev/utils/isCloudflareClass.js.map +1 -1
  109. package/build/cjs/dev/utils/queueTraceMeta.js +33 -0
  110. package/build/cjs/dev/utils/queueTraceMeta.js.map +1 -0
  111. package/build/cjs/dev/utils/rpcMeta.js +37 -27
  112. package/build/cjs/dev/utils/rpcMeta.js.map +1 -1
  113. package/build/cjs/dev/utils/traceLinks.js +52 -42
  114. package/build/cjs/dev/utils/traceLinks.js.map +1 -1
  115. package/build/cjs/dev/vendor/stacktrace.js +32 -24
  116. package/build/cjs/dev/vendor/stacktrace.js.map +1 -1
  117. package/build/cjs/dev/vite/agentClass.js +105 -98
  118. package/build/cjs/dev/vite/agentClass.js.map +1 -1
  119. package/build/cjs/dev/vite/autoInstrument.js +121 -122
  120. package/build/cjs/dev/vite/autoInstrument.js.map +1 -1
  121. package/build/cjs/dev/vite/index.js +44 -21
  122. package/build/cjs/dev/vite/index.js.map +1 -1
  123. package/build/cjs/dev/vite/instrumentFile.js +37 -20
  124. package/build/cjs/dev/vite/instrumentFile.js.map +1 -1
  125. package/build/cjs/dev/vite/mastraObservability.js +19 -12
  126. package/build/cjs/dev/vite/mastraObservability.js.map +1 -1
  127. package/build/cjs/dev/vite/moduleShape.js +220 -201
  128. package/build/cjs/dev/vite/moduleShape.js.map +1 -1
  129. package/build/cjs/dev/vite/providedModulePlugin.js +62 -45
  130. package/build/cjs/dev/vite/providedModulePlugin.js.map +1 -1
  131. package/build/cjs/dev/vite/transform.js +333 -284
  132. package/build/cjs/dev/vite/transform.js.map +1 -1
  133. package/build/cjs/dev/vite/workerEntrypoint.js +66 -57
  134. package/build/cjs/dev/vite/workerEntrypoint.js.map +1 -1
  135. package/build/cjs/dev/vite/wranglerConfig.js +92 -67
  136. package/build/cjs/dev/vite/wranglerConfig.js.map +1 -1
  137. package/build/cjs/dev/withSentry.js +32 -26
  138. package/build/cjs/dev/withSentry.js.map +1 -1
  139. package/build/cjs/dev/workflows.js +165 -149
  140. package/build/cjs/dev/workflows.js.map +1 -1
  141. package/build/cjs/dev/wrapMethodWithSentry.js +148 -169
  142. package/build/cjs/dev/wrapMethodWithSentry.js.map +1 -1
  143. package/build/cjs/dev/wrapRequestHandlerWithInit.js +78 -72
  144. package/build/cjs/dev/wrapRequestHandlerWithInit.js.map +1 -1
  145. package/build/cjs/prod/_virtual/_rolldown/runtime.js +22 -0
  146. package/build/cjs/prod/baseSdk.js +94 -93
  147. package/build/cjs/prod/baseSdk.js.map +1 -1
  148. package/build/cjs/prod/client.js +213 -237
  149. package/build/cjs/prod/client.js.map +1 -1
  150. package/build/cjs/prod/clientCache.js +8 -8
  151. package/build/cjs/prod/clientCache.js.map +1 -1
  152. package/build/cjs/prod/debug-build.js +9 -5
  153. package/build/cjs/prod/debug-build.js.map +1 -1
  154. package/build/cjs/prod/defineCloudflareOptions.js +5 -8
  155. package/build/cjs/prod/defineCloudflareOptions.js.map +1 -1
  156. package/build/cjs/prod/durableobject.js +290 -163
  157. package/build/cjs/prod/durableobject.js.map +1 -1
  158. package/build/cjs/prod/flush.js +104 -77
  159. package/build/cjs/prod/flush.js.map +1 -1
  160. package/build/cjs/prod/index.js +181 -182
  161. package/build/cjs/prod/instrument.js +53 -39
  162. package/build/cjs/prod/instrument.js.map +1 -1
  163. package/build/cjs/prod/instrumentations/agents/index.js +34 -13
  164. package/build/cjs/prod/instrumentations/agents/index.js.map +1 -1
  165. package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js +46 -49
  166. package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  167. package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js +23 -16
  168. package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
  169. package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js +36 -28
  170. package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
  171. package/build/cjs/prod/instrumentations/agents/types.js +103 -58
  172. package/build/cjs/prod/instrumentations/agents/types.js.map +1 -1
  173. package/build/cjs/prod/instrumentations/instrumentDurableObjectHandlers.js +87 -118
  174. package/build/cjs/prod/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
  175. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js +46 -44
  176. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  177. package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js +70 -71
  178. package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  179. package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -39
  180. package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  181. package/build/cjs/prod/instrumentations/instrumentSqlStorage.js +50 -52
  182. package/build/cjs/prod/instrumentations/instrumentSqlStorage.js.map +1 -1
  183. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js +136 -123
  184. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  185. package/build/cjs/prod/instrumentations/worker/instrumentD1.js +131 -146
  186. package/build/cjs/prod/instrumentations/worker/instrumentD1.js.map +1 -1
  187. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js +63 -61
  188. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js.map +1 -1
  189. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js +83 -87
  190. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js.map +1 -1
  191. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js +41 -48
  192. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js.map +1 -1
  193. package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js +25 -21
  194. package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js.map +1 -1
  195. package/build/cjs/prod/instrumentations/worker/instrumentKV.js +54 -67
  196. package/build/cjs/prod/instrumentations/worker/instrumentKV.js.map +1 -1
  197. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js +100 -76
  198. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js.map +1 -1
  199. package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js +91 -75
  200. package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  201. package/build/cjs/prod/instrumentations/worker/instrumentR2.js +128 -115
  202. package/build/cjs/prod/instrumentations/worker/instrumentR2.js.map +1 -1
  203. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js +90 -94
  204. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js.map +1 -1
  205. package/build/cjs/prod/instrumentations/worker/instrumentTail.js +100 -55
  206. package/build/cjs/prod/instrumentations/worker/instrumentTail.js.map +1 -1
  207. package/build/cjs/prod/integrations/cronTriggers.js +130 -85
  208. package/build/cjs/prod/integrations/cronTriggers.js.map +1 -1
  209. package/build/cjs/prod/integrations/fetch.js +9 -9
  210. package/build/cjs/prod/integrations/fetch.js.map +1 -1
  211. package/build/cjs/prod/integrations/httpServer.js +41 -22
  212. package/build/cjs/prod/integrations/httpServer.js.map +1 -1
  213. package/build/cjs/prod/integrations/spotlight.js +52 -55
  214. package/build/cjs/prod/integrations/spotlight.js.map +1 -1
  215. package/build/cjs/prod/opentelemetry/tracer.js +10 -8
  216. package/build/cjs/prod/opentelemetry/tracer.js.map +1 -1
  217. package/build/cjs/prod/options.js +37 -24
  218. package/build/cjs/prod/options.js.map +1 -1
  219. package/build/cjs/prod/orchestrion-deferred-channels.js +45 -29
  220. package/build/cjs/prod/orchestrion-deferred-channels.js.map +1 -1
  221. package/build/cjs/prod/orchestrion-diagnostics-channel.js +97 -72
  222. package/build/cjs/prod/orchestrion-diagnostics-channel.js.map +1 -1
  223. package/build/cjs/prod/pages-plugin.js +20 -21
  224. package/build/cjs/prod/pages-plugin.js.map +1 -1
  225. package/build/cjs/prod/request.js +16 -10
  226. package/build/cjs/prod/request.js.map +1 -1
  227. package/build/cjs/prod/scope-utils.js +12 -12
  228. package/build/cjs/prod/scope-utils.js.map +1 -1
  229. package/build/cjs/prod/sdk.js +24 -15
  230. package/build/cjs/prod/sdk.js.map +1 -1
  231. package/build/cjs/prod/transport.js +93 -86
  232. package/build/cjs/prod/transport.js.map +1 -1
  233. package/build/cjs/prod/utils/asyncContextStrategy.js +10 -10
  234. package/build/cjs/prod/utils/asyncContextStrategy.js.map +1 -1
  235. package/build/cjs/prod/utils/bindingPropagation.js +24 -0
  236. package/build/cjs/prod/utils/bindingPropagation.js.map +1 -0
  237. package/build/cjs/prod/utils/cloudflareTrace.js +34 -0
  238. package/build/cjs/prod/utils/cloudflareTrace.js.map +1 -0
  239. package/build/cjs/prod/utils/instrumentContext.js +74 -58
  240. package/build/cjs/prod/utils/instrumentContext.js.map +1 -1
  241. package/build/cjs/prod/utils/internalSqlQuery.js +38 -21
  242. package/build/cjs/prod/utils/internalSqlQuery.js.map +1 -1
  243. package/build/cjs/prod/utils/internalStorageKey.js +41 -38
  244. package/build/cjs/prod/utils/internalStorageKey.js.map +1 -1
  245. package/build/cjs/prod/utils/invocationContext.js +42 -32
  246. package/build/cjs/prod/utils/invocationContext.js.map +1 -1
  247. package/build/cjs/prod/utils/invocationScope.js +45 -21
  248. package/build/cjs/prod/utils/invocationScope.js.map +1 -1
  249. package/build/cjs/prod/utils/isBinding.js +47 -15
  250. package/build/cjs/prod/utils/isBinding.js.map +1 -1
  251. package/build/cjs/prod/utils/isCloudflareClass.js +11 -20
  252. package/build/cjs/prod/utils/isCloudflareClass.js.map +1 -1
  253. package/build/cjs/prod/utils/queueTraceMeta.js +33 -0
  254. package/build/cjs/prod/utils/queueTraceMeta.js.map +1 -0
  255. package/build/cjs/prod/utils/rpcMeta.js +37 -27
  256. package/build/cjs/prod/utils/rpcMeta.js.map +1 -1
  257. package/build/cjs/prod/utils/traceLinks.js +52 -42
  258. package/build/cjs/prod/utils/traceLinks.js.map +1 -1
  259. package/build/cjs/prod/vendor/stacktrace.js +32 -24
  260. package/build/cjs/prod/vendor/stacktrace.js.map +1 -1
  261. package/build/cjs/prod/vite/agentClass.js +105 -98
  262. package/build/cjs/prod/vite/agentClass.js.map +1 -1
  263. package/build/cjs/prod/vite/autoInstrument.js +121 -122
  264. package/build/cjs/prod/vite/autoInstrument.js.map +1 -1
  265. package/build/cjs/prod/vite/index.js +44 -21
  266. package/build/cjs/prod/vite/index.js.map +1 -1
  267. package/build/cjs/prod/vite/instrumentFile.js +37 -20
  268. package/build/cjs/prod/vite/instrumentFile.js.map +1 -1
  269. package/build/cjs/prod/vite/mastraObservability.js +19 -12
  270. package/build/cjs/prod/vite/mastraObservability.js.map +1 -1
  271. package/build/cjs/prod/vite/moduleShape.js +220 -201
  272. package/build/cjs/prod/vite/moduleShape.js.map +1 -1
  273. package/build/cjs/prod/vite/providedModulePlugin.js +62 -45
  274. package/build/cjs/prod/vite/providedModulePlugin.js.map +1 -1
  275. package/build/cjs/prod/vite/transform.js +333 -284
  276. package/build/cjs/prod/vite/transform.js.map +1 -1
  277. package/build/cjs/prod/vite/workerEntrypoint.js +66 -57
  278. package/build/cjs/prod/vite/workerEntrypoint.js.map +1 -1
  279. package/build/cjs/prod/vite/wranglerConfig.js +92 -67
  280. package/build/cjs/prod/vite/wranglerConfig.js.map +1 -1
  281. package/build/cjs/prod/withSentry.js +32 -26
  282. package/build/cjs/prod/withSentry.js.map +1 -1
  283. package/build/cjs/prod/workflows.js +165 -149
  284. package/build/cjs/prod/workflows.js.map +1 -1
  285. package/build/cjs/prod/wrapMethodWithSentry.js +148 -169
  286. package/build/cjs/prod/wrapMethodWithSentry.js.map +1 -1
  287. package/build/cjs/prod/wrapRequestHandlerWithInit.js +78 -72
  288. package/build/cjs/prod/wrapRequestHandlerWithInit.js.map +1 -1
  289. package/build/esm/dev/baseSdk.js +98 -101
  290. package/build/esm/dev/baseSdk.js.map +1 -1
  291. package/build/esm/dev/client.js +213 -235
  292. package/build/esm/dev/client.js.map +1 -1
  293. package/build/esm/dev/clientCache.js +8 -6
  294. package/build/esm/dev/clientCache.js.map +1 -1
  295. package/build/esm/dev/debug-build.js +9 -3
  296. package/build/esm/dev/debug-build.js.map +1 -1
  297. package/build/esm/dev/defineCloudflareOptions.js +5 -6
  298. package/build/esm/dev/defineCloudflareOptions.js.map +1 -1
  299. package/build/esm/dev/durableobject.js +290 -161
  300. package/build/esm/dev/durableobject.js.map +1 -1
  301. package/build/esm/dev/flush.js +104 -75
  302. package/build/esm/dev/flush.js.map +1 -1
  303. package/build/esm/dev/index.js +19 -18
  304. package/build/esm/dev/instrument.js +53 -37
  305. package/build/esm/dev/instrument.js.map +1 -1
  306. package/build/esm/dev/instrumentations/agents/index.js +34 -11
  307. package/build/esm/dev/instrumentations/agents/index.js.map +1 -1
  308. package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js +46 -47
  309. package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  310. package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js +23 -14
  311. package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
  312. package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js +36 -26
  313. package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
  314. package/build/esm/dev/instrumentations/agents/types.js +103 -56
  315. package/build/esm/dev/instrumentations/agents/types.js.map +1 -1
  316. package/build/esm/dev/instrumentations/instrumentDurableObjectHandlers.js +87 -116
  317. package/build/esm/dev/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
  318. package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js +46 -42
  319. package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  320. package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js +70 -69
  321. package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  322. package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -37
  323. package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  324. package/build/esm/dev/instrumentations/instrumentSqlStorage.js +50 -50
  325. package/build/esm/dev/instrumentations/instrumentSqlStorage.js.map +1 -1
  326. package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js +136 -121
  327. package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  328. package/build/esm/dev/instrumentations/worker/instrumentD1.js +131 -144
  329. package/build/esm/dev/instrumentations/worker/instrumentD1.js.map +1 -1
  330. package/build/esm/dev/instrumentations/worker/instrumentEmail.js +63 -59
  331. package/build/esm/dev/instrumentations/worker/instrumentEmail.js.map +1 -1
  332. package/build/esm/dev/instrumentations/worker/instrumentEnv.js +83 -85
  333. package/build/esm/dev/instrumentations/worker/instrumentEnv.js.map +1 -1
  334. package/build/esm/dev/instrumentations/worker/instrumentFetch.js +41 -46
  335. package/build/esm/dev/instrumentations/worker/instrumentFetch.js.map +1 -1
  336. package/build/esm/dev/instrumentations/worker/instrumentFetcher.js +25 -19
  337. package/build/esm/dev/instrumentations/worker/instrumentFetcher.js.map +1 -1
  338. package/build/esm/dev/instrumentations/worker/instrumentKV.js +54 -65
  339. package/build/esm/dev/instrumentations/worker/instrumentKV.js.map +1 -1
  340. package/build/esm/dev/instrumentations/worker/instrumentQueue.js +100 -74
  341. package/build/esm/dev/instrumentations/worker/instrumentQueue.js.map +1 -1
  342. package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js +91 -73
  343. package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  344. package/build/esm/dev/instrumentations/worker/instrumentR2.js +128 -113
  345. package/build/esm/dev/instrumentations/worker/instrumentR2.js.map +1 -1
  346. package/build/esm/dev/instrumentations/worker/instrumentScheduled.js +90 -92
  347. package/build/esm/dev/instrumentations/worker/instrumentScheduled.js.map +1 -1
  348. package/build/esm/dev/instrumentations/worker/instrumentTail.js +100 -53
  349. package/build/esm/dev/instrumentations/worker/instrumentTail.js.map +1 -1
  350. package/build/esm/dev/integrations/cronTriggers.js +129 -82
  351. package/build/esm/dev/integrations/cronTriggers.js.map +1 -1
  352. package/build/esm/dev/integrations/fetch.js +9 -6
  353. package/build/esm/dev/integrations/fetch.js.map +1 -1
  354. package/build/esm/dev/integrations/httpServer.js +40 -19
  355. package/build/esm/dev/integrations/httpServer.js.map +1 -1
  356. package/build/esm/dev/integrations/spotlight.js +51 -52
  357. package/build/esm/dev/integrations/spotlight.js.map +1 -1
  358. package/build/esm/dev/opentelemetry/tracer.js +10 -6
  359. package/build/esm/dev/opentelemetry/tracer.js.map +1 -1
  360. package/build/esm/dev/options.js +55 -37
  361. package/build/esm/dev/options.js.map +1 -1
  362. package/build/esm/dev/orchestrion-deferred-channels.js +45 -27
  363. package/build/esm/dev/orchestrion-deferred-channels.js.map +1 -1
  364. package/build/esm/dev/orchestrion-diagnostics-channel.js +87 -66
  365. package/build/esm/dev/orchestrion-diagnostics-channel.js.map +1 -1
  366. package/build/esm/dev/package.json +1 -1
  367. package/build/esm/dev/pages-plugin.js +20 -19
  368. package/build/esm/dev/pages-plugin.js.map +1 -1
  369. package/build/esm/dev/request.js +14 -7
  370. package/build/esm/dev/request.js.map +1 -1
  371. package/build/esm/dev/scope-utils.js +12 -10
  372. package/build/esm/dev/scope-utils.js.map +1 -1
  373. package/build/esm/dev/sdk.js +23 -13
  374. package/build/esm/dev/sdk.js.map +1 -1
  375. package/build/esm/dev/transport.js +93 -84
  376. package/build/esm/dev/transport.js.map +1 -1
  377. package/build/esm/dev/utils/asyncContextStrategy.js +10 -8
  378. package/build/esm/dev/utils/asyncContextStrategy.js.map +1 -1
  379. package/build/esm/dev/utils/bindingPropagation.js +23 -0
  380. package/build/esm/dev/utils/bindingPropagation.js.map +1 -0
  381. package/build/esm/dev/utils/cloudflareTrace.js +34 -0
  382. package/build/esm/dev/utils/cloudflareTrace.js.map +1 -0
  383. package/build/esm/dev/utils/instrumentContext.js +74 -56
  384. package/build/esm/dev/utils/instrumentContext.js.map +1 -1
  385. package/build/esm/dev/utils/internalSqlQuery.js +38 -19
  386. package/build/esm/dev/utils/internalSqlQuery.js.map +1 -1
  387. package/build/esm/dev/utils/internalStorageKey.js +41 -36
  388. package/build/esm/dev/utils/internalStorageKey.js.map +1 -1
  389. package/build/esm/dev/utils/invocationContext.js +42 -30
  390. package/build/esm/dev/utils/invocationContext.js.map +1 -1
  391. package/build/esm/dev/utils/invocationScope.js +45 -19
  392. package/build/esm/dev/utils/invocationScope.js.map +1 -1
  393. package/build/esm/dev/utils/isBinding.js +47 -13
  394. package/build/esm/dev/utils/isBinding.js.map +1 -1
  395. package/build/esm/dev/utils/isCloudflareClass.js +11 -18
  396. package/build/esm/dev/utils/isCloudflareClass.js.map +1 -1
  397. package/build/esm/dev/utils/queueTraceMeta.js +32 -0
  398. package/build/esm/dev/utils/queueTraceMeta.js.map +1 -0
  399. package/build/esm/dev/utils/rpcMeta.js +37 -25
  400. package/build/esm/dev/utils/rpcMeta.js.map +1 -1
  401. package/build/esm/dev/utils/traceLinks.js +52 -40
  402. package/build/esm/dev/utils/traceLinks.js.map +1 -1
  403. package/build/esm/dev/vendor/stacktrace.js +31 -21
  404. package/build/esm/dev/vendor/stacktrace.js.map +1 -1
  405. package/build/esm/dev/vite/agentClass.js +105 -96
  406. package/build/esm/dev/vite/agentClass.js.map +1 -1
  407. package/build/esm/dev/vite/autoInstrument.js +121 -120
  408. package/build/esm/dev/vite/autoInstrument.js.map +1 -1
  409. package/build/esm/dev/vite/index.js +43 -19
  410. package/build/esm/dev/vite/index.js.map +1 -1
  411. package/build/esm/dev/vite/instrumentFile.js +37 -18
  412. package/build/esm/dev/vite/instrumentFile.js.map +1 -1
  413. package/build/esm/dev/vite/mastraObservability.js +19 -10
  414. package/build/esm/dev/vite/mastraObservability.js.map +1 -1
  415. package/build/esm/dev/vite/moduleShape.js +220 -199
  416. package/build/esm/dev/vite/moduleShape.js.map +1 -1
  417. package/build/esm/dev/vite/providedModulePlugin.js +60 -43
  418. package/build/esm/dev/vite/providedModulePlugin.js.map +1 -1
  419. package/build/esm/dev/vite/transform.js +331 -282
  420. package/build/esm/dev/vite/transform.js.map +1 -1
  421. package/build/esm/dev/vite/workerEntrypoint.js +66 -55
  422. package/build/esm/dev/vite/workerEntrypoint.js.map +1 -1
  423. package/build/esm/dev/vite/wranglerConfig.js +92 -65
  424. package/build/esm/dev/vite/wranglerConfig.js.map +1 -1
  425. package/build/esm/dev/withSentry.js +32 -24
  426. package/build/esm/dev/withSentry.js.map +1 -1
  427. package/build/esm/dev/workflows.js +165 -147
  428. package/build/esm/dev/workflows.js.map +1 -1
  429. package/build/esm/dev/wrapMethodWithSentry.js +148 -167
  430. package/build/esm/dev/wrapMethodWithSentry.js.map +1 -1
  431. package/build/esm/dev/wrapRequestHandlerWithInit.js +78 -70
  432. package/build/esm/dev/wrapRequestHandlerWithInit.js.map +1 -1
  433. package/build/esm/prod/baseSdk.js +94 -91
  434. package/build/esm/prod/baseSdk.js.map +1 -1
  435. package/build/esm/prod/client.js +213 -235
  436. package/build/esm/prod/client.js.map +1 -1
  437. package/build/esm/prod/clientCache.js +8 -6
  438. package/build/esm/prod/clientCache.js.map +1 -1
  439. package/build/esm/prod/debug-build.js +9 -3
  440. package/build/esm/prod/debug-build.js.map +1 -1
  441. package/build/esm/prod/defineCloudflareOptions.js +5 -6
  442. package/build/esm/prod/defineCloudflareOptions.js.map +1 -1
  443. package/build/esm/prod/durableobject.js +290 -161
  444. package/build/esm/prod/durableobject.js.map +1 -1
  445. package/build/esm/prod/flush.js +104 -75
  446. package/build/esm/prod/flush.js.map +1 -1
  447. package/build/esm/prod/index.js +19 -18
  448. package/build/esm/prod/instrument.js +53 -37
  449. package/build/esm/prod/instrument.js.map +1 -1
  450. package/build/esm/prod/instrumentations/agents/index.js +34 -11
  451. package/build/esm/prod/instrumentations/agents/index.js.map +1 -1
  452. package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js +46 -47
  453. package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  454. package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js +23 -14
  455. package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
  456. package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js +36 -26
  457. package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
  458. package/build/esm/prod/instrumentations/agents/types.js +103 -56
  459. package/build/esm/prod/instrumentations/agents/types.js.map +1 -1
  460. package/build/esm/prod/instrumentations/instrumentDurableObjectHandlers.js +87 -116
  461. package/build/esm/prod/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
  462. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js +46 -42
  463. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  464. package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js +70 -69
  465. package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  466. package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -37
  467. package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  468. package/build/esm/prod/instrumentations/instrumentSqlStorage.js +50 -50
  469. package/build/esm/prod/instrumentations/instrumentSqlStorage.js.map +1 -1
  470. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js +136 -121
  471. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  472. package/build/esm/prod/instrumentations/worker/instrumentD1.js +131 -144
  473. package/build/esm/prod/instrumentations/worker/instrumentD1.js.map +1 -1
  474. package/build/esm/prod/instrumentations/worker/instrumentEmail.js +63 -59
  475. package/build/esm/prod/instrumentations/worker/instrumentEmail.js.map +1 -1
  476. package/build/esm/prod/instrumentations/worker/instrumentEnv.js +83 -85
  477. package/build/esm/prod/instrumentations/worker/instrumentEnv.js.map +1 -1
  478. package/build/esm/prod/instrumentations/worker/instrumentFetch.js +41 -46
  479. package/build/esm/prod/instrumentations/worker/instrumentFetch.js.map +1 -1
  480. package/build/esm/prod/instrumentations/worker/instrumentFetcher.js +25 -19
  481. package/build/esm/prod/instrumentations/worker/instrumentFetcher.js.map +1 -1
  482. package/build/esm/prod/instrumentations/worker/instrumentKV.js +54 -65
  483. package/build/esm/prod/instrumentations/worker/instrumentKV.js.map +1 -1
  484. package/build/esm/prod/instrumentations/worker/instrumentQueue.js +100 -74
  485. package/build/esm/prod/instrumentations/worker/instrumentQueue.js.map +1 -1
  486. package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js +91 -73
  487. package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  488. package/build/esm/prod/instrumentations/worker/instrumentR2.js +128 -113
  489. package/build/esm/prod/instrumentations/worker/instrumentR2.js.map +1 -1
  490. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js +90 -92
  491. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js.map +1 -1
  492. package/build/esm/prod/instrumentations/worker/instrumentTail.js +100 -53
  493. package/build/esm/prod/instrumentations/worker/instrumentTail.js.map +1 -1
  494. package/build/esm/prod/integrations/cronTriggers.js +129 -82
  495. package/build/esm/prod/integrations/cronTriggers.js.map +1 -1
  496. package/build/esm/prod/integrations/fetch.js +9 -6
  497. package/build/esm/prod/integrations/fetch.js.map +1 -1
  498. package/build/esm/prod/integrations/httpServer.js +40 -19
  499. package/build/esm/prod/integrations/httpServer.js.map +1 -1
  500. package/build/esm/prod/integrations/spotlight.js +51 -52
  501. package/build/esm/prod/integrations/spotlight.js.map +1 -1
  502. package/build/esm/prod/opentelemetry/tracer.js +10 -6
  503. package/build/esm/prod/opentelemetry/tracer.js.map +1 -1
  504. package/build/esm/prod/options.js +37 -22
  505. package/build/esm/prod/options.js.map +1 -1
  506. package/build/esm/prod/orchestrion-deferred-channels.js +45 -27
  507. package/build/esm/prod/orchestrion-deferred-channels.js.map +1 -1
  508. package/build/esm/prod/orchestrion-diagnostics-channel.js +87 -66
  509. package/build/esm/prod/orchestrion-diagnostics-channel.js.map +1 -1
  510. package/build/esm/prod/package.json +1 -1
  511. package/build/esm/prod/pages-plugin.js +20 -19
  512. package/build/esm/prod/pages-plugin.js.map +1 -1
  513. package/build/esm/prod/request.js +14 -7
  514. package/build/esm/prod/request.js.map +1 -1
  515. package/build/esm/prod/scope-utils.js +12 -10
  516. package/build/esm/prod/scope-utils.js.map +1 -1
  517. package/build/esm/prod/sdk.js +23 -13
  518. package/build/esm/prod/sdk.js.map +1 -1
  519. package/build/esm/prod/transport.js +93 -84
  520. package/build/esm/prod/transport.js.map +1 -1
  521. package/build/esm/prod/utils/asyncContextStrategy.js +10 -8
  522. package/build/esm/prod/utils/asyncContextStrategy.js.map +1 -1
  523. package/build/esm/prod/utils/bindingPropagation.js +23 -0
  524. package/build/esm/prod/utils/bindingPropagation.js.map +1 -0
  525. package/build/esm/prod/utils/cloudflareTrace.js +34 -0
  526. package/build/esm/prod/utils/cloudflareTrace.js.map +1 -0
  527. package/build/esm/prod/utils/instrumentContext.js +74 -56
  528. package/build/esm/prod/utils/instrumentContext.js.map +1 -1
  529. package/build/esm/prod/utils/internalSqlQuery.js +38 -19
  530. package/build/esm/prod/utils/internalSqlQuery.js.map +1 -1
  531. package/build/esm/prod/utils/internalStorageKey.js +41 -36
  532. package/build/esm/prod/utils/internalStorageKey.js.map +1 -1
  533. package/build/esm/prod/utils/invocationContext.js +42 -30
  534. package/build/esm/prod/utils/invocationContext.js.map +1 -1
  535. package/build/esm/prod/utils/invocationScope.js +45 -19
  536. package/build/esm/prod/utils/invocationScope.js.map +1 -1
  537. package/build/esm/prod/utils/isBinding.js +47 -13
  538. package/build/esm/prod/utils/isBinding.js.map +1 -1
  539. package/build/esm/prod/utils/isCloudflareClass.js +11 -18
  540. package/build/esm/prod/utils/isCloudflareClass.js.map +1 -1
  541. package/build/esm/prod/utils/queueTraceMeta.js +32 -0
  542. package/build/esm/prod/utils/queueTraceMeta.js.map +1 -0
  543. package/build/esm/prod/utils/rpcMeta.js +37 -25
  544. package/build/esm/prod/utils/rpcMeta.js.map +1 -1
  545. package/build/esm/prod/utils/traceLinks.js +52 -40
  546. package/build/esm/prod/utils/traceLinks.js.map +1 -1
  547. package/build/esm/prod/vendor/stacktrace.js +31 -21
  548. package/build/esm/prod/vendor/stacktrace.js.map +1 -1
  549. package/build/esm/prod/vite/agentClass.js +105 -96
  550. package/build/esm/prod/vite/agentClass.js.map +1 -1
  551. package/build/esm/prod/vite/autoInstrument.js +121 -120
  552. package/build/esm/prod/vite/autoInstrument.js.map +1 -1
  553. package/build/esm/prod/vite/index.js +43 -19
  554. package/build/esm/prod/vite/index.js.map +1 -1
  555. package/build/esm/prod/vite/instrumentFile.js +37 -18
  556. package/build/esm/prod/vite/instrumentFile.js.map +1 -1
  557. package/build/esm/prod/vite/mastraObservability.js +19 -10
  558. package/build/esm/prod/vite/mastraObservability.js.map +1 -1
  559. package/build/esm/prod/vite/moduleShape.js +220 -199
  560. package/build/esm/prod/vite/moduleShape.js.map +1 -1
  561. package/build/esm/prod/vite/providedModulePlugin.js +60 -43
  562. package/build/esm/prod/vite/providedModulePlugin.js.map +1 -1
  563. package/build/esm/prod/vite/transform.js +331 -282
  564. package/build/esm/prod/vite/transform.js.map +1 -1
  565. package/build/esm/prod/vite/workerEntrypoint.js +66 -55
  566. package/build/esm/prod/vite/workerEntrypoint.js.map +1 -1
  567. package/build/esm/prod/vite/wranglerConfig.js +92 -65
  568. package/build/esm/prod/vite/wranglerConfig.js.map +1 -1
  569. package/build/esm/prod/withSentry.js +32 -24
  570. package/build/esm/prod/withSentry.js.map +1 -1
  571. package/build/esm/prod/workflows.js +165 -147
  572. package/build/esm/prod/workflows.js.map +1 -1
  573. package/build/esm/prod/wrapMethodWithSentry.js +148 -167
  574. package/build/esm/prod/wrapMethodWithSentry.js.map +1 -1
  575. package/build/esm/prod/wrapRequestHandlerWithInit.js +78 -70
  576. package/build/esm/prod/wrapRequestHandlerWithInit.js.map +1 -1
  577. package/build/types/client.d.ts +32 -1
  578. package/build/types/client.d.ts.map +1 -1
  579. package/build/types/durableobject.d.ts.map +1 -1
  580. package/build/types/index.d.ts +3 -2
  581. package/build/types/index.d.ts.map +1 -1
  582. package/build/types/instrumentations/worker/instrumentEmail.d.ts.map +1 -1
  583. package/build/types/instrumentations/worker/instrumentEnv.d.ts +1 -1
  584. package/build/types/instrumentations/worker/instrumentEnv.d.ts.map +1 -1
  585. package/build/types/instrumentations/worker/instrumentFetcher.d.ts.map +1 -1
  586. package/build/types/instrumentations/worker/instrumentQueue.d.ts.map +1 -1
  587. package/build/types/instrumentations/worker/instrumentQueueProducer.d.ts +1 -1
  588. package/build/types/instrumentations/worker/instrumentQueueProducer.d.ts.map +1 -1
  589. package/build/types/instrumentations/worker/instrumentScheduled.d.ts.map +1 -1
  590. package/build/types/instrumentations/worker/instrumentTail.d.ts +4 -2
  591. package/build/types/instrumentations/worker/instrumentTail.d.ts.map +1 -1
  592. package/build/types/utils/{rpcPropagation.d.ts → bindingPropagation.d.ts} +6 -1
  593. package/build/types/utils/bindingPropagation.d.ts.map +1 -0
  594. package/build/types/utils/cloudflareTrace.d.ts +13 -0
  595. package/build/types/utils/cloudflareTrace.d.ts.map +1 -0
  596. package/build/types/utils/queueTraceMeta.d.ts +7 -0
  597. package/build/types/utils/queueTraceMeta.d.ts.map +1 -0
  598. package/build/types/vite/autoInstrument.d.ts.map +1 -1
  599. package/build/types/vite/index.d.ts.map +1 -1
  600. package/build/types/vite/providedModulePlugin.d.ts +15 -11
  601. package/build/types/vite/providedModulePlugin.d.ts.map +1 -1
  602. package/build/types/workflows.d.ts.map +1 -1
  603. package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
  604. package/build/types/wrapRequestHandlerWithInit.d.ts.map +1 -1
  605. package/package.json +20 -21
  606. package/build/cjs/dev/index.js.map +0 -1
  607. package/build/cjs/dev/utils/rpcPropagation.js +0 -15
  608. package/build/cjs/dev/utils/rpcPropagation.js.map +0 -1
  609. package/build/cjs/dev/vite/flueRuntime.js +0 -15
  610. package/build/cjs/dev/vite/flueRuntime.js.map +0 -1
  611. package/build/cjs/prod/index.js.map +0 -1
  612. package/build/cjs/prod/utils/rpcPropagation.js +0 -15
  613. package/build/cjs/prod/utils/rpcPropagation.js.map +0 -1
  614. package/build/cjs/prod/vite/flueRuntime.js +0 -15
  615. package/build/cjs/prod/vite/flueRuntime.js.map +0 -1
  616. package/build/esm/dev/index.js.map +0 -1
  617. package/build/esm/dev/utils/rpcPropagation.js +0 -13
  618. package/build/esm/dev/utils/rpcPropagation.js.map +0 -1
  619. package/build/esm/dev/vite/flueRuntime.js +0 -13
  620. package/build/esm/dev/vite/flueRuntime.js.map +0 -1
  621. package/build/esm/prod/index.js.map +0 -1
  622. package/build/esm/prod/utils/rpcPropagation.js +0 -13
  623. package/build/esm/prod/utils/rpcPropagation.js.map +0 -1
  624. package/build/esm/prod/vite/flueRuntime.js +0 -13
  625. package/build/esm/prod/vite/flueRuntime.js.map +0 -1
  626. package/build/types/utils/rpcPropagation.d.ts.map +0 -1
  627. package/build/types/vite/flueRuntime.d.ts +0 -12
  628. package/build/types/vite/flueRuntime.d.ts.map +0 -1
@@ -1,12 +1,14 @@
1
- import { GLOBAL_OBJ } from '@sentry/core';
2
-
1
+ import { GLOBAL_OBJ } from "@sentry/core";
2
+ // src/clientCache.ts
3
3
  const GLOBAL_CLIENT_KEY = "__SENTRY_CLOUDFLARE_CLIENT__";
4
+ /** Returns the one cached Cloudflare client for this isolate. */
4
5
  function getCachedClient() {
5
- return GLOBAL_OBJ[GLOBAL_CLIENT_KEY];
6
+ return GLOBAL_OBJ[GLOBAL_CLIENT_KEY];
6
7
  }
8
+ /** Stores the one Cloudflare client reused by every invocation in this isolate. */
7
9
  function cacheClient(client) {
8
- GLOBAL_OBJ[GLOBAL_CLIENT_KEY] = client;
10
+ GLOBAL_OBJ[GLOBAL_CLIENT_KEY] = client;
9
11
  }
10
-
11
12
  export { cacheClient, getCachedClient };
12
- //# sourceMappingURL=clientCache.js.map
13
+
14
+ //# sourceMappingURL=clientCache.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"clientCache.js","sources":["../../../src/clientCache.ts"],"sourcesContent":["import { GLOBAL_OBJ } from '@sentry/core';\nimport type { CloudflareClient } from './client';\n\nconst GLOBAL_CLIENT_KEY = '__SENTRY_CLOUDFLARE_CLIENT__' as const;\n\ntype GlobalWithCloudflareClient = typeof GLOBAL_OBJ & {\n [GLOBAL_CLIENT_KEY]?: CloudflareClient;\n};\n\n/** Returns the one cached Cloudflare client for this isolate. */\nexport function getCachedClient(): CloudflareClient | undefined {\n return (GLOBAL_OBJ as GlobalWithCloudflareClient)[GLOBAL_CLIENT_KEY];\n}\n\n/** Stores the one Cloudflare client reused by every invocation in this isolate. */\nexport function cacheClient(client: CloudflareClient): void {\n (GLOBAL_OBJ as GlobalWithCloudflareClient)[GLOBAL_CLIENT_KEY] = client;\n}\n\n/** @hidden Only for testing - clears the isolate's cached Cloudflare client. */\nexport function _clearGlobalClientCache(): void {\n (GLOBAL_OBJ as GlobalWithCloudflareClient)[GLOBAL_CLIENT_KEY] = undefined;\n}\n"],"names":[],"mappings":";;AAGA,MAAM,iBAAA,GAAoB,8BAAA;AAOnB,SAAS,eAAA,GAAgD;AAC9D,EAAA,OAAQ,WAA0C,iBAAiB,CAAA;AACrE;AAGO,SAAS,YAAY,MAAA,EAAgC;AAC1D,EAAC,UAAA,CAA0C,iBAAiB,CAAA,GAAI,MAAA;AAClE;;;;"}
1
+ {"version":3,"file":"clientCache.js","names":[],"sources":["../../../src/clientCache.ts"],"sourcesContent":["import { GLOBAL_OBJ } from '@sentry/core';\nimport type { CloudflareClient } from './client';\n\nconst GLOBAL_CLIENT_KEY = '__SENTRY_CLOUDFLARE_CLIENT__' as const;\n\ntype GlobalWithCloudflareClient = typeof GLOBAL_OBJ & {\n [GLOBAL_CLIENT_KEY]?: CloudflareClient;\n};\n\n/** Returns the one cached Cloudflare client for this isolate. */\nexport function getCachedClient(): CloudflareClient | undefined {\n return (GLOBAL_OBJ as GlobalWithCloudflareClient)[GLOBAL_CLIENT_KEY];\n}\n\n/** Stores the one Cloudflare client reused by every invocation in this isolate. */\nexport function cacheClient(client: CloudflareClient): void {\n (GLOBAL_OBJ as GlobalWithCloudflareClient)[GLOBAL_CLIENT_KEY] = client;\n}\n\n/** @hidden Only for testing - clears the isolate's cached Cloudflare client. */\nexport function _clearGlobalClientCache(): void {\n (GLOBAL_OBJ as GlobalWithCloudflareClient)[GLOBAL_CLIENT_KEY] = undefined;\n}\n"],"mappings":";;AAGA,MAAM,oBAAoB;;AAO1B,SAAgB,kBAAgD;CAC9D,OAAQ,WAA0C;AACpD;;AAGA,SAAgB,YAAY,QAAgC;CACzD,WAA0C,qBAAqB;AAClE"}
@@ -1,4 +1,10 @@
1
- const DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);
2
-
1
+ // src/debug-build.ts
2
+ /**
3
+ * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.
4
+ *
5
+ * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.
6
+ */
7
+ const DEBUG_BUILD = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
3
8
  export { DEBUG_BUILD };
4
- //# sourceMappingURL=debug-build.js.map
9
+
10
+ //# sourceMappingURL=debug-build.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"debug-build.js","sources":["../../../src/debug-build.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n"],"names":[],"mappings":"AAOO,MAAM,WAAA,IAAc,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA;;;;"}
1
+ {"version":3,"file":"debug-build.js","names":[],"sources":["../../../src/debug-build.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n"],"mappings":";;;;;;AAOA,MAAa,cAAe,OAAO,qBAAqB,eAAe"}
@@ -1,9 +1,8 @@
1
+ // src/defineCloudflareOptions.ts
1
2
  function defineCloudflareOptions(optionsOrCallback) {
2
- if (typeof optionsOrCallback === "function") {
3
- return optionsOrCallback;
4
- }
5
- return () => optionsOrCallback;
3
+ if (typeof optionsOrCallback === "function") return optionsOrCallback;
4
+ return () => optionsOrCallback;
6
5
  }
7
-
8
6
  export { defineCloudflareOptions };
9
- //# sourceMappingURL=defineCloudflareOptions.js.map
7
+
8
+ //# sourceMappingURL=defineCloudflareOptions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defineCloudflareOptions.js","sources":["../../../src/defineCloudflareOptions.ts"],"sourcesContent":["import type { CloudflareOptions } from './client';\nimport type { DefaultEnv, StrictCloudflareOptions } from './types';\n\n/**\n * Define the Sentry options for a Cloudflare Worker in a dedicated module.\n *\n * This is the recommended way to configure the SDK when using the Vite plugin's\n * auto-instrumentation: place an `instrument.server.{ts,js,mjs}` file next to\n * the worker entry whose **default export** is the result of this function. The\n * plugin picks it up automatically and hands it to `withSentry`.\n *\n * Unlike Node's `Sentry.init(...)`, the options cannot be applied at module\n * load time on Cloudflare: the DSN and other settings typically come from the\n * per-request `env`, which only exists inside the handler. Pass a callback to\n * read from `env`, or a static object when no `env` access is needed — either\n * way you get full type-checking and autocomplete on {@link CloudflareOptions}.\n *\n * At runtime this is a thin pass-through; it only normalizes a static object\n * into a callback so the plugin always imports a `(env) => options` function.\n *\n * @example\n * ```ts\n * // src/instrument.server.ts\n * import { defineCloudflareOptions } from '@sentry/cloudflare';\n *\n * export default defineCloudflareOptions((env) => ({\n * dsn: env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * }));\n * ```\n *\n * @example\n * ```ts\n * // Static options — no `env` access needed\n * export default defineCloudflareOptions({ tracesSampleRate: 1.0 });\n * ```\n */\n// Overloads rather than a union parameter: TypeScript does not infer `O` out of a union member,\n// so a union signature falls back to the default and the unknown-key check never runs. The object\n// overload stays on plain `CloudflareOptions` — a direct object literal is still excess property\n// checked, and a callback cannot match it.\nexport function defineCloudflareOptions<Env = DefaultEnv, O = unknown>(\n callback: (env: Env) => StrictCloudflareOptions<O> | undefined,\n): (env: Env) => CloudflareOptions | undefined;\nexport function defineCloudflareOptions<Env = DefaultEnv>(\n options: CloudflareOptions,\n): (env: Env) => CloudflareOptions | undefined;\nexport function defineCloudflareOptions<Env = DefaultEnv>(\n optionsOrCallback: CloudflareOptions | ((env: Env) => CloudflareOptions | undefined),\n): (env: Env) => CloudflareOptions | undefined {\n if (typeof optionsOrCallback === 'function') {\n return optionsOrCallback;\n }\n\n return () => optionsOrCallback;\n}\n"],"names":[],"mappings":"AA+CO,SAAS,wBACd,iBAAA,EAC6C;AAC7C,EAAA,IAAI,OAAO,sBAAsB,UAAA,EAAY;AAC3C,IAAA,OAAO,iBAAA;AAAA,EACT;AAEA,EAAA,OAAO,MAAM,iBAAA;AACf;;;;"}
1
+ {"version":3,"file":"defineCloudflareOptions.js","names":[],"sources":["../../../src/defineCloudflareOptions.ts"],"sourcesContent":["import type { CloudflareOptions } from './client';\nimport type { DefaultEnv, StrictCloudflareOptions } from './types';\n\n/**\n * Define the Sentry options for a Cloudflare Worker in a dedicated module.\n *\n * This is the recommended way to configure the SDK when using the Vite plugin's\n * auto-instrumentation: place an `instrument.server.{ts,js,mjs}` file next to\n * the worker entry whose **default export** is the result of this function. The\n * plugin picks it up automatically and hands it to `withSentry`.\n *\n * Unlike Node's `Sentry.init(...)`, the options cannot be applied at module\n * load time on Cloudflare: the DSN and other settings typically come from the\n * per-request `env`, which only exists inside the handler. Pass a callback to\n * read from `env`, or a static object when no `env` access is needed — either\n * way you get full type-checking and autocomplete on {@link CloudflareOptions}.\n *\n * At runtime this is a thin pass-through; it only normalizes a static object\n * into a callback so the plugin always imports a `(env) => options` function.\n *\n * @example\n * ```ts\n * // src/instrument.server.ts\n * import { defineCloudflareOptions } from '@sentry/cloudflare';\n *\n * export default defineCloudflareOptions((env) => ({\n * dsn: env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * }));\n * ```\n *\n * @example\n * ```ts\n * // Static options — no `env` access needed\n * export default defineCloudflareOptions({ tracesSampleRate: 1.0 });\n * ```\n */\n// Overloads rather than a union parameter: TypeScript does not infer `O` out of a union member,\n// so a union signature falls back to the default and the unknown-key check never runs. The object\n// overload stays on plain `CloudflareOptions` — a direct object literal is still excess property\n// checked, and a callback cannot match it.\nexport function defineCloudflareOptions<Env = DefaultEnv, O = unknown>(\n callback: (env: Env) => StrictCloudflareOptions<O> | undefined,\n): (env: Env) => CloudflareOptions | undefined;\nexport function defineCloudflareOptions<Env = DefaultEnv>(\n options: CloudflareOptions,\n): (env: Env) => CloudflareOptions | undefined;\nexport function defineCloudflareOptions<Env = DefaultEnv>(\n optionsOrCallback: CloudflareOptions | ((env: Env) => CloudflareOptions | undefined),\n): (env: Env) => CloudflareOptions | undefined {\n if (typeof optionsOrCallback === 'function') {\n return optionsOrCallback;\n }\n\n return () => optionsOrCallback;\n}\n"],"mappings":";AA+CA,SAAgB,wBACd,mBAC6C;CAC7C,IAAI,OAAO,sBAAsB,YAC/B,OAAO;CAGT,aAAa;AACf"}
@@ -1,186 +1,315 @@
1
- import { RPC } from '@sentry/conventions/op';
2
- import { getIsolationScope, getDefaultIsolationScope, isObjectLike, startNewTrace } from '@sentry/core';
3
- import { setAsyncLocalStorageAsyncContextStrategyForWorker } from './utils/asyncContextStrategy.js';
4
- import { markAsInstrumented, getInstrumented } from './instrument.js';
5
- import { instrumentDurableObjectHandlers } from './instrumentations/instrumentDurableObjectHandlers.js';
6
- import { instrumentEnv } from './instrumentations/worker/instrumentEnv.js';
7
- import { getFinalOptions } from './options.js';
8
- import { instrumentContext } from './utils/instrumentContext.js';
9
- import { withConstructionIsolationScope } from './utils/invocationScope.js';
10
- import { hasRpcMeta } from './utils/rpcMeta.js';
11
- import { instrumentCloudflareAgent } from './instrumentations/agents/index.js';
12
- import { wrapMethodWithSentry } from './wrapMethodWithSentry.js';
13
-
1
+ import { setAsyncLocalStorageAsyncContextStrategyForWorker } from "./utils/asyncContextStrategy.js";
2
+ import { getInstrumented, markAsInstrumented } from "./instrument.js";
3
+ import { instrumentDurableObjectHandlers } from "./instrumentations/instrumentDurableObjectHandlers.js";
4
+ import { instrumentEnv } from "./instrumentations/worker/instrumentEnv.js";
5
+ import { getFinalOptions } from "./options.js";
6
+ import { flushDeferredChannelEvents } from "./orchestrion-deferred-channels.js";
7
+ import { init } from "./sdk.js";
8
+ import { instrumentContext } from "./utils/instrumentContext.js";
9
+ import { withConstructionIsolationScope } from "./utils/invocationScope.js";
10
+ import { hasRpcMeta } from "./utils/rpcMeta.js";
11
+ import { instrumentCloudflareAgent } from "./instrumentations/agents/index.js";
12
+ import { wrapMethodWithSentry } from "./wrapMethodWithSentry.js";
13
+ import { getDefaultIsolationScope, getIsolationScope, isObjectLike, startNewTrace } from "@sentry/core";
14
+ import { RPC } from "@sentry/conventions/op";
15
+ // src/durableobject.ts
16
+ /**
17
+ * Constructs a Durable Object instance and instruments its built-in handler methods
18
+ * (`fetch`, `alarm`, `webSocketMessage`, `webSocketClose`, `webSocketError`).
19
+ *
20
+ * This is the shared construction path used by both {@link instrumentDurableObjectWithSentry}
21
+ * and {@link instrumentAgentWithSentry}. It intentionally does NOT apply the RPC prototype-method
22
+ * instrumentation — callers apply that last via {@link finalizeWithRpcInstrumentation}, after any
23
+ * additional per-instance instrumentation has been layered onto the returned object.
24
+ *
25
+ * @internal
26
+ */
14
27
  function constructInstrumentedDurableObject(target, ctx, env, newTarget, optionsCallback) {
15
- setAsyncLocalStorageAsyncContextStrategyForWorker();
16
- const options = getFinalOptions(optionsCallback(env), env);
17
- const context = instrumentContext(ctx);
18
- const instrumentedEnv = instrumentEnv(env, options);
19
- const prototype = newTarget.prototype ?? target.prototype;
20
- const cachedFrameworkManagedMethods = frameworkManagedMethodsCache.get(prototype);
21
- const methodsBeforeConstruction = cachedFrameworkManagedMethods ? void 0 : resolvePrototypeMethods(prototype);
22
- const obj = withConstructionIsolationScope(
23
- () => Reflect.construct(target, [context, instrumentedEnv], newTarget)
24
- );
25
- const frameworkManagedMethods = resolveFrameworkManagedMethods(
26
- prototype,
27
- obj,
28
- methodsBeforeConstruction,
29
- cachedFrameworkManagedMethods
30
- );
31
- instrumentDurableObjectHandlers(obj, options, context);
32
- return { obj, options, context, frameworkManagedMethods };
28
+ setAsyncLocalStorageAsyncContextStrategyForWorker();
29
+ const options = getFinalOptions(optionsCallback(env), env);
30
+ const context = instrumentContext(ctx);
31
+ const instrumentedEnv = instrumentEnv(env, options);
32
+ const prototype = newTarget.prototype ?? target.prototype;
33
+ const cachedFrameworkManagedMethods = frameworkManagedMethodsCache.get(prototype);
34
+ const methodsBeforeConstruction = cachedFrameworkManagedMethods ? void 0 : resolveMethodsBeforeFirstConstruction(prototype);
35
+ const obj = withConstructionIsolationScope(() => {
36
+ if (options.cacheClient !== false) {
37
+ init({ ...options });
38
+ flushDeferredChannelEvents();
39
+ }
40
+ return Reflect.construct(target, [context, instrumentedEnv], newTarget);
41
+ });
42
+ const frameworkManagedMethods = resolveFrameworkManagedMethods(prototype, obj, methodsBeforeConstruction, cachedFrameworkManagedMethods);
43
+ instrumentDurableObjectHandlers(obj, options, context);
44
+ return {
45
+ obj,
46
+ options,
47
+ context,
48
+ frameworkManagedMethods
49
+ };
33
50
  }
34
51
  const frameworkManagedMethodsCache = /* @__PURE__ */ new WeakMap();
52
+ const methodsBeforeFirstConstructionCache = /* @__PURE__ */ new WeakMap();
53
+ /**
54
+ * Collects the prototype's methods as they were before any instance was constructed.
55
+ *
56
+ * A constructor can throw after a framework has already installed its wrappers (the `agents` SDK
57
+ * wraps `@callable()` methods before storage initialization, which can fail). The next construction
58
+ * would then see those wrappers as the originals and treat the methods as unmanaged, so the methods
59
+ * collected on the first attempt are kept until a construction succeeds.
60
+ */
61
+ function resolveMethodsBeforeFirstConstruction(prototype) {
62
+ let methods = methodsBeforeFirstConstructionCache.get(prototype);
63
+ if (!methods) {
64
+ methods = resolvePrototypeMethods(prototype);
65
+ methodsBeforeFirstConstructionCache.set(prototype, methods);
66
+ }
67
+ return methods;
68
+ }
69
+ /**
70
+ * Collects the methods visible from a prototype, using normal property lookup precedence.
71
+ * Methods inherited from `Object.prototype` are excluded because they cannot be Durable Object RPC methods.
72
+ */
35
73
  function resolvePrototypeMethods(prototype) {
36
- const methods = /* @__PURE__ */ new Map();
37
- for (let current = prototype; current && current !== Object.prototype; current = Object.getPrototypeOf(current)) {
38
- for (const name of Object.getOwnPropertyNames(current)) {
39
- if (name === "constructor" || methods.has(name)) {
40
- continue;
41
- }
42
- const descriptor = Object.getOwnPropertyDescriptor(current, name);
43
- if (descriptor && typeof descriptor.value === "function") {
44
- methods.set(name, descriptor.value);
45
- }
46
- }
47
- }
48
- return methods;
74
+ const methods = /* @__PURE__ */ new Map();
75
+ for (let current = prototype; current && current !== Object.prototype; current = Object.getPrototypeOf(current)) for (const name of Object.getOwnPropertyNames(current)) {
76
+ if (name === "constructor" || methods.has(name)) continue;
77
+ const descriptor = Object.getOwnPropertyDescriptor(current, name);
78
+ if (descriptor && typeof descriptor.value === "function") methods.set(name, descriptor.value);
79
+ }
80
+ return methods;
49
81
  }
82
+ /**
83
+ * Finds methods that a framework replaced while constructing the first instance.
84
+ *
85
+ * Some frameworks register methods by function identity, so replacing one of their wrappers would
86
+ * break dispatch. The result is cached because frameworks commonly install their wrappers only
87
+ * once; later constructions would no longer reveal which methods they manage.
88
+ */
50
89
  function resolveFrameworkManagedMethods(prototype, obj, methodsBeforeConstruction, cached) {
51
- if (cached) {
52
- return cached;
53
- }
54
- const methodsAfterConstruction = resolvePrototypeMethods(Object.getPrototypeOf(obj));
55
- const managed = /* @__PURE__ */ new Set();
56
- for (const [name, method] of methodsAfterConstruction) {
57
- const before = methodsBeforeConstruction?.get(name);
58
- if (before && before !== method) {
59
- managed.add(name);
60
- }
61
- }
62
- frameworkManagedMethodsCache.set(prototype, managed);
63
- return managed;
90
+ if (cached) return cached;
91
+ const methodsAfterConstruction = resolvePrototypeMethods(Object.getPrototypeOf(obj));
92
+ const managed = /* @__PURE__ */ new Set();
93
+ for (const [name, method] of methodsAfterConstruction) {
94
+ const before = methodsBeforeConstruction?.get(name);
95
+ if (before && before !== method) managed.add(name);
96
+ }
97
+ frameworkManagedMethodsCache.set(prototype, managed);
98
+ methodsBeforeFirstConstructionCache.delete(prototype);
99
+ return managed;
64
100
  }
101
+ /**
102
+ * Method names the runtime never dispatches over RPC, so wrapping them buys no tracing.
103
+ *
104
+ * Mirrors `isReservedName` in workerd (`src/workerd/api/worker-rpc.c++`): the runtime rejects these
105
+ * before any property lookup happens. `fetch`, `alarm` and the `webSocket*` handlers are also
106
+ * instrumented per-instance as own properties, and `constructor` is on every prototype.
107
+ */
65
108
  const RESERVED_RPC_METHOD_NAMES = /* @__PURE__ */ new Set([
66
- "constructor",
67
- "fetch",
68
- "connect",
69
- "alarm",
70
- "webSocketMessage",
71
- "webSocketClose",
72
- "webSocketError",
73
- "dup"
109
+ "constructor",
110
+ "fetch",
111
+ "connect",
112
+ "alarm",
113
+ "webSocketMessage",
114
+ "webSocketClose",
115
+ "webSocketError",
116
+ "dup"
74
117
  ]);
75
118
  const rpcInstanceStates = /* @__PURE__ */ new WeakMap();
119
+ /**
120
+ * Instruments a constructed Durable Object's RPC methods.
121
+ *
122
+ * RPC methods are wrapped on the prototype because Cloudflare dispatches them with the Durable
123
+ * Object instance as the receiver. This preserves native private-field access and keeps the methods
124
+ * visible to Cloudflare's RPC dispatcher. Built-in handlers, Agent handlers, and methods managed by
125
+ * another framework are left untouched.
126
+ *
127
+ * Call this after all per-instance instrumentation has been applied.
128
+ *
129
+ * @param obj The constructed Durable Object instance.
130
+ * @param options The resolved SDK options for this instance.
131
+ * @param context The instrumented execution context for this instance.
132
+ * @param excludedMethods Method names owned by another framework and therefore not safe to wrap.
133
+ * @returns The same Durable Object instance, with eligible prototype methods instrumented.
134
+ * @internal
135
+ */
76
136
  function finalizeWithRpcInstrumentation(obj, options, context, excludedMethods) {
77
- rpcInstanceStates.set(obj, { options, context });
78
- instrumentPrototypeRpcMethods(obj, excludedMethods);
79
- return obj;
137
+ rpcInstanceStates.set(obj, {
138
+ options,
139
+ context
140
+ });
141
+ instrumentPrototypeRpcMethods(obj, excludedMethods);
142
+ return obj;
80
143
  }
144
+ /**
145
+ * Returns a prototype method when it is eligible for RPC instrumentation.
146
+ */
81
147
  function getRpcMethodDescriptor(obj, prototype, methodName, excludedMethods) {
82
- if (RESERVED_RPC_METHOD_NAMES.has(methodName) || Object.prototype.hasOwnProperty.call(obj, methodName) || excludedMethods?.has(methodName)) {
83
- return void 0;
84
- }
85
- const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
86
- if (!descriptor || typeof descriptor.value !== "function" || getInstrumented(descriptor.value)) {
87
- return void 0;
88
- }
89
- return descriptor;
148
+ if (RESERVED_RPC_METHOD_NAMES.has(methodName) || Object.prototype.hasOwnProperty.call(obj, methodName) || excludedMethods?.has(methodName)) return;
149
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
150
+ if (!descriptor || typeof descriptor.value !== "function" || getInstrumented(descriptor.value)) return;
151
+ return descriptor;
90
152
  }
153
+ /**
154
+ * Wraps eligible methods on the instance's prototype chain once per class.
155
+ */
91
156
  function instrumentPrototypeRpcMethods(obj, excludedMethods) {
92
- let prototype = Object.getPrototypeOf(obj);
93
- while (prototype && prototype !== Object.prototype) {
94
- for (const methodName of Object.getOwnPropertyNames(prototype)) {
95
- const descriptor = getRpcMethodDescriptor(obj, prototype, methodName, excludedMethods);
96
- if (!descriptor) {
97
- continue;
98
- }
99
- const wrapped = createRpcPrototypeWrapper(methodName, descriptor.value);
100
- try {
101
- Object.defineProperty(prototype, methodName, { ...descriptor, value: wrapped });
102
- } catch {
103
- }
104
- markAsInstrumented(wrapped);
105
- }
106
- prototype = Object.getPrototypeOf(prototype);
107
- }
157
+ let prototype = Object.getPrototypeOf(obj);
158
+ while (prototype && prototype !== Object.prototype) {
159
+ for (const methodName of Object.getOwnPropertyNames(prototype)) {
160
+ const descriptor = getRpcMethodDescriptor(obj, prototype, methodName, excludedMethods);
161
+ if (!descriptor) continue;
162
+ const wrapped = createRpcPrototypeWrapper(methodName, descriptor.value);
163
+ try {
164
+ Object.defineProperty(prototype, methodName, {
165
+ ...descriptor,
166
+ value: wrapped
167
+ });
168
+ } catch {}
169
+ markAsInstrumented(wrapped);
170
+ }
171
+ prototype = Object.getPrototypeOf(prototype);
172
+ }
108
173
  }
174
+ /**
175
+ * Returns the instance's instrumented wrapper for an RPC method, creating it on first use.
176
+ */
109
177
  function getInstrumentedRpcMethod(state, methodName, originalMethod) {
110
- const instrumentedMethods = state.instrumentedMethods ?? (state.instrumentedMethods = /* @__PURE__ */ new Map());
111
- let instrumented = instrumentedMethods.get(methodName);
112
- if (!instrumented) {
113
- instrumented = wrapMethodWithSentry(
114
- {
115
- options: state.options,
116
- context: state.context,
117
- spanName: (rpcMeta) => rpcMeta ? methodName : void 0,
118
- spanOp: RPC,
119
- origin: "auto.faas.cloudflare.durable_object"
120
- },
121
- originalMethod,
122
- void 0,
123
- true
124
- );
125
- instrumentedMethods.set(methodName, instrumented);
126
- }
127
- return instrumented;
178
+ const instrumentedMethods = state.instrumentedMethods ?? (state.instrumentedMethods = /* @__PURE__ */ new Map());
179
+ let instrumented = instrumentedMethods.get(methodName);
180
+ if (!instrumented) {
181
+ instrumented = wrapMethodWithSentry({
182
+ options: state.options,
183
+ context: state.context,
184
+ spanName: (rpcMeta) => rpcMeta ? methodName : void 0,
185
+ spanOp: RPC,
186
+ origin: "auto.faas.cloudflare.durable_object"
187
+ }, originalMethod, void 0, true);
188
+ instrumentedMethods.set(methodName, instrumented);
189
+ }
190
+ return instrumented;
128
191
  }
192
+ /**
193
+ * Creates a prototype wrapper that instruments external RPC calls.
194
+ *
195
+ * The wrapper looks up SDK state from its receiver, allowing one prototype function to serve every
196
+ * instance. A call carrying Sentry metadata continues that trace in an `rpc` span. A call without it
197
+ * still gets a client, so its errors, logs and metrics are captured, but no span. Calls the instance
198
+ * makes to its own methods run the original method directly. The original function name and arity
199
+ * are preserved because frameworks may inspect them for dispatch.
200
+ */
129
201
  function createRpcPrototypeWrapper(methodName, originalMethod) {
130
- const wrapper = function(...args) {
131
- const traced = hasRpcMeta(args);
132
- if (!traced && getIsolationScope() !== getDefaultIsolationScope()) {
133
- return Reflect.apply(originalMethod, this, args);
134
- }
135
- const state = isObjectLike(this) ? rpcInstanceStates.get(this) : void 0;
136
- if (!state) {
137
- return Reflect.apply(originalMethod, this, args);
138
- }
139
- const instrumented = getInstrumentedRpcMethod(state, methodName, originalMethod);
140
- if (traced) {
141
- return Reflect.apply(instrumented, this, args);
142
- }
143
- return startNewTrace(() => Reflect.apply(instrumented, this, args));
144
- };
145
- Object.defineProperties(wrapper, {
146
- name: { value: originalMethod.name, configurable: true },
147
- length: { value: originalMethod.length, configurable: true }
148
- });
149
- return wrapper;
202
+ const wrapper = function(...args) {
203
+ const traced = hasRpcMeta(args);
204
+ if (!traced && getIsolationScope() !== getDefaultIsolationScope()) return Reflect.apply(originalMethod, this, args);
205
+ const state = isObjectLike(this) ? rpcInstanceStates.get(this) : void 0;
206
+ if (!state) return Reflect.apply(originalMethod, this, args);
207
+ const instrumented = getInstrumentedRpcMethod(state, methodName, originalMethod);
208
+ if (traced) return Reflect.apply(instrumented, this, args);
209
+ return startNewTrace(() => Reflect.apply(instrumented, this, args));
210
+ };
211
+ Object.defineProperties(wrapper, {
212
+ name: {
213
+ value: originalMethod.name,
214
+ configurable: true
215
+ },
216
+ length: {
217
+ value: originalMethod.length,
218
+ configurable: true
219
+ }
220
+ });
221
+ return wrapper;
150
222
  }
223
+ /**
224
+ * Instruments a Durable Object class to capture errors and performance data.
225
+ *
226
+ * Instruments the following methods by default:
227
+ * - fetch
228
+ * - alarm
229
+ * - webSocketMessage
230
+ * - webSocketClose
231
+ * - webSocketError
232
+ *
233
+ * RPC methods (prototype methods) are instrumented too: an incoming trace continues into them, and
234
+ * errors, logs and metrics are captured whether or not the caller propagates a trace.
235
+ *
236
+ * @param optionsCallback Function that returns the options for the SDK initialization.
237
+ * @param DurableObjectClass The Durable Object class to instrument.
238
+ * @returns The instrumented Durable Object class.
239
+ *
240
+ * @example
241
+ * ```ts
242
+ * class MyDurableObjectBase extends DurableObject {
243
+ * constructor(ctx: DurableObjectState, env: Env) {
244
+ * super(ctx, env);
245
+ * }
246
+ * }
247
+ *
248
+ * export const MyDurableObject = instrumentDurableObjectWithSentry(
249
+ * env => ({
250
+ * dsn: env.SENTRY_DSN,
251
+ * tracesSampleRate: 1.0,
252
+ * }),
253
+ * MyDurableObjectBase,
254
+ * );
255
+ * ```
256
+ */
151
257
  function instrumentDurableObjectWithSentry(optionsCallback, DurableObjectClass) {
152
- const InstrumentedClass = new Proxy(DurableObjectClass, {
153
- construct(target, [ctx, env], newTarget) {
154
- const { obj, options, context, frameworkManagedMethods } = constructInstrumentedDurableObject(
155
- target,
156
- ctx,
157
- env,
158
- newTarget,
159
- optionsCallback
160
- );
161
- return finalizeWithRpcInstrumentation(obj, options, context, frameworkManagedMethods);
162
- }
163
- });
164
- markAsInstrumented(InstrumentedClass);
165
- return InstrumentedClass;
258
+ const InstrumentedClass = new Proxy(DurableObjectClass, { construct(target, [ctx, env], newTarget) {
259
+ const { obj, options, context, frameworkManagedMethods } = constructInstrumentedDurableObject(target, ctx, env, newTarget, optionsCallback);
260
+ return finalizeWithRpcInstrumentation(obj, options, context, frameworkManagedMethods);
261
+ } });
262
+ markAsInstrumented(InstrumentedClass);
263
+ return InstrumentedClass;
166
264
  }
265
+ /**
266
+ * Instruments a Cloudflare [`agents`](https://www.npmjs.com/package/agents) Agent class with Sentry.
267
+ *
268
+ * An `Agent` is a Durable Object under the hood, so this applies the same instrumentation as
269
+ * {@link instrumentDurableObjectWithSentry} (request transactions, `alarm`, WebSocket handlers, RPC
270
+ * trace propagation, SQL spans) and additionally captures Agent-specific telemetry via
271
+ * `instrumentCloudflareAgent`:
272
+ *
273
+ * - **Callable RPC spans** — a span (op `rpc`) for each `@callable()` method invoked over WebSocket.
274
+ * - **Breadcrumbs** — for every Agent observability event (`rpc`, `state:update`, `connect`,
275
+ * `disconnect`, `schedule:*`, `queue:*`, `workflow:*`, `email:*`, `mcp:*`, ...).
276
+ *
277
+ * Cloudflare Workers cannot auto-instrument, so the Agent class must be wrapped manually.
278
+ *
279
+ * @param optionsCallback Function that returns the options for the SDK initialization.
280
+ * @param AgentClass The Agent class to instrument.
281
+ * @returns The instrumented Agent class.
282
+ *
283
+ * @example
284
+ * ```ts
285
+ * import { Agent, callable, routeAgentRequest } from 'agents';
286
+ * import * as Sentry from '@sentry/cloudflare';
287
+ *
288
+ * class MyAgentBase extends Agent<Env> {
289
+ * @callable()
290
+ * async greet(name: string): Promise<string> {
291
+ * return `Hello, ${name}!`;
292
+ * }
293
+ * }
294
+ *
295
+ * export const MyAgent = Sentry.instrumentAgentWithSentry(
296
+ * env => ({
297
+ * dsn: env.SENTRY_DSN,
298
+ * tracesSampleRate: 1.0,
299
+ * }),
300
+ * MyAgentBase,
301
+ * );
302
+ * ```
303
+ */
167
304
  function instrumentAgentWithSentry(optionsCallback, AgentClass) {
168
- const InstrumentedClass = new Proxy(AgentClass, {
169
- construct(target, [ctx, env], newTarget) {
170
- const { obj, options, context, frameworkManagedMethods } = constructInstrumentedDurableObject(
171
- target,
172
- ctx,
173
- env,
174
- newTarget,
175
- optionsCallback
176
- );
177
- instrumentCloudflareAgent(obj);
178
- return finalizeWithRpcInstrumentation(obj, options, context, frameworkManagedMethods);
179
- }
180
- });
181
- markAsInstrumented(InstrumentedClass);
182
- return InstrumentedClass;
305
+ const InstrumentedClass = new Proxy(AgentClass, { construct(target, [ctx, env], newTarget) {
306
+ const { obj, options, context, frameworkManagedMethods } = constructInstrumentedDurableObject(target, ctx, env, newTarget, optionsCallback);
307
+ instrumentCloudflareAgent(obj);
308
+ return finalizeWithRpcInstrumentation(obj, options, context, frameworkManagedMethods);
309
+ } });
310
+ markAsInstrumented(InstrumentedClass);
311
+ return InstrumentedClass;
183
312
  }
184
-
185
313
  export { constructInstrumentedDurableObject, finalizeWithRpcInstrumentation, instrumentAgentWithSentry, instrumentDurableObjectWithSentry };
186
- //# sourceMappingURL=durableobject.js.map
314
+
315
+ //# sourceMappingURL=durableobject.js.map