@utk09/ui-observability 0.11.0 → 1.0.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 (557) hide show
  1. package/CHANGELOG.md +481 -0
  2. package/README.md +73 -669
  3. package/bin/uiobs.mjs +1 -1
  4. package/dist/{batch-CL9uWYY3.js → batch-CXmPmTse.js} +3 -3
  5. package/dist/batch-CXmPmTse.js.map +1 -0
  6. package/dist/{batch-C8OcWR2L.cjs → batch-mmPigCpi.cjs} +2 -2
  7. package/dist/batch-mmPigCpi.cjs.map +1 -0
  8. package/dist/bus/bus.d.cts +331 -0
  9. package/dist/bus/bus.d.ts +108 -57
  10. package/dist/bus/links.d.cts +132 -0
  11. package/dist/bus/links.d.ts +22 -7
  12. package/dist/bus/validation.d.cts +16 -0
  13. package/dist/bus/validation.d.ts +11 -2
  14. package/dist/bus-C39wspFV.js +775 -0
  15. package/dist/bus-C39wspFV.js.map +1 -0
  16. package/dist/bus-_EaOVPGq.cjs +2 -0
  17. package/dist/bus-_EaOVPGq.cjs.map +1 -0
  18. package/dist/capture/console.d.cts +37 -0
  19. package/dist/capture/console.d.ts +11 -11
  20. package/dist/capture/errors.d.cts +32 -0
  21. package/dist/capture/errors.d.ts +7 -7
  22. package/dist/capture/interactions.d.cts +48 -0
  23. package/dist/capture/interactions.d.ts +15 -15
  24. package/dist/capture/lifecycle.d.cts +20 -0
  25. package/dist/capture/lifecycle.d.ts +4 -4
  26. package/dist/capture/long-frames.d.cts +31 -0
  27. package/dist/capture/long-frames.d.ts +7 -7
  28. package/dist/capture/network.d.cts +57 -0
  29. package/dist/capture/network.d.ts +18 -18
  30. package/dist/capture/profiler-frames.d.cts +44 -0
  31. package/dist/capture/profiler-frames.d.ts +44 -0
  32. package/dist/capture/replay-buffer.d.cts +45 -0
  33. package/dist/capture/replay-buffer.d.ts +45 -0
  34. package/dist/capture/replay-upload.d.cts +79 -0
  35. package/dist/capture/replay-upload.d.ts +79 -0
  36. package/dist/capture/replay.d.cts +114 -0
  37. package/dist/capture/replay.d.ts +114 -0
  38. package/dist/capture/reports.d.cts +17 -0
  39. package/dist/capture/reports.d.ts +3 -3
  40. package/dist/capture/resource-timing.d.cts +14 -0
  41. package/dist/capture/resource-timing.d.ts +2 -2
  42. package/dist/capture/server-timing.d.cts +19 -0
  43. package/dist/capture/server-timing.d.ts +3 -3
  44. package/dist/capture/storm.d.cts +13 -0
  45. package/dist/capture/storm.d.ts +7 -7
  46. package/dist/capture/types.d.cts +128 -0
  47. package/dist/capture/types.d.ts +54 -41
  48. package/dist/capture/unclean-exit.d.cts +31 -0
  49. package/dist/capture/unclean-exit.d.ts +9 -9
  50. package/dist/capture/user-timing.d.cts +22 -0
  51. package/dist/capture/user-timing.d.ts +4 -4
  52. package/dist/capture/web-socket.d.cts +40 -0
  53. package/dist/capture/web-socket.d.ts +14 -14
  54. package/dist/capture/web-vitals.d.cts +40 -0
  55. package/dist/capture/web-vitals.d.ts +21 -8
  56. package/dist/compression-CvED_Jel.cjs +2 -0
  57. package/dist/compression-CvED_Jel.cjs.map +1 -0
  58. package/dist/compression-tVtXwVjX.js +11 -0
  59. package/dist/compression-tVtXwVjX.js.map +1 -0
  60. package/dist/config-DUs7uHHt.cjs +2 -0
  61. package/dist/config-DUs7uHHt.cjs.map +1 -0
  62. package/dist/config-SgQcCP1_.js +560 -0
  63. package/dist/config-SgQcCP1_.js.map +1 -0
  64. package/dist/console-BGgGnjSi.js +81 -0
  65. package/dist/console-BGgGnjSi.js.map +1 -0
  66. package/dist/console-CSZ5_Vx5.cjs +2 -0
  67. package/dist/console-CSZ5_Vx5.cjs.map +1 -0
  68. package/dist/constants-CUyd9cTZ.js +357 -0
  69. package/dist/constants-CUyd9cTZ.js.map +1 -0
  70. package/dist/constants-CqdJhTxH.cjs +2 -0
  71. package/dist/constants-CqdJhTxH.cjs.map +1 -0
  72. package/dist/constants.d.cts +751 -0
  73. package/dist/constants.d.ts +231 -116
  74. package/dist/core/breadcrumbs.d.cts +54 -0
  75. package/dist/core/breadcrumbs.d.ts +21 -15
  76. package/dist/core/config.d.cts +45 -0
  77. package/dist/core/config.d.ts +33 -5
  78. package/dist/core/context.d.cts +24 -0
  79. package/dist/core/context.d.ts +8 -13
  80. package/dist/core/debug-buffer.d.cts +34 -0
  81. package/dist/core/debug-buffer.d.ts +13 -13
  82. package/dist/core/debug-bundle.d.cts +12 -0
  83. package/dist/core/debug-bundle.d.ts +6 -6
  84. package/dist/core/deferred.d.cts +7 -0
  85. package/dist/core/deferred.d.ts +4 -4
  86. package/dist/core/diagnostics.d.cts +86 -0
  87. package/dist/core/diagnostics.d.ts +25 -22
  88. package/dist/core/drops.d.cts +39 -0
  89. package/dist/core/drops.d.ts +22 -12
  90. package/dist/core/hold-buffer.d.cts +36 -0
  91. package/dist/core/hold-buffer.d.ts +16 -7
  92. package/dist/core/journey.d.cts +148 -0
  93. package/dist/core/journey.d.ts +28 -29
  94. package/dist/core/logger.d.cts +141 -0
  95. package/dist/core/logger.d.ts +45 -51
  96. package/dist/core/measure.d.cts +30 -0
  97. package/dist/core/measure.d.ts +21 -10
  98. package/dist/core/meter.d.cts +78 -0
  99. package/dist/core/meter.d.ts +38 -28
  100. package/dist/core/pipeline.d.cts +227 -0
  101. package/dist/core/pipeline.d.ts +114 -50
  102. package/dist/core/profile-buckets.d.cts +31 -0
  103. package/dist/core/profile-buckets.d.ts +31 -0
  104. package/dist/core/profiler.d.cts +218 -0
  105. package/dist/core/profiler.d.ts +218 -0
  106. package/dist/core/record.d.cts +190 -0
  107. package/dist/core/record.d.ts +67 -35
  108. package/dist/core/remote-rules.d.cts +17 -0
  109. package/dist/core/remote-rules.d.ts +7 -7
  110. package/dist/core/remote-sampling.d.cts +74 -0
  111. package/dist/core/remote-sampling.d.ts +24 -23
  112. package/dist/core/rotation.d.cts +75 -0
  113. package/dist/core/rotation.d.ts +75 -0
  114. package/dist/core/runtime.d.cts +765 -0
  115. package/dist/core/runtime.d.ts +430 -186
  116. package/dist/core/sampling.d.cts +86 -0
  117. package/dist/core/sampling.d.ts +22 -22
  118. package/dist/core/sender.d.cts +161 -0
  119. package/dist/core/sender.d.ts +80 -34
  120. package/dist/core/spans.d.cts +39 -0
  121. package/dist/core/spans.d.ts +6 -6
  122. package/dist/{deadline-BOjOxNHj.js → deadline-C4ccAuk5.js} +3 -6
  123. package/dist/deadline-C4ccAuk5.js.map +1 -0
  124. package/dist/deadline-CUGbto-y.cjs +2 -0
  125. package/dist/deadline-CUGbto-y.cjs.map +1 -0
  126. package/dist/debug-bundle-BXIlwDKM.cjs +2 -0
  127. package/dist/debug-bundle-BXIlwDKM.cjs.map +1 -0
  128. package/dist/debug-bundle-CRpYV_ui.js +35 -0
  129. package/dist/debug-bundle-CRpYV_ui.js.map +1 -0
  130. package/dist/defineProperty-X1c4tIPD.cjs +1 -0
  131. package/dist/defineProperty-s2S8BXUc.js +35 -0
  132. package/dist/doctor.cjs +1 -1
  133. package/dist/doctor.cjs.map +1 -1
  134. package/dist/doctor.d.cts +36 -0
  135. package/dist/doctor.d.ts +19 -6
  136. package/dist/doctor.js +180 -53
  137. package/dist/doctor.js.map +1 -1
  138. package/dist/error-like-B11pB4aL.js.map +1 -1
  139. package/dist/error-like-gGRx2s36.cjs.map +1 -1
  140. package/dist/errors-BE_EZV7Q.js +86 -0
  141. package/dist/errors-BE_EZV7Q.js.map +1 -0
  142. package/dist/errors-CNPbesMs.cjs +3 -0
  143. package/dist/errors-CNPbesMs.cjs.map +1 -0
  144. package/dist/factory-CTi0Is3F.js +404 -0
  145. package/dist/factory-CTi0Is3F.js.map +1 -0
  146. package/dist/factory-hRrH32v5.cjs +2 -0
  147. package/dist/factory-hRrH32v5.cjs.map +1 -0
  148. package/dist/fixed-window-CvESpFYV.cjs.map +1 -1
  149. package/dist/fixed-window-Dq3MLUUv.js.map +1 -1
  150. package/dist/global-scope-BN-Io_yv.cjs.map +1 -1
  151. package/dist/global-scope-D9I8s-oN.js.map +1 -1
  152. package/dist/guards-BlYGRK4l.js +10 -0
  153. package/dist/guards-BlYGRK4l.js.map +1 -0
  154. package/dist/guards-EjG3ahFp.cjs +2 -0
  155. package/dist/guards-EjG3ahFp.cjs.map +1 -0
  156. package/dist/{identity-DT5VmvXy.js → identity-DdhKgrpk.js} +11 -15
  157. package/dist/identity-DdhKgrpk.js.map +1 -0
  158. package/dist/identity-DlWRIuwy.cjs +2 -0
  159. package/dist/identity-DlWRIuwy.cjs.map +1 -0
  160. package/dist/index.cjs +1 -1
  161. package/dist/index.cjs.map +1 -1
  162. package/dist/index.d.cts +300 -0
  163. package/dist/index.d.ts +165 -141
  164. package/dist/index.js +1283 -1468
  165. package/dist/index.js.map +1 -1
  166. package/dist/indexeddb-storage-CL9uqBCy.cjs +2 -0
  167. package/dist/indexeddb-storage-CL9uqBCy.cjs.map +1 -0
  168. package/dist/{indexeddb-storage-BJVtiQKm.js → indexeddb-storage-GHdl0t8A.js} +51 -47
  169. package/dist/indexeddb-storage-GHdl0t8A.js.map +1 -0
  170. package/dist/interactions-CUkzK8sR.cjs +2 -0
  171. package/dist/interactions-CUkzK8sR.cjs.map +1 -0
  172. package/dist/{interactions-DTgKy_6K.js → interactions-DiFvCosX.js} +41 -49
  173. package/dist/interactions-DiFvCosX.js.map +1 -0
  174. package/dist/journey-B4Adltjm.cjs +2 -0
  175. package/dist/journey-B4Adltjm.cjs.map +1 -0
  176. package/dist/{journey-CuJrHzEg.js → journey-D2_sia57.js} +51 -53
  177. package/dist/journey-D2_sia57.js.map +1 -0
  178. package/dist/{library-console-C1m6g1BR.js → library-console-Btrzt814.js} +2 -2
  179. package/dist/library-console-Btrzt814.js.map +1 -0
  180. package/dist/{library-console-D2GY9Or6.cjs → library-console-CPW6bvZH.cjs} +2 -2
  181. package/dist/library-console-CPW6bvZH.cjs.map +1 -0
  182. package/dist/{library-request-BQBT9N9Q.js → library-request-BJ9PLRaD.js} +2 -2
  183. package/dist/library-request-BJ9PLRaD.js.map +1 -0
  184. package/dist/{library-request-1BX_UlaX.cjs → library-request-D7OvTxZV.cjs} +2 -2
  185. package/dist/library-request-D7OvTxZV.cjs.map +1 -0
  186. package/dist/{lifecycle-BaKx_-32.js → lifecycle-22CUCrc9.js} +21 -29
  187. package/dist/lifecycle-22CUCrc9.js.map +1 -0
  188. package/dist/lifecycle-IaAm1mOC.cjs +2 -0
  189. package/dist/lifecycle-IaAm1mOC.cjs.map +1 -0
  190. package/dist/{log-record-CAoGBBf3.js → log-record-BNiLfqtL.js} +8 -7
  191. package/dist/log-record-BNiLfqtL.js.map +1 -0
  192. package/dist/log-record-CkivuiEl.cjs +2 -0
  193. package/dist/log-record-CkivuiEl.cjs.map +1 -0
  194. package/dist/long-frames-BUUbXd-B.cjs +2 -0
  195. package/dist/long-frames-BUUbXd-B.cjs.map +1 -0
  196. package/dist/long-frames-DNFaRnC3.js +62 -0
  197. package/dist/long-frames-DNFaRnC3.js.map +1 -0
  198. package/dist/models/batch.d.cts +57 -0
  199. package/dist/models/batch.d.ts +16 -17
  200. package/dist/models/bus.d.cts +158 -0
  201. package/dist/models/bus.d.ts +46 -26
  202. package/dist/models/config.d.cts +1540 -0
  203. package/dist/models/config.d.ts +692 -405
  204. package/dist/models/drop.d.cts +54 -0
  205. package/dist/models/drop.d.ts +29 -14
  206. package/dist/models/health.d.cts +148 -0
  207. package/dist/models/health.d.ts +119 -23
  208. package/dist/models/log-record.d.cts +61 -0
  209. package/dist/models/log-record.d.ts +13 -14
  210. package/dist/models/metric.d.cts +139 -0
  211. package/dist/models/metric.d.ts +94 -18
  212. package/dist/models/plugin.d.cts +47 -0
  213. package/dist/models/plugin.d.ts +16 -16
  214. package/dist/models/replay.d.cts +60 -0
  215. package/dist/models/replay.d.ts +60 -0
  216. package/dist/models/serializer.d.cts +23 -0
  217. package/dist/models/serializer.d.ts +3 -4
  218. package/dist/models/storage.d.cts +95 -0
  219. package/dist/models/storage.d.ts +17 -14
  220. package/dist/network-CGMLQ-mA.cjs +2 -0
  221. package/dist/network-CGMLQ-mA.cjs.map +1 -0
  222. package/dist/{network-DBNwApoF.js → network-on2zZT6H.js} +57 -57
  223. package/dist/network-on2zZT6H.js.map +1 -0
  224. package/dist/openfin-Bxelt0yg.js.map +1 -1
  225. package/dist/openfin-DtH2f7zX.cjs.map +1 -1
  226. package/dist/otlp-BENHf3g9.cjs +2 -0
  227. package/dist/otlp-BENHf3g9.cjs.map +1 -0
  228. package/dist/{otlp-BTJdIa6F.js → otlp-DimfrRor.js} +22 -29
  229. package/dist/otlp-DimfrRor.js.map +1 -0
  230. package/dist/patch-BX8KrPCT.cjs.map +1 -1
  231. package/dist/patch-UdPz1ea8.js.map +1 -1
  232. package/dist/{platform-DkcuXwe-.js → platform-BaaFIPCU.js} +8 -8
  233. package/dist/platform-BaaFIPCU.js.map +1 -0
  234. package/dist/{platform-C2Ez5kDc.cjs → platform-CfA3-7sJ.cjs} +2 -2
  235. package/dist/platform-CfA3-7sJ.cjs.map +1 -0
  236. package/dist/profiler-BAZoh7A4.js +292 -0
  237. package/dist/profiler-BAZoh7A4.js.map +1 -0
  238. package/dist/profiler-D4tJpDRc.cjs +2 -0
  239. package/dist/profiler-D4tJpDRc.cjs.map +1 -0
  240. package/dist/profiler-frames-C4xr7KfH.cjs +2 -0
  241. package/dist/profiler-frames-C4xr7KfH.cjs.map +1 -0
  242. package/dist/profiler-frames-cJMx9wNM.js +78 -0
  243. package/dist/profiler-frames-cJMx9wNM.js.map +1 -0
  244. package/dist/remote-rules-Dz9MRAsB.js +95 -0
  245. package/dist/remote-rules-Dz9MRAsB.js.map +1 -0
  246. package/dist/remote-rules-_tY0zj5o.cjs +2 -0
  247. package/dist/remote-rules-_tY0zj5o.cjs.map +1 -0
  248. package/dist/replay-B3gFXIZd.cjs +2 -0
  249. package/dist/replay-B3gFXIZd.cjs.map +1 -0
  250. package/dist/replay-Ds-ANH34.js +310 -0
  251. package/dist/replay-Ds-ANH34.js.map +1 -0
  252. package/dist/reports-BDSe4dFH.cjs +2 -0
  253. package/dist/reports-BDSe4dFH.cjs.map +1 -0
  254. package/dist/{reports-TA-zInnq.js → reports-C-thq-bk.js} +25 -30
  255. package/dist/reports-C-thq-bk.js.map +1 -0
  256. package/dist/resource-timing-C576gFIQ.cjs +2 -0
  257. package/dist/resource-timing-C576gFIQ.cjs.map +1 -0
  258. package/dist/{resource-timing-BLv3EA2A.js → resource-timing-eUl2dNgC.js} +20 -23
  259. package/dist/resource-timing-eUl2dNgC.js.map +1 -0
  260. package/dist/response-body-YdNl-HkR.cjs +3 -0
  261. package/dist/response-body-YdNl-HkR.cjs.map +1 -0
  262. package/dist/response-body-eoSQpLiH.js +331 -0
  263. package/dist/response-body-eoSQpLiH.js.map +1 -0
  264. package/dist/rotation-Cwct4ckk.js +94 -0
  265. package/dist/rotation-Cwct4ckk.js.map +1 -0
  266. package/dist/rotation-D4qUAHAu.cjs +2 -0
  267. package/dist/rotation-D4qUAHAu.cjs.map +1 -0
  268. package/dist/sampling-BlrI8jor.js +63 -0
  269. package/dist/sampling-BlrI8jor.js.map +1 -0
  270. package/dist/sampling-mXt4dstx.cjs +2 -0
  271. package/dist/sampling-mXt4dstx.cjs.map +1 -0
  272. package/dist/{sanitize-6ymPlVvP.js → sanitize-Ba0KqU06.js} +2 -2
  273. package/dist/sanitize-Ba0KqU06.js.map +1 -0
  274. package/dist/{sanitize-BAWzkZt0.cjs → sanitize-DQyiI_KY.cjs} +2 -2
  275. package/dist/sanitize-DQyiI_KY.cjs.map +1 -0
  276. package/dist/sender-BdRuNVhF.cjs +2 -0
  277. package/dist/sender-BdRuNVhF.cjs.map +1 -0
  278. package/dist/sender-Dv8rAmpV.js +979 -0
  279. package/dist/sender-Dv8rAmpV.js.map +1 -0
  280. package/dist/storage/context-storage.d.cts +90 -0
  281. package/dist/storage/context-storage.d.ts +38 -37
  282. package/dist/storage/emergency-queue.d.cts +27 -0
  283. package/dist/storage/emergency-queue.d.ts +13 -13
  284. package/dist/storage/eviction.d.cts +40 -0
  285. package/dist/storage/eviction.d.ts +13 -13
  286. package/dist/storage/factory.d.cts +21 -0
  287. package/dist/storage/factory.d.ts +11 -10
  288. package/dist/storage/gap.d.cts +20 -0
  289. package/dist/storage/gap.d.ts +9 -9
  290. package/dist/storage/idb-driver.d.cts +93 -0
  291. package/dist/storage/idb-driver.d.ts +32 -33
  292. package/dist/storage/indexeddb-storage.d.cts +97 -0
  293. package/dist/storage/indexeddb-storage.d.ts +38 -31
  294. package/dist/storage/keys.d.cts +17 -0
  295. package/dist/storage/keys.d.ts +9 -9
  296. package/dist/storage/local-storage.d.cts +139 -0
  297. package/dist/storage/local-storage.d.ts +49 -42
  298. package/dist/storage/memory-storage.d.cts +73 -0
  299. package/dist/storage/memory-storage.d.ts +25 -25
  300. package/dist/storage/persistence.d.cts +8 -0
  301. package/dist/storage/persistence.d.ts +3 -3
  302. package/dist/storage/stored-context.d.cts +34 -0
  303. package/dist/storage/stored-context.d.ts +34 -0
  304. package/dist/stored-context-B2EzVuYm.js +51 -0
  305. package/dist/stored-context-B2EzVuYm.js.map +1 -0
  306. package/dist/stored-context-CXt7eHZL.cjs +2 -0
  307. package/dist/stored-context-CXt7eHZL.cjs.map +1 -0
  308. package/dist/storm-C-zYSdDX.cjs +2 -0
  309. package/dist/storm-C-zYSdDX.cjs.map +1 -0
  310. package/dist/storm-DjKetLKZ.js +9 -0
  311. package/dist/storm-DjKetLKZ.js.map +1 -0
  312. package/dist/transport/compression.d.cts +7 -0
  313. package/dist/transport/compression.d.ts +2 -2
  314. package/dist/transport/custom-transport.d.cts +22 -0
  315. package/dist/transport/custom-transport.d.ts +6 -5
  316. package/dist/transport/errors.d.cts +31 -0
  317. package/dist/transport/errors.d.ts +7 -7
  318. package/dist/transport/exit-flush.d.cts +135 -0
  319. package/dist/transport/exit-flush.d.ts +62 -45
  320. package/dist/transport/headers.d.cts +8 -0
  321. package/dist/transport/headers.d.ts +4 -4
  322. package/dist/transport/http-transport.d.cts +116 -0
  323. package/dist/transport/http-transport.d.ts +48 -35
  324. package/dist/transport/memory-transport.d.cts +30 -0
  325. package/dist/transport/memory-transport.d.ts +8 -8
  326. package/dist/transport/response-body.d.cts +49 -0
  327. package/dist/transport/response-body.d.ts +49 -0
  328. package/dist/transport/retry-engine.d.cts +129 -0
  329. package/dist/transport/retry-engine.d.ts +62 -43
  330. package/dist/transport/serializers/ecs.d.cts +3 -0
  331. package/dist/transport/serializers/ecs.d.ts +2 -2
  332. package/dist/transport/serializers/otlp-metrics.d.cts +3 -0
  333. package/dist/transport/serializers/otlp-metrics.d.ts +2 -2
  334. package/dist/transport/serializers/otlp-traces.d.cts +3 -0
  335. package/dist/transport/serializers/otlp-traces.d.ts +2 -2
  336. package/dist/transport/serializers/otlp.d.cts +47 -0
  337. package/dist/transport/serializers/otlp.d.ts +18 -18
  338. package/dist/transport/serializers/select.d.cts +38 -0
  339. package/dist/transport/serializers/select.d.ts +11 -11
  340. package/dist/transport/status-transport.d.cts +129 -0
  341. package/dist/transport/status-transport.d.ts +45 -28
  342. package/dist/transport/worker-client.d.cts +23 -0
  343. package/dist/transport/worker-client.d.ts +12 -3
  344. package/dist/transport/worker-entry.d.cts +5 -0
  345. package/dist/transport/worker-entry.d.ts +1 -1
  346. package/dist/transport/worker-protocol.d.cts +38 -0
  347. package/dist/transport/worker-protocol.d.ts +7 -5
  348. package/dist/transport/worker-server.d.cts +3 -0
  349. package/dist/transport/worker-server.d.ts +1 -1
  350. package/dist/transport/worker-transport.d.cts +10 -0
  351. package/dist/transport/worker-transport.d.ts +5 -4
  352. package/dist/types-BAerHgCq.js.map +1 -1
  353. package/dist/types-C7WNpnG1.cjs.map +1 -1
  354. package/dist/{unclean-exit-CwcUhFOn.js → unclean-exit-DQD1cT7c.js} +23 -30
  355. package/dist/unclean-exit-DQD1cT7c.js.map +1 -0
  356. package/dist/unclean-exit-py99ApzT.cjs +2 -0
  357. package/dist/unclean-exit-py99ApzT.cjs.map +1 -0
  358. package/dist/unref-CU9Nyz_9.cjs +2 -0
  359. package/dist/unref-CU9Nyz_9.cjs.map +1 -0
  360. package/dist/unref-DgHPQeWv.js +7 -0
  361. package/dist/unref-DgHPQeWv.js.map +1 -0
  362. package/dist/{user-timing-_jZIhDKI.js → user-timing-BePqb1uN.js} +18 -18
  363. package/dist/user-timing-BePqb1uN.js.map +1 -0
  364. package/dist/user-timing-D6XTmpuM.cjs +2 -0
  365. package/dist/user-timing-D6XTmpuM.cjs.map +1 -0
  366. package/dist/utils/console.d.cts +36 -0
  367. package/dist/utils/console.d.ts +6 -6
  368. package/dist/utils/deadline.d.cts +14 -0
  369. package/dist/utils/deadline.d.ts +4 -4
  370. package/dist/utils/error-like.d.cts +25 -0
  371. package/dist/utils/error-like.d.ts +7 -7
  372. package/dist/utils/fixed-window.d.cts +25 -0
  373. package/dist/utils/fixed-window.d.ts +9 -8
  374. package/dist/utils/global-scope.d.cts +20 -0
  375. package/dist/utils/global-scope.d.ts +8 -8
  376. package/dist/utils/guards.d.cts +14 -0
  377. package/dist/utils/guards.d.ts +10 -2
  378. package/dist/utils/identity.d.cts +109 -0
  379. package/dist/utils/identity.d.ts +20 -21
  380. package/dist/utils/library-console.d.cts +11 -0
  381. package/dist/utils/library-console.d.ts +4 -4
  382. package/dist/utils/library-request.d.cts +24 -0
  383. package/dist/utils/library-request.d.ts +10 -10
  384. package/dist/utils/lock.d.cts +24 -0
  385. package/dist/utils/lock.d.ts +11 -10
  386. package/dist/utils/openfin.d.cts +48 -0
  387. package/dist/utils/openfin.d.ts +5 -5
  388. package/dist/utils/patch.d.cts +9 -0
  389. package/dist/utils/patch.d.ts +6 -6
  390. package/dist/utils/platform.d.cts +62 -0
  391. package/dist/utils/platform.d.ts +15 -13
  392. package/dist/utils/sanitize.d.cts +52 -0
  393. package/dist/utils/sanitize.d.ts +5 -5
  394. package/dist/utils/sequence.d.cts +10 -0
  395. package/dist/utils/tracing.d.cts +158 -0
  396. package/dist/utils/tracing.d.ts +49 -42
  397. package/dist/utils/unref.d.cts +9 -0
  398. package/dist/utils/unref.d.ts +3 -3
  399. package/dist/web-socket-CoIUBM3C.cjs +2 -0
  400. package/dist/web-socket-CoIUBM3C.cjs.map +1 -0
  401. package/dist/{web-socket-CV7yIMnm.js → web-socket-DSHgDiZ6.js} +23 -28
  402. package/dist/web-socket-DSHgDiZ6.js.map +1 -0
  403. package/dist/web-vitals-4pWACwaR.js +71 -0
  404. package/dist/web-vitals-4pWACwaR.js.map +1 -0
  405. package/dist/web-vitals-__X7t4pj.cjs +2 -0
  406. package/dist/web-vitals-__X7t4pj.cjs.map +1 -0
  407. package/dist/worker-protocol-QbvqNazn.cjs +2 -0
  408. package/dist/worker-protocol-QbvqNazn.cjs.map +1 -0
  409. package/dist/{worker-protocol-CrsdSDLn.js → worker-protocol-x074Rpet.js} +14 -11
  410. package/dist/worker-protocol-x074Rpet.js.map +1 -0
  411. package/dist/worker-server-CFe4nvos.cjs +2 -0
  412. package/dist/worker-server-CFe4nvos.cjs.map +1 -0
  413. package/dist/worker-server-iUVSjH8L.js +94 -0
  414. package/dist/worker-server-iUVSjH8L.js.map +1 -0
  415. package/dist/worker-transport-CRAX-09c.cjs +2 -0
  416. package/dist/worker-transport-CRAX-09c.cjs.map +1 -0
  417. package/dist/worker-transport-Dy1KMA7t.js +190 -0
  418. package/dist/worker-transport-Dy1KMA7t.js.map +1 -0
  419. package/llms.txt +397 -0
  420. package/package.json +55 -41
  421. package/dist/batch-C8OcWR2L.cjs.map +0 -1
  422. package/dist/batch-CL9uWYY3.js.map +0 -1
  423. package/dist/bus-BZ0GldpT.js +0 -660
  424. package/dist/bus-BZ0GldpT.js.map +0 -1
  425. package/dist/bus-VWlmM5xs.cjs +0 -2
  426. package/dist/bus-VWlmM5xs.cjs.map +0 -1
  427. package/dist/console-BPZCuSLc.cjs +0 -2
  428. package/dist/console-BPZCuSLc.cjs.map +0 -1
  429. package/dist/console-BeCF7n59.js +0 -82
  430. package/dist/console-BeCF7n59.js.map +0 -1
  431. package/dist/constants-DqKJH_MP.cjs +0 -2
  432. package/dist/constants-DqKJH_MP.cjs.map +0 -1
  433. package/dist/constants-zyrqveN4.js +0 -304
  434. package/dist/constants-zyrqveN4.js.map +0 -1
  435. package/dist/context-storage-BjzeBSxH.cjs +0 -2
  436. package/dist/context-storage-BjzeBSxH.cjs.map +0 -1
  437. package/dist/context-storage-BzkoHzkQ.js +0 -51
  438. package/dist/context-storage-BzkoHzkQ.js.map +0 -1
  439. package/dist/deadline-BOjOxNHj.js.map +0 -1
  440. package/dist/deadline-XSnm95pg.cjs +0 -2
  441. package/dist/deadline-XSnm95pg.cjs.map +0 -1
  442. package/dist/debug-bundle-BzJNpbF0.cjs +0 -2
  443. package/dist/debug-bundle-BzJNpbF0.cjs.map +0 -1
  444. package/dist/debug-bundle-C7UkHZ-q.js +0 -25
  445. package/dist/debug-bundle-C7UkHZ-q.js.map +0 -1
  446. package/dist/emergency-queue-CNTRui5t.cjs +0 -2
  447. package/dist/emergency-queue-CNTRui5t.cjs.map +0 -1
  448. package/dist/emergency-queue-Zy6lNafo.js +0 -67
  449. package/dist/emergency-queue-Zy6lNafo.js.map +0 -1
  450. package/dist/errors-Dh7kef0i.js +0 -92
  451. package/dist/errors-Dh7kef0i.js.map +0 -1
  452. package/dist/errors-tfEr48bS.cjs +0 -3
  453. package/dist/errors-tfEr48bS.cjs.map +0 -1
  454. package/dist/factory-BonqI3NL.js +0 -276
  455. package/dist/factory-BonqI3NL.js.map +0 -1
  456. package/dist/factory-CJXVYp0R.cjs +0 -2
  457. package/dist/factory-CJXVYp0R.cjs.map +0 -1
  458. package/dist/guards-Cidk71ME.js +0 -7
  459. package/dist/guards-Cidk71ME.js.map +0 -1
  460. package/dist/guards-nJ70syPt.cjs +0 -2
  461. package/dist/guards-nJ70syPt.cjs.map +0 -1
  462. package/dist/identity-Cxgj6pZX.cjs +0 -2
  463. package/dist/identity-Cxgj6pZX.cjs.map +0 -1
  464. package/dist/identity-DT5VmvXy.js.map +0 -1
  465. package/dist/indexeddb-storage-BJVtiQKm.js.map +0 -1
  466. package/dist/indexeddb-storage-CIoW21Xd.cjs +0 -2
  467. package/dist/indexeddb-storage-CIoW21Xd.cjs.map +0 -1
  468. package/dist/interactions-DTgKy_6K.js.map +0 -1
  469. package/dist/interactions-fEN6FbVo.cjs +0 -2
  470. package/dist/interactions-fEN6FbVo.cjs.map +0 -1
  471. package/dist/journey-CuJrHzEg.js.map +0 -1
  472. package/dist/journey-pffMVMfa.cjs +0 -2
  473. package/dist/journey-pffMVMfa.cjs.map +0 -1
  474. package/dist/keys-BHhw_0Wh.cjs +0 -2
  475. package/dist/keys-BHhw_0Wh.cjs.map +0 -1
  476. package/dist/keys-BU9j5YqW.js +0 -16
  477. package/dist/keys-BU9j5YqW.js.map +0 -1
  478. package/dist/library-console-C1m6g1BR.js.map +0 -1
  479. package/dist/library-console-D2GY9Or6.cjs.map +0 -1
  480. package/dist/library-request-1BX_UlaX.cjs.map +0 -1
  481. package/dist/library-request-BQBT9N9Q.js.map +0 -1
  482. package/dist/lifecycle-2EtUaRpo.cjs +0 -2
  483. package/dist/lifecycle-2EtUaRpo.cjs.map +0 -1
  484. package/dist/lifecycle-BaKx_-32.js.map +0 -1
  485. package/dist/log-record-CAoGBBf3.js.map +0 -1
  486. package/dist/log-record-i9zOTkpQ.cjs +0 -2
  487. package/dist/log-record-i9zOTkpQ.cjs.map +0 -1
  488. package/dist/long-frames-BVg4i5SC.cjs +0 -2
  489. package/dist/long-frames-BVg4i5SC.cjs.map +0 -1
  490. package/dist/long-frames-Czk7IupC.js +0 -64
  491. package/dist/long-frames-Czk7IupC.js.map +0 -1
  492. package/dist/models/stats.d.ts +0 -11
  493. package/dist/network-DBNwApoF.js.map +0 -1
  494. package/dist/network-xbbuvG_6.cjs +0 -2
  495. package/dist/network-xbbuvG_6.cjs.map +0 -1
  496. package/dist/otlp-BDvFrLnc.cjs +0 -2
  497. package/dist/otlp-BDvFrLnc.cjs.map +0 -1
  498. package/dist/otlp-BTJdIa6F.js.map +0 -1
  499. package/dist/platform-C2Ez5kDc.cjs.map +0 -1
  500. package/dist/platform-DkcuXwe-.js.map +0 -1
  501. package/dist/remote-rules-Cfb4K-Nl.js +0 -98
  502. package/dist/remote-rules-Cfb4K-Nl.js.map +0 -1
  503. package/dist/remote-rules-vzvk7aKf.cjs +0 -2
  504. package/dist/remote-rules-vzvk7aKf.cjs.map +0 -1
  505. package/dist/reports-Dk2YhKIh.cjs +0 -2
  506. package/dist/reports-Dk2YhKIh.cjs.map +0 -1
  507. package/dist/reports-TA-zInnq.js.map +0 -1
  508. package/dist/resource-timing-BLv3EA2A.js.map +0 -1
  509. package/dist/resource-timing-Cysw1S1f.cjs +0 -2
  510. package/dist/resource-timing-Cysw1S1f.cjs.map +0 -1
  511. package/dist/sampling-C4VV-1MS.js +0 -60
  512. package/dist/sampling-C4VV-1MS.js.map +0 -1
  513. package/dist/sampling-Ckh2yW9k.cjs +0 -2
  514. package/dist/sampling-Ckh2yW9k.cjs.map +0 -1
  515. package/dist/sanitize-6ymPlVvP.js.map +0 -1
  516. package/dist/sanitize-BAWzkZt0.cjs.map +0 -1
  517. package/dist/select-ZF4by-lF.cjs +0 -3
  518. package/dist/select-ZF4by-lF.cjs.map +0 -1
  519. package/dist/select-xtQaenIi.js +0 -270
  520. package/dist/select-xtQaenIi.js.map +0 -1
  521. package/dist/sender-CiMHC9YG.js +0 -856
  522. package/dist/sender-CiMHC9YG.js.map +0 -1
  523. package/dist/sender-D5wBoXA8.cjs +0 -2
  524. package/dist/sender-D5wBoXA8.cjs.map +0 -1
  525. package/dist/storage-BA9RqRO-.cjs +0 -2
  526. package/dist/storage-BA9RqRO-.cjs.map +0 -1
  527. package/dist/storage-DZwed89z.js +0 -16
  528. package/dist/storage-DZwed89z.js.map +0 -1
  529. package/dist/storm-CYi9Swpx.cjs +0 -2
  530. package/dist/storm-CYi9Swpx.cjs.map +0 -1
  531. package/dist/storm-VR024_QN.js +0 -9
  532. package/dist/storm-VR024_QN.js.map +0 -1
  533. package/dist/unclean-exit-CwcUhFOn.js.map +0 -1
  534. package/dist/unclean-exit-DFUN57wY.cjs +0 -2
  535. package/dist/unclean-exit-DFUN57wY.cjs.map +0 -1
  536. package/dist/user-timing-C9kfRq3J.cjs +0 -2
  537. package/dist/user-timing-C9kfRq3J.cjs.map +0 -1
  538. package/dist/user-timing-_jZIhDKI.js.map +0 -1
  539. package/dist/utils/timer.d.ts +0 -19
  540. package/dist/web-socket-BWUoqBh8.cjs +0 -2
  541. package/dist/web-socket-BWUoqBh8.cjs.map +0 -1
  542. package/dist/web-socket-CV7yIMnm.js.map +0 -1
  543. package/dist/web-vitals-Bq4WFHQo.js +0 -52
  544. package/dist/web-vitals-Bq4WFHQo.js.map +0 -1
  545. package/dist/web-vitals-DFuoTQbZ.cjs +0 -2
  546. package/dist/web-vitals-DFuoTQbZ.cjs.map +0 -1
  547. package/dist/worker-protocol-Bai7GAIA.cjs +0 -2
  548. package/dist/worker-protocol-Bai7GAIA.cjs.map +0 -1
  549. package/dist/worker-protocol-CrsdSDLn.js.map +0 -1
  550. package/dist/worker-server-BrIYkfoa.cjs +0 -2
  551. package/dist/worker-server-BrIYkfoa.cjs.map +0 -1
  552. package/dist/worker-server-Dp5HYm4b.js +0 -83
  553. package/dist/worker-server-Dp5HYm4b.js.map +0 -1
  554. package/dist/worker-transport-Bwej4N2e.cjs +0 -2
  555. package/dist/worker-transport-Bwej4N2e.cjs.map +0 -1
  556. package/dist/worker-transport-D6jtgpqN.js +0 -199
  557. package/dist/worker-transport-D6jtgpqN.js.map +0 -1
@@ -1,19 +1,22 @@
1
- import type { LogBatch } from "./batch";
2
- import type { RetentionOptions } from "./config";
1
+ import type { LogBatch } from "./batch.js";
2
+ import type { RetentionOptions } from "./config.js";
3
3
  /**
4
- * State of the request for persistent storage. "off" means no request. "pending" waits for the
5
- * browser. "unsupported" means the browser has no `navigator.storage.persist()`.
4
+ * State of the request for persistent storage. "off" means no request was made and "pending"
5
+ * is waiting for the browser. "unsupported" means the browser has no
6
+ * `navigator.storage.persist()`.
6
7
  */
7
8
  export type StoragePersistence = "off" | "pending" | "granted" | "denied" | "unsupported";
8
9
  /** Persistent batch storage interface. All methods must resolve and never throw. */
9
10
  export interface StorageAdapter {
10
- /** Adapter identifier name. */
11
+ /** Adapter name. */
11
12
  readonly name: string;
12
13
  /**
13
14
  * Persists a batch to storage.
14
15
  * @param batch The batch to store.
16
+ * @returns True if the batch is in storage when the save ends. A save's own prune can remove
17
+ * it, and the second write after a quota error runs no prune. False means nothing sends it again.
15
18
  */
16
- save(batch: LogBatch): Promise<void>;
19
+ save(batch: LogBatch): Promise<boolean>;
17
20
  /**
18
21
  * Reads up to `limit` batches in FIFO order without removing them.
19
22
  * @param limit Maximum number of batches to retrieve.
@@ -21,14 +24,14 @@ export interface StorageAdapter {
21
24
  */
22
25
  take(limit: number): Promise<LogBatch[]>;
23
26
  /**
24
- * Reads batches of one context without loading batches of other contexts.
27
+ * Reads one context's batches without loading those of other contexts.
25
28
  * @param id Delivery context id.
26
29
  * @param limit Maximum batches to return.
27
- * @returns Batches of this context, oldest first.
30
+ * @returns This context's batches, oldest first.
28
31
  */
29
32
  takeContext?(id: string, limit: number): Promise<LogBatch[]>;
30
33
  /**
31
- * Counts batches of one context without loading them.
34
+ * Counts one context's batches without loading them.
32
35
  * @param id Delivery context id.
33
36
  * @returns Number of batches in this context.
34
37
  */
@@ -66,8 +69,8 @@ export interface StorageLimits {
66
69
  maxAttempts: number;
67
70
  }
68
71
  /**
69
- * Gives the storage limits of a retention setting. "until-delivered" has no age limit and no
70
- * attempt limit. The batch cap still applies.
72
+ * Returns the storage limits for a retention setting. A null age or attempt limit becomes
73
+ * Infinity, so a batch stays until it's delivered, but the batch cap still applies.
71
74
  * @param retention Retention setting from the config.
72
75
  * @returns The limits for the storage adapters and the retry engine.
73
76
  */
@@ -79,14 +82,14 @@ export interface PruneResult {
79
82
  /** Total records dropped within evicted batches. */
80
83
  records: number;
81
84
  /**
82
- * Cause of the drop. If more than one rule applies, this is the last rule. "not_stored" means
83
- * that storage did not keep a batch after a failed send.
85
+ * Cause of the drop. If more than one rule applied, this is the last one. "not_stored" means
86
+ * storage did not keep a batch after a failed send.
84
87
  */
85
88
  reason: "expired" | "over_capacity" | "quota" | "not_stored";
86
89
  }
87
90
  /**
88
91
  * Callback invoked when dropped records create a telemetry gap.
89
92
  * @param result Summary of evicted data.
90
- * @param dropped The dropped batches. A corrupt entry has no batch. The list then has none for it.
93
+ * @param dropped The dropped batches. A corrupt entry has no batch, so the list omits it.
91
94
  */
92
95
  export type GapReporter = (result: PruneResult, dropped: readonly LogBatch[]) => void;
@@ -0,0 +1,2 @@
1
+ const e=require("./constants-CqdJhTxH.cjs"),t=require("./error-like-gGRx2s36.cjs"),n=require("./library-request-D7OvTxZV.cjs"),r=require("./patch-BX8KrPCT.cjs"),i=require("./platform-CfA3-7sJ.cjs"),a=require("./types-C7WNpnG1.cjs"),o=require("./defineProperty-X1c4tIPD.cjs");function s(e,t){let n=[],r=0,i=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o];a?a=!1:i&&s===`\\`?a=!0:s===`"`?i=!i:!i&&s===t&&(n.push(e.slice(r,o)),r=o+1)}return n.push(e.slice(r)),n}function c(e){return/^server-timing:(.*)$/im.exec(e)?.[1]??null}function l(t){let n={entries:[]};if(!t)return n;for(let r of s(t.slice(0,e.Ln),`,`).slice(0,32)){let[e,...t]=s(r,`;`),i=e.trim();if(!/^[!#$%&'*+.^_`|~\da-z-]+$/i.test(i))continue;let a={name:i,duration:0,description:``},o=new Set;for(let e of t){let t=e.indexOf(`=`);if(t<0)continue;let n=e.slice(0,t).trim().toLowerCase();if(o.has(n))continue;o.add(n);let r=e.slice(t+1).trim();if(r.startsWith(`"`)&&r.endsWith(`"`)&&(r=r.slice(1,-1).replace(/\\(.)/g,`$1`)),n===`dur`){let e=Number(r);Number.isFinite(e)&&e>=0&&(a.duration=e)}else n===`desc`&&(a.description=r)}if(n.entries.push(a),i.toLowerCase()===`traceparent`){let e=/^00-([\da-f]{32})-([\da-f]{16})-[\da-f]{2}$/.exec(a.description);e&&/[1-9a-f]/.test(e[1])&&/[1-9a-f]/.test(e[2])&&(n.link={traceId:e[1],spanId:e[2]})}}return n}var u=1e3,d={name:`http.client.request.duration`,kind:`histogram`,unit:`s`,boundaries:[.005,.01,.025,.05,.075,.1,.25,.5,.75,1,2.5,5,7.5,10]};function f(e,n,r,i){let a=typeof location<`u`?location.href:void 0,o={"http.request.method":e,"server.address":new URL(n,a).hostname};if(r===0){let e=t.r(i)?i.name:``;return o[`error.type`]=e===``?`_OTHER`:e,o}return o[`http.response.status_code`]=r,r>=400&&(o[`error.type`]=String(r)),o}function p(){return XMLHttpRequest.prototype}function m(e){if(typeof e==`string`)return e;if(e instanceof URL)return e.href;if(typeof e==`object`&&e){let{url:t}=e;if(typeof t==`string`)return t}return String(e)}function h(e,t){let n=t?.method;return n===void 0&&typeof e==`object`&&e&&(n=e.method),v(n??`GET`)}function g(e){return typeof e==`object`&&!(e instanceof URL)&&!(e instanceof Request)}function _(e){return e===void 0||Object.values(e).every(e=>e===void 0)}function v(e){return typeof e==`string`?e.toUpperCase():String(e)}var y=class{constructor(e){o.t(this,`ctx`,void 0),o.t(this,`name`,`network`),o.t(this,`installed`,!1),o.t(this,`restores`,[]),o.t(this,`warnedTransport`,!1),this.ctx=e}install(){this.installed||(this.installed=!0,this.ctx.config.capture.fetch&&this.installFetch(),this.ctx.config.capture.xhr&&this.installXhr())}uninstall(){if(this.installed){this.installed=!1;for(let e of this.restores.splice(0))e()}}ignored(e){return n.t()||a.t(e,this.ctx.config.capture.ignoreUrls)}propagates(e){let t=this.ctx.config.capture.propagateTraceHeaderTo;if(t.length===0)return!1;let n=this.ctx.diagnostics.guard(`capture.header_failed`,`The library could not read the origin of a request URL. Only a RegExp target can match it.`,()=>new URL(e,location.href).origin);return t.some(t=>typeof t==`string`?t===n:t.test(e))}installFetch(){if(typeof globalThis.fetch!=`function`)return;let t=!0,n=(e,t)=>this.prepareFetch(e,t),i=(e,t,n,r,i)=>{this.record(e.method,e.url,t,n,r,e.span,e.routingContextId,i)},a=r.t(globalThis,`fetch`,r=>{let a=r.bind(globalThis);return async function(r,o){let s=t?n(r,o):void 0;if(!s)return a(r,o);let c=performance.now();try{let t=await a(s.input,s.init);return i(s,t.status,performance.now()-c,void 0,()=>t.headers.get(e.In)),t}catch(e){throw i(s,0,performance.now()-c,e),e}}});this.restores.push(()=>{t=!1,a()})}prepareFetch(e,t){let n=this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not read a fetch request. It sends the request unchanged.`,()=>{let n=m(e);if(!this.ignored(n))return{method:h(e,t),url:n,propagate:this.propagates(n)}});if(!n)return;let{method:r,url:i}=n,a={method:r,url:i,input:e,init:t,routingContextId:this.ctx.config.securityContext.id};if(!n.propagate||g(e))return a;try{let n=e instanceof Request?e.headers:void 0,r=new Headers(t?.headers??n);if(r.has(`traceparent`))return this.ctx.diagnostics.report(`capture.trace_header_kept`,`The request already has a traceparent header. The library keeps it and records no client span.`,{url:i}),a;let o=this.ctx.tracing.request();for(let[e,t]of Object.entries(o.headers))r.set(e,t);if(e instanceof Request){let n={...t,headers:r};_(t)&&(n.referrer=e.referrer,n.referrerPolicy=e.referrerPolicy),a.input=new Request(e,n),a.init=void 0}else a.init={...t,headers:r};a.span=o.span}catch(n){a.input=e,a.init=t,this.ctx.diagnostics.report(`capture.header_failed`,`The library could not add the traceparent header. It sends the request unchanged.`,{url:i},n)}return a}installXhr(){if(typeof XMLHttpRequest>`u`)return;let e=!0,t=this.ctx,n=e=>this.ignored(e),i=e=>this.propagates(e),a=(e,t,n,r)=>{this.record(e.method,e.url,t,n,void 0,e.span,e.routingContextId,r)},o=p(),s=r.t(o,`open`,n=>function(r,i,...a){e&&t.diagnostics.guard(`capture.record_failed`,`The library could not read an XMLHttpRequest. It does not record the request.`,()=>{this.__uiobs={method:v(r),url:m(i),startedAt:0}}),n.apply(this,[r,i,...a])}),l=r.t(o,`send`,r=>function(...o){let s=e?this.__uiobs:void 0;s&&t.diagnostics.guard(`capture.record_failed`,`The library could not record ${s.method} ${s.url}.`,()=>{n(s.url)||(s.startedAt=performance.now(),s.routingContextId=t.config.securityContext.id,this.addEventListener(`loadend`,()=>{a(s,this.status,performance.now()-s.startedAt,()=>c(this.getAllResponseHeaders()))},{once:!0}),i(s.url)&&(s.span=b(this,s.url,t)))}),r.apply(this,o)});this.restores.push(()=>{e=!1,s(),l()})}record(e,t,r,a,o,s,c,p){if(this.ctx.isActive?.()===!1||this.ctx.config.securityContext.isolation&&c!==void 0&&c!==this.ctx.config.securityContext.id)return;let m=this.ctx.config.capture.serverTiming&&p?this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not read the Server-Timing response header.`,()=>l(p())):void 0,h=i.i(t,this.ctx.config.capture.fullUrls,this.ctx.config.capture.urlTransform,this.ctx.diagnostics);!this.warnedTransport&&n.n()&&(this.warnedTransport=!0,this.ctx.diagnostics.report(`capture.transport_request`,`Network capture saw ${e} ${h} during a custom transport call. If the transport sends this request, add its URL to capture.ignoreUrls.`)),this.ctx.config.capture.httpMetrics&&this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not record the duration of ${e} ${h}.`,()=>{let n=f(e,t,r,o);this.ctx.recordMetric(d,a/u,n)}),s&&this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not record the span of ${e} ${h}.`,()=>{let n=Date.now();this.ctx.recordSpan({...s,link:m?.link,name:e,kind:`client`,startMs:n-a,endMs:n,error:r===0||r>=400,attributes:{...f(e,t,r,o),"url.full":h}})}),this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not record ${e} ${h}.`,()=>{let t=Math.round(a);this.ctx.breadcrumbs.push({t:Date.now(),category:`http`,message:`${e} ${h} ${r===0?`failed`:String(r)}`,data:{durationMs:t}});let n={"http.request.method":e,"url.full":h,"http.response.status_code":r,"http.duration_ms":t,...m&&m.entries.length>0?{"server.timing":m.entries}:{}};r===0?this.ctx.logger.error(`${e} ${h} failed`,o,n):r>=400?this.ctx.logger.warn(`${e} ${h} returned ${String(r)}`,n):this.ctx.logger.debug(`${e} ${h}`,n)})}};function b(e,t,n){try{let t=n.tracing.request();for(let[n,r]of Object.entries(t.headers))e.setRequestHeader(n,r);return t.span}catch(e){n.diagnostics.report(`capture.header_failed`,`The library could not add the traceparent header. It sends the request unchanged.`,{url:t},e);return}}exports.NetworkCapture=y;
2
+ //# sourceMappingURL=network-CGMLQ-mA.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network-CGMLQ-mA.cjs","names":["SERVER_TIMING_MAX_CHARS","isErrorLike","isLibraryRequest","matchesAny","patch","SERVER_TIMING_HEADER","recordedUrl","isTransportPending","require_constants","require_error_like","require_library_request","require_patch","require_platform","require_types","require_defineProperty","splitHeader","parts","start","quoted","escaped","i","text","char","separator","xhrServerTiming","headers","readServerTiming","result","header","part","rawName","params","name","entry","seen","param","equal","key","value","duration","match","MS_PER_SECOND","HTTP_DURATION","durationAttributes","base","attributes","method","url","status","error","xhrMethods","readUrl","input","readFetchMethod","requested","init","toMethod","isForeignInput","isEmptyInit","NetworkCapture","ctx","restore","targets","origin","target","active","prepare","record","plan","durationMs","readTiming","call","original","startedAt","response","read","own","trace","rebuilt","ignored","propagates","meta","proto","restoreOpen","rest","originalOpen","restoreSend","args","addTraceHeaders","originalSend","routingContextId","timing","span","endMs","rounded","xhr"],"sources":["../src/capture/server-timing.ts","../src/capture/network.ts"],"sourcesContent":["import { SERVER_TIMING_MAX_CHARS, SERVER_TIMING_MAX_ENTRIES } from \"../constants\";\n\n/** One duration entry from the Server-Timing response header. */\ninterface ServerTimingEntry {\n name: string;\n duration: number;\n description: string;\n}\n\n/** Server duration entries, plus the server span they name. */\nexport interface ServerTiming {\n entries: ServerTimingEntry[];\n link?: { traceId: string; spanId: string };\n}\n\n/** Splits a header on separators outside quoted strings. An escaped quote doesn't end a string. */\nfunction splitHeader(text: string, separator: string): string[] {\n const parts: string[] = [];\n let start = 0;\n let quoted = false;\n let escaped = false;\n\n for (let i = 0; i < text.length; i++) {\n const char = text[i];\n if (escaped) {\n escaped = false;\n } else if (quoted && char === \"\\\\\") {\n escaped = true;\n } else if (char === '\"') {\n quoted = !quoted;\n } else if (!quoted && char === separator) {\n parts.push(text.slice(start, i));\n start = i + 1;\n }\n }\n\n parts.push(text.slice(start));\n return parts;\n}\n\n/** Finds the header in an XHR header list. Reading a hidden header directly logs a Chrome error. */\nexport function xhrServerTiming(headers: string): string | null {\n return /^server-timing:(.*)$/im.exec(headers)?.[1] ?? null;\n}\n\n/** Reads a bounded number of server duration entries. A missing header gives none. */\nexport function readServerTiming(header: string | null): ServerTiming {\n const result: ServerTiming = { entries: [] };\n if (!header) {\n return result;\n }\n\n for (const part of splitHeader(header.slice(0, SERVER_TIMING_MAX_CHARS), \",\").slice(\n 0,\n SERVER_TIMING_MAX_ENTRIES,\n )) {\n const [rawName, ...params] = splitHeader(part, \";\");\n const name = rawName.trim();\n if (!/^[!#$%&'*+.^_`|~\\da-z-]+$/i.test(name)) {\n continue;\n }\n\n const entry: ServerTimingEntry = { name, duration: 0, description: \"\" };\n const seen = new Set<string>();\n for (const param of params) {\n const equal = param.indexOf(\"=\");\n if (equal < 0) {\n continue;\n }\n\n const key = param.slice(0, equal).trim().toLowerCase();\n if (seen.has(key)) {\n continue;\n }\n seen.add(key);\n\n let value = param.slice(equal + 1).trim();\n if (value.startsWith('\"') && value.endsWith('\"')) {\n value = value.slice(1, -1).replace(/\\\\(.)/g, \"$1\");\n }\n\n if (key === \"dur\") {\n const duration = Number(value);\n if (Number.isFinite(duration) && duration >= 0) {\n entry.duration = duration;\n }\n } else if (key === \"desc\") {\n entry.description = value;\n }\n }\n\n result.entries.push(entry);\n if (name.toLowerCase() === \"traceparent\") {\n const match = /^00-([\\da-f]{32})-([\\da-f]{16})-[\\da-f]{2}$/.exec(entry.description);\n if (match && /[1-9a-f]/.test(match[1]) && /[1-9a-f]/.test(match[2])) {\n result.link = { traceId: match[1], spanId: match[2] };\n }\n }\n }\n\n return result;\n}\n","// src/capture/network.ts\n//\n// Instruments fetch and XMLHttpRequest to record the outcome and timing of network requests.\n\nimport { SERVER_TIMING_HEADER, TRACEPARENT_HEADER } from \"../constants\";\nimport { readServerTiming, xhrServerTiming } from \"./server-timing\";\nimport type { InstrumentDef, MetricAttributes } from \"../models/metric\";\nimport { isErrorLike } from \"../utils/error-like\";\nimport { isLibraryRequest, isTransportPending } from \"../utils/library-request\";\nimport { patch } from \"../utils/patch\";\nimport { recordedUrl } from \"../utils/platform\";\nimport type { ClientSpan } from \"../utils/tracing\";\nimport { type Capture, type CaptureContext, matchesAny } from \"./types\";\n\n/** Signature of the global fetch function. */\ntype FetchFn = typeof fetch;\n\n/** Milliseconds in one second. The histogram is in seconds, as its OpenTelemetry name says. */\nconst MS_PER_SECOND = 1000;\n\n/**\n * The HTTP client duration histogram from the OpenTelemetry semantic conventions, with the\n * boundaries the conventions recommend.\n */\nconst HTTP_DURATION: InstrumentDef = {\n name: \"http.client.request.duration\",\n kind: \"histogram\",\n unit: \"s\",\n boundaries: [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10],\n};\n\n/**\n * Builds the low-cardinality attributes for one request. The path and the query stay out,\n * because every distinct attribute value creates a new series in the backend.\n * @param method Uppercase HTTP method.\n * @param url Request URL.\n * @param status HTTP status code, or 0 when no response came.\n * @param error What failed, for a request with no response.\n * @returns The attribute set.\n */\nfunction durationAttributes(\n method: string,\n url: string,\n status: number,\n error: unknown,\n): MetricAttributes {\n // A relative URL needs the page URL as its base. A worker has a location too.\n const base = typeof location !== \"undefined\" ? location.href : undefined;\n const attributes: MetricAttributes = {\n \"http.request.method\": method,\n \"server.address\": new URL(url, base).hostname,\n };\n\n if (status === 0) {\n // A request with no response takes its error's type, for example TypeError.\n const name = isErrorLike(error) ? error.name : \"\";\n attributes[\"error.type\"] = name === \"\" ? \"_OTHER\" : name;\n return attributes;\n }\n\n attributes[\"http.response.status_code\"] = status;\n if (status >= 400) {\n attributes[\"error.type\"] = String(status);\n }\n\n return attributes;\n}\n\n/** Request data the XHR wrapper keeps from open to send. */\ninterface XhrMeta {\n /** The delivery context when the request started. */\n routingContextId?: string;\n /** Uppercase HTTP method. */\n method: string;\n /** Request target URL. */\n url: string;\n /** Performance timestamp at send. */\n startedAt: number;\n /** The client span the traceparent names. */\n span?: ClientSpan;\n}\n\n/** An XMLHttpRequest with our tracking metadata attached. */\ntype Tracked = XMLHttpRequest & {\n __uiobs?: XhrMeta;\n};\n\n/** The XMLHttpRequest prototype methods we wrap, kept unbound. */\ninterface XhrMethods {\n open: (this: XMLHttpRequest, ...args: never[]) => void;\n send: (this: XMLHttpRequest, ...args: never[]) => void;\n}\n\n/** Returns the XMLHttpRequest prototype. */\nfunction xhrMethods(): XhrMethods {\n return XMLHttpRequest.prototype;\n}\n\n/** The fetch call to make, and the method and URL to record. */\ninterface FetchPlan {\n /** The delivery context when the request started. */\n routingContextId?: string;\n /** Uppercase HTTP method. */\n method: string;\n /** Request target URL. */\n url: string;\n /** Input to pass to the original fetch. */\n input: RequestInfo | URL;\n /** Init to pass to the original fetch. */\n init: RequestInit | undefined;\n /** The client span the traceparent names. */\n span?: ClientSpan;\n}\n\n/**\n * Reads the URL from a fetch input or an XHR URL argument.\n * A Request from another realm fails `instanceof Request`, but its `url` property still works.\n * @param input String, URL, Request, or an object with a text form.\n * @returns The URL.\n * @throws TypeError when the input has no text form. Call it inside a diagnostics guard.\n */\nfunction readUrl(input: unknown): string {\n if (typeof input === \"string\") {\n return input;\n }\n\n if (input instanceof URL) {\n return input.href;\n }\n\n if (typeof input === \"object\" && input !== null) {\n const { url } = input as { url?: unknown };\n if (typeof url === \"string\") {\n return url;\n }\n }\n\n // fetch accepts anything with a text form.\n return String(input);\n}\n\n/**\n * Reads the method of a fetch call. The init's method wins over the Request's.\n * @param input Fetch input.\n * @param init Fetch init.\n * @returns Uppercase method. Defaults to GET.\n */\nfunction readFetchMethod(input: unknown, init: RequestInit | undefined): string {\n let requested: unknown = init?.method;\n\n if (requested === undefined && typeof input === \"object\" && input !== null) {\n requested = (input as { method?: unknown }).method;\n }\n\n return toMethod(requested ?? \"GET\");\n}\n\n/**\n * Checks whether a fetch input is an object that isn't a Request or a URL from this realm,\n * for example a Request from an iframe.\n * @param input Fetch input.\n * @returns True for a foreign object.\n */\nfunction isForeignInput(input: unknown): boolean {\n return typeof input === \"object\" && !(input instanceof URL) && !(input instanceof Request);\n}\n\n/**\n * Checks whether a fetch init sets nothing, for example {}. Like fetch(request), the call\n * fetch(request, {}) keeps the Request's referrer, and any other init resets it.\n * @param init The caller's fetch init.\n * @returns True when no member has a value.\n */\nfunction isEmptyInit(init: RequestInit | undefined): boolean {\n return init === undefined || Object.values(init).every((value) => value === undefined);\n}\n\n/**\n * Converts a method argument to text. Never throws on a method that isn't a string.\n * @param method The caller's method argument.\n * @returns The uppercase method for a string, or the text form of anything else.\n */\nfunction toMethod(method: unknown): string {\n return typeof method === \"string\" ? method.toUpperCase() : String(method);\n}\n\n/** Instruments global fetch and XMLHttpRequest to capture request durations and outcomes. */\nexport class NetworkCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"network\";\n\n /** Guards against wrapping a function twice. */\n private installed = false;\n\n /** Restore functions for the installed wrappers. */\n private readonly restores: (() => void)[] = [];\n\n /** True once we've reported a request made during a custom transport call. Reported once. */\n private warnedTransport = false;\n\n /**\n * @param ctx Capture context: configuration, diagnostics, logger, breadcrumbs and tracing.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Instruments the network APIs the configuration selects. */\n install(): void {\n if (this.installed) {\n return;\n }\n this.installed = true;\n\n if (this.ctx.config.capture.fetch) {\n this.installFetch();\n }\n if (this.ctx.config.capture.xhr) {\n this.installXhr();\n }\n }\n\n /**\n * Restores every host function that still holds this capture's wrapper.\n * A wrapper that another script wrapped again stays in place and records nothing.\n */\n uninstall(): void {\n if (!this.installed) {\n return;\n }\n this.installed = false;\n\n for (const restore of this.restores.splice(0)) {\n restore();\n }\n }\n\n /**\n * Checks whether a URL matches the ignore patterns.\n * @param url Request target URL.\n * @returns True if the URL must stay out of the telemetry.\n */\n private ignored(url: string): boolean {\n // resolveConfig always adds the endpoint to ignoreUrls. Otherwise a failed POST becomes a\n // log record, the record causes a new POST, and the loop never stops.\n // A custom transport has no known URL, but its request starts inside the library scope.\n return isLibraryRequest() || matchesAny(url, this.ctx.config.capture.ignoreUrls);\n }\n\n /**\n * Checks whether a request gets the trace headers.\n * @param url Request target URL.\n * @returns True if the URL is in propagateTraceHeaderTo.\n */\n private propagates(url: string): boolean {\n // Only add headers to allowlisted URLs. A traceparent on a third-party request triggers\n // a CORS preflight that the third party doesn't answer, and its API stops working.\n const targets = this.ctx.config.capture.propagateTraceHeaderTo;\n if (targets.length === 0) {\n return false;\n }\n\n // A string target is an origin. A relative URL resolves against the page.\n const origin = this.ctx.diagnostics.guard(\n \"capture.header_failed\",\n \"The library could not read the origin of a request URL. Only a RegExp target can match it.\",\n () => new URL(url, location.href).origin,\n );\n\n return targets.some((target) =>\n typeof target === \"string\" ? target === origin : target.test(url),\n );\n }\n\n /** Wraps globalThis.fetch to inject the trace headers and log the outcome. */\n private installFetch(): void {\n if (typeof globalThis.fetch !== \"function\") {\n return;\n }\n\n // Uninstall clears the flag, so a wrapper that stays in place only calls the original.\n let active = true;\n const prepare = (input: RequestInfo | URL, init: RequestInit | undefined) =>\n this.prepareFetch(input, init);\n const record = (\n plan: FetchPlan,\n status: number,\n durationMs: number,\n error: unknown,\n readTiming?: () => string | null,\n ): void => {\n this.record(\n plan.method,\n plan.url,\n status,\n durationMs,\n error,\n plan.span,\n plan.routingContextId,\n readTiming,\n );\n };\n\n const restore = patch(globalThis, \"fetch\", (original: FetchFn) => {\n const call = original.bind(globalThis);\n\n return async function instrumentedFetch(input, init) {\n const plan = active ? prepare(input, init) : undefined;\n if (!plan) {\n return call(input, init);\n }\n\n const startedAt = performance.now();\n try {\n const response = await call(plan.input, plan.init);\n record(plan, response.status, performance.now() - startedAt, undefined, () =>\n response.headers.get(SERVER_TIMING_HEADER),\n );\n return response;\n } catch (error) {\n record(plan, 0, performance.now() - startedAt, error);\n throw error;\n }\n };\n });\n\n this.restores.push(() => {\n active = false;\n restore();\n });\n }\n\n /**\n * Reads a fetch call and adds the trace headers to an allowlisted request.\n * @param input The caller's fetch input.\n * @param init The caller's fetch init.\n * @returns The plan, or undefined to send the request unchanged and record nothing.\n */\n private prepareFetch(\n input: RequestInfo | URL,\n init: RequestInit | undefined,\n ): FetchPlan | undefined {\n // This read runs inside the caller's fetch call, so a throw must not fail the request.\n const read = this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read a fetch request. It sends the request unchanged.\",\n (): { method: string; url: string; propagate: boolean } | undefined => {\n const url = readUrl(input);\n if (this.ignored(url)) {\n return undefined;\n }\n\n return { method: readFetchMethod(input, init), url, propagate: this.propagates(url) };\n },\n );\n\n if (!read) {\n return undefined;\n }\n\n const { method, url } = read;\n const plan: FetchPlan = {\n method,\n url,\n input,\n init,\n routingContextId: this.ctx.config.securityContext.id,\n };\n // An init with headers replaces every header on a foreign Request, Authorization\n // included. So a foreign input goes out without the trace headers.\n if (!read.propagate || isForeignInput(input)) {\n return plan;\n }\n\n try {\n // fetch(request, init) builds new Request(request, init), and init.headers then replaces\n // every header the Request had. So work on the headers that actually go out.\n const own = input instanceof Request ? input.headers : undefined;\n const headers = new Headers(init?.headers ?? own);\n\n // The caller runs its own trace, for example with OpenTelemetry, so don't break it.\n if (headers.has(TRACEPARENT_HEADER)) {\n this.ctx.diagnostics.report(\n \"capture.trace_header_kept\",\n \"The request already has a traceparent header. The library keeps it and records no \" +\n \"client span.\",\n { url },\n );\n return plan;\n }\n\n const trace = this.ctx.tracing.request();\n for (const [key, value] of Object.entries(trace.headers)) {\n headers.set(key, value);\n }\n\n if (input instanceof Request) {\n const rebuilt: RequestInit = { ...init, headers };\n // Our rebuild has headers, which resets the referrer, so keep it when the caller's didn't.\n if (isEmptyInit(init)) {\n rebuilt.referrer = input.referrer;\n rebuilt.referrerPolicy = input.referrerPolicy;\n }\n\n // Build the Request once with the caller's whole init, as fetch would, and pass no init\n // next to it. Otherwise fetch builds it again and reads the body twice, which throws.\n plan.input = new Request(input, rebuilt);\n plan.init = undefined;\n } else {\n plan.init = { ...init, headers };\n }\n\n // Only record the client span for a request that actually carries its traceparent.\n plan.span = trace.span;\n } catch (error) {\n // Send exactly what the caller gave us. A missing header is better than a failed\n // request.\n plan.input = input;\n plan.init = init;\n this.ctx.diagnostics.report(\n \"capture.header_failed\",\n \"The library could not add the traceparent header. It sends the request unchanged.\",\n { url },\n error,\n );\n }\n\n return plan;\n }\n\n /** Wraps the open and send methods on the XMLHttpRequest prototype. */\n private installXhr(): void {\n if (typeof XMLHttpRequest === \"undefined\") {\n return;\n }\n\n // Uninstall clears the flag, so a wrapper that stays in place only calls the original.\n let active = true;\n const ctx = this.ctx;\n const ignored = (url: string): boolean => this.ignored(url);\n const propagates = (url: string): boolean => this.propagates(url);\n const record = (\n meta: XhrMeta,\n status: number,\n durationMs: number,\n readTiming: () => string | null,\n ): void => {\n this.record(\n meta.method,\n meta.url,\n status,\n durationMs,\n undefined,\n meta.span,\n meta.routingContextId,\n readTiming,\n );\n };\n\n const proto = xhrMethods();\n\n const restoreOpen = patch(\n proto,\n \"open\",\n (originalOpen) =>\n function (this: Tracked, method: unknown, url: unknown, ...rest: never[]) {\n if (active) {\n // This read runs inside the caller's open call, so a throw must not fail it.\n ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read an XMLHttpRequest. It does not record the request.\",\n () => {\n this.__uiobs = { method: toMethod(method), url: readUrl(url), startedAt: 0 };\n },\n );\n }\n originalOpen.apply(this, [method, url, ...rest] as never[]);\n },\n );\n\n const restoreSend = patch(\n proto,\n \"send\",\n (originalSend) =>\n function (this: Tracked, ...args: never[]) {\n const meta = active ? this.__uiobs : undefined;\n if (meta) {\n ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record ${meta.method} ${meta.url}.`,\n () => {\n if (ignored(meta.url)) {\n return;\n }\n\n meta.startedAt = performance.now();\n meta.routingContextId = ctx.config.securityContext.id;\n // A reused XHR gets a new listener on every send, so the old one must not\n // fire again.\n this.addEventListener(\n \"loadend\",\n () => {\n record(meta, this.status, performance.now() - meta.startedAt, () =>\n xhrServerTiming(this.getAllResponseHeaders()),\n );\n },\n { once: true },\n );\n\n // setRequestHeader only works between open and send.\n if (propagates(meta.url)) {\n meta.span = addTraceHeaders(this, meta.url, ctx);\n }\n },\n );\n }\n originalSend.apply(this, args);\n },\n );\n\n this.restores.push(() => {\n active = false;\n restoreOpen();\n restoreSend();\n });\n }\n\n /**\n * Records the outcome of a request as attributes and a breadcrumb.\n * @param method Uppercase HTTP method.\n * @param target Request target URL. The query is removed here unless you set fullUrls.\n * @param status HTTP response status code, or 0 on failure.\n * @param durationMs Request duration in milliseconds.\n * @param error The caught error, for a failed request.\n * @param span The client span the request's traceparent names.\n */\n private record(\n method: string,\n target: string,\n status: number,\n durationMs: number,\n error: unknown,\n span?: ClientSpan,\n routingContextId?: string,\n readTiming?: () => string | null,\n ): void {\n if (\n this.ctx.isActive?.() === false ||\n (this.ctx.config.securityContext.isolation &&\n routingContextId !== undefined &&\n routingContextId !== this.ctx.config.securityContext.id)\n ) {\n return;\n }\n\n const timing =\n this.ctx.config.capture.serverTiming && readTiming\n ? this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read the Server-Timing response header.\",\n () => readServerTiming(readTiming()),\n )\n : undefined;\n\n // Strip the query here, not at the call sites. ignoreUrls and propagateTraceHeaderTo\n // match on the full URL, and only the recorded URL loses its query string.\n const url = recordedUrl(\n target,\n this.ctx.config.capture.fullUrls,\n this.ctx.config.capture.urlTransform,\n this.ctx.diagnostics,\n );\n\n // A transport request made after an await gets recorded, and that record causes the next\n // send.\n if (!this.warnedTransport && isTransportPending()) {\n this.warnedTransport = true;\n this.ctx.diagnostics.report(\n \"capture.transport_request\",\n `Network capture saw ${method} ${url} during a custom transport call. If the transport sends this request, add its URL to capture.ignoreUrls.`,\n );\n }\n\n // The histogram has its own guard, so a URL that doesn't parse can't stop the record.\n if (this.ctx.config.capture.httpMetrics) {\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record the duration of ${method} ${url}.`,\n () => {\n const attributes = durationAttributes(method, target, status, error);\n this.ctx.recordMetric(HTTP_DURATION, durationMs / MS_PER_SECOND, attributes);\n },\n );\n }\n\n if (span) {\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record the span of ${method} ${url}.`,\n () => {\n const endMs = Date.now();\n this.ctx.recordSpan({\n ...span,\n link: timing?.link,\n name: method,\n kind: \"client\",\n startMs: endMs - durationMs,\n endMs,\n error: status === 0 || status >= 400,\n attributes: { ...durationAttributes(method, target, status, error), \"url.full\": url },\n });\n },\n );\n }\n\n // This runs inside the caller's fetch call, so an error here must not fail the caller's\n // request.\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record ${method} ${url}.`,\n () => {\n const rounded = Math.round(durationMs);\n\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"http\",\n message: `${method} ${url} ${status === 0 ? \"failed\" : String(status)}`,\n data: { durationMs: rounded },\n });\n\n const attributes = {\n \"http.request.method\": method,\n \"url.full\": url,\n \"http.response.status_code\": status,\n \"http.duration_ms\": rounded,\n ...(timing && timing.entries.length > 0 ? { \"server.timing\": timing.entries } : {}),\n };\n\n if (status === 0) {\n this.ctx.logger.error(`${method} ${url} failed`, error, attributes);\n return;\n }\n if (status >= 400) {\n this.ctx.logger.warn(`${method} ${url} returned ${String(status)}`, attributes);\n return;\n }\n\n // Log a success at DEBUG, which the default minLevel of INFO drops. That way only\n // failures use bandwidth.\n this.ctx.logger.debug(`${method} ${url}`, attributes);\n },\n );\n }\n}\n\n/**\n * Adds the trace headers to an open XHR. If that fails, the request goes out without them.\n * @param xhr A request between open and send.\n * @param url Request target URL, for the diagnostic.\n * @param ctx Capture context with tracing and diagnostics.\n * @returns The client span the traceparent names, or undefined.\n */\nfunction addTraceHeaders(\n xhr: XMLHttpRequest,\n url: string,\n ctx: CaptureContext,\n): ClientSpan | undefined {\n try {\n const trace = ctx.tracing.request();\n for (const [key, value] of Object.entries(trace.headers)) {\n xhr.setRequestHeader(key, value);\n }\n return trace.span;\n } catch (error) {\n ctx.diagnostics.report(\n \"capture.header_failed\",\n \"The library could not add the traceparent header. It sends the request unchanged.\",\n { url },\n error,\n );\n return undefined;\n }\n}\n"],"mappings":"A,mRAgBA,SAASe,EAAY,EAAc,EAA6B,CAC9D,IAAMC,EAAkB,CAAC,EACrBC,EAAQ,EACRC,EAAS,GACTC,EAAU,GAEd,IAAK,IAAIC,EAAI,EAAGA,EAAIC,EAAK,OAAQ,IAAK,CACpC,IAAMC,EAAOD,EAAKD,GACdD,EACF,EAAU,GACDD,GAAUI,IAAS,KAC5B,EAAU,GACDA,IAAS,IAClB,EAAS,CAACJ,EACD,CAACA,GAAUI,IAASC,IAC7BP,EAAM,KAAKK,EAAK,MAAMJ,EAAOG,CAAC,CAAC,EAC/B,EAAQA,EAAI,EAEhB,CAGA,OADAJ,EAAM,KAAKK,EAAK,MAAMJ,CAAK,CAAC,EACrBD,CACT,CAGA,SAAgBQ,EAAgB,EAAgC,CAC9D,MAAO,yBAAyB,KAAKC,CAAO,CAAC,GAAG,IAAM,IACxD,CAGA,SAAgBC,EAAiB,EAAqC,CACpE,IAAMC,EAAuB,CAAE,QAAS,CAAC,CAAE,EAC3C,GAAI,CAACC,EACH,OAAOD,EAGT,IAAK,IAAME,KAAQd,EAAYa,EAAO,MAAM,EAAG5B,EAAAA,EAAuB,EAAG,GAAG,CAAC,CAAC,MAC5E,EAAA,EAEF,EAAG,CACD,GAAM,CAAC8B,EAAS,GAAGC,GAAUhB,EAAYc,EAAM,GAAG,EAC5CG,EAAOF,EAAQ,KAAK,EAC1B,GAAI,CAAC,6BAA6B,KAAKE,CAAI,EACzC,SAGF,IAAMC,EAA2B,CAAE,OAAM,SAA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,OAAO,MAAM,GAAGC,EAAO,GAAGC,IAAOF,CAAU,CACtD,CACF,CACF,CACF,EASA,SAAS2C,EACP,EACA,EACA,EACwB,CACxB,GAAI,CACF,IAAMX,EAAQjB,EAAI,QAAQ,QAAQ,EAClC,IAAK,GAAM,CAACvB,EAAKC,KAAU,OAAO,QAAQuC,EAAM,OAAO,EACrDkB,EAAI,iBAAiB1D,EAAKC,CAAK,EAEjC,OAAOuC,EAAM,IACf,OAAS5B,EAAO,CACdW,EAAI,YAAY,OACd,wBACA,oFACA,CAAE,KAAI,EACNX,CACF,EACA,MACF,CACF,C"}
@@ -1,11 +1,12 @@
1
- import { gn as e, hn as t } from "./constants-zyrqveN4.js";
1
+ import { In as e, Ln as t } from "./constants-CUyd9cTZ.js";
2
2
  import { r as n } from "./error-like-B11pB4aL.js";
3
- import { n as r, t as i } from "./library-request-BQBT9N9Q.js";
3
+ import { n as r, t as i } from "./library-request-BJ9PLRaD.js";
4
4
  import { t as a } from "./patch-UdPz1ea8.js";
5
- import { i as o } from "./platform-DkcuXwe-.js";
5
+ import { i as o } from "./platform-BaaFIPCU.js";
6
6
  import { t as s } from "./types-BAerHgCq.js";
7
+ import { t as c } from "./defineProperty-s2S8BXUc.js";
7
8
  // src/capture/server-timing.ts
8
- function c(e, t) {
9
+ function l(e, t) {
9
10
  let n = [], r = 0, i = !1, a = !1;
10
11
  for (let o = 0; o < e.length; o++) {
11
12
  let s = e[o];
@@ -13,14 +14,14 @@ function c(e, t) {
13
14
  }
14
15
  return n.push(e.slice(r)), n;
15
16
  }
16
- function l(e) {
17
+ function u(e) {
17
18
  return /^server-timing:(.*)$/im.exec(e)?.[1] ?? null;
18
19
  }
19
- function u(t) {
20
+ function d(e) {
20
21
  let n = { entries: [] };
21
- if (!t) return n;
22
- for (let r of c(t.slice(0, e), ",").slice(0, 32)) {
23
- let [e, ...t] = c(r, ";"), i = e.trim();
22
+ if (!e) return n;
23
+ for (let r of l(e.slice(0, t), ",").slice(0, 32)) {
24
+ let [e, ...t] = l(r, ";"), i = e.trim();
24
25
  if (!/^[!#$%&'*+.^_`|~\da-z-]+$/i.test(i)) continue;
25
26
  let a = {
26
27
  name: i,
@@ -50,7 +51,7 @@ function u(t) {
50
51
  return n;
51
52
  }
52
53
  // src/capture/network.ts
53
- var d = 1e3, f = {
54
+ var f = 1e3, p = {
54
55
  name: "http.client.request.duration",
55
56
  kind: "histogram",
56
57
  unit: "s",
@@ -71,7 +72,7 @@ var d = 1e3, f = {
71
72
  10
72
73
  ]
73
74
  };
74
- function p(e, t, r, i) {
75
+ function m(e, t, r, i) {
75
76
  let a = typeof location < "u" ? location.href : void 0, o = {
76
77
  "http.request.method": e,
77
78
  "server.address": new URL(t, a).hostname
@@ -82,10 +83,10 @@ function p(e, t, r, i) {
82
83
  }
83
84
  return o["http.response.status_code"] = r, r >= 400 && (o["error.type"] = String(r)), o;
84
85
  }
85
- function m() {
86
+ function h() {
86
87
  return XMLHttpRequest.prototype;
87
88
  }
88
- function h(e) {
89
+ function g(e) {
89
90
  if (typeof e == "string") return e;
90
91
  if (e instanceof URL) return e.href;
91
92
  if (typeof e == "object" && e) {
@@ -94,24 +95,22 @@ function h(e) {
94
95
  }
95
96
  return String(e);
96
97
  }
97
- function g(e, t) {
98
+ function _(e, t) {
98
99
  let n = t?.method;
99
- return n === void 0 && typeof e == "object" && e && (n = e.method), v(n ?? "GET");
100
+ return n === void 0 && typeof e == "object" && e && (n = e.method), b(n ?? "GET");
100
101
  }
101
- function _(e) {
102
+ function v(e) {
102
103
  return typeof e == "object" && !(e instanceof URL) && !(e instanceof Request);
103
104
  }
104
- function v(e) {
105
+ function y(e) {
106
+ return e === void 0 || Object.values(e).every((e) => e === void 0);
107
+ }
108
+ function b(e) {
105
109
  return typeof e == "string" ? e.toUpperCase() : String(e);
106
110
  }
107
- var y = class {
108
- ctx;
109
- name = "network";
110
- installed = !1;
111
- restores = [];
112
- warnedTransport = !1;
111
+ var x = class {
113
112
  constructor(e) {
114
- this.ctx = e;
113
+ c(this, "ctx", void 0), c(this, "name", "network"), c(this, "installed", !1), c(this, "restores", []), c(this, "warnedTransport", !1), this.ctx = e;
115
114
  }
116
115
  install() {
117
116
  this.installed || (this.installed = !0, this.ctx.config.capture.fetch && this.installFetch(), this.ctx.config.capture.xhr && this.installXhr());
@@ -133,31 +132,31 @@ var y = class {
133
132
  }
134
133
  installFetch() {
135
134
  if (typeof globalThis.fetch != "function") return;
136
- let e = !0, n = (e, t) => this.prepareFetch(e, t), r = (e, t, n, r, i) => {
135
+ let t = !0, n = (e, t) => this.prepareFetch(e, t), r = (e, t, n, r, i) => {
137
136
  this.record(e.method, e.url, t, n, r, e.span, e.routingContextId, i);
138
137
  }, i = a(globalThis, "fetch", (i) => {
139
138
  let a = i.bind(globalThis);
140
139
  return async function(i, o) {
141
- let s = e ? n(i, o) : void 0;
140
+ let s = t ? n(i, o) : void 0;
142
141
  if (!s) return a(i, o);
143
142
  let c = performance.now();
144
143
  try {
145
- let e = await a(s.input, s.init);
146
- return r(s, e.status, performance.now() - c, void 0, () => e.headers.get(t)), e;
144
+ let t = await a(s.input, s.init);
145
+ return r(s, t.status, performance.now() - c, void 0, () => t.headers.get(e)), t;
147
146
  } catch (e) {
148
147
  throw r(s, 0, performance.now() - c, e), e;
149
148
  }
150
149
  };
151
150
  });
152
151
  this.restores.push(() => {
153
- e = !1, i();
152
+ t = !1, i();
154
153
  });
155
154
  }
156
155
  prepareFetch(e, t) {
157
156
  let n = this.ctx.diagnostics.guard("capture.record_failed", "The library could not read a fetch request. It sends the request unchanged.", () => {
158
- let n = h(e);
157
+ let n = g(e);
159
158
  if (!this.ignored(n)) return {
160
- method: g(e, t),
159
+ method: _(e, t),
161
160
  url: n,
162
161
  propagate: this.propagates(n)
163
162
  };
@@ -170,22 +169,23 @@ var y = class {
170
169
  init: t,
171
170
  routingContextId: this.ctx.config.securityContext.id
172
171
  };
173
- if (!n.propagate || _(e)) return a;
172
+ if (!n.propagate || v(e)) return a;
174
173
  try {
175
- let n = this.ctx.tracing.request(), r = Object.entries(n.headers);
174
+ let n = e instanceof Request ? e.headers : void 0, r = new Headers(t?.headers ?? n);
175
+ if (r.has("traceparent")) return this.ctx.diagnostics.report("capture.trace_header_kept", "The request already has a traceparent header. The library keeps it and records no client span.", { url: i }), a;
176
+ let o = this.ctx.tracing.request();
177
+ for (let [e, t] of Object.entries(o.headers)) r.set(e, t);
176
178
  if (e instanceof Request) {
177
- let t = new Headers(e.headers);
178
- for (let [e, n] of r) t.set(e, n);
179
- a.input = new Request(e, { headers: t });
180
- } else {
181
- let e = new Headers(t?.headers);
182
- for (let [t, n] of r) e.set(t, n);
183
- a.init = {
179
+ let n = {
184
180
  ...t,
185
- headers: e
181
+ headers: r
186
182
  };
187
- }
188
- a.span = n.span;
183
+ y(t) && (n.referrer = e.referrer, n.referrerPolicy = e.referrerPolicy), a.input = new Request(e, n), a.init = void 0;
184
+ } else a.init = {
185
+ ...t,
186
+ headers: r
187
+ };
188
+ a.span = o.span;
189
189
  } catch (n) {
190
190
  a.input = e, a.init = t, this.ctx.diagnostics.report("capture.header_failed", "The library could not add the traceparent header. It sends the request unchanged.", { url: i }, n);
191
191
  }
@@ -195,11 +195,11 @@ var y = class {
195
195
  if (typeof XMLHttpRequest > "u") return;
196
196
  let e = !0, t = this.ctx, n = (e) => this.ignored(e), r = (e) => this.propagates(e), i = (e, t, n, r) => {
197
197
  this.record(e.method, e.url, t, n, void 0, e.span, e.routingContextId, r);
198
- }, o = m(), s = a(o, "open", (n) => function(r, i, ...a) {
198
+ }, o = h(), s = a(o, "open", (n) => function(r, i, ...a) {
199
199
  e && t.diagnostics.guard("capture.record_failed", "The library could not read an XMLHttpRequest. It does not record the request.", () => {
200
200
  this.__uiobs = {
201
- method: v(r),
202
- url: h(i),
201
+ method: b(r),
202
+ url: g(i),
203
203
  startedAt: 0
204
204
  };
205
205
  }), n.apply(this, [
@@ -211,8 +211,8 @@ var y = class {
211
211
  let s = e ? this.__uiobs : void 0;
212
212
  s && t.diagnostics.guard("capture.record_failed", `The library could not record ${s.method} ${s.url}.`, () => {
213
213
  n(s.url) || (s.startedAt = performance.now(), s.routingContextId = t.config.securityContext.id, this.addEventListener("loadend", () => {
214
- i(s, this.status, performance.now() - s.startedAt, () => l(this.getAllResponseHeaders()));
215
- }, { once: !0 }), r(s.url) && (s.span = b(this, s.url, t)));
214
+ i(s, this.status, performance.now() - s.startedAt, () => u(this.getAllResponseHeaders()));
215
+ }, { once: !0 }), r(s.url) && (s.span = S(this, s.url, t)));
216
216
  }), a.apply(this, o);
217
217
  });
218
218
  this.restores.push(() => {
@@ -221,22 +221,22 @@ var y = class {
221
221
  }
222
222
  record(e, t, n, i, a, s, c, l) {
223
223
  if (this.ctx.isActive?.() === !1 || this.ctx.config.securityContext.isolation && c !== void 0 && c !== this.ctx.config.securityContext.id) return;
224
- let m = this.ctx.config.capture.serverTiming && l ? this.ctx.diagnostics.guard("capture.record_failed", "The library could not read the Server-Timing response header.", () => u(l())) : void 0, h = o(t, this.ctx.config.capture.fullUrls, this.ctx.config.capture.urlTransform, this.ctx.diagnostics);
224
+ let u = this.ctx.config.capture.serverTiming && l ? this.ctx.diagnostics.guard("capture.record_failed", "The library could not read the Server-Timing response header.", () => d(l())) : void 0, h = o(t, this.ctx.config.capture.fullUrls, this.ctx.config.capture.urlTransform, this.ctx.diagnostics);
225
225
  !this.warnedTransport && r() && (this.warnedTransport = !0, this.ctx.diagnostics.report("capture.transport_request", `Network capture saw ${e} ${h} during a custom transport call. If the transport sends this request, add its URL to capture.ignoreUrls.`)), this.ctx.config.capture.httpMetrics && this.ctx.diagnostics.guard("capture.record_failed", `The library could not record the duration of ${e} ${h}.`, () => {
226
- let r = p(e, t, n, a);
227
- this.ctx.recordMetric(f, i / d, r);
226
+ let r = m(e, t, n, a);
227
+ this.ctx.recordMetric(p, i / f, r);
228
228
  }), s && this.ctx.diagnostics.guard("capture.record_failed", `The library could not record the span of ${e} ${h}.`, () => {
229
229
  let r = Date.now();
230
230
  this.ctx.recordSpan({
231
231
  ...s,
232
- link: m?.link,
232
+ link: u?.link,
233
233
  name: e,
234
234
  kind: "client",
235
235
  startMs: r - i,
236
236
  endMs: r,
237
237
  error: n === 0 || n >= 400,
238
238
  attributes: {
239
- ...p(e, t, n, a),
239
+ ...m(e, t, n, a),
240
240
  "url.full": h
241
241
  }
242
242
  });
@@ -253,13 +253,13 @@ var y = class {
253
253
  "url.full": h,
254
254
  "http.response.status_code": n,
255
255
  "http.duration_ms": t,
256
- ...m && m.entries.length > 0 ? { "server.timing": m.entries } : {}
256
+ ...u && u.entries.length > 0 ? { "server.timing": u.entries } : {}
257
257
  };
258
258
  n === 0 ? this.ctx.logger.error(`${e} ${h} failed`, a, r) : n >= 400 ? this.ctx.logger.warn(`${e} ${h} returned ${String(n)}`, r) : this.ctx.logger.debug(`${e} ${h}`, r);
259
259
  });
260
260
  }
261
261
  };
262
- function b(e, t, n) {
262
+ function S(e, t, n) {
263
263
  try {
264
264
  let t = n.tracing.request();
265
265
  for (let [n, r] of Object.entries(t.headers)) e.setRequestHeader(n, r);
@@ -269,6 +269,6 @@ function b(e, t, n) {
269
269
  return;
270
270
  }
271
271
  }
272
- export { y as NetworkCapture };
272
+ export { x as NetworkCapture };
273
273
 
274
- //# sourceMappingURL=network-DBNwApoF.js.map
274
+ //# sourceMappingURL=network-on2zZT6H.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network-on2zZT6H.js","names":["SERVER_TIMING_HEADER","SERVER_TIMING_MAX_CHARS","isErrorLike","isTransportPending","isLibraryRequest","patch","recordedUrl","matchesAny","_defineProperty","splitHeader","parts","start","quoted","escaped","i","text","char","separator","xhrServerTiming","headers","readServerTiming","result","header","part","rawName","params","name","entry","seen","param","equal","key","value","duration","match","MS_PER_SECOND","HTTP_DURATION","durationAttributes","base","attributes","method","url","status","error","xhrMethods","readUrl","input","readFetchMethod","requested","init","toMethod","isForeignInput","isEmptyInit","NetworkCapture","ctx","restore","targets","origin","target","active","prepare","record","plan","durationMs","readTiming","call","original","startedAt","response","read","own","trace","rebuilt","ignored","propagates","meta","proto","restoreOpen","rest","originalOpen","restoreSend","args","addTraceHeaders","originalSend","routingContextId","timing","span","endMs","rounded"],"sources":["../src/capture/server-timing.ts","../src/capture/network.ts"],"sourcesContent":["import { SERVER_TIMING_MAX_CHARS, SERVER_TIMING_MAX_ENTRIES } from \"../constants\";\n\n/** One duration entry from the Server-Timing response header. */\ninterface ServerTimingEntry {\n name: string;\n duration: number;\n description: string;\n}\n\n/** Server duration entries, plus the server span they name. */\nexport interface ServerTiming {\n entries: ServerTimingEntry[];\n link?: { traceId: string; spanId: string };\n}\n\n/** Splits a header on separators outside quoted strings. An escaped quote doesn't end a string. */\nfunction splitHeader(text: string, separator: string): string[] {\n const parts: string[] = [];\n let start = 0;\n let quoted = false;\n let escaped = false;\n\n for (let i = 0; i < text.length; i++) {\n const char = text[i];\n if (escaped) {\n escaped = false;\n } else if (quoted && char === \"\\\\\") {\n escaped = true;\n } else if (char === '\"') {\n quoted = !quoted;\n } else if (!quoted && char === separator) {\n parts.push(text.slice(start, i));\n start = i + 1;\n }\n }\n\n parts.push(text.slice(start));\n return parts;\n}\n\n/** Finds the header in an XHR header list. Reading a hidden header directly logs a Chrome error. */\nexport function xhrServerTiming(headers: string): string | null {\n return /^server-timing:(.*)$/im.exec(headers)?.[1] ?? null;\n}\n\n/** Reads a bounded number of server duration entries. A missing header gives none. */\nexport function readServerTiming(header: string | null): ServerTiming {\n const result: ServerTiming = { entries: [] };\n if (!header) {\n return result;\n }\n\n for (const part of splitHeader(header.slice(0, SERVER_TIMING_MAX_CHARS), \",\").slice(\n 0,\n SERVER_TIMING_MAX_ENTRIES,\n )) {\n const [rawName, ...params] = splitHeader(part, \";\");\n const name = rawName.trim();\n if (!/^[!#$%&'*+.^_`|~\\da-z-]+$/i.test(name)) {\n continue;\n }\n\n const entry: ServerTimingEntry = { name, duration: 0, description: \"\" };\n const seen = new Set<string>();\n for (const param of params) {\n const equal = param.indexOf(\"=\");\n if (equal < 0) {\n continue;\n }\n\n const key = param.slice(0, equal).trim().toLowerCase();\n if (seen.has(key)) {\n continue;\n }\n seen.add(key);\n\n let value = param.slice(equal + 1).trim();\n if (value.startsWith('\"') && value.endsWith('\"')) {\n value = value.slice(1, -1).replace(/\\\\(.)/g, \"$1\");\n }\n\n if (key === \"dur\") {\n const duration = Number(value);\n if (Number.isFinite(duration) && duration >= 0) {\n entry.duration = duration;\n }\n } else if (key === \"desc\") {\n entry.description = value;\n }\n }\n\n result.entries.push(entry);\n if (name.toLowerCase() === \"traceparent\") {\n const match = /^00-([\\da-f]{32})-([\\da-f]{16})-[\\da-f]{2}$/.exec(entry.description);\n if (match && /[1-9a-f]/.test(match[1]) && /[1-9a-f]/.test(match[2])) {\n result.link = { traceId: match[1], spanId: match[2] };\n }\n }\n }\n\n return result;\n}\n","// src/capture/network.ts\n//\n// Instruments fetch and XMLHttpRequest to record the outcome and timing of network requests.\n\nimport { SERVER_TIMING_HEADER, TRACEPARENT_HEADER } from \"../constants\";\nimport { readServerTiming, xhrServerTiming } from \"./server-timing\";\nimport type { InstrumentDef, MetricAttributes } from \"../models/metric\";\nimport { isErrorLike } from \"../utils/error-like\";\nimport { isLibraryRequest, isTransportPending } from \"../utils/library-request\";\nimport { patch } from \"../utils/patch\";\nimport { recordedUrl } from \"../utils/platform\";\nimport type { ClientSpan } from \"../utils/tracing\";\nimport { type Capture, type CaptureContext, matchesAny } from \"./types\";\n\n/** Signature of the global fetch function. */\ntype FetchFn = typeof fetch;\n\n/** Milliseconds in one second. The histogram is in seconds, as its OpenTelemetry name says. */\nconst MS_PER_SECOND = 1000;\n\n/**\n * The HTTP client duration histogram from the OpenTelemetry semantic conventions, with the\n * boundaries the conventions recommend.\n */\nconst HTTP_DURATION: InstrumentDef = {\n name: \"http.client.request.duration\",\n kind: \"histogram\",\n unit: \"s\",\n boundaries: [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10],\n};\n\n/**\n * Builds the low-cardinality attributes for one request. The path and the query stay out,\n * because every distinct attribute value creates a new series in the backend.\n * @param method Uppercase HTTP method.\n * @param url Request URL.\n * @param status HTTP status code, or 0 when no response came.\n * @param error What failed, for a request with no response.\n * @returns The attribute set.\n */\nfunction durationAttributes(\n method: string,\n url: string,\n status: number,\n error: unknown,\n): MetricAttributes {\n // A relative URL needs the page URL as its base. A worker has a location too.\n const base = typeof location !== \"undefined\" ? location.href : undefined;\n const attributes: MetricAttributes = {\n \"http.request.method\": method,\n \"server.address\": new URL(url, base).hostname,\n };\n\n if (status === 0) {\n // A request with no response takes its error's type, for example TypeError.\n const name = isErrorLike(error) ? error.name : \"\";\n attributes[\"error.type\"] = name === \"\" ? \"_OTHER\" : name;\n return attributes;\n }\n\n attributes[\"http.response.status_code\"] = status;\n if (status >= 400) {\n attributes[\"error.type\"] = String(status);\n }\n\n return attributes;\n}\n\n/** Request data the XHR wrapper keeps from open to send. */\ninterface XhrMeta {\n /** The delivery context when the request started. */\n routingContextId?: string;\n /** Uppercase HTTP method. */\n method: string;\n /** Request target URL. */\n url: string;\n /** Performance timestamp at send. */\n startedAt: number;\n /** The client span the traceparent names. */\n span?: ClientSpan;\n}\n\n/** An XMLHttpRequest with our tracking metadata attached. */\ntype Tracked = XMLHttpRequest & {\n __uiobs?: XhrMeta;\n};\n\n/** The XMLHttpRequest prototype methods we wrap, kept unbound. */\ninterface XhrMethods {\n open: (this: XMLHttpRequest, ...args: never[]) => void;\n send: (this: XMLHttpRequest, ...args: never[]) => void;\n}\n\n/** Returns the XMLHttpRequest prototype. */\nfunction xhrMethods(): XhrMethods {\n return XMLHttpRequest.prototype;\n}\n\n/** The fetch call to make, and the method and URL to record. */\ninterface FetchPlan {\n /** The delivery context when the request started. */\n routingContextId?: string;\n /** Uppercase HTTP method. */\n method: string;\n /** Request target URL. */\n url: string;\n /** Input to pass to the original fetch. */\n input: RequestInfo | URL;\n /** Init to pass to the original fetch. */\n init: RequestInit | undefined;\n /** The client span the traceparent names. */\n span?: ClientSpan;\n}\n\n/**\n * Reads the URL from a fetch input or an XHR URL argument.\n * A Request from another realm fails `instanceof Request`, but its `url` property still works.\n * @param input String, URL, Request, or an object with a text form.\n * @returns The URL.\n * @throws TypeError when the input has no text form. Call it inside a diagnostics guard.\n */\nfunction readUrl(input: unknown): string {\n if (typeof input === \"string\") {\n return input;\n }\n\n if (input instanceof URL) {\n return input.href;\n }\n\n if (typeof input === \"object\" && input !== null) {\n const { url } = input as { url?: unknown };\n if (typeof url === \"string\") {\n return url;\n }\n }\n\n // fetch accepts anything with a text form.\n return String(input);\n}\n\n/**\n * Reads the method of a fetch call. The init's method wins over the Request's.\n * @param input Fetch input.\n * @param init Fetch init.\n * @returns Uppercase method. Defaults to GET.\n */\nfunction readFetchMethod(input: unknown, init: RequestInit | undefined): string {\n let requested: unknown = init?.method;\n\n if (requested === undefined && typeof input === \"object\" && input !== null) {\n requested = (input as { method?: unknown }).method;\n }\n\n return toMethod(requested ?? \"GET\");\n}\n\n/**\n * Checks whether a fetch input is an object that isn't a Request or a URL from this realm,\n * for example a Request from an iframe.\n * @param input Fetch input.\n * @returns True for a foreign object.\n */\nfunction isForeignInput(input: unknown): boolean {\n return typeof input === \"object\" && !(input instanceof URL) && !(input instanceof Request);\n}\n\n/**\n * Checks whether a fetch init sets nothing, for example {}. Like fetch(request), the call\n * fetch(request, {}) keeps the Request's referrer, and any other init resets it.\n * @param init The caller's fetch init.\n * @returns True when no member has a value.\n */\nfunction isEmptyInit(init: RequestInit | undefined): boolean {\n return init === undefined || Object.values(init).every((value) => value === undefined);\n}\n\n/**\n * Converts a method argument to text. Never throws on a method that isn't a string.\n * @param method The caller's method argument.\n * @returns The uppercase method for a string, or the text form of anything else.\n */\nfunction toMethod(method: unknown): string {\n return typeof method === \"string\" ? method.toUpperCase() : String(method);\n}\n\n/** Instruments global fetch and XMLHttpRequest to capture request durations and outcomes. */\nexport class NetworkCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"network\";\n\n /** Guards against wrapping a function twice. */\n private installed = false;\n\n /** Restore functions for the installed wrappers. */\n private readonly restores: (() => void)[] = [];\n\n /** True once we've reported a request made during a custom transport call. Reported once. */\n private warnedTransport = false;\n\n /**\n * @param ctx Capture context: configuration, diagnostics, logger, breadcrumbs and tracing.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Instruments the network APIs the configuration selects. */\n install(): void {\n if (this.installed) {\n return;\n }\n this.installed = true;\n\n if (this.ctx.config.capture.fetch) {\n this.installFetch();\n }\n if (this.ctx.config.capture.xhr) {\n this.installXhr();\n }\n }\n\n /**\n * Restores every host function that still holds this capture's wrapper.\n * A wrapper that another script wrapped again stays in place and records nothing.\n */\n uninstall(): void {\n if (!this.installed) {\n return;\n }\n this.installed = false;\n\n for (const restore of this.restores.splice(0)) {\n restore();\n }\n }\n\n /**\n * Checks whether a URL matches the ignore patterns.\n * @param url Request target URL.\n * @returns True if the URL must stay out of the telemetry.\n */\n private ignored(url: string): boolean {\n // resolveConfig always adds the endpoint to ignoreUrls. Otherwise a failed POST becomes a\n // log record, the record causes a new POST, and the loop never stops.\n // A custom transport has no known URL, but its request starts inside the library scope.\n return isLibraryRequest() || matchesAny(url, this.ctx.config.capture.ignoreUrls);\n }\n\n /**\n * Checks whether a request gets the trace headers.\n * @param url Request target URL.\n * @returns True if the URL is in propagateTraceHeaderTo.\n */\n private propagates(url: string): boolean {\n // Only add headers to allowlisted URLs. A traceparent on a third-party request triggers\n // a CORS preflight that the third party doesn't answer, and its API stops working.\n const targets = this.ctx.config.capture.propagateTraceHeaderTo;\n if (targets.length === 0) {\n return false;\n }\n\n // A string target is an origin. A relative URL resolves against the page.\n const origin = this.ctx.diagnostics.guard(\n \"capture.header_failed\",\n \"The library could not read the origin of a request URL. Only a RegExp target can match it.\",\n () => new URL(url, location.href).origin,\n );\n\n return targets.some((target) =>\n typeof target === \"string\" ? target === origin : target.test(url),\n );\n }\n\n /** Wraps globalThis.fetch to inject the trace headers and log the outcome. */\n private installFetch(): void {\n if (typeof globalThis.fetch !== \"function\") {\n return;\n }\n\n // Uninstall clears the flag, so a wrapper that stays in place only calls the original.\n let active = true;\n const prepare = (input: RequestInfo | URL, init: RequestInit | undefined) =>\n this.prepareFetch(input, init);\n const record = (\n plan: FetchPlan,\n status: number,\n durationMs: number,\n error: unknown,\n readTiming?: () => string | null,\n ): void => {\n this.record(\n plan.method,\n plan.url,\n status,\n durationMs,\n error,\n plan.span,\n plan.routingContextId,\n readTiming,\n );\n };\n\n const restore = patch(globalThis, \"fetch\", (original: FetchFn) => {\n const call = original.bind(globalThis);\n\n return async function instrumentedFetch(input, init) {\n const plan = active ? prepare(input, init) : undefined;\n if (!plan) {\n return call(input, init);\n }\n\n const startedAt = performance.now();\n try {\n const response = await call(plan.input, plan.init);\n record(plan, response.status, performance.now() - startedAt, undefined, () =>\n response.headers.get(SERVER_TIMING_HEADER),\n );\n return response;\n } catch (error) {\n record(plan, 0, performance.now() - startedAt, error);\n throw error;\n }\n };\n });\n\n this.restores.push(() => {\n active = false;\n restore();\n });\n }\n\n /**\n * Reads a fetch call and adds the trace headers to an allowlisted request.\n * @param input The caller's fetch input.\n * @param init The caller's fetch init.\n * @returns The plan, or undefined to send the request unchanged and record nothing.\n */\n private prepareFetch(\n input: RequestInfo | URL,\n init: RequestInit | undefined,\n ): FetchPlan | undefined {\n // This read runs inside the caller's fetch call, so a throw must not fail the request.\n const read = this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read a fetch request. It sends the request unchanged.\",\n (): { method: string; url: string; propagate: boolean } | undefined => {\n const url = readUrl(input);\n if (this.ignored(url)) {\n return undefined;\n }\n\n return { method: readFetchMethod(input, init), url, propagate: this.propagates(url) };\n },\n );\n\n if (!read) {\n return undefined;\n }\n\n const { method, url } = read;\n const plan: FetchPlan = {\n method,\n url,\n input,\n init,\n routingContextId: this.ctx.config.securityContext.id,\n };\n // An init with headers replaces every header on a foreign Request, Authorization\n // included. So a foreign input goes out without the trace headers.\n if (!read.propagate || isForeignInput(input)) {\n return plan;\n }\n\n try {\n // fetch(request, init) builds new Request(request, init), and init.headers then replaces\n // every header the Request had. So work on the headers that actually go out.\n const own = input instanceof Request ? input.headers : undefined;\n const headers = new Headers(init?.headers ?? own);\n\n // The caller runs its own trace, for example with OpenTelemetry, so don't break it.\n if (headers.has(TRACEPARENT_HEADER)) {\n this.ctx.diagnostics.report(\n \"capture.trace_header_kept\",\n \"The request already has a traceparent header. The library keeps it and records no \" +\n \"client span.\",\n { url },\n );\n return plan;\n }\n\n const trace = this.ctx.tracing.request();\n for (const [key, value] of Object.entries(trace.headers)) {\n headers.set(key, value);\n }\n\n if (input instanceof Request) {\n const rebuilt: RequestInit = { ...init, headers };\n // Our rebuild has headers, which resets the referrer, so keep it when the caller's didn't.\n if (isEmptyInit(init)) {\n rebuilt.referrer = input.referrer;\n rebuilt.referrerPolicy = input.referrerPolicy;\n }\n\n // Build the Request once with the caller's whole init, as fetch would, and pass no init\n // next to it. Otherwise fetch builds it again and reads the body twice, which throws.\n plan.input = new Request(input, rebuilt);\n plan.init = undefined;\n } else {\n plan.init = { ...init, headers };\n }\n\n // Only record the client span for a request that actually carries its traceparent.\n plan.span = trace.span;\n } catch (error) {\n // Send exactly what the caller gave us. A missing header is better than a failed\n // request.\n plan.input = input;\n plan.init = init;\n this.ctx.diagnostics.report(\n \"capture.header_failed\",\n \"The library could not add the traceparent header. It sends the request unchanged.\",\n { url },\n error,\n );\n }\n\n return plan;\n }\n\n /** Wraps the open and send methods on the XMLHttpRequest prototype. */\n private installXhr(): void {\n if (typeof XMLHttpRequest === \"undefined\") {\n return;\n }\n\n // Uninstall clears the flag, so a wrapper that stays in place only calls the original.\n let active = true;\n const ctx = this.ctx;\n const ignored = (url: string): boolean => this.ignored(url);\n const propagates = (url: string): boolean => this.propagates(url);\n const record = (\n meta: XhrMeta,\n status: number,\n durationMs: number,\n readTiming: () => string | null,\n ): void => {\n this.record(\n meta.method,\n meta.url,\n status,\n durationMs,\n undefined,\n meta.span,\n meta.routingContextId,\n readTiming,\n );\n };\n\n const proto = xhrMethods();\n\n const restoreOpen = patch(\n proto,\n \"open\",\n (originalOpen) =>\n function (this: Tracked, method: unknown, url: unknown, ...rest: never[]) {\n if (active) {\n // This read runs inside the caller's open call, so a throw must not fail it.\n ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read an XMLHttpRequest. It does not record the request.\",\n () => {\n this.__uiobs = { method: toMethod(method), url: readUrl(url), startedAt: 0 };\n },\n );\n }\n originalOpen.apply(this, [method, url, ...rest] as never[]);\n },\n );\n\n const restoreSend = patch(\n proto,\n \"send\",\n (originalSend) =>\n function (this: Tracked, ...args: never[]) {\n const meta = active ? this.__uiobs : undefined;\n if (meta) {\n ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record ${meta.method} ${meta.url}.`,\n () => {\n if (ignored(meta.url)) {\n return;\n }\n\n meta.startedAt = performance.now();\n meta.routingContextId = ctx.config.securityContext.id;\n // A reused XHR gets a new listener on every send, so the old one must not\n // fire again.\n this.addEventListener(\n \"loadend\",\n () => {\n record(meta, this.status, performance.now() - meta.startedAt, () =>\n xhrServerTiming(this.getAllResponseHeaders()),\n );\n },\n { once: true },\n );\n\n // setRequestHeader only works between open and send.\n if (propagates(meta.url)) {\n meta.span = addTraceHeaders(this, meta.url, ctx);\n }\n },\n );\n }\n originalSend.apply(this, args);\n },\n );\n\n this.restores.push(() => {\n active = false;\n restoreOpen();\n restoreSend();\n });\n }\n\n /**\n * Records the outcome of a request as attributes and a breadcrumb.\n * @param method Uppercase HTTP method.\n * @param target Request target URL. The query is removed here unless you set fullUrls.\n * @param status HTTP response status code, or 0 on failure.\n * @param durationMs Request duration in milliseconds.\n * @param error The caught error, for a failed request.\n * @param span The client span the request's traceparent names.\n */\n private record(\n method: string,\n target: string,\n status: number,\n durationMs: number,\n error: unknown,\n span?: ClientSpan,\n routingContextId?: string,\n readTiming?: () => string | null,\n ): void {\n if (\n this.ctx.isActive?.() === false ||\n (this.ctx.config.securityContext.isolation &&\n routingContextId !== undefined &&\n routingContextId !== this.ctx.config.securityContext.id)\n ) {\n return;\n }\n\n const timing =\n this.ctx.config.capture.serverTiming && readTiming\n ? this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read the Server-Timing response header.\",\n () => readServerTiming(readTiming()),\n )\n : undefined;\n\n // Strip the query here, not at the call sites. ignoreUrls and propagateTraceHeaderTo\n // match on the full URL, and only the recorded URL loses its query string.\n const url = recordedUrl(\n target,\n this.ctx.config.capture.fullUrls,\n this.ctx.config.capture.urlTransform,\n this.ctx.diagnostics,\n );\n\n // A transport request made after an await gets recorded, and that record causes the next\n // send.\n if (!this.warnedTransport && isTransportPending()) {\n this.warnedTransport = true;\n this.ctx.diagnostics.report(\n \"capture.transport_request\",\n `Network capture saw ${method} ${url} during a custom transport call. If the transport sends this request, add its URL to capture.ignoreUrls.`,\n );\n }\n\n // The histogram has its own guard, so a URL that doesn't parse can't stop the record.\n if (this.ctx.config.capture.httpMetrics) {\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record the duration of ${method} ${url}.`,\n () => {\n const attributes = durationAttributes(method, target, status, error);\n this.ctx.recordMetric(HTTP_DURATION, durationMs / MS_PER_SECOND, attributes);\n },\n );\n }\n\n if (span) {\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record the span of ${method} ${url}.`,\n () => {\n const endMs = Date.now();\n this.ctx.recordSpan({\n ...span,\n link: timing?.link,\n name: method,\n kind: \"client\",\n startMs: endMs - durationMs,\n endMs,\n error: status === 0 || status >= 400,\n attributes: { ...durationAttributes(method, target, status, error), \"url.full\": url },\n });\n },\n );\n }\n\n // This runs inside the caller's fetch call, so an error here must not fail the caller's\n // request.\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record ${method} ${url}.`,\n () => {\n const rounded = Math.round(durationMs);\n\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"http\",\n message: `${method} ${url} ${status === 0 ? \"failed\" : String(status)}`,\n data: { durationMs: rounded },\n });\n\n const attributes = {\n \"http.request.method\": method,\n \"url.full\": url,\n \"http.response.status_code\": status,\n \"http.duration_ms\": rounded,\n ...(timing && timing.entries.length > 0 ? { \"server.timing\": timing.entries } : {}),\n };\n\n if (status === 0) {\n this.ctx.logger.error(`${method} ${url} failed`, error, attributes);\n return;\n }\n if (status >= 400) {\n this.ctx.logger.warn(`${method} ${url} returned ${String(status)}`, attributes);\n return;\n }\n\n // Log a success at DEBUG, which the default minLevel of INFO drops. That way only\n // failures use bandwidth.\n this.ctx.logger.debug(`${method} ${url}`, attributes);\n },\n );\n }\n}\n\n/**\n * Adds the trace headers to an open XHR. If that fails, the request goes out without them.\n * @param xhr A request between open and send.\n * @param url Request target URL, for the diagnostic.\n * @param ctx Capture context with tracing and diagnostics.\n * @returns The client span the traceparent names, or undefined.\n */\nfunction addTraceHeaders(\n xhr: XMLHttpRequest,\n url: string,\n ctx: CaptureContext,\n): ClientSpan | undefined {\n try {\n const trace = ctx.tracing.request();\n for (const [key, value] of Object.entries(trace.headers)) {\n xhr.setRequestHeader(key, value);\n }\n return trace.span;\n } catch (error) {\n ctx.diagnostics.report(\n \"capture.header_failed\",\n \"The library could not add the traceparent header. It sends the request unchanged.\",\n { url },\n error,\n );\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;AAgBA,SAASS,EAAY,GAAc,GAA6B;CAC9D,IAAMC,IAAkB,CAAC,GACrBC,IAAQ,GACRC,IAAS,IACTC,IAAU;CAEd,KAAK,IAAIC,IAAI,GAAGA,IAAIC,EAAK,QAAQ,KAAK;EACpC,IAAMC,IAAOD,EAAKD;EAClB,AAAID,IACF,IAAU,KACDD,KAAUI,MAAS,OAC5B,IAAU,KACDA,MAAS,OAClB,IAAS,CAACJ,IACD,CAACA,KAAUI,MAASC,MAC7BP,EAAM,KAAKK,EAAK,MAAMJ,GAAOG,CAAC,CAAC,GAC/B,IAAQA,IAAI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KAAK;IACxB,GAAG,KAAK,IAAI;IACZ,UAAU;IACV,SAAS,GAAGvB,EAAO,GAAGC,EAAI,GAAGC,MAAW,IAAI,WAAW,OAAOA,CAAM;IACpE,MAAM,EAAE,YAAY8C,EAAQ;GAC9B,CAAC;GAED,IAAMjD,IAAa;IACjB,uBAAuBC;IACvB,YAAYC;IACZ,6BAA6BC;IAC7B,oBAAoB8C;IACpB,GAAIH,KAAUA,EAAO,QAAQ,SAAS,IAAI,EAAE,iBAAiBA,EAAO,QAAQ,IAAI,CAAC;GACnF;GAEA,AAAI3C,MAAW,IACb,KAAK,IAAI,OAAO,MAAM,GAAGF,EAAO,GAAGC,EAAI,UAAUE,GAAOJ,CAAU,IAGhEG,KAAU,MACZ,KAAK,IAAI,OAAO,KAAK,GAAGF,EAAO,GAAGC,EAAI,YAAY,OAAOC,CAAM,KAAKH,CAAU,IAMhF,KAAK,IAAI,OAAO,MAAM,GAAGC,EAAO,GAAGC,KAAOF,CAAU;EACtD,CACF;CACF;AACF;AASA,SAAS2C,EACP,GACA,GACA,GACwB;CACxB,IAAI;EACF,IAAMX,IAAQjB,EAAI,QAAQ,QAAQ;EAClC,KAAK,IAAM,CAACvB,GAAKC,MAAU,OAAO,QAAQuC,EAAM,OAAO,GACrD,EAAI,iBAAiBxC,GAAKC,CAAK;EAEjC,OAAOuC,EAAM;CACf,SAAS5B,GAAO;EACd,EAAI,YAAY,OACd,yBACA,qFACA,EAAE,OAAI,GACNA,CACF;EACA;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"openfin-Bxelt0yg.js","names":["getFin"],"sources":["../src/utils/openfin.ts"],"sourcesContent":["// src/utils/openfin.ts\n//\n// Reads the optional OpenFin runtime API. The library does not import an OpenFin package. The\n// types list only the members that the library reads. Each member is optional, because a test, an\n// older runtime or OpenFin web can leave it out.\n\n/** The InterApplicationBus operations that the bus link uses. */\nexport interface FinIab {\n /**\n * Publishes a message to all topic subscribers.\n * @param topic Topic name.\n * @param message Message payload.\n */\n publish(topic: string, message: unknown): Promise<void>;\n\n /**\n * Subscribes a listener to a topic for matching application identities.\n * @param identity Target application identity.\n * @param topic Topic name.\n * @param listener Message callback.\n */\n subscribe(\n identity: { uuid: string },\n topic: string,\n listener: (message: unknown, uuid?: string, name?: string) => void,\n ): Promise<void>;\n}\n\n/** The members of fin.me that the library reads. */\nexport interface FinMe {\n /** True in an OpenFin view. */\n isView?: boolean;\n /** Identity of the window or view. */\n identity?: { uuid?: string; name?: string };\n /** Resolves the creation options of the window, with customData. */\n getOptions?: () => Promise<{ customData?: Record<string, unknown> }>;\n /** Adds a window event listener. */\n on?: (event: string, listener: () => void) => void;\n /** Removes a window event listener. */\n removeListener?: (event: string, listener: () => void) => void;\n}\n\n/** The members of the OpenFin global that the library reads. */\nexport interface FinLike {\n /** The window or view of this document. */\n me?: FinMe;\n /** The message bus of the OpenFin runtime. */\n InterApplicationBus?: FinIab;\n}\n\n/**\n * Gives the OpenFin global.\n * @returns The fin global, or undefined outside OpenFin.\n */\nexport function getFin(): FinLike | undefined {\n return (globalThis as { fin?: FinLike }).fin;\n}\n"],"mappings":";AAsDA,SAAgBA,IAA8B;CAC5C,OAAQ,WAAiC;AAC3C"}
1
+ {"version":3,"file":"openfin-Bxelt0yg.js","names":["getFin"],"sources":["../src/utils/openfin.ts"],"sourcesContent":["// src/utils/openfin.ts\n//\n// Reads the optional OpenFin runtime API without importing an OpenFin package. The types\n// list only the members that the library reads. Every member is optional, because a test, an\n// older runtime or OpenFin web can leave it out.\n\n/** The InterApplicationBus operations that the bus link uses. */\nexport interface FinIab {\n /**\n * Publishes a message to all topic subscribers.\n * @param topic Topic name.\n * @param message Message payload.\n */\n publish(topic: string, message: unknown): Promise<void>;\n\n /**\n * Subscribes a listener to a topic for matching application identities.\n * @param identity Target application identity.\n * @param topic Topic name.\n * @param listener Message callback.\n */\n subscribe(\n identity: { uuid: string },\n topic: string,\n listener: (message: unknown, uuid?: string, name?: string) => void,\n ): Promise<void>;\n}\n\n/** The fin.me members that the library reads. */\nexport interface FinMe {\n /** True in an OpenFin view. */\n isView?: boolean;\n /** Identity of the window or view. */\n identity?: { uuid?: string; name?: string };\n /** Resolves the window's creation options, including customData. */\n getOptions?: () => Promise<{ customData?: Record<string, unknown> }>;\n /** Adds a window event listener. */\n on?: (event: string, listener: () => void) => void;\n /** Removes a window event listener. */\n removeListener?: (event: string, listener: () => void) => void;\n}\n\n/** The members of the OpenFin global that the library reads. */\nexport interface FinLike {\n /** This document's window or view. */\n me?: FinMe;\n /** The OpenFin runtime's message bus. */\n InterApplicationBus?: FinIab;\n}\n\n/**\n * Returns the OpenFin global.\n * @returns The fin global, or undefined outside OpenFin.\n */\nexport function getFin(): FinLike | undefined {\n return (globalThis as { fin?: FinLike }).fin;\n}\n"],"mappings":";AAsDA,SAAgBA,IAA8B;CAC5C,OAAQ,WAAiC;AAC3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"openfin-DtH2f7zX.cjs","names":["getFin"],"sources":["../src/utils/openfin.ts"],"sourcesContent":["// src/utils/openfin.ts\n//\n// Reads the optional OpenFin runtime API. The library does not import an OpenFin package. The\n// types list only the members that the library reads. Each member is optional, because a test, an\n// older runtime or OpenFin web can leave it out.\n\n/** The InterApplicationBus operations that the bus link uses. */\nexport interface FinIab {\n /**\n * Publishes a message to all topic subscribers.\n * @param topic Topic name.\n * @param message Message payload.\n */\n publish(topic: string, message: unknown): Promise<void>;\n\n /**\n * Subscribes a listener to a topic for matching application identities.\n * @param identity Target application identity.\n * @param topic Topic name.\n * @param listener Message callback.\n */\n subscribe(\n identity: { uuid: string },\n topic: string,\n listener: (message: unknown, uuid?: string, name?: string) => void,\n ): Promise<void>;\n}\n\n/** The members of fin.me that the library reads. */\nexport interface FinMe {\n /** True in an OpenFin view. */\n isView?: boolean;\n /** Identity of the window or view. */\n identity?: { uuid?: string; name?: string };\n /** Resolves the creation options of the window, with customData. */\n getOptions?: () => Promise<{ customData?: Record<string, unknown> }>;\n /** Adds a window event listener. */\n on?: (event: string, listener: () => void) => void;\n /** Removes a window event listener. */\n removeListener?: (event: string, listener: () => void) => void;\n}\n\n/** The members of the OpenFin global that the library reads. */\nexport interface FinLike {\n /** The window or view of this document. */\n me?: FinMe;\n /** The message bus of the OpenFin runtime. */\n InterApplicationBus?: FinIab;\n}\n\n/**\n * Gives the OpenFin global.\n * @returns The fin global, or undefined outside OpenFin.\n */\nexport function getFin(): FinLike | undefined {\n return (globalThis as { fin?: FinLike }).fin;\n}\n"],"mappings":"AAsDA,SAAgBA,GAA8B,CAC5C,OAAQ,WAAiC,GAC3C,C"}
1
+ {"version":3,"file":"openfin-DtH2f7zX.cjs","names":["getFin"],"sources":["../src/utils/openfin.ts"],"sourcesContent":["// src/utils/openfin.ts\n//\n// Reads the optional OpenFin runtime API without importing an OpenFin package. The types\n// list only the members that the library reads. Every member is optional, because a test, an\n// older runtime or OpenFin web can leave it out.\n\n/** The InterApplicationBus operations that the bus link uses. */\nexport interface FinIab {\n /**\n * Publishes a message to all topic subscribers.\n * @param topic Topic name.\n * @param message Message payload.\n */\n publish(topic: string, message: unknown): Promise<void>;\n\n /**\n * Subscribes a listener to a topic for matching application identities.\n * @param identity Target application identity.\n * @param topic Topic name.\n * @param listener Message callback.\n */\n subscribe(\n identity: { uuid: string },\n topic: string,\n listener: (message: unknown, uuid?: string, name?: string) => void,\n ): Promise<void>;\n}\n\n/** The fin.me members that the library reads. */\nexport interface FinMe {\n /** True in an OpenFin view. */\n isView?: boolean;\n /** Identity of the window or view. */\n identity?: { uuid?: string; name?: string };\n /** Resolves the window's creation options, including customData. */\n getOptions?: () => Promise<{ customData?: Record<string, unknown> }>;\n /** Adds a window event listener. */\n on?: (event: string, listener: () => void) => void;\n /** Removes a window event listener. */\n removeListener?: (event: string, listener: () => void) => void;\n}\n\n/** The members of the OpenFin global that the library reads. */\nexport interface FinLike {\n /** This document's window or view. */\n me?: FinMe;\n /** The OpenFin runtime's message bus. */\n InterApplicationBus?: FinIab;\n}\n\n/**\n * Returns the OpenFin global.\n * @returns The fin global, or undefined outside OpenFin.\n */\nexport function getFin(): FinLike | undefined {\n return (globalThis as { fin?: FinLike }).fin;\n}\n"],"mappings":"AAsDA,SAAgBA,GAA8B,CAC5C,OAAQ,WAAiC,GAC3C,C"}
@@ -0,0 +1,2 @@
1
+ const e=require("./constants-CqdJhTxH.cjs");function t(e){return e==null?null:typeof e==`string`?{stringValue:e}:typeof e==`boolean`?{boolValue:e}:typeof e==`number`?Number.isSafeInteger(e)?{intValue:String(e)}:{doubleValue:e}:typeof e==`bigint`?{intValue:e.toString()}:Array.isArray(e)?{arrayValue:{values:e.map(t).filter(e=>e!==null)}}:typeof e==`object`?{kvlistValue:{values:n(e)}}:null}function n(e){let n=[];for(let[r,i]of Object.entries(e)){let e=t(i);e&&n.push({key:r,value:e})}return n}var r=new WeakMap;function i(e){let t=r.get(e);if(t!==void 0)return t;let n=JSON.stringify(e);return r.set(e,n),n}function a(e){let t=new Map;for(let n of e){let e=i(n.resource),r=t.get(e);r?r.records.push(n):t.set(e,{resource:n.resource,records:[n]})}return[...t.values()]}function o(t){let n=new Map;for(let r of t){let t=r.attributes[e.a],i=typeof t==`string`&&t?t:e.$n,a=n.get(i);a?a.push(r):n.set(i,[r])}return[...n].map(([e,t])=>({name:e,records:t}))}var s={name:e.Fn,serialize(t){let r=a(t).map(e=>({resource:{attributes:n(e.resource)},scopeLogs:o(e.records).map(e=>({scope:{name:e.name},logRecords:e.records.map(e=>({timeUnixNano:e.timeUnixNano,observedTimeUnixNano:e.observedTimeUnixNano??e.timeUnixNano,severityNumber:e.severityNumber,severityText:e.severityText,body:{stringValue:e.body},traceId:e.traceId,spanId:e.spanId,flags:e.traceFlags,attributes:n(e.attributes)}))}))}));return{body:JSON.stringify({resourceLogs:r}),contentType:e.z}}};Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
2
+ //# sourceMappingURL=otlp-BENHf3g9.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otlp-BENHf3g9.cjs","names":["items","nested","ATTR_APP_NAMESPACE","TELEMETRY_SDK_NAME","SERIALIZER_NAME_OTLP","CONTENT_TYPE_JSON","require_constants","toAnyValue","value","item","toKeyValues","out","key","raw","source","resourceKeys","resourceKey","cached","resource","groupByResource","groups","record","records","group","groupByScope","namespace","name","scoped","otlpSerializer","resourceLogs","scope"],"sources":["../src/transport/serializers/otlp.ts"],"sourcesContent":["// src/transport/serializers/otlp.ts\n//\n// Serializes log batches as OTLP/JSON log records. Records are grouped by resource, and each\n// logger namespace gets its own instrumentation scope.\n// The OTLP metrics serializer reuses the value encoding and the resource grouping from here.\n\nimport {\n ATTR_APP_NAMESPACE,\n CONTENT_TYPE_JSON,\n SERIALIZER_NAME_OTLP,\n TELEMETRY_SDK_NAME,\n} from \"../../constants\";\nimport type { LogRecord } from \"../../models/log-record\";\nimport type { LogSerializer, SerializedBatch } from \"../../models/serializer\";\n\n/** An OTLP AnyValue with typed value wrappers. */\ntype AnyValue = Record<string, unknown>;\n\n/** An OTLP KeyValue pair. */\nexport interface KeyValue {\n /** The attribute key. */\n key: string;\n /** The typed AnyValue. */\n value: AnyValue;\n}\n\n/** Records that share the same resource attributes. */\nexport interface ResourceGroup {\n /** The resource attribute map. */\n resource: Record<string, unknown>;\n /** The resource's log records. */\n records: LogRecord[];\n}\n\n/**\n * Wraps a JavaScript value in an OTLP AnyValue.\n * @param value Raw attribute or resource value.\n * @returns Typed AnyValue object or null if unsupported.\n */\nfunction toAnyValue(value: unknown): AnyValue | null {\n if (value === null || value === undefined) {\n return null;\n }\n\n if (typeof value === \"string\") {\n return { stringValue: value };\n }\n\n if (typeof value === \"boolean\") {\n return { boolValue: value };\n }\n\n // Encode int64 as a decimal string, as the OTLP protobuf JSON mapping requires. A conforming\n // collector answers a number with a 400 status, and the response doesn't give the cause.\n // An integer above MAX_SAFE_INTEGER goes to doubleValue, because its text can be \"1e+21\" or\n // overflow int64.\n if (typeof value === \"number\") {\n return Number.isSafeInteger(value) ? { intValue: String(value) } : { doubleValue: value };\n }\n\n // Convert a BigInt to a decimal string. JSON.stringify throws on a BigInt and would lose\n // the batch.\n if (typeof value === \"bigint\") {\n return { intValue: value.toString() };\n }\n\n if (Array.isArray(value)) {\n const items: readonly unknown[] = value;\n const values = items.map(toAnyValue).filter((item): item is AnyValue => item !== null);\n\n return { arrayValue: { values } };\n }\n\n if (typeof value === \"object\") {\n const nested = value as Record<string, unknown>;\n return { kvlistValue: { values: toKeyValues(nested) } };\n }\n\n return null;\n}\n\n/**\n * Converts a plain object to an array of OTLP KeyValue pairs.\n * @param source Key-value attribute object.\n * @returns Array of valid KeyValue pairs.\n */\nexport function toKeyValues(source: Record<string, unknown>): KeyValue[] {\n const out: KeyValue[] = [];\n\n for (const [key, raw] of Object.entries(source)) {\n const value = toAnyValue(raw);\n if (value) {\n out.push({ key, value });\n }\n }\n\n return out;\n}\n\n/** Caches the JSON key of every resource object, which avoids a repeated stringify. */\nconst resourceKeys = new WeakMap<object, string>();\n\n/**\n * Returns the stable JSON key of a resource object, and caches it.\n * @param resource Resource attribute object.\n * @returns JSON key string.\n */\nfunction resourceKey(resource: Record<string, unknown>): string {\n const cached = resourceKeys.get(resource);\n if (cached !== undefined) {\n return cached;\n }\n\n const key = JSON.stringify(resource);\n resourceKeys.set(resource, key);\n\n return key;\n}\n\n/**\n * Groups records by their resource attributes, keeping the record order within each group.\n * @param records Records to group.\n * @returns One group per resource.\n */\nexport function groupByResource(records: LogRecord[]): ResourceGroup[] {\n const groups = new Map<string, ResourceGroup>();\n\n for (const record of records) {\n const key = resourceKey(record.resource);\n const group = groups.get(key);\n\n if (group) {\n group.records.push(record);\n continue;\n }\n\n groups.set(key, { resource: record.resource, records: [record] });\n }\n\n return [...groups.values()];\n}\n\n/** The records of one instrumentation scope. */\nexport interface ScopeGroup {\n /** The scope name, which is the logger namespace. */\n name: string;\n /** The scope's records. */\n records: LogRecord[];\n}\n\n/**\n * Groups records by their logger namespace, keeping the record order within each group.\n * A record without a namespace goes to the library's own scope.\n * @param records Records of one resource.\n * @returns One group per namespace.\n */\nexport function groupByScope(records: LogRecord[]): ScopeGroup[] {\n const groups = new Map<string, LogRecord[]>();\n\n for (const record of records) {\n const namespace: unknown = record.attributes[ATTR_APP_NAMESPACE];\n const name = typeof namespace === \"string\" && namespace ? namespace : TELEMETRY_SDK_NAME;\n const group = groups.get(name);\n\n if (group) {\n group.push(record);\n continue;\n }\n\n groups.set(name, [record]);\n }\n\n return [...groups].map(([name, scoped]) => ({ name, records: scoped }));\n}\n\n/** Writes log records as OTLP/JSON payloads. */\nexport const otlpSerializer: LogSerializer = {\n /** The format name. */\n name: SERIALIZER_NAME_OTLP,\n\n /**\n * Groups records by resource and encodes them as an OTLP\n * ExportLogsServiceRequest JSON payload.\n * @param records Array of log records to serialize.\n * @returns Serialized JSON batch payload.\n */\n serialize(records: LogRecord[]): SerializedBatch {\n const resourceLogs = groupByResource(records).map((group) => ({\n resource: { attributes: toKeyValues(group.resource) },\n scopeLogs: groupByScope(group.records).map((scope) => ({\n scope: { name: scope.name },\n logRecords: scope.records.map((record) => ({\n timeUnixNano: record.timeUnixNano,\n // Use timeUnixNano when observedTimeUnixNano is not set.\n observedTimeUnixNano: record.observedTimeUnixNano ?? record.timeUnixNano,\n severityNumber: record.severityNumber,\n severityText: record.severityText,\n body: { stringValue: record.body },\n traceId: record.traceId,\n spanId: record.spanId,\n flags: record.traceFlags,\n attributes: toKeyValues(record.attributes),\n })),\n })),\n }));\n\n return {\n body: JSON.stringify({ resourceLogs }),\n contentType: CONTENT_TYPE_JSON,\n };\n },\n};\n"],"mappings":"A,4CAuCA,SAASO,EAAW,EAAiC,CAuCnD,OAtCIC,GAAU,KACL,KAGL,OAAOA,GAAU,SACZ,CAAE,YAAaA,CAAM,EAG1B,OAAOA,GAAU,UACZ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