@utk09/ui-observability 0.10.0 → 0.12.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 (406) hide show
  1. package/CHANGELOG.md +77 -1
  2. package/README.md +323 -113
  3. package/bin/uiobs.mjs +1 -1
  4. package/dist/{batch-BMdT9mKm.js → batch-BjQUwjA6.js} +5 -6
  5. package/dist/batch-BjQUwjA6.js.map +1 -0
  6. package/dist/{batch-BHXypM1j.cjs → batch-D5LlU4Q9.cjs} +2 -2
  7. package/dist/batch-D5LlU4Q9.cjs.map +1 -0
  8. package/dist/bus/bus.d.ts +48 -47
  9. package/dist/bus/links.d.ts +4 -4
  10. package/dist/bus/validation.d.ts +1 -1
  11. package/dist/bus-D_7pd7RN.cjs +2 -0
  12. package/dist/bus-D_7pd7RN.cjs.map +1 -0
  13. package/dist/{bus-DKfBaica.js → bus-ecxUNTja.js} +105 -109
  14. package/dist/bus-ecxUNTja.js.map +1 -0
  15. package/dist/capture/console.d.ts +10 -10
  16. package/dist/capture/errors.d.ts +6 -6
  17. package/dist/capture/interactions.d.ts +14 -14
  18. package/dist/capture/lifecycle.d.ts +3 -3
  19. package/dist/capture/long-frames.d.ts +6 -6
  20. package/dist/capture/network.d.ts +17 -17
  21. package/dist/capture/profiler-frames.d.ts +44 -0
  22. package/dist/capture/replay-buffer.d.ts +46 -0
  23. package/dist/capture/replay-upload.d.ts +74 -0
  24. package/dist/capture/replay.d.ts +114 -0
  25. package/dist/capture/reports.d.ts +2 -2
  26. package/dist/capture/resource-timing.d.ts +1 -1
  27. package/dist/capture/server-timing.d.ts +3 -3
  28. package/dist/capture/storm.d.ts +3 -3
  29. package/dist/capture/types.d.ts +45 -33
  30. package/dist/capture/unclean-exit.d.ts +8 -8
  31. package/dist/capture/user-timing.d.ts +3 -3
  32. package/dist/capture/web-socket.d.ts +11 -11
  33. package/dist/capture/web-vitals.d.ts +20 -7
  34. package/dist/compression-AJJCMBOa.js +11 -0
  35. package/dist/compression-AJJCMBOa.js.map +1 -0
  36. package/dist/compression-lD9abCcO.cjs +2 -0
  37. package/dist/compression-lD9abCcO.cjs.map +1 -0
  38. package/dist/console-CLz_PvFn.cjs +2 -0
  39. package/dist/console-CLz_PvFn.cjs.map +1 -0
  40. package/dist/{console-BX_0UCV7.js → console-cwgHKXvM.js} +14 -15
  41. package/dist/console-cwgHKXvM.js.map +1 -0
  42. package/dist/constants-Bwl_YtQi.js +349 -0
  43. package/dist/constants-Bwl_YtQi.js.map +1 -0
  44. package/dist/constants-DakMxVB2.cjs +2 -0
  45. package/dist/constants-DakMxVB2.cjs.map +1 -0
  46. package/dist/constants.d.ts +150 -103
  47. package/dist/context-storage-BjzeBSxH.cjs.map +1 -1
  48. package/dist/{context-storage-DxZf4Gfh.js → context-storage-BzkoHzkQ.js} +2 -3
  49. package/dist/context-storage-BzkoHzkQ.js.map +1 -0
  50. package/dist/core/breadcrumbs.d.ts +16 -15
  51. package/dist/core/config.d.ts +3 -3
  52. package/dist/core/context.d.ts +7 -7
  53. package/dist/core/debug-buffer.d.ts +10 -10
  54. package/dist/core/debug-bundle.d.ts +3 -3
  55. package/dist/core/deferred.d.ts +2 -2
  56. package/dist/core/diagnostics.d.ts +24 -21
  57. package/dist/core/drops.d.ts +7 -7
  58. package/dist/core/hold-buffer.d.ts +1 -1
  59. package/dist/core/journey.d.ts +22 -23
  60. package/dist/core/logger.d.ts +22 -21
  61. package/dist/core/measure.d.ts +7 -7
  62. package/dist/core/meter.d.ts +25 -21
  63. package/dist/core/pipeline.d.ts +42 -41
  64. package/dist/core/profile-buckets.d.ts +31 -0
  65. package/dist/core/profiler.d.ts +218 -0
  66. package/dist/core/record.d.ts +23 -23
  67. package/dist/core/remote-rules.d.ts +4 -4
  68. package/dist/core/remote-sampling.d.ts +21 -20
  69. package/dist/core/runtime.d.ts +206 -137
  70. package/dist/core/sampling.d.ts +18 -18
  71. package/dist/core/sender.d.ts +22 -20
  72. package/dist/core/spans.d.ts +5 -5
  73. package/dist/{deadline-5_PecIl5.js → deadline-C4ccAuk5.js} +4 -9
  74. package/dist/deadline-C4ccAuk5.js.map +1 -0
  75. package/dist/deadline-CUGbto-y.cjs +2 -0
  76. package/dist/deadline-CUGbto-y.cjs.map +1 -0
  77. package/dist/{debug-bundle-CZZ6SQQh.js → debug-bundle-BOdYmCeV.js} +12 -6
  78. package/dist/debug-bundle-BOdYmCeV.js.map +1 -0
  79. package/dist/debug-bundle-Ex4L_LSP.cjs +2 -0
  80. package/dist/debug-bundle-Ex4L_LSP.cjs.map +1 -0
  81. package/dist/doctor.cjs +1 -1
  82. package/dist/doctor.cjs.map +1 -1
  83. package/dist/doctor.d.ts +16 -6
  84. package/dist/doctor.js +148 -54
  85. package/dist/doctor.js.map +1 -1
  86. package/dist/{emergency-queue-Cs8-i2xw.js → emergency-queue-B9WZxanZ.js} +15 -17
  87. package/dist/emergency-queue-B9WZxanZ.js.map +1 -0
  88. package/dist/{emergency-queue-CQ-9acZf.cjs → emergency-queue-HBpL5r3V.cjs} +2 -2
  89. package/dist/emergency-queue-HBpL5r3V.cjs.map +1 -0
  90. package/dist/{error-like-Ywo5uRHo.js → error-like-B11pB4aL.js} +2 -3
  91. package/dist/error-like-B11pB4aL.js.map +1 -0
  92. package/dist/error-like-gGRx2s36.cjs.map +1 -1
  93. package/dist/{errors-oyxrpHjY.js → errors-D6bwgJtO.js} +5 -6
  94. package/dist/errors-D6bwgJtO.js.map +1 -0
  95. package/dist/{errors-CigX45pL.cjs → errors-DCOCRdSi.cjs} +2 -2
  96. package/dist/errors-DCOCRdSi.cjs.map +1 -0
  97. package/dist/{factory-BkjNzPYL.cjs → factory-DLFDjdLv.cjs} +2 -2
  98. package/dist/factory-DLFDjdLv.cjs.map +1 -0
  99. package/dist/{factory-Bgsky_e0.js → factory-e9Qo3K0z.js} +18 -22
  100. package/dist/factory-e9Qo3K0z.js.map +1 -0
  101. package/dist/fixed-window-CvESpFYV.cjs.map +1 -1
  102. package/dist/{fixed-window-CtaFHanJ.js → fixed-window-Dq3MLUUv.js} +2 -3
  103. package/dist/fixed-window-Dq3MLUUv.js.map +1 -0
  104. package/dist/global-scope-BN-Io_yv.cjs.map +1 -1
  105. package/dist/{global-scope-dp2jADRl.js → global-scope-D9I8s-oN.js} +2 -3
  106. package/dist/global-scope-D9I8s-oN.js.map +1 -0
  107. package/dist/{guards-CpvOpJL6.js → guards-Cidk71ME.js} +2 -3
  108. package/dist/guards-Cidk71ME.js.map +1 -0
  109. package/dist/guards-nJ70syPt.cjs.map +1 -1
  110. package/dist/{identity-BMlKGHUM.cjs → identity-BlvlgjrU.cjs} +2 -2
  111. package/dist/identity-BlvlgjrU.cjs.map +1 -0
  112. package/dist/{identity-DOaHdfhT.js → identity-BrQp_5J5.js} +20 -21
  113. package/dist/identity-BrQp_5J5.js.map +1 -0
  114. package/dist/index.cjs +1 -1
  115. package/dist/index.cjs.map +1 -1
  116. package/dist/index.d.ts +112 -79
  117. package/dist/index.js +797 -659
  118. package/dist/index.js.map +1 -1
  119. package/dist/{indexeddb-storage-CaXGJqDD.cjs → indexeddb-storage-CtLvZH1r.cjs} +2 -2
  120. package/dist/indexeddb-storage-CtLvZH1r.cjs.map +1 -0
  121. package/dist/{indexeddb-storage-D-lUW_5P.js → indexeddb-storage-DLXQzAGh.js} +5 -6
  122. package/dist/indexeddb-storage-DLXQzAGh.js.map +1 -0
  123. package/dist/{interactions-CqDNrtIR.js → interactions-B6z2I4tU.js} +10 -11
  124. package/dist/interactions-B6z2I4tU.js.map +1 -0
  125. package/dist/{interactions-8DgxtmgO.cjs → interactions-P6pz08Jn.cjs} +2 -2
  126. package/dist/interactions-P6pz08Jn.cjs.map +1 -0
  127. package/dist/{journey-DgIjhrIc.js → journey-35yCMNFo.js} +21 -21
  128. package/dist/journey-35yCMNFo.js.map +1 -0
  129. package/dist/journey-DAGh5h9k.cjs +2 -0
  130. package/dist/journey-DAGh5h9k.cjs.map +1 -0
  131. package/dist/keys-BHhw_0Wh.cjs.map +1 -1
  132. package/dist/{keys-D5r_GH9q.js → keys-BU9j5YqW.js} +2 -3
  133. package/dist/keys-BU9j5YqW.js.map +1 -0
  134. package/dist/{library-console-g_VU-wzP.cjs → library-console-BFWEuQsl.cjs} +2 -2
  135. package/dist/library-console-BFWEuQsl.cjs.map +1 -0
  136. package/dist/library-console-Dl_Ly6DQ.js +13 -0
  137. package/dist/library-console-Dl_Ly6DQ.js.map +1 -0
  138. package/dist/{library-request-FQaiWjCP.cjs → library-request-Da-CHKzT.cjs} +2 -2
  139. package/dist/library-request-Da-CHKzT.cjs.map +1 -0
  140. package/dist/{library-request-CyC-9IOk.js → library-request-nI6pvI6I.js} +4 -5
  141. package/dist/library-request-nI6pvI6I.js.map +1 -0
  142. package/dist/{lifecycle-C2z_d8OX.cjs → lifecycle-BGGOcN4N.cjs} +2 -2
  143. package/dist/lifecycle-BGGOcN4N.cjs.map +1 -0
  144. package/dist/{lifecycle-BLC4VU7c.js → lifecycle-CZ6RRXc6.js} +3 -4
  145. package/dist/lifecycle-CZ6RRXc6.js.map +1 -0
  146. package/dist/{log-record-DKvo-B-d.cjs → log-record-D7bA1RPb.cjs} +2 -2
  147. package/dist/log-record-D7bA1RPb.cjs.map +1 -0
  148. package/dist/{log-record-CndanC-p.js → log-record-DIA6McNr.js} +3 -4
  149. package/dist/log-record-DIA6McNr.js.map +1 -0
  150. package/dist/{long-frames-BQef9rXR.js → long-frames-430_85Da.js} +9 -8
  151. package/dist/long-frames-430_85Da.js.map +1 -0
  152. package/dist/long-frames-Dd8tsi2U.cjs +2 -0
  153. package/dist/long-frames-Dd8tsi2U.cjs.map +1 -0
  154. package/dist/models/batch.d.ts +14 -15
  155. package/dist/models/bus.d.ts +24 -24
  156. package/dist/models/config.d.ts +402 -216
  157. package/dist/models/drop.d.ts +13 -11
  158. package/dist/models/health.d.ts +13 -13
  159. package/dist/models/log-record.d.ts +13 -14
  160. package/dist/models/metric.d.ts +82 -17
  161. package/dist/models/plugin.d.ts +13 -13
  162. package/dist/models/replay.d.ts +60 -0
  163. package/dist/models/serializer.d.ts +2 -3
  164. package/dist/models/stats.d.ts +2 -2
  165. package/dist/models/storage.d.ts +12 -11
  166. package/dist/{network-CvkvYzRU.js → network-C7SkLf4v.js} +30 -32
  167. package/dist/network-C7SkLf4v.js.map +1 -0
  168. package/dist/{network-CqnQOqon.cjs → network-pEX3PAJv.cjs} +2 -2
  169. package/dist/network-pEX3PAJv.cjs.map +1 -0
  170. package/dist/openfin-Bxelt0yg.js +7 -0
  171. package/dist/openfin-Bxelt0yg.js.map +1 -0
  172. package/dist/openfin-DtH2f7zX.cjs.map +1 -1
  173. package/dist/otlp-2MCrC3kd.cjs +2 -0
  174. package/dist/otlp-2MCrC3kd.cjs.map +1 -0
  175. package/dist/{otlp-CYIL7MOE.js → otlp-COq033e3.js} +26 -35
  176. package/dist/otlp-COq033e3.js.map +1 -0
  177. package/dist/patch-BX8KrPCT.cjs.map +1 -1
  178. package/dist/{patch-CCWfuEY7.js → patch-UdPz1ea8.js} +2 -3
  179. package/dist/patch-UdPz1ea8.js.map +1 -0
  180. package/dist/{platform-KMWkoI-v.cjs → platform-12uR7kBQ.cjs} +2 -2
  181. package/dist/platform-12uR7kBQ.cjs.map +1 -0
  182. package/dist/{platform-wcAkkv9F.js → platform-CVewe4wQ.js} +9 -10
  183. package/dist/platform-CVewe4wQ.js.map +1 -0
  184. package/dist/profiler-BVWIOgnq.js +310 -0
  185. package/dist/profiler-BVWIOgnq.js.map +1 -0
  186. package/dist/profiler-eVCknCzS.cjs +2 -0
  187. package/dist/profiler-eVCknCzS.cjs.map +1 -0
  188. package/dist/profiler-frames-CLXlT_xL.js +86 -0
  189. package/dist/profiler-frames-CLXlT_xL.js.map +1 -0
  190. package/dist/profiler-frames-Dg2OebB2.cjs +2 -0
  191. package/dist/profiler-frames-Dg2OebB2.cjs.map +1 -0
  192. package/dist/{remote-rules-CH_7PphT.js → remote-rules-BJGDJGwA.js} +29 -30
  193. package/dist/remote-rules-BJGDJGwA.js.map +1 -0
  194. package/dist/{remote-rules-BL8km4xk.cjs → remote-rules-CJD3ToVk.cjs} +2 -2
  195. package/dist/remote-rules-CJD3ToVk.cjs.map +1 -0
  196. package/dist/replay-0zAJv9T3.js +338 -0
  197. package/dist/replay-0zAJv9T3.js.map +1 -0
  198. package/dist/replay-DomJpXqW.cjs +2 -0
  199. package/dist/replay-DomJpXqW.cjs.map +1 -0
  200. package/dist/{reports-Bh_-KpZ2.cjs → reports-BsbqmP8h.cjs} +2 -2
  201. package/dist/reports-BsbqmP8h.cjs.map +1 -0
  202. package/dist/{reports-BOKyY3_A.js → reports-BuXekPOS.js} +4 -5
  203. package/dist/reports-BuXekPOS.js.map +1 -0
  204. package/dist/{resource-timing-BROnEJ0E.js → resource-timing-CXGHwFRD.js} +6 -7
  205. package/dist/resource-timing-CXGHwFRD.js.map +1 -0
  206. package/dist/{resource-timing-CbgwNpog.cjs → resource-timing-DkycFGDa.cjs} +2 -2
  207. package/dist/resource-timing-DkycFGDa.cjs.map +1 -0
  208. package/dist/{sampling-ECGVYiDD.cjs → sampling-Dd0wllyq.cjs} +2 -2
  209. package/dist/sampling-Dd0wllyq.cjs.map +1 -0
  210. package/dist/{sampling-BLO_pcV4.js → sampling-UUDbi3K0.js} +11 -12
  211. package/dist/sampling-UUDbi3K0.js.map +1 -0
  212. package/dist/{sanitize-DS0G4_ea.js → sanitize-CNmsD9r3.js} +4 -5
  213. package/dist/sanitize-CNmsD9r3.js.map +1 -0
  214. package/dist/{sanitize-Bsn8HQWC.cjs → sanitize-ChLn97Ch.cjs} +2 -2
  215. package/dist/sanitize-ChLn97Ch.cjs.map +1 -0
  216. package/dist/{select-DWO0-w8_.cjs → select-CTk-K5mG.cjs} +3 -3
  217. package/dist/select-CTk-K5mG.cjs.map +1 -0
  218. package/dist/{select-wqt9Wxio.js → select-DPv_j6wq.js} +64 -67
  219. package/dist/select-DPv_j6wq.js.map +1 -0
  220. package/dist/{sender-BkAVt-Rq.js → sender-15zEsZpr.js} +98 -101
  221. package/dist/sender-15zEsZpr.js.map +1 -0
  222. package/dist/sender-Bfpv9tad.cjs +2 -0
  223. package/dist/sender-Bfpv9tad.cjs.map +1 -0
  224. package/dist/storage/context-storage.d.ts +34 -33
  225. package/dist/storage/emergency-queue.d.ts +9 -9
  226. package/dist/storage/eviction.d.ts +12 -12
  227. package/dist/storage/factory.d.ts +8 -7
  228. package/dist/storage/gap.d.ts +6 -6
  229. package/dist/storage/idb-driver.d.ts +31 -32
  230. package/dist/storage/indexeddb-storage.d.ts +26 -27
  231. package/dist/storage/keys.d.ts +7 -7
  232. package/dist/storage/local-storage.d.ts +38 -38
  233. package/dist/storage/memory-storage.d.ts +21 -22
  234. package/dist/storage/persistence.d.ts +1 -1
  235. package/dist/storage-BA9RqRO-.cjs.map +1 -1
  236. package/dist/{storage-w7Tslvlq.js → storage-DZwed89z.js} +2 -3
  237. package/dist/storage-DZwed89z.js.map +1 -0
  238. package/dist/{storm-DD4cUkoL.js → storm-BTSNTIWI.js} +4 -5
  239. package/dist/storm-BTSNTIWI.js.map +1 -0
  240. package/dist/{storm-DCEsqViG.cjs → storm-D0_qZOEg.cjs} +2 -2
  241. package/dist/storm-D0_qZOEg.cjs.map +1 -0
  242. package/dist/transport/compression.d.ts +2 -2
  243. package/dist/transport/errors.d.ts +7 -7
  244. package/dist/transport/exit-flush.d.ts +39 -39
  245. package/dist/transport/headers.d.ts +2 -2
  246. package/dist/transport/http-transport.d.ts +28 -27
  247. package/dist/transport/memory-transport.d.ts +6 -6
  248. package/dist/transport/retry-engine.d.ts +35 -34
  249. package/dist/transport/serializers/ecs.d.ts +1 -1
  250. package/dist/transport/serializers/otlp-metrics.d.ts +1 -1
  251. package/dist/transport/serializers/otlp-traces.d.ts +1 -1
  252. package/dist/transport/serializers/otlp.d.ts +16 -16
  253. package/dist/transport/serializers/select.d.ts +7 -7
  254. package/dist/transport/status-transport.d.ts +20 -20
  255. package/dist/transport/worker-protocol.d.ts +3 -3
  256. package/dist/{types-BR9t_w28.js → types-BAerHgCq.js} +2 -3
  257. package/dist/types-BAerHgCq.js.map +1 -0
  258. package/dist/types-C7WNpnG1.cjs.map +1 -1
  259. package/dist/{unclean-exit-CwdpbUDg.cjs → unclean-exit-ClGzrc2A.cjs} +2 -2
  260. package/dist/unclean-exit-ClGzrc2A.cjs.map +1 -0
  261. package/dist/{unclean-exit-BYZ5yaSI.js → unclean-exit-Cob_jyTv.js} +3 -4
  262. package/dist/unclean-exit-Cob_jyTv.js.map +1 -0
  263. package/dist/unref-CU9Nyz_9.cjs +2 -0
  264. package/dist/unref-CU9Nyz_9.cjs.map +1 -0
  265. package/dist/unref-DgHPQeWv.js +7 -0
  266. package/dist/unref-DgHPQeWv.js.map +1 -0
  267. package/dist/user-timing-CdYqx3PF.cjs +2 -0
  268. package/dist/user-timing-CdYqx3PF.cjs.map +1 -0
  269. package/dist/{user-timing-Di2ra5DB.js → user-timing-DgHubxCI.js} +7 -6
  270. package/dist/user-timing-DgHubxCI.js.map +1 -0
  271. package/dist/utils/console.d.ts +2 -2
  272. package/dist/utils/deadline.d.ts +4 -4
  273. package/dist/utils/error-like.d.ts +7 -7
  274. package/dist/utils/fixed-window.d.ts +9 -8
  275. package/dist/utils/global-scope.d.ts +8 -8
  276. package/dist/utils/guards.d.ts +2 -2
  277. package/dist/utils/identity.d.ts +17 -17
  278. package/dist/utils/library-console.d.ts +4 -4
  279. package/dist/utils/library-request.d.ts +10 -10
  280. package/dist/utils/lock.d.ts +10 -9
  281. package/dist/utils/openfin.d.ts +5 -5
  282. package/dist/utils/patch.d.ts +6 -6
  283. package/dist/utils/platform.d.ts +13 -11
  284. package/dist/utils/sanitize.d.ts +4 -4
  285. package/dist/utils/timer.d.ts +1 -1
  286. package/dist/utils/tracing.d.ts +38 -38
  287. package/dist/utils/unref.d.ts +3 -3
  288. package/dist/{web-socket-DwBNhgre.cjs → web-socket-BTuvYoJI.cjs} +2 -2
  289. package/dist/web-socket-BTuvYoJI.cjs.map +1 -0
  290. package/dist/{web-socket-B-5qqPy7.js → web-socket-DthJuSAg.js} +14 -15
  291. package/dist/web-socket-DthJuSAg.js.map +1 -0
  292. package/dist/web-vitals-Ch5BpDmo.cjs +2 -0
  293. package/dist/web-vitals-Ch5BpDmo.cjs.map +1 -0
  294. package/dist/web-vitals-CsGCWnUr.js +77 -0
  295. package/dist/web-vitals-CsGCWnUr.js.map +1 -0
  296. package/dist/{worker-protocol-0HMf4-kY.js → worker-protocol-B0_8rWy5.js} +6 -7
  297. package/dist/worker-protocol-B0_8rWy5.js.map +1 -0
  298. package/dist/{worker-protocol-DXekoADQ.cjs → worker-protocol-BjzFORfq.cjs} +2 -2
  299. package/dist/worker-protocol-BjzFORfq.cjs.map +1 -0
  300. package/dist/worker-server-4en-Lt-3.cjs +2 -0
  301. package/dist/worker-server-4en-Lt-3.cjs.map +1 -0
  302. package/dist/{worker-server-CKcmX5m5.js → worker-server-Cne9MX9I.js} +25 -26
  303. package/dist/{worker-server-CKcmX5m5.js.map → worker-server-Cne9MX9I.js.map} +1 -1
  304. package/dist/worker-transport-B-GF4Aqn.cjs +2 -0
  305. package/dist/worker-transport-B-GF4Aqn.cjs.map +1 -0
  306. package/dist/{worker-transport-2220ghFZ.js → worker-transport-C3SjJAEC.js} +64 -65
  307. package/dist/worker-transport-C3SjJAEC.js.map +1 -0
  308. package/package.json +33 -41
  309. package/dist/batch-BHXypM1j.cjs.map +0 -1
  310. package/dist/batch-BMdT9mKm.js.map +0 -1
  311. package/dist/bus-DKfBaica.js.map +0 -1
  312. package/dist/bus-Dea9rVhy.cjs +0 -2
  313. package/dist/bus-Dea9rVhy.cjs.map +0 -1
  314. package/dist/console-BX_0UCV7.js.map +0 -1
  315. package/dist/console-DZEcs7FL.cjs +0 -2
  316. package/dist/console-DZEcs7FL.cjs.map +0 -1
  317. package/dist/constants-CL0ZdI2f.cjs +0 -2
  318. package/dist/constants-CL0ZdI2f.cjs.map +0 -1
  319. package/dist/constants-CU60FG4w.js +0 -305
  320. package/dist/constants-CU60FG4w.js.map +0 -1
  321. package/dist/context-storage-DxZf4Gfh.js.map +0 -1
  322. package/dist/deadline-5_PecIl5.js.map +0 -1
  323. package/dist/deadline-XSnm95pg.cjs +0 -2
  324. package/dist/deadline-XSnm95pg.cjs.map +0 -1
  325. package/dist/debug-bundle-CZZ6SQQh.js.map +0 -1
  326. package/dist/debug-bundle-yRkrU1ny.cjs +0 -2
  327. package/dist/debug-bundle-yRkrU1ny.cjs.map +0 -1
  328. package/dist/emergency-queue-CQ-9acZf.cjs.map +0 -1
  329. package/dist/emergency-queue-Cs8-i2xw.js.map +0 -1
  330. package/dist/error-like-Ywo5uRHo.js.map +0 -1
  331. package/dist/errors-CigX45pL.cjs.map +0 -1
  332. package/dist/errors-oyxrpHjY.js.map +0 -1
  333. package/dist/factory-Bgsky_e0.js.map +0 -1
  334. package/dist/factory-BkjNzPYL.cjs.map +0 -1
  335. package/dist/fixed-window-CtaFHanJ.js.map +0 -1
  336. package/dist/global-scope-dp2jADRl.js.map +0 -1
  337. package/dist/guards-CpvOpJL6.js.map +0 -1
  338. package/dist/identity-BMlKGHUM.cjs.map +0 -1
  339. package/dist/identity-DOaHdfhT.js.map +0 -1
  340. package/dist/indexeddb-storage-CaXGJqDD.cjs.map +0 -1
  341. package/dist/indexeddb-storage-D-lUW_5P.js.map +0 -1
  342. package/dist/interactions-8DgxtmgO.cjs.map +0 -1
  343. package/dist/interactions-CqDNrtIR.js.map +0 -1
  344. package/dist/journey-5tcxEbnG.cjs +0 -2
  345. package/dist/journey-5tcxEbnG.cjs.map +0 -1
  346. package/dist/journey-DgIjhrIc.js.map +0 -1
  347. package/dist/keys-D5r_GH9q.js.map +0 -1
  348. package/dist/library-console-CabK2j2-.js +0 -14
  349. package/dist/library-console-CabK2j2-.js.map +0 -1
  350. package/dist/library-console-g_VU-wzP.cjs.map +0 -1
  351. package/dist/library-request-CyC-9IOk.js.map +0 -1
  352. package/dist/library-request-FQaiWjCP.cjs.map +0 -1
  353. package/dist/lifecycle-BLC4VU7c.js.map +0 -1
  354. package/dist/lifecycle-C2z_d8OX.cjs.map +0 -1
  355. package/dist/log-record-CndanC-p.js.map +0 -1
  356. package/dist/log-record-DKvo-B-d.cjs.map +0 -1
  357. package/dist/long-frames-BQef9rXR.js.map +0 -1
  358. package/dist/long-frames-CV5ZG2cx.cjs +0 -2
  359. package/dist/long-frames-CV5ZG2cx.cjs.map +0 -1
  360. package/dist/network-CqnQOqon.cjs.map +0 -1
  361. package/dist/network-CvkvYzRU.js.map +0 -1
  362. package/dist/openfin-BwEN0uj4.js +0 -8
  363. package/dist/openfin-BwEN0uj4.js.map +0 -1
  364. package/dist/otlp-CYIL7MOE.js.map +0 -1
  365. package/dist/otlp-RVbkNQRh.cjs +0 -2
  366. package/dist/otlp-RVbkNQRh.cjs.map +0 -1
  367. package/dist/patch-CCWfuEY7.js.map +0 -1
  368. package/dist/platform-KMWkoI-v.cjs.map +0 -1
  369. package/dist/platform-wcAkkv9F.js.map +0 -1
  370. package/dist/remote-rules-BL8km4xk.cjs.map +0 -1
  371. package/dist/remote-rules-CH_7PphT.js.map +0 -1
  372. package/dist/reports-BOKyY3_A.js.map +0 -1
  373. package/dist/reports-Bh_-KpZ2.cjs.map +0 -1
  374. package/dist/resource-timing-BROnEJ0E.js.map +0 -1
  375. package/dist/resource-timing-CbgwNpog.cjs.map +0 -1
  376. package/dist/sampling-BLO_pcV4.js.map +0 -1
  377. package/dist/sampling-ECGVYiDD.cjs.map +0 -1
  378. package/dist/sanitize-Bsn8HQWC.cjs.map +0 -1
  379. package/dist/sanitize-DS0G4_ea.js.map +0 -1
  380. package/dist/select-DWO0-w8_.cjs.map +0 -1
  381. package/dist/select-wqt9Wxio.js.map +0 -1
  382. package/dist/sender-BkAVt-Rq.js.map +0 -1
  383. package/dist/sender-D82PxlCY.cjs +0 -2
  384. package/dist/sender-D82PxlCY.cjs.map +0 -1
  385. package/dist/storage-w7Tslvlq.js.map +0 -1
  386. package/dist/storm-DCEsqViG.cjs.map +0 -1
  387. package/dist/storm-DD4cUkoL.js.map +0 -1
  388. package/dist/types-BR9t_w28.js.map +0 -1
  389. package/dist/unclean-exit-BYZ5yaSI.js.map +0 -1
  390. package/dist/unclean-exit-CwdpbUDg.cjs.map +0 -1
  391. package/dist/user-timing-C1kB3JEg.cjs +0 -2
  392. package/dist/user-timing-C1kB3JEg.cjs.map +0 -1
  393. package/dist/user-timing-Di2ra5DB.js.map +0 -1
  394. package/dist/web-socket-B-5qqPy7.js.map +0 -1
  395. package/dist/web-socket-DwBNhgre.cjs.map +0 -1
  396. package/dist/web-vitals-Bflr5jSA.js +0 -53
  397. package/dist/web-vitals-Bflr5jSA.js.map +0 -1
  398. package/dist/web-vitals-DFuoTQbZ.cjs +0 -2
  399. package/dist/web-vitals-DFuoTQbZ.cjs.map +0 -1
  400. package/dist/worker-protocol-0HMf4-kY.js.map +0 -1
  401. package/dist/worker-protocol-DXekoADQ.cjs.map +0 -1
  402. package/dist/worker-server-BQK5z2yl.cjs +0 -2
  403. package/dist/worker-server-BQK5z2yl.cjs.map +0 -1
  404. package/dist/worker-transport-2220ghFZ.js.map +0 -1
  405. package/dist/worker-transport-Dj2yCQN5.cjs +0 -2
  406. package/dist/worker-transport-Dj2yCQN5.cjs.map +0 -1
@@ -1,10 +1,10 @@
1
- import { gn as e, hn as t } from "./constants-CU60FG4w.js";
2
- import { r as n } from "./error-like-Ywo5uRHo.js";
3
- import { i as r } from "./platform-wcAkkv9F.js";
4
- import { n as i, t as a } from "./library-request-CyC-9IOk.js";
5
- import { t as o } from "./patch-CCWfuEY7.js";
6
- import { t as s } from "./types-BR9t_w28.js";
7
- //#region src/capture/server-timing.ts
1
+ import { Dn as e, On as t } from "./constants-Bwl_YtQi.js";
2
+ import { r as n } from "./error-like-B11pB4aL.js";
3
+ import { n as r, t as i } from "./library-request-nI6pvI6I.js";
4
+ import { t as a } from "./patch-UdPz1ea8.js";
5
+ import { i as o } from "./platform-CVewe4wQ.js";
6
+ import { t as s } from "./types-BAerHgCq.js";
7
+ // src/capture/server-timing.ts
8
8
  function c(e, t) {
9
9
  let n = [], r = 0, i = !1, a = !1;
10
10
  for (let o = 0; o < e.length; o++) {
@@ -16,10 +16,10 @@ function c(e, t) {
16
16
  function l(e) {
17
17
  return /^server-timing:(.*)$/im.exec(e)?.[1] ?? null;
18
18
  }
19
- function u(t) {
19
+ function u(e) {
20
20
  let n = { entries: [] };
21
- if (!t) return n;
22
- for (let r of c(t.slice(0, e), ",").slice(0, 32)) {
21
+ if (!e) return n;
22
+ for (let r of c(e.slice(0, t), ",").slice(0, 32)) {
23
23
  let [e, ...t] = c(r, ";"), i = e.trim();
24
24
  if (!/^[!#$%&'*+.^_`|~\da-z-]+$/i.test(i)) continue;
25
25
  let a = {
@@ -49,8 +49,7 @@ function u(t) {
49
49
  }
50
50
  return n;
51
51
  }
52
- //#endregion
53
- //#region src/capture/network.ts
52
+ // src/capture/network.ts
54
53
  var d = 1e3, f = {
55
54
  name: "http.client.request.duration",
56
55
  kind: "histogram",
@@ -124,7 +123,7 @@ var y = class {
124
123
  }
125
124
  }
126
125
  ignored(e) {
127
- return a() || s(e, this.ctx.config.capture.ignoreUrls);
126
+ return i() || s(e, this.ctx.config.capture.ignoreUrls);
128
127
  }
129
128
  propagates(e) {
130
129
  let t = this.ctx.config.capture.propagateTraceHeaderTo;
@@ -134,24 +133,24 @@ var y = class {
134
133
  }
135
134
  installFetch() {
136
135
  if (typeof globalThis.fetch != "function") return;
137
- let e = !0, n = (e, t) => this.prepareFetch(e, t), r = (e, t, n, r, i) => {
136
+ let t = !0, n = (e, t) => this.prepareFetch(e, t), r = (e, t, n, r, i) => {
138
137
  this.record(e.method, e.url, t, n, r, e.span, e.routingContextId, i);
139
- }, i = o(globalThis, "fetch", (i) => {
138
+ }, i = a(globalThis, "fetch", (i) => {
140
139
  let a = i.bind(globalThis);
141
140
  return async function(i, o) {
142
- let s = e ? n(i, o) : void 0;
141
+ let s = t ? n(i, o) : void 0;
143
142
  if (!s) return a(i, o);
144
143
  let c = performance.now();
145
144
  try {
146
- let e = await a(s.input, s.init);
147
- return r(s, e.status, performance.now() - c, void 0, () => e.headers.get(t)), e;
145
+ let t = await a(s.input, s.init);
146
+ return r(s, t.status, performance.now() - c, void 0, () => t.headers.get(e)), t;
148
147
  } catch (e) {
149
148
  throw r(s, 0, performance.now() - c, e), e;
150
149
  }
151
150
  };
152
151
  });
153
152
  this.restores.push(() => {
154
- e = !1, i();
153
+ t = !1, i();
155
154
  });
156
155
  }
157
156
  prepareFetch(e, t) {
@@ -196,7 +195,7 @@ var y = class {
196
195
  if (typeof XMLHttpRequest > "u") return;
197
196
  let e = !0, t = this.ctx, n = (e) => this.ignored(e), r = (e) => this.propagates(e), i = (e, t, n, r) => {
198
197
  this.record(e.method, e.url, t, n, void 0, e.span, e.routingContextId, r);
199
- }, a = m(), s = o(a, "open", (n) => function(r, i, ...a) {
198
+ }, o = m(), s = a(o, "open", (n) => function(r, i, ...a) {
200
199
  e && t.diagnostics.guard("capture.record_failed", "The library could not read an XMLHttpRequest. It does not record the request.", () => {
201
200
  this.__uiobs = {
202
201
  method: v(r),
@@ -208,7 +207,7 @@ var y = class {
208
207
  i,
209
208
  ...a
210
209
  ]);
211
- }), c = o(a, "send", (a) => function(...o) {
210
+ }), c = a(o, "send", (a) => function(...o) {
212
211
  let s = e ? this.__uiobs : void 0;
213
212
  s && t.diagnostics.guard("capture.record_failed", `The library could not record ${s.method} ${s.url}.`, () => {
214
213
  n(s.url) || (s.startedAt = performance.now(), s.routingContextId = t.config.securityContext.id, this.addEventListener("loadend", () => {
@@ -220,12 +219,12 @@ var y = class {
220
219
  e = !1, s(), c();
221
220
  });
222
221
  }
223
- record(e, t, n, a, o, s, c, l) {
222
+ record(e, t, n, i, a, s, c, l) {
224
223
  if (this.ctx.isActive?.() === !1 || this.ctx.config.securityContext.isolation && c !== void 0 && c !== this.ctx.config.securityContext.id) return;
225
- 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 = r(t, this.ctx.config.capture.fullUrls, this.ctx.config.capture.urlTransform, this.ctx.diagnostics);
226
- !this.warnedTransport && i() && (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}.`, () => {
227
- let r = p(e, t, n, o);
228
- this.ctx.recordMetric(f, a / d, r);
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);
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);
229
228
  }), s && this.ctx.diagnostics.guard("capture.record_failed", `The library could not record the span of ${e} ${h}.`, () => {
230
229
  let r = Date.now();
231
230
  this.ctx.recordSpan({
@@ -233,16 +232,16 @@ var y = class {
233
232
  link: m?.link,
234
233
  name: e,
235
234
  kind: "client",
236
- startMs: r - a,
235
+ startMs: r - i,
237
236
  endMs: r,
238
237
  error: n === 0 || n >= 400,
239
238
  attributes: {
240
- ...p(e, t, n, o),
239
+ ...p(e, t, n, a),
241
240
  "url.full": h
242
241
  }
243
242
  });
244
243
  }), this.ctx.diagnostics.guard("capture.record_failed", `The library could not record ${e} ${h}.`, () => {
245
- let t = Math.round(a);
244
+ let t = Math.round(i);
246
245
  this.ctx.breadcrumbs.push({
247
246
  t: Date.now(),
248
247
  category: "http",
@@ -256,7 +255,7 @@ var y = class {
256
255
  "http.duration_ms": t,
257
256
  ...m && m.entries.length > 0 ? { "server.timing": m.entries } : {}
258
257
  };
259
- n === 0 ? this.ctx.logger.error(`${e} ${h} failed`, o, r) : n >= 400 ? this.ctx.logger.warn(`${e} ${h} returned ${String(n)}`, r) : this.ctx.logger.debug(`${e} ${h}`, r);
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);
260
259
  });
261
260
  }
262
261
  };
@@ -270,7 +269,6 @@ function b(e, t, n) {
270
269
  return;
271
270
  }
272
271
  }
273
- //#endregion
274
272
  export { y as NetworkCapture };
275
273
 
276
- //# sourceMappingURL=network-CvkvYzRU.js.map
274
+ //# sourceMappingURL=network-C7SkLf4v.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network-C7SkLf4v.js","names":["SERVER_TIMING_HEADER","SERVER_TIMING_MAX_CHARS","isErrorLike","isTransportPending","isLibraryRequest","patch","recordedUrl","matchesAny","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","NetworkCapture","ctx","restore","targets","origin","target","active","prepare","record","plan","durationMs","readTiming","call","original","startedAt","response","read","trace","injected","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 } 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 * 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 const trace = this.ctx.tracing.request();\n const injected = Object.entries(trace.headers);\n\n if (input instanceof Request) {\n // Don't spread a non-empty init next to a Request input. That runs the Request\n // constructor on `input` again and reads its body, and reading a body twice\n // throws a TypeError.\n const headers = new Headers(input.headers);\n for (const [key, value] of injected) {\n headers.set(key, value);\n }\n plan.input = new Request(input, { headers });\n } else {\n const headers = new Headers(init?.headers);\n for (const [key, value] of injected) {\n headers.set(key, value);\n }\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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AU;IACV,SAAS,GAAGtB,EAAO,GAAGC,EAAI,GAAGC,MAAW,IAAI,WAAW,OAAOA,CAAM;IACpE,MAAM,EAAE,YAAY4C,EAAQ;GAC9B,CAAC;GAED,IAAM/C,IAAa;IACjB,uBAAuBC;IACvB,YAAYC;IACZ,6BAA6BC;IAC7B,oBAAoB4C;IACpB,GAAIH,KAAUA,EAAO,QAAQ,SAAS,IAAI,EAAE,iBAAiBA,EAAO,QAAQ,IAAI,CAAC;GACnF;GAEA,AAAIzC,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,SAASyC,EACP,GACA,GACA,GACwB;CACxB,IAAI;EACF,IAAMX,IAAQhB,EAAI,QAAQ,QAAQ;EAClC,KAAK,IAAM,CAACtB,GAAKC,MAAU,OAAO,QAAQqC,EAAM,OAAO,GACrD,EAAI,iBAAiBtC,GAAKC,CAAK;EAEjC,OAAOqC,EAAM;CACf,SAAS1B,GAAO;EACd,EAAI,YAAY,OACd,yBACA,qFACA,EAAE,OAAI,GACNA,CACF;EACA;CACF;AACF"}
@@ -1,2 +1,2 @@
1
- const e=require("./constants-CL0ZdI2f.cjs"),t=require("./error-like-gGRx2s36.cjs"),n=require("./platform-KMWkoI-v.cjs"),r=require("./library-request-FQaiWjCP.cjs"),i=require("./patch-BX8KrPCT.cjs"),a=require("./types-C7WNpnG1.cjs");function o(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 s(e){return/^server-timing:(.*)$/im.exec(e)?.[1]??null}function c(t){let n={entries:[]};if(!t)return n;for(let r of o(t.slice(0,e.gn),`,`).slice(0,32)){let[e,...t]=o(r,`;`),i=e.trim();if(!/^[!#$%&'*+.^_`|~\da-z-]+$/i.test(i))continue;let a={name:i,duration:0,description:``},s=new Set;for(let e of t){let t=e.indexOf(`=`);if(t<0)continue;let n=e.slice(0,t).trim().toLowerCase();if(s.has(n))continue;s.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 l=1e3,u={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 d(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 f(){return XMLHttpRequest.prototype}function p(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 m(e,t){let n=t?.method;return n===void 0&&typeof e==`object`&&e&&(n=e.method),g(n??`GET`)}function h(e){return typeof e==`object`&&!(e instanceof URL)&&!(e instanceof Request)}function g(e){return typeof e==`string`?e.toUpperCase():String(e)}var _=class{ctx;name=`network`;installed=!1;restores=[];warnedTransport=!1;constructor(e){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 r.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),r=(e,t,n,r,i)=>{this.record(e.method,e.url,t,n,r,e.span,e.routingContextId,i)},a=i.t(globalThis,`fetch`,i=>{let a=i.bind(globalThis);return async function(i,o){let s=t?n(i,o):void 0;if(!s)return a(i,o);let c=performance.now();try{let t=await a(s.input,s.init);return r(s,t.status,performance.now()-c,void 0,()=>t.headers.get(e.hn)),t}catch(e){throw r(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=p(e);if(!this.ignored(n))return{method:m(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||h(e))return a;try{let n=this.ctx.tracing.request(),r=Object.entries(n.headers);if(e instanceof Request){let t=new Headers(e.headers);for(let[e,n]of r)t.set(e,n);a.input=new Request(e,{headers:t})}else{let e=new Headers(t?.headers);for(let[t,n]of r)e.set(t,n);a.init={...t,headers:e}}a.span=n.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),r=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=f(),c=i.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:g(r),url:p(i),startedAt:0}}),n.apply(this,[r,i,...a])}),l=i.t(o,`send`,i=>function(...o){let c=e?this.__uiobs:void 0;c&&t.diagnostics.guard(`capture.record_failed`,`The library could not record ${c.method} ${c.url}.`,()=>{n(c.url)||(c.startedAt=performance.now(),c.routingContextId=t.config.securityContext.id,this.addEventListener(`loadend`,()=>{a(c,this.status,performance.now()-c.startedAt,()=>s(this.getAllResponseHeaders()))},{once:!0}),r(c.url)&&(c.span=v(this,c.url,t)))}),i.apply(this,o)});this.restores.push(()=>{e=!1,c(),l()})}record(e,t,i,a,o,s,f,p){if(this.ctx.isActive?.()===!1||this.ctx.config.securityContext.isolation&&f!==void 0&&f!==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.`,()=>c(p())):void 0,h=n.i(t,this.ctx.config.capture.fullUrls,this.ctx.config.capture.urlTransform,this.ctx.diagnostics);!this.warnedTransport&&r.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=d(e,t,i,o);this.ctx.recordMetric(u,a/l,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:i===0||i>=400,attributes:{...d(e,t,i,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} ${i===0?`failed`:String(i)}`,data:{durationMs:t}});let n={"http.request.method":e,"url.full":h,"http.response.status_code":i,"http.duration_ms":t,...m&&m.entries.length>0?{"server.timing":m.entries}:{}};i===0?this.ctx.logger.error(`${e} ${h} failed`,o,n):i>=400?this.ctx.logger.warn(`${e} ${h} returned ${String(i)}`,n):this.ctx.logger.debug(`${e} ${h}`,n)})}};function v(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=_;
2
- //# sourceMappingURL=network-CqnQOqon.cjs.map
1
+ const e=require("./constants-DakMxVB2.cjs"),t=require("./error-like-gGRx2s36.cjs"),n=require("./library-request-Da-CHKzT.cjs"),r=require("./patch-BX8KrPCT.cjs"),i=require("./platform-12uR7kBQ.cjs"),a=require("./types-C7WNpnG1.cjs");function o(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 s(e){return/^server-timing:(.*)$/im.exec(e)?.[1]??null}function c(t){let n={entries:[]};if(!t)return n;for(let r of o(t.slice(0,e.On),`,`).slice(0,32)){let[e,...t]=o(r,`;`),i=e.trim();if(!/^[!#$%&'*+.^_`|~\da-z-]+$/i.test(i))continue;let a={name:i,duration:0,description:``},s=new Set;for(let e of t){let t=e.indexOf(`=`);if(t<0)continue;let n=e.slice(0,t).trim().toLowerCase();if(s.has(n))continue;s.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 l=1e3,u={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 d(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 f(){return XMLHttpRequest.prototype}function p(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 m(e,t){let n=t?.method;return n===void 0&&typeof e==`object`&&e&&(n=e.method),g(n??`GET`)}function h(e){return typeof e==`object`&&!(e instanceof URL)&&!(e instanceof Request)}function g(e){return typeof e==`string`?e.toUpperCase():String(e)}var _=class{ctx;name=`network`;installed=!1;restores=[];warnedTransport=!1;constructor(e){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.Dn)),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=p(e);if(!this.ignored(n))return{method:m(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||h(e))return a;try{let n=this.ctx.tracing.request(),r=Object.entries(n.headers);if(e instanceof Request){let t=new Headers(e.headers);for(let[e,n]of r)t.set(e,n);a.input=new Request(e,{headers:t})}else{let e=new Headers(t?.headers);for(let[t,n]of r)e.set(t,n);a.init={...t,headers:e}}a.span=n.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=f(),c=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:g(r),url:p(i),startedAt:0}}),n.apply(this,[r,i,...a])}),l=r.t(o,`send`,r=>function(...o){let c=e?this.__uiobs:void 0;c&&t.diagnostics.guard(`capture.record_failed`,`The library could not record ${c.method} ${c.url}.`,()=>{n(c.url)||(c.startedAt=performance.now(),c.routingContextId=t.config.securityContext.id,this.addEventListener(`loadend`,()=>{a(c,this.status,performance.now()-c.startedAt,()=>s(this.getAllResponseHeaders()))},{once:!0}),i(c.url)&&(c.span=v(this,c.url,t)))}),r.apply(this,o)});this.restores.push(()=>{e=!1,c(),l()})}record(e,t,r,a,o,s,f,p){if(this.ctx.isActive?.()===!1||this.ctx.config.securityContext.isolation&&f!==void 0&&f!==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.`,()=>c(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=d(e,t,r,o);this.ctx.recordMetric(u,a/l,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:{...d(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 v(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=_;
2
+ //# sourceMappingURL=network-pEX3PAJv.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network-pEX3PAJv.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","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","NetworkCapture","ctx","restore","targets","origin","target","active","prepare","record","plan","durationMs","readTiming","call","original","startedAt","response","read","trace","injected","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 } 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 * 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 const trace = this.ctx.tracing.request();\n const injected = Object.entries(trace.headers);\n\n if (input instanceof Request) {\n // Don't spread a non-empty init next to a Request input. That runs the Request\n // constructor on `input` again and reads its body, and reading a body twice\n // throws a TypeError.\n const headers = new Headers(input.headers);\n for (const [key, value] of injected) {\n headers.set(key, value);\n }\n plan.input = new Request(input, { headers });\n } else {\n const headers = new Headers(init?.headers);\n for (const [key, value] of injected) {\n headers.set(key, value);\n }\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,wOAgBA,SAASc,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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KAAK,IAAI,OAAO,KAAK,GAAGF,EAAO,GAAGC,EAAI,YAAY,OAAOC,CAAM,IAAKH,CAAU,EAMhF,KAAK,IAAI,OAAO,MAAM,GAAGC,EAAO,GAAGC,IAAOF,CAAU,CACtD,CACF,CACF,CACF,EASA,SAASyC,EACP,EACA,EACA,EACwB,CACxB,GAAI,CACF,IAAMX,EAAQhB,EAAI,QAAQ,QAAQ,EAClC,IAAK,GAAM,CAACtB,EAAKC,KAAU,OAAO,QAAQqC,EAAM,OAAO,EACrDkB,EAAI,iBAAiBxD,EAAKC,CAAK,EAEjC,OAAOqC,EAAM,IACf,OAAS1B,EAAO,CACdU,EAAI,YAAY,OACd,wBACA,oFACA,CAAE,KAAI,EACNV,CACF,EACA,MACF,CACF,C"}
@@ -0,0 +1,7 @@
1
+ // src/utils/openfin.ts
2
+ function e() {
3
+ return globalThis.fin;
4
+ }
5
+ export { e as t };
6
+
7
+ //# sourceMappingURL=openfin-Bxelt0yg.js.map
@@ -0,0 +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 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"}
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-DakMxVB2.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.Wn,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.En,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.R}}};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-2MCrC3kd.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otlp-2MCrC3kd.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,CAAE,UAAWA,CAAM,EAOxB,OAAOA,GAAU,SACZ,OAAO,cAAcA,CAAK,EAAI,CAAE,SAAU,OAAOA,CAAK,CAAE,EAAI,CAAE,YAAaA,C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GAAc,UAAYA,EAAYA,EAAYtB,EAAAA,GAChEoB,EAAQH,EAAO,IAAIM,CAAI,EAEzBH,EACFA,EAAM,KAAKF,CAAM,EAInBD,EAAO,IAAIM,EAAM,CAACL,CAAM,CAAC,CAC3B,CAEA,MAAO,CAAC,GAAGD,CAAM,CAAC,CAAC,KAAK,CAACM,EAAMC,MAAa,CAAE,OAAM,QAASA,CAAO,EAAE,CACxE,CAGA,IAAaC,EAAgC,CAE3C,KAAMxB,EAAAA,GAQN,UAAU,EAAuC,CAC/C,IAAMyB,EAAeV,EAAgBG,CAAO,CAAC,CAAC,IAAK,IAAW,CAC5D,SAAU,CAAE,WAAYZ,EAAYa,EAAM,QAAQ,CAAE,EACpD,UAAWC,EAAaD,EAAM,OAAO,CAAC,CAAC,IAAK,IAAW,CACrD,MAAO,CAAE,KAAMO,EAAM,IAAK,EAC1B,WAAYA,EAAM,QAAQ,IAAK,IAAY,CACzC,aAAcT,EAAO,aAErB,qBAAsBA,EAAO,sBAAwBA,EAAO,aAC5D,eAAgBA,EAAO,eACvB,aAAcA,EAAO,aACrB,KAAM,CAAE,YAAaA,EAAO,IAAK,EACjC,QAASA,EAAO,QAChB,OAAQA,EAAO,OACf,MAAOA,EAAO,WACd,WAAYX,EAAYW,EAAO,UAAU,CAC3C,EAAE,CACJ,EAAE,CACJ,EAAE,EAEF,MAAO,CACL,KAAM,KAAK,UAAU,CAAE,cAAa,CAAC,EACrC,YAAahB,EAAAA,CACf,CACF,CACF,E"}
@@ -1,20 +1,12 @@
1
- import { Mn as e, R as t, a as n, mn as r, tt as i } from "./constants-CU60FG4w.js";
2
- //#region src/transport/compression.ts
3
- async function a(e) {
4
- let t = globalThis.CompressionStream;
5
- if (t === void 0) return null;
6
- let n = new Blob([e]).stream().pipeThrough(new t(i)), r = await new Response(n).arrayBuffer();
7
- return new Uint8Array(r);
1
+ import { En as e, R as t, Wn as n, a as r } from "./constants-Bwl_YtQi.js";
2
+ // src/transport/serializers/otlp.ts
3
+ function i(e) {
4
+ 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(i).filter((e) => e !== null) } } : typeof e == "object" ? { kvlistValue: { values: a(e) } } : null;
8
5
  }
9
- //#endregion
10
- //#region src/transport/serializers/otlp.ts
11
- function o(e) {
12
- 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(o).filter((e) => e !== null) } } : typeof e == "object" ? { kvlistValue: { values: s(e) } } : null;
13
- }
14
- function s(e) {
6
+ function a(e) {
15
7
  let t = [];
16
8
  for (let [n, r] of Object.entries(e)) {
17
- let e = o(r);
9
+ let e = i(r);
18
10
  e && t.push({
19
11
  key: n,
20
12
  value: e
@@ -22,17 +14,17 @@ function s(e) {
22
14
  }
23
15
  return t;
24
16
  }
25
- var c = /* @__PURE__ */ new WeakMap();
26
- function l(e) {
27
- let t = c.get(e);
17
+ var o = /* @__PURE__ */ new WeakMap();
18
+ function s(e) {
19
+ let t = o.get(e);
28
20
  if (t !== void 0) return t;
29
21
  let n = JSON.stringify(e);
30
- return c.set(e, n), n;
22
+ return o.set(e, n), n;
31
23
  }
32
- function u(e) {
24
+ function c(e) {
33
25
  let t = /* @__PURE__ */ new Map();
34
26
  for (let n of e) {
35
- let e = l(n.resource), r = t.get(e);
27
+ let e = s(n.resource), r = t.get(e);
36
28
  r ? r.records.push(n) : t.set(e, {
37
29
  resource: n.resource,
38
30
  records: [n]
@@ -40,23 +32,23 @@ function u(e) {
40
32
  }
41
33
  return [...t.values()];
42
34
  }
43
- function d(t) {
44
- let r = /* @__PURE__ */ new Map();
45
- for (let i of t) {
46
- let t = i.attributes[n], a = typeof t == "string" && t ? t : e, o = r.get(a);
47
- o ? o.push(i) : r.set(a, [i]);
35
+ function l(e) {
36
+ let t = /* @__PURE__ */ new Map();
37
+ for (let i of e) {
38
+ let e = i.attributes[r], a = typeof e == "string" && e ? e : n, o = t.get(a);
39
+ o ? o.push(i) : t.set(a, [i]);
48
40
  }
49
- return [...r].map(([e, t]) => ({
41
+ return [...t].map(([e, t]) => ({
50
42
  name: e,
51
43
  records: t
52
44
  }));
53
45
  }
54
- var f = {
55
- name: r,
46
+ var u = {
47
+ name: e,
56
48
  serialize(e) {
57
- let n = u(e).map((e) => ({
58
- resource: { attributes: s(e.resource) },
59
- scopeLogs: d(e.records).map((e) => ({
49
+ let n = c(e).map((e) => ({
50
+ resource: { attributes: a(e.resource) },
51
+ scopeLogs: l(e.records).map((e) => ({
60
52
  scope: { name: e.name },
61
53
  logRecords: e.records.map((e) => ({
62
54
  timeUnixNano: e.timeUnixNano,
@@ -67,7 +59,7 @@ var f = {
67
59
  traceId: e.traceId,
68
60
  spanId: e.spanId,
69
61
  flags: e.traceFlags,
70
- attributes: s(e.attributes)
62
+ attributes: a(e.attributes)
71
63
  }))
72
64
  }))
73
65
  }));
@@ -77,7 +69,6 @@ var f = {
77
69
  };
78
70
  }
79
71
  };
80
- //#endregion
81
- export { a, s as i, d as n, f as r, u as t };
72
+ export { a as i, l as n, u as r, c as t };
82
73
 
83
- //# sourceMappingURL=otlp-CYIL7MOE.js.map
74
+ //# sourceMappingURL=otlp-COq033e3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otlp-COq033e3.js","names":["items","nested","SERIALIZER_NAME_OTLP","CONTENT_TYPE_JSON","TELEMETRY_SDK_NAME","ATTR_APP_NAMESPACE","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":";;AAuCA,SAASM,EAAW,GAAiC;CAuCnD,OAtCIC,KAAU,OACL,OAGL,OAAOA,KAAU,WACZ,EAAE,aAAaA,EAAM,IAG1B,OAAOA,KAAU,YACZ,EAAE,WAAWA,EAAM,IAOxB,OAAOA,KAAU,WACZ,OAAO,cAAcA,CAAK,IAAI,EAAE,UAAU,OAAOA,CAAK,EAAE,IAAI,EAAE,aAAaA,EAAM,IAKtF,OAAOA,KAAU,WACZ,EAAE,UAAUA,EAAM,SAAS,EAAE,IAGlC,MAAM,QAAQA,CAAK,IAId,EAAE,YAAY,EAAE,QAFRP,EAAM,IAAIM,CAAU,CAAC,CAAC,QAAQ,MAA2BE,MAAS,IAE1D,EAAO,EAAE,IAG9B,OAAOD,KAAU,WAEZ,EAAE,aAAa,EAAE,QAAQE,EA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MC,QAAa;EAAE;EAAM,SAASA;CAAO,EAAE;AACxE;AAGA,IAAaC,IAAgC;CAE3C,MAAMzB;CAQN,UAAU,GAAuC;EAC/C,IAAM0B,IAAeV,EAAgBG,CAAO,CAAC,CAAC,KAAK,OAAW;GAC5D,UAAU,EAAE,YAAYZ,EAAYa,EAAM,QAAQ,EAAE;GACpD,WAAWC,EAAaD,EAAM,OAAO,CAAC,CAAC,KAAK,OAAW;IACrD,OAAO,EAAE,MAAMO,EAAM,KAAK;IAC1B,YAAYA,EAAM,QAAQ,KAAK,OAAY;KACzC,cAAcT,EAAO;KAErB,sBAAsBA,EAAO,wBAAwBA,EAAO;KAC5D,gBAAgBA,EAAO;KACvB,cAAcA,EAAO;KACrB,MAAM,EAAE,aAAaA,EAAO,KAAK;KACjC,SAASA,EAAO;KAChB,QAAQA,EAAO;KACf,OAAOA,EAAO;KACd,YAAYX,EAAYW,EAAO,UAAU;IAC3C,EAAE;GACJ,EAAE;EACJ,EAAE;EAEF,OAAO;GACL,MAAM,KAAK,UAAU,EAAE,gBAAa,CAAC;GACrC,aAAajB;EACf;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"patch-BX8KrPCT.cjs","names":["patch","original","target","key","wrapper","wrap"],"sources":["../src/utils/patch.ts"],"sourcesContent":["// src/utils/patch.ts\n//\n// Replaces a host function with a wrapper and gives back a safe restore. A router or a\n// second SDK can wrap the same function after the library. A blind restore removes that\n// wrapper and breaks the host page.\n\n/**\n * Replaces `target[key]` with a wrapper of the current value.\n * @param target Object that holds the function, for example `console` or `globalThis`.\n * @param key Property to replace.\n * @param wrap Makes the wrapper from the original value.\n * @returns Restore function. It writes the original back only if the property still holds\n * the wrapper. It then returns true. If not, it changes nothing. It returns false.\n */\nexport function patch<T extends object, K extends keyof T>(\n target: T,\n key: K,\n wrap: (original: T[K]) => T[K],\n): () => boolean {\n const original = target[key];\n const wrapper = wrap(original);\n target[key] = wrapper;\n\n return () => {\n // Another script wrapped the property after the library. Keep its wrapper.\n if (target[key] !== wrapper) {\n return false;\n }\n\n target[key] = original;\n return true;\n };\n}\n"],"mappings":"AAcA,SAAgBA,EACd,EACA,EACA,EACe,CACf,IAAMC,EAAWC,EAAOC,GAClBC,EAAUC,EAAKJ,CAAQ,EAG7B,MAFA,GAAOE,GAAOC,MAIRF,EAAOC,KAASC,IAIpB,EAAOD,GAAOF,EACP,GAEX"}
1
+ {"version":3,"file":"patch-BX8KrPCT.cjs","names":["patch","original","target","key","wrapper","wrap"],"sources":["../src/utils/patch.ts"],"sourcesContent":["// src/utils/patch.ts\n//\n// Replaces a host function with a wrapper and returns a safe restore. A router or a second\n// SDK can wrap the same function after we do, and a blind restore would remove that wrapper\n// and break the host page.\n\n/**\n * Replaces `target[key]` with a wrapper around the current value.\n * @param target The object that holds the function, for example `console` or `globalThis`.\n * @param key The property to replace.\n * @param wrap Builds the wrapper from the original value.\n * @returns A restore function. It writes the original back and returns true only if the\n * property still holds the wrapper. Otherwise it changes nothing and returns false.\n */\nexport function patch<T extends object, K extends keyof T>(\n target: T,\n key: K,\n wrap: (original: T[K]) => T[K],\n): () => boolean {\n const original = target[key];\n const wrapper = wrap(original);\n target[key] = wrapper;\n\n return () => {\n // Another script wrapped the property after us. Keep its wrapper.\n if (target[key] !== wrapper) {\n return false;\n }\n\n target[key] = original;\n return true;\n };\n}\n"],"mappings":"AAcA,SAAgBA,EACd,EACA,EACA,EACe,CACf,IAAMC,EAAWC,EAAOC,GAClBC,EAAUC,EAAKJ,CAAQ,EAG7B,MAFA,GAAOE,GAAOC,MAIRF,EAAOC,KAASC,IAIpB,EAAOD,GAAOF,EACP,GAEX,C"}
@@ -1,9 +1,8 @@
1
- //#region src/utils/patch.ts
1
+ // src/utils/patch.ts
2
2
  function e(e, t, n) {
3
3
  let r = e[t], i = n(r);
4
4
  return e[t] = i, () => e[t] === i && (e[t] = r, !0);
5
5
  }
6
- //#endregion
7
6
  export { e as t };
8
7
 
9
- //# sourceMappingURL=patch-CCWfuEY7.js.map
8
+ //# sourceMappingURL=patch-UdPz1ea8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patch-UdPz1ea8.js","names":["patch","original","target","key","wrapper","wrap"],"sources":["../src/utils/patch.ts"],"sourcesContent":["// src/utils/patch.ts\n//\n// Replaces a host function with a wrapper and returns a safe restore. A router or a second\n// SDK can wrap the same function after we do, and a blind restore would remove that wrapper\n// and break the host page.\n\n/**\n * Replaces `target[key]` with a wrapper around the current value.\n * @param target The object that holds the function, for example `console` or `globalThis`.\n * @param key The property to replace.\n * @param wrap Builds the wrapper from the original value.\n * @returns A restore function. It writes the original back and returns true only if the\n * property still holds the wrapper. Otherwise it changes nothing and returns false.\n */\nexport function patch<T extends object, K extends keyof T>(\n target: T,\n key: K,\n wrap: (original: T[K]) => T[K],\n): () => boolean {\n const original = target[key];\n const wrapper = wrap(original);\n target[key] = wrapper;\n\n return () => {\n // Another script wrapped the property after us. Keep its wrapper.\n if (target[key] !== wrapper) {\n return false;\n }\n\n target[key] = original;\n return true;\n };\n}\n"],"mappings":";AAcA,SAAgBA,EACd,GACA,GACA,GACe;CACf,IAAMC,IAAWC,EAAOC,IAClBC,IAAUC,EAAKJ,CAAQ;CAG7B,OAFA,EAAOE,KAAOC,SAIRF,EAAOC,OAASC,MAIpB,EAAOD,KAAOF,GACP;AAEX"}
@@ -1,2 +1,2 @@
1
- const e=require("./constants-CL0ZdI2f.cjs"),t=require("./openfin-DtH2f7zX.cjs");var n=null;function r(e,t){let n=e[t];return n!==void 0&&e instanceof n}function i(i){if(n)return n;let s=globalThis,c=s.navigator?.userAgent??``,l=`browser`,u,d,f=!1,p=t.t()?.me;return r(s,`ServiceWorkerGlobalScope`)?(l=`service_worker`,f=!0):r(s,`SharedWorkerGlobalScope`)?(l=`shared_worker`,f=!0):r(s,`WorkerGlobalScope`)?(l=`web_worker`,f=!0):p===void 0?s.Capacitor!==void 0||s.Ionic!==void 0?l=`ionic`:s.cordova!==void 0||a(c)?l=`mobile_webview`:typeof document>`u`&&typeof process<`u`&&(l=`node`):(l=e.Vt.test(c)?`openfin`:`openfin_web`,i.guard(`openfin.unavailable`,`The library could not read fin.me.identity.`,()=>{let e=p.identity;u=e?.uuid,d=e?.name})),n={platform:l,openfinUuid:u,openfinName:d,userAgent:c,isWorker:f,isTopLevelDocument:o(i)},n}function a(t){return e.i.test(t)?!0:(e._t.test(t)||e.jt.test(t)&&e.It.test(t))&&t.includes(`AppleWebKit`)&&!t.includes(`Safari/`)}function o(e){if(typeof window>`u`)return!1;try{return window.self===window.top}catch{return e.count(`platform.api_blocked`),!1}}function s(e){try{return typeof location<`u`?location.href:``}catch{return e.count(`platform.api_blocked`),``}}var c=/^([a-z][a-z\d+.-]*:\/\/)[^/?#]*@/i;function l(e,t,n,r){if(n)try{let t=n(e);return typeof t==`string`?t:``}catch(e){return r?.report(`capture.record_failed`,`capture.urlTransform threw an error. The library records an empty URL.`,void 0,e),``}let i=e.replace(c,`$1`);return t?i:u(i)}function u(e){let t=e.search(/[?#]/);return t===-1?e:e.slice(0,t)}function d(){return globalThis.navigator?.onLine!==!1}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
2
- //# sourceMappingURL=platform-KMWkoI-v.cjs.map
1
+ const e=require("./constants-DakMxVB2.cjs"),t=require("./openfin-DtH2f7zX.cjs");var n=null;function r(e,t){let n=e[t];return n!==void 0&&e instanceof n}function i(i){if(n)return n;let s=globalThis,c=s.navigator?.userAgent??``,l=`browser`,u,d,f=!1,p=t.t()?.me;return r(s,`ServiceWorkerGlobalScope`)?(l=`service_worker`,f=!0):r(s,`SharedWorkerGlobalScope`)?(l=`shared_worker`,f=!0):r(s,`WorkerGlobalScope`)?(l=`web_worker`,f=!0):p===void 0?s.Capacitor!==void 0||s.Ionic!==void 0?l=`ionic`:s.cordova!==void 0||a(c)?l=`mobile_webview`:typeof document>`u`&&typeof process<`u`&&(l=`node`):(l=e.Ht.test(c)?`openfin`:`openfin_web`,i.guard(`openfin.unavailable`,`The library could not read fin.me.identity.`,()=>{let e=p.identity;u=e?.uuid,d=e?.name})),n={platform:l,openfinUuid:u,openfinName:d,userAgent:c,isWorker:f,isTopLevelDocument:o(i)},n}function a(t){return e.i.test(t)?!0:(e.vt.test(t)||e.Mt.test(t)&&e.Lt.test(t))&&t.includes(`AppleWebKit`)&&!t.includes(`Safari/`)}function o(e){if(typeof window>`u`)return!1;try{return window.self===window.top}catch{return e.count(`platform.api_blocked`),!1}}function s(e){try{return typeof location<`u`?location.href:``}catch{return e.count(`platform.api_blocked`),``}}var c=/^([a-z][a-z\d+.-]*:\/\/)[^/?#]*@/i;function l(e,t,n,r){if(n)try{let t=n(e);return typeof t==`string`?t:``}catch(e){return r?.report(`capture.record_failed`,`capture.urlTransform threw an error. The library records an empty URL.`,void 0,e),``}let i=e.replace(c,`$1`);return t?i:u(i)}function u(e){let t=e.search(/[?#]/);return t===-1?e:e.slice(0,t)}function d(){return globalThis.navigator?.onLine!==!1}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
2
+ //# sourceMappingURL=platform-12uR7kBQ.cjs.map