@sentry/cloudflare 10.69.0 → 11.0.0-alpha.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 (771) 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/dev/durableobject.js +234 -0
  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} +15 -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/{instrumentations → dev/instrumentations}/agents/index.js +2 -0
  14. package/build/cjs/dev/instrumentations/agents/index.js.map +1 -0
  15. package/build/cjs/{instrumentations → dev/instrumentations}/agents/instrumentAgentCallableRpc.js +2 -2
  16. package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
  17. package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js +19 -0
  18. package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
  19. package/build/cjs/{instrumentations → dev/instrumentations}/agents/instrumentChatAgentConversation.js +3 -3
  20. package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
  21. package/build/cjs/dev/instrumentations/agents/types.js +77 -0
  22. package/build/cjs/dev/instrumentations/agents/types.js.map +1 -0
  23. package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
  24. package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
  25. package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
  26. package/build/cjs/dev/instrumentations/instrumentSqlStorage.js.map +1 -0
  27. package/build/cjs/{instrumentations → dev/instrumentations}/instrumentWorkerEntrypoint.js +3 -3
  28. package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
  29. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentD1.js +0 -4
  30. package/build/cjs/dev/instrumentations/worker/instrumentD1.js.map +1 -0
  31. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentEmail.js +3 -1
  32. package/build/cjs/dev/instrumentations/worker/instrumentEmail.js.map +1 -0
  33. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentEnv.js +3 -4
  34. package/build/cjs/dev/instrumentations/worker/instrumentEnv.js.map +1 -0
  35. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentFetch.js +9 -3
  36. package/build/cjs/dev/instrumentations/worker/instrumentFetch.js.map +1 -0
  37. package/build/cjs/dev/instrumentations/worker/instrumentFetcher.js.map +1 -0
  38. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentQueue.js +3 -2
  39. package/build/cjs/dev/instrumentations/worker/instrumentQueue.js.map +1 -0
  40. package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
  41. package/build/cjs/dev/instrumentations/worker/instrumentR2.js.map +1 -0
  42. package/build/cjs/dev/instrumentations/worker/instrumentRateLimit.js.map +1 -0
  43. package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentScheduled.js +3 -1
  44. package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js.map +1 -0
  45. package/build/cjs/dev/instrumentations/worker/instrumentTail.js.map +1 -0
  46. package/build/cjs/{integrations → dev/integrations}/fetch.js +1 -1
  47. package/build/cjs/dev/integrations/fetch.js.map +1 -0
  48. package/build/cjs/{integrations → dev/integrations}/httpServer.js +5 -4
  49. package/build/cjs/dev/integrations/httpServer.js.map +1 -0
  50. package/build/cjs/dev/integrations/spotlight.js.map +1 -0
  51. package/build/cjs/{nodejs_compat → dev}/integrations/tracing/vercelai.js +6 -6
  52. package/build/cjs/dev/integrations/tracing/vercelai.js.map +1 -0
  53. package/build/cjs/dev/opentelemetry/tracer.js.map +1 -0
  54. package/build/cjs/{options.js → dev/options.js} +8 -0
  55. package/build/cjs/dev/options.js.map +1 -0
  56. package/build/cjs/{pages-plugin.js → dev/pages-plugin.js} +8 -3
  57. package/build/cjs/dev/pages-plugin.js.map +1 -0
  58. package/build/cjs/{request.js → dev/request.js} +23 -12
  59. package/build/cjs/dev/request.js.map +1 -0
  60. package/build/cjs/dev/scope-utils.js.map +1 -0
  61. package/build/cjs/dev/sdk.js +19 -0
  62. package/build/cjs/dev/sdk.js.map +1 -0
  63. package/build/cjs/dev/transport.js.map +1 -0
  64. package/build/cjs/{utils → dev/utils}/instrumentContext.js +8 -13
  65. package/build/cjs/dev/utils/instrumentContext.js.map +1 -0
  66. package/build/cjs/dev/utils/internalSqlQuery.js.map +1 -0
  67. package/build/cjs/dev/utils/internalStorageKey.js.map +1 -0
  68. package/build/cjs/dev/utils/invocationScope.js +12 -0
  69. package/build/cjs/dev/utils/invocationScope.js.map +1 -0
  70. package/build/cjs/dev/utils/isBinding.js.map +1 -0
  71. package/build/cjs/dev/utils/isCloudflareClass.js.map +1 -0
  72. package/build/cjs/{utils → dev/utils}/rpcMeta.js +4 -0
  73. package/build/cjs/dev/utils/rpcMeta.js.map +1 -0
  74. package/build/cjs/dev/utils/streaming.js.map +1 -0
  75. package/build/cjs/dev/utils/traceLinks.js.map +1 -0
  76. package/build/cjs/dev/vendor/stacktrace.js.map +1 -0
  77. package/build/cjs/dev/vite/agentClass.js.map +1 -0
  78. package/build/cjs/dev/vite/autoInstrument.js.map +1 -0
  79. package/build/cjs/{vite → dev/vite}/index.js +3 -1
  80. package/build/cjs/dev/vite/index.js.map +1 -0
  81. package/build/cjs/dev/vite/instrumentFile.js.map +1 -0
  82. package/build/cjs/dev/vite/moduleShape.js.map +1 -0
  83. package/build/cjs/dev/vite/transform.js.map +1 -0
  84. package/build/cjs/dev/vite/workerEntrypoint.js.map +1 -0
  85. package/build/cjs/dev/vite/wranglerConfig.js.map +1 -0
  86. package/build/cjs/{withSentry.js → dev/withSentry.js} +2 -19
  87. package/build/cjs/dev/withSentry.js.map +1 -0
  88. package/build/cjs/{workflows.js → dev/workflows.js} +9 -4
  89. package/build/cjs/dev/workflows.js.map +1 -0
  90. package/build/cjs/{wrapMethodWithSentry.js → dev/wrapMethodWithSentry.js} +2 -3
  91. package/build/cjs/dev/wrapMethodWithSentry.js.map +1 -0
  92. package/build/cjs/prod/baseSdk.js +73 -0
  93. package/build/cjs/prod/baseSdk.js.map +1 -0
  94. package/build/cjs/prod/client.js +122 -0
  95. package/build/cjs/prod/client.js.map +1 -0
  96. package/build/cjs/prod/debug-build.js +6 -0
  97. package/build/cjs/prod/debug-build.js.map +1 -0
  98. package/build/cjs/prod/defineCloudflareOptions.js +11 -0
  99. package/build/cjs/prod/defineCloudflareOptions.js.map +1 -0
  100. package/build/cjs/prod/durableobject.js +234 -0
  101. package/build/cjs/prod/durableobject.js.map +1 -0
  102. package/build/cjs/prod/flush.js +87 -0
  103. package/build/cjs/prod/flush.js.map +1 -0
  104. package/build/cjs/{nodejs_compat → prod}/index.js +33 -37
  105. package/build/cjs/{nodejs_compat → prod}/index.js.map +1 -1
  106. package/build/cjs/prod/instrument.js +52 -0
  107. package/build/cjs/prod/instrument.js.map +1 -0
  108. package/build/cjs/prod/instrumentations/agents/index.js +16 -0
  109. package/build/cjs/prod/instrumentations/agents/index.js.map +1 -0
  110. package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js +52 -0
  111. package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
  112. package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js +19 -0
  113. package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
  114. package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js +31 -0
  115. package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
  116. package/build/cjs/prod/instrumentations/agents/types.js +77 -0
  117. package/build/cjs/prod/instrumentations/agents/types.js.map +1 -0
  118. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js +41 -0
  119. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
  120. package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js +72 -0
  121. package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
  122. package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +40 -0
  123. package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
  124. package/build/cjs/prod/instrumentations/instrumentSqlStorage.js +42 -0
  125. package/build/cjs/prod/instrumentations/instrumentSqlStorage.js.map +1 -0
  126. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js +139 -0
  127. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
  128. package/build/cjs/prod/instrumentations/worker/instrumentD1.js +161 -0
  129. package/build/cjs/prod/instrumentations/worker/instrumentD1.js.map +1 -0
  130. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js +63 -0
  131. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js.map +1 -0
  132. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js +90 -0
  133. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js.map +1 -0
  134. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js +54 -0
  135. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js.map +1 -0
  136. package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js +24 -0
  137. package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js.map +1 -0
  138. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js +82 -0
  139. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js.map +1 -0
  140. package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js +80 -0
  141. package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
  142. package/build/cjs/prod/instrumentations/worker/instrumentR2.js +124 -0
  143. package/build/cjs/prod/instrumentations/worker/instrumentR2.js.map +1 -0
  144. package/build/cjs/prod/instrumentations/worker/instrumentRateLimit.js +29 -0
  145. package/build/cjs/prod/instrumentations/worker/instrumentRateLimit.js.map +1 -0
  146. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js +78 -0
  147. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js.map +1 -0
  148. package/build/cjs/prod/instrumentations/worker/instrumentTail.js +60 -0
  149. package/build/cjs/prod/instrumentations/worker/instrumentTail.js.map +1 -0
  150. package/build/cjs/prod/integrations/fetch.js +119 -0
  151. package/build/cjs/prod/integrations/fetch.js.map +1 -0
  152. package/build/cjs/prod/integrations/httpServer.js +36 -0
  153. package/build/cjs/prod/integrations/httpServer.js.map +1 -0
  154. package/build/cjs/prod/integrations/spotlight.js +64 -0
  155. package/build/cjs/prod/integrations/spotlight.js.map +1 -0
  156. package/build/cjs/{integrations → prod/integrations}/tracing/vercelai.js +5 -5
  157. package/build/cjs/prod/integrations/tracing/vercelai.js.map +1 -0
  158. package/build/cjs/prod/opentelemetry/tracer.js +49 -0
  159. package/build/cjs/prod/opentelemetry/tracer.js.map +1 -0
  160. package/build/cjs/prod/options.js +33 -0
  161. package/build/cjs/prod/options.js.map +1 -0
  162. package/build/cjs/prod/pages-plugin.js +24 -0
  163. package/build/cjs/prod/pages-plugin.js.map +1 -0
  164. package/build/cjs/prod/request.js +132 -0
  165. package/build/cjs/prod/request.js.map +1 -0
  166. package/build/cjs/prod/scope-utils.js +22 -0
  167. package/build/cjs/prod/scope-utils.js.map +1 -0
  168. package/build/cjs/prod/sdk.js +19 -0
  169. package/build/cjs/prod/sdk.js.map +1 -0
  170. package/build/cjs/prod/transport.js +75 -0
  171. package/build/cjs/prod/transport.js.map +1 -0
  172. package/build/cjs/prod/utils/instrumentContext.js +63 -0
  173. package/build/cjs/prod/utils/instrumentContext.js.map +1 -0
  174. package/build/cjs/prod/utils/internalSqlQuery.js +25 -0
  175. package/build/cjs/prod/utils/internalSqlQuery.js.map +1 -0
  176. package/build/cjs/prod/utils/internalStorageKey.js +44 -0
  177. package/build/cjs/prod/utils/internalStorageKey.js.map +1 -0
  178. package/build/cjs/prod/utils/invocationScope.js +12 -0
  179. package/build/cjs/prod/utils/invocationScope.js.map +1 -0
  180. package/build/cjs/prod/utils/isBinding.js +37 -0
  181. package/build/cjs/prod/utils/isBinding.js.map +1 -0
  182. package/build/cjs/prod/utils/isCloudflareClass.js +23 -0
  183. package/build/cjs/prod/utils/isCloudflareClass.js.map +1 -0
  184. package/build/cjs/prod/utils/rpcMeta.js +39 -0
  185. package/build/cjs/prod/utils/rpcMeta.js.map +1 -0
  186. package/build/cjs/prod/utils/streaming.js +16 -0
  187. package/build/cjs/prod/utils/streaming.js.map +1 -0
  188. package/build/cjs/prod/utils/traceLinks.js +54 -0
  189. package/build/cjs/prod/utils/traceLinks.js.map +1 -0
  190. package/build/cjs/prod/vendor/stacktrace.js +28 -0
  191. package/build/cjs/prod/vendor/stacktrace.js.map +1 -0
  192. package/build/cjs/prod/vite/agentClass.js +114 -0
  193. package/build/cjs/prod/vite/agentClass.js.map +1 -0
  194. package/build/cjs/prod/vite/autoInstrument.js +94 -0
  195. package/build/cjs/prod/vite/autoInstrument.js.map +1 -0
  196. package/build/cjs/prod/vite/index.js +16 -0
  197. package/build/cjs/prod/vite/index.js.map +1 -0
  198. package/build/cjs/prod/vite/instrumentFile.js +31 -0
  199. package/build/cjs/prod/vite/instrumentFile.js.map +1 -0
  200. package/build/cjs/prod/vite/moduleShape.js +231 -0
  201. package/build/cjs/prod/vite/moduleShape.js.map +1 -0
  202. package/build/cjs/prod/vite/transform.js +149 -0
  203. package/build/cjs/prod/vite/transform.js.map +1 -0
  204. package/build/cjs/prod/vite/workerEntrypoint.js +66 -0
  205. package/build/cjs/prod/vite/workerEntrypoint.js.map +1 -0
  206. package/build/cjs/prod/vite/wranglerConfig.js +54 -0
  207. package/build/cjs/prod/vite/wranglerConfig.js.map +1 -0
  208. package/build/cjs/prod/withSentry.js +29 -0
  209. package/build/cjs/prod/withSentry.js.map +1 -0
  210. package/build/cjs/prod/workflows.js +139 -0
  211. package/build/cjs/prod/workflows.js.map +1 -0
  212. package/build/cjs/prod/wrapMethodWithSentry.js +134 -0
  213. package/build/cjs/prod/wrapMethodWithSentry.js.map +1 -0
  214. package/build/esm/{sdk.js → dev/baseSdk.js} +26 -17
  215. package/build/esm/dev/baseSdk.js.map +1 -0
  216. package/build/esm/dev/client.js.map +1 -0
  217. package/build/esm/dev/debug-build.js.map +1 -0
  218. package/build/esm/dev/defineCloudflareOptions.js.map +1 -0
  219. package/build/esm/dev/durableobject.js +229 -0
  220. package/build/esm/dev/durableobject.js.map +1 -0
  221. package/build/esm/dev/flush.js.map +1 -0
  222. package/build/esm/dev/index.js +15 -0
  223. package/build/esm/{index.js.map → dev/index.js.map} +1 -1
  224. package/build/esm/dev/instrument.js.map +1 -0
  225. package/build/esm/{instrumentations → dev/instrumentations}/agents/index.js +2 -0
  226. package/build/esm/dev/instrumentations/agents/index.js.map +1 -0
  227. package/build/esm/{instrumentations → dev/instrumentations}/agents/instrumentAgentCallableRpc.js +2 -2
  228. package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
  229. package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js +17 -0
  230. package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
  231. package/build/esm/{instrumentations → dev/instrumentations}/agents/instrumentChatAgentConversation.js +4 -4
  232. package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
  233. package/build/esm/dev/instrumentations/agents/types.js +69 -0
  234. package/build/esm/dev/instrumentations/agents/types.js.map +1 -0
  235. package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
  236. package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
  237. package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
  238. package/build/esm/dev/instrumentations/instrumentSqlStorage.js.map +1 -0
  239. package/build/esm/{instrumentations → dev/instrumentations}/instrumentWorkerEntrypoint.js +2 -2
  240. package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
  241. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentD1.js +1 -4
  242. package/build/esm/dev/instrumentations/worker/instrumentD1.js.map +1 -0
  243. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentEmail.js +3 -1
  244. package/build/esm/dev/instrumentations/worker/instrumentEmail.js.map +1 -0
  245. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentEnv.js +3 -4
  246. package/build/esm/dev/instrumentations/worker/instrumentEnv.js.map +1 -0
  247. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentFetch.js +10 -4
  248. package/build/esm/dev/instrumentations/worker/instrumentFetch.js.map +1 -0
  249. package/build/esm/dev/instrumentations/worker/instrumentFetcher.js.map +1 -0
  250. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentQueue.js +4 -3
  251. package/build/esm/dev/instrumentations/worker/instrumentQueue.js.map +1 -0
  252. package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
  253. package/build/esm/dev/instrumentations/worker/instrumentR2.js.map +1 -0
  254. package/build/esm/dev/instrumentations/worker/instrumentRateLimit.js.map +1 -0
  255. package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentScheduled.js +3 -1
  256. package/build/esm/dev/instrumentations/worker/instrumentScheduled.js.map +1 -0
  257. package/build/esm/dev/instrumentations/worker/instrumentTail.js.map +1 -0
  258. package/build/esm/{integrations → dev/integrations}/fetch.js +1 -1
  259. package/build/esm/dev/integrations/fetch.js.map +1 -0
  260. package/build/esm/{integrations → dev/integrations}/httpServer.js +5 -4
  261. package/build/esm/dev/integrations/httpServer.js.map +1 -0
  262. package/build/esm/dev/integrations/spotlight.js.map +1 -0
  263. package/build/esm/{integrations → dev/integrations}/tracing/vercelai.js +5 -5
  264. package/build/esm/dev/integrations/tracing/vercelai.js.map +1 -0
  265. package/build/esm/dev/opentelemetry/tracer.js.map +1 -0
  266. package/build/esm/{options.js → dev/options.js} +8 -0
  267. package/build/esm/dev/options.js.map +1 -0
  268. package/build/esm/dev/package.json +1 -0
  269. package/build/esm/{pages-plugin.js → dev/pages-plugin.js} +8 -3
  270. package/build/esm/dev/pages-plugin.js.map +1 -0
  271. package/build/esm/{request.js → dev/request.js} +24 -14
  272. package/build/esm/dev/request.js.map +1 -0
  273. package/build/esm/dev/scope-utils.js.map +1 -0
  274. package/build/esm/dev/sdk.js +16 -0
  275. package/build/esm/dev/sdk.js.map +1 -0
  276. package/build/esm/dev/transport.js.map +1 -0
  277. package/build/esm/{utils → dev/utils}/instrumentContext.js +8 -13
  278. package/build/esm/dev/utils/instrumentContext.js.map +1 -0
  279. package/build/esm/dev/utils/internalSqlQuery.js.map +1 -0
  280. package/build/esm/dev/utils/internalStorageKey.js.map +1 -0
  281. package/build/esm/dev/utils/invocationScope.js +10 -0
  282. package/build/esm/dev/utils/invocationScope.js.map +1 -0
  283. package/build/esm/dev/utils/isBinding.js.map +1 -0
  284. package/build/esm/dev/utils/isCloudflareClass.js.map +1 -0
  285. package/build/esm/{utils → dev/utils}/rpcMeta.js +4 -1
  286. package/build/esm/dev/utils/rpcMeta.js.map +1 -0
  287. package/build/esm/dev/utils/streaming.js.map +1 -0
  288. package/build/esm/{utils → dev/utils}/traceLinks.js +1 -1
  289. package/build/esm/dev/utils/traceLinks.js.map +1 -0
  290. package/build/esm/dev/vendor/stacktrace.js.map +1 -0
  291. package/build/esm/dev/vite/agentClass.js.map +1 -0
  292. package/build/esm/dev/vite/autoInstrument.js.map +1 -0
  293. package/build/esm/{vite → dev/vite}/index.js +3 -1
  294. package/build/esm/dev/vite/index.js.map +1 -0
  295. package/build/esm/dev/vite/instrumentFile.js.map +1 -0
  296. package/build/esm/dev/vite/moduleShape.js.map +1 -0
  297. package/build/esm/dev/vite/transform.js.map +1 -0
  298. package/build/esm/dev/vite/workerEntrypoint.js.map +1 -0
  299. package/build/esm/dev/vite/wranglerConfig.js.map +1 -0
  300. package/build/esm/{withSentry.js → dev/withSentry.js} +1 -18
  301. package/build/esm/dev/withSentry.js.map +1 -0
  302. package/build/esm/{workflows.js → dev/workflows.js} +9 -4
  303. package/build/esm/dev/workflows.js.map +1 -0
  304. package/build/esm/{wrapMethodWithSentry.js → dev/wrapMethodWithSentry.js} +3 -4
  305. package/build/esm/dev/wrapMethodWithSentry.js.map +1 -0
  306. package/build/esm/prod/baseSdk.js +69 -0
  307. package/build/esm/prod/baseSdk.js.map +1 -0
  308. package/build/esm/prod/client.js +120 -0
  309. package/build/esm/prod/client.js.map +1 -0
  310. package/build/esm/prod/debug-build.js +4 -0
  311. package/build/esm/prod/debug-build.js.map +1 -0
  312. package/build/esm/prod/defineCloudflareOptions.js +9 -0
  313. package/build/esm/prod/defineCloudflareOptions.js.map +1 -0
  314. package/build/esm/prod/durableobject.js +229 -0
  315. package/build/esm/prod/durableobject.js.map +1 -0
  316. package/build/esm/prod/flush.js +83 -0
  317. package/build/esm/prod/flush.js.map +1 -0
  318. package/build/esm/prod/index.js +15 -0
  319. package/build/esm/{nodejs_compat → prod}/index.js.map +1 -1
  320. package/build/esm/prod/instrument.js +48 -0
  321. package/build/esm/prod/instrument.js.map +1 -0
  322. package/build/esm/prod/instrumentations/agents/index.js +14 -0
  323. package/build/esm/prod/instrumentations/agents/index.js.map +1 -0
  324. package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js +50 -0
  325. package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
  326. package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js +17 -0
  327. package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
  328. package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js +29 -0
  329. package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
  330. package/build/esm/prod/instrumentations/agents/types.js +69 -0
  331. package/build/esm/prod/instrumentations/agents/types.js.map +1 -0
  332. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js +38 -0
  333. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
  334. package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js +70 -0
  335. package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
  336. package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +38 -0
  337. package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
  338. package/build/esm/prod/instrumentations/instrumentSqlStorage.js +40 -0
  339. package/build/esm/prod/instrumentations/instrumentSqlStorage.js.map +1 -0
  340. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js +137 -0
  341. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
  342. package/build/esm/prod/instrumentations/worker/instrumentD1.js +159 -0
  343. package/build/esm/prod/instrumentations/worker/instrumentD1.js.map +1 -0
  344. package/build/esm/prod/instrumentations/worker/instrumentEmail.js +61 -0
  345. package/build/esm/prod/instrumentations/worker/instrumentEmail.js.map +1 -0
  346. package/build/esm/prod/instrumentations/worker/instrumentEnv.js +88 -0
  347. package/build/esm/prod/instrumentations/worker/instrumentEnv.js.map +1 -0
  348. package/build/esm/prod/instrumentations/worker/instrumentFetch.js +51 -0
  349. package/build/esm/prod/instrumentations/worker/instrumentFetch.js.map +1 -0
  350. package/build/esm/prod/instrumentations/worker/instrumentFetcher.js +22 -0
  351. package/build/esm/prod/instrumentations/worker/instrumentFetcher.js.map +1 -0
  352. package/build/esm/prod/instrumentations/worker/instrumentQueue.js +79 -0
  353. package/build/esm/prod/instrumentations/worker/instrumentQueue.js.map +1 -0
  354. package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js +78 -0
  355. package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
  356. package/build/esm/prod/instrumentations/worker/instrumentR2.js +122 -0
  357. package/build/esm/prod/instrumentations/worker/instrumentR2.js.map +1 -0
  358. package/build/esm/prod/instrumentations/worker/instrumentRateLimit.js +27 -0
  359. package/build/esm/prod/instrumentations/worker/instrumentRateLimit.js.map +1 -0
  360. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js +75 -0
  361. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js.map +1 -0
  362. package/build/esm/prod/instrumentations/worker/instrumentTail.js +57 -0
  363. package/build/esm/prod/instrumentations/worker/instrumentTail.js.map +1 -0
  364. package/build/esm/prod/integrations/fetch.js +117 -0
  365. package/build/esm/prod/integrations/fetch.js.map +1 -0
  366. package/build/esm/prod/integrations/httpServer.js +33 -0
  367. package/build/esm/prod/integrations/httpServer.js.map +1 -0
  368. package/build/esm/prod/integrations/spotlight.js +61 -0
  369. package/build/esm/prod/integrations/spotlight.js.map +1 -0
  370. package/build/esm/prod/integrations/tracing/vercelai.js +16 -0
  371. package/build/esm/prod/integrations/tracing/vercelai.js.map +1 -0
  372. package/build/esm/prod/opentelemetry/tracer.js +47 -0
  373. package/build/esm/prod/opentelemetry/tracer.js.map +1 -0
  374. package/build/esm/prod/options.js +31 -0
  375. package/build/esm/prod/options.js.map +1 -0
  376. package/build/esm/prod/package.json +1 -0
  377. package/build/esm/prod/pages-plugin.js +22 -0
  378. package/build/esm/prod/pages-plugin.js.map +1 -0
  379. package/build/esm/prod/request.js +129 -0
  380. package/build/esm/prod/request.js.map +1 -0
  381. package/build/esm/prod/scope-utils.js +18 -0
  382. package/build/esm/prod/scope-utils.js.map +1 -0
  383. package/build/esm/prod/sdk.js +16 -0
  384. package/build/esm/prod/sdk.js.map +1 -0
  385. package/build/esm/prod/transport.js +72 -0
  386. package/build/esm/prod/transport.js.map +1 -0
  387. package/build/esm/prod/utils/instrumentContext.js +61 -0
  388. package/build/esm/prod/utils/instrumentContext.js.map +1 -0
  389. package/build/esm/prod/utils/internalSqlQuery.js +23 -0
  390. package/build/esm/prod/utils/internalSqlQuery.js.map +1 -0
  391. package/build/esm/prod/utils/internalStorageKey.js +41 -0
  392. package/build/esm/prod/utils/internalStorageKey.js.map +1 -0
  393. package/build/esm/prod/utils/invocationScope.js +10 -0
  394. package/build/esm/prod/utils/invocationScope.js.map +1 -0
  395. package/build/esm/prod/utils/isBinding.js +29 -0
  396. package/build/esm/prod/utils/isBinding.js.map +1 -0
  397. package/build/esm/prod/utils/isCloudflareClass.js +21 -0
  398. package/build/esm/prod/utils/isCloudflareClass.js.map +1 -0
  399. package/build/esm/prod/utils/rpcMeta.js +35 -0
  400. package/build/esm/prod/utils/rpcMeta.js.map +1 -0
  401. package/build/esm/prod/utils/streaming.js +14 -0
  402. package/build/esm/prod/utils/streaming.js.map +1 -0
  403. package/build/esm/prod/utils/traceLinks.js +49 -0
  404. package/build/esm/prod/utils/traceLinks.js.map +1 -0
  405. package/build/esm/prod/vendor/stacktrace.js +25 -0
  406. package/build/esm/prod/vendor/stacktrace.js.map +1 -0
  407. package/build/esm/prod/vite/agentClass.js +111 -0
  408. package/build/esm/prod/vite/agentClass.js.map +1 -0
  409. package/build/esm/prod/vite/autoInstrument.js +92 -0
  410. package/build/esm/prod/vite/autoInstrument.js.map +1 -0
  411. package/build/esm/prod/vite/index.js +14 -0
  412. package/build/esm/prod/vite/index.js.map +1 -0
  413. package/build/esm/prod/vite/instrumentFile.js +27 -0
  414. package/build/esm/prod/vite/instrumentFile.js.map +1 -0
  415. package/build/esm/prod/vite/moduleShape.js +227 -0
  416. package/build/esm/prod/vite/moduleShape.js.map +1 -0
  417. package/build/esm/prod/vite/transform.js +147 -0
  418. package/build/esm/prod/vite/transform.js.map +1 -0
  419. package/build/esm/prod/vite/workerEntrypoint.js +64 -0
  420. package/build/esm/prod/vite/workerEntrypoint.js.map +1 -0
  421. package/build/esm/prod/vite/wranglerConfig.js +52 -0
  422. package/build/esm/prod/vite/wranglerConfig.js.map +1 -0
  423. package/build/esm/prod/withSentry.js +27 -0
  424. package/build/esm/prod/withSentry.js.map +1 -0
  425. package/build/esm/prod/workflows.js +136 -0
  426. package/build/esm/prod/workflows.js.map +1 -0
  427. package/build/esm/prod/wrapMethodWithSentry.js +132 -0
  428. package/build/esm/prod/wrapMethodWithSentry.js.map +1 -0
  429. package/build/types/baseSdk.d.ts +28 -0
  430. package/build/types/baseSdk.d.ts.map +1 -0
  431. package/build/types/client.d.ts +12 -39
  432. package/build/types/client.d.ts.map +1 -1
  433. package/build/types/defineCloudflareOptions.d.ts +2 -2
  434. package/build/types/defineCloudflareOptions.d.ts.map +1 -1
  435. package/build/types/durableobject.d.ts +22 -12
  436. package/build/types/durableobject.d.ts.map +1 -1
  437. package/build/types/flush.d.ts +1 -1
  438. package/build/types/flush.d.ts.map +1 -1
  439. package/build/types/index.d.ts +3 -5
  440. package/build/types/index.d.ts.map +1 -1
  441. package/build/types/instrumentations/agents/index.d.ts +4 -3
  442. package/build/types/instrumentations/agents/index.d.ts.map +1 -1
  443. package/build/types/instrumentations/agents/instrumentAgentCallableRpc.d.ts +4 -1
  444. package/build/types/instrumentations/agents/instrumentAgentCallableRpc.d.ts.map +1 -1
  445. package/build/types/instrumentations/agents/instrumentAgentRequestConversation.d.ts +16 -0
  446. package/build/types/instrumentations/agents/instrumentAgentRequestConversation.d.ts.map +1 -0
  447. package/build/types/instrumentations/agents/instrumentChatAgentConversation.d.ts +10 -9
  448. package/build/types/instrumentations/agents/instrumentChatAgentConversation.d.ts.map +1 -1
  449. package/build/types/instrumentations/agents/types.d.ts +63 -18
  450. package/build/types/instrumentations/agents/types.d.ts.map +1 -1
  451. package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts.map +1 -1
  452. package/build/types/instrumentations/instrumentSqlStorage.d.ts.map +1 -1
  453. package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts +2 -1
  454. package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts.map +1 -1
  455. package/build/types/instrumentations/worker/instrumentD1.d.ts +0 -16
  456. package/build/types/instrumentations/worker/instrumentD1.d.ts.map +1 -1
  457. package/build/types/instrumentations/worker/instrumentEmail.d.ts +2 -2
  458. package/build/types/instrumentations/worker/instrumentEmail.d.ts.map +1 -1
  459. package/build/types/instrumentations/worker/instrumentEnv.d.ts.map +1 -1
  460. package/build/types/instrumentations/worker/instrumentFetch.d.ts +2 -2
  461. package/build/types/instrumentations/worker/instrumentFetch.d.ts.map +1 -1
  462. package/build/types/instrumentations/worker/instrumentQueue.d.ts +2 -2
  463. package/build/types/instrumentations/worker/instrumentQueue.d.ts.map +1 -1
  464. package/build/types/instrumentations/worker/instrumentScheduled.d.ts +2 -2
  465. package/build/types/instrumentations/worker/instrumentScheduled.d.ts.map +1 -1
  466. package/build/types/instrumentations/worker/instrumentTail.d.ts +2 -2
  467. package/build/types/instrumentations/worker/instrumentTail.d.ts.map +1 -1
  468. package/build/types/integrations/httpServer.d.ts.map +1 -1
  469. package/build/types/integrations/spotlight.d.ts +1 -1
  470. package/build/types/integrations/tracing/vercelai.d.ts +2 -9
  471. package/build/types/integrations/tracing/vercelai.d.ts.map +1 -1
  472. package/build/types/options.d.ts.map +1 -1
  473. package/build/types/pages-plugin.d.ts +1 -1
  474. package/build/types/pages-plugin.d.ts.map +1 -1
  475. package/build/types/request.d.ts +17 -2
  476. package/build/types/request.d.ts.map +1 -1
  477. package/build/types/sdk.d.ts +8 -3
  478. package/build/types/sdk.d.ts.map +1 -1
  479. package/build/types/transport.d.ts.map +1 -1
  480. package/build/types/types.d.ts +85 -0
  481. package/build/types/types.d.ts.map +1 -0
  482. package/build/types/utils/instrumentContext.d.ts.map +1 -1
  483. package/build/types/utils/invocationScope.d.ts +24 -0
  484. package/build/types/utils/invocationScope.d.ts.map +1 -0
  485. package/build/types/utils/isCloudflareClass.d.ts +1 -1
  486. package/build/types/utils/isCloudflareClass.d.ts.map +1 -1
  487. package/build/types/utils/rpcMeta.d.ts +8 -0
  488. package/build/types/utils/rpcMeta.d.ts.map +1 -1
  489. package/build/types/vite/autoInstrument.d.ts.map +1 -1
  490. package/build/types/vite/index.d.ts +20 -44
  491. package/build/types/vite/index.d.ts.map +1 -1
  492. package/build/types/withSentry.d.ts +2 -2
  493. package/build/types/withSentry.d.ts.map +1 -1
  494. package/build/types/workflows.d.ts +5 -4
  495. package/build/types/workflows.d.ts.map +1 -1
  496. package/build/types/wrapMethodWithSentry.d.ts +1 -1
  497. package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
  498. package/package.json +28 -51
  499. package/build/cjs/async.js +0 -63
  500. package/build/cjs/async.js.map +0 -1
  501. package/build/cjs/client.js.map +0 -1
  502. package/build/cjs/debug-build.js.map +0 -1
  503. package/build/cjs/defineCloudflareOptions.js.map +0 -1
  504. package/build/cjs/durableobject.js +0 -155
  505. package/build/cjs/durableobject.js.map +0 -1
  506. package/build/cjs/flush.js.map +0 -1
  507. package/build/cjs/instrument.js.map +0 -1
  508. package/build/cjs/instrumentations/agents/index.js.map +0 -1
  509. package/build/cjs/instrumentations/agents/instrumentAgentCallableRpc.js.map +0 -1
  510. package/build/cjs/instrumentations/agents/instrumentChatAgentConversation.js.map +0 -1
  511. package/build/cjs/instrumentations/agents/types.js +0 -32
  512. package/build/cjs/instrumentations/agents/types.js.map +0 -1
  513. package/build/cjs/instrumentations/instrumentDurableObjectNamespace.js.map +0 -1
  514. package/build/cjs/instrumentations/instrumentDurableObjectStorage.js.map +0 -1
  515. package/build/cjs/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +0 -1
  516. package/build/cjs/instrumentations/instrumentSqlStorage.js.map +0 -1
  517. package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js.map +0 -1
  518. package/build/cjs/instrumentations/worker/instrumentD1.js.map +0 -1
  519. package/build/cjs/instrumentations/worker/instrumentEmail.js.map +0 -1
  520. package/build/cjs/instrumentations/worker/instrumentEnv.js.map +0 -1
  521. package/build/cjs/instrumentations/worker/instrumentFetch.js.map +0 -1
  522. package/build/cjs/instrumentations/worker/instrumentFetcher.js.map +0 -1
  523. package/build/cjs/instrumentations/worker/instrumentQueue.js.map +0 -1
  524. package/build/cjs/instrumentations/worker/instrumentQueueProducer.js.map +0 -1
  525. package/build/cjs/instrumentations/worker/instrumentR2.js.map +0 -1
  526. package/build/cjs/instrumentations/worker/instrumentRateLimit.js.map +0 -1
  527. package/build/cjs/instrumentations/worker/instrumentScheduled.js.map +0 -1
  528. package/build/cjs/instrumentations/worker/instrumentTail.js.map +0 -1
  529. package/build/cjs/integrations/fetch.js.map +0 -1
  530. package/build/cjs/integrations/hono.js +0 -52
  531. package/build/cjs/integrations/hono.js.map +0 -1
  532. package/build/cjs/integrations/httpServer.js.map +0 -1
  533. package/build/cjs/integrations/spotlight.js.map +0 -1
  534. package/build/cjs/integrations/tracing/vercelai.js.map +0 -1
  535. package/build/cjs/nodejs_compat/integrations/tracing/vercelai.js.map +0 -1
  536. package/build/cjs/opentelemetry/tracer.js.map +0 -1
  537. package/build/cjs/options.js.map +0 -1
  538. package/build/cjs/pages-plugin.js.map +0 -1
  539. package/build/cjs/request.js.map +0 -1
  540. package/build/cjs/scope-utils.js.map +0 -1
  541. package/build/cjs/sdk.js.map +0 -1
  542. package/build/cjs/transport.js.map +0 -1
  543. package/build/cjs/utils/instrumentContext.js.map +0 -1
  544. package/build/cjs/utils/internalSqlQuery.js.map +0 -1
  545. package/build/cjs/utils/internalStorageKey.js.map +0 -1
  546. package/build/cjs/utils/isBinding.js.map +0 -1
  547. package/build/cjs/utils/isCloudflareClass.js.map +0 -1
  548. package/build/cjs/utils/rpcMeta.js.map +0 -1
  549. package/build/cjs/utils/rpcOptions.js +0 -26
  550. package/build/cjs/utils/rpcOptions.js.map +0 -1
  551. package/build/cjs/utils/streaming.js.map +0 -1
  552. package/build/cjs/utils/traceLinks.js.map +0 -1
  553. package/build/cjs/vendor/stacktrace.js.map +0 -1
  554. package/build/cjs/vite/agentClass.js.map +0 -1
  555. package/build/cjs/vite/autoInstrument.js.map +0 -1
  556. package/build/cjs/vite/index.js.map +0 -1
  557. package/build/cjs/vite/instrumentFile.js.map +0 -1
  558. package/build/cjs/vite/moduleShape.js.map +0 -1
  559. package/build/cjs/vite/transform.js.map +0 -1
  560. package/build/cjs/vite/workerEntrypoint.js.map +0 -1
  561. package/build/cjs/vite/wranglerConfig.js.map +0 -1
  562. package/build/cjs/withSentry.js.map +0 -1
  563. package/build/cjs/workflows.js.map +0 -1
  564. package/build/cjs/wrapMethodWithSentry.js.map +0 -1
  565. package/build/esm/async.js +0 -61
  566. package/build/esm/async.js.map +0 -1
  567. package/build/esm/client.js.map +0 -1
  568. package/build/esm/debug-build.js.map +0 -1
  569. package/build/esm/defineCloudflareOptions.js.map +0 -1
  570. package/build/esm/durableobject.js +0 -150
  571. package/build/esm/durableobject.js.map +0 -1
  572. package/build/esm/flush.js.map +0 -1
  573. package/build/esm/index.js +0 -17
  574. package/build/esm/instrument.js.map +0 -1
  575. package/build/esm/instrumentations/agents/index.js.map +0 -1
  576. package/build/esm/instrumentations/agents/instrumentAgentCallableRpc.js.map +0 -1
  577. package/build/esm/instrumentations/agents/instrumentChatAgentConversation.js.map +0 -1
  578. package/build/esm/instrumentations/agents/types.js +0 -26
  579. package/build/esm/instrumentations/agents/types.js.map +0 -1
  580. package/build/esm/instrumentations/instrumentDurableObjectNamespace.js.map +0 -1
  581. package/build/esm/instrumentations/instrumentDurableObjectStorage.js.map +0 -1
  582. package/build/esm/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +0 -1
  583. package/build/esm/instrumentations/instrumentSqlStorage.js.map +0 -1
  584. package/build/esm/instrumentations/instrumentWorkerEntrypoint.js.map +0 -1
  585. package/build/esm/instrumentations/worker/instrumentD1.js.map +0 -1
  586. package/build/esm/instrumentations/worker/instrumentEmail.js.map +0 -1
  587. package/build/esm/instrumentations/worker/instrumentEnv.js.map +0 -1
  588. package/build/esm/instrumentations/worker/instrumentFetch.js.map +0 -1
  589. package/build/esm/instrumentations/worker/instrumentFetcher.js.map +0 -1
  590. package/build/esm/instrumentations/worker/instrumentQueue.js.map +0 -1
  591. package/build/esm/instrumentations/worker/instrumentQueueProducer.js.map +0 -1
  592. package/build/esm/instrumentations/worker/instrumentR2.js.map +0 -1
  593. package/build/esm/instrumentations/worker/instrumentRateLimit.js.map +0 -1
  594. package/build/esm/instrumentations/worker/instrumentScheduled.js.map +0 -1
  595. package/build/esm/instrumentations/worker/instrumentTail.js.map +0 -1
  596. package/build/esm/integrations/fetch.js.map +0 -1
  597. package/build/esm/integrations/hono.js +0 -49
  598. package/build/esm/integrations/hono.js.map +0 -1
  599. package/build/esm/integrations/httpServer.js.map +0 -1
  600. package/build/esm/integrations/spotlight.js.map +0 -1
  601. package/build/esm/integrations/tracing/vercelai.js.map +0 -1
  602. package/build/esm/nodejs_compat/index.js +0 -18
  603. package/build/esm/nodejs_compat/integrations/tracing/vercelai.js +0 -16
  604. package/build/esm/nodejs_compat/integrations/tracing/vercelai.js.map +0 -1
  605. package/build/esm/opentelemetry/tracer.js.map +0 -1
  606. package/build/esm/options.js.map +0 -1
  607. package/build/esm/package.json +0 -1
  608. package/build/esm/pages-plugin.js.map +0 -1
  609. package/build/esm/request.js.map +0 -1
  610. package/build/esm/scope-utils.js.map +0 -1
  611. package/build/esm/sdk.js.map +0 -1
  612. package/build/esm/transport.js.map +0 -1
  613. package/build/esm/utils/instrumentContext.js.map +0 -1
  614. package/build/esm/utils/internalSqlQuery.js.map +0 -1
  615. package/build/esm/utils/internalStorageKey.js.map +0 -1
  616. package/build/esm/utils/isBinding.js.map +0 -1
  617. package/build/esm/utils/isCloudflareClass.js.map +0 -1
  618. package/build/esm/utils/rpcMeta.js.map +0 -1
  619. package/build/esm/utils/rpcOptions.js +0 -24
  620. package/build/esm/utils/rpcOptions.js.map +0 -1
  621. package/build/esm/utils/streaming.js.map +0 -1
  622. package/build/esm/utils/traceLinks.js.map +0 -1
  623. package/build/esm/vendor/stacktrace.js.map +0 -1
  624. package/build/esm/vite/agentClass.js.map +0 -1
  625. package/build/esm/vite/autoInstrument.js.map +0 -1
  626. package/build/esm/vite/index.js.map +0 -1
  627. package/build/esm/vite/instrumentFile.js.map +0 -1
  628. package/build/esm/vite/moduleShape.js.map +0 -1
  629. package/build/esm/vite/transform.js.map +0 -1
  630. package/build/esm/vite/workerEntrypoint.js.map +0 -1
  631. package/build/esm/vite/wranglerConfig.js.map +0 -1
  632. package/build/esm/withSentry.js.map +0 -1
  633. package/build/esm/workflows.js.map +0 -1
  634. package/build/esm/wrapMethodWithSentry.js.map +0 -1
  635. package/build/types/async.d.ts +0 -11
  636. package/build/types/async.d.ts.map +0 -1
  637. package/build/types/integrations/hono.d.ts +0 -42
  638. package/build/types/integrations/hono.d.ts.map +0 -1
  639. package/build/types/nodejs_compat/index.d.ts +0 -4
  640. package/build/types/nodejs_compat/index.d.ts.map +0 -1
  641. package/build/types/nodejs_compat/integrations/tracing/vercelai.d.ts +0 -37
  642. package/build/types/nodejs_compat/integrations/tracing/vercelai.d.ts.map +0 -1
  643. package/build/types/utils/rpcOptions.d.ts +0 -13
  644. package/build/types/utils/rpcOptions.d.ts.map +0 -1
  645. package/build/types-ts3.8/async.d.ts +0 -11
  646. package/build/types-ts3.8/client.d.ts +0 -203
  647. package/build/types-ts3.8/debug-build.d.ts +0 -7
  648. package/build/types-ts3.8/defineCloudflareOptions.d.ts +0 -38
  649. package/build/types-ts3.8/durableobject.d.ts +0 -118
  650. package/build/types-ts3.8/executionContext.d.ts +0 -13
  651. package/build/types-ts3.8/flush.d.ts +0 -47
  652. package/build/types-ts3.8/index.d.ts +0 -19
  653. package/build/types-ts3.8/instrument.d.ts +0 -20
  654. package/build/types-ts3.8/instrumentations/agents/index.d.ts +0 -24
  655. package/build/types-ts3.8/instrumentations/agents/instrumentAgentCallableRpc.d.ts +0 -11
  656. package/build/types-ts3.8/instrumentations/agents/instrumentChatAgentConversation.d.ts +0 -22
  657. package/build/types-ts3.8/instrumentations/agents/types.d.ts +0 -49
  658. package/build/types-ts3.8/instrumentations/instrumentDurableObjectNamespace.d.ts +0 -13
  659. package/build/types-ts3.8/instrumentations/instrumentDurableObjectStorage.d.ts +0 -19
  660. package/build/types-ts3.8/instrumentations/instrumentDurableObjectSyncKvStorage.d.ts +0 -3
  661. package/build/types-ts3.8/instrumentations/instrumentSqlStorage.d.ts +0 -9
  662. package/build/types-ts3.8/instrumentations/instrumentWorkerEntrypoint.d.ts +0 -42
  663. package/build/types-ts3.8/instrumentations/worker/instrumentD1.d.ts +0 -19
  664. package/build/types-ts3.8/instrumentations/worker/instrumentEmail.d.ts +0 -8
  665. package/build/types-ts3.8/instrumentations/worker/instrumentEnv.d.ts +0 -18
  666. package/build/types-ts3.8/instrumentations/worker/instrumentFetch.d.ts +0 -12
  667. package/build/types-ts3.8/instrumentations/worker/instrumentFetcher.d.ts +0 -10
  668. package/build/types-ts3.8/instrumentations/worker/instrumentQueue.d.ts +0 -12
  669. package/build/types-ts3.8/instrumentations/worker/instrumentQueueProducer.d.ts +0 -10
  670. package/build/types-ts3.8/instrumentations/worker/instrumentR2.d.ts +0 -9
  671. package/build/types-ts3.8/instrumentations/worker/instrumentRateLimit.d.ts +0 -6
  672. package/build/types-ts3.8/instrumentations/worker/instrumentScheduled.d.ts +0 -12
  673. package/build/types-ts3.8/instrumentations/worker/instrumentTail.d.ts +0 -12
  674. package/build/types-ts3.8/integrations/fetch.d.ts +0 -19
  675. package/build/types-ts3.8/integrations/hono.d.ts +0 -42
  676. package/build/types-ts3.8/integrations/httpServer.d.ts +0 -63
  677. package/build/types-ts3.8/integrations/spotlight.d.ts +0 -22
  678. package/build/types-ts3.8/integrations/tracing/vercelai.d.ts +0 -47
  679. package/build/types-ts3.8/nodejs_compat/index.d.ts +0 -4
  680. package/build/types-ts3.8/nodejs_compat/integrations/tracing/vercelai.d.ts +0 -37
  681. package/build/types-ts3.8/opentelemetry/tracer.d.ts +0 -6
  682. package/build/types-ts3.8/options.d.ts +0 -17
  683. package/build/types-ts3.8/pages-plugin.d.ts +0 -34
  684. package/build/types-ts3.8/request.d.ts +0 -25
  685. package/build/types-ts3.8/scope-utils.d.ts +0 -15
  686. package/build/types-ts3.8/sdk.d.ts +0 -10
  687. package/build/types-ts3.8/transport.d.ts +0 -34
  688. package/build/types-ts3.8/utils/instrumentContext.d.ts +0 -16
  689. package/build/types-ts3.8/utils/internalSqlQuery.d.ts +0 -20
  690. package/build/types-ts3.8/utils/internalStorageKey.d.ts +0 -22
  691. package/build/types-ts3.8/utils/isBinding.d.ts +0 -77
  692. package/build/types-ts3.8/utils/isCloudflareClass.d.ts +0 -30
  693. package/build/types-ts3.8/utils/rpcMeta.d.ts +0 -15
  694. package/build/types-ts3.8/utils/rpcOptions.d.ts +0 -13
  695. package/build/types-ts3.8/utils/streaming.d.ts +0 -17
  696. package/build/types-ts3.8/utils/traceLinks.d.ts +0 -28
  697. package/build/types-ts3.8/vendor/stacktrace.d.ts +0 -11
  698. package/build/types-ts3.8/vite/agentClass.d.ts +0 -41
  699. package/build/types-ts3.8/vite/autoInstrument.d.ts +0 -22
  700. package/build/types-ts3.8/vite/index.d.ts +0 -98
  701. package/build/types-ts3.8/vite/instrumentFile.d.ts +0 -22
  702. package/build/types-ts3.8/vite/moduleShape.d.ts +0 -52
  703. package/build/types-ts3.8/vite/transform.d.ts +0 -65
  704. package/build/types-ts3.8/vite/workerEntrypoint.d.ts +0 -12
  705. package/build/types-ts3.8/vite/wranglerConfig.d.ts +0 -43
  706. package/build/types-ts3.8/withSentry.d.ts +0 -16
  707. package/build/types-ts3.8/workflows.d.ts +0 -25
  708. package/build/types-ts3.8/wrapMethodWithSentry.d.ts +0 -43
  709. /package/build/cjs/{client.js → dev/client.js} +0 -0
  710. /package/build/cjs/{debug-build.js → dev/debug-build.js} +0 -0
  711. /package/build/cjs/{defineCloudflareOptions.js → dev/defineCloudflareOptions.js} +0 -0
  712. /package/build/cjs/{flush.js → dev/flush.js} +0 -0
  713. /package/build/cjs/{instrument.js → dev/instrument.js} +0 -0
  714. /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentDurableObjectNamespace.js +0 -0
  715. /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentDurableObjectStorage.js +0 -0
  716. /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentDurableObjectSyncKvStorage.js +0 -0
  717. /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentSqlStorage.js +0 -0
  718. /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentFetcher.js +0 -0
  719. /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentQueueProducer.js +0 -0
  720. /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentR2.js +0 -0
  721. /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentRateLimit.js +0 -0
  722. /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentTail.js +0 -0
  723. /package/build/cjs/{integrations → dev/integrations}/spotlight.js +0 -0
  724. /package/build/cjs/{opentelemetry → dev/opentelemetry}/tracer.js +0 -0
  725. /package/build/cjs/{scope-utils.js → dev/scope-utils.js} +0 -0
  726. /package/build/cjs/{transport.js → dev/transport.js} +0 -0
  727. /package/build/cjs/{utils → dev/utils}/internalSqlQuery.js +0 -0
  728. /package/build/cjs/{utils → dev/utils}/internalStorageKey.js +0 -0
  729. /package/build/cjs/{utils → dev/utils}/isBinding.js +0 -0
  730. /package/build/cjs/{utils → dev/utils}/isCloudflareClass.js +0 -0
  731. /package/build/cjs/{utils → dev/utils}/streaming.js +0 -0
  732. /package/build/cjs/{utils → dev/utils}/traceLinks.js +0 -0
  733. /package/build/cjs/{vendor → dev/vendor}/stacktrace.js +0 -0
  734. /package/build/cjs/{vite → dev/vite}/agentClass.js +0 -0
  735. /package/build/cjs/{vite → dev/vite}/autoInstrument.js +0 -0
  736. /package/build/cjs/{vite → dev/vite}/instrumentFile.js +0 -0
  737. /package/build/cjs/{vite → dev/vite}/moduleShape.js +0 -0
  738. /package/build/cjs/{vite → dev/vite}/transform.js +0 -0
  739. /package/build/cjs/{vite → dev/vite}/workerEntrypoint.js +0 -0
  740. /package/build/cjs/{vite → dev/vite}/wranglerConfig.js +0 -0
  741. /package/build/esm/{client.js → dev/client.js} +0 -0
  742. /package/build/esm/{debug-build.js → dev/debug-build.js} +0 -0
  743. /package/build/esm/{defineCloudflareOptions.js → dev/defineCloudflareOptions.js} +0 -0
  744. /package/build/esm/{flush.js → dev/flush.js} +0 -0
  745. /package/build/esm/{instrument.js → dev/instrument.js} +0 -0
  746. /package/build/esm/{instrumentations → dev/instrumentations}/instrumentDurableObjectNamespace.js +0 -0
  747. /package/build/esm/{instrumentations → dev/instrumentations}/instrumentDurableObjectStorage.js +0 -0
  748. /package/build/esm/{instrumentations → dev/instrumentations}/instrumentDurableObjectSyncKvStorage.js +0 -0
  749. /package/build/esm/{instrumentations → dev/instrumentations}/instrumentSqlStorage.js +0 -0
  750. /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentFetcher.js +0 -0
  751. /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentQueueProducer.js +0 -0
  752. /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentR2.js +0 -0
  753. /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentRateLimit.js +0 -0
  754. /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentTail.js +0 -0
  755. /package/build/esm/{integrations → dev/integrations}/spotlight.js +0 -0
  756. /package/build/esm/{opentelemetry → dev/opentelemetry}/tracer.js +0 -0
  757. /package/build/esm/{scope-utils.js → dev/scope-utils.js} +0 -0
  758. /package/build/esm/{transport.js → dev/transport.js} +0 -0
  759. /package/build/esm/{utils → dev/utils}/internalSqlQuery.js +0 -0
  760. /package/build/esm/{utils → dev/utils}/internalStorageKey.js +0 -0
  761. /package/build/esm/{utils → dev/utils}/isBinding.js +0 -0
  762. /package/build/esm/{utils → dev/utils}/isCloudflareClass.js +0 -0
  763. /package/build/esm/{utils → dev/utils}/streaming.js +0 -0
  764. /package/build/esm/{vendor → dev/vendor}/stacktrace.js +0 -0
  765. /package/build/esm/{vite → dev/vite}/agentClass.js +0 -0
  766. /package/build/esm/{vite → dev/vite}/autoInstrument.js +0 -0
  767. /package/build/esm/{vite → dev/vite}/instrumentFile.js +0 -0
  768. /package/build/esm/{vite → dev/vite}/moduleShape.js +0 -0
  769. /package/build/esm/{vite → dev/vite}/transform.js +0 -0
  770. /package/build/esm/{vite → dev/vite}/workerEntrypoint.js +0 -0
  771. /package/build/esm/{vite → dev/vite}/wranglerConfig.js +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport {\n consoleIntegration,\n conversationIdIntegration,\n dedupeIntegration,\n functionToStringIntegration,\n getIntegrationsToSetup,\n GLOBAL_OBJ,\n inboundFiltersIntegration,\n initAndBind,\n linkedErrorsIntegration,\n requestDataIntegration,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport type { CloudflareClientOptions, CloudflareOptions } from './client';\nimport { CloudflareClient } from './client';\nimport { makeFlushLock } from './flush';\nimport { httpServerIntegration } from './integrations/httpServer';\nimport { fetchIntegration } from './integrations/fetch';\nimport { honoIntegration } from './integrations/hono';\nimport { INTEGRATION_NAME as SPOTLIGHT_INTEGRATION_NAME, spotlightIntegration } from './integrations/spotlight';\nimport { setupOpenTelemetryTracer } from './opentelemetry/tracer';\nimport { makeCloudflareTransport } from './transport';\nimport { defaultStackParser } from './vendor/stacktrace';\n\n/**\n * Instantiate the channel-subscriber factories the `@sentry/cloudflare/vite`\n * plugin registered on the global marker. The plugin splices a small snippet\n * into each instrumented module that `.set`s its factory here (keyed by export\n * name), so the marker holds one factory per package actually bundled.\n *\n * The marker is read directly instead of importing the factories, so a worker\n * built without the plugin — where the channels never fire — ships none of this\n * code.\n * TODO(v11): Use `@sentry/server-utils/orchestrion` once we move to `nodejs_compat` by default.\n */\nfunction getRegisteredChannelIntegrations(): Integration[] {\n const registered = GLOBAL_OBJ.__SENTRY_ORCHESTRION__?.integrations;\n\n return registered ? [...registered.values()].map(factory => factory()) : [];\n}\n\n/** Get the default integrations for the Cloudflare SDK. */\nexport function getDefaultIntegrations(options: CloudflareOptions): Integration[] {\n // TODO(v11): Drop this transitional gating and let `requestDataIntegration` rely on the resolved\n // `dataCollection` defaults directly. Until then, preserve the historical Cloudflare behavior of not\n // attaching cookies unless the user explicitly opts in via `sendDefaultPii` or `dataCollection.cookies`.\n // eslint-disable-next-line typescript/no-deprecated\n const cookiesEnabled = options.sendDefaultPii || options.dataCollection?.cookies != null;\n return [\n // The Dedupe integration should not be used in workflows because we want to\n // capture all step failures, even if they are the same error.\n ...(options.enableDedupe === false ? [] : [dedupeIntegration()]),\n // TODO(v11): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n // eslint-disable-next-line typescript/no-deprecated\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n conversationIdIntegration(),\n linkedErrorsIntegration(),\n fetchIntegration(),\n // eslint-disable-next-line typescript/no-deprecated\n honoIntegration(),\n httpServerIntegration(),\n requestDataIntegration(cookiesEnabled ? undefined : { include: { cookies: false } }),\n consoleIntegration(),\n // The orchestrion diagnostics-channel subscribers (mysql, pg, …). The\n // `@sentry/cloudflare/vite` plugin injects the channels at build time and,\n // next to each, a snippet that registers the matching subscriber factory on\n // the global marker. Read from there instead of importing them so bundles\n // built without the plugin — where the channels would never fire — don't\n // ship the code.\n ...getRegisteredChannelIntegrations(),\n ];\n}\n\n/**\n * Initializes the cloudflare SDK.\n */\nexport function init(options: CloudflareOptions): CloudflareClient | undefined {\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = getDefaultIntegrations(options);\n }\n\n const flushLock = options.ctx ? makeFlushLock(options.ctx) : undefined;\n delete options.ctx;\n\n const clientOptions: CloudflareClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: getIntegrationsToSetup(options),\n transport: options.transport || makeCloudflareTransport,\n flushLock,\n };\n\n if (options.spotlight && !clientOptions.integrations.some(({ name }) => name === SPOTLIGHT_INTEGRATION_NAME)) {\n clientOptions.integrations.push(\n spotlightIntegration({\n sidecarUrl: typeof options.spotlight === 'string' ? options.spotlight : undefined,\n }),\n );\n }\n\n /**\n * The Cloudflare SDK is not OpenTelemetry native, however, we set up some OpenTelemetry compatibility\n * via a custom trace provider.\n * This ensures that any spans emitted via `@opentelemetry/api` will be captured by Sentry.\n * HOWEVER, big caveat: This does not handle custom context handling, it will always work off the current scope.\n * This should be good enough for many, but not all integrations.\n */\n if (!options.skipOpenTelemetrySetup) {\n setupOpenTelemetryTracer();\n }\n\n return initAndBind(CloudflareClient, clientOptions) as CloudflareClient;\n}\n"],"names":["SPOTLIGHT_INTEGRATION_NAME"],"mappings":";;;;;;;;;;;AAoCA,SAAS,gCAAA,GAAkD;AACzD,EAAA,MAAM,UAAA,GAAa,WAAW,sBAAA,EAAwB,YAAA;AAEtD,EAAA,OAAO,UAAA,GAAa,CAAC,GAAG,UAAA,CAAW,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,CAAA,OAAA,KAAW,OAAA,EAAS,CAAA,GAAI,EAAC;AAC5E;AAGO,SAAS,uBAAuB,OAAA,EAA2C;AAKhF,EAAA,MAAM,cAAA,GAAiB,OAAA,CAAQ,cAAA,IAAkB,OAAA,CAAQ,gBAAgB,OAAA,IAAW,IAAA;AACpF,EAAA,OAAO;AAAA;AAAA;AAAA,IAGL,GAAI,QAAQ,YAAA,KAAiB,KAAA,GAAQ,EAAC,GAAI,CAAC,mBAAmB,CAAA;AAAA;AAAA;AAAA,IAG9D,yBAAA,EAA0B;AAAA,IAC1B,2BAAA,EAA4B;AAAA,IAC5B,yBAAA,EAA0B;AAAA,IAC1B,uBAAA,EAAwB;AAAA,IACxB,gBAAA,EAAiB;AAAA;AAAA,IAEjB,eA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A,CAAY,kBAAkB,aAAa,CAAA;AACpD;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"transport.js","sources":["../../src/transport.ts"],"sourcesContent":["import type { BaseTransportOptions, Transport, TransportMakeRequestResponse, TransportRequest } from '@sentry/core';\nimport { createTransport, SENTRY_BUFFER_FULL_ERROR, suppressTracing } from '@sentry/core';\n\nexport interface CloudflareTransportOptions extends BaseTransportOptions {\n /** Custom fetch function to use. This allows usage of things like Workers VPC */\n fetch?: typeof fetch;\n /** Fetch API init parameters. */\n fetchOptions?: RequestInit;\n}\n\nconst DEFAULT_TRANSPORT_BUFFER_SIZE = 30;\n\n/**\n * This is a modified promise buffer that collects tasks until drain is called.\n * We need this in the edge runtime because edge function invocations may not share I/O objects, like fetch requests\n * and responses, and the normal PromiseBuffer inherently buffers stuff inbetween incoming requests.\n *\n * A limitation we need to be aware of is that DEFAULT_TRANSPORT_BUFFER_SIZE is the maximum amount of payloads the\n * SDK can send for a given edge function invocation.\n */\nexport class IsolatedPromiseBuffer {\n // We just have this field because the promise buffer interface requires it.\n // If we ever remove it from the interface we should also remove it here.\n public $: Array<PromiseLike<TransportMakeRequestResponse>>;\n\n private _taskProducers: (() => PromiseLike<TransportMakeRequestResponse>)[];\n\n private readonly _bufferSize: number;\n\n public constructor(_bufferSize = DEFAULT_TRANSPORT_BUFFER_SIZE) {\n this.$ = [];\n this._taskProducers = [];\n this._bufferSize = _bufferSize;\n }\n\n /**\n * @inheritdoc\n */\n public add(taskProducer: () => PromiseLike<TransportMakeRequestResponse>): PromiseLike<TransportMakeRequestResponse> {\n if (this._taskProducers.length >= this._bufferSize) {\n return Promise.reject(SENTRY_BUFFER_FULL_ERROR);\n }\n\n this._taskProducers.push(taskProducer);\n return Promise.resolve({});\n }\n\n /**\n * @inheritdoc\n */\n public drain(timeout?: number): PromiseLike<boolean> {\n const oldTaskProducers = [...this._taskProducers];\n this._taskProducers = [];\n\n return new Promise(resolve => {\n const timer = setTimeout(() => {\n if (timeout && timeout > 0) {\n resolve(false);\n }\n }, timeout);\n\n // This cannot reject\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.all(\n oldTaskProducers.map(taskProducer =>\n taskProducer().then(null, () => {\n // catch all failed requests\n }),\n ),\n ).then(() => {\n // resolve to true if all fetch requests settled\n clearTimeout(timer);\n resolve(true);\n });\n });\n }\n}\n\n/**\n * Creates a Transport that uses the native fetch API to send events to Sentry.\n */\nexport function makeCloudflareTransport(options: CloudflareTransportOptions): Transport {\n function makeRequest(request: TransportRequest): PromiseLike<TransportMakeRequestResponse> {\n const requestOptions: RequestInit = {\n body: request.body,\n method: 'POST',\n headers: options.headers,\n ...options.fetchOptions,\n };\n\n return suppressTracing(() => {\n return (options.fetch ?? fetch)(options.url, requestOptions).then(async response => {\n // Consume the response body to satisfy Cloudflare Workers' fetch requirements.\n // The runtime requires all fetch response bodies to be read or explicitly canceled\n // to prevent connection stalls and potential deadlocks. We read the body as text\n // even though we don't use the content, as Sentry's response information is in the headers.\n // See: https://github.com/getsentry/sentry-javascript/issues/18534\n try {\n await response.text();\n } catch {\n // no-op\n }\n\n return {\n statusCode: response.status,\n headers: {\n 'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),\n 'retry-after': response.headers.get('Retry-After'),\n },\n };\n });\n });\n }\n\n return createTransport(options, makeRequest, new IsolatedPromiseBuffer(options.bufferSize));\n}\n"],"names":[],"mappings":";;AAUA,MAAM,6BAAA,GAAgC,EAAA;AAU/B,MAAM,qBAAA,CAAsB;AAAA,EAS1B,WAAA,CAAY,cAAc,6BAAA,EAA+B;AAC9D,IAAA,IAAA,CAAK,IAAI,EAAC;AACV,IAAA,IAAA,CAAK,iBAAiB,EAAC;AACvB,IAAA,IAAA,CAAK,WAAA,GAAc,WAAA;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA,EAKO,IAAI,YAAA,EAA0G;AACnH,IAAA,IAAI,IAAA,CAAK,cAAA,CAAe,MAAA,IAAU,IAAA,CAAK,WAAA,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,OAAA,CAAQ,KAAK,cAAc,CAAA,CAAE,IAAA,CAAK,OAAM,QAAA,KAAY;AAMlF,QAAA,IAAI;AACF,UAAA,MAAM,SAAS,IAAA,EAAK;AAAA,QACtB,CAAA,CAAA,MAAQ;AAAA,QAER;AAEA,QAAA,OAAO;AAAA,UACL,YAAY,QAAA,CAAS,MAAA;AAAA,UACrB,OAAA,EAAS;AAAA,YACP,sBAAA,EAAwB,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,sBAAsB,CAAA;AAAA,YACnE,aAAA,EAAe,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,aAAa;AAAA;AACnD,SACF;AAAA,MACF,CAAC,CAAA;AAAA,IACH,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,OAAO,gBAAgB,OAAA,EAAS,WAAA,EAAa,IAAI,qBAAA,CAAsB,OAAA,CAAQ,UAAU,CAAC,CAAA;AAC5F;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"instrumentContext.js","sources":["../../../src/utils/instrumentContext.ts"],"sourcesContent":["import { type DurableObjectState, type DurableObjectStorage, type ExecutionContext } from '@cloudflare/workers-types';\nimport { instrumentDurableObjectStorage } from '../instrumentations/instrumentDurableObjectStorage';\n\ntype ContextType = ExecutionContext | DurableObjectState;\ntype OverridesStore<T extends ContextType> = Map<keyof T, (...args: unknown[]) => unknown>;\n\n/**\n * Instruments an execution context or DurableObjectState with Sentry tracing.\n *\n * Creates a copy of the context that:\n * - Allows overriding of methods (e.g., waitUntil)\n * - For DurableObjectState: instruments storage operations (get, put, delete, list, etc.)\n * to create Sentry spans automatically\n *\n * @param ctx - The execution context or DurableObjectState to instrument\n * @returns An instrumented copy of the context\n */\nexport function instrumentContext<T extends ContextType>(ctx: T): T {\n if (!ctx) return ctx;\n\n const overrides: OverridesStore<T> = new Map();\n const contextPrototype = Object.getPrototypeOf(ctx);\n const prototypeMethodNames = Object.getOwnPropertyNames(contextPrototype) as unknown as (keyof T)[];\n const ownPropertyNames = Object.getOwnPropertyNames(ctx) as unknown as (keyof T)[];\n const instrumented = new Set<unknown>(['constructor']);\n const descriptors: PropertyDescriptorMap = [...ownPropertyNames, ...prototypeMethodNames].reduce(\n (prevDescriptors, methodName) => {\n if (instrumented.has(methodName)) return prevDescriptors;\n if (typeof ctx[methodName] !== 'function') return prevDescriptors;\n instrumented.add(methodName);\n const overridableDescriptor = makeOverridableDescriptor(overrides, ctx, methodName);\n return {\n ...prevDescriptors,\n [methodName]: overridableDescriptor,\n };\n },\n {} as PropertyDescriptorMap,\n );\n\n // Check if this is a DurableObjectState context with a storage property\n // If so, wrap the storage with instrumentation\n if ('storage' in ctx && ctx.storage) {\n const originalStorage = ctx.storage;\n const waitUntil = 'waitUntil' in ctx && typeof ctx.waitUntil === 'function' ? ctx.waitUntil.bind(ctx) : undefined;\n let instrumentedStorage: DurableObjectStorage | undefined;\n descriptors.storage = {\n configurable: true,\n enumerable: true,\n get: () => {\n if (!instrumentedStorage) {\n instrumentedStorage = instrumentDurableObjectStorage(originalStorage, waitUntil);\n }\n return instrumentedStorage;\n },\n };\n // Expose the original uninstrumented storage for internal Sentry operations\n // This avoids creating spans for internal storage operations\n descriptors.originalStorage = {\n configurable: true,\n enumerable: false,\n get: () => originalStorage,\n };\n }\n\n return Object.create(ctx, descriptors);\n}\n\n/**\n * Creates a property descriptor that allows overriding of a method on the given context object.\n *\n * This descriptor supports property overriding with functions only. It delegates method calls to\n * the provided store if an override exists or to the original method on the context otherwise.\n *\n * @param {OverridesStore<ContextType>} store - The storage for overridden methods specific to the context type.\n * @param {ContextType} ctx - The context object that contains the method to be overridden.\n * @param {keyof ContextType} method - The method on the context object to create the overridable descriptor for.\n * @return {PropertyDescriptor} A property descriptor enabling the overriding of the specified method.\n */\nfunction makeOverridableDescriptor<T extends ContextType>(\n store: OverridesStore<T>,\n ctx: T,\n method: keyof T,\n): PropertyDescriptor {\n return {\n configurable: true,\n enumerable: true,\n set: newValue => {\n if (typeof newValue == 'function') {\n store.set(method, newValue);\n return;\n }\n Reflect.set(ctx, method, newValue);\n },\n\n get: () => {\n if (store.has(method)) return store.get(method);\n const methodFunction = Reflect.get(ctx, method);\n if (typeof methodFunction !== 'function') return methodFunction;\n // We should do bind() to make sure that the method is bound to the context object - otherwise it will not work\n return methodFunction.bind(ctx);\n },\n };\n}\n"],"names":[],"mappings":";;AAiBO,SAAS,kBAAyC,GAAA,EAAW;AAClE,EAAA,IAAI,CAAC,KAAK,OAAO,GAAA;AAEjB,EAAA,MAAM,SAAA,uBAAmC,GAAA,EAAI;AAC7C,EAAA,MAAM,gBAAA,GAAmB,MAAA,CAAO,cAAA,CAAe,GAAG,CAAA;AAClD,EAAA,MAAM,oBAAA,GAAuB,MAAA,CAAO,mBAAA,CAAoB,gBAAgB,CAAA;AACxE,EAAA,MAAM,gBAAA,GAAmB,MAAA,CAAO,mBAAA,CAAoB,GAAG,CAAA;AACvD,EAAA,MAAM,YAAA,mBAAe,IAAI,GAAA,CAAa,CAAC,aAAa,CAAC,CAAA;AACrD,EAAA,MAAM,cAAqC,CAAC,GAAG,gBAAA,EAAkB,GAAG,oBAAoB,CAAA,CAAE,MAAA;AAAA,IACxF,CAAC,iBAAiB,UAAA,KAAe;AAC/B,MAAA,IAAI,YAAA,CAAa,GAAA,CAAI,UAAU,CAAA,EAAG,OAAO,eAAA;AACzC,MAAA,IAAI,OAAO,GAAA,CAAI,UAAU,CAAA,KAAM,YAAY,OAAO,eAAA;AAClD,MAAA,YAAA,CAAa,IAAI,UAAU,CAAA;AAC3B,MAAA,MAAM,qBAAA,GAAwB,yBAAA,CAA0B,SAAA,EAAW,GAAA,EAAK,UAAU,CAAA;AAClF,MAAA,OAAO;AAAA,QACL,GAAG,eAAA;AAAA,QACH,CAAC,UAAU,GAAG;AAAA,OAChB;AAAA,IACF,CAAA;AAAA,IACA;AAAC,GACH;AAIA,EAAA,IAAI,SAAA,IAAa,GAAA,IAAO,GAAA,CAAI,OAAA,EAAS;AACnC,IAAA,MAAM,kBAA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GAAA,CAAI,GAAA,EAAK,MAAM,CAAA;AAC9C,MAAA,IAAI,OAAO,cAAA,KAAmB,UAAA,EAAY,OAAO,cAAA;AAEjD,MAAA,OAAO,cAAA,CAAe,KAAK,GAAG,CAAA;AAAA,IAChC;AAAA,GACF;AACF;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"internalSqlQuery.js","sources":["../../../src/utils/internalSqlQuery.ts"],"sourcesContent":["import { stringMatchesSomePattern } from '@sentry/core';\n\n/**\n * Cloudflare frameworks that build on Durable Objects (`agents`, `partyserver`, ...) manage their\n * own internal SQLite tables, all namespaced with a `cf_` prefix — e.g. `cf_agents_schedules`,\n * `cf_agent_state`, `cf_ai_chat_stream_chunks`. Queries against them (schedule polling, chat-stream\n * persistence, state bookkeeping) are framework implementation details that otherwise flood traces\n * with dozens of zero-signal `db.query` spans per request. The exact set of tables even varies\n * between framework versions, so we match the reserved prefix rather than an enumerated list.\n *\n * The `cf_` prefix is a reserved convention for framework-managed tables, so user tables should not\n * use it. In case a user table does collide with the prefix, the `durableObjectSqlSpanAllowlist`\n * option lets them opt those tables back into instrumentation.\n *\n * The check operates on the query summary produced by `getSqlQuerySummary` (`{operation} {table} ...`,\n * the same value used as the span name), so table targets are already isolated from the rest of the\n * query. The one exception is `CREATE INDEX`: its summary carries the index name, not the indexed\n * table (upstream OTel convention), so the `cf_` target only appears in the ON clause of the full\n * statement, which `queryText` is needed for.\n */\nexport function targetsCloudflareInternalTable(\n querySummary: string | undefined,\n allowlist?: Array<string | RegExp>,\n queryText?: string,\n): boolean {\n if (!querySummary) {\n return false;\n }\n\n const indexedTable = queryText ? CREATE_INDEX_TABLE_RE.exec(queryText)?.groups?.['table'] : undefined;\n if (indexedTable) {\n return isCloudflareInternalTable(indexedTable, allowlist);\n }\n\n const [, ...tables] = querySummary.split(' ');\n\n return tables.some(table => isCloudflareInternalTable(table, allowlist));\n}\n\n// `CREATE [UNIQUE] INDEX [IF NOT EXISTS] <name> ON <table>` — the IF EXISTS shape mirrors DDL_RE\n// in @sentry/core.\nconst CREATE_INDEX_TABLE_RE =\n /^\\s*CREATE\\s+(?:UNIQUE\\s+)?INDEX(?:\\s+IF\\s+(?:NOT\\s+)?EXISTS)?\\s+[^\\s(,;)]+\\s+ON\\s+(?<table>[^\\s(,;)]+)/i;\n\nfunction isCloudflareInternalTable(table: string, allowlist?: Array<string | RegExp>): boolean {\n if (!table.toLowerCase().startsWith('cf_')) {\n return false;\n }\n\n // A table on the allowlist is treated as a user table and stays instrumented, even though it\n // matches the reserved prefix.\n return !allowlist?.length || !stringMatchesSomePattern(table, allowlist, true);\n}\n"],"names":[],"mappings":";;AAoBO,SAAS,8BAAA,CACd,YAAA,EACA,SAAA,EACA,SAAA,EACS;AACT,EAAA,IAAI,CAAC,YAAA,EAAc;AACjB,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,MAAM,YAAA,GAAe,YAAY,qBAAA,CAAsB,IAAA,CAAK,SAAS,CAAA,EAAG,MAAA,GAAS,OAAO,CAAA,GAAI,MAAA;AAC5F,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,OAAO,yBAAA,CAA0B,cAAc,SAAS,CAAA;AAAA,EAC1D;AAEA,EAAA,MAAM,GAAG,GAAG,MAAM,CAAA,GAAI,YAAA,CAAa,MAAM,GAAG,CAAA;AAE5C,EAAA,OAAO,OAAO,IAAA,CAAK,CAAA,KAAA,KAAS,yBAAA,CAA0B,KAAA,EAAO,SAAS,CAAC,CAAA;AACzE;AAIA,MAAM,qBAAA,GACJ,0GAAA;AAEF,SAAS,yBAAA,CAA0B,OAAe,SAAA,EAA6C;AAC7F,EAAA,IAAI,CAAC,KAAA,CAAM,WAAA,EAAY,CAAE,UAAA,CAAW,KAAK,CAAA,EAAG;AAC1C,IAAA,OAAO,KAAA;AAAA,EACT;AAIA,EAAA,OAAO,CAAC,SAAA,EAAW,MAAA,IAAU,CAAC,wBAAA,CAAyB,KAAA,EAAO,WAAW,IAAI,CAAA;AAC/E;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"internalStorageKey.js","sources":["../../../src/utils/internalStorageKey.ts"],"sourcesContent":["import { stringMatchesSomePattern } from '@sentry/core';\n\n/**\n * Cloudflare frameworks that build on Durable Objects (`agents`, `partyserver`, ...) also manage\n * their own internal KV entries alongside their internal SQLite tables, namespaced with a reserved\n * prefix — e.g. `cf_agents_state`, `cf_agents_mcp_servers`, `__ps_name`. Reads/writes of these\n * (message persistence, MCP connection bookkeeping, name hydration) are framework implementation\n * details that otherwise flood traces with dozens of zero-signal `durable_object_storage_*` spans\n * per request, so we match the reserved prefixes rather than an enumerated list. This mirrors the\n * `cf_` convention used for internal SQL tables (see `targetsCloudflareInternalTable`).\n *\n * The prefixes are a reserved convention for framework-managed entries, so user keys should not use\n * them. In case a user key does collide, the `durableObjectStorageSpanAllowlist` option lets them\n * opt those keys back into instrumentation.\n */\nexport function targetsCloudflareInternalKey(key: string | undefined, allowlist?: Array<string | RegExp>): boolean {\n if (!key) {\n return false;\n }\n\n // Framework-managed KV namespaces:\n // - `cf_` — agents / ai-chat internal state (mirrors the internal SQL table convention)\n // - `cf:` — agents chat-recovery entries (`cf:chat-recovery:*`, `cf:chat:*`); the same reserved\n // `cf` namespace, but colon-separated instead of underscore-separated\n // - `__ps_` — partyserver internals (e.g. `__ps_name`)\n // - `/` — MCP OAuth client state (`/<clientName>/<serverId>/{token,client_info,state,...}`),\n // read on every MCP tool call. User keys on an Agent rarely use a leading slash; if one does,\n // the allowlist opts it back in.\n const isFrameworkKey =\n key.startsWith('cf_') || key.startsWith('cf:') || key.startsWith('__ps_') || key.startsWith('/');\n if (!isFrameworkKey) {\n return false;\n }\n\n // A key on the allowlist is treated as a user key and stays instrumented, even though it matches\n // a reserved prefix.\n return !allowlist?.length || !stringMatchesSomePattern(key, allowlist, true);\n}\n\n/**\n * Extracts the KV keys a Durable Object storage call targets, so the caller can decide whether the\n * operation only touches framework-internal entries. Returns `undefined` when the keys can't be\n * determined from the arguments (e.g. `list()` without a prefix), in which case the call is treated\n * as user work and stays instrumented.\n */\nexport function getStorageKeys(methodName: string, args: unknown[]): string[] | undefined {\n const [first] = args;\n\n if (methodName === 'get' || methodName === 'delete') {\n // get(key) / get(keys[]) / delete(key) / delete(keys[])\n if (typeof first === 'string') {\n return [first];\n }\n if (Array.isArray(first)) {\n return first.filter((k): k is string => typeof k === 'string');\n }\n return undefined;\n }\n\n if (methodName === 'put') {\n // put(key, value) or put({ key: value, ... })\n if (typeof first === 'string') {\n return [first];\n }\n if (first && typeof first === 'object' && !Array.isArray(first)) {\n return Object.keys(first);\n }\n return undefined;\n }\n\n if (methodName === 'list') {\n // list({ prefix })\n const prefix = first && typeof first === 'object' ? (first as { prefix?: unknown }).prefix : undefined;\n return typeof prefix === 'string' ? [prefix] : undefined;\n }\n\n return undefined;\n}\n"],"names":[],"mappings":";;AAeO,SAAS,4BAAA,CAA6B,KAAyB,SAAA,EAA6C;AACjH,EAAA,IAAI,CAAC,GAAA,EAAK;AACR,IAAA,OAAO,KAAA;AAAA,EACT;AAUA,EAAA,MAAM,cAAA,GACJ,GAAA,CAAI,UAAA,CAAW,KAAK,KAAK,GAAA,CAAI,UAAA,CAAW,KAAK,CAAA,IAAK,IAAI,UAAA,CAAW,OAAO,CAAA,IAAK,GAAA,CAAI,WAAW,GAAG,CAAA;AACjG,EAAA,IAAI,CAAC,cAAA,EAAgB;AACnB,IAAA,OAAO,KAAA;AAAA,EACT;AAIA,EAAA,OAAO,CAAC,SAAA,EAAW,MAAA,IAAU,CAAC,wBAAA,CAAyB,GAAA,EAAK,WAAW,IAAI,CAAA;AAC7E;AAQO,SAAS,cAAA,CAAe,YAAoB,IAAA,EAAuC;AACxF,EAAA,MAAM,CAAC,KAAK,CAAA,GAAI,IAAA;AAEhB,EAAA,IAAI,UAAA,KAAe,KAAA,IAAS,UAAA,KAAe,QAAA,EAAU;AAEnD,IAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,MAAA,OAAO,CAAC,KAAK,CAAA;AAAA,IACf;AACA,IAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,MAAA,OAAO,MAAM,MAAA,CAAO,CAAC,CAAA,KAAmB,OAAO,MAAM,QAAQ,CAAA;AAAA,IAC/D;AACA,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,IAAI,eAAe,KAAA,EAAO;AAExB,IAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,MAAA,OAAO,CAAC,KAAK,CAAA;AAAA,IACf;AACA,IAAA,IAAI,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,IAAY,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AAC/D,MAAA,OAAO,MAAA,CAAO,KAAK,KAAK,CAAA;AAAA,IAC1B;AACA,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,IAAI,eAAe,MAAA,EAAQ;AAEzB,IAAA,MAAM,SAAS,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,GAAY,MAA+B,MAAA,GAAS,MAAA;AAC7F,IAAA,OAAO,OAAO,MAAA,KAAW,QAAA,GAAW,CAAC,MAAM,CAAA,GAAI,MAAA;AAAA,EACjD;AAEA,EAAA,OAAO,MAAA;AACT;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"isBinding.js","sources":["../../../src/utils/isBinding.ts"],"sourcesContent":["/**\n * Adapted from https://github.com/evanderkoogh/otel-cf-workers/blob/effeb549f0a4ed1c55ea0c4f0d8e8e37e5494fb3/src/instrumentation/env.ts\n *\n * BSD 3-Clause License\n *\n * Copyright (c) 2023, Erwin van der Koogh\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * 3. Neither the name of the copyright holder nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport type { Ai, D1Database, DurableObjectNamespace, Queue, R2Bucket, RateLimit } from '@cloudflare/workers-types';\n\n/**\n * Checks if a value is a JSRPC proxy (service binding).\n *\n * JSRPC proxies return a truthy value for ANY property access, including\n * properties that don't exist. This makes other duck-type checks unreliable\n * unless we exclude JSRPC first.\n *\n * Must be checked before other binding type checks.\n */\nexport function isJSRPC(item: unknown): item is Service {\n try {\n return !!(item as Record<string, unknown>)[`__some_property_that_will_never_exist__${Math.random()}`];\n } catch {\n return false;\n }\n}\n\nconst isNotJSRPC = (item: unknown): item is Record<string, unknown> => !isJSRPC(item);\n\n/**\n * Duck-type check for DurableObjectNamespace bindings.\n * DurableObjectNamespace has `idFromName`, `idFromString`, `get`, `newUniqueId`.\n */\nexport function isDurableObjectNamespace(item: unknown): item is DurableObjectNamespace {\n return item != null && isNotJSRPC(item) && typeof item.idFromName === 'function';\n}\n\n/**\n * Duck-type check for Queue producer bindings.\n * Queue has `send` and `sendBatch` async methods.\n */\nexport function isQueue(item: unknown): item is Queue {\n return item != null && isNotJSRPC(item) && typeof item.send === 'function' && typeof item.sendBatch === 'function';\n}\n\n/**\n * Duck-type check for D1Database bindings.\n * D1Database has `prepare`, `batch`, and `exec` methods.\n */\nexport function isD1Database(item: unknown): item is D1Database {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.prepare === 'function' &&\n typeof item.batch === 'function' &&\n typeof item.exec === 'function'\n );\n}\n\n/**\n * Duck-type check for Workers AI bindings.\n * The Ai binding has `run`, `gateway`, and `toMarkdown` methods.\n */\nexport function isAiBinding(item: unknown): item is Ai {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.run === 'function' &&\n typeof item.gateway === 'function' &&\n typeof item.toMarkdown === 'function'\n );\n}\n\n/**\n * Duck-type check for R2 Bucket bindings.\n * R2Bucket has `head`, `put`, and `createMultipartUpload` methods.\n */\nexport function isR2Bucket(item: unknown): item is R2Bucket {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.head === 'function' &&\n typeof item.put === 'function' &&\n typeof item.createMultipartUpload === 'function'\n );\n}\n\n/**\n * Duck-type check for RateLimit bindings.\n * RateLimit only exposes a single `limit` method. Because that is a fairly\n * common method name, this check is intentionally run after the more specific\n * binding checks (Queue, R2, D1) in `instrumentEnv`, so those win when a binding\n * also happens to expose `limit`.\n */\nexport function isRateLimit(item: unknown): item is RateLimit {\n return item != null && isNotJSRPC(item) && typeof item.limit === 'function';\n}\n"],"names":[],"mappings":"AA4CO,SAAS,QAAQ,IAAA,EAAgC;AACtD,EAAA,IAAI;AACF,IAAA,OAAO,CAAC,CAAE,IAAA,CAAiC,0CAA0C,IAAA,CAAK,MAAA,EAAQ,CAAA,CAAE,CAAA;AAAA,EACtG,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;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
1
- {"version":3,"file":"isCloudflareClass.js","sources":["../../../src/utils/isCloudflareClass.ts"],"sourcesContent":["import type { DurableObject, WorkflowEntrypoint } from 'cloudflare:workers';\nimport type { WorkerEntrypointConstructor } from '../instrumentations/instrumentWorkerEntrypoint';\ntype CloudflareClassName = 'WorkerEntrypoint' | 'DurableObject' | 'WorkflowEntrypoint';\n\n/**\n * Checks if a class constructor extends a specific Cloudflare base class.\n *\n * Uses prototype chain walking with constructor names rather than instanceof,\n * so it works in Node at build time without requiring the cloudflare:workers\n * module (which only exists in the Workers runtime).\n *\n * This is used to differentiate between different Cloudflare worker types:\n * - WorkerEntrypoint: Class-based workers (used with instrumentWorkerEntrypoint)\n * - DurableObject: Durable Object classes\n * - Workflow: Workflow classes\n *\n * For ExportedHandler (plain objects), this will return false for all types.\n *\n * @param value - The value to check (typically a class constructor)\n * @param className - The Cloudflare base class name to check against\n * @returns true if the value is a class that extends the specified Cloudflare class\n *\n * @example\n * ```ts\n * isCloudflareClass(MyWorker, 'WorkerEntrypoint') // true if MyWorker extends WorkerEntrypoint\n * isCloudflareClass(MyDO, 'DurableObject') // true if MyDO extends DurableObject\n * ```\n */\nexport function isCloudflareClass(value: unknown, className: 'WorkerEntrypoint'): value is WorkerEntrypointConstructor;\nexport function isCloudflareClass(\n value: unknown,\n className: 'DurableObject',\n): value is new (...args: unknown[]) => DurableObject;\nexport function isCloudflareClass(\n value: unknown,\n className: 'WorkflowEntrypoint',\n): value is new (...args: unknown[]) => WorkflowEntrypoint;\nexport function isCloudflareClass(value: unknown, className: CloudflareClassName): boolean {\n if (!value || typeof value !== 'function') {\n return false;\n }\n\n if (value.name === className) {\n return false;\n }\n\n let proto: object | null = value.prototype;\n\n while (proto) {\n const ctor = (proto as { constructor?: { name?: string } }).constructor;\n const constructorName = ctor?.name;\n\n if (constructorName === className) {\n return true;\n }\n\n proto = Object.getPrototypeOf(proto);\n }\n\n return false;\n}\n"],"names":[],"mappings":"AAqCO,SAAS,iBAAA,CAAkB,OAAgB,SAAA,EAAyC;AACzF,EAAA,IAAI,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,UAAA,EAAY;AACzC,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,IAAI,KAAA,CAAM,SAAS,SAAA,EAAW;AAC5B,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,IAAI,QAAuB,KAAA,CAAM,SAAA;AAEjC,EAAA,OAAO,KAAA,EAAO;AACZ,IAAA,MAAM,OAAQ,KAAA,CAA8C,WAAA;AAC5D,IAAA,MAAM,kBAAkB,IAAA,EAAM,IAAA;AAE9B,IAAA,IAAI,oBAAoB,SAAA,EAAW;AACjC,MAAA,OAAO,IAAA;AAAA,IACT;AAEA,IAAA,KAAA,GAAQ,MAAA,CAAO,eAAe,KAAK,CAAA;AAAA,EACrC;AAEA,EAAA,OAAO,KAAA;AACT;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"rpcMeta.js","sources":["../../../src/utils/rpcMeta.ts"],"sourcesContent":["import { getTraceData, isObjectLike, type SerializedTraceData } from '@sentry/core';\n\n/**\n * Key used to identify Sentry RPC metadata in a trailing argument.\n * This enables transparent trace propagation across Cloudflare Workers RPC\n * calls (Cap'n Proto), which have no native header/metadata support.\n */\nconst SENTRY_RPC_META_KEY = '__sentry_rpc_meta__';\n\ninterface SentryRpcMeta {\n __sentry_rpc_meta__: SerializedTraceData;\n}\n\nfunction isSentryRpcMeta(value: unknown): value is SentryRpcMeta {\n if (!isObjectLike(value) || !(SENTRY_RPC_META_KEY in value)) {\n return false;\n }\n return isObjectLike(value[SENTRY_RPC_META_KEY]);\n}\n\n/**\n * Appends Sentry RPC metadata to an args array for trace propagation.\n * If no active trace exists, returns the original args unchanged.\n */\nexport function appendRpcMeta(args: unknown[]): unknown[] {\n const traceData = getTraceData();\n\n if (!traceData['sentry-trace']) {\n return args;\n }\n\n return [...args, { [SENTRY_RPC_META_KEY]: traceData }];\n}\n\n/**\n * Extracts Sentry RPC metadata from the trailing argument of an args array.\n * Returns cleaned args (without meta) and the extracted trace data if found.\n */\nexport function extractRpcMeta<T extends unknown[]>(\n args: T,\n): {\n args: T;\n rpcMeta?: SerializedTraceData;\n} {\n if (args.length === 0) {\n return { args };\n }\n\n const last = args[args.length - 1];\n if (isSentryRpcMeta(last)) {\n return {\n args: args.slice(0, -1) as T,\n rpcMeta: last.__sentry_rpc_meta__,\n };\n }\n\n return { args };\n}\n"],"names":[],"mappings":";;AAOA,MAAM,mBAAA,GAAsB,qBAAA;AAM5B,SAAS,gBAAgB,KAAA,EAAwC;AAC/D,EAAA,IAAI,CAAC,YAAA,CAAa,KAAK,CAAA,IAAK,EAAE,uBAAuB,KAAA,CAAA,EAAQ;AAC3D,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OAAO,YAAA,CAAa,KAAA,CAAM,mBAAmB,CAAC,CAAA;AAChD;AAMO,SAAS,cAAc,IAAA,EAA4B;AACxD,EAAA,MAAM,YAAY,YAAA,EAAa;AAE/B,EAAA,IAAI,CAAC,SAAA,CAAU,cAAc,CAAA,EAAG;AAC9B,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,CAAC,GAAG,IAAA,EAAM,EAAE,CAAC,mBAAmB,GAAG,WAAW,CAAA;AACvD;AAMO,SAAS,eACd,IAAA,EAIA;AACA,EAAA,IAAI,IAAA,CAAK,WAAW,CAAA,EAAG;AACrB,IAAA,OAAO,EAAE,IAAA,EAAK;AAAA,EAChB;AAEA,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,IAAA,CAAK,MAAA,GAAS,CAAC,CAAA;AACjC,EAAA,IAAI,eAAA,CAAgB,IAAI,CAAA,EAAG;AACzB,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA;AAAA,MACtB,SAAS,IAAA,CAAK;AAAA,KAChB;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,IAAA,EAAK;AAChB;;;;"}
@@ -1,24 +0,0 @@
1
- import { debug } from '@sentry/core';
2
- import { DEBUG_BUILD } from '../debug-build.js';
3
-
4
- function getEffectiveRpcPropagation(options) {
5
- const { enableRpcTracePropagation, instrumentPrototypeMethods } = options;
6
- if (enableRpcTracePropagation !== void 0) {
7
- if (instrumentPrototypeMethods !== void 0) {
8
- DEBUG_BUILD && debug.warn(
9
- "[Sentry] Both `enableRpcTracePropagation` and `instrumentPrototypeMethods` are set. Using `enableRpcTracePropagation` and ignoring `instrumentPrototypeMethods`."
10
- );
11
- }
12
- return enableRpcTracePropagation;
13
- }
14
- if (instrumentPrototypeMethods !== void 0) {
15
- DEBUG_BUILD && debug.warn(
16
- "[Sentry] `instrumentPrototypeMethods` is deprecated and will be removed in a future major version. Please use `enableRpcTracePropagation` instead."
17
- );
18
- return instrumentPrototypeMethods === true || Array.isArray(instrumentPrototypeMethods) && instrumentPrototypeMethods.length > 0;
19
- }
20
- return false;
21
- }
22
-
23
- export { getEffectiveRpcPropagation };
24
- //# sourceMappingURL=rpcOptions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rpcOptions.js","sources":["../../../src/utils/rpcOptions.ts"],"sourcesContent":["import { debug } from '@sentry/core';\nimport type { CloudflareOptions } from '../client';\nimport { DEBUG_BUILD } from '../debug-build';\n\n/**\n * Gets the effective RPC propagation setting, handling deprecation of `instrumentPrototypeMethods`.\n *\n * Priority:\n * 1. If `enableRpcTracePropagation` is set, use it (ignore `instrumentPrototypeMethods`)\n * 2. If only `instrumentPrototypeMethods` is set, use it with deprecation warning\n * 3. If neither is set, return `false`\n *\n * @returns The effective setting for RPC trace propagation\n */\nexport function getEffectiveRpcPropagation(options: CloudflareOptions): boolean {\n // eslint-disable-next-line typescript/no-deprecated\n const { enableRpcTracePropagation, instrumentPrototypeMethods } = options;\n\n // If the new option is explicitly set, use it\n if (enableRpcTracePropagation !== undefined) {\n if (instrumentPrototypeMethods !== undefined) {\n DEBUG_BUILD &&\n debug.warn(\n '[Sentry] Both `enableRpcTracePropagation` and `instrumentPrototypeMethods` are set. ' +\n 'Using `enableRpcTracePropagation` and ignoring `instrumentPrototypeMethods`.',\n );\n }\n return enableRpcTracePropagation;\n }\n\n // Fall back to deprecated option with warning\n if (instrumentPrototypeMethods !== undefined) {\n DEBUG_BUILD &&\n debug.warn(\n '[Sentry] `instrumentPrototypeMethods` is deprecated and will be removed in a future major version. ' +\n 'Please use `enableRpcTracePropagation` instead.',\n );\n // instrumentPrototypeMethods can be boolean or string[], convert to boolean\n return (\n instrumentPrototypeMethods === true ||\n (Array.isArray(instrumentPrototypeMethods) && instrumentPrototypeMethods.length > 0)\n );\n }\n\n return false;\n}\n"],"names":[],"mappings":";;;AAcO,SAAS,2BAA2B,OAAA,EAAqC;AAE9E,EAAA,MAAM,EAAE,yBAAA,EAA2B,0BAAA,EAA2B,GAAI,OAAA;AAGlE,EAAA,IAAI,8BAA8B,MAAA,EAAW;AAC3C,IAAA,IAAI,+BAA+B,MAAA,EAAW;AAC5C,MAAA,WAAA,IACE,KAAA,CAAM,IAAA;AAAA,QACJ;AAAA,OAEF;AAAA,IACJ;AACA,IAAA,OAAO,yBAAA;AAAA,EACT;AAGA,EAAA,IAAI,+BAA+B,MAAA,EAAW;AAC5C,IAAA,WAAA,IACE,KAAA,CAAM,IAAA;AAAA,MACJ;AAAA,KAEF;AAEF,IAAA,OACE,+BAA+B,IAAA,IAC9B,KAAA,CAAM,QAAQ,0BAA0B,CAAA,IAAK,2BAA2B,MAAA,GAAS,CAAA;AAAA,EAEtF;AAEA,EAAA,OAAO,KAAA;AACT;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"streaming.js","sources":["../../../src/utils/streaming.ts"],"sourcesContent":["export type StreamingGuess = {\n isStreaming: boolean;\n};\n\n/**\n * Classifies a Response as streaming or non-streaming.\n *\n * Heuristics:\n * - No body → not streaming\n * - Known streaming Content-Types → streaming (SSE, NDJSON, JSON streaming)\n * - text/plain without Content-Length → streaming (some AI APIs)\n * - Otherwise → not streaming (conservative default, including HTML/SSR)\n *\n * We avoid probing the stream to prevent blocking on transform streams (like injectTraceMetaTags)\n * or SSR streams that may not have data ready immediately.\n */\nexport function classifyResponseStreaming(res: Response): StreamingGuess {\n if (!res.body) {\n return { isStreaming: false };\n }\n\n const contentType = res.headers.get('content-type') ?? '';\n const contentLength = res.headers.get('content-length');\n\n // Streaming: Known streaming content types\n // - text/event-stream: Server-Sent Events (Vercel AI SDK, real-time APIs)\n // - application/x-ndjson, application/ndjson: Newline-delimited JSON\n // - application/stream+json: JSON streaming\n // - text/plain (without Content-Length): Some AI APIs use this for streaming text\n if (\n /^text\\/event-stream\\b/i.test(contentType) ||\n /^application\\/(x-)?ndjson\\b/i.test(contentType) ||\n /^application\\/stream\\+json\\b/i.test(contentType) ||\n (/^text\\/plain\\b/i.test(contentType) && !contentLength)\n ) {\n return { isStreaming: true };\n }\n\n // Default: treat as non-streaming\n return { isStreaming: false };\n}\n"],"names":[],"mappings":"AAgBO,SAAS,0BAA0B,GAAA,EAA+B;AACvE,EAAA,IAAI,CAAC,IAAI,IAAA,EAAM;AACb,IAAA,OAAO,EAAE,aAAa,KAAA,EAAM;AAAA,EAC9B;AAEA,EAAA,MAAM,WAAA,GAAc,GAAA,CAAI,OAAA,CAAQ,GAAA,CAAI,cAAc,CAAA,IAAK,EAAA;AACvD,EAAA,MAAM,aAAA,GAAgB,GAAA,CAAI,OAAA,CAAQ,GAAA,CAAI,gBAAgB,CAAA;AAOtD,EAAA,IACE,yBAAyB,IAAA,CAAK,WAAW,CAAA,IACzC,8BAAA,CAA+B,KAAK,WAAW,CAAA,IAC/C,+BAAA,CAAgC,IAAA,CAAK,WAAW,CAAA,IAC/C,iBAAA,CAAkB,KAAK,WAAW,CAAA,IAAK,CAAC,aAAA,EACzC;AACA,IAAA,OAAO,EAAE,aAAa,IAAA,EAAK;AAAA,EAC7B;AAGA,EAAA,OAAO,EAAE,aAAa,KAAA,EAAM;AAC9B;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"traceLinks.js","sources":["../../../src/utils/traceLinks.ts"],"sourcesContent":["import type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport { TraceFlags } from '@opentelemetry/api';\nimport type { SpanLink } from '@sentry/core';\nimport { debug, getActiveSpan, SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE, spanIsSampled } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\n/** Storage key prefix for the span context that links consecutive method invocations */\nconst SENTRY_TRACE_LINK_KEY_PREFIX = '__SENTRY_TRACE_LINK__';\n\n/** Stored span context for creating span links */\nexport interface StoredSpanContext {\n traceId: string;\n spanId: string;\n sampled: boolean;\n}\n\n/**\n * Gets the storage key for a specific method's trace link.\n */\nexport function getTraceLinkKey(methodName: string): string {\n return `${SENTRY_TRACE_LINK_KEY_PREFIX}${methodName}`;\n}\n\n/**\n * Stores the current span context in Durable Object storage for trace linking.\n * Uses the original uninstrumented storage to avoid creating spans for internal operations.\n * Errors are silently ignored to prevent internal storage failures from propagating to user code.\n */\nexport function storeSpanContext(originalStorage: DurableObjectStorage, methodName: string): void {\n try {\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n const spanContext = activeSpan.spanContext();\n const storedContext: StoredSpanContext = {\n traceId: spanContext.traceId,\n spanId: spanContext.spanId,\n sampled: spanIsSampled(activeSpan),\n };\n\n originalStorage.kv.put(getTraceLinkKey(methodName), storedContext);\n }\n } catch (error) {\n // Silently ignore storage errors to prevent internal failures from affecting user code\n DEBUG_BUILD && debug.log(`[CloudflareClient] Error storing span context for method ${methodName}`, error);\n }\n}\n\n/**\n * Retrieves a stored span context from Durable Object storage.\n * Errors are silently ignored to prevent internal storage failures from propagating to user code.\n */\nexport function getStoredSpanContext(\n originalStorage: DurableObjectStorage,\n methodName: string,\n): StoredSpanContext | undefined {\n try {\n return originalStorage.kv.get<StoredSpanContext>(getTraceLinkKey(methodName));\n } catch (error) {\n // Silently ignore storage errors to prevent internal failures from affecting user code\n DEBUG_BUILD && debug.log(`[CloudflareClient] Error retrieving span context for method ${methodName}`, error);\n return undefined;\n }\n}\n\n/**\n * Builds span links from a stored span context.\n */\nexport function buildSpanLinks(storedContext: StoredSpanContext): SpanLink[] {\n return [\n {\n context: {\n traceId: storedContext.traceId,\n spanId: storedContext.spanId,\n traceFlags: storedContext.sampled ? TraceFlags.SAMPLED : TraceFlags.NONE,\n },\n attributes: {\n [SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE]: 'previous_trace',\n },\n },\n ];\n}\n"],"names":[],"mappings":";;;;AAOA,MAAM,4BAAA,GAA+B,uBAAA;AAY9B,SAAS,gBAAgB,UAAA,EAA4B;AAC1D,EAAA,OAAO,CAAA,EAAG,4BAA4B,CAAA,EAAG,UAAU,CAAA,CAAA;AACrD;AAOO,SAAS,gBAAA,CAAiB,iBAAuC,UAAA,EAA0B;AAChG,EAAA,IAAI;AACF,IAAA,MAAM,aAAa,aAAA,EAAc;AACjC,IAAA,IAAI,UAAA,EAAY;AACd,MAAA,MAAM,WAAA,GAAc,WAAW,WAAA,EAAY;AAC3C,MAAA,MAAM,aAAA,GAAmC;AAAA,QACvC,SAAS,WAAA,CAAY,OAAA;AAAA,QACrB,QAAQ,WAAA,CAAY,MAAA;AAAA,QACpB,OAAA,EAAS,cAAc,UAAU;AAAA,OACnC;AAEA,MAAA,eAAA,CAAgB,EAAA,CAAG,GAAA,CAAI,eAAA,CAAgB,UAAU,GAAG,aAAa,CAAA;AAAA,IACnE;AAAA,EACF,SAAS,KAAA,EAAO;AAEd,IAAA,WAAA,IAAe,KAAA,CAAM,GAAA,CAAI,CAAA,yDAAA,EAA4D,UAAU,IAAI,KAAK,CAAA;AAAA,EAC1G;AACF;AAMO,SAAS,oBAAA,CACd,iBACA,UAAA,EAC+B;AAC/B,EAAA,IAAI;AACF,IAAA,OAAO,eAAA,CAAgB,EAAA,CAAG,GAAA,CAAuB,eAAA,CAAgB,UAAU,CAAC,CAAA;AAAA,EAC9E,SAAS,KAAA,EAAO;AAEd,IAAA,WAAA,IAAe,KAAA,CAAM,GAAA,CAAI,CAAA,4DAAA,EAA+D,UAAU,IAAI,KAAK,CAAA;AAC3G,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAKO,SAAS,eAAe,aAAA,EAA8C;AAC3E,EAAA,OAAO;AAAA,IACL;AAAA,MACE,OAAA,EAAS;AAAA,QACP,SAAS,aAAA,CAAc,OAAA;AAAA,QACvB,QAAQ,aAAA,CAAc,MAAA;AAAA,QACtB,UAAA,EAAY,aAAA,CAAc,OAAA,GAAU,UAAA,CAAW,UAAU,UAAA,CAAW;AAAA,OACtE;AAAA,MACA,UAAA,EAAY;AAAA,QACV,CAAC,iCAAiC,GAAG;AAAA;AACvC;AACF,GACF;AACF;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"stacktrace.js","sources":["../../../src/vendor/stacktrace.ts"],"sourcesContent":["// Vendored from https://github.com/robertcepa/toucan-js/blob/036568729e49d0a937de527dc32d73580d9a41b3/packages/toucan-js/src/stacktrace.ts\n// Copyright (c) 2022 Robert Cepa\n// SPDX-License-Identifier: MIT\n\nimport type { StackLineParser, StackLineParserFn, StackParser } from '@sentry/core';\nimport { basename, createStackParser, nodeStackLineParser } from '@sentry/core';\n\ntype GetModuleFn = (filename: string | undefined) => string | undefined;\n\n/**\n * Stack line parser for Cloudflare Workers.\n * This wraps node stack parser and adjusts root paths to match with source maps.\n *\n */\nfunction workersStackLineParser(getModule?: GetModuleFn): StackLineParser {\n const [arg1, arg2] = nodeStackLineParser(getModule);\n\n const fn: StackLineParserFn = line => {\n const result = arg2(line);\n if (result) {\n const filename = result.filename;\n // Workers runtime runs a single bundled file that is always in a virtual root\n result.abs_path = filename !== undefined && !filename.startsWith('/') ? `/${filename}` : filename;\n // There is no way to tell what code is in_app and what comes from dependencies (node_modules), since we have one bundled file.\n // So everything is in_app, unless an error comes from runtime function (ie. JSON.parse), which is determined by the presence of filename.\n result.in_app = filename !== undefined;\n }\n return result;\n };\n\n return [arg1, fn];\n}\n\n/**\n * Gets the module from filename.\n *\n * @param filename\n * @returns Module name\n */\nexport function getModule(filename: string | undefined): string | undefined {\n if (!filename) {\n return;\n }\n\n // In Cloudflare Workers there is always only one bundled file\n return basename(filename, '.js');\n}\n\n/** Cloudflare Workers stack parser */\nexport const defaultStackParser: StackParser = createStackParser(workersStackLineParser(getModule));\n"],"names":["getModule"],"mappings":";;AAcA,SAAS,uBAAuBA,UAAAA,EAA0C;AACxE,EAAA,MAAM,CAAC,IAAA,EAAM,IAAI,CAAA,GAAI,oBAAoBA,UAAS,CAAA;AAElD,EAAA,MAAM,KAAwB,CAAA,IAAA,KAAQ;AACpC,IAAA,MAAM,MAAA,GAAS,KAAK,IAAI,CAAA;AACxB,IAAA,IAAI,MAAA,EAAQ;AACV,MAAA,MAAM,WAAW,MAAA,CAAO,QAAA;AAExB,MAAA,MAAA,CAAO,QAAA,GAAW,QAAA,KAAa,MAAA,IAAa,CAAC,QAAA,CAAS,WAAW,GAAG,CAAA,GAAI,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA,GAAK,QAAA;AAGzF,MAAA,MAAA,CAAO,SAAS,QAAA,KAAa,MAAA;AAAA,IAC/B;AACA,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AAEA,EAAA,OAAO,CAAC,MAAM,EAAE,CAAA;AAClB;AAQO,SAAS,UAAU,QAAA,EAAkD;AAC1E,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA;AAAA,EACF;AAGA,EAAA,OAAO,QAAA,CAAS,UAAU,KAAK,CAAA;AACjC;AAGO,MAAM,kBAAA,GAAkC,iBAAA,CAAkB,sBAAA,CAAuB,SAAS,CAAC;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"agentClass.js","sources":["../../../src/vite/agentClass.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { DEFAULT_EXPORT, type ModuleShape, shapeFromAst, shapeFromSource, type SuperRef } from './moduleShape';\nimport type { ProgramBody } from './transform';\n\n/**\n * Agent base classes, keyed by the module specifier they are imported from. A class extending any\n * of these — directly or through a chain of local/imported subclasses — is an `agents` Agent rather\n * than a plain Durable Object.\n *\n * `McpAgent`, `AIChatAgent` and `Think` all extend `Agent` themselves, but they live in packages\n * whose sources we never walk into (see {@link followImport}), so each needs its own entry.\n */\nconst AGENT_BASE_CLASSES: Record<string, ReadonlySet<string>> = {\n agents: new Set(['Agent']),\n 'agents/mcp': new Set(['McpAgent']),\n '@cloudflare/ai-chat': new Set(['AIChatAgent']),\n '@cloudflare/think': new Set(['Think']),\n};\n\n/**\n * How many modules deep the base-class chain is followed. Guards against pathological module graphs;\n * real Agent hierarchies are only a few levels deep.\n */\nconst MAX_DEPTH = 8;\n\n/**\n * The subset of the Vite/Rollup plugin context needed to walk the module graph.\n *\n * `resolve` is optional: without it detection still works, but only for base-class chains declared\n * inside the entry module itself. `readFile` is injectable for tests and defaults to reading disk.\n *\n * Deliberately **no `load`**: awaiting the plugin context's `load()` from inside a `transform` hook\n * deadlocks the build — the module cannot finish loading while its own transform is still pending\n * (Rollup documents this hazard, and Vite's Rolldown pipeline is stricter still). Sibling modules\n * are therefore read straight off disk; see {@link getModuleShape}.\n */\nexport interface ModuleResolver {\n parse(code: string): ProgramBody;\n resolve?(source: string, importer: string): Promise<{ id: string } | null | undefined>;\n readFile?(id: string): string | undefined;\n}\n\ninterface DetectContext {\n resolver: ModuleResolver;\n modules: Map<string, ModuleShape | undefined>;\n}\n\n/**\n * Find which of `candidates` (top-level class names in the entry module) are Cloudflare\n * [`agents`](https://www.npmjs.com/package/agents) Agents.\n *\n * An Agent is a Durable Object under the hood, so wrangler configures it as one and the transform\n * would otherwise reach for `instrumentDurableObjectWithSentry`. Detecting the Agent base chain lets\n * it pick `instrumentAgentWithSentry` instead, which adds the Agent-specific telemetry on top.\n *\n * Unlike `WorkerEntrypoint` detection, the chain is followed *across* modules: base classes commonly\n * live in their own file (`import { MyBase } from './base'`), and there is no runtime fallback that\n * would catch a missed one. Resolution stops at package boundaries — a base class imported from\n * `node_modules` is only recognized when it is one of {@link AGENT_BASE_CLASSES}.\n */\nexport async function detectAgentClasses(\n ast: ProgramBody,\n entryId: string,\n candidates: Iterable<string>,\n resolver: ModuleResolver,\n): Promise<Set<string>> {\n // The entry's shape comes from the AST Vite already handed us (TypeScript stripped, full\n // fidelity); only sibling modules fall back to source scanning.\n const ctx: DetectContext = { resolver, modules: new Map([[entryId, shapeFromAst(ast)]]) };\n\n const detected = new Set<string>();\n for (const name of candidates) {\n // A fresh cycle guard per candidate: a shared one would record \"not an Agent\" for bindings\n // visited while resolving an earlier candidate that turned out to be unrelated.\n if (await isAgentBinding(ctx, entryId, name, 0, new Set())) {\n detected.add(name);\n }\n }\n return detected;\n}\n\n/**\n * The local class names in the entry that a configured class name could refer to — either declared\n * under that name directly, or aliased to it by an `export { Local as Configured }` specifier.\n *\n * Keeps detection (which reads and scans other modules) off classes that no binding points at.\n */\nexport function collectAgentCandidates(ast: ProgramBody, configuredNames: Iterable<string>): Set<string> {\n const shape = shapeFromAst(ast);\n const candidates = new Set<string>();\n\n for (const configured of configuredNames) {\n if (shape.classes.has(configured)) {\n candidates.add(configured);\n }\n const local = shape.localExports.get(configured);\n if (local && shape.classes.has(local)) {\n candidates.add(local);\n }\n }\n\n return candidates;\n}\n\nasync function isAgentBinding(\n ctx: DetectContext,\n moduleId: string,\n name: string,\n depth: number,\n visited: Set<string>,\n): Promise<boolean> {\n if (depth > MAX_DEPTH) return false;\n\n const key = `${moduleId} ${name}`;\n if (visited.has(key)) return false;\n visited.add(key);\n\n const shape = await getModuleShape(ctx, moduleId);\n if (!shape) return false;\n\n if (shape.classes.has(name)) {\n return extendsAgent(ctx, shape, moduleId, shape.classes.get(name), depth, visited);\n }\n\n const imported = shape.imports.get(name);\n if (imported) {\n return followImport(ctx, moduleId, imported.source, imported.imported, depth, visited);\n }\n\n if (name === DEFAULT_EXPORT) {\n if (shape.defaultExportIsClass) {\n return extendsAgent(ctx, shape, moduleId, shape.defaultExportSuper, depth, visited);\n }\n if (shape.defaultExportName) {\n return isAgentBinding(ctx, moduleId, shape.defaultExportName, depth + 1, visited);\n }\n }\n\n // `export { Local as Requested }` — the caller asked by exported name.\n const localName = shape.localExports.get(name);\n if (localName) {\n return isAgentBinding(ctx, moduleId, localName, depth + 1, visited);\n }\n\n const reexport = shape.reexports.get(name);\n if (reexport) {\n return followImport(ctx, moduleId, reexport.source, reexport.imported, depth, visited);\n }\n\n // Barrel modules (`export * from './base'`) don't name the binding, so every star source is a\n // candidate home for it.\n for (const source of shape.starExports) {\n if (await followImport(ctx, moduleId, source, name, depth, visited)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Whether a superclass reference resolves to an Agent base — a bare identifier (imported, or a\n * subclass declared in the same module) or `ns.Agent` off a namespace import.\n */\nasync function extendsAgent(\n ctx: DetectContext,\n shape: ModuleShape,\n moduleId: string,\n superClass: SuperRef | undefined,\n depth: number,\n visited: Set<string>,\n): Promise<boolean> {\n if (!superClass) return false;\n\n if (superClass.kind === 'identifier') {\n return isAgentBinding(ctx, moduleId, superClass.name, depth + 1, visited);\n }\n\n const source = shape.namespaces.get(superClass.object);\n if (source) {\n return followImport(ctx, moduleId, source, superClass.property, depth, visited);\n }\n\n return false;\n}\n\n/** Resolve an import to its module and continue the search there, stopping at package boundaries. */\nasync function followImport(\n ctx: DetectContext,\n importerId: string,\n source: string,\n importedName: string,\n depth: number,\n visited: Set<string>,\n): Promise<boolean> {\n if (AGENT_BASE_CLASSES[source]?.has(importedName)) return true;\n\n if (!ctx.resolver.resolve) return false;\n\n let resolved: { id: string } | null | undefined;\n try {\n resolved = await ctx.resolver.resolve(source, importerId);\n } catch {\n return false;\n }\n if (!resolved?.id) return false;\n\n // Third-party sources are not walked: they are large, may not be plain JS by the time we see\n // them, and any Agent base worth knowing about is listed in AGENT_BASE_CLASSES.\n if (resolved.id.includes('/node_modules/') || resolved.id.includes('\\\\node_modules\\\\')) return false;\n\n return isAgentBinding(ctx, resolved.id, importedName, depth + 1, visited);\n}\n\nasync function getModuleShape(ctx: DetectContext, moduleId: string): Promise<ModuleShape | undefined> {\n if (ctx.modules.has(moduleId)) return ctx.modules.get(moduleId);\n\n let shape: ModuleShape | undefined;\n try {\n const code = ctx.resolver.readFile\n ? ctx.resolver.readFile(moduleId)\n : readFileSync(moduleId.replace(/[?#].*$/, ''), 'utf8');\n if (typeof code === 'string') {\n shape = shapeFromSource(code);\n }\n } catch {\n // Unreadable or not a source file — treat as \"not an Agent\" rather than failing the build.\n }\n\n ctx.modules.set(moduleId, shape);\n return shape;\n}\n"],"names":[],"mappings":";;;AAYA,MAAM,kBAAA,GAA0D;AAAA,EAC9D,MAAA,kBAAQ,IAAI,GAAA,CAAI,CAAC,OAAO,CAAC,CAAA;AAAA,EACzB,YAAA,kBAAc,IAAI,GAAA,CAAI,CAAC,UAAU,CAAC,CAAA;AAAA,EAClC,qBAAA,kBAAuB,IAAI,GAAA,CAAI,CAAC,aAAa,CAAC,CAAA;AAAA,EAC9C,mBAAA,kBAAqB,IAAI,GAAA,CAAI,CAAC,OAAO,CAAC;AACxC,CAAA;AAMA,MAAM,SAAA,GAAY,CAAA;AAqClB,eAAsB,kBAAA,CACpB,GAAA,EACA,OAAA,EACA,UAAA,EACA,QAAA,EACsB;AAGtB,EAAA,MAAM,GAAA,GAAqB,EAAE,QAAA,EAAU,OAAA,sBAAa,GAAA,CAAI,CAAC,CAAC,OAAA,EAAS,YAAA,CAAa,GAAG,CAAC,CAAC,CAAC,CAAA,EAAE;AAExF,EAAA,MAAM,QAAA,uBAAe,GAAA,EAAY;AACjC,EAAA,KAAA,MAAW,QAAQ,UAAA,EAAY;AAG7B,IAAA,IAAI,MAAM,eAAe,GAAA,EAAK,OAAA,EAAS,MAAM,CAAA,kBAAG,IAAI,GAAA,EAAK,CAAA,EAAG;AAC1D,MAAA,QAAA,CAAS,IAAI,IAAI,CAAA;AAAA,IACnB;AAAA,EACF;AACA,EAAA,OAAO,QAAA;AACT;AAQO,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IAAI,YAAA,EAAc,KAAA,GAAQ,GAAG,OAAO,CAAA;AAC1E;AAEA,eAAe,cAAA,CAAe,KAAoB,QAAA,EAAoD;AACpG,EAAA,IAAI,GAAA,CAAI,QAAQ,GAAA,CAAI,QAAQ,GAAG,OAAO,GAAA,CAAI,OAAA,CAAQ,GAAA,CAAI,QAAQ,CAAA;AAE9D,EAAA,IAAI,KAAA;AACJ,EAAA,IAAI;AACF,IAAA,MAAM,IAAA,GAAO,GAAA,CAAI,QAAA,CAAS,QAAA,GACtB,IAAI,QAAA,CAAS,QAAA,CAAS,QAAQ,CAAA,GAC9B,aAAa,QAAA,CAAS,OAAA,CAAQ,SAAA,EAAW,EAAE,GAAG,MAAM,CAAA;AACxD,IAAA,IAAI,OAAO,SAAS,QAAA,EAAU;AAC5B,MAAA,KAAA,GAAQ,gBAAgB,IAAI,CAAA;AAAA,IAC9B;AAAA,EACF,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,GAAA,CAAI,OAAA,CAAQ,GAAA,CAAI,QAAA,EAAU,KAAK,CAAA;AAC/B,EAAA,OAAO,KAAA;AACT;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"autoInstrument.js","sources":["../../../src/vite/autoInstrument.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport { collectAgentCandidates, detectAgentClasses, type ModuleResolver } from './agentClass';\nimport { buildOptionsImport, ENV_FALLBACK_OPTIONS_FN, resolveInstrumentFile } from './instrumentFile';\nimport { applyAutoInstrumentTransforms, type ClassWrapperKind, type ProgramBody } from './transform';\nimport { resolveWranglerConfig, type WranglerConfig } from './wranglerConfig';\n\n// Vite normalizes module IDs to posix separators even on Windows, while\n// `path.resolve` yields backslashes there — normalize before comparing.\nfunction normalizePath(path: string): string {\n return path.replace(/\\\\/g, '/');\n}\n\n// Extensions the entry-module match may tolerate swapping (e.g. wrangler's\n// `main` says `.ts` but the served module is `.js`). Anything else — `.css`,\n// `.html`, … — sharing the entry's basename must never be treated as the entry.\nconst JS_EXTENSION_REGEX = /\\.[cm]?[jt]sx?$/;\n\nexport function sentryCloudflareAutoInstrumentPlugin(options: { wranglerConfigPath?: string } = {}) {\n let wranglerConfig: WranglerConfig | undefined;\n let entryFilePath: string | undefined;\n\n let optionsFn = ENV_FALLBACK_OPTIONS_FN;\n let optionsImport: string | undefined;\n\n return {\n name: 'sentry-cloudflare-auto-instrument',\n\n configResolved(config: { root: string; logger?: { warn(msg: string): void } }): void {\n const result = resolveWranglerConfig(config.root, options.wranglerConfigPath);\n if (!result) {\n // An explicit path that fails is a misconfiguration worth naming;\n // without one, hint at the option so custom-named configs (e.g. a\n // `configPath` handed to @cloudflare/vite-plugin) are discoverable.\n config.logger?.warn(\n options.wranglerConfigPath\n ? `[sentry] Could not find or parse the wrangler config \"${basename(options.wranglerConfigPath)}\" ` +\n '(resolved against the Vite root) — auto-instrumentation disabled.'\n : '[sentry] No parseable wrangler config found — auto-instrumentation disabled. ' +\n 'Set `wranglerConfigPath` if your config uses a custom name.',\n );\n return;\n }\n\n wranglerConfig = result.config;\n if (wranglerConfig.main) {\n // `main` is already absolute (wrangler resolves it); just normalize\n // separators so the entry-module comparison holds on Windows.\n entryFilePath = normalizePath(wranglerConfig.main);\n }\n\n if (entryFilePath) {\n const instrumentFilePath = resolveInstrumentFile(entryFilePath);\n if (instrumentFilePath) {\n const built = buildOptionsImport(entryFilePath, instrumentFilePath);\n optionsFn = built.optionsFn;\n optionsImport = built.importStmt;\n }\n }\n },\n\n async transform(\n this: ModuleResolver & { warn?(msg: string): void; environment?: { name?: string } },\n code: string,\n id: string,\n ): Promise<{ code: string; map: unknown } | undefined> {\n if (!wranglerConfig || !entryFilePath) return undefined;\n\n // The worker entry never belongs to the client (browser) environment.\n // Skipping it keeps a same-basename sibling (e.g. a `src/index.tsx`\n // client entry next to a `src/index.ts` worker) out of the browser bundle.\n if (this.environment?.name === 'client') return undefined;\n\n // Vite may append query/hash params to the module ID.\n const normalizedId = normalizePath(id.replace(/[?#].*$/, ''));\n if (normalizedId !== entryFilePath) {\n // Tolerate a differing JS-flavored extension (e.g. `.js` vs `.ts`).\n if (!JS_EXTENSION_REGEX.test(normalizedId) || !JS_EXTENSION_REGEX.test(entryFilePath)) return undefined;\n if (normalizedId.replace(JS_EXTENSION_REGEX, '') !== entryFilePath.replace(JS_EXTENSION_REGEX, '')) {\n return undefined;\n }\n }\n\n let ast: ProgramBody;\n try {\n ast = this.parse(code);\n } catch {\n // Raw TypeScript or syntax error — esbuild hasn't run yet (unlikely)\n // or the file is genuinely broken. Either way, skip silently.\n return undefined;\n }\n\n const classWrappers = new Map<string, ClassWrapperKind>();\n for (const { className } of wranglerConfig.durableObjects) {\n classWrappers.set(className, 'durableObject');\n }\n for (const { className } of wranglerConfig.workflows) {\n classWrappers.set(className, 'workflow');\n }\n for (const className of wranglerConfig.workerEntrypoints) {\n classWrappers.set(className, 'workerEntrypoint');\n }\n\n // An `agents` Agent is a Durable Object, so wrangler lists it among the DO bindings and only\n // its base-class chain tells the two apart. Detection walks the module graph (base classes\n // usually live in their own file), so it is limited to the configured DO classes.\n //\n // Only `resolve` is handed over — never `load`: awaiting `load()` from inside a transform\n // hook deadlocks the build, since the module can't finish loading while this transform is\n // still pending. `agentClass` reads sibling modules off disk instead.\n const agentCandidates = collectAgentCandidates(\n ast,\n [...classWrappers].filter(([, kind]) => kind === 'durableObject').map(([name]) => name),\n );\n const agentClasses =\n agentCandidates.size > 0\n ? await detectAgentClasses(ast, normalizedId, agentCandidates, {\n parse: code => this.parse(code),\n resolve: this.resolve ? (source, importer) => this.resolve!(source, importer) : undefined,\n })\n : undefined;\n\n // No registration import is injected here: the orchestrion plugin's\n // subscribe-injection makes each bundled package self-register its channel\n // subscriber on the global marker, so wrapping the entry with `withSentry`\n // is all this plugin needs to do.\n const result = applyAutoInstrumentTransforms(code, ast, {\n classWrappers,\n agentClasses,\n optionsFn,\n optionsImport,\n });\n\n const wrappedClasses = result?.wrappedClasses ?? new Set<string>();\n const missing = [...classWrappers.keys()].filter(name => !wrappedClasses.has(name));\n if (missing.length > 0) {\n this.warn?.(\n `[sentry] Could not auto-instrument class(es) ${missing.join(', ')}: no matching exported class ` +\n 'declaration found in the worker entry (re-exports from other modules cannot be wrapped ' +\n 'automatically). Wrap them manually with the matching `instrument*WithSentry` helper.',\n );\n }\n\n return result ?? undefined;\n },\n };\n}\n"],"names":["code"],"mappings":";;;;;;AAQA,SAAS,cAAc,IAAA,EAAsB;AAC3C,EAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,GAAG,CAAA;AAChC;AAKA,MAAM,kBAAA,GAAqB,iBAAA;AAEpB,SAAS,oCAAA,CAAqC,OAAA,GAA2C,EAAC,EAAG;AAClG,EAAA,IAAI,cAAA;AACJ,EAAA,IAAI,aAAA;AAEJ,EAAA,IAAI,SAAA,GAAY,uBAAA;AAChB,EAAA,IAAI,aAAA;AAEJ,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,mCAAA;AAAA,IAEN,eAAe,MAAA,EAAsE;AACnF,MAAA,MAAM,MAAA,GAAS,qBAAA,CAAsB,MAAA,CAAO,IAAA,EAAM,QAAQ,kBAAkB,CAAA;AAC5E,MAAA,IAAI,CAAC,MAAA,EAAQ;AAIX,QAAA,MAAA,CAAO,MAAA,EAAQ,IAAA;AAAA,UACb,QAAQ,kBAAA,GACJ,CAAA,sDAAA,EAAyD,SAAS,OAAA,CAAQ,kBAAkB,CAAC,CAAA,wEAAA,CAAA,GAE7F;AAAA,SAEN;AACA,QAAA;AAAA,MACF;AAEA,MAAA,cAAA,GAAiB,MAAA,CAAO,MAAA;AACxB,MAAA,IAAI,eAAe,IAAA,EAAM;AAGvB,QAAA,aAAA,GAAgB,aAAA,CAAc,eAAe,IAAI,CAAA;AAAA,MACnD;AAEA,MAAA,IAAI,aAAA,EAAe;AACjB,QAAA,MAAM,kBAAA,GAAqB,sBAAsB,aAAa,CAAA;AAC9D,QAAA,IAAI,kBAAA,EAAoB;AACtB,UAAA,MAAM,K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,6CAAA,EAAgD,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAC,CAAA,0MAAA;AAAA,SAGpE;AAAA,MACF;AAEA,MAAA,OAAO,MAAA,IAAU,MAAA;AAAA,IACnB;AAAA,GACF;AACF;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/vite/index.ts"],"sourcesContent":["// Published ESM-only via the `@sentry/cloudflare/vite` subpath export:\n// `@sentry/server-utils/orchestrion/vite` exposes no `require` condition, so a\n// CJS entry here would fail at resolution time (ERR_PACKAGE_PATH_NOT_EXPORTED).\n// The CJS rollup variant still emits this file, but `package.json` doesn't\n// expose it — same setup as `@sentry/server-utils/orchestrion/vite` itself.\nimport { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/vite';\nimport { sentryCloudflareAutoInstrumentPlugin } from './autoInstrument';\n\n/**\n * Options for {@link sentryCloudflareVitePlugin}.\n */\nexport interface SentryCloudflareVitePluginOptions {\n /**\n * Path to the wrangler config, relative to the Vite root (or absolute).\n * Set this when your config doesn't use a default name — e.g. when you\n * pass `configPath: './wrangler.agent.jsonc'` to `@cloudflare/vite-plugin`,\n * which the Sentry plugin cannot see. When set, only this file is read\n * (no default-name probing), and a warning is emitted if it is missing or\n * unparseable.\n *\n * @default undefined (probes `wrangler.json`, `wrangler.jsonc`, `wrangler.toml` at the Vite root)\n */\n wranglerConfigPath?: string;\n /**\n * Experimental options that may change or be removed without notice.\n */\n _experimental?: {\n /**\n * Enables build-time automatic instrumentation of supported dependencies\n * (e.g. database clients like `mysql`) so the Sentry Cloudflare SDK can\n * trace them without monkey-patching, which wouldn't work in workerd anyway.\n *\n * When enabled, the plugin injects `diagnostics_channel.tracingChannel`\n * calls into the bundled packages and, next to each, a snippet that\n * registers the matching Sentry channel-subscriber factory on the global\n * marker, which the SDK picks up in `Sentry.withSentry()`. Both `vite build`\n * and `vite dev` are instrumented.\n *\n * @default false\n * @experimental May change or be removed in any release.\n */\n useDiagnosticsChannelInjection?: boolean;\n /**\n * Automatically wraps your Worker at build time so you don't have to edit\n * your entry: the plugin reads your wrangler config, wraps the default\n * export with `Sentry.withSentry()` (sourcing options from a co-located\n * `instrument.*` file, falling back to env), and wraps any configured\n * Durable Object class with `instrumentDurableObjectWithSentry`. Both\n * `vite build` and `vite dev` are instrumented.\n *\n * @default false\n * @experimental May change or be removed in any release.\n */\n autoInstrumentation?: boolean;\n };\n}\n\n/**\n * Sentry Vite plugin for Cloudflare Workers.\n *\n * Add this plugin to your Vite configuration to enable additional Sentry\n * instrumentation for Cloudflare Workers built with Vite. Configure the Sentry\n * SDK in your Worker as usual with `Sentry.withSentry()`.\n *\n * Currently, the only functionality is the experimental\n * `_experimental.useDiagnosticsChannelInjection` option, which traces supported\n * dependencies (such as database clients) without changing your application\n * code. Without it, the plugin is a no-op.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { cloudflare } from '@cloudflare/vite-plugin';\n * import { sentryCloudflareVitePlugin } from '@sentry/cloudflare/vite';\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * plugins: [\n * cloudflare(),\n * sentryCloudflareVitePlugin({\n * _experimental: {\n * useDiagnosticsChannelInjection: true,\n * },\n * }),\n * ],\n * });\n * ```\n */\nexport function sentryCloudflareVitePlugin(options: SentryCloudflareVitePluginOptions = {}) {\n return [\n ...(options._experimental?.useDiagnosticsChannelInjection\n ? [sentryOrchestrionPlugin({ injectChannelSubscribers: true })]\n : []),\n ...(options._experimental?.autoInstrumentation\n ? [sentryCloudflareAutoInstrumentPlugin({ wranglerConfigPath: options.wranglerConfigPath })]\n : []),\n ];\n}\n"],"names":[],"mappings":";;;AAwFO,SAAS,0BAAA,CAA2B,OAAA,GAA6C,EAAC,EAAG;AAC1F,EAAA,OAAO;AAAA,IACL,GAAI,OAAA,CAAQ,aAAA,EAAe,8BAAA,GACvB,CAAC,uBAAA,CAAwB,EAAE,wBAAA,EAA0B,IAAA,EAAM,CAAC,CAAA,GAC5D,EAAC;AAAA,IACL,GAAI,OAAA,CAAQ,aAAA,EAAe,mBAAA,GACvB,CAAC,oCAAA,CAAqC,EAAE,kBAAA,EAAoB,OAAA,CAAQ,kBAAA,EAAoB,CAAC,IACzF;AAAC,GACP;AACF;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"instrumentFile.js","sources":["../../../src/vite/instrumentFile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, relative, resolve } from 'node:path';\n\n// Fallback options callback used when no instrument file is present. Returning\n// `undefined` makes the SDK read all configuration (DSN, release, environment,\n// sample rate, …) from the worker's `env` at runtime.\nexport const ENV_FALLBACK_OPTIONS_FN = '() => undefined';\n\n// Identifier the generated import binds the user's options module to.\nconst OPTIONS_IMPORT_IDENTIFIER = '__SENTRY_OPTIONS_CALLBACK__';\n\n// Conventional, non-configurable name of the Sentry options module. It is\n// looked up next to the worker entry file; its default export is the options\n// callback `(env) => CloudflareOptions`.\nconst INSTRUMENT_FILE_BASENAME = 'instrument.server';\nconst INSTRUMENT_FILE_EXTENSIONS = ['ts', 'mts', 'js', 'mjs', 'cjs'];\n\n/**\n * Locate the conventional `instrument.server.*` module sitting next to the\n * worker entry file. Returns its absolute path, or `undefined` when absent.\n */\nexport function resolveInstrumentFile(entryFilePath: string): string | undefined {\n const dir = dirname(entryFilePath);\n for (const ext of INSTRUMENT_FILE_EXTENSIONS) {\n const candidate = resolve(dir, `${INSTRUMENT_FILE_BASENAME}.${ext}`);\n if (existsSync(candidate)) return candidate;\n }\n return undefined;\n}\n\n/**\n * Build the `optionsFn` reference and `import` statement for the instrument\n * module whose **default export** is the options callback\n * `(env) => CloudflareOptions`.\n *\n * The import is emitted relative to `entryFilePath` because it is injected into\n * the entry file's source. The file extension is kept: extensionless specifiers\n * only resolve for extensions in Vite's default `resolve.extensions` (which\n * excludes `.cjs`), and keeping it makes our probe order authoritative when\n * several `instrument.server.*` files coexist.\n */\nexport function buildOptionsImport(\n entryFilePath: string,\n instrumentFilePath: string,\n): { optionsFn: string; importStmt: string } {\n let relativePath = relative(dirname(entryFilePath), instrumentFilePath).replace(/\\\\/g, '/');\n if (!relativePath.startsWith('.')) relativePath = `./${relativePath}`;\n\n return {\n optionsFn: OPTIONS_IMPORT_IDENTIFIER,\n importStmt: `import ${OPTIONS_IMPORT_IDENTIFIER} from '${relativePath}';\\n`,\n };\n}\n"],"names":[],"mappings":";;;AAMO,MAAM,uBAAA,GAA0B;AAGvC,MAAM,yBAAA,GAA4B,6BAAA;AAKlC,MAAM,wBAAA,GAA2B,mBAAA;AACjC,MAAM,6BAA6B,CAAC,IAAA,EAAM,KAAA,EAAO,IAAA,EAAM,OAAO,KAAK,CAAA;AAM5D,SAAS,sBAAsB,aAAA,EAA2C;AAC/E,EAAA,MAAM,GAAA,GAAM,QAAQ,aAAa,CAAA;AACjC,EAAA,KAAA,MAAW,OAAO,0BAAA,EAA4B;AAC5C,IAAA,MAAM,YAAY,OAAA,CAAQ,GAAA,EAAK,GAAG,wBAAwB,CAAA,CAAA,EAAI,GAAG,CAAA,CAAE,CAAA;AACnE,IAAA,IAAI,UAAA,CAAW,SAAS,CAAA,EAAG,OAAO,SAAA;AAAA,EACpC;AACA,EAAA,OAAO,MAAA;AACT;AAaO,SAAS,kBAAA,CACd,eACA,kBAAA,EAC2C;AAC3C,EAAA,IAAI,YAAA,GAAe,SAAS,OAAA,CAAQ,aAAa,GAAG,kBAAkB,CAAA,CAAE,OAAA,CAAQ,KAAA,EAAO,GAAG,CAAA;AAC1F,EAAA,IAAI,CAAC,YAAA,CAAa,UAAA,CAAW,GAAG,CAAA,EAAG,YAAA,GAAe,KAAK,YAAY,CAAA,CAAA;AAEnE,EAAA,OAAO;AAAA,IACL,SAAA,EAAW,yBAAA;AAAA,IACX,UAAA,EAAY,CAAA,OAAA,EAAU,yBAAyB,CAAA,OAAA,EAAU,YAAY,CAAA;AAAA;AAAA,GACvE;AACF;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"moduleShape.js","sources":["../../../src/vite/moduleShape.ts"],"sourcesContent":["import type { BaseNode, ProgramBody } from './transform';\n\n// ---------------------------------------------------------------------------\n// Minimal ESTree node shapes for structural Agent detection.\n// ---------------------------------------------------------------------------\n\ninterface IdentifierNode extends BaseNode {\n name: string;\n}\n\ninterface ClassNode extends BaseNode {\n id?: IdentifierNode | null;\n superClass?: BaseNode | null;\n}\n\ninterface MemberExpressionNode extends BaseNode {\n object?: { type: string; name?: string };\n property?: { type: string; name?: string };\n}\n\ninterface ImportSpecifierNode {\n type: string;\n imported?: { type: string; name?: string };\n local?: { type: string; name?: string };\n}\n\ninterface ImportDeclarationNode extends BaseNode {\n source?: { value?: unknown };\n specifiers?: ImportSpecifierNode[];\n}\n\ninterface ExportSpecifierNode {\n type: string;\n local?: { type: string; name?: string };\n exported?: { type: string; name?: string };\n}\n\ninterface ExportNamedNode extends BaseNode {\n declaration?: BaseNode | null;\n source?: { value?: unknown } | null;\n specifiers?: ExportSpecifierNode[];\n}\n\ninterface ExportDefaultNode extends BaseNode {\n declaration: BaseNode;\n}\n\ninterface ExportAllNode extends BaseNode {\n source?: { value?: unknown };\n exported?: { type: string; name?: string } | null;\n}\n\n/** Binding name used for a module's default export. */\nexport const DEFAULT_EXPORT = 'default';\n\n/** A resolved superclass reference: a bare identifier or a `ns.Member` expression. */\nexport type SuperRef = { kind: 'identifier'; name: string } | { kind: 'member'; object: string; property: string };\n\n/** The declarations of a single module that binding resolution needs. */\nexport interface ModuleShape {\n /** Top-level class names → their superclass reference (absent when the class has no `extends`). */\n classes: Map<string, SuperRef | undefined>;\n /** Local binding name → the import it came from (`imported` is `default` for a default import). */\n imports: Map<string, { source: string; imported: string }>;\n /** Local binding name → module specifier, for `import * as ns from '...'`. */\n namespaces: Map<string, string>;\n /** Exported name → the re-export it came from, for `export { x as y } from '...'`. */\n reexports: Map<string, { source: string; imported: string }>;\n /** Exported name → local binding name, for `export { x as y }` without a source. */\n localExports: Map<string, string>;\n /** Module specifiers of bare `export * from '...'` declarations. */\n starExports: string[];\n /** `export default <Identifier>` — the local name it refers to. */\n defaultExportName?: string;\n /** True when the module's default export is a class declaration/expression. */\n defaultExportIsClass?: boolean;\n /** Superclass of an anonymous `export default class extends X`. */\n defaultExportSuper?: SuperRef;\n}\n\nfunction emptyShape(): ModuleShape {\n return {\n classes: new Map(),\n imports: new Map(),\n namespaces: new Map(),\n reexports: new Map(),\n localExports: new Map(),\n starExports: [],\n };\n}\n\n// ---------------------------------------------------------------------------\n// Shape from a parsed AST (used for the entry module)\n// ---------------------------------------------------------------------------\n\n/** Collect the shape of a module from its parsed AST — used for the already-parsed entry module. */\nexport function shapeFromAst(ast: ProgramBody): ModuleShape {\n const shape = emptyShape();\n\n for (const node of ast.body) {\n switch (node.type) {\n case 'ClassDeclaration':\n addAstClass(shape, node as ClassNode);\n break;\n case 'ImportDeclaration':\n addAstImports(shape, node as ImportDeclarationNode);\n break;\n case 'ExportNamedDeclaration':\n addAstNamedExport(shape, node as ExportNamedNode);\n break;\n case 'ExportDefaultDeclaration': {\n const decl = (node as ExportDefaultNode).declaration;\n if (decl.type === 'ClassDeclaration' || decl.type === 'ClassExpression') {\n shape.defaultExportIsClass = true;\n shape.defaultExportSuper = superRefFromNode((decl as ClassNode).superClass);\n // `export default class Foo {}` also binds `Foo` locally.\n addAstClass(shape, decl as ClassNode);\n } else if (decl.type === 'Identifier') {\n shape.defaultExportName = (decl as IdentifierNode).name;\n }\n break;\n }\n case 'ExportAllDeclaration': {\n const starNode = node as ExportAllNode;\n // `export * as ns from '...'` binds a namespace object, not the individual exports.\n const source = starNode.exported ? undefined : asString(starNode.source?.value);\n if (source) shape.starExports.push(source);\n break;\n }\n }\n }\n\n return shape;\n}\n\nfunction superRefFromNode(superClass: BaseNode | null | undefined): SuperRef | undefined {\n if (!superClass) return undefined;\n\n if (superClass.type === 'Identifier') {\n return { kind: 'identifier', name: (superClass as IdentifierNode).name };\n }\n\n if (superClass.type === 'MemberExpression') {\n const member = superClass as MemberExpressionNode;\n const object = member.object?.type === 'Identifier' ? member.object.name : undefined;\n const property = member.property?.name;\n if (object && property) return { kind: 'member', object, property };\n }\n\n return undefined;\n}\n\nfunction addAstClass(shape: ModuleShape, classNode: ClassNode): void {\n if (classNode.id?.name) shape.classes.set(classNode.id.name, superRefFromNode(classNode.superClass));\n}\n\nfunction addAstImports(shape: ModuleShape, node: ImportDeclarationNode): void {\n const source = asString(node.source?.value);\n if (!source) return;\n\n for (const specifier of node.specifiers ?? []) {\n const local = specifier.local?.name;\n if (!local) continue;\n\n if (specifier.type === 'ImportSpecifier' && specifier.imported?.name) {\n shape.imports.set(local, { source, imported: specifier.imported.name });\n } else if (specifier.type === 'ImportDefaultSpecifier') {\n shape.imports.set(local, { source, imported: DEFAULT_EXPORT });\n } else if (specifier.type === 'ImportNamespaceSpecifier') {\n shape.namespaces.set(local, source);\n }\n }\n}\n\nfunction addAstNamedExport(shape: ModuleShape, node: ExportNamedNode): void {\n if (node.declaration?.type === 'ClassDeclaration') {\n addAstClass(shape, node.declaration as ClassNode);\n return;\n }\n\n const source = asString(node.source?.value);\n for (const specifier of node.specifiers ?? []) {\n const exported = specifier.exported?.name;\n const local = specifier.local?.name;\n if (!exported || !local) continue;\n\n if (source) {\n shape.reexports.set(exported, { source, imported: local });\n } else {\n shape.localExports.set(exported, local);\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Shape from raw source (used for sibling modules read off disk)\n// ---------------------------------------------------------------------------\n\n/**\n * Extract the module shape from **unprocessed source**.\n *\n * Sibling modules are read straight from disk (the plugin context's `load()` would deadlock inside a\n * transform hook), so they may still be TypeScript — which no JS parser will accept. Only\n * import/export statements and `class X extends Y` headers matter here, and those are\n * declaration-level syntax a scan can pick out reliably; class bodies, type annotations and generics\n * are irrelevant and simply skipped.\n */\nexport function shapeFromSource(rawCode: string): ModuleShape {\n const code = stripComments(rawCode);\n const shape = emptyShape();\n\n // `class X extends Y {` / `class X<T> extends Y<T> {`, optionally exported and/or abstract.\n const CLASS_RE = /\\b(?:export\\s+(?:default\\s+)?)?(?:abstract\\s+)?class\\s+([A-Za-z_$][\\w$]*)([^{]*)\\{/g;\n for (const match of code.matchAll(CLASS_RE)) {\n const className = match[1]!;\n const isDefault = /\\bexport\\s+default\\b/.test(match[0]);\n const superRef = superRefFromHeader(match[2] ?? '');\n\n shape.classes.set(className, superRef);\n if (isDefault) {\n shape.defaultExportIsClass = true;\n shape.defaultExportSuper = superRef;\n }\n }\n\n // `export default Identifier;`\n const defaultExprMatch = /\\bexport\\s+default\\s+([A-Za-z_$][\\w$]*)\\s*;/.exec(code);\n if (defaultExprMatch && !shape.defaultExportIsClass) {\n shape.defaultExportName = defaultExprMatch[1];\n }\n\n // `export * from '...'` (but not `export * as ns from '...'`).\n for (const match of code.matchAll(/\\bexport\\s*\\*\\s*from\\s*['\"]([^'\"]+)['\"]/g)) {\n if (match[1]) shape.starExports.push(match[1]);\n }\n\n // `export { a, b as c } from '...'` and `export { a, b as c }`.\n for (const match of code.matchAll(/\\bexport\\s*\\{([^}]*)\\}\\s*(?:from\\s*['\"]([^'\"]+)['\"])?/g)) {\n const source = match[2];\n for (const { imported, local } of parseSpecifierList(match[1] ?? '')) {\n // In an export clause the first name is local and the alias is the exported name.\n if (source) {\n shape.reexports.set(local, { source, imported });\n } else {\n shape.localExports.set(local, imported);\n }\n }\n }\n\n // `import Default, { a as b }, * as ns from '...'` in its various shapes.\n for (const match of code.matchAll(/\\bimport\\s+([^'\";]+?)\\s+from\\s*['\"]([^'\"]+)['\"]/g)) {\n addSourceImports(shape, match[1] ?? '', match[2]!);\n }\n\n return shape;\n}\n\n/** Pull the superclass out of the text between a class name and its body. */\nfunction superRefFromHeader(header: string): SuperRef | undefined {\n // The header still carries the class's own generic parameter list (`<T extends S>`), whose\n // constraint `extends` would otherwise be mistaken for the superclass clause. Strip a leading\n // balanced `<...>` first, then read the (possibly dotted) base name. Trailing generic args on the\n // base (`extends Agent<Env>`) stop the match naturally.\n const withoutParams = stripLeadingGenerics(header);\n const match = /\\bextends\\s+([A-Za-z_$][\\w$]*)\\s*(?:\\.\\s*([A-Za-z_$][\\w$]*))?/.exec(withoutParams);\n if (!match) return undefined;\n\n return match[2] ? { kind: 'member', object: match[1]!, property: match[2] } : { kind: 'identifier', name: match[1]! };\n}\n\n/**\n * Remove a leading `<...>` generic parameter list, honoring nesting (`<T extends Map<K, V>>`).\n * Anything after the balanced close — the superclass clause — is returned unchanged. When the\n * header doesn't start with `<` (no generics), it is returned as-is.\n */\nfunction stripLeadingGenerics(header: string): string {\n const start = header.indexOf('<');\n // Only treat it as a parameter list when `<` is the first meaningful token — a `<` appearing\n // later is part of the superclass's own generic args and must be left alone.\n if (start === -1 || header.slice(0, start).trim() !== '') return header;\n\n let depth = 0;\n for (let i = start; i < header.length; i++) {\n const char = header[i];\n if (char === '<') depth++;\n else if (char === '>') {\n depth--;\n if (depth === 0) return header.slice(i + 1);\n }\n }\n // Unbalanced `<` — fall back to the untouched header rather than dropping the superclass.\n return header;\n}\n\n/** Parse `a, b as c` into `{ imported: 'b', local: 'c' }` pairs (type-only specifiers dropped). */\nfunction parseSpecifierList(clause: string): Array<{ imported: string; local: string }> {\n const specifiers: Array<{ imported: string; local: string }> = [];\n\n for (const rawPart of clause.split(',')) {\n const part = rawPart.trim().replace(/^type\\s+/, '');\n if (!part) continue;\n\n const aliased = /^([A-Za-z_$][\\w$]*)\\s+as\\s+([A-Za-z_$][\\w$]*)$/.exec(part);\n if (aliased) {\n specifiers.push({ imported: aliased[1]!, local: aliased[2]! });\n } else if (/^[A-Za-z_$][\\w$]*$/.test(part)) {\n specifiers.push({ imported: part, local: part });\n }\n }\n\n return specifiers;\n}\n\nfunction addSourceImports(shape: ModuleShape, clause: string, source: string): void {\n // Type-only imports never contribute a runtime base class.\n if (/^type\\s/.test(clause.trim())) return;\n\n const namespaceMatch = /\\*\\s*as\\s+([A-Za-z_$][\\w$]*)/.exec(clause);\n if (namespaceMatch) {\n shape.namespaces.set(namespaceMatch[1]!, source);\n }\n\n const bracesMatch = /\\{([^}]*)\\}/.exec(clause);\n if (bracesMatch) {\n for (const { imported, local } of parseSpecifierList(bracesMatch[1] ?? '')) {\n shape.imports.set(local, { source, imported });\n }\n }\n\n // A leading bare identifier (before any brace/star) is the default import.\n const defaultMatch = /^\\s*([A-Za-z_$][\\w$]*)\\s*(?:,|$)/.exec(clause);\n if (defaultMatch) {\n shape.imports.set(defaultMatch[1]!, { source, imported: DEFAULT_EXPORT });\n }\n}\n\n/** Remove line and block comments, leaving string literals (module specifiers) intact. */\nfunction stripComments(code: string): string {\n let result = '';\n let index = 0;\n\n while (index < code.length) {\n const char = code[index]!;\n const next = code[index + 1];\n\n if (char === '/' && next === '/') {\n while (index < code.length && code[index] !== '\\n') index++;\n continue;\n }\n\n if (char === '/' && next === '*') {\n index += 2;\n while (index < code.length && !(code[index] === '*' && code[index + 1] === '/')) index++;\n index += 2;\n // Keep a separator so `*/class` doesn't fuse into one token.\n result += ' ';\n continue;\n }\n\n if (char === '\"' || char === \"'\" || char === '`') {\n const quote = char;\n result += char;\n index++;\n while (index < code.length) {\n const inner = code[index]!;\n result += inner;\n index++;\n if (inner === '\\\\') {\n if (index < code.length) {\n result += code[index]!;\n index++;\n }\n continue;\n }\n if (inner === quote) break;\n }\n continue;\n }\n\n result += char;\n index++;\n }\n\n return result;\n}\n\nfunction asString(value: unknown): string | undefined {\n return typeof value === 'string' && value ? value : undefined;\n}\n"],"names":[],"mappings":"AAqDO,MAAM,cAAA,GAAiB;AA2B9B,SAAS,UAAA,GAA0B;AACjC,EAAA,OAAO;AAAA,IACL,OAAA,sBAAa,GAAA,EAAI;AAAA,IACjB,OAAA,sBAAa,GAAA,EAAI;AAAA,IACjB,UAAA,sBAAgB,GAAA,EAAI;AAAA,IACpB,SAAA,sBAAe,GAAA,EAAI;AAAA,IACnB,YAAA,sBAAkB,GAAA,EAAI;AAAA,IACtB,aAAa;AAAC,GAChB;AACF;AAOO,SAAS,aAAa,GAAA,EAA+B;AAC1D,EAAA,MAAM,QAAQ,UA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AA,IAAS,CAAA;AACT,MAAA,OAAO,KAAA,GAAQ,IAAA,CAAK,MAAA,IAAU,EAAE,IAAA,CAAK,KAAK,CAAA,KAAM,GAAA,IAAO,IAAA,CAAK,KAAA,GAAQ,CAAC,CAAA,KAAM,GAAA,CAAA,EAAM,KAAA,EAAA;AACjF,MAAA,KAAA,IAAS,CAAA;AAET,MAAA,MAAA,IAAU,GAAA;AACV,MAAA;AAAA,IACF;AAEA,IAAA,IAAI,IAAA,KAAS,GAAA,IAAO,IAAA,KAAS,GAAA,IAAO,SAAS,GAAA,EAAK;AAChD,MAAA,MAAM,KAAA,GAAQ,IAAA;AACd,MAAA,MAAA,IAAU,IAAA;AACV,MAAA,KAAA,EAAA;AACA,MAAA,OAAO,KAAA,GAAQ,KAAK,MAAA,EAAQ;AAC1B,QAAA,MAAM,KAAA,GAAQ,KAAK,KAAK,CAAA;AACxB,QAAA,MAAA,IAAU,KAAA;AACV,QAAA,KAAA,EAAA;AACA,QAAA,IAAI,UAAU,IAAA,EAAM;AAClB,UAAA,IAAI,KAAA,GAAQ,KAAK,MAAA,EAAQ;AACvB,YAAA,MAAA,IAAU,KAAK,KAAK,CAAA;AACpB,YAAA,KAAA,EAAA;AAAA,UACF;AACA,UAAA;AAAA,QACF;AACA,QAAA,IAAI,UAAU,KAAA,EAAO;AAAA,MACvB;AACA,MAAA;AAAA,IACF;AAEA,IAAA,MAAA,IAAU,IAAA;AACV,IAAA,KAAA,EAAA;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,SAAS,KAAA,EAAoC;AACpD,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,GAAQ,KAAA,GAAQ,MAAA;AACtD;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"transform.js","sources":["../../../src/vite/transform.ts"],"sourcesContent":["import MagicString from 'magic-string';\nimport { detectWorkerEntrypointClasses } from './workerEntrypoint';\n\n// ---------------------------------------------------------------------------\n// Minimal ESTree node types for the AST nodes we inspect.\n// ---------------------------------------------------------------------------\n\nexport interface BaseNode {\n type: string;\n start: number;\n end: number;\n}\n\nexport interface ProgramBody {\n body: BaseNode[];\n}\n\ninterface IdentifierNode extends BaseNode {\n name: string;\n}\n\ninterface CalleeNode {\n type: string;\n name?: string;\n property?: { type: string; name?: string };\n}\n\ninterface CallExpressionNode extends BaseNode {\n callee?: CalleeNode;\n}\n\ninterface ClassDeclarationNode extends BaseNode {\n id?: IdentifierNode | null;\n}\n\ninterface ExportDefaultNode extends BaseNode {\n declaration: BaseNode;\n}\n\ninterface ExportSpecifierNode {\n type: string;\n local?: { type: string; name?: string };\n exported?: { type: string; name?: string };\n}\n\ninterface ExportNamedNode extends BaseNode {\n declaration?: BaseNode | null;\n source?: unknown;\n specifiers?: ExportSpecifierNode[];\n}\n\ninterface VariableDeclaratorNode {\n id?: { type: string; name?: string };\n init?: BaseNode | null;\n}\n\ninterface VariableDeclarationNode extends BaseNode {\n declarations?: VariableDeclaratorNode[];\n}\n\nfunction isCallToMethod(node: BaseNode, methodName: string): boolean {\n if (node.type !== 'CallExpression') return false;\n const callee = (node as CallExpressionNode).callee;\n if (!callee) return false;\n if (callee.type === 'Identifier' && callee.name === methodName) return true;\n return (\n callee.type === 'MemberExpression' && callee.property?.type === 'Identifier' && callee.property.name === methodName\n );\n}\n\n/**\n * The kind of Sentry wrapper to apply to an exported class.\n *\n * `durableObject` and `workflow` are keyed by name from the wrangler config\n * (`durable_objects.bindings`, `workflows`), since those class names are\n * authoritative there. `workerEntrypoint` is different: a worker's own\n * entrypoints aren't enumerated in its config, so they're detected structurally\n * (a class extending `WorkerEntrypoint` from `cloudflare:workers`), with the\n * config providing only a fallback for self-bound entrypoints whose base class\n * lives in another module.\n */\nexport type ClassWrapperKind = 'durableObject' | 'agent' | 'workflow' | 'workerEntrypoint';\n\n/**\n * The `@sentry/cloudflare` helper each wrapper kind emits. All share the same\n * `(optionsCallback, Class)` signature. `WorkerEntrypoint` classes use\n * `withSentry`, which runtime-detects the class type and routes accordingly.\n */\nconst WRAPPER_METHODS: Record<ClassWrapperKind, string> = {\n durableObject: 'instrumentDurableObjectWithSentry',\n agent: 'instrumentAgentWithSentry',\n workflow: 'instrumentWorkflowWithSentry',\n workerEntrypoint: 'withSentry',\n};\n\nexport interface TransformContext {\n /**\n * Exported class name → the kind of Sentry wrapper to apply. Populated from\n * the wrangler config, so the transform can wrap by name without resolving\n * each class's base type.\n */\n classWrappers: Map<string, ClassWrapperKind>;\n /**\n * Local class names detected as `agents` Agents. An Agent is configured as a Durable Object in\n * wrangler, so this upgrades those entries from `durableObject` to `agent`.\n */\n agentClasses?: ReadonlySet<string>;\n optionsFn: string;\n /** Import statement prepended when `optionsFn` references a separate module. */\n optionsImport?: string;\n}\n\nexport interface TransformResult {\n code: string;\n map: ReturnType<MagicString['generateMap']>;\n /**\n * The configured class names that were actually wrapped. Lets the plugin warn\n * about configured classes it could not find, instead of silently leaving\n * them uninstrumented.\n */\n wrappedClasses: Set<string>;\n}\n\n/**\n * Rewrite the worker entry source to wrap its default export with `withSentry`\n * and any configured class export with its matching Sentry wrapper (see\n * {@link TransformContext.classWrappers}, e.g. Durable Object classes with\n * `instrumentDurableObjectWithSentry`).\n *\n * Handles both `export class MyDO {}` and the specifier form\n * (`class MyDO {}` … `export { MyDO }` / `export { Foo as MyDO }`).\n * Re-exports from other modules (`export { MyDO } from './do'`) cannot be\n * wrapped here and are left alone — the plugin warns about them via\n * {@link TransformResult.wrappedClasses}.\n *\n * Exported (rather than inlined into the plugin) so it can be unit-tested with a\n * plain AST and no Vite context. Returns `undefined` when nothing was wrapped and\n * there are no already-manually-wrapped classes to report.\n */\nexport function applyAutoInstrumentTransforms(\n code: string,\n ast: ProgramBody,\n ctx: TransformContext,\n): TransformResult | undefined {\n const ms = new MagicString(code);\n const topLevelClasses = collectTopLevelClasses(ast);\n const state: TransformState = {\n ms,\n needsImport: false,\n wrappedClasses: new Set<string>(),\n topLevelClasses,\n renamedLocals: new Set<string>(),\n classWrappers: ctx.classWrappers,\n agentClasses: ctx.agentClasses ?? new Set<string>(),\n workerEntrypointClasses: detectWorkerEntrypointClasses(ast),\n };\n const { wrappedClasses } = state;\n\n // Named exports first, regardless of source order: the default-export handler\n // needs to know which local bindings a named export already wrapped, so it can\n // skip a class that is both exported by name and re-exported as default (which\n // would otherwise wrap it twice).\n for (const node of ast.body) {\n if (node.type === 'ExportNamedDeclaration') {\n handleNamedExport(node as ExportNamedNode, ctx, state);\n }\n }\n for (const node of ast.body) {\n if (node.type === 'ExportDefaultDeclaration') {\n wrapDefaultExport(node as ExportDefaultNode, ctx, state);\n }\n }\n\n if (!state.needsImport) {\n // Nothing was rewritten. Still surface any classes found already wrapped\n // manually (via `wrappedClasses`) so the caller doesn't warn about them;\n // return undefined only when there was nothing to report either.\n if (wrappedClasses.size === 0) return undefined;\n return { code, map: ms.generateMap({ hires: true }), wrappedClasses };\n }\n\n if (ctx.optionsImport) ms.prepend(ctx.optionsImport);\n ms.prepend(\"import * as __SENTRY__ from '@sentry/cloudflare';\\n\");\n\n return {\n code: ms.toString(),\n map: ms.generateMap({ hires: true }),\n wrappedClasses,\n };\n}\n\ninterface TransformState {\n ms: MagicString;\n needsImport: boolean;\n wrappedClasses: Set<string>;\n /**\n * Top-level (non-exported) class declarations, so specifier exports like\n * `export { MyDO }` can locate the class they refer to.\n */\n topLevelClasses: Map<string, ClassDeclarationNode>;\n /**\n * Local class names already renamed + wrapped, so two specifiers pointing at\n * the same class don't produce duplicate bindings.\n */\n renamedLocals: Set<string>;\n /** Class name → wrapper kind, keyed by the *exported* name (from config). */\n classWrappers: Map<string, ClassWrapperKind>;\n /** Local class names detected as `agents` Agents (see {@link TransformContext.agentClasses}). */\n agentClasses: ReadonlySet<string>;\n /**\n * Local class names detected as `WorkerEntrypoint` subclasses in this module,\n * so they can be wrapped without a config entry.\n */\n workerEntrypointClasses: Set<string>;\n}\n\n/**\n * Resolve the wrapper kind for a class export.\n *\n * Config (`classWrappers`) wins — it's authoritative for Durable Objects and\n * Workflows, and provides the self-binding fallback for WorkerEntrypoints whose\n * base class this module can't see. Otherwise a structurally-detected\n * `WorkerEntrypoint` subclass (matched by its *local* name) gets wrapped with\n * `withSentry`.\n *\n * The one case where config is refined rather than obeyed is an `agents` Agent:\n * it *is* a Durable Object, so wrangler can only ever describe it as one, and\n * only the detected base chain distinguishes the two.\n */\nfunction resolveWrapperKind(\n exportedName: string,\n localName: string | undefined,\n state: TransformState,\n): ClassWrapperKind | undefined {\n const configured = state.classWrappers.get(exportedName);\n if (configured === 'durableObject' && localName && state.agentClasses.has(localName)) return 'agent';\n if (configured) return configured;\n if (localName && state.workerEntrypointClasses.has(localName)) return 'workerEntrypoint';\n return undefined;\n}\n\nfunction collectTopLevelClasses(ast: ProgramBody): Map<string, ClassDeclarationNode> {\n const classes = new Map<string, ClassDeclarationNode>();\n for (const node of ast.body) {\n if (node.type !== 'ClassDeclaration') continue;\n const classNode = node as ClassDeclarationNode;\n if (classNode.id?.name) classes.set(classNode.id.name, classNode);\n }\n return classes;\n}\n\nfunction wrapDefaultExport(node: ExportDefaultNode, ctx: TransformContext, state: TransformState): void {\n const decl = node.declaration;\n\n // Already wrapped — leave it alone\n if (isCallToMethod(decl, 'withSentry')) return;\n\n // `export default Foo` where `Foo` is a local class already wrapped by a named\n // export (e.g. a self-bound WorkerEntrypoint also used as the default handler).\n // Wrapping again would produce `withSentry(withSentry(...))`.\n if (decl.type === 'Identifier' && state.renamedLocals.has((decl as IdentifierNode).name)) return;\n\n // `export default <expr>` → `const __SENTRY_DEFAULT_EXPORT__ = <expr>`\n // MagicString positions are always relative to the original source.\n state.ms.overwrite(node.start, decl.start, 'const __SENTRY_DEFAULT_EXPORT__ = ');\n state.ms.append(`\\nexport default __SENTRY__.withSentry(${ctx.optionsFn}, __SENTRY_DEFAULT_EXPORT__);\\n`);\n state.needsImport = true;\n}\n\nfunction handleNamedExport(node: ExportNamedNode, ctx: TransformContext, state: TransformState): void {\n const decl = node.declaration;\n\n // ---- Manually wrapped class export ----\n // `export const MyDO = instrumentDurableObjectWithSentry(...)` — count it\n // as wrapped so the plugin doesn't warn about it, but leave it alone.\n if (decl?.type === 'VariableDeclaration') {\n collectManuallyWrappedClassExports(decl as VariableDeclarationNode, ctx, state);\n return;\n }\n\n // ---- Named class export matching a configured binding ----\n if (decl?.type === 'ClassDeclaration') {\n wrapInlineClassExport(node, decl as ClassDeclarationNode, ctx, state);\n return;\n }\n\n // ---- Specifier export of a local class (`export { Foo as MyDO }`) ----\n // Re-exports from another module carry a `source` — nothing local to wrap.\n if (node.source) return;\n for (const specifier of node.specifiers ?? []) {\n wrapSpecifierExport(specifier, ctx, state);\n }\n}\n\nfunction collectManuallyWrappedClassExports(\n varDecl: VariableDeclarationNode,\n ctx: TransformContext,\n state: TransformState,\n): void {\n for (const declarator of varDecl.declarations ?? []) {\n const name = declarator.id?.type === 'Identifier' ? declarator.id.name : undefined;\n const kind = name ? ctx.classWrappers.get(name) : undefined;\n if (!name || !kind || !declarator.init) continue;\n\n // A hand-wrapped Agent is configured as a Durable Object, so accept either helper there —\n // otherwise an already-instrumented Agent would be reported as unwrapped.\n const accepted =\n kind === 'durableObject' ? [WRAPPER_METHODS.durableObject, WRAPPER_METHODS.agent] : [WRAPPER_METHODS[kind]];\n\n if (accepted.some(method => isCallToMethod(declarator.init as BaseNode, method))) {\n state.wrappedClasses.add(name);\n }\n }\n}\n\nfunction wrapInlineClassExport(\n exportNode: ExportNamedNode,\n classDecl: ClassDeclarationNode,\n ctx: TransformContext,\n state: TransformState,\n): void {\n const classId = classDecl.id;\n // Inline export: the exported name and the local class name are the same.\n const kind = classId ? resolveWrapperKind(classId.name, classId.name, state) : undefined;\n if (!classId || !kind) return;\n\n const className = classId.name;\n const renamedClass = `__SENTRY_ORIGINAL_${className}__`;\n\n // Strip the `export ` keyword\n state.ms.overwrite(exportNode.start, classDecl.start, '');\n\n // Rename the class to avoid a duplicate binding\n state.ms.overwrite(classId.start, classId.end, renamedClass);\n\n // Insert the wrapped re-export after the class body\n state.ms.appendLeft(\n exportNode.end,\n `\\nexport const ${className} = __SENTRY__.${WRAPPER_METHODS[kind]}(${ctx.optionsFn}, ${renamedClass});\\n`,\n );\n\n state.wrappedClasses.add(className);\n state.renamedLocals.add(className);\n state.needsImport = true;\n}\n\nfunction wrapSpecifierExport(specifier: ExportSpecifierNode, ctx: TransformContext, state: TransformState): void {\n if (specifier.type !== 'ExportSpecifier' || specifier.exported?.type !== 'Identifier') return;\n const exportedName = specifier.exported.name;\n if (!exportedName) return;\n\n const localName = specifier.local?.type === 'Identifier' ? specifier.local.name : undefined;\n const kind = resolveWrapperKind(exportedName, localName, state);\n if (!kind) return;\n\n const localClass = localName ? state.topLevelClasses.get(localName) : undefined;\n if (!localName || !localClass?.id) return;\n\n state.wrappedClasses.add(exportedName);\n state.needsImport = true;\n if (state.renamedLocals.has(localName)) return;\n state.renamedLocals.add(localName);\n\n const renamedClass = `__SENTRY_ORIGINAL_${localName}__`;\n state.ms.overwrite(localClass.id.start, localClass.id.end, renamedClass);\n // The existing `export { ... }` statement keeps exporting the (now\n // wrapped) `localName` binding, so the wrapper is NOT exported here.\n state.ms.appendLeft(\n localClass.end,\n `\\nconst ${localName} = __SENTRY__.${WRAPPER_METHODS[kind]}(${ctx.optionsFn}, ${renamedClass});\\n`,\n );\n}\n"],"names":[],"mappings":";;;AA4DA,SAAS,cAAA,CAAe,MAAgB,UAAA,EAA6B;AACnE,EAAA,IAAI,IAAA,CAAK,IAAA,KAAS,gBAAA,EAAkB,OAAO,KAAA;AAC3C,EAAA,MAAM,SAAU,IAAA,CAA4B,MAAA;AAC5C,EAAA,IAAI,CAAC,QAAQ,OAAO,KAAA;AACpB,EAAA,IAAI,OAAO,IAAA,KAAS,YAAA,IAAgB,MAAA,CAAO,IAAA,KAAS,YAAY,OAAO,IAAA;AACvE,EAAA,OACE,MAAA,CAAO,SAAS,kBAAA,IAAsB,MAAA,CAAO,UAAU,IAAA,KAAS,YAAA,IAAgB,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GAAe,qBAAqB,SAAS,CAAA,EAAA,CAAA;AACnD,EAAA,KAAA,CAAM,EAAA,CAAG,UAAU,UAAA,CAAW,EAAA,CAAG,OAAO,UAAA,CAAW,EAAA,CAAG,KAAK,YAAY,CAAA;AAGvE,EAAA,KAAA,CAAM,EAAA,CAAG,UAAA;AAAA,IACP,UAAA,CAAW,GAAA;AAAA,IACX;AAAA,MAAA,EAAW,SAAS,iBAAiB,eAAA,CAAgB,IAAI,CAAC,CAAA,CAAA,EAAI,GAAA,CAAI,SAAS,CAAA,EAAA,EAAK,YAAY,CAAA;AAAA;AAAA,GAC9F;AACF;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"workerEntrypoint.js","sources":["../../../src/vite/workerEntrypoint.ts"],"sourcesContent":["import type { BaseNode, ProgramBody } from './transform';\n\n// ---------------------------------------------------------------------------\n// Minimal ESTree node shapes for structural WorkerEntrypoint detection.\n// ---------------------------------------------------------------------------\n\ninterface IdentifierNode extends BaseNode {\n name: string;\n}\n\ninterface MemberExpressionNode extends BaseNode {\n object?: { type: string; name?: string };\n property?: { type: string; name?: string };\n}\n\ninterface ClassDeclarationNode extends BaseNode {\n id?: IdentifierNode | null;\n superClass?: BaseNode | null;\n}\n\ninterface ExportNamedDeclNode extends BaseNode {\n declaration?: BaseNode | null;\n}\n\ninterface ImportSpecifierNode {\n type: string;\n imported?: { type: string; name?: string };\n local?: { type: string; name?: string };\n}\n\ninterface ImportDeclarationNode extends BaseNode {\n source?: { value?: unknown };\n specifiers?: ImportSpecifierNode[];\n}\n\ninterface WorkerEntrypointBases {\n /** Local identifiers bound to the named `WorkerEntrypoint` import. */\n named: Set<string>;\n /** Local identifiers bound to a `* as ns` import of `cloudflare:workers`. */\n namespaces: Set<string>;\n}\n\n/**\n * Find top-level classes that (transitively, within this module) extend\n * `WorkerEntrypoint` imported from `cloudflare:workers`. esbuild has already\n * stripped TypeScript by transform time, so a superclass is a plain identifier\n * (`extends WorkerEntrypoint`) or member access (`extends cf.WorkerEntrypoint`).\n *\n * Only same-file base chains are resolvable here; a base class imported from\n * another module is invisible and relies on the config self-binding fallback.\n */\nexport function detectWorkerEntrypointClasses(ast: ProgramBody): Set<string> {\n const bases = collectWorkerEntrypointImports(ast);\n if (bases.named.size === 0 && bases.namespaces.size === 0) {\n return new Set<string>();\n }\n\n // Every top-level class, including the `export class Foo {}` form (where the\n // class is nested inside an ExportNamedDeclaration) so directly-exported\n // entrypoints are seen too.\n const classes = new Map<string, ClassDeclarationNode>();\n for (const node of ast.body) {\n const classNode = asClassDeclaration(node);\n if (classNode?.id?.name) classes.set(classNode.id.name, classNode);\n }\n\n const entrypoints = new Set<string>();\n // Iterate to a fixed point so an indirect chain (A extends B extends WE) is\n // fully resolved regardless of declaration order.\n let changed = true;\n while (changed) {\n changed = false;\n for (const [name, classNode] of classes) {\n if (entrypoints.has(name)) continue;\n if (extendsWorkerEntrypoint(classNode.superClass, bases, entrypoints)) {\n entrypoints.add(name);\n changed = true;\n }\n }\n }\n return entrypoints;\n}\n\n/** Unwrap `export class Foo {}` to its ClassDeclaration; pass bare classes through. */\nfunction asClassDeclaration(node: BaseNode): ClassDeclarationNode | undefined {\n if (node.type === 'ClassDeclaration') return node as ClassDeclarationNode;\n if (node.type === 'ExportNamedDeclaration') {\n const decl = (node as ExportNamedDeclNode).declaration;\n if (decl?.type === 'ClassDeclaration') return decl as ClassDeclarationNode;\n }\n return undefined;\n}\n\nfunction collectWorkerEntrypointImports(ast: ProgramBody): WorkerEntrypointBases {\n const named = new Set<string>();\n const namespaces = new Set<string>();\n for (const node of ast.body) {\n if (node.type !== 'ImportDeclaration') continue;\n const importNode = node as ImportDeclarationNode;\n if (importNode.source?.value !== 'cloudflare:workers') continue;\n for (const specifier of importNode.specifiers ?? []) {\n if (\n specifier.type === 'ImportSpecifier' &&\n specifier.imported?.name === 'WorkerEntrypoint' &&\n specifier.local?.name\n ) {\n named.add(specifier.local.name);\n } else if (specifier.type === 'ImportNamespaceSpecifier' && specifier.local?.name) {\n namespaces.add(specifier.local.name);\n }\n }\n }\n return { named, namespaces };\n}\n\n/**\n * Whether a superclass expression resolves to `WorkerEntrypoint` — either a bare\n * identifier from the named import (or an already-detected local subclass), or a\n * `ns.WorkerEntrypoint` member access off a namespace import.\n */\nfunction extendsWorkerEntrypoint(\n superClass: BaseNode | null | undefined,\n bases: WorkerEntrypointBases,\n detected: Set<string>,\n): boolean {\n if (!superClass) return false;\n if (superClass.type === 'Identifier') {\n const name = (superClass as IdentifierNode).name;\n return bases.named.has(name) || detected.has(name);\n }\n if (superClass.type === 'MemberExpression') {\n const member = superClass as MemberExpressionNode;\n return (\n member.object?.type === 'Identifier' &&\n !!member.object.name &&\n bases.namespaces.has(member.object.name) &&\n member.property?.name === 'WorkerEntrypoint'\n );\n }\n return false;\n}\n"],"names":[],"mappings":"AAmDO,SAAS,8BAA8B,GAAA,EAA+B;AAC3E,EAAA,MAAM,KAAA,GAAQ,+BAA+B,GAAG,CAAA;AAChD,EAAA,IAAI,MAAM,KAAA,CAAM,IAAA,KAAS,KAAK,KAAA,CAAM,UAAA,CAAW,SAAS,CAAA,EAAG;AACzD,IAAA,2BAAW,GAAA,EAAY;AAAA,EACzB;AAKA,EAAA,MAAM,OAAA,uBAAc,GAAA,EAAkC;AACtD,EAAA,KAAA,MAAW,IAAA,IAAQ,IAAI,IAAA,EAAM;AAC3B,IAAA,MAAM,SAAA,GAAY,mBAAmB,IAAI,CAAA;AACzC,IAAA,IAAI,SAAA,EAAW,IAAI,IAAA,EAAM,OAAA,CAAQ,IAAI,SAAA,CAAU,EAAA,CAAG,MAAM,SAAS,CAAA;AAAA,EACnE;AAEA,EAAA,MAAM,WAAA,uBAAkB,GAAA,EAAY;AAGpC,EAAA,IAAI,OAAA,GAAU,IAAA;AACd,EAAA,OAAO,OAAA,EAAS;AACd,IAAA,OAAA,GAAU,KAAA;AACV,IAAA,KAAA,MAAW,CAAC,IAAA,EAAM,SAAS,CAAA,IAAK,OAAA,EAAS;AACvC,MAAA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0BAAA,IAA8B,SAAA,CAAU,OAAO,IAAA,EAAM;AACjF,QAAA,UAAA,CAAW,GAAA,CAAI,SAAA,CAAU,KAAA,CAAM,IAAI,CAAA;AAAA,MACrC;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,EAAE,OAAO,UAAA,EAAW;AAC7B;AAOA,SAAS,uBAAA,CACP,UAAA,EACA,KAAA,EACA,QAAA,EACS;AACT,EAAA,IAAI,CAAC,YAAY,OAAO,KAAA;AACxB,EAAA,IAAI,UAAA,CAAW,SAAS,YAAA,EAAc;AACpC,IAAA,MAAM,OAAQ,UAAA,CAA8B,IAAA;AAC5C,IAAA,OAAO,MAAM,KAAA,CAAM,GAAA,CAAI,IAAI,CAAA,IAAK,QAAA,CAAS,IAAI,IAAI,CAAA;AAAA,EACnD;AACA,EAAA,IAAI,UAAA,CAAW,SAAS,kBAAA,EAAoB;AAC1C,IAAA,MAAM,MAAA,GAAS,UAAA;AACf,IAAA,OACE,OAAO,MAAA,EAAQ,IAAA,KAAS,gBACxB,CAAC,CAAC,OAAO,MAAA,CAAO,IAAA,IAChB,KAAA,CAAM,UAAA,CAAW,IAAI,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA,IACvC,MAAA,CAAO,UAAU,IAAA,KAAS,kBAAA;AAAA,EAE9B;AACA,EAAA,OAAO,KAAA;AACT;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"wranglerConfig.js","sources":["../../../src/vite/wranglerConfig.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { type Unstable_Config, unstable_readConfig } from 'wrangler';\n\n/**\n * The slice of the wrangler configuration the auto-instrument plugin cares\n * about. `main` is an absolute path (wrangler resolves it against the config\n * file's directory).\n */\nexport interface WranglerConfig {\n main?: string;\n durableObjects: Array<{ name: string; className: string }>;\n workflows: Array<{ name: string; className: string }>;\n /**\n * Named `WorkerEntrypoint` exports this worker binds to itself via a service\n * binding (`services[]` whose `service` is this worker's own `name`). Only\n * self-bindings appear here: a service binding's `entrypoint` otherwise names\n * an export on a *different* worker, which this build can't wrap.\n */\n workerEntrypoints: string[];\n}\n\n/**\n * Locate and resolve the wrangler configuration via wrangler's own\n * `unstable_readConfig` — the API `@cloudflare/vite-plugin` uses.\n *\n * We only locate the file (probing `wrangler.json`, `.jsonc`, `.toml` inside\n * `root` with wrangler's own precedence, since it discovers from `cwd` rather\n * than an arbitrary root); wrangler then parses it, flattens the active\n * environment (honoring `CLOUDFLARE_ENV`), and resolves `main` to an absolute\n * path. Durable Object and Workflow bindings are the active environment's,\n * matching what the deployed Worker actually binds.\n *\n * Returns `undefined` when no config file is found or it can't be read/parsed\n * (the caller warns and disables auto-instrumentation rather than failing the\n * whole build).\n */\nexport function resolveWranglerConfig(\n root: string,\n explicitPath?: string,\n): { config: WranglerConfig; configDir: string } | undefined {\n const configPath = explicitPath\n ? resolve(root, explicitPath)\n : ['wrangler.json', 'wrangler.jsonc', 'wrangler.toml'].map(name => resolve(root, name)).find(existsSync);\n\n if (!configPath || !existsSync(configPath)) {\n return undefined;\n }\n\n let raw: Unstable_Config;\n try {\n // `hideWarnings` keeps wrangler's config diagnostics (e.g. missing DO\n // migrations) out of the Vite build output.\n raw = unstable_readConfig({ config: configPath }, { hideWarnings: true });\n } catch {\n return undefined;\n }\n\n return {\n config: {\n main: raw.main,\n durableObjects: collectClassBindings(raw.durable_objects?.bindings),\n workflows: collectClassBindings(raw.workflows),\n workerEntrypoints: collectSelfBoundEntrypoints(raw),\n },\n configDir: dirname(raw.configPath ?? configPath),\n };\n}\n\n/**\n * Collect named `WorkerEntrypoint` exports the worker binds to itself. A service\n * binding's `entrypoint` normally names an export on the *target* worker, so it\n * is only ours when `service` equals this worker's own `name`. Without a `name`\n * there is nothing to match against, so no entrypoints are derivable.\n */\nfunction collectSelfBoundEntrypoints(raw: Unstable_Config): string[] {\n if (!raw.name) {\n return [];\n }\n const entrypoints = new Set<string>();\n for (const binding of raw.services ?? []) {\n if (binding?.service === raw.name && typeof binding.entrypoint === 'string') {\n entrypoints.add(binding.entrypoint);\n }\n }\n return [...entrypoints];\n}\n\n/**\n * Map wrangler class bindings (Durable Objects, Workflows — same shape) to the\n * `{ name, className }` the transform needs, skipping duplicates and bindings\n * with a `script_name` (those reference a class exported by a *different*\n * worker, so there is nothing to wrap in this worker's entry file).\n */\nfunction collectClassBindings(\n bindings: ReadonlyArray<{ name: string; class_name?: string; script_name?: string }> | undefined,\n): Array<{ name: string; className: string }> {\n const result: Array<{ name: string; className: string }> = [];\n const seenClassNames = new Set<string>();\n for (const binding of bindings ?? []) {\n if (typeof binding?.class_name !== 'string' || binding.script_name || seenClassNames.has(binding.class_name)) {\n continue;\n }\n seenClassNames.add(binding.class_name);\n result.push({ name: binding.name, className: binding.class_name });\n }\n return result;\n}\n"],"names":[],"mappings":";;;;AAqCO,SAAS,qBAAA,CACd,MACA,YAAA,EAC2D;AAC3D,EAAA,MAAM,aAAa,YAAA,GACf,OAAA,CAAQ,MAAM,YAAY,CAAA,GAC1B,CAAC,eAAA,EAAiB,gBAAA,EAAkB,eAAe,CAAA,CAAE,GAAA,CAAI,UAAQ,OAAA,CAAQ,IAAA,EAAM,IAAI,CAAC,CAAA,CAAE,KAAK,UAAU,CAAA;AAEzG,EAAA,IAAI,CAAC,UAAA,IAAc,CAAC,UAAA,CAAW,UAAU,CAAA,EAAG;AAC1C,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,IAAI,GAAA;AACJ,EAAA,IAAI;AAGF,IAAA,GAAA,GAAM,mBAAA,CAAoB,EAAE,MAAA,EAAQ,UAAA,IAAc,EAAE,YAAA,EAAc,MAAM,CAAA;AAAA,EAC1E,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ;AAAA,MACN,MAAM,GAAA,CAAI,IAAA;AAAA,MACV,cAAA,EAAgB,oBAAA,CAAqB,GAAA,CAAI,eAAA,EAAi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withSentry.js","sources":["../../src/withSentry.ts"],"sourcesContent":["import type { env as cloudflareEnv } from 'cloudflare:workers';\nimport { setAsyncLocalStorageAsyncContextStrategy } from './async';\nimport type { CloudflareOptions } from './client';\nimport { ensureInstrumented } from './instrument';\nimport { instrumentExportedHandlerEmail } from './instrumentations/worker/instrumentEmail';\nimport { instrumentExportedHandlerFetch } from './instrumentations/worker/instrumentFetch';\nimport { instrumentExportedHandlerQueue } from './instrumentations/worker/instrumentQueue';\nimport { instrumentExportedHandlerScheduled } from './instrumentations/worker/instrumentScheduled';\nimport { instrumentExportedHandlerTail } from './instrumentations/worker/instrumentTail';\nimport { getHonoIntegration } from './integrations/hono';\nimport { isCloudflareClass } from './utils/isCloudflareClass';\nimport {\n instrumentWorkerEntrypoint,\n type WorkerEntrypointConstructor,\n} from './instrumentations/instrumentWorkerEntrypoint';\n\n/**\n * Wrapper for Cloudflare handlers.\n *\n * Initializes the SDK and wraps the handler with Sentry instrumentation.\n *\n * Automatically instruments the `fetch` method of the handler.\n *\n * @param optionsCallback Function that returns the options for the SDK initialization.\n * @param handler {ExportedHandler} The handler to wrap.\n * @returns The wrapped handler.\n */\n// TODO(v11): The generic types need to be rewritten to following to improve type safety:\n// T extends ExportedHandler<any, any, any> | WorkerEntrypointConstructor<any, any>\nexport function withSentry<\n Env = typeof cloudflareEnv,\n QueueHandlerMessage = unknown,\n CfHostMetadata = unknown,\n T extends ExportedHandler<Env, QueueHandlerMessage, CfHostMetadata> | WorkerEntrypointConstructor = ExportedHandler<\n Env,\n QueueHandlerMessage,\n CfHostMetadata\n >,\n>(optionsCallback: (env: Env) => CloudflareOptions | undefined, handler: T): T {\n if (isCloudflareClass(handler, 'WorkerEntrypoint')) {\n // oxlint-disable-next-line typescript/no-explicit-any\n return instrumentWorkerEntrypoint(optionsCallback as any, handler);\n }\n\n setAsyncLocalStorageAsyncContextStrategy();\n\n try {\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerFetch(handler, optionsCallback as any);\n instrumentHonoErrorHandler(handler);\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerScheduled(handler, optionsCallback as any);\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerEmail(handler, optionsCallback as any);\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerQueue(handler, optionsCallback as any);\n // oxlint-disable-next-line typescript/no-explicit-any\n instrumentExportedHandlerTail(handler, optionsCallback as any);\n // This is here because Miniflare sometimes cannot get instrumented\n } catch {\n // Do not console anything here, we don't want to spam the console with errors\n }\n\n return handler;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction instrumentHonoErrorHandler<T extends ExportedHandler<any, any, any>>(handler: T): void {\n if ('onError' in handler && 'errorHandler' in handler && typeof handler.errorHandler === 'function') {\n handler.errorHandler = ensureInstrumented(\n handler.errorHandler,\n original =>\n new Proxy(original, {\n apply(target, thisArg, args) {\n const [err, context] = args;\n\n getHonoIntegration()?.handleHonoException(err, context);\n\n return Reflect.apply(target, thisArg, args);\n },\n }),\n );\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA6BO,SAAS,UAAA,CASd,iBAA8D,OAAA,EAAe;AAC7E,EAAA,IAAI,iBAAA,CAAkB,OAAA,EAAS,kBAAkB,CAAA,EAAG;AAElD,IAAA,OAAO,0BAAA,CAA2B,iBAAwB,OAAO,CAAA;AAAA,EACnE;AAEA,EAAA,wCAAA,EAAyC;AAEzC,EAAA,IAAI;AAEF,IAAA,8BAAA,CAA+B,SAAS,eAAsB,CAAA;AAC9D,IAAA,0BAAA,CAA2B,OAAO,CAAA;AAElC,IAAA,kCAAA,CAAmC,SAAS,eAAsB,CAAA;AAElE,IAAA,8BAAA,CAA+B,SAAS,eAAsB,CAAA;AAE9D,IAAA,8BAAA,CAA+B,SAAS,eAAsB,CAAA;AAE9D,IAAA,6BAAA,CAA8B,SAAS,eAAsB,CAAA;AAAA,EAE/D,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,OAAA;AACT;AAGA,SAAS,2BAAqE,OAAA,EAAkB;AAC9F,EAAA,IAAI,aAAa,OAAA,IAAW,cAAA,IAAkB,WAAW,OAAO,OAAA,CAAQ,iBAAiB,UAAA,EAAY;AACnG,IAAA,OAAA,CAAQ,YAAA,GAAe,kBAAA;AAAA,MACrB,OAAA,CAAQ,YAAA;AAAA,MACR,CAAA,QAAA,KACE,IAAI,KAAA,CAAM,QAAA,EAAU;AAAA,QAClB,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,IAAA,EAAM;AAC3B,UAAA,MAAM,CAAC,GAAA,EAAK,OAAO,CAAA,GAAI,IAAA;AAEvB,UAAA,kBAAA,EAAmB,EAAG,mBAAA,CAAoB,GAAA,EAAK,OAAO,CAAA;AAEtD,UAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,IAAI,CAAA;AAAA,QAC5C;AAAA,OACD;AAAA,KACL;AAAA,EACF;AACF;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflows.js","sources":["../../src/workflows.ts"],"sourcesContent":["import type { PropagationContext } from '@sentry/core';\nimport {\n captureException,\n flush,\n getCurrentScope,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n startSpan,\n withIsolationScope,\n withScope,\n} from '@sentry/core';\nimport type {\n WorkflowDelayDuration,\n WorkflowEntrypoint,\n WorkflowEvent,\n WorkflowSleepDuration,\n WorkflowStep,\n WorkflowStepConfig,\n WorkflowStepContext,\n WorkflowStepEvent,\n WorkflowStepRollbackOptions,\n WorkflowTimeoutDuration,\n} from 'cloudflare:workers';\nimport { setAsyncLocalStorageAsyncContextStrategy } from './async';\nimport type { CloudflareOptions } from './client';\nimport { flushAndDispose } from './flush';\nimport { instrumentEnv } from './instrumentations/worker/instrumentEnv';\nimport { addCloudResourceContext } from './scope-utils';\nimport { init } from './sdk';\nimport { instrumentContext } from './utils/instrumentContext';\n\nconst UUID_REGEX = /^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$/i;\n\n/**\n * Hashes a string to a UUID using SHA-1.\n */\nexport async function deterministicTraceIdFromInstanceId(instanceId: string): Promise<string> {\n const buf = await crypto.subtle.digest('SHA-1', new TextEncoder().encode(instanceId));\n return (\n Array.from(new Uint8Array(buf))\n // We only need the first 16 bytes for the 32 characters\n .slice(0, 16)\n .map(b => b.toString(16).padStart(2, '0'))\n .join('')\n );\n}\n\nasync function propagationContextFromInstanceId(instanceId: string): Promise<PropagationContext> {\n const traceId = UUID_REGEX.test(instanceId)\n ? instanceId.replace(/-/g, '')\n : await deterministicTraceIdFromInstanceId(instanceId);\n\n // Derive sampleRand from last 4 characters of the random UUID\n //\n // We cannot store any state between workflow steps, so we derive the\n // sampleRand from the traceId itself. This ensures that the sampling is\n // consistent across all steps in the same workflow instance.\n const sampleRand = parseInt(traceId.slice(-4), 16) / 0xffff;\n\n return {\n traceId,\n sampleRand,\n };\n}\n\nclass WrappedWorkflowStep implements WorkflowStep {\n public constructor(\n private _instanceId: string,\n private _options: CloudflareOptions,\n private _step: WorkflowStep,\n private _waitUntil: ExecutionContext['waitUntil'],\n ) {}\n\n public async do<T extends Rpc.Serializable<T>>(\n name: string,\n callback: (ctx: WorkflowStepContext) => Promise<T>,\n rollbackOptions?: WorkflowStepRollbackOptions<T>,\n ): Promise<T>;\n public async do<T extends Rpc.Serializable<T>, const C extends WorkflowStepConfig>(\n name: string,\n config: C,\n callback: (\n ctx: WorkflowStepContext<C['retries'] extends { delay: infer D } ? D : WorkflowDelayDuration | number>,\n ) => Promise<T>,\n rollbackOptions?: WorkflowStepRollbackOptions<T>,\n ): Promise<T>;\n public async do<T extends Rpc.Serializable<T>>(\n name: string,\n configOrCallback: WorkflowStepConfig | ((ctx: WorkflowStepContext) => Promise<T>),\n callbackOrRollback?: ((ctx: WorkflowStepContext) => Promise<T>) | WorkflowStepRollbackOptions<T>,\n maybeRollback?: WorkflowStepRollbackOptions<T>,\n ): Promise<T> {\n // Capture the current scope, so parent span (e.g., a startSpan surrounding step.do) is preserved\n const scopeForStep = getCurrentScope();\n\n const hasConfig = typeof configOrCallback !== 'function';\n const config = hasConfig ? configOrCallback : undefined;\n const userCallback = (hasConfig ? callbackOrRollback : configOrCallback) as (\n ctx: WorkflowStepContext,\n ) => Promise<T>;\n const rollbackOptions = (hasConfig ? maybeRollback : callbackOrRollback) as\n | WorkflowStepRollbackOptions<T>\n | undefined;\n\n const instrumentedCallback = async (...args: unknown[]): Promise<T> => {\n // Feature detection: Cloudflare Workflows (April 2026+) pass a step context\n // with `attempt` and `config.retries.limit`. When available, we only capture\n // errors on the final attempt to avoid duplicates during retries.\n const stepContext = args[0] as { attempt?: number; config?: { retries?: { limit?: number } } } | undefined;\n const attempt = stepContext?.attempt;\n const retryLimit = stepContext?.config?.retries?.limit;\n const hasStepContext = typeof attempt === 'number' && typeof retryLimit === 'number';\n\n // Only capture error on final attempt (attempt > retryLimit means no more retries left)\n // or when step context is unavailable (legacy behavior - capture all errors)\n const isFinalAttempt = !hasStepContext || attempt > retryLimit;\n\n return startSpan(\n {\n op: 'function.step.do',\n name,\n scope: scopeForStep,\n attributes: {\n 'cloudflare.workflow.timeout': config?.timeout,\n 'cloudflare.workflow.retries.backoff': config?.retries?.backoff,\n // In workers-types v5, `delay` may be a `WorkflowDelayFunction`, which isn't a valid span attribute value.\n 'cloudflare.workflow.retries.delay':\n typeof config?.retries?.delay === 'function' ? undefined : config?.retries?.delay,\n 'cloudflare.workflow.retries.limit': config?.retries?.limit,\n 'cloudflare.workflow.attempt': attempt,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.workflow',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',\n },\n },\n async span => {\n try {\n const result = await (userCallback as (...args: unknown[]) => Promise<T>)(...args);\n span.setStatus({ code: 1 });\n return result;\n } catch (error) {\n if (isFinalAttempt) {\n captureException(error, { mechanism: { handled: true, type: 'auto.faas.cloudflare.workflow' } });\n }\n throw error;\n } finally {\n this._waitUntil(flush(2000));\n }\n },\n );\n };\n\n if (config) {\n return rollbackOptions\n ? this._step.do(name, config, instrumentedCallback, rollbackOptions)\n : this._step.do(name, config, instrumentedCallback);\n }\n\n return rollbackOptions\n ? this._step.do(name, instrumentedCallback, rollbackOptions)\n : this._step.do(name, instrumentedCallback);\n }\n\n public async sleep(name: string, duration: WorkflowSleepDuration): Promise<void> {\n return this._step.sleep(name, duration);\n }\n\n public async sleepUntil(name: string, timestamp: Date | number): Promise<void> {\n return this._step.sleepUntil(name, timestamp);\n }\n\n public async waitForEvent<T extends Rpc.Serializable<T>>(\n name: string,\n options: { type: string; timeout?: WorkflowTimeoutDuration | number },\n ): Promise<WorkflowStepEvent<T>> {\n return this._step.waitForEvent<T>(name, options);\n }\n}\n\n/**\n * Instruments a Cloudflare Workflow class with Sentry.\n *\n * @example\n * ```typescript\n * const InstrumentedWorkflow = instrumentWorkflowWithSentry(\n * (env) => ({ dsn: env.SENTRY_DSN }),\n * MyWorkflowClass\n * );\n *\n * export default InstrumentedWorkflow;\n * ```\n *\n * @param optionsCallback - Function that returns Sentry options to initialize Sentry\n * @param WorkflowClass - The workflow class to instrument\n * @returns Instrumented workflow class with the same interface\n */\nexport function instrumentWorkflowWithSentry<\n E, // Environment type\n P, // Payload type\n T extends WorkflowEntrypoint<E, P>, // WorkflowEntrypoint type\n C extends new (ctx: ExecutionContext, env: E) => T, // Constructor type of the WorkflowEntrypoint class\n>(optionsCallback: (env: E) => CloudflareOptions, WorkFlowClass: C): C {\n return new Proxy(WorkFlowClass, {\n construct(target: C, args: [ctx: ExecutionContext, env: E], newTarget) {\n const [ctx, env] = args;\n const context = instrumentContext(ctx);\n const options = optionsCallback(env);\n args[0] = context;\n args[1] = instrumentEnv(env as Record<string, unknown>, options) as E;\n const instance = Reflect.construct(target, args, newTarget) as T;\n return new Proxy(instance, {\n get(obj, prop, receiver) {\n if (prop === 'run') {\n return async function (event: WorkflowEvent<P>, step: WorkflowStep): Promise<unknown> {\n setAsyncLocalStorageAsyncContextStrategy();\n\n return withIsolationScope(async isolationScope => {\n const waitUntil = context.waitUntil.bind(context);\n const client = init({ ...options, ctx: context, enableDedupe: false });\n isolationScope.setClient(client);\n\n addCloudResourceContext(isolationScope);\n\n return withScope(async scope => {\n const propagationContext = await propagationContextFromInstanceId(event.instanceId);\n scope.setPropagationContext(propagationContext);\n\n try {\n return await obj.run.call(\n obj,\n event,\n new WrappedWorkflowStep(event.instanceId, options, step, waitUntil),\n );\n } finally {\n waitUntil(flushAndDispose(client));\n }\n });\n });\n };\n }\n return Reflect.get(obj, prop, receiver);\n },\n });\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;AA+BA,MAAM,UAAA,GAAa,qEAAA;AAKnB,eAAsB,mCAAmC,UAAA,EAAqC;AAC5F,EAAA,MAAM,GAAA,GAAM,MAAM,MAAA,CAAO,MAAA,CAAO,MAAA,CAAO,OAAA,EAAS,IAAI,WAAA,EAAY,CAAE,MAAA,CAAO,UAAU,CAAC,CAAA;AACpF,EAAA,OACE,KAAA,CAAM,KAAK,IAAI,UAAA,CAAW,GAAG,CAAC,CAAA,CAE3B,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA,CACX,IAAI,CAAA,CAAA,KAAK,CAAA,CAAE,QAAA,CAAS,EAAE,CAAA,CAAE,QAAA,CAAS,GAAG,GAAG,CAAC,CAAA,CACxC,IAAA,CAAK,EAAE,CAAA;AAEd;AAEA,eAAe,iCAAiC,UAAA,EAAiD;AAC/F,EAAA,MAAM,OAAA,GAAU,UAAA,CAAW,IAAA,CAAK,UAAU,CAAA,GACtC,UAAA,CAAW,OAAA,CAAQ,IAAA,EAAM,EAAE,CAAA,GAC3B,MAAM,kCAAA,CAAmC,UAAU,CAAA;AAOvD,EAAA,MAAM,aAAa,QAAA,CAAS,OAAA,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AAS,KAAA,EAAO;AAClB,YAAA,OAAO,eAAgB,OAAyB,IAAA,EAAsC;AACpF,cAAA,wCAAA,EAAyC;AAEzC,cAAA,OAAO,kBAAA,CAAmB,OAAM,cAAA,KAAkB;AAChD,gBAAA,MAAM,SAAA,GAAY,OAAA,CAAQ,SAAA,CAAU,IAAA,CAAK,OAAO,CAAA;AAChD,gBAAA,MAAM,MAAA,GAAS,KAAK,EAAE,GAAG,SAAS,GAAA,EAAK,OAAA,EAAS,YAAA,EAAc,KAAA,EAAO,CAAA;AACrE,gBAAA,cAAA,CAAe,UAAU,MAAM,CAAA;AAE/B,gBAAA,uBAAA,CAAwB,cAAc,CAAA;AAEtC,gBAAA,OAAO,SAAA,CAAU,OAAM,KAAA,KAAS;AAC9B,kBAAA,MAAM,kBAAA,GAAqB,MAAM,gCAAA,CAAiC,KAAA,CAAM,UAAU,CAAA;AAClF,kBAAA,KAAA,CAAM,sBAAsB,kBAAkB,CAAA;AAE9C,kBAAA,IAAI;AACF,oBAAA,OAAO,MAAM,IAAI,GAAA,CAAI,IAAA;AAAA,sBACnB,GAAA;AAAA,sBACA,KAAA;AAAA,sBACA,IAAI,mBAAA,CAAoB,KAAA,CAAM,UAAA,EAAY,OAAA,EAAS,MAAM,SAAS;AAAA,qBACpE;AAAA,kBACF,CAAA,SAAE;AACA,oBAAA,SAAA,CAAU,eAAA,CAAgB,MAAM,CAAC,CAAA;AAAA,kBACnC;AAAA,gBACF,CAAC,CAAA;AAAA,cACH,CAAC,CAAA;AAAA,YACH,CAAA;AAAA,UACF;AACA,UAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,GAAA,EAAK,IAAA,EAAM,QAAQ,CAAA;AAAA,QACxC;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrapMethodWithSentry.js","sources":["../../src/wrapMethodWithSentry.ts"],"sourcesContent":["import type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport type { SerializedTraceData } from '@sentry/core';\nimport {\n isObjectLike,\n captureException,\n continueTrace,\n getClient,\n isThenable,\n type Scope,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startNewTrace as startNewTraceCore,\n startSpan,\n withIsolationScope,\n withScope,\n} from '@sentry/core';\nimport type { CloudflareOptions } from './client';\nimport type { ExecutionContextCompat } from './executionContext';\nimport { flushAndDispose, getOriginalWaitUntil } from './flush';\nimport { ensureInstrumented } from './instrument';\nimport { init } from './sdk';\nimport { extractRpcMeta } from './utils/rpcMeta';\nimport { buildSpanLinks, getStoredSpanContext, storeSpanContext } from './utils/traceLinks';\n\n/** Extended DurableObjectState with originalStorage exposed by instrumentContext */\ninterface InstrumentedDurableObjectState extends DurableObjectState {\n originalStorage?: DurableObjectStorage;\n}\n\n/**\n * Resolves uninstrumented DO storage for the current invocation.\n * Prefer `thisArg.ctx` (the live Durable Object instance) over the context captured at\n * construction time to avoid cross-DO I/O errors in the same isolate.\n */\nfunction resolveOriginalStorage(\n context: ExecutionContext | InstrumentedDurableObjectState | undefined,\n thisArg: unknown,\n): DurableObjectStorage | undefined {\n if (isObjectLike(thisArg) && 'ctx' in thisArg) {\n const doCtx = (thisArg as { ctx: InstrumentedDurableObjectState }).ctx;\n if (doCtx?.originalStorage) {\n return doCtx.originalStorage;\n }\n }\n\n if (context && 'originalStorage' in context && context.originalStorage) {\n return context.originalStorage;\n }\n\n return undefined;\n}\n\ntype MethodWrapperOptions = {\n spanName?: string;\n spanOp?: string;\n options: CloudflareOptions;\n context: ExecutionContext | InstrumentedDurableObjectState;\n /**\n * If true, starts a fresh trace instead of inheriting from a parent trace.\n * Useful for scheduled/independent invocations like alarms.\n *\n * If true, it also stores the current span context and links to the previous invocation's span.\n * Uses Durable Object storage to persist the link. The link is set asynchronously via `span.addLinks()`\n * in a `waitUntil` to avoid blocking.\n *\n * @default false\n */\n startNewTrace?: boolean;\n /**\n * The trace origin identifying which instrumentation created the span, e.g. `auto.faas.cloudflare.durable_object`.\n * Used both as the span's `sentry.origin` attribute and as the `mechanism.type` for captured exceptions.\n */\n origin: string;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UncheckedMethod = (...args: any[]) => any;\ntype OriginalMethod = UncheckedMethod;\n\n/**\n * Wraps a method with Sentry error tracking and optional tracing.\n * Supports starting new traces and linking to previous invocations via Durable Object storage.\n *\n * @param wrapperOptions - The options for the wrapper.\n * @param handler - The method to wrap.\n * @param callback - The callback to call.\n * @param noMark - Whether to mark the method as instrumented.\n * @returns The wrapped method.\n */\nexport function wrapMethodWithSentry<T extends OriginalMethod>(\n wrapperOptions: MethodWrapperOptions,\n handler: T,\n callback?: (...args: Parameters<T>) => void,\n noMark?: true,\n): T {\n return ensureInstrumented(\n handler,\n original =>\n new Proxy(original, {\n apply(target, thisArg, rawArgs: Parameters<T>) {\n const { startNewTrace, origin } = wrapperOptions;\n\n // For RPC methods, extract Sentry trace context from the trailing argument.\n // The caller side (instrumentDurableObjectStub / JSRPC proxy) appends it;\n // we strip it here so the user's method never sees it.\n let args = rawArgs;\n let rpcMeta: SerializedTraceData | undefined;\n\n if (wrapperOptions.spanOp === 'rpc') {\n const extracted = extractRpcMeta(rawArgs);\n args = extracted.args;\n rpcMeta = extracted.rpcMeta;\n }\n\n // For startNewTrace, always use withIsolationScope to ensure a fresh scope\n // Otherwise, use existing client's scope or isolation scope\n const currentClient = getClient();\n const sentryWithScope = startNewTrace ? withIsolationScope : currentClient ? withScope : withIsolationScope;\n\n const wrappedFunction = (scope: Scope): unknown | Promise<unknown> => {\n // In certain situations, the passed context can become undefined.\n // For example, for Astro while prerendering pages at build time.\n // see: https://github.com/getsentry/sentry-javascript/issues/13217\n const context: typeof wrapperOptions.context | undefined = wrapperOptions.context;\n\n // see: https://github.com/getsentry/sentry-javascript/issues/22328\n const waitUntil = context\n ? getOriginalWaitUntil(context as ExecutionContextCompat)?.bind(context)\n : undefined;\n const storage = resolveOriginalStorage(context, thisArg);\n\n let scopeClient = scope.getClient();\n // Check if client exists AND is still usable (transport not disposed)\n // This handles the case where a previous handler disposed the client\n // but the scope still holds a reference to it (e.g., alarm handlers in Durable Objects)\n // For startNewTrace, always create a fresh client\n if (startNewTrace || !scopeClient?.getTransport()) {\n const client = init({\n ...wrapperOptions.options,\n ctx: context as unknown as ExecutionContext | undefined,\n });\n scope.setClient(client);\n scopeClient = client;\n }\n\n const clientToDispose = scopeClient;\n const methodName = wrapperOptions.spanName || 'unknown';\n\n const teardown = async (): Promise<void> => {\n if (startNewTrace && storage) {\n storeSpanContext(storage, methodName);\n }\n await flushAndDispose(clientToDispose);\n };\n\n const onFulfilled = (res: unknown) => {\n waitUntil?.(teardown());\n return res;\n };\n\n const onRejected = (e: unknown) => {\n captureException(e, {\n mechanism: {\n type: origin,\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\n };\n\n if (!wrapperOptions.spanName) {\n try {\n if (callback) {\n callback(...args);\n }\n\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(onFulfilled, onRejected);\n } else {\n return onFulfilled(result);\n }\n } catch (e) {\n return onRejected(e);\n }\n }\n\n const attributes = wrapperOptions.spanOp\n ? {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin,\n }\n : {};\n\n const executeSpan = (): unknown => {\n return startSpan({ name: methodName, attributes }, span => {\n if (startNewTrace && storage) {\n const storedContext = getStoredSpanContext(storage, methodName);\n\n if (storedContext) {\n span.addLinks(buildSpanLinks(storedContext));\n // TODO: Remove this once EAP can store span links. We currently only set this attribute so that we\n // can obtain the previous trace information from the EAP store. Long-term, EAP will handle\n // span links and then we should remove this again. Also throwing in a TODO(v11), to remind us\n // to check this at v11 time :)\n const sampledFlag = storedContext.sampled ? '1' : '0';\n span.setAttribute(\n 'sentry.previous_trace',\n `${storedContext.traceId}-${storedContext.spanId}-${sampledFlag}`,\n );\n }\n }\n\n try {\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(onFulfilled, onRejected);\n } else {\n return onFulfilled(result);\n }\n } catch (e) {\n return onRejected(e);\n }\n });\n };\n\n if (rpcMeta) {\n return continueTrace(\n { sentryTrace: rpcMeta['sentry-trace'] || '', baggage: rpcMeta.baggage || '' },\n executeSpan,\n );\n }\n\n if (startNewTrace) {\n return startNewTraceCore(() => executeSpan());\n }\n\n return executeSpan();\n };\n\n return sentryWithScope(wrappedFunction);\n },\n }),\n noMark,\n );\n}\n"],"names":["startNewTrace","startNewTraceCore"],"mappings":";;;;;;;AAkCA,SAAS,sBAAA,CACP,SACA,OAAA,EACkC;AAClC,EAAA,IAAI,YAAA,CAAa,OAAO,CAAA,IAAK,KAAA,IAAS,OAAA,EAAS;AAC7C,IAAA,MAAM,QAAS,OAAA,CAAoD,GAAA;AACnE,IAAA,IAAI,OAAO,eAAA,EAAiB;AAC1B,MAAA,OAAO,KAAA,CAAM,eAAA;AAAA,IACf;AAAA,EACF;AAEA,EAAA,IAAI,OAAA,IAAW,iBAAA,IAAqB,OAAA,IAAW,OAAA,CAAQ,eAAA,EAAiB;AACtE,IAAA,OAAO,OAAA,CAAQ,eAAA;AAAA,EACjB;AAEA,EAAA,OAAO,MAAA;AACT;AAuCO,SAAS,oBAAA,CACd,cAAA,EACA,OAAA,EACA,QAAA,EACA,MAAA,EACG;AACH,EAAA,OAAO,kBAAA;AAAA,IACL,OAAA;AAAA,IACA,CAAA,QAAA,KACE,IAAI,KAAA,CAAM,QAAA,EAAU;AAAA,MAClB,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,OAAA,EAAwB;AAC7C,QAAA,MAAM,iBAAEA,eAAA,EAAe,MAAA,EAAO,GAAI,cAAA;AAKlC,QAAA,IAAI,IAAA,GAAO,OAAA;AACX,QAAA,IAAI,OAAA;AAEJ,QAAA,IAAI,cAAA,CAAe,WAAW,K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- * AsyncLocalStorage is only available in the cloudflare workers runtime if you set
5
- * compatibility_flags = ["nodejs_compat"]
6
- *
7
- * @internal Only exported to be used in higher-level Sentry packages
8
- * @hidden Only exported to be used in higher-level Sentry packages
9
- */
10
- export declare function setAsyncLocalStorageAsyncContextStrategy(): void;
11
- //# sourceMappingURL=async.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/async.ts"],"names":[],"mappings":"AAWA;;;;;;;;GAQG;AACH,wBAAgB,wCAAwC,IAAI,IAAI,CAqE/D"}
@@ -1,42 +0,0 @@
1
- interface HonoError extends Error {
2
- status?: number;
3
- }
4
- export interface HonoContext {
5
- req: {
6
- method: string;
7
- path?: string;
8
- };
9
- }
10
- export interface Options {
11
- /**
12
- * Callback method deciding whether error should be captured and sent to Sentry
13
- * @param error Captured middleware error
14
- */
15
- shouldHandleError?(this: void, error: HonoError): boolean;
16
- }
17
- /** Only exported for internal use */
18
- export declare function getHonoIntegration(): ReturnType<typeof _honoIntegration> | undefined;
19
- declare const _honoIntegration: (options?: Partial<Options>) => {
20
- name: "Hono";
21
- handleHonoException(err: HonoError, context: HonoContext): void;
22
- };
23
- /**
24
- * Automatically captures exceptions caught with the `onError` handler in Hono.
25
- *
26
- * The integration is enabled by default.
27
- *
28
- * @deprecated Use the `@sentry/hono` package instead. The `sentry()` middleware from `@sentry/hono/cloudflare`
29
- * handles error capturing automatically without needing this integration.
30
- *
31
- * @example
32
- * integrations: [
33
- * honoIntegration({
34
- * shouldHandleError: (err) => true; // always capture exceptions in onError
35
- * })
36
- * ]
37
- */
38
- export declare const honoIntegration: (options?: Partial<Options> | undefined) => import("@sentry/core").Integration & {
39
- name: "Hono";
40
- };
41
- export {};
42
- //# sourceMappingURL=hono.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../../../src/integrations/hono.ts"],"names":[],"mappings":"AAgBA,UAAU,SAAU,SAAQ,KAAK;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAGD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACxC;AAED,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,iBAAiB,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC;CAC3D;AAED,qCAAqC;AACrC,wBAAgB,kBAAkB,IAAI,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAAG,SAAS,CAEpF;AAYD,QAAA,MAAM,gBAAgB,aAAc,OAAO,CAAC,OAAO,CAAC;;6BAIvB,SAAS,WAAW,WAAW,GAAG,IAAI;CA2BzC,CAAC;AAE3B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe;;CAAsC,CAAC"}
@@ -1,4 +0,0 @@
1
- export * from '../index';
2
- export { prismaIntegration } from '@sentry/server-utils';
3
- export { vercelAIIntegration } from './integrations/tracing/vercelai';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/nodejs_compat/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC"}