@sentry/cloudflare 11.12.0 → 11.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (610) hide show
  1. package/build/cjs/dev/_virtual/_rolldown/runtime.js +22 -0
  2. package/build/cjs/dev/baseSdk.js +98 -103
  3. package/build/cjs/dev/baseSdk.js.map +1 -1
  4. package/build/cjs/dev/client.js +213 -237
  5. package/build/cjs/dev/client.js.map +1 -1
  6. package/build/cjs/dev/clientCache.js +8 -8
  7. package/build/cjs/dev/clientCache.js.map +1 -1
  8. package/build/cjs/dev/debug-build.js +9 -5
  9. package/build/cjs/dev/debug-build.js.map +1 -1
  10. package/build/cjs/dev/defineCloudflareOptions.js +5 -8
  11. package/build/cjs/dev/defineCloudflareOptions.js.map +1 -1
  12. package/build/cjs/dev/durableobject.js +287 -176
  13. package/build/cjs/dev/durableobject.js.map +1 -1
  14. package/build/cjs/dev/flush.js +104 -77
  15. package/build/cjs/dev/flush.js.map +1 -1
  16. package/build/cjs/dev/index.js +181 -182
  17. package/build/cjs/dev/instrument.js +53 -39
  18. package/build/cjs/dev/instrument.js.map +1 -1
  19. package/build/cjs/dev/instrumentations/agents/index.js +34 -13
  20. package/build/cjs/dev/instrumentations/agents/index.js.map +1 -1
  21. package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js +46 -49
  22. package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  23. package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js +23 -16
  24. package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
  25. package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js +36 -28
  26. package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
  27. package/build/cjs/dev/instrumentations/agents/types.js +103 -58
  28. package/build/cjs/dev/instrumentations/agents/types.js.map +1 -1
  29. package/build/cjs/dev/instrumentations/instrumentDurableObjectHandlers.js +87 -118
  30. package/build/cjs/dev/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
  31. package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js +46 -44
  32. package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  33. package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js +70 -71
  34. package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  35. package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -39
  36. package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  37. package/build/cjs/dev/instrumentations/instrumentSqlStorage.js +50 -52
  38. package/build/cjs/dev/instrumentations/instrumentSqlStorage.js.map +1 -1
  39. package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js +136 -123
  40. package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  41. package/build/cjs/dev/instrumentations/worker/instrumentD1.js +131 -146
  42. package/build/cjs/dev/instrumentations/worker/instrumentD1.js.map +1 -1
  43. package/build/cjs/dev/instrumentations/worker/instrumentEmail.js +63 -61
  44. package/build/cjs/dev/instrumentations/worker/instrumentEmail.js.map +1 -1
  45. package/build/cjs/dev/instrumentations/worker/instrumentEnv.js +83 -88
  46. package/build/cjs/dev/instrumentations/worker/instrumentEnv.js.map +1 -1
  47. package/build/cjs/dev/instrumentations/worker/instrumentFetch.js +41 -48
  48. package/build/cjs/dev/instrumentations/worker/instrumentFetch.js.map +1 -1
  49. package/build/cjs/dev/instrumentations/worker/instrumentFetcher.js +25 -21
  50. package/build/cjs/dev/instrumentations/worker/instrumentFetcher.js.map +1 -1
  51. package/build/cjs/dev/instrumentations/worker/instrumentKV.js +54 -67
  52. package/build/cjs/dev/instrumentations/worker/instrumentKV.js.map +1 -1
  53. package/build/cjs/dev/instrumentations/worker/instrumentQueue.js +98 -105
  54. package/build/cjs/dev/instrumentations/worker/instrumentQueue.js.map +1 -1
  55. package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js +88 -94
  56. package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  57. package/build/cjs/dev/instrumentations/worker/instrumentR2.js +128 -115
  58. package/build/cjs/dev/instrumentations/worker/instrumentR2.js.map +1 -1
  59. package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js +90 -94
  60. package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js.map +1 -1
  61. package/build/cjs/dev/instrumentations/worker/instrumentTail.js +100 -55
  62. package/build/cjs/dev/instrumentations/worker/instrumentTail.js.map +1 -1
  63. package/build/cjs/dev/integrations/cronTriggers.js +130 -85
  64. package/build/cjs/dev/integrations/cronTriggers.js.map +1 -1
  65. package/build/cjs/dev/integrations/fetch.js +9 -9
  66. package/build/cjs/dev/integrations/fetch.js.map +1 -1
  67. package/build/cjs/dev/integrations/httpServer.js +41 -22
  68. package/build/cjs/dev/integrations/httpServer.js.map +1 -1
  69. package/build/cjs/dev/integrations/spotlight.js +52 -55
  70. package/build/cjs/dev/integrations/spotlight.js.map +1 -1
  71. package/build/cjs/dev/opentelemetry/tracer.js +10 -8
  72. package/build/cjs/dev/opentelemetry/tracer.js.map +1 -1
  73. package/build/cjs/dev/options.js +55 -39
  74. package/build/cjs/dev/options.js.map +1 -1
  75. package/build/cjs/dev/orchestrion-deferred-channels.js +45 -29
  76. package/build/cjs/dev/orchestrion-deferred-channels.js.map +1 -1
  77. package/build/cjs/dev/orchestrion-diagnostics-channel.js +97 -72
  78. package/build/cjs/dev/orchestrion-diagnostics-channel.js.map +1 -1
  79. package/build/cjs/dev/pages-plugin.js +20 -21
  80. package/build/cjs/dev/pages-plugin.js.map +1 -1
  81. package/build/cjs/dev/request.js +16 -10
  82. package/build/cjs/dev/request.js.map +1 -1
  83. package/build/cjs/dev/scope-utils.js +12 -12
  84. package/build/cjs/dev/scope-utils.js.map +1 -1
  85. package/build/cjs/dev/sdk.js +24 -15
  86. package/build/cjs/dev/sdk.js.map +1 -1
  87. package/build/cjs/dev/transport.js +93 -86
  88. package/build/cjs/dev/transport.js.map +1 -1
  89. package/build/cjs/dev/utils/asyncContextStrategy.js +10 -10
  90. package/build/cjs/dev/utils/asyncContextStrategy.js.map +1 -1
  91. package/build/cjs/dev/utils/bindingPropagation.js +17 -11
  92. package/build/cjs/dev/utils/bindingPropagation.js.map +1 -1
  93. package/build/cjs/dev/utils/cloudflareTrace.js +34 -0
  94. package/build/cjs/dev/utils/cloudflareTrace.js.map +1 -0
  95. package/build/cjs/dev/utils/instrumentContext.js +74 -58
  96. package/build/cjs/dev/utils/instrumentContext.js.map +1 -1
  97. package/build/cjs/dev/utils/internalSqlQuery.js +38 -21
  98. package/build/cjs/dev/utils/internalSqlQuery.js.map +1 -1
  99. package/build/cjs/dev/utils/internalStorageKey.js +41 -38
  100. package/build/cjs/dev/utils/internalStorageKey.js.map +1 -1
  101. package/build/cjs/dev/utils/invocationContext.js +42 -32
  102. package/build/cjs/dev/utils/invocationContext.js.map +1 -1
  103. package/build/cjs/dev/utils/invocationScope.js +45 -21
  104. package/build/cjs/dev/utils/invocationScope.js.map +1 -1
  105. package/build/cjs/dev/utils/isBinding.js +47 -15
  106. package/build/cjs/dev/utils/isBinding.js.map +1 -1
  107. package/build/cjs/dev/utils/isCloudflareClass.js +11 -20
  108. package/build/cjs/dev/utils/isCloudflareClass.js.map +1 -1
  109. package/build/cjs/dev/utils/queueTraceMeta.js +24 -35
  110. package/build/cjs/dev/utils/queueTraceMeta.js.map +1 -1
  111. package/build/cjs/dev/utils/rpcMeta.js +37 -27
  112. package/build/cjs/dev/utils/rpcMeta.js.map +1 -1
  113. package/build/cjs/dev/utils/traceLinks.js +52 -42
  114. package/build/cjs/dev/utils/traceLinks.js.map +1 -1
  115. package/build/cjs/dev/vendor/stacktrace.js +32 -24
  116. package/build/cjs/dev/vendor/stacktrace.js.map +1 -1
  117. package/build/cjs/dev/vite/agentClass.js +105 -98
  118. package/build/cjs/dev/vite/agentClass.js.map +1 -1
  119. package/build/cjs/dev/vite/autoInstrument.js +121 -122
  120. package/build/cjs/dev/vite/autoInstrument.js.map +1 -1
  121. package/build/cjs/dev/vite/index.js +44 -21
  122. package/build/cjs/dev/vite/index.js.map +1 -1
  123. package/build/cjs/dev/vite/instrumentFile.js +37 -20
  124. package/build/cjs/dev/vite/instrumentFile.js.map +1 -1
  125. package/build/cjs/dev/vite/mastraObservability.js +19 -12
  126. package/build/cjs/dev/vite/mastraObservability.js.map +1 -1
  127. package/build/cjs/dev/vite/moduleShape.js +220 -201
  128. package/build/cjs/dev/vite/moduleShape.js.map +1 -1
  129. package/build/cjs/dev/vite/providedModulePlugin.js +62 -45
  130. package/build/cjs/dev/vite/providedModulePlugin.js.map +1 -1
  131. package/build/cjs/dev/vite/transform.js +333 -284
  132. package/build/cjs/dev/vite/transform.js.map +1 -1
  133. package/build/cjs/dev/vite/workerEntrypoint.js +66 -57
  134. package/build/cjs/dev/vite/workerEntrypoint.js.map +1 -1
  135. package/build/cjs/dev/vite/wranglerConfig.js +92 -67
  136. package/build/cjs/dev/vite/wranglerConfig.js.map +1 -1
  137. package/build/cjs/dev/withSentry.js +32 -26
  138. package/build/cjs/dev/withSentry.js.map +1 -1
  139. package/build/cjs/dev/workflows.js +164 -151
  140. package/build/cjs/dev/workflows.js.map +1 -1
  141. package/build/cjs/dev/wrapMethodWithSentry.js +148 -169
  142. package/build/cjs/dev/wrapMethodWithSentry.js.map +1 -1
  143. package/build/cjs/dev/wrapRequestHandlerWithInit.js +76 -78
  144. package/build/cjs/dev/wrapRequestHandlerWithInit.js.map +1 -1
  145. package/build/cjs/prod/_virtual/_rolldown/runtime.js +22 -0
  146. package/build/cjs/prod/baseSdk.js +94 -93
  147. package/build/cjs/prod/baseSdk.js.map +1 -1
  148. package/build/cjs/prod/client.js +213 -237
  149. package/build/cjs/prod/client.js.map +1 -1
  150. package/build/cjs/prod/clientCache.js +8 -8
  151. package/build/cjs/prod/clientCache.js.map +1 -1
  152. package/build/cjs/prod/debug-build.js +9 -5
  153. package/build/cjs/prod/debug-build.js.map +1 -1
  154. package/build/cjs/prod/defineCloudflareOptions.js +5 -8
  155. package/build/cjs/prod/defineCloudflareOptions.js.map +1 -1
  156. package/build/cjs/prod/durableobject.js +287 -176
  157. package/build/cjs/prod/durableobject.js.map +1 -1
  158. package/build/cjs/prod/flush.js +104 -77
  159. package/build/cjs/prod/flush.js.map +1 -1
  160. package/build/cjs/prod/index.js +181 -182
  161. package/build/cjs/prod/instrument.js +53 -39
  162. package/build/cjs/prod/instrument.js.map +1 -1
  163. package/build/cjs/prod/instrumentations/agents/index.js +34 -13
  164. package/build/cjs/prod/instrumentations/agents/index.js.map +1 -1
  165. package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js +46 -49
  166. package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  167. package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js +23 -16
  168. package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
  169. package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js +36 -28
  170. package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
  171. package/build/cjs/prod/instrumentations/agents/types.js +103 -58
  172. package/build/cjs/prod/instrumentations/agents/types.js.map +1 -1
  173. package/build/cjs/prod/instrumentations/instrumentDurableObjectHandlers.js +87 -118
  174. package/build/cjs/prod/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
  175. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js +46 -44
  176. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  177. package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js +70 -71
  178. package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  179. package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -39
  180. package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  181. package/build/cjs/prod/instrumentations/instrumentSqlStorage.js +50 -52
  182. package/build/cjs/prod/instrumentations/instrumentSqlStorage.js.map +1 -1
  183. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js +136 -123
  184. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  185. package/build/cjs/prod/instrumentations/worker/instrumentD1.js +131 -146
  186. package/build/cjs/prod/instrumentations/worker/instrumentD1.js.map +1 -1
  187. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js +63 -61
  188. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js.map +1 -1
  189. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js +83 -88
  190. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js.map +1 -1
  191. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js +41 -48
  192. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js.map +1 -1
  193. package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js +25 -21
  194. package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js.map +1 -1
  195. package/build/cjs/prod/instrumentations/worker/instrumentKV.js +54 -67
  196. package/build/cjs/prod/instrumentations/worker/instrumentKV.js.map +1 -1
  197. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js +98 -105
  198. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js.map +1 -1
  199. package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js +88 -94
  200. package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  201. package/build/cjs/prod/instrumentations/worker/instrumentR2.js +128 -115
  202. package/build/cjs/prod/instrumentations/worker/instrumentR2.js.map +1 -1
  203. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js +90 -94
  204. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js.map +1 -1
  205. package/build/cjs/prod/instrumentations/worker/instrumentTail.js +100 -55
  206. package/build/cjs/prod/instrumentations/worker/instrumentTail.js.map +1 -1
  207. package/build/cjs/prod/integrations/cronTriggers.js +130 -85
  208. package/build/cjs/prod/integrations/cronTriggers.js.map +1 -1
  209. package/build/cjs/prod/integrations/fetch.js +9 -9
  210. package/build/cjs/prod/integrations/fetch.js.map +1 -1
  211. package/build/cjs/prod/integrations/httpServer.js +41 -22
  212. package/build/cjs/prod/integrations/httpServer.js.map +1 -1
  213. package/build/cjs/prod/integrations/spotlight.js +52 -55
  214. package/build/cjs/prod/integrations/spotlight.js.map +1 -1
  215. package/build/cjs/prod/opentelemetry/tracer.js +10 -8
  216. package/build/cjs/prod/opentelemetry/tracer.js.map +1 -1
  217. package/build/cjs/prod/options.js +37 -24
  218. package/build/cjs/prod/options.js.map +1 -1
  219. package/build/cjs/prod/orchestrion-deferred-channels.js +45 -29
  220. package/build/cjs/prod/orchestrion-deferred-channels.js.map +1 -1
  221. package/build/cjs/prod/orchestrion-diagnostics-channel.js +97 -72
  222. package/build/cjs/prod/orchestrion-diagnostics-channel.js.map +1 -1
  223. package/build/cjs/prod/pages-plugin.js +20 -21
  224. package/build/cjs/prod/pages-plugin.js.map +1 -1
  225. package/build/cjs/prod/request.js +16 -10
  226. package/build/cjs/prod/request.js.map +1 -1
  227. package/build/cjs/prod/scope-utils.js +12 -12
  228. package/build/cjs/prod/scope-utils.js.map +1 -1
  229. package/build/cjs/prod/sdk.js +24 -15
  230. package/build/cjs/prod/sdk.js.map +1 -1
  231. package/build/cjs/prod/transport.js +93 -86
  232. package/build/cjs/prod/transport.js.map +1 -1
  233. package/build/cjs/prod/utils/asyncContextStrategy.js +10 -10
  234. package/build/cjs/prod/utils/asyncContextStrategy.js.map +1 -1
  235. package/build/cjs/prod/utils/bindingPropagation.js +17 -11
  236. package/build/cjs/prod/utils/bindingPropagation.js.map +1 -1
  237. package/build/cjs/prod/utils/cloudflareTrace.js +34 -0
  238. package/build/cjs/prod/utils/cloudflareTrace.js.map +1 -0
  239. package/build/cjs/prod/utils/instrumentContext.js +74 -58
  240. package/build/cjs/prod/utils/instrumentContext.js.map +1 -1
  241. package/build/cjs/prod/utils/internalSqlQuery.js +38 -21
  242. package/build/cjs/prod/utils/internalSqlQuery.js.map +1 -1
  243. package/build/cjs/prod/utils/internalStorageKey.js +41 -38
  244. package/build/cjs/prod/utils/internalStorageKey.js.map +1 -1
  245. package/build/cjs/prod/utils/invocationContext.js +42 -32
  246. package/build/cjs/prod/utils/invocationContext.js.map +1 -1
  247. package/build/cjs/prod/utils/invocationScope.js +45 -21
  248. package/build/cjs/prod/utils/invocationScope.js.map +1 -1
  249. package/build/cjs/prod/utils/isBinding.js +47 -15
  250. package/build/cjs/prod/utils/isBinding.js.map +1 -1
  251. package/build/cjs/prod/utils/isCloudflareClass.js +11 -20
  252. package/build/cjs/prod/utils/isCloudflareClass.js.map +1 -1
  253. package/build/cjs/prod/utils/queueTraceMeta.js +24 -35
  254. package/build/cjs/prod/utils/queueTraceMeta.js.map +1 -1
  255. package/build/cjs/prod/utils/rpcMeta.js +37 -27
  256. package/build/cjs/prod/utils/rpcMeta.js.map +1 -1
  257. package/build/cjs/prod/utils/traceLinks.js +52 -42
  258. package/build/cjs/prod/utils/traceLinks.js.map +1 -1
  259. package/build/cjs/prod/vendor/stacktrace.js +32 -24
  260. package/build/cjs/prod/vendor/stacktrace.js.map +1 -1
  261. package/build/cjs/prod/vite/agentClass.js +105 -98
  262. package/build/cjs/prod/vite/agentClass.js.map +1 -1
  263. package/build/cjs/prod/vite/autoInstrument.js +121 -122
  264. package/build/cjs/prod/vite/autoInstrument.js.map +1 -1
  265. package/build/cjs/prod/vite/index.js +44 -21
  266. package/build/cjs/prod/vite/index.js.map +1 -1
  267. package/build/cjs/prod/vite/instrumentFile.js +37 -20
  268. package/build/cjs/prod/vite/instrumentFile.js.map +1 -1
  269. package/build/cjs/prod/vite/mastraObservability.js +19 -12
  270. package/build/cjs/prod/vite/mastraObservability.js.map +1 -1
  271. package/build/cjs/prod/vite/moduleShape.js +220 -201
  272. package/build/cjs/prod/vite/moduleShape.js.map +1 -1
  273. package/build/cjs/prod/vite/providedModulePlugin.js +62 -45
  274. package/build/cjs/prod/vite/providedModulePlugin.js.map +1 -1
  275. package/build/cjs/prod/vite/transform.js +333 -284
  276. package/build/cjs/prod/vite/transform.js.map +1 -1
  277. package/build/cjs/prod/vite/workerEntrypoint.js +66 -57
  278. package/build/cjs/prod/vite/workerEntrypoint.js.map +1 -1
  279. package/build/cjs/prod/vite/wranglerConfig.js +92 -67
  280. package/build/cjs/prod/vite/wranglerConfig.js.map +1 -1
  281. package/build/cjs/prod/withSentry.js +32 -26
  282. package/build/cjs/prod/withSentry.js.map +1 -1
  283. package/build/cjs/prod/workflows.js +164 -151
  284. package/build/cjs/prod/workflows.js.map +1 -1
  285. package/build/cjs/prod/wrapMethodWithSentry.js +148 -169
  286. package/build/cjs/prod/wrapMethodWithSentry.js.map +1 -1
  287. package/build/cjs/prod/wrapRequestHandlerWithInit.js +76 -78
  288. package/build/cjs/prod/wrapRequestHandlerWithInit.js.map +1 -1
  289. package/build/esm/dev/baseSdk.js +98 -101
  290. package/build/esm/dev/baseSdk.js.map +1 -1
  291. package/build/esm/dev/client.js +213 -235
  292. package/build/esm/dev/client.js.map +1 -1
  293. package/build/esm/dev/clientCache.js +8 -6
  294. package/build/esm/dev/clientCache.js.map +1 -1
  295. package/build/esm/dev/debug-build.js +9 -3
  296. package/build/esm/dev/debug-build.js.map +1 -1
  297. package/build/esm/dev/defineCloudflareOptions.js +5 -6
  298. package/build/esm/dev/defineCloudflareOptions.js.map +1 -1
  299. package/build/esm/dev/durableobject.js +287 -174
  300. package/build/esm/dev/durableobject.js.map +1 -1
  301. package/build/esm/dev/flush.js +104 -75
  302. package/build/esm/dev/flush.js.map +1 -1
  303. package/build/esm/dev/index.js +19 -18
  304. package/build/esm/dev/instrument.js +53 -37
  305. package/build/esm/dev/instrument.js.map +1 -1
  306. package/build/esm/dev/instrumentations/agents/index.js +34 -11
  307. package/build/esm/dev/instrumentations/agents/index.js.map +1 -1
  308. package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js +46 -47
  309. package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  310. package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js +23 -14
  311. package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
  312. package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js +36 -26
  313. package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
  314. package/build/esm/dev/instrumentations/agents/types.js +103 -56
  315. package/build/esm/dev/instrumentations/agents/types.js.map +1 -1
  316. package/build/esm/dev/instrumentations/instrumentDurableObjectHandlers.js +87 -116
  317. package/build/esm/dev/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
  318. package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js +46 -42
  319. package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  320. package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js +70 -69
  321. package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  322. package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -37
  323. package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  324. package/build/esm/dev/instrumentations/instrumentSqlStorage.js +50 -50
  325. package/build/esm/dev/instrumentations/instrumentSqlStorage.js.map +1 -1
  326. package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js +136 -121
  327. package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  328. package/build/esm/dev/instrumentations/worker/instrumentD1.js +131 -144
  329. package/build/esm/dev/instrumentations/worker/instrumentD1.js.map +1 -1
  330. package/build/esm/dev/instrumentations/worker/instrumentEmail.js +63 -59
  331. package/build/esm/dev/instrumentations/worker/instrumentEmail.js.map +1 -1
  332. package/build/esm/dev/instrumentations/worker/instrumentEnv.js +83 -86
  333. package/build/esm/dev/instrumentations/worker/instrumentEnv.js.map +1 -1
  334. package/build/esm/dev/instrumentations/worker/instrumentFetch.js +41 -46
  335. package/build/esm/dev/instrumentations/worker/instrumentFetch.js.map +1 -1
  336. package/build/esm/dev/instrumentations/worker/instrumentFetcher.js +25 -19
  337. package/build/esm/dev/instrumentations/worker/instrumentFetcher.js.map +1 -1
  338. package/build/esm/dev/instrumentations/worker/instrumentKV.js +54 -65
  339. package/build/esm/dev/instrumentations/worker/instrumentKV.js.map +1 -1
  340. package/build/esm/dev/instrumentations/worker/instrumentQueue.js +98 -103
  341. package/build/esm/dev/instrumentations/worker/instrumentQueue.js.map +1 -1
  342. package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js +88 -92
  343. package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  344. package/build/esm/dev/instrumentations/worker/instrumentR2.js +128 -113
  345. package/build/esm/dev/instrumentations/worker/instrumentR2.js.map +1 -1
  346. package/build/esm/dev/instrumentations/worker/instrumentScheduled.js +90 -92
  347. package/build/esm/dev/instrumentations/worker/instrumentScheduled.js.map +1 -1
  348. package/build/esm/dev/instrumentations/worker/instrumentTail.js +100 -53
  349. package/build/esm/dev/instrumentations/worker/instrumentTail.js.map +1 -1
  350. package/build/esm/dev/integrations/cronTriggers.js +129 -82
  351. package/build/esm/dev/integrations/cronTriggers.js.map +1 -1
  352. package/build/esm/dev/integrations/fetch.js +9 -6
  353. package/build/esm/dev/integrations/fetch.js.map +1 -1
  354. package/build/esm/dev/integrations/httpServer.js +40 -19
  355. package/build/esm/dev/integrations/httpServer.js.map +1 -1
  356. package/build/esm/dev/integrations/spotlight.js +51 -52
  357. package/build/esm/dev/integrations/spotlight.js.map +1 -1
  358. package/build/esm/dev/opentelemetry/tracer.js +10 -6
  359. package/build/esm/dev/opentelemetry/tracer.js.map +1 -1
  360. package/build/esm/dev/options.js +55 -37
  361. package/build/esm/dev/options.js.map +1 -1
  362. package/build/esm/dev/orchestrion-deferred-channels.js +45 -27
  363. package/build/esm/dev/orchestrion-deferred-channels.js.map +1 -1
  364. package/build/esm/dev/orchestrion-diagnostics-channel.js +87 -66
  365. package/build/esm/dev/orchestrion-diagnostics-channel.js.map +1 -1
  366. package/build/esm/dev/package.json +1 -1
  367. package/build/esm/dev/pages-plugin.js +20 -19
  368. package/build/esm/dev/pages-plugin.js.map +1 -1
  369. package/build/esm/dev/request.js +14 -7
  370. package/build/esm/dev/request.js.map +1 -1
  371. package/build/esm/dev/scope-utils.js +12 -10
  372. package/build/esm/dev/scope-utils.js.map +1 -1
  373. package/build/esm/dev/sdk.js +23 -13
  374. package/build/esm/dev/sdk.js.map +1 -1
  375. package/build/esm/dev/transport.js +93 -84
  376. package/build/esm/dev/transport.js.map +1 -1
  377. package/build/esm/dev/utils/asyncContextStrategy.js +10 -8
  378. package/build/esm/dev/utils/asyncContextStrategy.js.map +1 -1
  379. package/build/esm/dev/utils/bindingPropagation.js +17 -9
  380. package/build/esm/dev/utils/bindingPropagation.js.map +1 -1
  381. package/build/esm/dev/utils/cloudflareTrace.js +34 -0
  382. package/build/esm/dev/utils/cloudflareTrace.js.map +1 -0
  383. package/build/esm/dev/utils/instrumentContext.js +74 -56
  384. package/build/esm/dev/utils/instrumentContext.js.map +1 -1
  385. package/build/esm/dev/utils/internalSqlQuery.js +38 -19
  386. package/build/esm/dev/utils/internalSqlQuery.js.map +1 -1
  387. package/build/esm/dev/utils/internalStorageKey.js +41 -36
  388. package/build/esm/dev/utils/internalStorageKey.js.map +1 -1
  389. package/build/esm/dev/utils/invocationContext.js +42 -30
  390. package/build/esm/dev/utils/invocationContext.js.map +1 -1
  391. package/build/esm/dev/utils/invocationScope.js +45 -19
  392. package/build/esm/dev/utils/invocationScope.js.map +1 -1
  393. package/build/esm/dev/utils/isBinding.js +47 -13
  394. package/build/esm/dev/utils/isBinding.js.map +1 -1
  395. package/build/esm/dev/utils/isCloudflareClass.js +11 -18
  396. package/build/esm/dev/utils/isCloudflareClass.js.map +1 -1
  397. package/build/esm/dev/utils/queueTraceMeta.js +24 -33
  398. package/build/esm/dev/utils/queueTraceMeta.js.map +1 -1
  399. package/build/esm/dev/utils/rpcMeta.js +37 -25
  400. package/build/esm/dev/utils/rpcMeta.js.map +1 -1
  401. package/build/esm/dev/utils/traceLinks.js +52 -40
  402. package/build/esm/dev/utils/traceLinks.js.map +1 -1
  403. package/build/esm/dev/vendor/stacktrace.js +31 -21
  404. package/build/esm/dev/vendor/stacktrace.js.map +1 -1
  405. package/build/esm/dev/vite/agentClass.js +105 -96
  406. package/build/esm/dev/vite/agentClass.js.map +1 -1
  407. package/build/esm/dev/vite/autoInstrument.js +121 -120
  408. package/build/esm/dev/vite/autoInstrument.js.map +1 -1
  409. package/build/esm/dev/vite/index.js +43 -19
  410. package/build/esm/dev/vite/index.js.map +1 -1
  411. package/build/esm/dev/vite/instrumentFile.js +37 -18
  412. package/build/esm/dev/vite/instrumentFile.js.map +1 -1
  413. package/build/esm/dev/vite/mastraObservability.js +19 -10
  414. package/build/esm/dev/vite/mastraObservability.js.map +1 -1
  415. package/build/esm/dev/vite/moduleShape.js +220 -199
  416. package/build/esm/dev/vite/moduleShape.js.map +1 -1
  417. package/build/esm/dev/vite/providedModulePlugin.js +60 -43
  418. package/build/esm/dev/vite/providedModulePlugin.js.map +1 -1
  419. package/build/esm/dev/vite/transform.js +331 -282
  420. package/build/esm/dev/vite/transform.js.map +1 -1
  421. package/build/esm/dev/vite/workerEntrypoint.js +66 -55
  422. package/build/esm/dev/vite/workerEntrypoint.js.map +1 -1
  423. package/build/esm/dev/vite/wranglerConfig.js +92 -65
  424. package/build/esm/dev/vite/wranglerConfig.js.map +1 -1
  425. package/build/esm/dev/withSentry.js +32 -24
  426. package/build/esm/dev/withSentry.js.map +1 -1
  427. package/build/esm/dev/workflows.js +164 -149
  428. package/build/esm/dev/workflows.js.map +1 -1
  429. package/build/esm/dev/wrapMethodWithSentry.js +148 -167
  430. package/build/esm/dev/wrapMethodWithSentry.js.map +1 -1
  431. package/build/esm/dev/wrapRequestHandlerWithInit.js +76 -76
  432. package/build/esm/dev/wrapRequestHandlerWithInit.js.map +1 -1
  433. package/build/esm/prod/baseSdk.js +94 -91
  434. package/build/esm/prod/baseSdk.js.map +1 -1
  435. package/build/esm/prod/client.js +213 -235
  436. package/build/esm/prod/client.js.map +1 -1
  437. package/build/esm/prod/clientCache.js +8 -6
  438. package/build/esm/prod/clientCache.js.map +1 -1
  439. package/build/esm/prod/debug-build.js +9 -3
  440. package/build/esm/prod/debug-build.js.map +1 -1
  441. package/build/esm/prod/defineCloudflareOptions.js +5 -6
  442. package/build/esm/prod/defineCloudflareOptions.js.map +1 -1
  443. package/build/esm/prod/durableobject.js +287 -174
  444. package/build/esm/prod/durableobject.js.map +1 -1
  445. package/build/esm/prod/flush.js +104 -75
  446. package/build/esm/prod/flush.js.map +1 -1
  447. package/build/esm/prod/index.js +19 -18
  448. package/build/esm/prod/instrument.js +53 -37
  449. package/build/esm/prod/instrument.js.map +1 -1
  450. package/build/esm/prod/instrumentations/agents/index.js +34 -11
  451. package/build/esm/prod/instrumentations/agents/index.js.map +1 -1
  452. package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js +46 -47
  453. package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  454. package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js +23 -14
  455. package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
  456. package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js +36 -26
  457. package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
  458. package/build/esm/prod/instrumentations/agents/types.js +103 -56
  459. package/build/esm/prod/instrumentations/agents/types.js.map +1 -1
  460. package/build/esm/prod/instrumentations/instrumentDurableObjectHandlers.js +87 -116
  461. package/build/esm/prod/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
  462. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js +46 -42
  463. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  464. package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js +70 -69
  465. package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  466. package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -37
  467. package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  468. package/build/esm/prod/instrumentations/instrumentSqlStorage.js +50 -50
  469. package/build/esm/prod/instrumentations/instrumentSqlStorage.js.map +1 -1
  470. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js +136 -121
  471. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  472. package/build/esm/prod/instrumentations/worker/instrumentD1.js +131 -144
  473. package/build/esm/prod/instrumentations/worker/instrumentD1.js.map +1 -1
  474. package/build/esm/prod/instrumentations/worker/instrumentEmail.js +63 -59
  475. package/build/esm/prod/instrumentations/worker/instrumentEmail.js.map +1 -1
  476. package/build/esm/prod/instrumentations/worker/instrumentEnv.js +83 -86
  477. package/build/esm/prod/instrumentations/worker/instrumentEnv.js.map +1 -1
  478. package/build/esm/prod/instrumentations/worker/instrumentFetch.js +41 -46
  479. package/build/esm/prod/instrumentations/worker/instrumentFetch.js.map +1 -1
  480. package/build/esm/prod/instrumentations/worker/instrumentFetcher.js +25 -19
  481. package/build/esm/prod/instrumentations/worker/instrumentFetcher.js.map +1 -1
  482. package/build/esm/prod/instrumentations/worker/instrumentKV.js +54 -65
  483. package/build/esm/prod/instrumentations/worker/instrumentKV.js.map +1 -1
  484. package/build/esm/prod/instrumentations/worker/instrumentQueue.js +98 -103
  485. package/build/esm/prod/instrumentations/worker/instrumentQueue.js.map +1 -1
  486. package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js +88 -92
  487. package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  488. package/build/esm/prod/instrumentations/worker/instrumentR2.js +128 -113
  489. package/build/esm/prod/instrumentations/worker/instrumentR2.js.map +1 -1
  490. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js +90 -92
  491. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js.map +1 -1
  492. package/build/esm/prod/instrumentations/worker/instrumentTail.js +100 -53
  493. package/build/esm/prod/instrumentations/worker/instrumentTail.js.map +1 -1
  494. package/build/esm/prod/integrations/cronTriggers.js +129 -82
  495. package/build/esm/prod/integrations/cronTriggers.js.map +1 -1
  496. package/build/esm/prod/integrations/fetch.js +9 -6
  497. package/build/esm/prod/integrations/fetch.js.map +1 -1
  498. package/build/esm/prod/integrations/httpServer.js +40 -19
  499. package/build/esm/prod/integrations/httpServer.js.map +1 -1
  500. package/build/esm/prod/integrations/spotlight.js +51 -52
  501. package/build/esm/prod/integrations/spotlight.js.map +1 -1
  502. package/build/esm/prod/opentelemetry/tracer.js +10 -6
  503. package/build/esm/prod/opentelemetry/tracer.js.map +1 -1
  504. package/build/esm/prod/options.js +37 -22
  505. package/build/esm/prod/options.js.map +1 -1
  506. package/build/esm/prod/orchestrion-deferred-channels.js +45 -27
  507. package/build/esm/prod/orchestrion-deferred-channels.js.map +1 -1
  508. package/build/esm/prod/orchestrion-diagnostics-channel.js +87 -66
  509. package/build/esm/prod/orchestrion-diagnostics-channel.js.map +1 -1
  510. package/build/esm/prod/package.json +1 -1
  511. package/build/esm/prod/pages-plugin.js +20 -19
  512. package/build/esm/prod/pages-plugin.js.map +1 -1
  513. package/build/esm/prod/request.js +14 -7
  514. package/build/esm/prod/request.js.map +1 -1
  515. package/build/esm/prod/scope-utils.js +12 -10
  516. package/build/esm/prod/scope-utils.js.map +1 -1
  517. package/build/esm/prod/sdk.js +23 -13
  518. package/build/esm/prod/sdk.js.map +1 -1
  519. package/build/esm/prod/transport.js +93 -84
  520. package/build/esm/prod/transport.js.map +1 -1
  521. package/build/esm/prod/utils/asyncContextStrategy.js +10 -8
  522. package/build/esm/prod/utils/asyncContextStrategy.js.map +1 -1
  523. package/build/esm/prod/utils/bindingPropagation.js +17 -9
  524. package/build/esm/prod/utils/bindingPropagation.js.map +1 -1
  525. package/build/esm/prod/utils/cloudflareTrace.js +34 -0
  526. package/build/esm/prod/utils/cloudflareTrace.js.map +1 -0
  527. package/build/esm/prod/utils/instrumentContext.js +74 -56
  528. package/build/esm/prod/utils/instrumentContext.js.map +1 -1
  529. package/build/esm/prod/utils/internalSqlQuery.js +38 -19
  530. package/build/esm/prod/utils/internalSqlQuery.js.map +1 -1
  531. package/build/esm/prod/utils/internalStorageKey.js +41 -36
  532. package/build/esm/prod/utils/internalStorageKey.js.map +1 -1
  533. package/build/esm/prod/utils/invocationContext.js +42 -30
  534. package/build/esm/prod/utils/invocationContext.js.map +1 -1
  535. package/build/esm/prod/utils/invocationScope.js +45 -19
  536. package/build/esm/prod/utils/invocationScope.js.map +1 -1
  537. package/build/esm/prod/utils/isBinding.js +47 -13
  538. package/build/esm/prod/utils/isBinding.js.map +1 -1
  539. package/build/esm/prod/utils/isCloudflareClass.js +11 -18
  540. package/build/esm/prod/utils/isCloudflareClass.js.map +1 -1
  541. package/build/esm/prod/utils/queueTraceMeta.js +24 -33
  542. package/build/esm/prod/utils/queueTraceMeta.js.map +1 -1
  543. package/build/esm/prod/utils/rpcMeta.js +37 -25
  544. package/build/esm/prod/utils/rpcMeta.js.map +1 -1
  545. package/build/esm/prod/utils/traceLinks.js +52 -40
  546. package/build/esm/prod/utils/traceLinks.js.map +1 -1
  547. package/build/esm/prod/vendor/stacktrace.js +31 -21
  548. package/build/esm/prod/vendor/stacktrace.js.map +1 -1
  549. package/build/esm/prod/vite/agentClass.js +105 -96
  550. package/build/esm/prod/vite/agentClass.js.map +1 -1
  551. package/build/esm/prod/vite/autoInstrument.js +121 -120
  552. package/build/esm/prod/vite/autoInstrument.js.map +1 -1
  553. package/build/esm/prod/vite/index.js +43 -19
  554. package/build/esm/prod/vite/index.js.map +1 -1
  555. package/build/esm/prod/vite/instrumentFile.js +37 -18
  556. package/build/esm/prod/vite/instrumentFile.js.map +1 -1
  557. package/build/esm/prod/vite/mastraObservability.js +19 -10
  558. package/build/esm/prod/vite/mastraObservability.js.map +1 -1
  559. package/build/esm/prod/vite/moduleShape.js +220 -199
  560. package/build/esm/prod/vite/moduleShape.js.map +1 -1
  561. package/build/esm/prod/vite/providedModulePlugin.js +60 -43
  562. package/build/esm/prod/vite/providedModulePlugin.js.map +1 -1
  563. package/build/esm/prod/vite/transform.js +331 -282
  564. package/build/esm/prod/vite/transform.js.map +1 -1
  565. package/build/esm/prod/vite/workerEntrypoint.js +66 -55
  566. package/build/esm/prod/vite/workerEntrypoint.js.map +1 -1
  567. package/build/esm/prod/vite/wranglerConfig.js +92 -65
  568. package/build/esm/prod/vite/wranglerConfig.js.map +1 -1
  569. package/build/esm/prod/withSentry.js +32 -24
  570. package/build/esm/prod/withSentry.js.map +1 -1
  571. package/build/esm/prod/workflows.js +164 -149
  572. package/build/esm/prod/workflows.js.map +1 -1
  573. package/build/esm/prod/wrapMethodWithSentry.js +148 -167
  574. package/build/esm/prod/wrapMethodWithSentry.js.map +1 -1
  575. package/build/esm/prod/wrapRequestHandlerWithInit.js +76 -76
  576. package/build/esm/prod/wrapRequestHandlerWithInit.js.map +1 -1
  577. package/build/types/client.d.ts +2 -1
  578. package/build/types/client.d.ts.map +1 -1
  579. package/build/types/index.d.ts +3 -2
  580. package/build/types/index.d.ts.map +1 -1
  581. package/build/types/instrumentations/worker/instrumentEmail.d.ts.map +1 -1
  582. package/build/types/instrumentations/worker/instrumentFetcher.d.ts.map +1 -1
  583. package/build/types/instrumentations/worker/instrumentQueue.d.ts.map +1 -1
  584. package/build/types/instrumentations/worker/instrumentScheduled.d.ts.map +1 -1
  585. package/build/types/instrumentations/worker/instrumentTail.d.ts +4 -2
  586. package/build/types/instrumentations/worker/instrumentTail.d.ts.map +1 -1
  587. package/build/types/utils/cloudflareTrace.d.ts +13 -0
  588. package/build/types/utils/cloudflareTrace.d.ts.map +1 -0
  589. package/build/types/vite/autoInstrument.d.ts.map +1 -1
  590. package/build/types/vite/index.d.ts.map +1 -1
  591. package/build/types/vite/providedModulePlugin.d.ts +15 -11
  592. package/build/types/vite/providedModulePlugin.d.ts.map +1 -1
  593. package/build/types/workflows.d.ts.map +1 -1
  594. package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
  595. package/build/types/wrapRequestHandlerWithInit.d.ts.map +1 -1
  596. package/package.json +10 -14
  597. package/build/cjs/dev/index.js.map +0 -1
  598. package/build/cjs/dev/vite/flueRuntime.js +0 -15
  599. package/build/cjs/dev/vite/flueRuntime.js.map +0 -1
  600. package/build/cjs/prod/index.js.map +0 -1
  601. package/build/cjs/prod/vite/flueRuntime.js +0 -15
  602. package/build/cjs/prod/vite/flueRuntime.js.map +0 -1
  603. package/build/esm/dev/index.js.map +0 -1
  604. package/build/esm/dev/vite/flueRuntime.js +0 -13
  605. package/build/esm/dev/vite/flueRuntime.js.map +0 -1
  606. package/build/esm/prod/index.js.map +0 -1
  607. package/build/esm/prod/vite/flueRuntime.js +0 -13
  608. package/build/esm/prod/vite/flueRuntime.js.map +0 -1
  609. package/build/types/vite/flueRuntime.d.ts +0 -12
  610. package/build/types/vite/flueRuntime.d.ts.map +0 -1
@@ -1,61 +1,60 @@
1
- import { defineIntegration, debug, serializeEnvelope, suppressTracing } from '@sentry/core';
2
- import { DEBUG_BUILD } from '../debug-build.js';
3
-
1
+ import { DEBUG_BUILD } from "../debug-build.js";
2
+ import { debug, defineIntegration, serializeEnvelope, suppressTracing } from "@sentry/core";
3
+ // src/integrations/spotlight.ts
4
4
  const INTEGRATION_NAME = "Spotlight";
5
5
  const _spotlightIntegration = ((options = {}) => {
6
- const sidecarUrl = options.sidecarUrl || "http://localhost:8969/stream";
7
- return {
8
- name: INTEGRATION_NAME,
9
- setup(client) {
10
- DEBUG_BUILD && debug.log("[Spotlight] Using Sidecar URL", sidecarUrl);
11
- setupSidecarForwarding(client, sidecarUrl);
12
- }
13
- };
6
+ const sidecarUrl = options.sidecarUrl || "http://localhost:8969/stream";
7
+ return {
8
+ name: INTEGRATION_NAME,
9
+ setup(client) {
10
+ DEBUG_BUILD && debug.log("[Spotlight] Using Sidecar URL", sidecarUrl);
11
+ setupSidecarForwarding(client, sidecarUrl);
12
+ }
13
+ };
14
14
  });
15
+ /**
16
+ * Use this integration to send errors and transactions to Spotlight.
17
+ *
18
+ * Learn more about spotlight at https://spotlightjs.com
19
+ *
20
+ * Important: This integration is intended for local development only.
21
+ * Each forwarded envelope counts as a Worker subrequest (50 free / 1000 paid
22
+ * per invocation), so it should not be enabled in production.
23
+ */
15
24
  const spotlightIntegration = defineIntegration(_spotlightIntegration);
16
25
  function setupSidecarForwarding(client, sidecarUrl) {
17
- const parsedUrl = parseSidecarUrl(sidecarUrl);
18
- if (!parsedUrl) {
19
- return;
20
- }
21
- let failCount = 0;
22
- client.on("beforeEnvelope", (envelope) => {
23
- if (failCount > 3) {
24
- DEBUG_BUILD && debug.warn("[Spotlight] Disabled Sentry -> Spotlight forwarding due to too many failed requests");
25
- return;
26
- }
27
- const body = serializeEnvelope(envelope);
28
- suppressTracing(() => {
29
- fetch(parsedUrl.href, {
30
- method: "POST",
31
- body,
32
- headers: {
33
- "Content-Type": "application/x-sentry-envelope"
34
- }
35
- }).then(
36
- (res) => {
37
- res.text().catch(() => {
38
- });
39
- if (res.status >= 200 && res.status < 400) {
40
- failCount = 0;
41
- }
42
- },
43
- () => {
44
- failCount++;
45
- DEBUG_BUILD && debug.warn("[Spotlight] Failed to send envelope to Spotlight Sidecar");
46
- }
47
- );
48
- });
49
- });
26
+ const parsedUrl = parseSidecarUrl(sidecarUrl);
27
+ if (!parsedUrl) return;
28
+ let failCount = 0;
29
+ client.on("beforeEnvelope", (envelope) => {
30
+ if (failCount > 3) {
31
+ DEBUG_BUILD && debug.warn("[Spotlight] Disabled Sentry -> Spotlight forwarding due to too many failed requests");
32
+ return;
33
+ }
34
+ const body = serializeEnvelope(envelope);
35
+ suppressTracing(() => {
36
+ fetch(parsedUrl.href, {
37
+ method: "POST",
38
+ body,
39
+ headers: { "Content-Type": "application/x-sentry-envelope" }
40
+ }).then((res) => {
41
+ res.text().catch(() => {});
42
+ if (res.status >= 200 && res.status < 400) failCount = 0;
43
+ }, () => {
44
+ failCount++;
45
+ DEBUG_BUILD && debug.warn("[Spotlight] Failed to send envelope to Spotlight Sidecar");
46
+ });
47
+ });
48
+ });
50
49
  }
51
50
  function parseSidecarUrl(url) {
52
- try {
53
- return new URL(url);
54
- } catch {
55
- DEBUG_BUILD && debug.warn(`[Spotlight] Invalid sidecar URL: ${url}`);
56
- return void 0;
57
- }
51
+ try {
52
+ return new URL(url);
53
+ } catch {
54
+ DEBUG_BUILD && debug.warn(`[Spotlight] Invalid sidecar URL: ${url}`);
55
+ return;
56
+ }
58
57
  }
59
-
60
58
  export { INTEGRATION_NAME, spotlightIntegration };
61
- //# sourceMappingURL=spotlight.js.map
59
+
60
+ //# sourceMappingURL=spotlight.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"spotlight.js","sources":["../../../../src/integrations/spotlight.ts"],"sourcesContent":["import type { Client, Envelope, IntegrationFn } from '@sentry/core';\nimport { debug, defineIntegration, serializeEnvelope, suppressTracing } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\ntype SpotlightConnectionOptions = {\n /**\n * Set this if the Spotlight Sidecar is not running on localhost:8969.\n * By default, the URL is set to http://localhost:8969/stream\n */\n sidecarUrl?: string;\n};\n\nexport const INTEGRATION_NAME = 'Spotlight' as const;\n\nconst _spotlightIntegration = ((options: Partial<SpotlightConnectionOptions> = {}) => {\n const sidecarUrl = options.sidecarUrl || 'http://localhost:8969/stream';\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n DEBUG_BUILD && debug.log('[Spotlight] Using Sidecar URL', sidecarUrl);\n setupSidecarForwarding(client, sidecarUrl);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Use this integration to send errors and transactions to Spotlight.\n *\n * Learn more about spotlight at https://spotlightjs.com\n *\n * Important: This integration is intended for local development only.\n * Each forwarded envelope counts as a Worker subrequest (50 free / 1000 paid\n * per invocation), so it should not be enabled in production.\n */\nexport const spotlightIntegration = defineIntegration(_spotlightIntegration);\n\nfunction setupSidecarForwarding(client: Client, sidecarUrl: string): void {\n const parsedUrl = parseSidecarUrl(sidecarUrl);\n if (!parsedUrl) {\n return;\n }\n\n let failCount = 0;\n\n client.on('beforeEnvelope', (envelope: Envelope) => {\n if (failCount > 3) {\n DEBUG_BUILD && debug.warn('[Spotlight] Disabled Sentry -> Spotlight forwarding due to too many failed requests');\n return;\n }\n\n const body = serializeEnvelope(envelope);\n\n suppressTracing(() => {\n fetch(parsedUrl.href, {\n method: 'POST',\n body,\n headers: {\n 'Content-Type': 'application/x-sentry-envelope',\n },\n }).then(\n res => {\n // Consume the response body to satisfy Cloudflare Workers' requirement\n // that all fetch response bodies are read or cancelled.\n res.text().catch(() => {\n // no-op\n });\n\n if (res.status >= 200 && res.status < 400) {\n failCount = 0;\n }\n },\n () => {\n failCount++;\n DEBUG_BUILD && debug.warn('[Spotlight] Failed to send envelope to Spotlight Sidecar');\n },\n );\n });\n });\n}\n\nfunction parseSidecarUrl(url: string): URL | undefined {\n try {\n return new URL(url);\n } catch {\n DEBUG_BUILD && debug.warn(`[Spotlight] Invalid sidecar URL: ${url}`);\n return undefined;\n }\n}\n"],"names":[],"mappings":";;;AAYO,MAAM,gBAAA,GAAmB;AAEhC,MAAM,qBAAA,IAAyB,CAAC,OAAA,GAA+C,EAAC,KAAM;AACpF,EAAA,MAAM,UAAA,GAAa,QAAQ,UAAA,IAAc,8BAAA;AAEzC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,MAAM,MAAA,EAAQ;AACZ,MAAA,WAAA,IAAe,KAAA,CAAM,GAAA,CAAI,+BAAA,EAAiC,UAAU,CAAA;AACpE,MAAA,sBAAA,CAAuB,QAAQ,UAAU,CAAA;AAAA,IAC3C;AAAA,GACF;AACF,CAAA,CAAA;AAWO,MAAM,oBAAA,GAAuB,kBAAkB,qBAAqB;AAE3E,SAAS,sBAAA,CAAuB,QAAgB,UAAA,EAA0B;AACxE,EAAA,MAAM,SAAA,GAAY,gBAAgB,UAAU,CAAA;AAC5C,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA;AAAA,EACF;AAEA,EAAA,IAAI,SAAA,GAAY,CAAA;AAEhB,EAAA,MAAA,CAAO,EAAA,CAAG,gBAAA,EAAkB,CAAC,QAAA,KAAuB;AAClD,IAAA,IAAI,YAAY,CAAA,EAAG;AACjB,MAAA,WAAA,IAAe,KAAA,CAAM,KAAK,qFAAqF,CAAA;AAC/G,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,IAAA,GAAO,kBAAkB,QAAQ,CAAA;AAEvC,IAAA,eAAA,CAAgB,MAAM;AACpB,MAAA,KAAA,CAAM,UAAU,IAAA,EAAM;AAAA,QACpB,MAAA,EAAQ,MAAA;AAAA,QACR,IAAA;AAAA,QACA,OAAA,EAAS;AAAA,UACP,cAAA,EAAgB;AAAA;AAClB,OACD,CAAA,CAAE,IAAA;AAAA,QACD,CAAA,GAAA,KAAO;AAGL,UAAA,GAAA,CAAI,IAAA,EAAK,CAAE,KAAA,CAAM,MAAM;AAAA,UAEvB,CAAC,CAAA;AAED,UAAA,IAAI,GAAA,CAAI,MAAA,IAAU,GAAA,IAAO,GAAA,CAAI,SAAS,GAAA,EAAK;AACzC,YAAA,SAAA,GAAY,CAAA;AAAA,UACd;AAAA,QACF,CAAA;AAAA,QACA,MAAM;AACJ,UAAA,SAAA,EAAA;AACA,UAAA,WAAA,IAAe,KAAA,CAAM,KAAK,0DAA0D,CAAA;AAAA,QACtF;AAAA,OACF;AAAA,IACF,CAAC,CAAA;AAAA,EACH,CAAC,CAAA;AACH;AAEA,SAAS,gBAAgB,GAAA,EAA8B;AACrD,EAAA,IAAI;AACF,IAAA,OAAO,IAAI,IAAI,GAAG,CAAA;AAAA,EACpB,CAAA,CAAA,MAAQ;AACN,IAAA,WAAA,IAAe,KAAA,CAAM,IAAA,CAAK,CAAA,iCAAA,EAAoC,GAAG,CAAA,CAAE,CAAA;AACnE,IAAA,OAAO,MAAA;AAAA,EACT;AACF;;;;"}
1
+ {"version":3,"file":"spotlight.js","names":[],"sources":["../../../../src/integrations/spotlight.ts"],"sourcesContent":["import type { Client, Envelope, IntegrationFn } from '@sentry/core';\nimport { debug, defineIntegration, serializeEnvelope, suppressTracing } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\ntype SpotlightConnectionOptions = {\n /**\n * Set this if the Spotlight Sidecar is not running on localhost:8969.\n * By default, the URL is set to http://localhost:8969/stream\n */\n sidecarUrl?: string;\n};\n\nexport const INTEGRATION_NAME = 'Spotlight' as const;\n\nconst _spotlightIntegration = ((options: Partial<SpotlightConnectionOptions> = {}) => {\n const sidecarUrl = options.sidecarUrl || 'http://localhost:8969/stream';\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n DEBUG_BUILD && debug.log('[Spotlight] Using Sidecar URL', sidecarUrl);\n setupSidecarForwarding(client, sidecarUrl);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Use this integration to send errors and transactions to Spotlight.\n *\n * Learn more about spotlight at https://spotlightjs.com\n *\n * Important: This integration is intended for local development only.\n * Each forwarded envelope counts as a Worker subrequest (50 free / 1000 paid\n * per invocation), so it should not be enabled in production.\n */\nexport const spotlightIntegration = defineIntegration(_spotlightIntegration);\n\nfunction setupSidecarForwarding(client: Client, sidecarUrl: string): void {\n const parsedUrl = parseSidecarUrl(sidecarUrl);\n if (!parsedUrl) {\n return;\n }\n\n let failCount = 0;\n\n client.on('beforeEnvelope', (envelope: Envelope) => {\n if (failCount > 3) {\n DEBUG_BUILD && debug.warn('[Spotlight] Disabled Sentry -> Spotlight forwarding due to too many failed requests');\n return;\n }\n\n const body = serializeEnvelope(envelope);\n\n suppressTracing(() => {\n fetch(parsedUrl.href, {\n method: 'POST',\n body,\n headers: {\n 'Content-Type': 'application/x-sentry-envelope',\n },\n }).then(\n res => {\n // Consume the response body to satisfy Cloudflare Workers' requirement\n // that all fetch response bodies are read or cancelled.\n res.text().catch(() => {\n // no-op\n });\n\n if (res.status >= 200 && res.status < 400) {\n failCount = 0;\n }\n },\n () => {\n failCount++;\n DEBUG_BUILD && debug.warn('[Spotlight] Failed to send envelope to Spotlight Sidecar');\n },\n );\n });\n });\n}\n\nfunction parseSidecarUrl(url: string): URL | undefined {\n try {\n return new URL(url);\n } catch {\n DEBUG_BUILD && debug.warn(`[Spotlight] Invalid sidecar URL: ${url}`);\n return undefined;\n }\n}\n"],"mappings":";;;AAYA,MAAa,mBAAmB;AAEhC,MAAM,0BAA0B,UAA+C,CAAC,MAAM;CACpF,MAAM,aAAa,QAAQ,cAAc;CAEzC,OAAO;EACL,MAAM;EACN,MAAM,QAAQ;GACZ,eAAe,MAAM,IAAI,iCAAiC,UAAU;GACpE,uBAAuB,QAAQ,UAAU;EAC3C;CACF;AACF;;;;;;;;;;AAWA,MAAa,uBAAuB,kBAAkB,qBAAqB;AAE3E,SAAS,uBAAuB,QAAgB,YAA0B;CACxE,MAAM,YAAY,gBAAgB,UAAU;CAC5C,IAAI,CAAC,WACH;CAGF,IAAI,YAAY;CAEhB,OAAO,GAAG,mBAAmB,aAAuB;EAClD,IAAI,YAAY,GAAG;GACjB,eAAe,MAAM,KAAK,qFAAqF;GAC/G;EACF;EAEA,MAAM,OAAO,kBAAkB,QAAQ;EAEvC,sBAAsB;GACpB,MAAM,UAAU,MAAM;IACpB,QAAQ;IACR;IACA,SAAS,EACP,gBAAgB,gCAClB;GACF,CAAC,CAAC,CAAC,MACD,QAAO;IAGL,IAAI,KAAK,CAAC,CAAC,YAAY,CAEvB,CAAC;IAED,IAAI,IAAI,UAAU,OAAO,IAAI,SAAS,KACpC,YAAY;GAEhB,SACM;IACJ;IACA,eAAe,MAAM,KAAK,0DAA0D;GACtF,CACF;EACF,CAAC;CACH,CAAC;AACH;AAEA,SAAS,gBAAgB,KAA8B;CACrD,IAAI;EACF,OAAO,IAAI,IAAI,GAAG;CACpB,QAAQ;EACN,eAAe,MAAM,KAAK,oCAAoC,KAAK;EACnE;CACF;AACF"}
@@ -1,9 +1,13 @@
1
- import { trace } from '@opentelemetry/api';
2
- import { SentryTracerProvider } from '@sentry/opentelemetry';
3
-
1
+ import { trace } from "@opentelemetry/api";
2
+ import { SentryTracerProvider } from "@sentry/opentelemetry";
3
+ // src/opentelemetry/tracer.ts
4
+ /**
5
+ * Set up a mock OTEL tracer to allow inter-op with OpenTelemetry emitted spans.
6
+ * This is not perfect but handles easy/common use cases.
7
+ */
4
8
  function setupOpenTelemetryTracer() {
5
- trace.setGlobalTracerProvider(new SentryTracerProvider());
9
+ trace.setGlobalTracerProvider(new SentryTracerProvider());
6
10
  }
7
-
8
11
  export { setupOpenTelemetryTracer };
9
- //# sourceMappingURL=tracer.js.map
12
+
13
+ //# sourceMappingURL=tracer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tracer.js","sources":["../../../../src/opentelemetry/tracer.ts"],"sourcesContent":["import { trace } from '@opentelemetry/api';\nimport { SentryTracerProvider } from '@sentry/opentelemetry';\n\n/**\n * Set up a mock OTEL tracer to allow inter-op with OpenTelemetry emitted spans.\n * This is not perfect but handles easy/common use cases.\n */\nexport function setupOpenTelemetryTracer(): void {\n trace.setGlobalTracerProvider(new SentryTracerProvider());\n}\n"],"names":[],"mappings":";;;AAOO,SAAS,wBAAA,GAAiC;AAC/C,EAAA,KAAA,CAAM,uBAAA,CAAwB,IAAI,oBAAA,EAAsB,CAAA;AAC1D;;;;"}
1
+ {"version":3,"file":"tracer.js","names":[],"sources":["../../../../src/opentelemetry/tracer.ts"],"sourcesContent":["import { trace } from '@opentelemetry/api';\nimport { SentryTracerProvider } from '@sentry/opentelemetry';\n\n/**\n * Set up a mock OTEL tracer to allow inter-op with OpenTelemetry emitted spans.\n * This is not perfect but handles easy/common use cases.\n */\nexport function setupOpenTelemetryTracer(): void {\n trace.setGlobalTracerProvider(new SentryTracerProvider());\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,2BAAiC;CAC/C,MAAM,wBAAwB,IAAI,qBAAqB,CAAC;AAC1D"}
@@ -1,48 +1,66 @@
1
- import { isObjectLike, envToBool } from '@sentry/core';
2
-
1
+ import { envToBool, isObjectLike } from "@sentry/core";
2
+ // src/options.ts
3
+ /**
4
+ * Checks if the value is a valid CF_VERSION_METADATA binding.
5
+ */
3
6
  function isVersionMetadata(value) {
4
- return isObjectLike(value) && "id" in value && typeof value.id === "string";
7
+ return isObjectLike(value) && "id" in value && typeof value.id === "string";
5
8
  }
6
9
  function getEnvVar(env, varName) {
7
- return isObjectLike(env) && varName in env && typeof env[varName] === "string" ? env[varName] : void 0;
10
+ return isObjectLike(env) && varName in env && typeof env[varName] === "string" ? env[varName] : void 0;
8
11
  }
12
+ /**
13
+ * Merges the options passed in from the user with the options we read from
14
+ * the Cloudflare `env` environment variable object.
15
+ *
16
+ * Release is determined with the following priority (highest to lowest):
17
+ * 1. User-provided release option
18
+ * 2. SENTRY_RELEASE environment variable
19
+ * 3. CF_VERSION_METADATA.id binding (if configured in the wrangler config)
20
+ *
21
+ * @param userOptions - The options passed in from the user.
22
+ * @param env - The environment variables.
23
+ *
24
+ * @returns The final options.
25
+ */
9
26
  function getFinalOptions(userOptions = {}, env) {
10
- if (!isObjectLike(env)) {
11
- return userOptions;
12
- }
13
- const release = "SENTRY_RELEASE" in env && typeof env.SENTRY_RELEASE === "string" ? env.SENTRY_RELEASE : "CF_VERSION_METADATA" in env && isVersionMetadata(env.CF_VERSION_METADATA) ? env.CF_VERSION_METADATA.id : void 0;
14
- const tracesSampleRate = userOptions.tracesSampleRate ?? parseFloat(getEnvVar(env, "SENTRY_TRACES_SAMPLE_RATE") ?? "");
15
- /*! rollup-include-development-only */
16
- const spotlight = getSpotlightFromEnv(userOptions.spotlight, getEnvVar(env, "SENTRY_SPOTLIGHT"));
17
- /*! rollup-include-development-only-end */
18
- return {
19
- release,
20
- ...userOptions,
21
- dsn: userOptions.dsn ?? getEnvVar(env, "SENTRY_DSN"),
22
- environment: userOptions.environment ?? getEnvVar(env, "SENTRY_ENVIRONMENT"),
23
- tracesSampleRate: isFinite(tracesSampleRate) ? tracesSampleRate : void 0,
24
- debug: userOptions.debug ?? envToBool(getEnvVar(env, "SENTRY_DEBUG")),
25
- tunnel: userOptions.tunnel ?? getEnvVar(env, "SENTRY_TUNNEL"),
26
- traceLifecycle: userOptions.traceLifecycle ?? getTraceLifecycleFromEnv(getEnvVar(env, "SENTRY_TRACE_LIFECYCLE")),
27
- /*! rollup-include-development-only */
28
- spotlight
29
- /*! rollup-include-development-only-end */
30
- };
27
+ if (!isObjectLike(env)) return userOptions;
28
+ const release = "SENTRY_RELEASE" in env && typeof env.SENTRY_RELEASE === "string" ? env.SENTRY_RELEASE : "CF_VERSION_METADATA" in env && isVersionMetadata(env.CF_VERSION_METADATA) ? env.CF_VERSION_METADATA.id : void 0;
29
+ const tracesSampleRate = userOptions.tracesSampleRate ?? parseFloat(getEnvVar(env, "SENTRY_TRACES_SAMPLE_RATE") ?? "");
30
+ /*! rollup-include-development-only */
31
+ const spotlight = getSpotlightFromEnv(userOptions.spotlight, getEnvVar(env, "SENTRY_SPOTLIGHT"));
32
+ /*! rollup-include-development-only-end */
33
+ return {
34
+ release,
35
+ ...userOptions,
36
+ dsn: userOptions.dsn ?? getEnvVar(env, "SENTRY_DSN"),
37
+ environment: userOptions.environment ?? getEnvVar(env, "SENTRY_ENVIRONMENT"),
38
+ tracesSampleRate: isFinite(tracesSampleRate) ? tracesSampleRate : void 0,
39
+ debug: userOptions.debug ?? envToBool(getEnvVar(env, "SENTRY_DEBUG")),
40
+ tunnel: userOptions.tunnel ?? getEnvVar(env, "SENTRY_TUNNEL"),
41
+ traceLifecycle: userOptions.traceLifecycle ?? getTraceLifecycleFromEnv(getEnvVar(env, "SENTRY_TRACE_LIFECYCLE")),
42
+ /*! rollup-include-development-only */
43
+ spotlight
44
+ };
45
+ /*! rollup-include-development-only-end */
31
46
  }
47
+ /**
48
+ * Resolve the spotlight option from a user-supplied value and an env binding string.
49
+ * Mirrors node-core's `getSpotlightConfig` precedence:
50
+ * - `false` or explicit string from options → use as-is
51
+ * - `true` → enable, but prefer a custom URL from the env var if set
52
+ * - `undefined` → defer entirely to the env var (bool or URL)
53
+ */
32
54
  function getSpotlightFromEnv(optionsSpotlight, envVar) {
33
- if (optionsSpotlight === false) {
34
- return false;
35
- }
36
- if (typeof optionsSpotlight === "string") {
37
- return optionsSpotlight;
38
- }
39
- const envBool = envToBool(envVar, { strict: true });
40
- const envUrl = envBool === null && envVar ? envVar : void 0;
41
- return optionsSpotlight === true ? envUrl ?? true : envBool ?? envUrl;
55
+ if (optionsSpotlight === false) return false;
56
+ if (typeof optionsSpotlight === "string") return optionsSpotlight;
57
+ const envBool = envToBool(envVar, { strict: true });
58
+ const envUrl = envBool === null && envVar ? envVar : void 0;
59
+ return optionsSpotlight === true ? envUrl ?? true : envBool ?? envUrl;
42
60
  }
43
61
  function getTraceLifecycleFromEnv(envVar) {
44
- return envVar === "stream" || envVar === "static" ? envVar : void 0;
62
+ return envVar === "stream" || envVar === "static" ? envVar : void 0;
45
63
  }
46
-
47
64
  export { getFinalOptions };
48
- //# sourceMappingURL=options.js.map
65
+
66
+ //# sourceMappingURL=options.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sources":["../../../src/options.ts"],"sourcesContent":["import { isObjectLike, envToBool } from '@sentry/core';\nimport type { CloudflareOptions } from './client';\n\n/**\n * Cloudflare's version metadata binding structure.\n * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/version-metadata/\n */\ninterface CfVersionMetadata {\n id: string;\n tag?: string;\n timestamp?: string;\n}\n\n/**\n * Checks if the value is a valid CF_VERSION_METADATA binding.\n */\nfunction isVersionMetadata(value: unknown): value is CfVersionMetadata {\n return isObjectLike(value) && 'id' in value && typeof value.id === 'string';\n}\n\nfunction getEnvVar<T extends Record<string, unknown>>(env: unknown, varName: keyof T): string | undefined {\n return isObjectLike(env) && varName in env && typeof (env as T)[varName] === 'string'\n ? ((env as T)[varName] as string)\n : undefined;\n}\n\n/**\n * Merges the options passed in from the user with the options we read from\n * the Cloudflare `env` environment variable object.\n *\n * Release is determined with the following priority (highest to lowest):\n * 1. User-provided release option\n * 2. SENTRY_RELEASE environment variable\n * 3. CF_VERSION_METADATA.id binding (if configured in the wrangler config)\n *\n * @param userOptions - The options passed in from the user.\n * @param env - The environment variables.\n *\n * @returns The final options.\n */\nexport function getFinalOptions(userOptions: CloudflareOptions = {}, env: unknown): CloudflareOptions {\n if (!isObjectLike(env)) {\n return userOptions;\n }\n\n // Priority: userOptions.release > SENTRY_RELEASE > CF_VERSION_METADATA.id\n const release =\n 'SENTRY_RELEASE' in env && typeof env.SENTRY_RELEASE === 'string'\n ? env.SENTRY_RELEASE\n : 'CF_VERSION_METADATA' in env && isVersionMetadata(env.CF_VERSION_METADATA)\n ? env.CF_VERSION_METADATA.id\n : undefined;\n\n const tracesSampleRate =\n userOptions.tracesSampleRate ?? parseFloat(getEnvVar(env, 'SENTRY_TRACES_SAMPLE_RATE') ?? '');\n\n // Spotlight precedence (mirrors node-core's getSpotlightConfig):\n // - false or explicit string from options: use as-is\n // - true: enable, but prefer a custom URL from the env var if set\n // - undefined: defer entirely to the env var (bool or URL)\n /*! rollup-include-development-only */\n const spotlight = getSpotlightFromEnv(userOptions.spotlight, getEnvVar(env, 'SENTRY_SPOTLIGHT'));\n /*! rollup-include-development-only-end */\n\n return {\n release,\n ...userOptions,\n dsn: userOptions.dsn ?? getEnvVar(env, 'SENTRY_DSN'),\n environment: userOptions.environment ?? getEnvVar(env, 'SENTRY_ENVIRONMENT'),\n tracesSampleRate: isFinite(tracesSampleRate) ? tracesSampleRate : undefined,\n debug: userOptions.debug ?? envToBool(getEnvVar(env, 'SENTRY_DEBUG')),\n tunnel: userOptions.tunnel ?? getEnvVar(env, 'SENTRY_TUNNEL'),\n traceLifecycle: userOptions.traceLifecycle ?? getTraceLifecycleFromEnv(getEnvVar(env, 'SENTRY_TRACE_LIFECYCLE')),\n /*! rollup-include-development-only */\n spotlight,\n /*! rollup-include-development-only-end */\n };\n}\n\n/**\n * Resolve the spotlight option from a user-supplied value and an env binding string.\n * Mirrors node-core's `getSpotlightConfig` precedence:\n * - `false` or explicit string from options → use as-is\n * - `true` → enable, but prefer a custom URL from the env var if set\n * - `undefined` → defer entirely to the env var (bool or URL)\n */\nfunction getSpotlightFromEnv(\n optionsSpotlight: boolean | string | undefined,\n envVar: string | undefined,\n): boolean | string | undefined {\n if (optionsSpotlight === false) {\n return false;\n }\n if (typeof optionsSpotlight === 'string') {\n return optionsSpotlight;\n }\n\n // optionsSpotlight is true or undefined\n const envBool = envToBool(envVar, { strict: true });\n const envUrl = envBool === null && envVar ? envVar : undefined;\n\n return optionsSpotlight === true\n ? (envUrl ?? true) // true: use env URL if present, otherwise true\n : (envBool ?? envUrl); // undefined: use env var (bool or URL)\n}\n\nfunction getTraceLifecycleFromEnv(envVar: string | undefined): 'static' | 'stream' | undefined {\n return envVar === 'stream' || envVar === 'static' ? envVar : undefined;\n}\n"],"names":[],"mappings":";;AAgBA,SAAS,kBAAkB,KAAA,EAA4C;AACrE,EAAA,OAAO,aAAa,KAAK,CAAA,IAAK,QAAQ,KAAA,IAAS,OAAO,MAAM,EAAA,KAAO,QAAA;AACrE;AAEA,SAAS,SAAA,CAA6C,KAAc,OAAA,EAAsC;AACxG,EAAA,OAAO,YAAA,CAAa,GAAG,CAAA,IAAK,OAAA,IAAW,GAAA,IAAO,OAAQ,GAAA,CAAU,OAAO,CAAA,KAAM,QAAA,GACvE,GAAA,CAAU,OAAO,CAAA,GACnB,MAAA;AACN;AAgBO,SAAS,eAAA,CAAgB,WAAA,GAAiC,EAAC,EAAG,GAAA,EAAiC;AACpG,EAAA,IAAI,CAAC,YAAA,CAAa,GAAG,CAAA,EAAG;AACtB,IAAA,OAAO,WAAA;AAAA,EACT;AAGA,EAAA,MAAM,UACJ,gBAAA,IAAoB,GAAA,IAAO,OAAO,GAAA,CAAI,mBAAmB,QAAA,GACrD,GAAA,CAAI,cAAA,GACJ,qBAAA,IAAyB,OAAO,iBAAA,CAAkB,GAAA,CAAI,mBAAmB,CAAA,GACvE,GAAA,CAAI,oBAAoB,EAAA,GACxB,MAAA;AAER,EAAA,MAAM,gBAAA,GACJ,YAAY,gBAAA,IAAoB,UAAA,CAAW,UAAU,GAAA,EAAK,2BAA2B,KAAK,EAAE,CAAA;AAAA;AAO9F,EAAA,MAAM,YAAY,mBAAA,CAAoB,WAAA,CAAY,WAAW,SAAA,CAAU,GAAA,EAAK,kBAAkB,CAAC,CAAA;AAAA;AAG/F,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IACA,GAAG,WAAA;AAAA,IACH,GAAA,EAAK,WAAA,CAAY,GAAA,IAAO,SAAA,CAAU,KAAK,YAAY,CAAA;AAAA,IACnD,WAAA,EAAa,WAAA,CAAY,WAAA,IAAe,SAAA,CAAU,KAAK,oBAAoB,CAAA;AAAA,IAC3E,gBAAA,EAAkB,QAAA,CAAS,gBAAgB,CAAA,GAAI,gBAAA,GAAmB,MAAA;AAAA,IAClE,OAAO,WAAA,CAAY,KAAA,IAAS,UAAU,SAAA,CAAU,GAAA,EAAK,cAAc,CAAC,CAAA;AAAA,IACpE,MAAA,EAAQ,WAAA,CAAY,MAAA,IAAU,SAAA,CAAU,KAAK,eAAe,CAAA;AAAA,IAC5D,gBAAgB,WAAA,CAAY,cAAA,IAAkB,yBAAyB,SAAA,CAAU,GAAA,EAAK,wBAAwB,CAAC,CAAA;AAAA;AAAA,IAE/G;AAAA;AAAA,GAEF;AACF;AASA,SAAS,mBAAA,CACP,kBACA,MAAA,EAC8B;AAC9B,EAAA,IAAI,qBAAqB,KAAA,EAAO;AAC9B,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IAAI,OAAO,qBAAqB,QAAA,EAAU;AACxC,IAAA,OAAO,gBAAA;AAAA,EACT;AAGA,EAAA,MAAM,UAAU,SAAA,CAAU,MAAA,EAAQ,EAAE,MAAA,EAAQ,MAAM,CAAA;AAClD,EAAA,MAAM,MAAA,GAAS,OAAA,KAAY,IAAA,IAAQ,MAAA,GAAS,MAAA,GAAS,MAAA;AAErD,EAAA,OAAO,gBAAA,KAAqB,IAAA,GACvB,MAAA,IAAU,IAAA,GACV,OAAA,IAAW,MAAA;AAClB;AAEA,SAAS,yBAAyB,MAAA,EAA6D;AAC7F,EAAA,OAAO,MAAA,KAAW,QAAA,IAAY,MAAA,KAAW,QAAA,GAAW,MAAA,GAAS,MAAA;AAC/D;;;;"}
1
+ {"version":3,"file":"options.js","names":[],"sources":["../../../src/options.ts"],"sourcesContent":["import { isObjectLike, envToBool } from '@sentry/core';\nimport type { CloudflareOptions } from './client';\n\n/**\n * Cloudflare's version metadata binding structure.\n * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/version-metadata/\n */\ninterface CfVersionMetadata {\n id: string;\n tag?: string;\n timestamp?: string;\n}\n\n/**\n * Checks if the value is a valid CF_VERSION_METADATA binding.\n */\nfunction isVersionMetadata(value: unknown): value is CfVersionMetadata {\n return isObjectLike(value) && 'id' in value && typeof value.id === 'string';\n}\n\nfunction getEnvVar<T extends Record<string, unknown>>(env: unknown, varName: keyof T): string | undefined {\n return isObjectLike(env) && varName in env && typeof (env as T)[varName] === 'string'\n ? ((env as T)[varName] as string)\n : undefined;\n}\n\n/**\n * Merges the options passed in from the user with the options we read from\n * the Cloudflare `env` environment variable object.\n *\n * Release is determined with the following priority (highest to lowest):\n * 1. User-provided release option\n * 2. SENTRY_RELEASE environment variable\n * 3. CF_VERSION_METADATA.id binding (if configured in the wrangler config)\n *\n * @param userOptions - The options passed in from the user.\n * @param env - The environment variables.\n *\n * @returns The final options.\n */\nexport function getFinalOptions(userOptions: CloudflareOptions = {}, env: unknown): CloudflareOptions {\n if (!isObjectLike(env)) {\n return userOptions;\n }\n\n // Priority: userOptions.release > SENTRY_RELEASE > CF_VERSION_METADATA.id\n const release =\n 'SENTRY_RELEASE' in env && typeof env.SENTRY_RELEASE === 'string'\n ? env.SENTRY_RELEASE\n : 'CF_VERSION_METADATA' in env && isVersionMetadata(env.CF_VERSION_METADATA)\n ? env.CF_VERSION_METADATA.id\n : undefined;\n\n const tracesSampleRate =\n userOptions.tracesSampleRate ?? parseFloat(getEnvVar(env, 'SENTRY_TRACES_SAMPLE_RATE') ?? '');\n\n // Spotlight precedence (mirrors node-core's getSpotlightConfig):\n // - false or explicit string from options: use as-is\n // - true: enable, but prefer a custom URL from the env var if set\n // - undefined: defer entirely to the env var (bool or URL)\n /*! rollup-include-development-only */\n const spotlight = getSpotlightFromEnv(userOptions.spotlight, getEnvVar(env, 'SENTRY_SPOTLIGHT'));\n /*! rollup-include-development-only-end */\n\n return {\n release,\n ...userOptions,\n dsn: userOptions.dsn ?? getEnvVar(env, 'SENTRY_DSN'),\n environment: userOptions.environment ?? getEnvVar(env, 'SENTRY_ENVIRONMENT'),\n tracesSampleRate: isFinite(tracesSampleRate) ? tracesSampleRate : undefined,\n debug: userOptions.debug ?? envToBool(getEnvVar(env, 'SENTRY_DEBUG')),\n tunnel: userOptions.tunnel ?? getEnvVar(env, 'SENTRY_TUNNEL'),\n traceLifecycle: userOptions.traceLifecycle ?? getTraceLifecycleFromEnv(getEnvVar(env, 'SENTRY_TRACE_LIFECYCLE')),\n /*! rollup-include-development-only */\n spotlight,\n /*! rollup-include-development-only-end */\n };\n}\n\n/**\n * Resolve the spotlight option from a user-supplied value and an env binding string.\n * Mirrors node-core's `getSpotlightConfig` precedence:\n * - `false` or explicit string from options → use as-is\n * - `true` → enable, but prefer a custom URL from the env var if set\n * - `undefined` → defer entirely to the env var (bool or URL)\n */\nfunction getSpotlightFromEnv(\n optionsSpotlight: boolean | string | undefined,\n envVar: string | undefined,\n): boolean | string | undefined {\n if (optionsSpotlight === false) {\n return false;\n }\n if (typeof optionsSpotlight === 'string') {\n return optionsSpotlight;\n }\n\n // optionsSpotlight is true or undefined\n const envBool = envToBool(envVar, { strict: true });\n const envUrl = envBool === null && envVar ? envVar : undefined;\n\n return optionsSpotlight === true\n ? (envUrl ?? true) // true: use env URL if present, otherwise true\n : (envBool ?? envUrl); // undefined: use env var (bool or URL)\n}\n\nfunction getTraceLifecycleFromEnv(envVar: string | undefined): 'static' | 'stream' | undefined {\n return envVar === 'stream' || envVar === 'static' ? envVar : undefined;\n}\n"],"mappings":";;;;;AAgBA,SAAS,kBAAkB,OAA4C;CACrE,OAAO,aAAa,KAAK,KAAK,QAAQ,SAAS,OAAO,MAAM,OAAO;AACrE;AAEA,SAAS,UAA6C,KAAc,SAAsC;CACxG,OAAO,aAAa,GAAG,KAAK,WAAW,OAAO,OAAQ,IAAU,aAAa,WACvE,IAAU,WACZ,KAAA;AACN;;;;;;;;;;;;;;;AAgBA,SAAgB,gBAAgB,cAAiC,CAAC,GAAG,KAAiC;CACpG,IAAI,CAAC,aAAa,GAAG,GACnB,OAAO;CAIT,MAAM,UACJ,oBAAoB,OAAO,OAAO,IAAI,mBAAmB,WACrD,IAAI,iBACJ,yBAAyB,OAAO,kBAAkB,IAAI,mBAAmB,IACvE,IAAI,oBAAoB,KACxB,KAAA;CAER,MAAM,mBACJ,YAAY,oBAAoB,WAAW,UAAU,KAAK,2BAA2B,KAAK,EAAE;;CAO9F,MAAM,YAAY,oBAAoB,YAAY,WAAW,UAAU,KAAK,kBAAkB,CAAC;;CAG/F,OAAO;EACL;EACA,GAAG;EACH,KAAK,YAAY,OAAO,UAAU,KAAK,YAAY;EACnD,aAAa,YAAY,eAAe,UAAU,KAAK,oBAAoB;EAC3E,kBAAkB,SAAS,gBAAgB,IAAI,mBAAmB,KAAA;EAClE,OAAO,YAAY,SAAS,UAAU,UAAU,KAAK,cAAc,CAAC;EACpE,QAAQ,YAAY,UAAU,UAAU,KAAK,eAAe;EAC5D,gBAAgB,YAAY,kBAAkB,yBAAyB,UAAU,KAAK,wBAAwB,CAAC;;EAE/G;CAEF;;AACF;;;;;;;;AASA,SAAS,oBACP,kBACA,QAC8B;CAC9B,IAAI,qBAAqB,OACvB,OAAO;CAET,IAAI,OAAO,qBAAqB,UAC9B,OAAO;CAIT,MAAM,UAAU,UAAU,QAAQ,EAAE,QAAQ,KAAK,CAAC;CAClD,MAAM,SAAS,YAAY,QAAQ,SAAS,SAAS,KAAA;CAErD,OAAO,qBAAqB,OACvB,UAAU,OACV,WAAW;AAClB;AAEA,SAAS,yBAAyB,QAA6D;CAC7F,OAAO,WAAW,YAAY,WAAW,WAAW,SAAS,KAAA;AAC/D"}
@@ -1,35 +1,53 @@
1
- import { debug } from '@sentry/core';
2
- import { DEBUG_BUILD } from './debug-build.js';
3
-
1
+ import { DEBUG_BUILD } from "./debug-build.js";
2
+ import { debug } from "@sentry/core";
3
+ // src/orchestrion-deferred-channels.ts
4
+ /**
5
+ * Deferral for orchestrion channel events that could not be published when they occurred.
6
+ *
7
+ * On workerd, `channel.publish()`/`runStores()` throw at module/global scope, so a library
8
+ * instantiated at module scope (`const app = new Hono()`) cannot emit its wrapping event
9
+ * there. {@link ./orchestrion-diagnostics-channel} defers those events here;
10
+ * {@link flushDeferredChannelEvents} emits them once a request is being handled (where
11
+ * publish works) and the SDK's `init()` has registered subscribers.
12
+ *
13
+ * This module imports NO `node:*` builtin, so it is safe to pull into the request wrapper on
14
+ * runtimes without `nodejs_compat` — there the queue is always empty (no channels were ever
15
+ * injected) and the flush is a no-op.
16
+ */
4
17
  const deferred = [];
5
- const DEFERRED = /* @__PURE__ */ Symbol("sentryOrchestrionDeferred");
18
+ const DEFERRED = Symbol("sentryOrchestrionDeferred");
19
+ /** workerd's global-scope guard is the only error we degrade on; anything else is a real fault. */
6
20
  function isGlobalScopeError(error) {
7
- return error instanceof Error && /within global scope/.test(error.message);
21
+ return error instanceof Error && /within global scope/.test(error.message);
8
22
  }
23
+ /** Queue a channel event that could not be published now, at most once per context object. */
9
24
  function deferChannelEvent(channel, ctx) {
10
- if (ctx[DEFERRED]) {
11
- return;
12
- }
13
- ctx[DEFERRED] = true;
14
- deferred.push({ channel, ctx, hadError: "error" in ctx });
25
+ if (ctx[DEFERRED]) return;
26
+ ctx[DEFERRED] = true;
27
+ deferred.push({
28
+ channel,
29
+ ctx,
30
+ hadError: "error" in ctx
31
+ });
15
32
  }
33
+ /**
34
+ * Emit every deferred channel event via the real channel. Called at the top of the request
35
+ * handler, after `init()` has subscribed. Uses bare `start`/`end` publish (never `runStores`),
36
+ * so no `bindStore` producer runs and no span is parented to this request — only the plain
37
+ * subscribers (the instance patchers) fire. Idempotent: it drains the queue, so later requests
38
+ * and re-entrant calls are no-ops.
39
+ */
16
40
  function flushDeferredChannelEvents() {
17
- if (deferred.length === 0) {
18
- return;
19
- }
20
- const pending = deferred.splice(0, deferred.length);
21
- for (const { channel, ctx, hadError } of pending) {
22
- try {
23
- channel.start.publish(ctx);
24
- if (hadError) {
25
- channel.error.publish(ctx);
26
- }
27
- channel.end.publish(ctx);
28
- } catch (error) {
29
- DEBUG_BUILD && debug.warn("[orchestrion] failed to emit a deferred channel event", error);
30
- }
31
- }
41
+ if (deferred.length === 0) return;
42
+ const pending = deferred.splice(0, deferred.length);
43
+ for (const { channel, ctx, hadError } of pending) try {
44
+ channel.start.publish(ctx);
45
+ if (hadError) channel.error.publish(ctx);
46
+ channel.end.publish(ctx);
47
+ } catch (error) {
48
+ DEBUG_BUILD && debug.warn("[orchestrion] failed to emit a deferred channel event", error);
49
+ }
32
50
  }
33
-
34
51
  export { deferChannelEvent, flushDeferredChannelEvents, isGlobalScopeError };
35
- //# sourceMappingURL=orchestrion-deferred-channels.js.map
52
+
53
+ //# sourceMappingURL=orchestrion-deferred-channels.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrion-deferred-channels.js","sources":["../../../src/orchestrion-deferred-channels.ts"],"sourcesContent":["/**\n * Deferral for orchestrion channel events that could not be published when they occurred.\n *\n * On workerd, `channel.publish()`/`runStores()` throw at module/global scope, so a library\n * instantiated at module scope (`const app = new Hono()`) cannot emit its wrapping event\n * there. {@link ./orchestrion-diagnostics-channel} defers those events here;\n * {@link flushDeferredChannelEvents} emits them once a request is being handled (where\n * publish works) and the SDK's `init()` has registered subscribers.\n *\n * This module imports NO `node:*` builtin, so it is safe to pull into the request wrapper on\n * runtimes without `nodejs_compat` — there the queue is always empty (no channels were ever\n * injected) and the flush is a no-op.\n */\nimport { debug } from '@sentry/core';\nimport { DEBUG_BUILD } from './debug-build';\n\ntype Ctx = Record<string, unknown>;\n\n// The minimal slice of a `node:diagnostics_channel` TracingChannel we emit on. Declared locally\n// (rather than imported from `node:diagnostics_channel`) so this module's graph carries no `node:`\n// specifier — `wrapRequestHandler` must load on runtimes without `nodejs_compat`, and the\n// module-graph test forbids any `node:` import reachable from it.\ninterface PublishableTracingChannel {\n start: { publish(ctx: Ctx): void };\n end: { publish(ctx: Ctx): void };\n error: { publish(ctx: Ctx): void };\n}\n\ninterface DeferredChannelEvent {\n channel: PublishableTracingChannel;\n ctx: Ctx;\n hadError: boolean;\n}\n\nconst deferred: DeferredChannelEvent[] = [];\nconst DEFERRED = Symbol('sentryOrchestrionDeferred');\n\n/** workerd's global-scope guard is the only error we degrade on; anything else is a real fault. */\nexport function isGlobalScopeError(error: unknown): boolean {\n return error instanceof Error && /within global scope/.test(error.message);\n}\n\n/** Queue a channel event that could not be published now, at most once per context object. */\nexport function deferChannelEvent(channel: PublishableTracingChannel, ctx: Ctx): void {\n if ((ctx as Record<symbol, unknown>)[DEFERRED]) {\n return;\n }\n (ctx as Record<symbol, unknown>)[DEFERRED] = true;\n deferred.push({ channel, ctx, hadError: 'error' in ctx });\n}\n\n/**\n * Emit every deferred channel event via the real channel. Called at the top of the request\n * handler, after `init()` has subscribed. Uses bare `start`/`end` publish (never `runStores`),\n * so no `bindStore` producer runs and no span is parented to this request — only the plain\n * subscribers (the instance patchers) fire. Idempotent: it drains the queue, so later requests\n * and re-entrant calls are no-ops.\n */\nexport function flushDeferredChannelEvents(): void {\n if (deferred.length === 0) {\n return;\n }\n const pending = deferred.splice(0, deferred.length);\n for (const { channel, ctx, hadError } of pending) {\n try {\n channel.start.publish(ctx);\n if (hadError) {\n channel.error.publish(ctx);\n }\n channel.end.publish(ctx);\n } catch (error) {\n DEBUG_BUILD && debug.warn('[orchestrion] failed to emit a deferred channel event', error);\n }\n }\n}\n"],"names":[],"mappings":";;;AAkCA,MAAM,WAAmC,EAAC;AAC1C,MAAM,QAAA,0BAAkB,2BAA2B,CAAA;AAG5C,SAAS,mBAAmB,KAAA,EAAyB;AAC1D,EAAA,OAAO,KAAA,YAAiB,KAAA,IAAS,qBAAA,CAAsB,IAAA,CAAK,MAAM,OAAO,CAAA;AAC3E;AAGO,SAAS,iBAAA,CAAkB,SAAoC,GAAA,EAAgB;AACpF,EAAA,IAAK,GAAA,CAAgC,QAAQ,CAAA,EAAG;AAC9C,IAAA;AAAA,EACF;AACA,EAAC,GAAA,CAAgC,QAAQ,CAAA,GAAI,IAAA;AAC7C,EAAA,QAAA,CAAS,KAAK,EAAE,OAAA,EAAS,KAAK,QAAA,EAAU,OAAA,IAAW,KAAK,CAAA;AAC1D;AASO,SAAS,0BAAA,GAAmC;AACjD,EAAA,IAAI,QAAA,CAAS,WAAW,CAAA,EAAG;AACzB,IAAA;AAAA,EACF;AACA,EAAA,MAAM,OAAA,GAAU,QAAA,CAAS,MAAA,CAAO,CAAA,EAAG,SAAS,MAAM,CAAA;AAClD,EAAA,KAAA,MAAW,EAAE,OAAA,EAAS,GAAA,EAAK,QAAA,MAAc,OAAA,EAAS;AAChD,IAAA,IAAI;AACF,MAAA,OAAA,CAAQ,KAAA,CAAM,QAAQ,GAAG,CAAA;AACzB,MAAA,IAAI,QAAA,EAAU;AACZ,QAAA,OAAA,CAAQ,KAAA,CAAM,QAAQ,GAAG,CAAA;AAAA,MAC3B;AACA,MAAA,OAAA,CAAQ,GAAA,CAAI,QAAQ,GAAG,CAAA;AAAA,IACzB,SAAS,KAAA,EAAO;AACd,MAAA,WAAA,IAAe,KAAA,CAAM,IAAA,CAAK,uDAAA,EAAyD,KAAK,CAAA;AAAA,IAC1F;AAAA,EACF;AACF;;;;"}
1
+ {"version":3,"file":"orchestrion-deferred-channels.js","names":[],"sources":["../../../src/orchestrion-deferred-channels.ts"],"sourcesContent":["/**\n * Deferral for orchestrion channel events that could not be published when they occurred.\n *\n * On workerd, `channel.publish()`/`runStores()` throw at module/global scope, so a library\n * instantiated at module scope (`const app = new Hono()`) cannot emit its wrapping event\n * there. {@link ./orchestrion-diagnostics-channel} defers those events here;\n * {@link flushDeferredChannelEvents} emits them once a request is being handled (where\n * publish works) and the SDK's `init()` has registered subscribers.\n *\n * This module imports NO `node:*` builtin, so it is safe to pull into the request wrapper on\n * runtimes without `nodejs_compat` — there the queue is always empty (no channels were ever\n * injected) and the flush is a no-op.\n */\nimport { debug } from '@sentry/core';\nimport { DEBUG_BUILD } from './debug-build';\n\ntype Ctx = Record<string, unknown>;\n\n// The minimal slice of a `node:diagnostics_channel` TracingChannel we emit on. Declared locally\n// (rather than imported from `node:diagnostics_channel`) so this module's graph carries no `node:`\n// specifier — `wrapRequestHandler` must load on runtimes without `nodejs_compat`, and the\n// module-graph test forbids any `node:` import reachable from it.\ninterface PublishableTracingChannel {\n start: { publish(ctx: Ctx): void };\n end: { publish(ctx: Ctx): void };\n error: { publish(ctx: Ctx): void };\n}\n\ninterface DeferredChannelEvent {\n channel: PublishableTracingChannel;\n ctx: Ctx;\n hadError: boolean;\n}\n\nconst deferred: DeferredChannelEvent[] = [];\nconst DEFERRED = Symbol('sentryOrchestrionDeferred');\n\n/** workerd's global-scope guard is the only error we degrade on; anything else is a real fault. */\nexport function isGlobalScopeError(error: unknown): boolean {\n return error instanceof Error && /within global scope/.test(error.message);\n}\n\n/** Queue a channel event that could not be published now, at most once per context object. */\nexport function deferChannelEvent(channel: PublishableTracingChannel, ctx: Ctx): void {\n if ((ctx as Record<symbol, unknown>)[DEFERRED]) {\n return;\n }\n (ctx as Record<symbol, unknown>)[DEFERRED] = true;\n deferred.push({ channel, ctx, hadError: 'error' in ctx });\n}\n\n/**\n * Emit every deferred channel event via the real channel. Called at the top of the request\n * handler, after `init()` has subscribed. Uses bare `start`/`end` publish (never `runStores`),\n * so no `bindStore` producer runs and no span is parented to this request — only the plain\n * subscribers (the instance patchers) fire. Idempotent: it drains the queue, so later requests\n * and re-entrant calls are no-ops.\n */\nexport function flushDeferredChannelEvents(): void {\n if (deferred.length === 0) {\n return;\n }\n const pending = deferred.splice(0, deferred.length);\n for (const { channel, ctx, hadError } of pending) {\n try {\n channel.start.publish(ctx);\n if (hadError) {\n channel.error.publish(ctx);\n }\n channel.end.publish(ctx);\n } catch (error) {\n DEBUG_BUILD && debug.warn('[orchestrion] failed to emit a deferred channel event', error);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,MAAM,WAAmC,CAAC;AAC1C,MAAM,WAAW,OAAO,2BAA2B;;AAGnD,SAAgB,mBAAmB,OAAyB;CAC1D,OAAO,iBAAiB,SAAS,sBAAsB,KAAK,MAAM,OAAO;AAC3E;;AAGA,SAAgB,kBAAkB,SAAoC,KAAgB;CACpF,IAAK,IAAgC,WACnC;CAED,IAAgC,YAAY;CAC7C,SAAS,KAAK;EAAE;EAAS;EAAK,UAAU,WAAW;CAAI,CAAC;AAC1D;;;;;;;;AASA,SAAgB,6BAAmC;CACjD,IAAI,SAAS,WAAW,GACtB;CAEF,MAAM,UAAU,SAAS,OAAO,GAAG,SAAS,MAAM;CAClD,KAAK,MAAM,EAAE,SAAS,KAAK,cAAc,SACvC,IAAI;EACF,QAAQ,MAAM,QAAQ,GAAG;EACzB,IAAI,UACF,QAAQ,MAAM,QAAQ,GAAG;EAE3B,QAAQ,IAAI,QAAQ,GAAG;CACzB,SAAS,OAAO;EACd,eAAe,MAAM,KAAK,yDAAyD,KAAK;CAC1F;AAEJ"}
@@ -1,77 +1,98 @@
1
- import * as realDc from 'node:diagnostics_channel';
2
- import { isGlobalScopeError, deferChannelEvent } from './orchestrion-deferred-channels.js';
3
-
1
+ import { deferChannelEvent, isGlobalScopeError } from "./orchestrion-deferred-channels.js";
2
+ import * as realDc from "node:diagnostics_channel";
3
+ // src/orchestrion-diagnostics-channel.ts
4
+ /**
5
+ * A workerd-safe `diagnostics_channel` façade for the orchestrion EMIT side, and the
6
+ * `dcModule` target for the Cloudflare orchestrion build (see `vite/index.ts`): orchestrion's
7
+ * transformed code imports `tracingChannel` from here (its default export) instead of
8
+ * `node:diagnostics_channel`.
9
+ *
10
+ * On workerd, `channel.publish()` and `channel.runStores()` throw at module/global scope
11
+ * ("Disallowed operation called within global scope …"); only inside a request handler do they
12
+ * work. `subscribe` and channel creation are fine anywhere. Orchestrion's transformed code emits
13
+ * `start.runStores(...)` / `end.publish(...)` at each wrapped call site, so a library
14
+ * instantiated at module scope (`const app = new Hono()`) throws the moment it is wrapped — or,
15
+ * if no subscriber exists yet, is skipped by the wrapper's `if (!hasSubscribers) return
16
+ * __apm$traced()` short-circuit and never instrumented.
17
+ *
18
+ * This façade delegates to the real `node:diagnostics_channel` singletons — so subscribers, which
19
+ * keep subscribing through `node:diagnostics_channel`, are reached unchanged — and changes two
20
+ * things:
21
+ *
22
+ * 1. `hasSubscribers` always reports `true`, so the wrapper never short-circuits. On Cloudflare a
23
+ * channel is only injected for an integration that is actually bundled, so the short-circuit
24
+ * buys nothing — and disabling it is what lets the wrapper run (and reach us) at module scope,
25
+ * before the per-request cached `init()` has subscribed.
26
+ * 2. When a delegated `publish`/`runStores` throws the global-scope error, the event is queued via
27
+ * {@link deferChannelEvent} instead. {@link flushDeferredChannelEvents}, called at the top of
28
+ * the request handler after `init()`, emits it via the real channel — now inside a request,
29
+ * where publish works.
30
+ *
31
+ * In a request handler nothing throws, so every call is a transparent pass-through to the real
32
+ * channel: lifecycle channels (spans, context binding) behave exactly as on Node.
33
+ */
4
34
  const cache = /* @__PURE__ */ new Map();
5
35
  function channelHasSubscribers(ch) {
6
- const value = ch.hasSubscribers;
7
- return typeof value === "function" ? Boolean(value.call(ch)) : Boolean(value);
36
+ const value = ch.hasSubscribers;
37
+ return typeof value === "function" ? Boolean(value.call(ch)) : Boolean(value);
8
38
  }
9
39
  function wrapSubChannel(tracing, real) {
10
- return {
11
- name: real.name,
12
- // A method (not a getter) so it reads truthy as a property in the emit guard *and* is callable,
13
- // matching workerd's native shape. Forced `true`: on Cloudflare a channel is only injected for a
14
- // bundled integration, so the wrapper's no-subscriber short-circuit buys nothing — and disabling
15
- // it is what lets the wrapper run (and reach us) at module scope before `init()` has subscribed.
16
- hasSubscribers() {
17
- return true;
18
- },
19
- publish(ctx) {
20
- const hadSubscribers = channelHasSubscribers(real);
21
- try {
22
- real.publish(ctx);
23
- } catch (error) {
24
- if (!isGlobalScopeError(error)) {
25
- throw error;
26
- }
27
- if (!hadSubscribers) {
28
- deferChannelEvent(tracing, ctx);
29
- }
30
- }
31
- },
32
- runStores(ctx, fn, ...rest) {
33
- try {
34
- return real.runStores(ctx, fn, ...rest);
35
- } catch (error) {
36
- if (!isGlobalScopeError(error)) {
37
- throw error;
38
- }
39
- return fn();
40
- }
41
- },
42
- subscribe: real.subscribe.bind(real),
43
- unsubscribe: real.unsubscribe.bind(real),
44
- bindStore: real.bindStore.bind(real),
45
- unbindStore: real.unbindStore.bind(real)
46
- };
40
+ return {
41
+ name: real.name,
42
+ hasSubscribers() {
43
+ return true;
44
+ },
45
+ publish(ctx) {
46
+ const hadSubscribers = channelHasSubscribers(real);
47
+ try {
48
+ real.publish(ctx);
49
+ } catch (error) {
50
+ if (!isGlobalScopeError(error)) throw error;
51
+ if (!hadSubscribers) deferChannelEvent(tracing, ctx);
52
+ }
53
+ },
54
+ runStores(ctx, fn, ...rest) {
55
+ try {
56
+ return real.runStores(ctx, fn, ...rest);
57
+ } catch (error) {
58
+ if (!isGlobalScopeError(error)) throw error;
59
+ return fn();
60
+ }
61
+ },
62
+ subscribe: real.subscribe.bind(real),
63
+ unsubscribe: real.unsubscribe.bind(real),
64
+ bindStore: real.bindStore.bind(real),
65
+ unbindStore: real.unbindStore.bind(real)
66
+ };
47
67
  }
48
68
  function tracingChannel(name) {
49
- const cached = cache.get(name);
50
- if (cached) {
51
- return cached;
52
- }
53
- const real = realDc.tracingChannel(name);
54
- const facade = {
55
- start: wrapSubChannel(real, real.start),
56
- end: wrapSubChannel(real, real.end),
57
- asyncStart: wrapSubChannel(real, real.asyncStart),
58
- asyncEnd: wrapSubChannel(real, real.asyncEnd),
59
- error: wrapSubChannel(real, real.error),
60
- // Iterator (`:next`) channels call these on the tracingChannel itself; delegate to the real
61
- // implementation (they only run in-request, where publish/runStores are allowed).
62
- traceSync: real.traceSync.bind(real),
63
- tracePromise: real.tracePromise.bind(real),
64
- traceCallback: real.traceCallback.bind(real),
65
- subscribe: real.subscribe.bind(real),
66
- unsubscribe: real.unsubscribe.bind(real)
67
- };
68
- cache.set(name, facade);
69
- return facade;
69
+ const cached = cache.get(name);
70
+ if (cached) return cached;
71
+ const real = realDc.tracingChannel(name);
72
+ const facade = {
73
+ start: wrapSubChannel(real, real.start),
74
+ end: wrapSubChannel(real, real.end),
75
+ asyncStart: wrapSubChannel(real, real.asyncStart),
76
+ asyncEnd: wrapSubChannel(real, real.asyncEnd),
77
+ error: wrapSubChannel(real, real.error),
78
+ traceSync: real.traceSync.bind(real),
79
+ tracePromise: real.tracePromise.bind(real),
80
+ traceCallback: real.traceCallback.bind(real),
81
+ subscribe: real.subscribe.bind(real),
82
+ unsubscribe: real.unsubscribe.bind(real)
83
+ };
84
+ cache.set(name, facade);
85
+ return facade;
70
86
  }
71
87
  const channel = realDc.channel;
72
88
  const subscribe = realDc.subscribe;
73
89
  const unsubscribe = realDc.unsubscribe;
74
- const orchestrionDiagnosticsChannel = { tracingChannel, channel, subscribe, unsubscribe };
90
+ var orchestrion_diagnostics_channel_default = {
91
+ tracingChannel,
92
+ channel,
93
+ subscribe,
94
+ unsubscribe
95
+ };
96
+ export { channel, orchestrion_diagnostics_channel_default as default, subscribe, tracingChannel, unsubscribe };
75
97
 
76
- export { channel, orchestrionDiagnosticsChannel as default, subscribe, tracingChannel, unsubscribe };
77
- //# sourceMappingURL=orchestrion-diagnostics-channel.js.map
98
+ //# sourceMappingURL=orchestrion-diagnostics-channel.js.map