@utk09/ui-observability 0.11.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (557) hide show
  1. package/CHANGELOG.md +481 -0
  2. package/README.md +73 -669
  3. package/bin/uiobs.mjs +1 -1
  4. package/dist/{batch-CL9uWYY3.js → batch-CXmPmTse.js} +3 -3
  5. package/dist/batch-CXmPmTse.js.map +1 -0
  6. package/dist/{batch-C8OcWR2L.cjs → batch-mmPigCpi.cjs} +2 -2
  7. package/dist/batch-mmPigCpi.cjs.map +1 -0
  8. package/dist/bus/bus.d.cts +331 -0
  9. package/dist/bus/bus.d.ts +108 -57
  10. package/dist/bus/links.d.cts +132 -0
  11. package/dist/bus/links.d.ts +22 -7
  12. package/dist/bus/validation.d.cts +16 -0
  13. package/dist/bus/validation.d.ts +11 -2
  14. package/dist/bus-C39wspFV.js +775 -0
  15. package/dist/bus-C39wspFV.js.map +1 -0
  16. package/dist/bus-_EaOVPGq.cjs +2 -0
  17. package/dist/bus-_EaOVPGq.cjs.map +1 -0
  18. package/dist/capture/console.d.cts +37 -0
  19. package/dist/capture/console.d.ts +11 -11
  20. package/dist/capture/errors.d.cts +32 -0
  21. package/dist/capture/errors.d.ts +7 -7
  22. package/dist/capture/interactions.d.cts +48 -0
  23. package/dist/capture/interactions.d.ts +15 -15
  24. package/dist/capture/lifecycle.d.cts +20 -0
  25. package/dist/capture/lifecycle.d.ts +4 -4
  26. package/dist/capture/long-frames.d.cts +31 -0
  27. package/dist/capture/long-frames.d.ts +7 -7
  28. package/dist/capture/network.d.cts +57 -0
  29. package/dist/capture/network.d.ts +18 -18
  30. package/dist/capture/profiler-frames.d.cts +44 -0
  31. package/dist/capture/profiler-frames.d.ts +44 -0
  32. package/dist/capture/replay-buffer.d.cts +45 -0
  33. package/dist/capture/replay-buffer.d.ts +45 -0
  34. package/dist/capture/replay-upload.d.cts +79 -0
  35. package/dist/capture/replay-upload.d.ts +79 -0
  36. package/dist/capture/replay.d.cts +114 -0
  37. package/dist/capture/replay.d.ts +114 -0
  38. package/dist/capture/reports.d.cts +17 -0
  39. package/dist/capture/reports.d.ts +3 -3
  40. package/dist/capture/resource-timing.d.cts +14 -0
  41. package/dist/capture/resource-timing.d.ts +2 -2
  42. package/dist/capture/server-timing.d.cts +19 -0
  43. package/dist/capture/server-timing.d.ts +3 -3
  44. package/dist/capture/storm.d.cts +13 -0
  45. package/dist/capture/storm.d.ts +7 -7
  46. package/dist/capture/types.d.cts +128 -0
  47. package/dist/capture/types.d.ts +54 -41
  48. package/dist/capture/unclean-exit.d.cts +31 -0
  49. package/dist/capture/unclean-exit.d.ts +9 -9
  50. package/dist/capture/user-timing.d.cts +22 -0
  51. package/dist/capture/user-timing.d.ts +4 -4
  52. package/dist/capture/web-socket.d.cts +40 -0
  53. package/dist/capture/web-socket.d.ts +14 -14
  54. package/dist/capture/web-vitals.d.cts +40 -0
  55. package/dist/capture/web-vitals.d.ts +21 -8
  56. package/dist/compression-CvED_Jel.cjs +2 -0
  57. package/dist/compression-CvED_Jel.cjs.map +1 -0
  58. package/dist/compression-tVtXwVjX.js +11 -0
  59. package/dist/compression-tVtXwVjX.js.map +1 -0
  60. package/dist/config-DUs7uHHt.cjs +2 -0
  61. package/dist/config-DUs7uHHt.cjs.map +1 -0
  62. package/dist/config-SgQcCP1_.js +560 -0
  63. package/dist/config-SgQcCP1_.js.map +1 -0
  64. package/dist/console-BGgGnjSi.js +81 -0
  65. package/dist/console-BGgGnjSi.js.map +1 -0
  66. package/dist/console-CSZ5_Vx5.cjs +2 -0
  67. package/dist/console-CSZ5_Vx5.cjs.map +1 -0
  68. package/dist/constants-CUyd9cTZ.js +357 -0
  69. package/dist/constants-CUyd9cTZ.js.map +1 -0
  70. package/dist/constants-CqdJhTxH.cjs +2 -0
  71. package/dist/constants-CqdJhTxH.cjs.map +1 -0
  72. package/dist/constants.d.cts +751 -0
  73. package/dist/constants.d.ts +231 -116
  74. package/dist/core/breadcrumbs.d.cts +54 -0
  75. package/dist/core/breadcrumbs.d.ts +21 -15
  76. package/dist/core/config.d.cts +45 -0
  77. package/dist/core/config.d.ts +33 -5
  78. package/dist/core/context.d.cts +24 -0
  79. package/dist/core/context.d.ts +8 -13
  80. package/dist/core/debug-buffer.d.cts +34 -0
  81. package/dist/core/debug-buffer.d.ts +13 -13
  82. package/dist/core/debug-bundle.d.cts +12 -0
  83. package/dist/core/debug-bundle.d.ts +6 -6
  84. package/dist/core/deferred.d.cts +7 -0
  85. package/dist/core/deferred.d.ts +4 -4
  86. package/dist/core/diagnostics.d.cts +86 -0
  87. package/dist/core/diagnostics.d.ts +25 -22
  88. package/dist/core/drops.d.cts +39 -0
  89. package/dist/core/drops.d.ts +22 -12
  90. package/dist/core/hold-buffer.d.cts +36 -0
  91. package/dist/core/hold-buffer.d.ts +16 -7
  92. package/dist/core/journey.d.cts +148 -0
  93. package/dist/core/journey.d.ts +28 -29
  94. package/dist/core/logger.d.cts +141 -0
  95. package/dist/core/logger.d.ts +45 -51
  96. package/dist/core/measure.d.cts +30 -0
  97. package/dist/core/measure.d.ts +21 -10
  98. package/dist/core/meter.d.cts +78 -0
  99. package/dist/core/meter.d.ts +38 -28
  100. package/dist/core/pipeline.d.cts +227 -0
  101. package/dist/core/pipeline.d.ts +114 -50
  102. package/dist/core/profile-buckets.d.cts +31 -0
  103. package/dist/core/profile-buckets.d.ts +31 -0
  104. package/dist/core/profiler.d.cts +218 -0
  105. package/dist/core/profiler.d.ts +218 -0
  106. package/dist/core/record.d.cts +190 -0
  107. package/dist/core/record.d.ts +67 -35
  108. package/dist/core/remote-rules.d.cts +17 -0
  109. package/dist/core/remote-rules.d.ts +7 -7
  110. package/dist/core/remote-sampling.d.cts +74 -0
  111. package/dist/core/remote-sampling.d.ts +24 -23
  112. package/dist/core/rotation.d.cts +75 -0
  113. package/dist/core/rotation.d.ts +75 -0
  114. package/dist/core/runtime.d.cts +765 -0
  115. package/dist/core/runtime.d.ts +430 -186
  116. package/dist/core/sampling.d.cts +86 -0
  117. package/dist/core/sampling.d.ts +22 -22
  118. package/dist/core/sender.d.cts +161 -0
  119. package/dist/core/sender.d.ts +80 -34
  120. package/dist/core/spans.d.cts +39 -0
  121. package/dist/core/spans.d.ts +6 -6
  122. package/dist/{deadline-BOjOxNHj.js → deadline-C4ccAuk5.js} +3 -6
  123. package/dist/deadline-C4ccAuk5.js.map +1 -0
  124. package/dist/deadline-CUGbto-y.cjs +2 -0
  125. package/dist/deadline-CUGbto-y.cjs.map +1 -0
  126. package/dist/debug-bundle-BXIlwDKM.cjs +2 -0
  127. package/dist/debug-bundle-BXIlwDKM.cjs.map +1 -0
  128. package/dist/debug-bundle-CRpYV_ui.js +35 -0
  129. package/dist/debug-bundle-CRpYV_ui.js.map +1 -0
  130. package/dist/defineProperty-X1c4tIPD.cjs +1 -0
  131. package/dist/defineProperty-s2S8BXUc.js +35 -0
  132. package/dist/doctor.cjs +1 -1
  133. package/dist/doctor.cjs.map +1 -1
  134. package/dist/doctor.d.cts +36 -0
  135. package/dist/doctor.d.ts +19 -6
  136. package/dist/doctor.js +180 -53
  137. package/dist/doctor.js.map +1 -1
  138. package/dist/error-like-B11pB4aL.js.map +1 -1
  139. package/dist/error-like-gGRx2s36.cjs.map +1 -1
  140. package/dist/errors-BE_EZV7Q.js +86 -0
  141. package/dist/errors-BE_EZV7Q.js.map +1 -0
  142. package/dist/errors-CNPbesMs.cjs +3 -0
  143. package/dist/errors-CNPbesMs.cjs.map +1 -0
  144. package/dist/factory-CTi0Is3F.js +404 -0
  145. package/dist/factory-CTi0Is3F.js.map +1 -0
  146. package/dist/factory-hRrH32v5.cjs +2 -0
  147. package/dist/factory-hRrH32v5.cjs.map +1 -0
  148. package/dist/fixed-window-CvESpFYV.cjs.map +1 -1
  149. package/dist/fixed-window-Dq3MLUUv.js.map +1 -1
  150. package/dist/global-scope-BN-Io_yv.cjs.map +1 -1
  151. package/dist/global-scope-D9I8s-oN.js.map +1 -1
  152. package/dist/guards-BlYGRK4l.js +10 -0
  153. package/dist/guards-BlYGRK4l.js.map +1 -0
  154. package/dist/guards-EjG3ahFp.cjs +2 -0
  155. package/dist/guards-EjG3ahFp.cjs.map +1 -0
  156. package/dist/{identity-DT5VmvXy.js → identity-DdhKgrpk.js} +11 -15
  157. package/dist/identity-DdhKgrpk.js.map +1 -0
  158. package/dist/identity-DlWRIuwy.cjs +2 -0
  159. package/dist/identity-DlWRIuwy.cjs.map +1 -0
  160. package/dist/index.cjs +1 -1
  161. package/dist/index.cjs.map +1 -1
  162. package/dist/index.d.cts +300 -0
  163. package/dist/index.d.ts +165 -141
  164. package/dist/index.js +1283 -1468
  165. package/dist/index.js.map +1 -1
  166. package/dist/indexeddb-storage-CL9uqBCy.cjs +2 -0
  167. package/dist/indexeddb-storage-CL9uqBCy.cjs.map +1 -0
  168. package/dist/{indexeddb-storage-BJVtiQKm.js → indexeddb-storage-GHdl0t8A.js} +51 -47
  169. package/dist/indexeddb-storage-GHdl0t8A.js.map +1 -0
  170. package/dist/interactions-CUkzK8sR.cjs +2 -0
  171. package/dist/interactions-CUkzK8sR.cjs.map +1 -0
  172. package/dist/{interactions-DTgKy_6K.js → interactions-DiFvCosX.js} +41 -49
  173. package/dist/interactions-DiFvCosX.js.map +1 -0
  174. package/dist/journey-B4Adltjm.cjs +2 -0
  175. package/dist/journey-B4Adltjm.cjs.map +1 -0
  176. package/dist/{journey-CuJrHzEg.js → journey-D2_sia57.js} +51 -53
  177. package/dist/journey-D2_sia57.js.map +1 -0
  178. package/dist/{library-console-C1m6g1BR.js → library-console-Btrzt814.js} +2 -2
  179. package/dist/library-console-Btrzt814.js.map +1 -0
  180. package/dist/{library-console-D2GY9Or6.cjs → library-console-CPW6bvZH.cjs} +2 -2
  181. package/dist/library-console-CPW6bvZH.cjs.map +1 -0
  182. package/dist/{library-request-BQBT9N9Q.js → library-request-BJ9PLRaD.js} +2 -2
  183. package/dist/library-request-BJ9PLRaD.js.map +1 -0
  184. package/dist/{library-request-1BX_UlaX.cjs → library-request-D7OvTxZV.cjs} +2 -2
  185. package/dist/library-request-D7OvTxZV.cjs.map +1 -0
  186. package/dist/{lifecycle-BaKx_-32.js → lifecycle-22CUCrc9.js} +21 -29
  187. package/dist/lifecycle-22CUCrc9.js.map +1 -0
  188. package/dist/lifecycle-IaAm1mOC.cjs +2 -0
  189. package/dist/lifecycle-IaAm1mOC.cjs.map +1 -0
  190. package/dist/{log-record-CAoGBBf3.js → log-record-BNiLfqtL.js} +8 -7
  191. package/dist/log-record-BNiLfqtL.js.map +1 -0
  192. package/dist/log-record-CkivuiEl.cjs +2 -0
  193. package/dist/log-record-CkivuiEl.cjs.map +1 -0
  194. package/dist/long-frames-BUUbXd-B.cjs +2 -0
  195. package/dist/long-frames-BUUbXd-B.cjs.map +1 -0
  196. package/dist/long-frames-DNFaRnC3.js +62 -0
  197. package/dist/long-frames-DNFaRnC3.js.map +1 -0
  198. package/dist/models/batch.d.cts +57 -0
  199. package/dist/models/batch.d.ts +16 -17
  200. package/dist/models/bus.d.cts +158 -0
  201. package/dist/models/bus.d.ts +46 -26
  202. package/dist/models/config.d.cts +1540 -0
  203. package/dist/models/config.d.ts +692 -405
  204. package/dist/models/drop.d.cts +54 -0
  205. package/dist/models/drop.d.ts +29 -14
  206. package/dist/models/health.d.cts +148 -0
  207. package/dist/models/health.d.ts +119 -23
  208. package/dist/models/log-record.d.cts +61 -0
  209. package/dist/models/log-record.d.ts +13 -14
  210. package/dist/models/metric.d.cts +139 -0
  211. package/dist/models/metric.d.ts +94 -18
  212. package/dist/models/plugin.d.cts +47 -0
  213. package/dist/models/plugin.d.ts +16 -16
  214. package/dist/models/replay.d.cts +60 -0
  215. package/dist/models/replay.d.ts +60 -0
  216. package/dist/models/serializer.d.cts +23 -0
  217. package/dist/models/serializer.d.ts +3 -4
  218. package/dist/models/storage.d.cts +95 -0
  219. package/dist/models/storage.d.ts +17 -14
  220. package/dist/network-CGMLQ-mA.cjs +2 -0
  221. package/dist/network-CGMLQ-mA.cjs.map +1 -0
  222. package/dist/{network-DBNwApoF.js → network-on2zZT6H.js} +57 -57
  223. package/dist/network-on2zZT6H.js.map +1 -0
  224. package/dist/openfin-Bxelt0yg.js.map +1 -1
  225. package/dist/openfin-DtH2f7zX.cjs.map +1 -1
  226. package/dist/otlp-BENHf3g9.cjs +2 -0
  227. package/dist/otlp-BENHf3g9.cjs.map +1 -0
  228. package/dist/{otlp-BTJdIa6F.js → otlp-DimfrRor.js} +22 -29
  229. package/dist/otlp-DimfrRor.js.map +1 -0
  230. package/dist/patch-BX8KrPCT.cjs.map +1 -1
  231. package/dist/patch-UdPz1ea8.js.map +1 -1
  232. package/dist/{platform-DkcuXwe-.js → platform-BaaFIPCU.js} +8 -8
  233. package/dist/platform-BaaFIPCU.js.map +1 -0
  234. package/dist/{platform-C2Ez5kDc.cjs → platform-CfA3-7sJ.cjs} +2 -2
  235. package/dist/platform-CfA3-7sJ.cjs.map +1 -0
  236. package/dist/profiler-BAZoh7A4.js +292 -0
  237. package/dist/profiler-BAZoh7A4.js.map +1 -0
  238. package/dist/profiler-D4tJpDRc.cjs +2 -0
  239. package/dist/profiler-D4tJpDRc.cjs.map +1 -0
  240. package/dist/profiler-frames-C4xr7KfH.cjs +2 -0
  241. package/dist/profiler-frames-C4xr7KfH.cjs.map +1 -0
  242. package/dist/profiler-frames-cJMx9wNM.js +78 -0
  243. package/dist/profiler-frames-cJMx9wNM.js.map +1 -0
  244. package/dist/remote-rules-Dz9MRAsB.js +95 -0
  245. package/dist/remote-rules-Dz9MRAsB.js.map +1 -0
  246. package/dist/remote-rules-_tY0zj5o.cjs +2 -0
  247. package/dist/remote-rules-_tY0zj5o.cjs.map +1 -0
  248. package/dist/replay-B3gFXIZd.cjs +2 -0
  249. package/dist/replay-B3gFXIZd.cjs.map +1 -0
  250. package/dist/replay-Ds-ANH34.js +310 -0
  251. package/dist/replay-Ds-ANH34.js.map +1 -0
  252. package/dist/reports-BDSe4dFH.cjs +2 -0
  253. package/dist/reports-BDSe4dFH.cjs.map +1 -0
  254. package/dist/{reports-TA-zInnq.js → reports-C-thq-bk.js} +25 -30
  255. package/dist/reports-C-thq-bk.js.map +1 -0
  256. package/dist/resource-timing-C576gFIQ.cjs +2 -0
  257. package/dist/resource-timing-C576gFIQ.cjs.map +1 -0
  258. package/dist/{resource-timing-BLv3EA2A.js → resource-timing-eUl2dNgC.js} +20 -23
  259. package/dist/resource-timing-eUl2dNgC.js.map +1 -0
  260. package/dist/response-body-YdNl-HkR.cjs +3 -0
  261. package/dist/response-body-YdNl-HkR.cjs.map +1 -0
  262. package/dist/response-body-eoSQpLiH.js +331 -0
  263. package/dist/response-body-eoSQpLiH.js.map +1 -0
  264. package/dist/rotation-Cwct4ckk.js +94 -0
  265. package/dist/rotation-Cwct4ckk.js.map +1 -0
  266. package/dist/rotation-D4qUAHAu.cjs +2 -0
  267. package/dist/rotation-D4qUAHAu.cjs.map +1 -0
  268. package/dist/sampling-BlrI8jor.js +63 -0
  269. package/dist/sampling-BlrI8jor.js.map +1 -0
  270. package/dist/sampling-mXt4dstx.cjs +2 -0
  271. package/dist/sampling-mXt4dstx.cjs.map +1 -0
  272. package/dist/{sanitize-6ymPlVvP.js → sanitize-Ba0KqU06.js} +2 -2
  273. package/dist/sanitize-Ba0KqU06.js.map +1 -0
  274. package/dist/{sanitize-BAWzkZt0.cjs → sanitize-DQyiI_KY.cjs} +2 -2
  275. package/dist/sanitize-DQyiI_KY.cjs.map +1 -0
  276. package/dist/sender-BdRuNVhF.cjs +2 -0
  277. package/dist/sender-BdRuNVhF.cjs.map +1 -0
  278. package/dist/sender-Dv8rAmpV.js +979 -0
  279. package/dist/sender-Dv8rAmpV.js.map +1 -0
  280. package/dist/storage/context-storage.d.cts +90 -0
  281. package/dist/storage/context-storage.d.ts +38 -37
  282. package/dist/storage/emergency-queue.d.cts +27 -0
  283. package/dist/storage/emergency-queue.d.ts +13 -13
  284. package/dist/storage/eviction.d.cts +40 -0
  285. package/dist/storage/eviction.d.ts +13 -13
  286. package/dist/storage/factory.d.cts +21 -0
  287. package/dist/storage/factory.d.ts +11 -10
  288. package/dist/storage/gap.d.cts +20 -0
  289. package/dist/storage/gap.d.ts +9 -9
  290. package/dist/storage/idb-driver.d.cts +93 -0
  291. package/dist/storage/idb-driver.d.ts +32 -33
  292. package/dist/storage/indexeddb-storage.d.cts +97 -0
  293. package/dist/storage/indexeddb-storage.d.ts +38 -31
  294. package/dist/storage/keys.d.cts +17 -0
  295. package/dist/storage/keys.d.ts +9 -9
  296. package/dist/storage/local-storage.d.cts +139 -0
  297. package/dist/storage/local-storage.d.ts +49 -42
  298. package/dist/storage/memory-storage.d.cts +73 -0
  299. package/dist/storage/memory-storage.d.ts +25 -25
  300. package/dist/storage/persistence.d.cts +8 -0
  301. package/dist/storage/persistence.d.ts +3 -3
  302. package/dist/storage/stored-context.d.cts +34 -0
  303. package/dist/storage/stored-context.d.ts +34 -0
  304. package/dist/stored-context-B2EzVuYm.js +51 -0
  305. package/dist/stored-context-B2EzVuYm.js.map +1 -0
  306. package/dist/stored-context-CXt7eHZL.cjs +2 -0
  307. package/dist/stored-context-CXt7eHZL.cjs.map +1 -0
  308. package/dist/storm-C-zYSdDX.cjs +2 -0
  309. package/dist/storm-C-zYSdDX.cjs.map +1 -0
  310. package/dist/storm-DjKetLKZ.js +9 -0
  311. package/dist/storm-DjKetLKZ.js.map +1 -0
  312. package/dist/transport/compression.d.cts +7 -0
  313. package/dist/transport/compression.d.ts +2 -2
  314. package/dist/transport/custom-transport.d.cts +22 -0
  315. package/dist/transport/custom-transport.d.ts +6 -5
  316. package/dist/transport/errors.d.cts +31 -0
  317. package/dist/transport/errors.d.ts +7 -7
  318. package/dist/transport/exit-flush.d.cts +135 -0
  319. package/dist/transport/exit-flush.d.ts +62 -45
  320. package/dist/transport/headers.d.cts +8 -0
  321. package/dist/transport/headers.d.ts +4 -4
  322. package/dist/transport/http-transport.d.cts +116 -0
  323. package/dist/transport/http-transport.d.ts +48 -35
  324. package/dist/transport/memory-transport.d.cts +30 -0
  325. package/dist/transport/memory-transport.d.ts +8 -8
  326. package/dist/transport/response-body.d.cts +49 -0
  327. package/dist/transport/response-body.d.ts +49 -0
  328. package/dist/transport/retry-engine.d.cts +129 -0
  329. package/dist/transport/retry-engine.d.ts +62 -43
  330. package/dist/transport/serializers/ecs.d.cts +3 -0
  331. package/dist/transport/serializers/ecs.d.ts +2 -2
  332. package/dist/transport/serializers/otlp-metrics.d.cts +3 -0
  333. package/dist/transport/serializers/otlp-metrics.d.ts +2 -2
  334. package/dist/transport/serializers/otlp-traces.d.cts +3 -0
  335. package/dist/transport/serializers/otlp-traces.d.ts +2 -2
  336. package/dist/transport/serializers/otlp.d.cts +47 -0
  337. package/dist/transport/serializers/otlp.d.ts +18 -18
  338. package/dist/transport/serializers/select.d.cts +38 -0
  339. package/dist/transport/serializers/select.d.ts +11 -11
  340. package/dist/transport/status-transport.d.cts +129 -0
  341. package/dist/transport/status-transport.d.ts +45 -28
  342. package/dist/transport/worker-client.d.cts +23 -0
  343. package/dist/transport/worker-client.d.ts +12 -3
  344. package/dist/transport/worker-entry.d.cts +5 -0
  345. package/dist/transport/worker-entry.d.ts +1 -1
  346. package/dist/transport/worker-protocol.d.cts +38 -0
  347. package/dist/transport/worker-protocol.d.ts +7 -5
  348. package/dist/transport/worker-server.d.cts +3 -0
  349. package/dist/transport/worker-server.d.ts +1 -1
  350. package/dist/transport/worker-transport.d.cts +10 -0
  351. package/dist/transport/worker-transport.d.ts +5 -4
  352. package/dist/types-BAerHgCq.js.map +1 -1
  353. package/dist/types-C7WNpnG1.cjs.map +1 -1
  354. package/dist/{unclean-exit-CwcUhFOn.js → unclean-exit-DQD1cT7c.js} +23 -30
  355. package/dist/unclean-exit-DQD1cT7c.js.map +1 -0
  356. package/dist/unclean-exit-py99ApzT.cjs +2 -0
  357. package/dist/unclean-exit-py99ApzT.cjs.map +1 -0
  358. package/dist/unref-CU9Nyz_9.cjs +2 -0
  359. package/dist/unref-CU9Nyz_9.cjs.map +1 -0
  360. package/dist/unref-DgHPQeWv.js +7 -0
  361. package/dist/unref-DgHPQeWv.js.map +1 -0
  362. package/dist/{user-timing-_jZIhDKI.js → user-timing-BePqb1uN.js} +18 -18
  363. package/dist/user-timing-BePqb1uN.js.map +1 -0
  364. package/dist/user-timing-D6XTmpuM.cjs +2 -0
  365. package/dist/user-timing-D6XTmpuM.cjs.map +1 -0
  366. package/dist/utils/console.d.cts +36 -0
  367. package/dist/utils/console.d.ts +6 -6
  368. package/dist/utils/deadline.d.cts +14 -0
  369. package/dist/utils/deadline.d.ts +4 -4
  370. package/dist/utils/error-like.d.cts +25 -0
  371. package/dist/utils/error-like.d.ts +7 -7
  372. package/dist/utils/fixed-window.d.cts +25 -0
  373. package/dist/utils/fixed-window.d.ts +9 -8
  374. package/dist/utils/global-scope.d.cts +20 -0
  375. package/dist/utils/global-scope.d.ts +8 -8
  376. package/dist/utils/guards.d.cts +14 -0
  377. package/dist/utils/guards.d.ts +10 -2
  378. package/dist/utils/identity.d.cts +109 -0
  379. package/dist/utils/identity.d.ts +20 -21
  380. package/dist/utils/library-console.d.cts +11 -0
  381. package/dist/utils/library-console.d.ts +4 -4
  382. package/dist/utils/library-request.d.cts +24 -0
  383. package/dist/utils/library-request.d.ts +10 -10
  384. package/dist/utils/lock.d.cts +24 -0
  385. package/dist/utils/lock.d.ts +11 -10
  386. package/dist/utils/openfin.d.cts +48 -0
  387. package/dist/utils/openfin.d.ts +5 -5
  388. package/dist/utils/patch.d.cts +9 -0
  389. package/dist/utils/patch.d.ts +6 -6
  390. package/dist/utils/platform.d.cts +62 -0
  391. package/dist/utils/platform.d.ts +15 -13
  392. package/dist/utils/sanitize.d.cts +52 -0
  393. package/dist/utils/sanitize.d.ts +5 -5
  394. package/dist/utils/sequence.d.cts +10 -0
  395. package/dist/utils/tracing.d.cts +158 -0
  396. package/dist/utils/tracing.d.ts +49 -42
  397. package/dist/utils/unref.d.cts +9 -0
  398. package/dist/utils/unref.d.ts +3 -3
  399. package/dist/web-socket-CoIUBM3C.cjs +2 -0
  400. package/dist/web-socket-CoIUBM3C.cjs.map +1 -0
  401. package/dist/{web-socket-CV7yIMnm.js → web-socket-DSHgDiZ6.js} +23 -28
  402. package/dist/web-socket-DSHgDiZ6.js.map +1 -0
  403. package/dist/web-vitals-4pWACwaR.js +71 -0
  404. package/dist/web-vitals-4pWACwaR.js.map +1 -0
  405. package/dist/web-vitals-__X7t4pj.cjs +2 -0
  406. package/dist/web-vitals-__X7t4pj.cjs.map +1 -0
  407. package/dist/worker-protocol-QbvqNazn.cjs +2 -0
  408. package/dist/worker-protocol-QbvqNazn.cjs.map +1 -0
  409. package/dist/{worker-protocol-CrsdSDLn.js → worker-protocol-x074Rpet.js} +14 -11
  410. package/dist/worker-protocol-x074Rpet.js.map +1 -0
  411. package/dist/worker-server-CFe4nvos.cjs +2 -0
  412. package/dist/worker-server-CFe4nvos.cjs.map +1 -0
  413. package/dist/worker-server-iUVSjH8L.js +94 -0
  414. package/dist/worker-server-iUVSjH8L.js.map +1 -0
  415. package/dist/worker-transport-CRAX-09c.cjs +2 -0
  416. package/dist/worker-transport-CRAX-09c.cjs.map +1 -0
  417. package/dist/worker-transport-Dy1KMA7t.js +190 -0
  418. package/dist/worker-transport-Dy1KMA7t.js.map +1 -0
  419. package/llms.txt +397 -0
  420. package/package.json +55 -41
  421. package/dist/batch-C8OcWR2L.cjs.map +0 -1
  422. package/dist/batch-CL9uWYY3.js.map +0 -1
  423. package/dist/bus-BZ0GldpT.js +0 -660
  424. package/dist/bus-BZ0GldpT.js.map +0 -1
  425. package/dist/bus-VWlmM5xs.cjs +0 -2
  426. package/dist/bus-VWlmM5xs.cjs.map +0 -1
  427. package/dist/console-BPZCuSLc.cjs +0 -2
  428. package/dist/console-BPZCuSLc.cjs.map +0 -1
  429. package/dist/console-BeCF7n59.js +0 -82
  430. package/dist/console-BeCF7n59.js.map +0 -1
  431. package/dist/constants-DqKJH_MP.cjs +0 -2
  432. package/dist/constants-DqKJH_MP.cjs.map +0 -1
  433. package/dist/constants-zyrqveN4.js +0 -304
  434. package/dist/constants-zyrqveN4.js.map +0 -1
  435. package/dist/context-storage-BjzeBSxH.cjs +0 -2
  436. package/dist/context-storage-BjzeBSxH.cjs.map +0 -1
  437. package/dist/context-storage-BzkoHzkQ.js +0 -51
  438. package/dist/context-storage-BzkoHzkQ.js.map +0 -1
  439. package/dist/deadline-BOjOxNHj.js.map +0 -1
  440. package/dist/deadline-XSnm95pg.cjs +0 -2
  441. package/dist/deadline-XSnm95pg.cjs.map +0 -1
  442. package/dist/debug-bundle-BzJNpbF0.cjs +0 -2
  443. package/dist/debug-bundle-BzJNpbF0.cjs.map +0 -1
  444. package/dist/debug-bundle-C7UkHZ-q.js +0 -25
  445. package/dist/debug-bundle-C7UkHZ-q.js.map +0 -1
  446. package/dist/emergency-queue-CNTRui5t.cjs +0 -2
  447. package/dist/emergency-queue-CNTRui5t.cjs.map +0 -1
  448. package/dist/emergency-queue-Zy6lNafo.js +0 -67
  449. package/dist/emergency-queue-Zy6lNafo.js.map +0 -1
  450. package/dist/errors-Dh7kef0i.js +0 -92
  451. package/dist/errors-Dh7kef0i.js.map +0 -1
  452. package/dist/errors-tfEr48bS.cjs +0 -3
  453. package/dist/errors-tfEr48bS.cjs.map +0 -1
  454. package/dist/factory-BonqI3NL.js +0 -276
  455. package/dist/factory-BonqI3NL.js.map +0 -1
  456. package/dist/factory-CJXVYp0R.cjs +0 -2
  457. package/dist/factory-CJXVYp0R.cjs.map +0 -1
  458. package/dist/guards-Cidk71ME.js +0 -7
  459. package/dist/guards-Cidk71ME.js.map +0 -1
  460. package/dist/guards-nJ70syPt.cjs +0 -2
  461. package/dist/guards-nJ70syPt.cjs.map +0 -1
  462. package/dist/identity-Cxgj6pZX.cjs +0 -2
  463. package/dist/identity-Cxgj6pZX.cjs.map +0 -1
  464. package/dist/identity-DT5VmvXy.js.map +0 -1
  465. package/dist/indexeddb-storage-BJVtiQKm.js.map +0 -1
  466. package/dist/indexeddb-storage-CIoW21Xd.cjs +0 -2
  467. package/dist/indexeddb-storage-CIoW21Xd.cjs.map +0 -1
  468. package/dist/interactions-DTgKy_6K.js.map +0 -1
  469. package/dist/interactions-fEN6FbVo.cjs +0 -2
  470. package/dist/interactions-fEN6FbVo.cjs.map +0 -1
  471. package/dist/journey-CuJrHzEg.js.map +0 -1
  472. package/dist/journey-pffMVMfa.cjs +0 -2
  473. package/dist/journey-pffMVMfa.cjs.map +0 -1
  474. package/dist/keys-BHhw_0Wh.cjs +0 -2
  475. package/dist/keys-BHhw_0Wh.cjs.map +0 -1
  476. package/dist/keys-BU9j5YqW.js +0 -16
  477. package/dist/keys-BU9j5YqW.js.map +0 -1
  478. package/dist/library-console-C1m6g1BR.js.map +0 -1
  479. package/dist/library-console-D2GY9Or6.cjs.map +0 -1
  480. package/dist/library-request-1BX_UlaX.cjs.map +0 -1
  481. package/dist/library-request-BQBT9N9Q.js.map +0 -1
  482. package/dist/lifecycle-2EtUaRpo.cjs +0 -2
  483. package/dist/lifecycle-2EtUaRpo.cjs.map +0 -1
  484. package/dist/lifecycle-BaKx_-32.js.map +0 -1
  485. package/dist/log-record-CAoGBBf3.js.map +0 -1
  486. package/dist/log-record-i9zOTkpQ.cjs +0 -2
  487. package/dist/log-record-i9zOTkpQ.cjs.map +0 -1
  488. package/dist/long-frames-BVg4i5SC.cjs +0 -2
  489. package/dist/long-frames-BVg4i5SC.cjs.map +0 -1
  490. package/dist/long-frames-Czk7IupC.js +0 -64
  491. package/dist/long-frames-Czk7IupC.js.map +0 -1
  492. package/dist/models/stats.d.ts +0 -11
  493. package/dist/network-DBNwApoF.js.map +0 -1
  494. package/dist/network-xbbuvG_6.cjs +0 -2
  495. package/dist/network-xbbuvG_6.cjs.map +0 -1
  496. package/dist/otlp-BDvFrLnc.cjs +0 -2
  497. package/dist/otlp-BDvFrLnc.cjs.map +0 -1
  498. package/dist/otlp-BTJdIa6F.js.map +0 -1
  499. package/dist/platform-C2Ez5kDc.cjs.map +0 -1
  500. package/dist/platform-DkcuXwe-.js.map +0 -1
  501. package/dist/remote-rules-Cfb4K-Nl.js +0 -98
  502. package/dist/remote-rules-Cfb4K-Nl.js.map +0 -1
  503. package/dist/remote-rules-vzvk7aKf.cjs +0 -2
  504. package/dist/remote-rules-vzvk7aKf.cjs.map +0 -1
  505. package/dist/reports-Dk2YhKIh.cjs +0 -2
  506. package/dist/reports-Dk2YhKIh.cjs.map +0 -1
  507. package/dist/reports-TA-zInnq.js.map +0 -1
  508. package/dist/resource-timing-BLv3EA2A.js.map +0 -1
  509. package/dist/resource-timing-Cysw1S1f.cjs +0 -2
  510. package/dist/resource-timing-Cysw1S1f.cjs.map +0 -1
  511. package/dist/sampling-C4VV-1MS.js +0 -60
  512. package/dist/sampling-C4VV-1MS.js.map +0 -1
  513. package/dist/sampling-Ckh2yW9k.cjs +0 -2
  514. package/dist/sampling-Ckh2yW9k.cjs.map +0 -1
  515. package/dist/sanitize-6ymPlVvP.js.map +0 -1
  516. package/dist/sanitize-BAWzkZt0.cjs.map +0 -1
  517. package/dist/select-ZF4by-lF.cjs +0 -3
  518. package/dist/select-ZF4by-lF.cjs.map +0 -1
  519. package/dist/select-xtQaenIi.js +0 -270
  520. package/dist/select-xtQaenIi.js.map +0 -1
  521. package/dist/sender-CiMHC9YG.js +0 -856
  522. package/dist/sender-CiMHC9YG.js.map +0 -1
  523. package/dist/sender-D5wBoXA8.cjs +0 -2
  524. package/dist/sender-D5wBoXA8.cjs.map +0 -1
  525. package/dist/storage-BA9RqRO-.cjs +0 -2
  526. package/dist/storage-BA9RqRO-.cjs.map +0 -1
  527. package/dist/storage-DZwed89z.js +0 -16
  528. package/dist/storage-DZwed89z.js.map +0 -1
  529. package/dist/storm-CYi9Swpx.cjs +0 -2
  530. package/dist/storm-CYi9Swpx.cjs.map +0 -1
  531. package/dist/storm-VR024_QN.js +0 -9
  532. package/dist/storm-VR024_QN.js.map +0 -1
  533. package/dist/unclean-exit-CwcUhFOn.js.map +0 -1
  534. package/dist/unclean-exit-DFUN57wY.cjs +0 -2
  535. package/dist/unclean-exit-DFUN57wY.cjs.map +0 -1
  536. package/dist/user-timing-C9kfRq3J.cjs +0 -2
  537. package/dist/user-timing-C9kfRq3J.cjs.map +0 -1
  538. package/dist/user-timing-_jZIhDKI.js.map +0 -1
  539. package/dist/utils/timer.d.ts +0 -19
  540. package/dist/web-socket-BWUoqBh8.cjs +0 -2
  541. package/dist/web-socket-BWUoqBh8.cjs.map +0 -1
  542. package/dist/web-socket-CV7yIMnm.js.map +0 -1
  543. package/dist/web-vitals-Bq4WFHQo.js +0 -52
  544. package/dist/web-vitals-Bq4WFHQo.js.map +0 -1
  545. package/dist/web-vitals-DFuoTQbZ.cjs +0 -2
  546. package/dist/web-vitals-DFuoTQbZ.cjs.map +0 -1
  547. package/dist/worker-protocol-Bai7GAIA.cjs +0 -2
  548. package/dist/worker-protocol-Bai7GAIA.cjs.map +0 -1
  549. package/dist/worker-protocol-CrsdSDLn.js.map +0 -1
  550. package/dist/worker-server-BrIYkfoa.cjs +0 -2
  551. package/dist/worker-server-BrIYkfoa.cjs.map +0 -1
  552. package/dist/worker-server-Dp5HYm4b.js +0 -83
  553. package/dist/worker-server-Dp5HYm4b.js.map +0 -1
  554. package/dist/worker-transport-Bwej4N2e.cjs +0 -2
  555. package/dist/worker-transport-Bwej4N2e.cjs.map +0 -1
  556. package/dist/worker-transport-D6jtgpqN.js +0 -199
  557. package/dist/worker-transport-D6jtgpqN.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-transport-Dy1KMA7t.js","names":["HEADER_ATTEMPT","WORKER_REPLY_GRACE_MS","TRANSPORT_WORKER_TYPE","HEADER_BATCH_ID","withDeadline","DeadlineError","isOnline","TransportError","batchKind","endpointFor","StatusTransport","resolveHeaders","HttpTransport","resetHeaders","CREDENTIAL_ADVICE","unrefTimer","workerMessage","isWorkerMessage","isWorkerResult","_defineProperty","WorkerFault","kind","createWorkerClient","session","closed","sequence","inactive","signal","fail","old","diagnostics","pending","post","error","connect","worker","factory","channel","current","onMessage","message","event","id","onError","finish","cancel","reject","abort","timer","graceMs","timeoutMs","job","WorkerTransport","config","onSampling","loss","onClock","http","batch","endpoint","client","hidden","onKeepalive","result","timeout","end","last","deadline","values","remaining","headers","createWorkerTransport","onLoss"],"sources":["../src/transport/worker-client.ts","../src/transport/worker-transport.ts"],"sourcesContent":["import { TRANSPORT_WORKER_TYPE } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { unrefTimer } from \"../utils/unref\";\nimport {\n isWorkerMessage,\n isWorkerResult,\n workerMessage,\n type WorkerJob,\n type WorkerResult,\n} from \"./worker-protocol\";\n\n/** A channel failure permits HTTP fallback. A timeout keeps the retry policy. */\nexport class WorkerFault extends Error {\n constructor(readonly kind: \"channel\" | \"timeout\" | \"cancelled\") {\n super(\"The transport worker did not complete the request.\");\n }\n}\n\n/** One pending request on the private channel. */\ninterface Pending {\n job: WorkerJob;\n resolve: (result: WorkerResult) => void;\n reject: (error: WorkerFault) => void;\n}\n\n/** One connection to one worker. */\ninterface Session {\n worker: Worker;\n port: MessagePort;\n ready: boolean;\n pending: Map<number, Pending>;\n detach: () => void;\n}\n\n/** Private channel operations of the HTTP worker adapter. */\nexport interface WorkerClient {\n /**\n * Sends one job to the worker.\n * @param job The job.\n * @param signal Cancels the job.\n * @param timeoutMs Wait for the worker's ready answer, and then for its result.\n * @param graceMs Extra wait for the result of a ready worker, which enforces the deadline\n * itself and may reply with a status at the deadline.\n * @returns The worker's result.\n */\n send(\n job: WorkerJob,\n signal: AbortSignal,\n timeoutMs: number,\n graceMs: number,\n ): Promise<WorkerResult>;\n close(): void;\n}\n\n/** Opens a private message port. The worker factory stays on the main thread. */\nexport function createWorkerClient(factory: () => Worker, diagnostics: Diagnostics): WorkerClient {\n let session: Session | undefined;\n let closed = false;\n let sequence = 0;\n\n const inactive = (signal: AbortSignal): boolean => closed || signal.aborted;\n\n const fail = (): void => {\n const old = session;\n session = undefined;\n if (!old) {\n return;\n }\n diagnostics.guard(\"transport.http_error\", \"The transport worker could not be closed.\", () => {\n old.detach();\n });\n diagnostics.guard(\"transport.http_error\", \"The transport port could not be closed.\", () => {\n old.port.close();\n });\n diagnostics.guard(\n \"transport.http_error\",\n \"The transport worker could not be terminated.\",\n () => {\n old.worker.terminate();\n },\n );\n for (const pending of old.pending.values()) {\n pending.reject(new WorkerFault(\"channel\"));\n }\n old.pending.clear();\n };\n\n const post = (current: Session, id: number, job: WorkerJob): void => {\n try {\n current.port.postMessage(workerMessage(TRANSPORT_WORKER_TYPE.send, { id, job }));\n } catch (error) {\n diagnostics.report(\n \"transport.http_error\",\n \"The transport worker could not clone its batch.\",\n undefined,\n error,\n );\n fail();\n }\n };\n\n const connect = (): Session => {\n if (session) {\n return session;\n }\n let worker: Worker | undefined;\n try {\n worker = factory();\n const channel = new MessageChannel();\n const current: Session = {\n worker,\n port: channel.port1,\n ready: false,\n pending: new Map(),\n detach: () => undefined,\n };\n session = current;\n const onMessage = (event: MessageEvent<unknown>): void => {\n const message = event.data;\n if (!isWorkerMessage(message)) {\n fail();\n return;\n }\n if (message.t === TRANSPORT_WORKER_TYPE.ready) {\n if (message.ok !== true) {\n fail();\n return;\n }\n if (!current.ready) {\n current.ready = true;\n for (const [id, pending] of current.pending) {\n post(current, id, pending.job);\n }\n }\n return;\n }\n if (\n message.t !== TRANSPORT_WORKER_TYPE.result ||\n typeof message.id !== \"number\" ||\n !isWorkerResult(message.result)\n ) {\n fail();\n return;\n }\n\n current.pending.get(message.id)?.resolve(message.result);\n };\n const onError = (): void => {\n fail();\n };\n current.port.addEventListener(\"message\", onMessage);\n current.port.addEventListener(\"messageerror\", onError);\n worker.addEventListener(\"error\", onError);\n worker.addEventListener(\"messageerror\", onError);\n current.detach = () => {\n current.port.removeEventListener(\"message\", onMessage);\n current.port.removeEventListener(\"messageerror\", onError);\n current.worker.removeEventListener(\"error\", onError);\n current.worker.removeEventListener(\"messageerror\", onError);\n };\n current.port.start();\n worker.postMessage(workerMessage(TRANSPORT_WORKER_TYPE.connect), [channel.port2]);\n return current;\n } catch (error) {\n diagnostics.report(\n \"transport.http_error\",\n \"The transport worker could not start.\",\n undefined,\n error,\n );\n fail();\n diagnostics.guard(\"transport.http_error\", \"The transport worker could not stop.\", () =>\n worker?.terminate(),\n );\n throw new WorkerFault(\"channel\");\n }\n };\n\n return {\n send: async (job, signal, timeoutMs, graceMs) => {\n if (inactive(signal)) {\n throw new WorkerFault(\"cancelled\");\n }\n const current = connect();\n if (inactive(signal)) {\n fail();\n throw new WorkerFault(\"cancelled\");\n }\n const id = ++sequence;\n let finish!: () => void;\n try {\n return await new Promise<WorkerResult>((resolve, reject) => {\n const cancel = (kind: \"timeout\" | \"cancelled\"): void => {\n current.pending.delete(id);\n diagnostics.guard(\n \"transport.http_error\",\n \"The transport worker request could not be cancelled.\",\n () => {\n current.port.postMessage(workerMessage(TRANSPORT_WORKER_TYPE.cancel, { id }));\n },\n );\n reject(new WorkerFault(kind));\n };\n const abort = (): void => {\n cancel(\"cancelled\");\n };\n let timer = setTimeout(() => {\n // A worker that hasn't answered ready hasn't started, so HTTP can't duplicate its\n // unsent job.\n if (!current.ready) {\n fail();\n return;\n }\n\n timer = setTimeout(() => {\n cancel(\"timeout\");\n }, graceMs);\n unrefTimer(timer);\n }, timeoutMs);\n unrefTimer(timer);\n finish = () => {\n clearTimeout(timer);\n signal.removeEventListener(\"abort\", abort);\n current.pending.delete(id);\n };\n current.pending.set(id, { job, resolve, reject });\n signal.addEventListener(\"abort\", abort, { once: true });\n if (current.ready) {\n post(current, id, job);\n }\n });\n } finally {\n finish();\n }\n },\n close: () => {\n closed = true;\n fail();\n },\n };\n}\n","import {\n HEADER_ATTEMPT,\n HEADER_BATCH_ID,\n HTTP_FORBIDDEN,\n HTTP_SUCCESS_END,\n HTTP_SUCCESS_MIN,\n HTTP_UNAUTHORIZED,\n WORKER_REPLY_GRACE_MS,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { LogBatch } from \"../models/batch\";\nimport type { BatchKind, ResolvedConfig } from \"../models/config\";\nimport type { LossReporter } from \"../models/drop\";\nimport { DeadlineError, withDeadline } from \"../utils/deadline\";\nimport { isOnline } from \"../utils/platform\";\nimport { TransportError } from \"./errors\";\nimport { resetHeaders, resolveHeaders } from \"./headers\";\nimport { CREDENTIAL_ADVICE, HttpTransport } from \"./http-transport\";\nimport { batchKind, endpointFor } from \"./serializers/select\";\nimport { StatusTransport } from \"./status-transport\";\nimport { createWorkerClient, WorkerFault, type WorkerClient } from \"./worker-client\";\nimport type { WorkerResult } from \"./worker-protocol\";\n\n/** Main-thread policy around the private worker channel. */\nclass WorkerTransport extends StatusTransport {\n private client: WorkerClient | undefined;\n\n private source: ResolvedConfig[\"transportWorker\"];\n\n private disabled = false;\n\n constructor(\n config: ResolvedConfig,\n diagnostics: Diagnostics,\n private readonly http: HttpTransport,\n onSampling: (raw: unknown) => void,\n private readonly loss: LossReporter,\n onClock: (offsetMs: number) => void,\n ) {\n super(config, diagnostics, onSampling, loss, onClock);\n }\n\n /**\n * Encodes and sends in the worker. Hidden pages keep the main HTTP keepalive path.\n * @param batch Batch to send.\n * @param onKeepalive Runs when one of the batch's requests starts with keepalive.\n * @returns Promise that resolves to the records lost in a send that ends without an error.\n */\n async send(batch: LogBatch, onKeepalive?: () => void): Promise<number> {\n this.assertContext(batch);\n const kind = batchKind(batch, this.config);\n const endpoint = endpointFor(kind, this.config);\n if (!endpoint) {\n this.diagnostics.count(\"record.dropped_no_destination\");\n return batch.records.length;\n }\n if (batch.records.length === 0) {\n return 0;\n }\n\n const client = this.workerClient();\n const hidden = typeof document !== \"undefined\" && document.visibilityState === \"hidden\";\n if (!client || typeof this.config.serializer !== \"string\" || hidden) {\n return this.http.send(batch, onKeepalive);\n }\n\n let result: WorkerResult;\n try {\n result = await this.attempt(client, batch, kind, endpoint, this.config.serializer);\n this.assertContext(batch);\n if (\n \"status\" in result &&\n (result.status === HTTP_UNAUTHORIZED || result.status === HTTP_FORBIDDEN) &&\n typeof this.config.headers === \"function\"\n ) {\n resetHeaders(this.http);\n result = await this.attempt(client, batch, kind, endpoint, this.config.serializer);\n this.assertContext(batch);\n }\n if (\"failure\" in result && result.failure === \"protocol\") {\n throw new WorkerFault(\"channel\");\n }\n } catch (error) {\n this.diagnostics.report(\n \"transport.http_error\",\n \"The transport worker request failed.\",\n undefined,\n error,\n );\n this.assertContext(batch);\n if (\n error instanceof DeadlineError ||\n (error instanceof WorkerFault && error.kind === \"timeout\")\n ) {\n this.diagnostics.report(\n \"transport.timeout\",\n \"The transport worker request exceeded its time limit.\",\n );\n throw new TransportError(\n \"timeout\",\n \"The transport worker request exceeded its time limit.\",\n );\n }\n if (error instanceof WorkerFault && error.kind === \"channel\") {\n if (this.client === client) {\n this.disabled = true;\n client.close();\n }\n return this.http.send(batch, onKeepalive);\n }\n throw new TransportError(\"transient\", \"The transport worker request failed.\");\n }\n\n if (\"failure\" in result) {\n if (result.failure === \"serialize\") {\n this.diagnostics.report(\n \"transport.serialize_failed\",\n \"The transport worker could not serialize its batch.\",\n { batchId: batch.id },\n );\n this.loss(\"unserializable\", batch.records, [batch.id]);\n return batch.records.length;\n }\n const timeout = result.failure === \"timeout\";\n this.diagnostics.report(\n timeout ? \"transport.timeout\" : \"transport.http_error\",\n \"The transport worker did not send its batch.\",\n );\n // An offline failure must not use up a stored attempt. The HTTP path applies the same rule.\n throw new TransportError(\n timeout ? \"timeout\" : isOnline() ? \"transient\" : \"offline\",\n \"The transport worker did not send its batch.\",\n );\n }\n if (result.compressionFailed) {\n this.diagnostics.report(\n \"transport.http_error\",\n \"The transport worker sent its batch without gzip after a compression failure.\",\n );\n }\n if (result.status >= HTTP_SUCCESS_MIN && result.status < HTTP_SUCCESS_END) {\n this.accept(kind, result.sampling, result.date);\n return result.body === undefined ? 0 : this.reportPartial(batch, kind, result.body);\n }\n throw this.reject(result.status, batch.id, kind, {\n retryAfterMs: result.retryAfterMs,\n maxBytes: result.maxBytes,\n advice: CREDENTIAL_ADVICE,\n });\n }\n\n /** Keeps throttle state from both the worker and the hidden-page HTTP path. */\n override throttledForMs(batch: LogBatch): number {\n return Math.max(super.throttledForMs(batch), this.http.throttledForMs(batch));\n }\n\n /** Returns the latest throttle end from either path. */\n override throttleEnd(): number | null {\n const end = Math.max(super.throttleEnd() ?? -Infinity, this.http.throttleEnd() ?? -Infinity);\n return Number.isFinite(end) ? end : null;\n }\n\n /** Returns the last accepted send from either path. */\n override lastSendAt(): number | null {\n const last = Math.max(super.lastSendAt() ?? -Infinity, this.http.lastSendAt() ?? -Infinity);\n return Number.isFinite(last) ? last : null;\n }\n\n /** Stops both paths before a delivery identity change or shutdown. */\n override stop(): void {\n super.stop();\n this.client?.close();\n this.http.stop();\n }\n\n private workerClient(): WorkerClient | undefined {\n const factory = this.config.transportWorker;\n if (factory !== this.source) {\n this.client?.close();\n this.client = undefined;\n this.source = factory;\n this.disabled = false;\n }\n if (!factory || this.disabled) {\n return undefined;\n }\n this.client ??= createWorkerClient(factory, this.diagnostics);\n return this.client;\n }\n\n /** One deadline covers the main headers function and the worker operation. */\n private async attempt(\n client: WorkerClient,\n batch: LogBatch,\n kind: BatchKind,\n endpoint: string,\n serializer: \"otlp\" | \"ecs\",\n ): Promise<WorkerResult> {\n const timeoutMs = this.config.delivery.requestTimeoutMs;\n const deadline = Date.now() + timeoutMs;\n const values = await withDeadline(\n this.untilCancelled(resolveHeaders(this.http, this.config, this.diagnostics)),\n timeoutMs,\n );\n this.assertContext(batch);\n const remaining = deadline - Date.now();\n if (remaining <= 0) {\n throw new DeadlineError(timeoutMs);\n }\n const headers = new Headers(values);\n headers.set(HEADER_BATCH_ID, batch.id);\n headers.set(HEADER_ATTEMPT, String(batch.attempts));\n return client.send(\n {\n batch,\n kind,\n endpoint,\n serializer,\n headers: Object.fromEntries(headers),\n compression: this.config.compression,\n credentials: this.config.credentials,\n priority: this.config.delivery.priority,\n timeoutMs: remaining,\n deadlineMs: deadline,\n },\n this.cancellation.signal,\n remaining,\n // The worker enforces the deadline itself. Without the grace, our timer fires first and\n // a 2xx the worker got in time comes back as a timeout, so the batch goes out again.\n WORKER_REPLY_GRACE_MS,\n );\n }\n}\n\n/** Creates the worker adapter without adding a package entry point or a runtime dependency. */\nexport function createWorkerTransport(\n config: ResolvedConfig,\n diagnostics: Diagnostics,\n onSampling: (raw: unknown) => void,\n onLoss: LossReporter,\n onClock: (offsetMs: number) => void,\n): {\n transport: StatusTransport;\n exitHeaders: () => Record<string, string> | undefined;\n keepaliveInFlight: () => number;\n} {\n const http = new HttpTransport(config, diagnostics, onSampling, onLoss, onClock);\n return {\n transport: new WorkerTransport(config, diagnostics, http, onSampling, onLoss, onClock),\n exitHeaders: () => http.lastHeaders(),\n // The worker's own fetch has no keepalive, so only the hidden-page HTTP path uses this budget.\n // Hypothesis from the Fetch spec: a worker is its own fetch group, with a budget of its own.\n keepaliveInFlight: () => http.keepaliveInFlight(),\n };\n}\n"],"mappings":";;;;;;;;;AAYA,IAAaoB,IAAb,cAAiC,MAAM;CACrC,YAAY,GAAoD;EAA3C,AACnB,MAAM,oDAAoD,GADvCD,EAAA,MAAA,QAAA,KAAA,CAAA,GAAA,KAAA,OAAAE;CAErB;AACF;AAuCA,SAAgBC,EAAmB,GAAuB,GAAwC;CAChG,IAAIC,GACAC,IAAS,IACTC,IAAW,GAETC,KAAY,MAAiCF,KAAUG,EAAO,SAE9DC,UAAmB;EACvB,IAAMC,IAAMN;EAEZ,IADA,IAAU,KAAA,GACLM,GAGL;GAMA,AANAC,EAAY,MAAM,wBAAwB,mDAAmD;IAC3F,EAAI,OAAO;GACb,CAAC,GACDA,EAAY,MAAM,wBAAwB,iDAAiD;IACzF,EAAI,KAAK,MAAM;GACjB,CAAC,GACDA,EAAY,MACV,wBACA,uDACM;IACJ,EAAI,OAAO,UAAU;GACvB,CACF;GACA,KAAK,IAAMC,KAAWF,EAAI,QAAQ,OAAO,GACvC,EAAQ,OAAO,IAAIT,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,eAAeO,EAAe,KAAK,MAAM,KAAK,QAAQ,KAAK,WAAW,CAAC,GAC5EuC,CACF;EACA,KAAK,cAAcQ,CAAK;EACxB,IAAMW,IAAYF,IAAW,KAAK,IAAI;EACtC,IAAIE,KAAa,GACf,MAAM,IAAIhE,EAAc6C,CAAS;EAEnC,IAAMoB,IAAU,IAAI,QAAQF,CAAM;EAGlC,OAFAE,EAAQ,IAAInE,GAAiBuD,EAAM,EAAE,GACrCY,EAAQ,IAAItE,GAAgB,OAAO0D,EAAM,QAAQ,CAAC,GAC3CE,EAAO,KACZ;GACE;GACA;GACA;GACA;GACA,SAAS,OAAO,YAAYU,CAAO;GACnC,aAAa,KAAK,OAAO;GACzB,aAAa,KAAK,OAAO;GACzB,UAAU,KAAK,OAAO,SAAS;GAC/B,WAAWD;GACX,YAAYF;EACd,GACA,KAAK,aAAa,QAClBE,GAGApE,CACF;CACF;AACF;AAGA,SAAgBsE,EACd,GACA,GACA,GACA,GACA,GAKA;CACA,IAAMd,IAAO,IAAI7C,EAAcyC,GAAQvB,GAAawB,GAAYkB,GAAQhB,CAAO;CAC/E,OAAO;EACL,WAAW,IAAIJ,EAAgBC,GAAQvB,GAAa2B,GAAMH,GAAYkB,GAAQhB,CAAO;EACrF,mBAAmBC,EAAK,YAAY;EAGpC,yBAAyBA,EAAK,kBAAkB;CAClD;AACF"}
package/llms.txt ADDED
@@ -0,0 +1,397 @@
1
+ # @utk09/ui-observability
2
+
3
+ > Framework-neutral structured logging and UI observability for browsers, embedded webviews and OpenFin containers. The library batches records and sends them over HTTP as OTLP/JSON. It stores a batch that fails to send and sends it again later. It sends the last records when the page closes. It has one entry point, no runtime dependency and three optional peers. A log call never throws.
4
+
5
+ This file is for a large language model that writes code with this package. The package does not include the `docs/` folder, so this file has the rules for the common tasks. Each function name, config key and default here comes from `src/index.ts`, `src/models/config.ts` and `src/constants.ts` of version 1.0.0. The links at the end go to the full reference.
6
+
7
+ ## What the library does
8
+
9
+ - Writes log records with a namespace, a level, a message and a payload.
10
+ - Records user actions, domain events, metrics (counter, gauge, histogram), timed operations (measures) and profiler probes.
11
+ - Captures browser signals when you turn them on. Uncaught errors and unhandled rejections are on by default. Fetch, XHR, clicks, navigation, web vitals, long frames, console calls and WebSockets are off by default.
12
+ - Puts five correlation ids on each record: `session.id`, `tab.id`, `context.id`, `journey.id` and `trace_id`.
13
+ - Sends OTLP/JSON by default, or ECS NDJSON. It gzips a body of 1 KiB or more. Metrics and spans can go to their own OTLP endpoints.
14
+ - Stores a failed batch in IndexedDB or `localStorage` and sends it again with backoff.
15
+ - Connects iframes, workers and OpenFin views to one sender in each tab, through a bus.
16
+ - Records the DOM for a session replay after an error, with the `@rrweb/record` package of the app. The replay is off by default.
17
+
18
+ ## What the library does not do
19
+
20
+ - It imports no framework. It has no React, Angular or Vue adapter. The app writes that code. See the React recipe below.
21
+ - It does not remove personal data by default. Write a `redact` hook for that. Without hooks, the library only makes values safe to serialize.
22
+ - On Node, for example in server-side rendering, it sends nothing. It prints to the console only.
23
+ - It does not authenticate. The app gives `headers`, `credentials` or a custom `transport`.
24
+ - It is not an audit trail. A record can be lost. `onDrop` reports each loss of a built record.
25
+ - OpenFin support is not validated on a real OpenFin runtime.
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ npm install --save-exact @utk09/ui-observability
31
+ ```
32
+
33
+ | Peer | Version | Install it for | Set this key |
34
+ | -------------------- | ------------------ | ------------------------------------- | -------------------------- |
35
+ | `@opentelemetry/api` | `^1` | Records on your OpenTelemetry traces. | `otelLoader` |
36
+ | `@rrweb/record` | `^2` | Session replay. | `replay.loader` |
37
+ | `web-vitals` | `^4`, `^5` or `^6` | LCP, CLS, INP, FCP and TTFB. | `capture.webVitals.loader` |
38
+
39
+ Each peer is optional. Give each peer as a loader function with a dynamic `import()`. The library never imports a peer by name, so a missing peer cannot break the bundler.
40
+
41
+ ```ts
42
+ configure({
43
+ endpoint: "https://ingest.example/v1/logs",
44
+ serviceName: "orders",
45
+ otelLoader: () => import("@opentelemetry/api"),
46
+ capture: { webVitals: { loader: () => import("web-vitals") } },
47
+ replay: {
48
+ enabled: true,
49
+ endpoint: "https://ingest.example/v1/replay",
50
+ loader: () => import("@rrweb/record"),
51
+ },
52
+ });
53
+ ```
54
+
55
+ - Without `capture.webVitals.loader`, the library reports `config.invalid`. Only the navigation timing then runs.
56
+ - Without `otelLoader`, OpenTelemetry is off. The library then makes its own `trace_id`.
57
+ - Browsers: Chrome 85, Edge 85, Firefox 79, Safari 14.1 and later. Node 22.22.3 or later, console only.
58
+ - The package has an ES module entry and a CommonJS entry. They are separate copies with separate state. Use one format in one app.
59
+
60
+ ## The start rule
61
+
62
+ - Nothing starts before the first `configure()` call that works. Call it one time, at module top level of the app entry, before the first render.
63
+ - Before that call, a log call does not throw. The record waits in memory, in the hold buffer. The library installs no capture, starts no bus, sends nothing and writes nothing to storage. `getHealth().status` is `"unconfigured"`. `flush()` returns the status `"inactive"`. `rotateSecurityContext()` rejects.
64
+ - The first call that works starts the runtime. The held records then get its `processors`, its `redact` and its identity. Then they go out.
65
+ - An app that never calls `configure()` sends nothing. The console output is off by default, so it also prints nothing.
66
+ - `getLogger()` at module top level is safe before `configure()`. The logger finds the runtime on its first write.
67
+ - `configure()` never throws. A value of the wrong type or outside its range reports `config.invalid`, and the current value stays. An unknown key also reports `config.invalid`.
68
+ - Set `endpoint` and `serviceName` in the first call. Set `endpoint: null` for console-only mode.
69
+ - A later call merges into the current settings. An omitted key or `undefined` keeps the current value. `null` removes a hook or turns off an endpoint. On a limit key, `null` means no limit and `0` means zero.
70
+ - These keys are fixed by the first call that works: `identity`, `correlation`, `limits`, `journey.maxAgeMs`, `profiler.maxProbes`, `storage`, `bus.mode` and `bus.openFinRole`. `batching` and `retention` are fixed when the delivery stack loads. A later change reports `config.invalid`.
71
+ - `otelLoader` is also fixed by the first call that works. A later change has no effect and reports nothing.
72
+ - With `securityContext.isolation: true` (the default), `configure()` refuses a change of `endpoint`, `metricsEndpoint`, `tracesEndpoint`, `headers`, `credentials`, `transport`, `transportOnExit`, `transportWorker` and `securityContext.id`. Use `rotateSecurityContext()` for these changes.
73
+ - `enabled: false` is a pause, not a stop. Log calls do nothing. The captures, the replay and the sender stop. The records in memory and in storage stay, and they go out after `enabled: true`. `getHealth().status` is `"disabled"`.
74
+ - `shutdown()` stops the runtime. After it, each call does nothing until the next `configure()`, which builds a new runtime. `rotateSecurityContext()` rejects until then.
75
+ - Call `configure()` in one context of each document. In a page with microfrontends, the shell calls it. Each microfrontend calls only `getLogger()` with its own namespace.
76
+
77
+ ## Public functions
78
+
79
+ Import each function and type from `"@utk09/ui-observability"`. A call never throws.
80
+
81
+ Setup and lifecycle:
82
+
83
+ - `configure(config: Partial<ObservabilityConfig>): void`. Starts the runtime, or updates it.
84
+ - `setConfigurationLocked(locked: boolean): void`. Refuses later `configure()` changes. Call it after `configure()`.
85
+ - `rotateSecurityContext(update: SecurityContextUpdate, options?: SecurityContextRotationOptions): Promise<void>`. Changes the delivery identity and the routing settings together, at login, logout or a tenant change. `update` is `{ id?, routing, context? }`. A routing field that you omit resets to its default. An omitted `id` gives a new id. An omitted `context` removes the old context attributes. `options` is `{ pending?: "discard" | "flush" | "retain" | "carry", timeoutMs? }`, defaults `"discard"` and `5000`.
86
+ - `newSession(): void`. Starts a new `session.id` in this tab. It does not isolate the stored batches or the credentials.
87
+ - `shutdown(options?: ShutdownOptions): Promise<void>`. Stops each subsystem. `options` is `{ pending?: "flush" | "discard", clearStorage?: "context" | "namespace" | null }`. The default `"flush"` sends the records in memory, then runs the exit flush.
88
+
89
+ Logging:
90
+
91
+ - `getLogger(namespace: string, options?: { scopedContext?: Record<string, unknown> }): Logger`. Returns the cached logger of the namespace. With `options`, it returns a new logger that is not cached.
92
+ - `Logger` methods: `trace`, `debug`, `info`, `warn` take `(message: string, payload?: Record<string, unknown>)`. `error` and `fatal` take `(message: string, err?: unknown, payload?: Record<string, unknown>)` and add the breadcrumb trail. `logAction(name, payload?)` logs a user action. `logEvent(name, payload?)` logs a domain or lifecycle event. `child(namespace, options?)` returns a logger for `<namespace>.<child>`.
93
+ - `trace`, `debug`, `info`, `warn`, `error`, `fatal`, `logAction`, `logEvent`. The same functions on the `"app"` logger.
94
+ - `addBreadcrumb(message: string, data?: Record<string, unknown>): void`. Adds a breadcrumb. The next error record carries the trail.
95
+
96
+ Metrics and timing:
97
+
98
+ - `counter(name: string, options?: { unit?: string }): Counter`. `add(value, attributes?)` sums values of 0 or more.
99
+ - `gauge(name: string, options?: { unit?: string }): Gauge`. `set(value, attributes?)` keeps the last value.
100
+ - `histogram(name: string, options?: { unit?: string; boundaries?: readonly number[] }): Histogram`. `record(value, attributes?)` counts values in buckets.
101
+ - `startMeasure(name: string, attributes?: MetricAttributes): Measure`. `phase(name)` starts a named phase. `end(outcome?)` records the total. The default outcome is `"ok"`.
102
+ - `measure<T>(name: string, fn: () => T, attributes?: MetricAttributes): T`. Times one call. A throw or a rejection gives the outcome `"error"` and goes to the caller. `measure()` does not log the error. The app logs it.
103
+ - `profiler.probe(name: string, options?: { sampleEvery?, slowMs?, async? }): Probe`. A low-cost timer for code that runs very often. `begin()` returns a token for `end(token)`. Needs `profiler.enabled: true`.
104
+ - `profiler.time<T>(name: string, fn: () => T): T`. Times one call with the probe of the name.
105
+ - Metric attribute values are strings, finite numbers or booleans. Each instrument sends one point for each attribute set at each `metrics.intervalMs`. Sampling and `minLevel` do not drop a point.
106
+
107
+ Context, journeys and traces:
108
+
109
+ - `setContext(values: Record<string, unknown>): void`. Merges attributes into each later record. A `null` value removes its key.
110
+ - `removeContext(key: string): void`. Removes one context attribute.
111
+ - `startJourney(name: string, options?: { parent?: boolean; id?: string }): Journey`. Starts a workflow id that spans windows. `Journey` has `id`, `name`, `startedAt`, `parentId?` and `ownerContextId`.
112
+ - `endJourney(): void`. Ends the active journey.
113
+ - `currentJourney(): Journey | null`. Returns the active journey.
114
+ - `getJourneyToken(): string | null`. Returns a URL token for the active journey, or `null`.
115
+ - `adoptJourney(token: string): boolean`. Adopts a journey token. Returns `true` when the token is valid.
116
+ - `newTrace(): void`. Starts a new trace. Later records and requests have the new `trace_id`.
117
+ - `getTraceHeaders(): Record<string, string>`. Returns the W3C `traceparent` header for an outgoing request.
118
+
119
+ Frames, workers and transports:
120
+
121
+ - `registerFrame(frame: HTMLIFrameElement | Window, options: { origin: string; permissions?: BusPermission[] }): () => void`. Lets a child frame on that exact origin forward its records. Returns a function that removes the registration.
122
+ - `registerWorker(worker: WorkerLike, options?: { permissions?: BusPermission[] }): () => void`. The same for a Web Worker or a `MessagePort`.
123
+ - `BusPermission` is `"records"`, `"journey:read"`, `"journey:write"` or `"sampling:read"`. Without a list, the source can only send records.
124
+ - `serveTransportWorker(options?: { onDiagnostic? }): () => void`. Call it in the worker script of `transportWorker`. Returns a function that stops the service.
125
+ - `createMemoryTransport(): MemoryTransport`. A transport for tests. It has `transport`, `records()`, `batches()`, `clear()` and `respondWith(status, retryAfterMs?)`.
126
+
127
+ Delivery and health:
128
+
129
+ - `flush(options?: { timeoutMs?: number }): Promise<FlushResult>`. Sends the records in memory and waits until each one has a final state, or until `timeoutMs` (default 5000, range 0 to 600000). It never rejects. `FlushResult` is `{ status: "complete" | "timeout" | "inactive", accepted, stored, dropped, forwarded, pending }`. Each count is a number of records.
130
+ - `getHealth(): Promise<ObservabilityHealth>`. Returns `status` (`"unconfigured"`, `"disabled"`, `"starting"`, `"ready"`, `"rotating"`, `"degraded"` or `"stopped"`), `mode`, `issues`, `sdkVersion` and the `delivery` block `{ pending, inFlight, stored, lastSendAt, lastFailureAt, consecutiveFailures, throttledUntil, dropped }`.
131
+ - `getDiagnosticCounters(): Record<string, number>`. Returns the count of each diagnostic code.
132
+ - `collectDebugBundle(): Promise<DebugBundle>`. Returns a JSON-safe bundle for a support ticket. It has no headers and no URL query.
133
+
134
+ Session replay:
135
+
136
+ - `startReplay(): void`. Starts the recorder. With `replay.requireConsent: true`, nothing records before this call.
137
+ - `stopReplay(): void`. Stops the recorder and drops each replay event that is not sent.
138
+
139
+ ## Configuration
140
+
141
+ Top-level keys of `ObservabilityConfig`, with their defaults:
142
+
143
+ | Key | Default | Use |
144
+ | ------------------- | ----------- | ------------------------------------------------------------------------------------------- |
145
+ | `endpoint` | not set | URL for the log batches. Required in the first call. `null` selects console-only mode. |
146
+ | `serviceName` | `""` | `service.name` on each record. |
147
+ | `serviceVersion` | `""` | `service.version` on each record. |
148
+ | `environment` | `""` | `deployment.environment` on each record. |
149
+ | `enabled` | `true` | `false` pauses the library. |
150
+ | `minLevel` | `"INFO"` | Lowest level that the library sends: `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `FATAL`. |
151
+ | `minLevels` | `{}` | Lowest level for each namespace prefix, for example `{ "trading.ticks": "DEBUG" }`. |
152
+ | `consoleOutput` | `false` | `true` prints from `DEBUG` up. A level name prints from that level. Or `{ level, styles }`. |
153
+ | `metricsEndpoint` | `null` | OTLP metrics URL. Without it, a metric point is a log record on `endpoint`. |
154
+ | `tracesEndpoint` | `null` | OTLP traces URL. Without it, the library sends no span. |
155
+ | `serializer` | `"otlp"` | `"otlp"`, `"ecs"` or a custom `LogSerializer`. |
156
+ | `compression` | `"gzip"` | `"gzip"` or `"none"`. |
157
+ | `credentials` | `"omit"` | Fetch credentials mode. `"include"` for cookie authentication. |
158
+ | `headers` | not set | An object, or a function that returns one or a promise of one. |
159
+ | `identity` | `"storage"` | Where the ids live. `"memory"` writes no key to `localStorage` or `sessionStorage`. |
160
+ | `payloadMode` | `"copy"` | `"defer"` keeps the payload reference until idle time. |
161
+ | `redact` | not set | `(record: LogRecord) => LogRecord \| null`. The last privacy gate. |
162
+ | `processors` | `[]` | Functions with the contract of `redact`. They run before `redact`. |
163
+ | `contextProvider` | not set | Returns attributes for each record. Keep it fast and synchronous. |
164
+ | `onDrop` | not set | `(summary: DropSummary) => void`. Gets each loss of built records. |
165
+ | `onDiagnostic` | not set | `(event: DiagnosticEvent) => void`. Gets each fault of the library. |
166
+ | `transport` | not set | Sends a batch through a channel of the app. `endpoint` is then optional. |
167
+ | `transportOnExit` | not set | Sends the last batch while the page closes. Needs `transport`. Must not wait. |
168
+ | `transportWorker` | not set | `() => Worker`. Sends from a dedicated worker that calls `serveTransportWorker()`. |
169
+ | `otelLoader` | not set | `() => import("@opentelemetry/api")`. |
170
+ | `lockConfiguration` | `false` | Refuses changes through `configure()`. |
171
+
172
+ Sections and their keys. Each key is optional in `configure()`. A section takes an object only. For example, `storage: "memory"` reports `config.invalid`.
173
+
174
+ - `capture`: `errors: true`, `rejections: true`, `httpMetrics: true`. Each other switch is `false`: `resourceErrors`, `fetch`, `xhr`, `interactions`, `navigation`, `webVitals`, `longFrames`, `console`, `webSocket`, `uncleanExit`, `userTiming`, `serverTiming`, `reports`, `resourceTiming`, `lifecycle`. URL rules: `fullUrls: false`, `urlTransform` not set, `ignoreUrls: []`, `propagateTraceHeaderTo: []`. Also `remoteToggles: []` and `plugins: []`.
175
+ - Capture options objects. An object turns the capture on. `interactions: { text, selector, ignoreSelector, maxTextChars, actionAttribute, rageClicks, rageClickCount, rageClickWindowMs, deadClicks, deadClickMs }`. `webVitals: { loader }`. `longFrames: { thresholdMs }` (default 100). `console: { levels }` (default `["error", "warn"]`). `userTiming: { include }` (default `[]`, each name). `resourceTiming: { slowMs }` (default 1000).
176
+ - `sampling`: `defaultRate: 1`, `rates: {}`, `alwaysSampleTypes: ["action"]`, `alwaysSampleFrom: "ERROR"`, `errorCeiling: 500`, `errorCeilingWindowMs: 10000`, `remote: false`, `remoteMaxRate: 1`.
177
+ - `storage`: `backend: "auto"` (`"auto"`, `"indexeddb"`, `"localstorage"`, `"memory"` or `"none"`), `namespace: ""`, `requestPersistent: false`.
178
+ - `bus`: `mode: "auto"` (`"auto"`, `"sender"`, `"forwarder"` or `"off"`), `trustedOrigins: []`, `sourcePolicy: "registered"` (or `"trusted-origin"`), `openFinRole: "auto"`, `maxMessageBytes: 262144`, `maxRecordsPerMessage: 100`, `maxMessagesPerSecond: 100`.
179
+ - `batching`: `logFlushIntervalMs: 2000`, `logBatchSize: 100`, `metricBatchSize: 500`.
180
+ - `retention`: `maxBatches: 500`, `maxAgeMs: 86400000`, `maxAttempts: 5`.
181
+ - `delivery`: `requestTimeoutMs: 15000`, `maxConcurrentRequests: 2`, `retryBaseDelayMs: 2000`, `retryMaxDelayMs: 60000`, `priority: "low"`.
182
+ - `buffering`: `maxPendingRecords: 10000`, `maxPendingBytes: 16777216`, `maxHeldRecords: 500`, `overflow: "drop-oldest"`.
183
+ - `limits`: `maxBodyChars: 4096`, `maxAttributeChars: 8192`, `maxAttributeCount: 128`, `maxStackChars: 8192`, `maxDepth: 6`, `maxArrayLength: 100`, `maxNodes: 10000`, `maxRecordBytes: 32768`.
184
+ - `metrics`: `intervalMs: 10000`, `maxSeries: 100`, `maxInstruments: 1000`, `maxHistogramBoundaries: 50`.
185
+ - `correlation`: `sessionIdleMs: 1800000`, `traceMaxAgeMs: 300000`.
186
+ - `journey`: `scope: "auto"`, `maxAgeMs: 1800000`.
187
+ - `securityContext`: `id` (generated when not set), `isolation: true`.
188
+ - `captureLimits`: `breadcrumbs: 50`, `errorDedupeMs: 5000`, `errorsPerWindow: 20`, `consolePerWindow: 20`, `longFramesPerWindow: 20`, `webSocketPerWindow: 20`, `reportsPerWindow: 20`, `resourcesPerWindow: 100`, `lifecyclePerWindow: 20`, `windowMs: 10000`.
189
+ - `metadata`: `pageUrl: true`, `userAgent: true`, `openfin: true`, `clockOffset: true`.
190
+ - `diagnostics`: `throttleMs: 1000`, `consoleFallback: false`, `records: false`.
191
+ - `debugBuffer`: `enabled: false`, `maxRecords: 200`, `maxAgeMs: 60000`.
192
+ - `profiler`: `enabled: false`, `maxProbes: 64`, `framePhases: false`, `framePacing: false`.
193
+ - `replay`: `enabled: false`, `mode: "onError"`, `endpoint: null`, `loader: null`, `requireConsent: false`, `bufferMs: 60000`, `maxBufferBytes: 10000000`, `afterErrorMs: 5000`, `uploadsPerWindow: 3`, `uploadWindowMs: 10000`, `maxSegmentEvents: 200`, `maxSegmentBytes: 512000`, `flushIntervalMs: 2000`, `maxQueueBytes: 20000000`, `maxAttempts: 3`, `maskText: true`, `maskInputs: true`, `recordCanvas: false`, `maskSelectors: []`, `blockSelectors: []`, `headers: null`, `onSegment: null`, `plugins: []`, `recordOptions: {}`. The replay needs `loader`, and `endpoint` or `onSegment`.
194
+ - `loggerCache`: `maxEntries: 256`.
195
+
196
+ ## Recipes
197
+
198
+ Console only, with no network:
199
+
200
+ ```ts
201
+ configure({
202
+ endpoint: null,
203
+ serviceName: "orders",
204
+ identity: "memory",
205
+ storage: { backend: "none" },
206
+ bus: { mode: "off" },
207
+ consoleOutput: "DEBUG",
208
+ });
209
+ ```
210
+
211
+ Redact a field. `redact` runs on each record before the console, a callback or the network sees it. The sender also runs its `redact` on each record from a frame or a worker, so a second run must give the same result.
212
+
213
+ ```ts
214
+ configure({
215
+ endpoint: "https://ingest.example/v1/logs",
216
+ serviceName: "orders",
217
+ redact: (record) =>
218
+ "card" in record.attributes
219
+ ? { ...record, attributes: { ...record.attributes, card: "[redacted]" } }
220
+ : record,
221
+ });
222
+ ```
223
+
224
+ React error boundary. A render error that a React error boundary catches does not reach `window.onerror`, so the error capture does not see it. Log it in `componentDidCatch`. The library has no React code. The example app in `playground/react/src/observability.tsx` on GitHub has a boundary, a provider and hooks. Call `configure()` at module top level, not in a component.
225
+
226
+ ```ts
227
+ componentDidCatch(error: Error, info: React.ErrorInfo): void {
228
+ getLogger("react").error("render failed", error, {
229
+ "react.component_stack": info.componentStack,
230
+ });
231
+ }
232
+ ```
233
+
234
+ Frames. Register the frame in the parent before the frame loads its page. The frame also calls `configure()`. A cross-origin frame needs the parent origin in `bus.trustedOrigins`. The parent batches and sends the records of the frame, and the parent `redact` runs on them.
235
+
236
+ ```ts
237
+ // Parent page, after configure(). The iframe is in the document and has no src yet.
238
+ registerFrame(frame, { origin: "https://ticket.example", permissions: ["records"] });
239
+ await flush(); // Waits for the startup, so the registration is active.
240
+ frame.src = "https://ticket.example/";
241
+
242
+ // Frame on https://ticket.example.
243
+ configure({
244
+ endpoint: "https://ingest.example/v1/logs",
245
+ serviceName: "ticket",
246
+ bus: { trustedOrigins: ["https://app.example"] },
247
+ });
248
+ ```
249
+
250
+ A frame that starts before the parent runtime gets no owner. After 1,500 ms (4,500 ms for a cross-origin frame) it sends its own records with its own `redact`.
251
+
252
+ Workers. Register the worker in the page. The worker script calls `configure()` and logs as usual.
253
+
254
+ ```ts
255
+ const worker = new Worker(new URL("./pricing.worker.ts", import.meta.url), { type: "module" });
256
+ registerWorker(worker);
257
+ ```
258
+
259
+ Logout on a shared device. Send nothing more, and remove the stored batches, the session id, the tab id and the journey. Then start a new runtime for the next user.
260
+
261
+ ```ts
262
+ await shutdown({ pending: "discard", clearStorage: "context" });
263
+ configure(anonymousConfig);
264
+ ```
265
+
266
+ Logout that sends the old records with the old token first, then changes the routing:
267
+
268
+ ```ts
269
+ await rotateSecurityContext(
270
+ { routing: { endpoint: "https://ingest.example/v1/logs" } },
271
+ { pending: "flush", timeoutMs: 3000 },
272
+ );
273
+ ```
274
+
275
+ Flush with a time limit, for example before a navigation that the app controls. `status: "complete"` means only that no record waits. A dropped record and a stored record also count as complete. To confirm delivery, check `accepted`, `dropped` and `stored`.
276
+
277
+ ```ts
278
+ const result = await flush({ timeoutMs: 2000 });
279
+ if (result.pending > 0) {
280
+ // These records have no final state yet. The library still sends or stores them.
281
+ }
282
+ if (result.dropped > 0 || result.stored > 0) {
283
+ // These records did not reach the server. A stored record goes out at a later retry.
284
+ }
285
+ ```
286
+
287
+ Custom transport. The status code has the meaning of the ingest contract. Put the transport URL in `capture.ignoreUrls`, or the network capture records each send, and the sends do not stop.
288
+
289
+ ```ts
290
+ configure({
291
+ serviceName: "orders",
292
+ transport: async (request) => {
293
+ const response = await apiClient.post("/telemetry", request.body, {
294
+ headers: { "Content-Type": request.contentType, "X-UiObs-Batch-Id": request.batchId },
295
+ });
296
+ return { status: response.status };
297
+ },
298
+ capture: { ignoreUrls: ["/telemetry"] },
299
+ });
300
+ ```
301
+
302
+ Tests. Use the memory transport, and run the test in a DOM environment. In Node, the library is console-only, so the memory transport gets no batch. In Vitest, install `happy-dom` or `jsdom` and set the test environment.
303
+
304
+ ```ts
305
+ // vitest.config.ts
306
+ import { defineConfig } from "vitest/config";
307
+
308
+ export default defineConfig({
309
+ test: { environment: "happy-dom" },
310
+ });
311
+ ```
312
+
313
+ Set `storage: { backend: "none" }`, or `shutdown()` stores the unsent records for the next test. `memory.clear()` keeps the answer of `respondWith()`, so call `memory.respondWith(200)` in `afterEach` when a test changes the answer.
314
+
315
+ ```ts
316
+ const memory = createMemoryTransport();
317
+ configure({
318
+ serviceName: "orders",
319
+ transport: memory.transport,
320
+ storage: { backend: "none" },
321
+ bus: { mode: "off" },
322
+ identity: "memory",
323
+ });
324
+ getLogger("orders.ticket").logAction("ORDER_SUBMIT", { orderId: "ORD-1" });
325
+ expect(await flush()).toMatchObject({ status: "complete", dropped: 0, stored: 0 });
326
+ expect(memory.records()).toContainEqual(expect.objectContaining({ body: "ORDER_SUBMIT" }));
327
+ memory.clear();
328
+ memory.respondWith(200);
329
+ await shutdown();
330
+ ```
331
+
332
+ Metrics and measures:
333
+
334
+ ```ts
335
+ counter("orders.submitted").add(1, { tier: "gold" });
336
+ gauge("queue.depth").set(queue.length);
337
+ histogram("price.latency", { unit: "ms" }).record(elapsedMs);
338
+ // measure() records the outcome "error" but writes no error record. Log the error yourself.
339
+ const rows = await measure("rows.fetch", () => fetchRows()).catch((err: unknown) => {
340
+ getLogger("app").error("rows.fetch failed", err);
341
+ throw err;
342
+ });
343
+ ```
344
+
345
+ ## Privacy rules
346
+
347
+ - `redact` is the last privacy gate. `processors` run first, then `redact`. Then the console, a callback or the network sees the record.
348
+ - A hook that throws, or returns a value that is not a record, drops the record.
349
+ - A `redact` value that is not a function keeps the current hook. With no current hook, the library drops each record until `redact` is a function or `null`.
350
+ - A server can never change a privacy setting. A remote rule in `X-UiObs-Sampling` changes only the sampling rates, the levels that the library sends and the capture switches in `capture.remoteToggles`. Each rule has a time limit.
351
+ - A recorded URL has no query and no fragment, unless `capture.fullUrls` is `true` or `urlTransform` is set.
352
+ - Click capture records no element text and no selector, unless `interactions.text` or `interactions.selector` is `true`.
353
+ - Set `redact` before you turn on `capture.console`, because a console argument can hold a header or a token.
354
+ - The replay masks text and input values by default. `redact` and `processors` do not apply to a replay event.
355
+ - `identity: "memory"` writes no id to the device.
356
+
357
+ ## Ingest contract
358
+
359
+ - The server accepts `POST` with `Content-Type: application/json` (OTLP), `application/x-ndjson` (ECS, with `serializer: "ecs"`) or `text/plain;charset=UTF-8`. The exit batch to another origin uses `text/plain;charset=UTF-8`.
360
+ - Each batch has the headers `X-UiObs-Batch-Id` and `X-UiObs-Attempt`. A body of 1 KiB or more has `Content-Encoding: gzip`. The CORS preflight must allow `content-type, content-encoding, x-uiobs-batch-id, x-uiobs-attempt`, and the name of each header in `headers`.
361
+ - The exit batch has its batch id in the query `uiobs_batch_id` and the reason in `uiobs_exit`.
362
+ - The server deduplicates on the batch id for at least 24 hours. The library can send a batch more than one time.
363
+ - `200`, `202` and `204` accept the batch. `413` splits it, and a JSON body `{"maxBytes": n}` gives the limit. `429` and `503` throttle, with `Retry-After`. `408` and `5xx` retry. With a `headers` function, `401` and `403` get one more send with new headers. Each other `4xx` drops the batch.
364
+ - Expose `Retry-After`, `X-UiObs-Sampling` and `Date` with `Access-Control-Expose-Headers`.
365
+ - The replay endpoint is a separate URL. It gets one JSON `POST` for each segment, with the batch id `<replay.id>-<sequence>` and only the `replay.headers`.
366
+ - Check a server with `pnpm dlx @utk09/ui-observability doctor https://ingest.example/v1/logs --origin https://app.example`.
367
+
368
+ ## Common mistakes
369
+
370
+ - Do not import a peer by name to give it to the library. Give a loader: `() => import("web-vitals")`.
371
+ - Do not import a subpath, for example `@utk09/ui-observability/react` or a file in `dist/`. The package exports `.` only.
372
+ - Do not use `enabled: false` to stop the library or to withdraw consent. It is a pause, and the records go out after `enabled: true`. At a consent withdrawal, call `shutdown({ pending: "discard", clearStorage: "context" })`. Call `configure()` again only after the user agrees.
373
+ - Do not call `configure()` in a component body or an effect. Call it one time at module top level.
374
+ - Do not use `configure({ headers: null })` or `headers: undefined` at logout. With isolation on, the first is refused, and the second keeps the token. Use `rotateSecurityContext()` or `shutdown()` with `clearStorage`.
375
+ - Do not use `0` for "no limit". Use `null`. Do not use `""` to turn off an endpoint. Use `null`.
376
+ - Do not load child frames before the parent calls `configure()` and registers them.
377
+ - Do not log through the library in `onDrop`.
378
+ - Do not put a user id or a full URL in a metric attribute. Each value makes a new series.
379
+ - Do not expect `flush()` to reject. Check the counts of its result.
380
+ - Do not load two versions of the library on one page. A copy of another version runs console-only and reports `runtime.version_mismatch`. Use one module format in one app.
381
+ - Do not use the names that 1.0.0 removed. `logMetric` is `gauge`, `counter` or `histogram`. `timeSync` and `timeAsync` are `measure`, but `measure()` does not log the error. Catch the error and log it to keep the old ERROR record. `getStats()` is `(await getHealth()).delivery`. `getQueueDepth()` is `(await getHealth()).delivery.stored`. `clearPersistedLogs(scope)` is `shutdown({ pending: "discard", clearStorage: scope })`. Then call `configure()` again. `setContextMap(values)` is `setContext(values)`. `startTrace()` is `newTrace()`. The type `OneLogger` is `Logger`. The key `console` is `consoleOutput`. `capturePolicy` is `captureLimits`. `persistence` goes into `storage`.
382
+
383
+ ## Reference documents
384
+
385
+ - [README](https://github.com/utk09-NCL/ui-observability/blob/main/README.md): install, quick start and the common recipes.
386
+ - [API Reference](https://github.com/utk09-NCL/ui-observability/blob/main/docs/api.md): each function, the delivery health, the flush result and the shutdown options.
387
+ - [Configuration Options](https://github.com/utk09-NCL/ui-observability/blob/main/docs/configuration.md): each key, its default and its rules.
388
+ - [Guides](https://github.com/utk09-NCL/ui-observability/blob/main/docs/guides.md): console output, custom transport, worker transport, testing and remote sampling.
389
+ - [Production recipes](https://github.com/utk09-NCL/ui-observability/blob/main/docs/production-recipes.md): login, logout, tenant rotation, token refresh and consent withdrawal.
390
+ - [Ingest Server Requirements](https://github.com/utk09-NCL/ui-observability/blob/main/docs/ingest-server.md): the full ingest contract and the `doctor` tool.
391
+ - [Migration to 1.0.0](https://github.com/utk09-NCL/ui-observability/blob/main/docs/migration-v1.md): each change from 0.12.x.
392
+ - [Delivery guarantees](https://github.com/utk09-NCL/ui-observability/blob/main/docs/delivery-guarantees.md): duplicates, order and each loss reason.
393
+ - [Attribute reference](https://github.com/utk09-NCL/ui-observability/blob/main/docs/attributes.md): each attribute that the library writes.
394
+ - [Browser support](https://github.com/utk09-NCL/ui-observability/blob/main/docs/browser-support.md): the browser APIs and the fallback for each.
395
+ - [Threat model](https://github.com/utk09-NCL/ui-observability/blob/main/docs/threat-model.md): the trust boundaries and the controls.
396
+ - [Release and support](https://github.com/utk09-NCL/ui-observability/blob/main/docs/release-and-support.md): the stable API contract.
397
+ - [React example](https://github.com/utk09-NCL/ui-observability/blob/main/playground/react/src/observability.tsx): an error boundary, a provider and hooks.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utk09/ui-observability",
3
- "version": "0.11.0",
3
+ "version": "1.0.0",
4
4
  "description": "UI observability and logging for browser, OpenFin and webview applications",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -37,19 +37,60 @@
37
37
  "files": [
38
38
  "dist",
39
39
  "bin",
40
- "CHANGELOG.md"
40
+ "CHANGELOG.md",
41
+ "llms.txt"
41
42
  ],
42
43
  "main": "./dist/index.cjs",
43
44
  "module": "./dist/index.js",
44
45
  "types": "./dist/index.d.ts",
45
46
  "exports": {
46
47
  ".": {
47
- "types": "./dist/index.d.ts",
48
- "import": "./dist/index.js",
49
- "require": "./dist/index.cjs"
48
+ "import": {
49
+ "types": "./dist/index.d.ts",
50
+ "default": "./dist/index.js"
51
+ },
52
+ "require": {
53
+ "types": "./dist/index.d.cts",
54
+ "default": "./dist/index.cjs"
55
+ }
50
56
  },
51
57
  "./package.json": "./package.json"
52
58
  },
59
+ "peerDependencies": {
60
+ "@opentelemetry/api": "^1",
61
+ "@rrweb/record": "^2",
62
+ "web-vitals": "^4 || ^5 || ^6"
63
+ },
64
+ "peerDependenciesMeta": {
65
+ "@opentelemetry/api": {
66
+ "optional": true
67
+ },
68
+ "@rrweb/record": {
69
+ "optional": true
70
+ },
71
+ "web-vitals": {
72
+ "optional": true
73
+ }
74
+ },
75
+ "devDependencies": {
76
+ "@eslint/js": "10.0.1",
77
+ "@opentelemetry/api": "1.10.0",
78
+ "@playwright/test": "1.58.2",
79
+ "@types/node": "26.6.6",
80
+ "@vitest/coverage-istanbul": "5.1.0",
81
+ "concurrently": "10.0.7",
82
+ "eslint": "10.15.0",
83
+ "eslint-config-prettier": "10.1.8",
84
+ "fake-indexeddb": "6.2.8",
85
+ "happy-dom": "21.0.4",
86
+ "prettier": "3.10.1",
87
+ "rimraf": "6.1.4",
88
+ "typescript": "6.0.3",
89
+ "typescript-eslint": "8.72.2",
90
+ "vite": "8.3.8",
91
+ "vitest": "5.1.0",
92
+ "web-vitals": "6.2.3"
93
+ },
53
94
  "scripts": {
54
95
  "dev": "concurrently -k \"pnpm run dev:vanilla\" \"pnpm run dev:ingest\" \"pnpm run dev:cross-origin\"",
55
96
  "dev:vanilla": "pnpm --filter @example/vanilla run dev",
@@ -59,7 +100,7 @@
59
100
  "example:angular": "pnpm --filter @example/angular run dev",
60
101
  "example:microfrontend": "concurrently -k \"pnpm --filter @example/mf-blotter run dev\" \"pnpm --filter @example/mf-ticket run dev\" \"pnpm --filter @example/mf-host run dev\"",
61
102
  "example:console-only": "pnpm --filter @example/console-only run dev",
62
- "build": "rimraf dist && tsc --project tsconfig.build.json && vite build",
103
+ "build": "rimraf dist && tsc --project tsconfig.build.json && node tools/finish-declarations.mjs && vite build",
63
104
  "build:watch": "vite build --watch",
64
105
  "lint": "eslint .",
65
106
  "lint:fix": "eslint . --fix",
@@ -68,42 +109,15 @@
68
109
  "test": "vitest run",
69
110
  "test:watch": "vitest",
70
111
  "test:coverage": "vitest run --coverage",
112
+ "test:e2e": "playwright test --config e2e/playwright.config.ts",
113
+ "test:collector": "node tools/check-collector.mjs",
114
+ "bench:release": "node tools/bench-release.mjs",
71
115
  "typecheck": "tsc --noEmit",
72
116
  "check:peers": "node tools/check-peer-imports.mjs",
73
117
  "check:size": "node tools/check-size.mjs",
74
118
  "check:dev": "node tools/check-dev-server.mjs",
75
- "verify": "pnpm run format:check && pnpm run typecheck && pnpm run build && pnpm run lint && pnpm run check:peers && pnpm run check:size && pnpm run check:dev && pnpm run test:coverage",
76
- "prepublishOnly": "pnpm run verify"
77
- },
78
- "peerDependencies": {
79
- "@opentelemetry/api": "^1",
80
- "web-vitals": "^4 || ^5 || ^6"
81
- },
82
- "peerDependenciesMeta": {
83
- "@opentelemetry/api": {
84
- "optional": true
85
- },
86
- "web-vitals": {
87
- "optional": true
88
- }
89
- },
90
- "devDependencies": {
91
- "@eslint/js": "catalog:library",
92
- "@opentelemetry/api": "catalog:library",
93
- "@types/node": "catalog:library",
94
- "@vitest/coverage-istanbul": "catalog:library",
95
- "concurrently": "catalog:library",
96
- "eslint": "catalog:library",
97
- "eslint-config-prettier": "catalog:library",
98
- "fake-indexeddb": "catalog:library",
99
- "happy-dom": "catalog:library",
100
- "prettier": "catalog:library",
101
- "rimraf": "catalog:library",
102
- "typescript": "catalog:library",
103
- "typescript-eslint": "catalog:library",
104
- "vite": "catalog:library",
105
- "vitest": "catalog:library",
106
- "web-vitals": "catalog:library"
107
- },
108
- "packageManager": "pnpm@12.18.0"
109
- }
119
+ "check:consumers": "node tools/check-consumers.mjs",
120
+ "fix": "pnpm run lint:fix && pnpm run format",
121
+ "verify": "pnpm run format:check && pnpm run typecheck && pnpm run build && pnpm run lint && pnpm run check:peers && pnpm run check:size && pnpm run check:dev && pnpm run check:consumers && pnpm run test:coverage"
122
+ }
123
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"batch-C8OcWR2L.cjs","names":["newId","ATTR_LOG_TYPE","LOG_TYPE_ACTION","require_constants","require_identity","isLogBatch","value","id","createdAt","attempts","records","splitBatch","batch","middle","halve","diagnostics","attributeOf","record","attributes","key","isActionRecord","countRecords","batches","total"],"sources":["../src/models/batch.ts"],"sourcesContent":["// src/models/batch.ts\n//\n// A batch of log records for delivery to the ingest endpoint.\n\nimport { ATTR_LOG_TYPE, LOG_TYPE_ACTION } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { newId } from \"../utils/identity\";\nimport type { LogRecord } from \"./log-record\";\n\n/**\n * A batch of records with a stable id used for server-side deduplication across retries.\n * @see {@link splitBatch}\n */\nexport interface LogBatch {\n /** Application namespace that owns this stored batch. */\n readonly persistenceNamespace?: string;\n /** Delivery context id. It does not change. With isolation, a batch without this id stays stored. */\n readonly routingContextId?: string;\n /** Deduplication key. It stays the same across retries and reloads. */\n id: string;\n /** Records to deliver, in log order. */\n records: LogRecord[];\n /** Batch creation time, in epoch milliseconds. */\n createdAt: number;\n /** Delivery attempts so far. */\n attempts: number;\n}\n\n/**\n * Tells if a value from storage has all fields of a batch. `keyOf` cannot match\n * an entry without `id` after delivery. The library then retries that entry with no\n * end, and the entry blocks each batch behind it. An entry without `attempts` counts\n * as NaN. That count never reaches `maxAttempts`. Thus the library never drops the\n * entry as a dead letter.\n * @param value Parsed storage entry.\n * @returns True when each required field is present and has the correct type.\n */\nexport function isLogBatch(value: unknown): value is LogBatch {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const id: unknown = Reflect.get(value, \"id\");\n const createdAt: unknown = Reflect.get(value, \"createdAt\");\n const attempts: unknown = Reflect.get(value, \"attempts\");\n const records: unknown = Reflect.get(value, \"records\");\n\n return (\n typeof id === \"string\" &&\n typeof createdAt === \"number\" &&\n typeof attempts === \"number\" &&\n Array.isArray(records)\n );\n}\n\n/**\n * Splits a batch that the server rejected as too large into two halves.\n * Each half gets a new id. Each half keeps the age and attempts of the original batch.\n * @param batch The rejected batch.\n * @param diagnostics Diagnostics reporter for the new batch ids.\n * @returns Two batches, or `null` if a single record is already over the limit.\n */\nexport function splitBatch(batch: LogBatch, diagnostics: Diagnostics): [LogBatch, LogBatch] | null {\n if (batch.records.length < 2) {\n return null;\n }\n\n const middle = Math.floor(batch.records.length / 2);\n const halve = (records: LogRecord[]): LogBatch => ({\n id: newId(diagnostics),\n records,\n createdAt: batch.createdAt,\n attempts: batch.attempts,\n routingContextId: batch.routingContextId,\n persistenceNamespace: batch.persistenceNamespace,\n });\n\n return [halve(batch.records.slice(0, middle)), halve(batch.records.slice(middle))];\n}\n\n/**\n * Reads one attribute of a record. A record from storage can be corrupt. It can be null or have\n * no attributes.\n * @param record Record to read.\n * @param key Attribute key.\n * @returns The attribute value, or undefined for a corrupt record.\n */\nexport function attributeOf(record: LogRecord, key: string): unknown {\n const value: unknown = record;\n if (typeof value !== \"object\" || value === null) {\n return undefined;\n }\n\n const attributes: unknown = Reflect.get(value, \"attributes\");\n if (typeof attributes !== \"object\" || attributes === null) {\n return undefined;\n }\n\n return Reflect.get(attributes, key);\n}\n\n/**\n * Tests if a record is an action. A corrupt record from storage is not an action.\n * @param record Record to test.\n * @returns True for an action record.\n */\nexport function isActionRecord(record: LogRecord): boolean {\n return attributeOf(record, ATTR_LOG_TYPE) === LOG_TYPE_ACTION;\n}\n\n/**\n * Returns the total record count of the batches.\n * @param batches Batches to measure.\n * @returns Total record count.\n */\nexport function countRecords(batches: readonly LogBatch[]): number {\n return batches.reduce((total, batch) => total + batch.records.length, 0);\n}\n"],"mappings":"A,iFAqCA,SAAgBK,EAAW,EAAmC,CAC5D,GAAI,OAAOC,GAAU,WAAYA,EAC/B,MAAO,GAGT,IAAMC,EAAc,QAAQ,IAAID,EAAO,IAAI,EACrCE,EAAqB,QAAQ,IAAIF,EAAO,WAAW,EACnDG,EAAoB,QAAQ,IAAIH,EAAO,UAAU,EACjDI,EAAmB,QAAQ,IAAIJ,EAAO,SAAS,EAErD,OACE,OAAOC,GAAO,UACd,OAAOC,GAAc,UACrB,OAAOC,GAAa,UACpB,MAAM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