@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
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # @utk09/ui-observability
2
2
 
3
- Structured logging and UI observability for browsers, embedded webviews and OpenFin containers. The library imports no framework.
3
+ Structured logging and UI observability for browsers, embedded webviews and OpenFin containers. The library imports no framework. OpenFin support is not validated on a real OpenFin runtime.
4
4
 
5
5
  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. When the page closes, the library sends the records that are left. Iframes, workers and OpenFin windows share one sender through the bus. A log call never throws.
6
6
 
7
- > **Status: early development.** A minor release can change a public API. Pin the exact version.
7
+ > **Status: stable from 1.0.0.** A minor release or a patch release does not make a breaking change. The [release contract](docs/release-and-support.md) states what a breaking change is. To upgrade from 0.12.x, read the [migration guide](docs/migration-v1.md).
8
8
 
9
9
  ---
10
10
 
@@ -23,21 +23,17 @@ pnpm add --save-exact @utk09/ui-observability
23
23
  yarn add --exact @utk09/ui-observability
24
24
  ```
25
25
 
26
+ The package has an ES module entry and a CommonJS entry. Each entry has its own type declarations.
27
+ The types work with `moduleResolution` set to `NodeNext` or `Bundler`. They also work with `skipLibCheck: false`.
28
+ Use one module format in one application. The two entries are separate copies with separate state and separate types.
29
+
26
30
  ### Peer Dependencies
27
31
 
28
- Both peers are optional. The library has no runtime dependency.
32
+ Each peer is optional. The library has no runtime dependency.
29
33
 
30
- Install `web-vitals` (`^4 || ^5 || ^6`) for `capture.webVitals`, and set `capture.webVitalsLoader`. Without the loader, the library reports `config.invalid`:
34
+ Install `@rrweb/record` (`^2`) for the session replay, and set `replay.loader`. See [Session replay](docs/api.md#session-replay).
31
35
 
32
- ```ts
33
- configure({
34
- endpoint: "https://telemetry.example.com/v1/logs",
35
- capture: {
36
- webVitals: true,
37
- webVitalsLoader: () => import("web-vitals"),
38
- },
39
- });
40
- ```
36
+ Install `web-vitals` (`^4 || ^5 || ^6`) for `capture.webVitals`, and set `capture.webVitals.loader`. The object turns the capture on. Without the loader, the library reports `config.invalid`. LCP, CLS, INP, FCP and TTFB then stay off, and the navigation timing continues.
41
37
 
42
38
  Install `@opentelemetry/api` (`^1`) to put records on the traces of your spans. Set `otelLoader` to load it. Without `otelLoader`, OTel is off. The library then makes its own `trace_id`.
43
39
 
@@ -46,7 +42,11 @@ The library never imports a peer by name. A missing peer cannot break your bundl
46
42
  ```ts
47
43
  configure({
48
44
  endpoint: "https://telemetry.example.com/v1/logs",
45
+ serviceName: "equities-blotter",
49
46
  otelLoader: () => import("@opentelemetry/api"),
47
+ capture: {
48
+ webVitals: { loader: () => import("web-vitals") },
49
+ },
50
50
  });
51
51
  ```
52
52
 
@@ -73,13 +73,19 @@ log.logAction("ORDER_SUBMIT", { orderId: "ORD-1001", qty: 100 });
73
73
  log.error("pricing call failed", caughtError);
74
74
  ```
75
75
 
76
- - `configure()` is idempotent. A later call updates an unlocked runtime singleton in place. Delivery/identity changes require `rotateSecurityContext()` by default. You cannot change `storage`, `identity`, `batching`, `retention`, `limits` or `journey.maxAgeMs` after startup. The library reports that change and ignores it.
77
- - Call `configure()` from one context in each document. A second call changes `service.name` on the records of every other context. In a composed page, the shell calls `configure()`. Each microfrontend uses its own namespace.
76
+ - Nothing starts before the first `configure()` call that works. Before it, a log call does not throw. The record waits in memory. The library sends nothing and writes nothing to storage.
77
+ - An app that never calls `configure()` sends nothing. The console output is off by default, so it prints nothing.
78
+ - Call `configure()` from one context in each document. In a composed page, the shell calls `configure()`. Each microfrontend uses its own namespace. A second call changes `service.name` on the records of every other context.
78
79
  - You can call `getLogger()` at module top level, before `configure()`. The logger finds the runtime on its first write.
79
- - A write before the first `configure()` starts a runtime with default settings. It does not throw. The first `configure()` then sets `limits`, `journey.maxAgeMs`, `persistence.namespace` and an explicit `securityContext.id` of that runtime.
80
- - After `shutdown()`, logging does nothing until the next `configure()`; health/stats remain inspectable.
80
+ - A repeated `configure()` call with the same values and the same function references changes no setting. A later call updates an unlocked runtime in place. Some settings are fixed after startup. Use `rotateSecurityContext()` to change the delivery identity or the routing settings.
81
+ - `enabled: false` pauses the library. It does not stop it. `shutdown()` stops it. After `shutdown()`, logging does nothing until the next `configure()`.
82
+ - [Initialization order](docs/production-recipes.md#initialization-order) gives each rule of the startup. [Settings that are fixed after startup](docs/production-recipes.md#settings-that-are-fixed-after-startup) gives the rule for each key.
83
+
84
+ ---
81
85
 
82
- ### Console Only (No Network)
86
+ ## Recipes
87
+
88
+ ### Console only
83
89
 
84
90
  Set `endpoint: null`. The library sends nothing. It prints records to the console only.
85
91
 
@@ -88,61 +94,15 @@ configure({
88
94
  endpoint: null,
89
95
  serviceName: "skardela",
90
96
  identity: "memory",
91
- storage: "none",
97
+ storage: { backend: "none" },
92
98
  bus: { mode: "off" },
93
- console: import.meta.env.DEV ? "DEBUG" : "WARN",
99
+ consoleOutput: import.meta.env.DEV ? "DEBUG" : "WARN",
94
100
  });
95
101
  ```
96
102
 
97
- - `endpoint: null` loads no transport, no storage and no exit flush. It reports no diagnostic.
98
- - `identity: "memory"` writes no key to `localStorage` or `sessionStorage`.
99
- - `console` and `minLevel` are independent. `console` sets what the library prints. `minLevel` sets what the library sends.
100
- - The console output does not depend on the bus or the endpoint.
101
- - With a `redact` hook, the console shows only what `redact` returns. A record that a processor or `redact` drops prints no line. With `redact` or `processors`, a record below `minLevel` or outside the sample also goes through them before the console prints it. Without hooks, such a record shows its message, payload and error as given.
102
-
103
- ### Console Output
103
+ [Console Only](docs/guides.md#console-only-no-network) gives the rules of this mode. [Console Output](docs/guides.md#console-output) gives the line format and the colors.
104
104
 
105
- Each console line has the form `[namespace][LEVEL] message payload`:
106
-
107
- ```text
108
- [app.puzzle-page][INFO] The puzzle page loaded {puzzleId: 'colour-binary-0006', difficulty: 'easy'}
109
- ```
110
-
111
- The namespace and the level each have a color. To change the colors, use the object form of `console`:
112
-
113
- ```ts
114
- configure({
115
- console: {
116
- level: "DEBUG",
117
- styles: {
118
- namespace: "color:#888",
119
- INFO: "color:#0a7;font-weight:bold",
120
- WARN: "color:#c80;font-weight:bold",
121
- },
122
- },
123
- });
124
- ```
125
-
126
- - Each style is a CSS string. A browser applies it with `%c`. Node prints the text without the style.
127
- - A style can set the text color and the background together. This example shows the level as a badge:
128
-
129
- ```ts
130
- configure({
131
- console: {
132
- styles: {
133
- INFO: "color:#fff;background:#1e6fd9;padding:0 4px;border-radius:3px",
134
- ERROR: "color:#fff;background:#d32f2f;padding:0 4px;border-radius:3px",
135
- },
136
- },
137
- });
138
- ```
139
-
140
- - The style keys are `namespace`, `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR` and `FATAL`. A key that you do not set keeps its style.
141
- - The default namespace color is gray. The default levels are gray for `TRACE` and `DEBUG`, blue for `INFO`, orange for `WARN`, and red for `ERROR` and `FATAL`.
142
- - A later `configure({ console: "WARN" })` changes the level. The styles stay.
143
- - A later `configure({ console: { styles } })` changes the styles. The level stays.
144
-
145
- ### Custom Transport
105
+ ### Custom transport
146
106
 
147
107
  Set `transport` to send batches through a channel of your app, for example an API client with token refresh, a WebSocket, Electron IPC or an OpenFin channel. With `transport`, `endpoint` is optional.
148
108
 
@@ -163,634 +123,78 @@ configure({
163
123
  });
164
124
  ```
165
125
 
166
- - The library keeps batching, retry, storage, splitting and the exit flush.
167
- - The status code that you return has the meaning of the ingest contract. `2xx` accepts the batch. `413` splits it. `429` and `503` throttle. `408` and `5xx` retry. Each other code drops the batch.
168
- - A rejected promise counts as a network error. The library sends the batch again later. A call that does not settle in 15 seconds counts as a timeout.
169
- - The library does not compress `request.body`. Compress it in your transport if necessary.
170
- - `request.records` holds the built records after `redact`. Do not change them, because the retry engine can send them again.
171
- - `request.kind` is `"metrics"` for a batch of metric records when `metricsEndpoint` is set. `request.body` is then an OTLP `ExportMetricsServiceRequest`. Send it to your metrics endpoint.
172
- - `request.kind` is `"traces"` for a batch of span records. `request.body` is then an OTLP `ExportTraceServiceRequest`. Send it to your traces endpoint. Each other batch has the kind `"logs"`.
173
- - Without `transportOnExit`, the last batch goes to the emergency queue when the page closes. The next page load sends it.
174
- - With `storage: "none"`, the next page load cannot keep that batch. Set `transportOnExit`, or the library loses the last batch.
175
- - The library ignores a `retryAfterMs` or a `maxBytes` that is not a finite number. It uses 0 for a negative value.
176
- - `request.signal` aborts at `shutdown()` and at a rotation. Check it to cancel your work. A stored batch of that request stays in storage.
177
- - Return the `Date` header of a `2xx` answer in `date`. The library then computes `uiobs.clock_offset_ms`.
178
- - After the delivery stack loads, you cannot add or remove `transport`. You can replace it with another function.
179
- - Network capture skips a request that your transport starts before its first `await`. Put your telemetry URL in `capture.ignoreUrls` too. A request after an `await` is outside that scope.
180
- - Without that URL in `capture.ignoreUrls`, each send records a value of the `http.client.request.duration` histogram. That value causes the next send, and the sends do not stop. Network capture reports `capture.transport_request` one time when it sees a request during a transport call.
181
-
182
- ### Worker transport
183
-
184
- The app creates a dedicated module worker. Configure its factory at startup.
185
-
186
- ```ts
187
- configure({
188
- endpoint: "https://ingest.example/v1/logs",
189
- serviceName: "orders",
190
- transportWorker: () =>
191
- new Worker(new URL("./transport.worker.ts", import.meta.url), { type: "module" }),
192
- });
193
- ```
194
-
195
- In `transport.worker.ts`:
196
-
197
- ```ts
198
- import { serveTransportWorker } from "@utk09/ui-observability";
199
-
200
- serveTransportWorker();
201
- ```
202
-
203
- The worker encodes OTLP or ECS, compresses the payload and sends HTTP requests. Record construction, privacy hooks, queue accounting, retry and storage stay on the main thread. The `headers` function also stays there. The worker receives only its resolved headers and built records after the privacy hooks.
204
-
205
- - Return a fresh worker from each factory call. The library owns that worker until shutdown or rotation.
206
- - Bundle and serve the worker script with the app. Its worker policy and CORS rules must permit the script and the ingest endpoint.
207
- - Use the same exact library version in the worker and the page. A private transferred port carries a fixed protocol tag and that version.
208
- - `serveTransportWorker()` installs its connection listener at once. It loads the worker delivery code after the connection. Its return value stops the service. Its optional `onDiagnostic` handler runs in the worker.
209
- - One request deadline covers header resolution, transfer, encoding, compression and delivery. The main thread handles status codes, sampling rules and clock offset.
210
- - A startup failure or a channel failure during a send switches that sender to HTTP. A worker that does not connect before the request deadline is a startup failure. A new factory or a rotation permits another worker. A timeout or network failure follows the normal retry policy.
211
- - Hidden-page sends use the main HTTP keepalive path. The exit flush also stays on the main thread. It uses the same cached headers.
212
- - `transport` takes precedence over `transportWorker`. A custom serializer runs on the main thread. Functions do not cross the worker channel.
213
- - With isolation on, change the factory through `rotateSecurityContext()`. After the stack loads, `configure()` cannot add or remove `transportWorker`.
214
- - The helper does not join the context bus. Node remains console-only.
215
-
216
- The vanilla playground has links for the worker and main-thread paths. Verify both paths in a real browser before release.
217
-
218
- ### Testing
219
-
220
- Use `createMemoryTransport()` to check what your code logs. It needs no network and no `fetch` mock.
221
-
222
- ```ts
223
- import {
224
- configure,
225
- createMemoryTransport,
226
- flush,
227
- getLogger,
228
- shutdown,
229
- } from "@utk09/ui-observability";
230
-
231
- const memory = createMemoryTransport();
232
-
233
- beforeEach(() => {
234
- configure({
235
- serviceName: "orders",
236
- transport: memory.transport,
237
- storage: "none",
238
- bus: { mode: "off" },
239
- identity: "memory",
240
- });
241
- });
242
-
243
- afterEach(async () => {
244
- memory.clear();
245
- await shutdown();
246
- });
247
-
248
- it("logs the order submit", async () => {
249
- getLogger("orders.ticket").logAction("ORDER_SUBMIT", { orderId: "ORD-1" });
250
- await flush();
251
-
252
- expect(memory.records()).toContainEqual(expect.objectContaining({ body: "ORDER_SUBMIT" }));
253
- });
254
- ```
255
-
256
- - `records()` returns the records of each accepted batch. `batches()` returns each request, accepted or refused.
257
- - `respondWith(status, retryAfterMs?)` sets the answer for each later batch. Use it to test a `413`, `429` or `500` answer. The default answer is `200`.
258
- - `flush()` waits for startup. A record that you log directly after `configure()` is in the flushed batch.
259
- - After `shutdown()`, each call does nothing until the next `configure()`.
260
- - Set `storage: "none"` in tests. Without it, `shutdown()` stores the unsent records, and the next test can receive them.
261
-
262
- ---
126
+ [Custom Transport](docs/guides.md#custom-transport) gives the status codes, the retry rules and the exit send. [Worker transport](docs/guides.md#worker-transport) sends the batches from a dedicated worker.
263
127
 
264
- ### Remote Sampling
128
+ ### Frames and workers
265
129
 
266
- With `sampling: { remote: true }`, the ingest server can change the sampling during an incident. You do not deploy the app again.
267
-
268
- ```http
269
- X-UiObs-Sampling: {"v":1,"ttlMs":600000,"defaultRate":0.1,"rates":{"blotter.grid":1},"minLevel":"DEBUG"}
270
- ```
271
-
272
- - The library reads the header only on a `2xx` answer to a batch that it sent. A custom transport returns the rules in `TransportResponse.sampling`, as text or as an object.
273
- - `v` must be `1`. `ttlMs` is mandatory, from more than 0 to 3,600,000 (1 hour). After the TTL, the rules from `configure()` apply again.
274
- - `rates` apply over the `configure()` rates. The other `configure()` rates stay. `defaultRate` applies only if the header has it.
275
- - `minLevel` can only lower the level that the library sends. It does not change the console level.
276
- - `minLevels` sets a level for each namespace prefix, for example `{"trading.ticks":"DEBUG"}`. A remote prefix wins over the remote `minLevel`. A remote level applies only when it is lower than the `configure()` level of the namespace. At most 100 prefixes.
277
- - `sampling.remoteMaxRate` caps each remote rate. It also caps the records that a remote `minLevel` adds. Set it below 1 to limit the traffic that a compromised server can cause.
278
- - The library rejects all the rules if one field is not valid, for example a rate outside 0 to 1, more than 100 `rates` or a header longer than 4096 characters. It reports `config.invalid`.
279
- - The library keeps the rules in memory only. A reload uses the `configure()` rules until the next accepted batch.
280
- - A child frame, a worker or an OpenFin view asks its owner for the rules at start and each 30 seconds. Set `sampling.remote: true` in each context.
281
- - A frame accepts rules from a parent only if the parent origin is the page origin or is in `bus.trustedOrigins`. A page that embeds your app cannot lower `minLevel`.
282
- - Under the default `bus.sourcePolicy: "registered"`, a parent sends rules only to a frame or a worker that it registered with the `sampling:read` permission.
283
- - Each OpenFin view of one app can read the bus messages of the others. Load only trusted content into a view that has the `fin` API.
284
-
285
- ## API Reference
286
-
287
- ### Lifecycle & Setup
288
-
289
- | Function | Description |
290
- | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
291
- | `configure(config)` | Starts the runtime singleton, or updates it. |
292
- | `shutdown()` | Sends pending records and stops every subsystem. It cancels a request that is still open after the final flush. Later calls do nothing until the next `configure()`. |
293
- | `rotateSecurityContext(update, options?)` | Changes the delivery identity and the delivery settings together. Use it at logout or a tenant change. See [runtime policies](docs/runtime-policies.md#security-context-rotation). |
294
- | `setConfigurationLocked(locked)` | Locks or unlocks changes through `configure()`. |
295
-
296
- ### Logging Methods
297
-
298
- | Function | Description |
299
- | ---------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
300
- | `getLogger(namespace, options?)` | Returns the cached logger for a namespace. With `options`, it returns a new logger that is not cached. |
301
- | `trace(msg, payload?)` | Logs a TRACE record. |
302
- | `debug(msg, payload?)` | Logs a DEBUG record. |
303
- | `info(msg, payload?)` | Logs an INFO record. |
304
- | `warn(msg, payload?)` | Logs a WARN record. |
305
- | `error(msg, err?, payload?)` | Logs an ERROR record with the error and the breadcrumb trail. |
306
- | `fatal(msg, err?, payload?)` | Logs a FATAL record with the error and the breadcrumb trail. |
307
- | `logAction(name, payload?)` | Logs one user action. |
308
- | `logEvent(name, payload?)` | Logs one domain or lifecycle event. |
309
- | `logMetric(name, value, unit?, type?, attrs?)` | Logs a measurement (`gauge`, `counter`, `histogram`). |
310
- | `counter(name, { unit? })` | Gives a counter. `add(value, attrs?)` sums a value of 0 or larger in memory. The library sends one point for each attribute set at each interval. |
311
- | `histogram(name, { unit?, boundaries? })` | Gives a histogram. `record(value, attrs?)` counts a value in buckets in memory. The library sends one point for each attribute set at each interval. |
312
- | `timeSync(label, fn, attrs?)` | Times a function and emits a duration histogram with `status` `SUCCESS` or `FAILURE`. |
313
- | `timeAsync(label, fn, attrs?)` | Times a promise and emits a duration histogram with `status` `SUCCESS` or `FAILURE`. |
314
- | `startMeasure(name, attrs?)` | Times an operation with named phases. See [Measures](#measures). |
315
-
316
- The level methods give records with `log.type: "log"`. Records of the library itself have `log.type: "system"`. `logMetric` drops a value that is not finite and counts `record.dropped_malformed`.
317
-
318
- `counter` and `histogram` sum their values for `batching.metricFlushIntervalMs`. Then they send one point for each attribute set. 1000 calls of `add(1)` give one point with the value 1000. Sampling and `minLevel` do not drop a point. The console does not print it. Each instrument keeps at most 100 attribute sets in each interval. The values of more sets go to one set with `otel.metric.overflow: true`. Attribute values must be strings, finite numbers or booleans. The library drops an attribute key that starts with `metric.`. It also drops the keys that it sets on each record, for example `page.url` and `log.type`. The record limits do not cut the metric fields of a point, for example the bucket counts. `redact` cannot change them. Do not use a user id or a URL as an attribute. Each value makes a new series in the backend. The default histogram boundaries are `[0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000]`. The points of the open interval go out at `flush()`, at `shutdown()` and before the exit flush. A frame that forwards its records sends its points at the interval, at `flush()` and at `shutdown()` only.
319
-
320
- ### Measures
321
-
322
- `startMeasure()` times an operation with named phases.
130
+ A child frame or a worker forwards its records to the page over the bus. The page batches, stores and sends them, and its `redact` runs on them. Register each child in the page before the child starts. Each child calls `configure()` too. A cross-origin child also needs the origin of the page in `bus.trustedOrigins`. A child that starts before the page runtime gets no owner. After a timeout, it sends its own records with its own `redact`.
323
131
 
324
132
  ```ts
325
- const measure = startMeasure("checkout", { tier: "gold" });
326
- measure.phase("validate");
327
- await validate();
328
- measure.phase("payment");
329
- await pay();
330
- measure.end();
331
- ```
133
+ import { flush, registerFrame, registerWorker } from "@utk09/ui-observability";
332
134
 
333
- - `phase(name)` closes the open phase and starts the next phase. `end(outcome?)` closes the open phase and records the total. Later calls of the handle do nothing.
334
- - Each phase goes into the histogram `ui.measure.phase.duration` with `measure.name` and `measure.phase`. The total goes into `ui.measure.duration` with `measure.name` and `measure.outcome`. Both are in milliseconds.
335
- - The default outcome is `"ok"`. Each name, outcome and attribute set makes one series. Keep these values small in number.
336
- - With `tracesEndpoint`, the measure is a span of kind INTERNAL with one child span for each phase. The outcome `"error"` marks the measure span and its open phase as failed.
337
- - A shutdown drops a measure that has no end. With isolation, a new delivery identity also drops it.
338
-
339
- ### Context & Correlation
340
-
341
- | Function | Description |
342
- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
343
- | `setContext(key, value)` | Sets one ambient attribute on every later record. |
344
- | `setContextMap(values)` | Merges an attribute map into the ambient context. |
345
- | `removeContext(key)` | Removes one attribute from the ambient context. |
346
- | `addBreadcrumb(message, data?)` | Adds a breadcrumb with the category `custom`. The next error record carries the trail. The library copies `data` at the call. |
347
- | `startJourney(name, options?)` | Starts a journey across windows. `options.parent: true` links the active journey as the parent. `options.id` sets the id, 1 to 64 letters, digits, `_`, `.`, `:` or `-`. Another value gives a new id and a `config.invalid` report. |
348
- | `endJourney()` | Ends the active journey. |
349
- | `currentJourney()` | Returns the active `Journey`, or null. |
350
- | `getJourneyToken()` | Serializes the active journey into a URL token. |
351
- | `adoptJourney(token)` | Adopts a journey token into this context. |
352
- | `startTrace()` | Rotates the ambient trace context. |
353
- | `getTraceHeaders()` | Returns the W3C `traceparent` header for an outgoing request. |
354
- | `registerWorker(worker, options?)` | Attaches a Web Worker or MessagePort to the bus, with its permissions. Returns a function that removes the registration. |
355
- | `registerFrame(frame, options)` | Registers a child iframe element or window at its exact origin, with its permissions. Returns a function that removes the registration. A child frame forwards only after its registration, unless `bus.sourcePolicy` is `trusted-origin`. |
356
- | `newSession()` | Rotates correlation in this tab. Use `rotateSecurityContext()` for logout or tenant changes. It sends the open metric points, ends the active trace and journey, and clears the breadcrumbs. Other tabs read the new id at their next startup. |
357
-
358
- See [runtime policies, operational budgets and migration](docs/runtime-policies.md) for `rotateSecurityContext()`, `registerFrame()`, source permissions, `setConfigurationLocked()`, `getHealth()` and configurable cache/bus budgets. Defaults favor privacy and isolation; applications can explicitly choose broader capture and delivery policies.
359
-
360
- `serveTransportWorker({ onDiagnostic? })` starts the dedicated transport worker service. It returns a function that stops the service.
361
-
362
- ### Delivery & Diagnostics
363
-
364
- | Function | Description |
365
- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
366
- | `flush()` | Sends the records held in the pipeline or the forward buffer, and waits for the batches in flight. |
367
- | `getQueueDepth()` | Returns the number of batches in storage. |
368
- | `getStats()` | Returns `{ pending, inFlight, stored, lastSendAt }`. `pending` counts the records in the buffers. `inFlight` counts the records in requests. `stored` counts the batches in storage. `lastSendAt` is the epoch time in ms of the last batch that the server accepted, or null. A forwarder reports only its own buffers. |
369
- | `getDiagnosticCounters()` | Returns the count of each diagnostic code. |
370
- | `getHealth()` | Returns the state of this SDK copy. It has the SDK version, the status, the delivery role and counts, the lock and cache state, the issue codes and the policies. |
371
- | `collectDebugBundle()` | Returns a JSON-safe bundle for a support ticket. It has the health, the diagnostic counters, the resource, the breadcrumbs, the debug buffer and a config summary. The summary has no headers and no URL query. A plugin or a custom serializer shows only its name. The privacy hooks process the breadcrumbs. A debug buffer record keeps its context attributes. Your app decides where to send it. |
372
- | `clearPersistedLogs(scope?)` | Removes the stored records of the active context. With `"namespace"`, it removes the stored records of each context in the persistence namespace. |
373
-
374
- ---
135
+ // In the page, after configure(). The frame is in the document and has no src yet.
136
+ const frame = document.body.appendChild(document.createElement("iframe"));
137
+ registerFrame(frame, { origin: "https://ticket.example" });
375
138
 
376
- ## Configuration Options
377
-
378
- No key is required. Set `endpoint` to send records. A value of the wrong type or outside its range reports `config.invalid`. The value in force stays. Level names can have any case. You cannot change `batching` and `retention` after the delivery stack loads. You cannot change `limits` and `journey.maxAgeMs` after the first `configure()`. [Runtime policies](docs/runtime-policies.md) gives each default and range of the policy sections.
379
-
380
- | Key | Default | Description |
381
- | ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
382
- | `endpoint` | `""` | HTTP endpoint that receives the batches. `null` selects console-only mode. `""` reports `config.invalid`. |
383
- | `metricsEndpoint` | `""` | OTLP metrics endpoint, for example `https://ingest.example/v1/metrics`. With it, each batch of metric records goes there as an OTLP `ExportMetricsServiceRequest`. Without it, metric records are log records on `endpoint`. It needs `serializer: "otlp"`, and `endpoint` or `transport`. |
384
- | `tracesEndpoint` | `""` | OTLP traces endpoint, for example `https://ingest.example/v1/traces`. With it, the library records spans and sends them there as an OTLP `ExportTraceServiceRequest`. Without it, the library sends no span. It needs `serializer: "otlp"`, and `endpoint` or `transport`. See [Spans](#spans). |
385
- | `serviceName` | `""` | `service.name` on every record. |
386
- | `serviceVersion` | `""` | `service.version` on every record. |
387
- | `environment` | `""` | `deployment.environment` on every record. |
388
- | `enabled` | `true` | Set `false` to stop all logging. Every log call then does nothing. |
389
- | `payloadMode` | `"copy"` | `"defer"` keeps payload references until idle time. The debug buffer always builds records at the call. |
390
- | `minLevel` | `"INFO"` | Lowest level that the library sends (`TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `FATAL`). It does not drop actions and metrics. |
391
- | `minLevels` | `{}` | Lowest level for each namespace prefix, for example `{ "trading.ticks": "DEBUG" }`. The longest matching prefix wins. A prefix matches its own namespace and the namespaces below it after a dot. A namespace with no match uses `minLevel`. A new map replaces the map in force. |
392
- | `compression` | `"gzip"` | `gzip` or `none`. The library compresses a payload above 1 KB only. |
393
- | `serializer` | `"otlp"` | `otlp`, `ecs`, or a custom `LogSerializer`. `ecs` writes ECS 8.10 NDJSON. It maps `app.namespace` to `log.logger`, `error.type`, `error.message` and `error.stack_trace` to `error.*`, and `log.type` to `event.kind`. The other attributes go to `labels`. |
394
- | `credentials` | `"omit"` | Fetch credentials mode. Set `"include"` for cookie auth. |
395
- | `headers` | `{}` | Static headers, or a function that returns them. After a 401 or 403, a function gets one more call and the batch one more send. The exit flush sends the last headers. Before a function gives its first result, the exit flush puts the batch in the emergency queue. `headers: undefined` removes the headers. |
396
- | `storage` | `"auto"` | Store for undelivered batches: `auto`, `indexeddb`, `localstorage`, `memory` or `none`. Fixed at startup. |
397
- | `identity` | `"storage"` | Store for session, tab and journey ids. `memory` writes no key. Fixed at startup. |
398
- | `sampling.defaultRate` | `1` | Keep rate for a namespace with no rule. |
399
- | `sampling.rates` | `{}` | Keep rate per namespace. The longest matching prefix wins. |
400
- | `sampling.alwaysSampleTypes` | `["action"]` | Record types that ignore the rate. |
401
- | `sampling.alwaysSampleFrom` | `"ERROR"` | Lowest level that ignores the rate. `capturePolicy.errorCeiling` limits these log records. |
402
- | `sampling.remote` | `false` | Reads sampling rules from the `X-UiObs-Sampling` header of each accepted batch (see Remote Sampling). |
403
- | `sampling.remoteMaxRate` | `1` | Highest rate that a remote rule can set. It applies to the remote `defaultRate` and to each remote namespace rate. |
404
- | `bus.mode` | `"auto"` | `auto`, `sender`, `forwarder` or `off`. With `off`, this context sends its own records and opens no link. A same-origin child frame that the page registers can still forward to it. |
405
- | `bus.trustedOrigins` | `[]` | Origins of other documents that this document trusts. A cross-origin child frame forwards its records only to a parent on these origins. With `bus.sourcePolicy: "trusted-origin"`, a parent also accepts records from a child frame on these origins. With the default policy, use `registerFrame()`. The library keeps the origin of each URL. For a sandboxed frame, set `bus.mode: "sender"` in the frame. A trusted origin is also trusted for metric points. Its points bypass the sampling and the limit of 100 attribute sets of this document. |
406
- | `bus.sourcePolicy` | `"registered"` | `registered` accepts only the frames and workers that the page registers. `trusted-origin` also accepts each frame on the page origin or in `bus.trustedOrigins`. |
407
- | `bus.validation` | `"strict"` | `strict` checks the fields of each bus message. `envelope` checks the envelope only. |
408
- | `bus.maxMessageBytes`, `bus.maxRecordsPerMessage`, `bus.maxMessagesPerSecond`, `bus.maxTrackedSources` | `262144`, `100`, `100`, `256` | Bus budgets for each message and each source. `0` turns a limit off. |
409
- | `bus.openFinRole` | `"auto"` | `auto`, `provider` or `client`. |
410
- | `journey.scope` | `"auto"` | Which contexts adopt a journey. `context`: each context keeps its own. `tab`: a frame or a worker adopts the journey of its owner. `origin`: each context of the origin, also in other tabs. `auto` is `origin` in OpenFin and `tab` in a browser. |
411
- | `journey.maxAgeMs` | `1800000` | Maximum open time of a journey, in milliseconds. Then the library ends it. The range is 60000 to 86400000. |
412
- | `batching.logFlushIntervalMs` | `2000` | Maximum wait of a partial log batch, in milliseconds. The range is 100 to 60000. |
413
- | `batching.logBatchSize` | `100` | Maximum records in one log batch. The range is 1 to 1000. |
414
- | `batching.metricFlushIntervalMs` | `10000` | Maximum wait of a partial metric batch, in milliseconds. The range is 100 to 60000. |
415
- | `batching.metricBatchSize` | `500` | Maximum records in one metric batch. The range is 1 to 1000. |
416
- | `retention.mode` | `"limited"` | `limited` or `until-delivered`. With `until-delivered`, a stored batch has no age limit and no attempt limit. `retention.maxBatches` still applies. A permanent error still drops the batch. A batch that always gets a temporary error stays first. The batches of the same endpoint behind it wait. |
417
- | `retention.maxBatches` | `500` | Maximum stored batches. A new batch evicts the oldest batch without an action first. The range is 1 to 5000. |
418
- | `retention.maxAgeMs` | `86400000` | Maximum age of a stored batch, in milliseconds. The range is 60000 to 604800000. |
419
- | `retention.maxAttempts` | `5` | Maximum send attempts of a stored batch. The range is 1 to 20. |
420
- | `limits.maxBodyChars` | `4096` | Maximum body length, in characters. The range is 256 to 65536. |
421
- | `limits.maxAttributeChars` | `8192` | Maximum length of a string attribute, in characters. The range is 256 to 65536. |
422
- | `limits.maxAttributeCount` | `128` | Maximum keys in one object. The range is 1 to 1024. |
423
- | `limits.maxStackChars` | `8192` | Maximum length of an error stack, in characters. The range is 256 to 65536. |
424
- | `limits.maxDepth` | `6` | Maximum depth of a nested value. The range is 1 to 16. |
425
- | `limits.maxArrayLength` | `100` | Maximum items in one array, set or map. The range is 1 to 10000. |
426
- | `limits.maxNodes` | `10000` | Maximum values in one sanitize pass. The range is 100 to 100000. |
427
- | `limits.maxRecordBytes` | `32768` | Maximum attribute bytes of one record. Above it, the library drops the caller attributes. The range is 1024 to 60000. |
428
- | `securityContext.id` | Generated | Delivery identity of this runtime. Supply a stable opaque id to send stored batches after a reload. Do not put secrets or personal data in it. |
429
- | `securityContext.isolation` | `true` | Keeps the stored batches of each identity apart. Delivery changes then need `rotateSecurityContext()`. |
430
- | `lockConfiguration` | `false` | Refuses changes through `configure()`. Identical repeated settings are accepted. `setConfigurationLocked(false)` unlocks. |
431
- | `loggerCache.maxEntries` | `256` | LRU limit of cached loggers. `0` turns the cache off. `null` sets no limit. |
432
- | `delivery` | See policies | Request timeout, request concurrency, retry delays, batches in one retry pass and fetch priority (`"low"` by default). |
433
- | `buffering` | 10,000 records, 16 MiB, `"drop-oldest"` | Limits of the live buffers, and the overflow rule. |
434
- | `debugBuffer` | `{ enabled: false, maxRecords: 200, maxAgeMs: 60000 }` | Keeps the records that `minLevel` or sampling drops. An ERROR or FATAL record of this context sends them first, with `uiobs.debug_buffer: true`. A later change of `redact` or `processors` empties the buffer. |
435
- | `metrics` | See policies | Limits of instrument names, attribute sets and histogram boundaries. |
436
- | `correlation` | See policies | Session idle time, session write interval and trace age. Fixed at startup. |
437
- | `capturePolicy` | See policies | Breadcrumb capacity, error duplicate check, capture rate limits and the error ceiling. |
438
- | `diagnostics` | `{ throttleMs: 1000, consoleFallback: false, records: false }` | Report interval of each diagnostic code, and the console fallback when `onDiagnostic` throws. `records: true`, or a list of codes, also sends each report as a record in the namespace `uiobs.diagnostics`. |
439
- | `persistence.namespace` | `""` | Separates the batch stores, the emergency queue and the retry locks of one application. Fixed at startup. |
440
- | `persistence.requestPersistent` | `false` | Asks the browser to keep the stored batches under storage pressure. Firefox can show a prompt. `getHealth()` reports the answer. Fixed at startup. |
441
- | `metadata` | All `true` | `pageUrl`, `userAgent` and `openfin` include `page.url`, `browser.user_agent` and the OpenFin fields. `clockOffset` adds `uiobs.clock_offset_ms` to logs and spans. |
442
- | `capture` | See below | Auto-capture settings. |
443
- | `capture.remoteToggles` | `[]` | Capture switches that remote rules can change for their TTL. Requires `sampling.remote`. Privacy controls stay local. |
444
- | `capture.serverTiming` | `false` | Adds Server-Timing response entries to fetch and XHR records. Links a valid traceparent entry to the client span. |
445
- | `capture.reports` | `false` | Records deprecations, interventions and CSP reports as WARN `ui.report`. |
446
- | `capture.resourceTiming` | `false` | Records `ui.resource.duration` by initiator type and host. Accepts `true` or an object with `slowMs`. |
447
- | `capture.resourceTiming.slowMs` | `1000` | Minimum duration of a `ui.resource.slow` event, in milliseconds. Set `0` for no slow events. |
448
- | `capture.lifecycle` | `false` | Records visible, hidden, frozen, resumed and restored states with the duration of the previous state. |
449
- | `capturePolicy.reportsPerWindow` | `20` | Maximum browser reports in each capture window. Set `0` for no limit. |
450
- | `capturePolicy.resourcesPerWindow` | `100` | Maximum resource entries in each capture window. Set `0` for no limit. |
451
- | `capturePolicy.lifecyclePerWindow` | `20` | Maximum lifecycle events in each capture window. Set `0` for no limit. |
452
- | `console` | `false` | Prints records to devtools. `true` prints from `DEBUG` up. A level name prints from that level up. An object sets `level` and `styles` (see Console Output). It does not depend on `minLevel`. |
453
- | `transport(request)` | `undefined` | Sends batches through a channel of your app in place of HTTP (see Custom Transport). |
454
- | `transportWorker()` | `undefined` | Creates a dedicated HTTP worker. It calls `serveTransportWorker()`. Retry, storage, header functions and exit sends stay on the main thread. |
455
- | `transportOnExit(request)` | `undefined` | Sends the last batch while the page closes. It must return a boolean and must not wait. |
456
- | `otelLoader()` | `undefined` | Loads `@opentelemetry/api`. Without it, OTel is off. |
457
- | `contextProvider()` | `undefined` | Returns attributes for each built record, including console/breadcrumb-only candidates, for example the current route. Its values override `setContext()` values. The logger scope and the call payload override its values. Keep it fast and synchronous. A provider that throws reports `handler.threw`. A value that is not an object reports `config.invalid`. The record is still built. |
458
- | `processors` | `[]` | Functions that change or drop a record. They run in list order, before `redact`. A processor has the contract of `redact`. Return the record or a new record to keep it, or `null` to drop it. If a processor throws or returns a value that is not a record, the library drops the record. It counts `record.dropped_by_processor`. A new list replaces the list in force. |
459
- | `redact(record)` | `undefined` | Changes a record before the library sends or prints it, including console-only candidates. Return `null` to drop the record. If the hook throws or returns a value that is not a record, the library drops the record. It counts `record.dropped_by_redact`. The sender also runs its `redact` on each record from a frame or a worker. A record that the child already redacted then runs through `redact` again. Write `redact` so that a second run gives the same result. |
460
- | `onDiagnostic(event)` | `undefined` | Receives the faults of the library itself. |
461
- | `onDrop(summary)` | `undefined` | Receives a summary when the library loses records that it built. The summary has `reason`, `records`, `batchIds`, `journeyIds` and `actions`. Sampling, `minLevel`, `processors` and `redact` do not cause a loss. Do not log through the library in the hook. A record from the hook can evict a stored batch. A batch that storage evicts during its send can still reach the server. |
462
-
463
- ### Deferred payloads
139
+ const worker = new Worker(new URL("./pricing.worker.ts", import.meta.url), { type: "module" });
140
+ registerWorker(worker);
464
141
 
465
- ```ts
466
- configure({ payloadMode: "defer" });
467
- const payload = { status: "before" };
468
- getLogger("orders").info("Order state", payload);
469
- payload.status = "after";
142
+ // The registrations start with the runtime. A frame that loads before that finds no owner.
143
+ await flush();
144
+ frame.src = "https://ticket.example/";
470
145
  ```
471
146
 
472
- With `defer`, the record sees `status: "after"` if the idle build runs after the assignment. With the default `copy`, it sees `"before"`. The queue keeps the payload reference without reading its fields. Error reasons and metric attributes also wait for the build. Console output and breadcrumbs wait with the record. A call below the level queues nothing unless the console uses it. Sampling checks use the rules in force at build time.
473
-
474
- The call keeps its timestamp, trace, journey and a shallow copy of the ambient context. The builder reads `contextProvider`, scoped context and payload fields at build time. Processors and `redact` also run at build time. The queue can hold raw values until then. Debug bundle output does not include those raw queued values.
475
-
476
- `requestIdleCallback` builds records while idle time remains. A callback timeout of 1000 ms permits one build without idle time. A timer runs the build when the idle API is absent. `flush()`, shutdown and page exit build pending records first. Reconfiguration, session changes and delivery identity changes also drain pending calls first.
477
-
478
- The queue holds at most 1000 calls for each runtime. A lower positive `buffering.maxPendingRecords` also lowers this cap. A full queue builds its calls before it accepts another payload reference. Calls from a hook wait for the next callback. Extra calls from a hook at the cap increment `record.dropped_by_ceiling`. The library does not build those calls.
479
-
480
- The deferred cap is separate from the delivery buffer. Delivery byte budgets and stats apply to built records. With `debugBuffer.enabled`, the logger builds every record at the call, also with `payloadMode: "defer"`. This preserves the debug buffer's immediate privacy processing.
481
-
482
- ### Remote capture switches
483
-
484
147
  ```ts
148
+ // In the frame on https://ticket.example. A same-origin frame or a worker needs no trustedOrigins.
485
149
  configure({
486
- sampling: { remote: true },
487
- capture: { remoteToggles: ["fetch", "resourceTiming", "lifecycle"] },
150
+ endpoint: "https://telemetry.example.com/v1/logs",
151
+ serviceName: "ticket",
152
+ bus: { trustedOrigins: ["https://app.example"] },
488
153
  });
489
154
  ```
490
155
 
491
- ```http
492
- X-UiObs-Sampling: {"v":1,"ttlMs":60000,"capture":{"fetch":true,"lifecycle":false}}
493
- ```
494
-
495
- The rules change only the switches in this context's `remoteToggles`. The empty default list permits no changes. Each switch is boolean. An invalid switch or a privacy control rejects the whole header. The allowed names are `errors`, `rejections`, `resourceErrors`, `fetch`, `xhr`, `httpMetrics`, `interactions`, `navigation`, `webVitals`, `longFrames`, `console`, `webSocket`, `uncleanExit`, `userTiming`, `serverTiming`, `reports`, `resourceTiming` and `lifecycle`.
496
-
497
- A remote enable keeps the local options of a capture, for example click privacy settings or a console method list. The server cannot change text capture, selectors, URL rules, trace propagation, plugins or thresholds. The library restores local settings when the TTL ends, remote sampling stops, or the delivery identity changes. The trusted sampling path also sends these rules to forwarders. Each forwarder applies its own allowlist.
498
-
499
- ### Auto-Capture Options
500
-
501
- ```ts
502
- capture: {
503
- errors: true, // Uncaught window.onerror exceptions (default: true)
504
- rejections: true, // Unhandled promise rejections (default: true)
505
- resourceErrors: false, // <img>, <script>, <link> load failures
506
- fetch: false, // window.fetch duration and status codes
507
- xhr: false, // XMLHttpRequest duration and status codes
508
- httpMetrics: true, // http.client.request.duration histogram of fetch and xhr requests, in seconds.
509
- // Attributes: http.request.method, http.response.status_code, server.address, error.type
510
- interactions: false, // Click action names. The object form sets actionAttribute, text, selector,
511
- // rageClicks and deadClicks
512
- navigation: false, // Single-page navigation URL changes
513
- webVitals: false, // Core Web Vitals (LCP, CLS, INP, FCP, TTFB)
514
- longFrames: false, // Frames that freeze the page, as ui.long_frame.duration
515
- longFrameThresholdMs: 100, // Minimum frame duration that longFrames records
516
- console: false, // App console calls: true, or a list such as ["error", "warn", "info"]
517
- fullUrls: false, // Keep query strings and fragments on recorded URLs
518
- urlTransform: undefined, // Function that replaces the default URL rule
519
- ignoreUrls: [], // URL patterns excluded from network capture
520
- propagateTraceHeaderTo: [], // Origins, or RegExp patterns, that receive traceparent
521
- webSocket: false, // WebSocket open, close and error, and ui.websocket.messages
522
- uncleanExit: false, // WARN ui.unclean_exit when the previous page of the tab did not close cleanly
523
- userTiming: false, // performance.measure() as ui.user_timing.duration. A mark gives a breadcrumb
524
- userTimingInclude: [], // Mark and measure names that userTiming records. Empty records each name
525
- remoteToggles: [], // Capture switches that a remote rule can change for its TTL
526
- serverTiming: false, // Server-Timing entries on fetch and XHR records
527
- reports: false, // Browser reports as WARN ui.report
528
- resourceTiming: false, // Resource durations. An object sets slowMs, with default 1000
529
- lifecycle: false, // Page states and the duration of the previous state
530
- plugins: [], // Capture plugins of your app
531
- }
532
- ```
533
-
534
- `interactions: { rageClicks: true, deadClicks: true }` finds frustrated clicks. Each event names only the action, in `click.action`.
535
-
536
- - A rage click is `rageClickCount` clicks (default 3) on one element in `rageClickWindowMs` (default 1000). It gives the event `ui.rage_click` with `click.count`. More clicks in the same burst give no second event. A burst ends when no click stays in the window.
537
- - A dead click is a click on a control that gives no DOM change, no navigation and no scroll in `deadClickMs` (default 1000). It gives the event `ui.dead_click`. A control is a button, a link, a `role="button"` element or an element with the action attribute. A click on a `target="_blank"` or `download` link gives no event.
538
- - A request alone is not a response. A page that changes its DOM all the time gives no dead click.
539
-
540
- `uncleanExit` finds a page of this tab that stopped without a clean close, for example after a crash. The top document keeps a marker in `sessionStorage`. A clean close removes it. The next page of the tab logs WARN `ui.unclean_exit`. A popup with an opener reports nothing, because it copies the `sessionStorage` of its opener. A duplicated tab copies it too, and can report a false exit. `identity: "memory"` turns this capture off, because that mode writes nothing to the device.
541
-
542
- - The attributes are `exit.session_id`, `exit.last_seen_ms`, `exit.visibility` and `exit.discarded`.
543
- - The marker updates every 30 seconds and at each visibility change. `exit.last_seen_ms` is correct to about 30 seconds.
544
- - A mobile OS can stop a hidden page with no close event. `exit.visibility: "hidden"` shows this case. `exit.discarded: true` shows a page that the browser discarded to free memory.
545
-
546
- `userTiming` records each `performance.measure()` of the app in the histogram `ui.user_timing.duration`, in milliseconds, with the attribute `user_timing.name`. Each `performance.mark()` adds a breadcrumb. Frameworks create many marks and measures. Set `userTimingInclude`, for example `[/^app\./]`, to keep only the names of your app. `metrics.maxSeries` limits the number of names in one interval. Names follow `fullUrls`. Without it, a name loses the part after the first `?` or `#`.
547
-
548
- `serverTiming` reads the `Server-Timing` response header of captured fetch and XHR requests. It adds `server.timing` entries with `name`, `duration` and `description`. A valid `traceparent;desc="00-<trace-id>-<span-id>-01"` adds an OTLP link to the client span. The client span keeps its own trace and parent. Set `tracesEndpoint` and `propagateTraceHeaderTo` to record client spans.
549
-
550
- For cross-origin requests, expose `Server-Timing` with `Access-Control-Expose-Headers`. Also send `Timing-Allow-Origin` for access through browser performance tools. The [Server Timing specification](https://www.w3.org/TR/server-timing/) defines that interface. The library reads at most 4096 header characters and 32 entries. The privacy hooks process the entries before delivery.
551
-
552
- `reports` records deprecations and interventions through ReportingObserver. CSP reports use the `securitypolicyviolation` event. Each WARN `ui.report` has the type, the URL and the available source location or CSP directive. Report URLs never keep credentials, queries or fragments. This rule also applies with `fullUrls` or `urlTransform`. Message text and code samples stay out.
553
-
554
- `resourceTiming: true` records the histogram `ui.resource.duration` in milliseconds. Its attributes are `resource.initiator_type` and `server.address`. Each resource at or above 1000 ms also gives `ui.resource.slow`. Set `resourceTiming: { slowMs: 500 }` to change the threshold. Set `slowMs: 0` for no slow events. The capture skips ingest endpoints, ignored URLs and non-HTTP resources. Only the first install reads buffered resources. `metrics.maxSeries` limits the host and initiator series.
555
-
556
- `lifecycle` records `ui.lifecycle` at install and on each state change. The states are `visible`, `hidden`, `frozen`, `resumed` and `restored`. `restored` means a back-forward cache restore. Each event has `lifecycle.previous_state` and `lifecycle.duration_ms`. A monotonic clock measures the duration.
557
-
558
- The three captures have separate rate limits in `capturePolicy`. They use `capturePolicy.windowMs`, which defaults to 10000 ms. Disabling a capture removes its listeners or disconnects its observer.
559
-
560
- `longFrames` records each frame at or above `longFrameThresholdMs` as the histogram `ui.long_frame.duration`. Each long frame also adds a breadcrumb. The next error record then shows the freeze before it.
561
-
562
- - The library observes `long-animation-frame`. A browser without it gives `longtask` entries, with no script attributes.
563
- - The attributes are `frame.type`, `frame.blocking_ms`, `frame.script.invoker` and `frame.script.source`. The source URL follows `fullUrls`.
564
- - The library records at most 20 long frames in each 10-second window.
565
-
566
- `capture.console` records the console calls of your app and of third-party code. It is different from the top-level `console` option, which prints records.
567
-
568
- > **Set `redact` before you turn on `capture.console`.** A call such as `console.error("Request failed", error.response)` sends the request headers, for example `Authorization`. Third-party code on the page writes such lines too.
569
-
570
- - `true` wraps `console.error` and `console.warn`. A list selects from `error`, `warn`, `info` and `log`.
571
- - `error` gives an ERROR record, and `warn` gives a WARN record. `info` and `log` give a breadcrumb only.
572
- - The first string is the message. The first `Error` of an `error` call gives the `error.*` fields. The other arguments go into `console.args`.
573
- - The wrapper calls the original method first. Devtools shows the same text. The source link of the line points to the library wrapper.
574
- - The library does not record the lines that it prints itself.
575
- - The library records at most 20 `error` and `warn` calls in each 10-second window. The error capture has a separate limit. Console noise cannot hide an uncaught error.
576
- - To record an argument, the library reads each property, also a getter. A getter with a side effect then runs during the console call.
577
- - On `shutdown()`, the library restores each method. If another script wrapped the method later, the library leaves it and reports `capture.install_failed`.
578
-
579
- `webSocket` records the lifecycle of each WebSocket that the app opens after the capture loads.
580
-
581
- - `websocket.open` and `websocket.close` are events. `websocket.error` is a WARN record. Each has `url.full` and `server.address`.
582
- - `websocket.close` adds `websocket.close.code` and `websocket.close.clean`.
583
- - `url.full` has no user info, no query and no fragment, also with `fullUrls`. A socket URL often holds a token. Only `urlTransform` can record more of the URL.
584
- - The counter `ui.websocket.messages` counts the messages, with `network.io.direction` (`transmit` or `receive`) and `server.address`.
585
- - The library never reads the content of a message.
586
- - The library records at most 20 lifecycle records in each 10-second window. The counter counts each message.
587
-
588
- `plugins` adds your own capture modules. A plugin is an object with `name`, `install(ctx)` and `uninstall()`.
589
-
590
- - `ctx` gives `logger`, `counter()`, `histogram()`, `addBreadcrumb()` and `ownRequest(fn)`. The logger namespace is `uiobs.capture.<name>`.
591
- - `ownRequest(fn)` runs `fn`. The network capture does not record a request that `fn` starts before its first `await`, and does not add `traceparent` to it.
592
- - A `configure()` that changes the capture section calls `uninstall()`, then `install(ctx)` again. `shutdown()` calls `uninstall()`.
593
- - If `install()` or `uninstall()` throws, the library reports `capture.install_failed`. The other capture modules keep working.
594
- - The console-only runtime next to another version of the library installs no plugin.
595
-
596
- ```ts
597
- import { type CapturePlugin, configure } from "@utk09/ui-observability";
598
-
599
- let onChange: (() => void) | undefined;
600
-
601
- const visibility: CapturePlugin = {
602
- name: "visibility",
603
- install(ctx) {
604
- onChange = () => {
605
- ctx.logger.logEvent("page.visibility", { state: document.visibilityState });
606
- };
607
- document.addEventListener("visibilitychange", onChange);
608
- },
609
- uninstall() {
610
- if (onChange) {
611
- document.removeEventListener("visibilitychange", onChange);
612
- }
613
- },
614
- };
615
-
616
- configure({ endpoint: "https://ingest.example/v1/logs", capture: { plugins: [visibility] } });
617
- ```
618
-
619
- `fullUrls` is off by default. The library then cuts each recorded URL at the first `?` or `#`. This applies to the page URL, the request target and the URL of a failed resource. `ignoreUrls` and a RegExp in `propagateTraceHeaderTo` match the full URL. `urlTransform` replaces this rule. It receives the original URL. If it throws, the library records an empty URL and reports `capture.record_failed`.
620
-
621
- A string in `propagateTraceHeaderTo` is an origin, for example `"https://api.example"`. It matches a request to that origin only. A URL with a path gives its origin. A relative request URL resolves against the page. To match a path, use a RegExp. A RegExp tests the request URL in the form that the caller gives. Start each RegExp with `^`. Without it, `/\/api\//` also matches `https://vendor.example/api/`. For example, `/^https:\/\/api\.example\/v2\//` matches one path on one origin. `/^\/api\//` matches a relative request URL only.
622
-
623
- ### Spans
624
-
625
- With `tracesEndpoint`, the library sends spans. The backend then has a root span for each trace of the library.
626
-
627
- - **Root span:** Each ambient trace has one root span of kind INTERNAL. It starts with the trace and ends when the trace rotates. Its name tells why the trace started: `ui.start`, `ui.interaction`, `ui.navigation` or `ui.trace`.
628
- - **Client span:** Each `fetch` or XHR request that gets `traceparent` from `capture.propagateTraceHeaderTo` has one span of kind CLIENT. The `traceparent` names the client span, and the root span is its parent. Its name is the HTTP method. Its attributes are `http.request.method`, `url.full`, `server.address`, `http.response.status_code` and `error.type`. A status of 0 or 400 and more sets the status ERROR.
629
- - **Measure span:** Each `startMeasure()` call has one span of kind INTERNAL under the root span. Each phase has one child span. Sampling and the OpenTelemetry rule apply to it as to a client span.
630
- - **Sampling:** `sampling.defaultRate` samples each trace by its trace id. The whole trace stays or goes. `minLevel` does not apply to a span. For a trace that sampling drops, the `traceparent` has the sampled flag off. A downstream service then drops its spans too.
631
- - **Exit:** The exit flush and `shutdown()` end the root span of the active trace. The root span of a trace ends one time. A tab that becomes hidden ends it too, because a mobile OS can stop a hidden page.
632
- - **OpenTelemetry:** With `otelLoader`, a trace from the OpenTelemetry API keeps its own spans. The library sends no span for it.
633
- - `getTraceHeaders()` names the root span. Your server span is then a child of the root span.
634
- - Span records go through `processors` and `redact`. They also carry the context attributes of a record, for example `page.url` and `journey.id`.
635
-
636
- ### Browser Storage Keys
637
-
638
- | Key | Store | Written when | Option that stops it |
639
- | ------------------------------ | ---------------- | ---------------------------------------------------------------- | ---------------------------------------------------- |
640
- | `ui-observability.session` | `localStorage` | At startup, then at most one time each minute while logging | `identity: "memory"` |
641
- | `ui-observability.tab` | `sessionStorage` | At startup, and when the bus finds a duplicated tab | `identity: "memory"` |
642
- | `ui-observability.journey` | `sessionStorage` | When a journey starts or ends | `identity: "memory"` |
643
- | `ui-observability.alive` | `sessionStorage` | At startup, at each visibility change and at each interval | `capture.uncleanExit: false` or `identity: "memory"` |
644
- | `ui-observability.batch.*` | `localStorage` | When a send fails and the `localstorage` adapter holds the batch | `storage` other than `auto` or `localstorage` |
645
- | `ui-observability.emergency.*` | `localStorage` | When the exit flush cannot send a batch | `endpoint: null`, `storage: "memory"` or `"none"` |
646
- | `ui-observability.probe` | `localStorage` | One write and one remove, when the library tests `localStorage` | `storage` other than `auto` or `localstorage` |
647
-
648
- IndexedDB holds undelivered batches with `storage: "auto"` or `"indexeddb"`, in the database `UiObservability`.
649
-
650
- With `persistence.namespace`, the batch keys start with `ui-observability:namespaced:<namespace>:batch:`, the emergency keys start with `ui-observability:namespaced:<namespace>:emergency:`, and the database is `UiObservability:<namespace>`.
651
-
652
- ---
653
-
654
- ## Reference Documents
655
-
656
- - [Attribute reference](docs/attributes.md): each attribute that the library writes, and its type.
657
- - [Browser support](docs/browser-support.md): the browser APIs that the library uses, and the fallback for each.
658
- - [Delivery guarantees](docs/delivery-guarantees.md): duplicates, order, each loss and its `onDrop` reason, retention, the exit flush and rotation.
659
- - [Threat model](docs/threat-model.md): the trust boundaries, the threats and the controls.
660
- - [Runtime policies and migration](docs/runtime-policies.md): the defaults, the overrides, security-context rotation, registered bus sources, health and the upgrade steps.
661
-
662
- ---
663
-
664
- ## Core Architecture
665
-
666
- - **Code splitting:** The main chunk holds the logger, the record builder and the console sink. The delivery stack loads only when you set an endpoint. The bus loads only when the context needs it. Each capture module loads only when you enable it.
667
- - **Document singleton:** The library keeps the runtime at `globalThis[Symbol.for("ui-observability.runtime")]`. Federated microfrontends and separate bundles share one buffer, one sequence and one transport.
668
- - **One sender:** Iframes, workers and OpenFin views find the nearest long-lived context. They forward their records to it over the bus. That context batches, stores and sends for all of them. By default, a parent accepts only the frames and workers that it registers with `registerFrame()` and `registerWorker()`. A frame that knows its owner relays the records of its own children.
669
- - **One sender for each tab:** Each top-level tab or window has its own sender. Two tabs of one origin send their records separately. They have the same `session.id` and a different `tab.id`. A retry of stored batches runs in one tab at a time, under a Web Lock for each persistence namespace.
670
- - **Five correlation ids:** Each record carries `session.id`, `tab.id`, `context.id`, `journey.id` and `trace_id`.
671
- - **Durability and exit flush:** The library stores a batch that fails to send, in IndexedDB or localStorage. It sends the batch again with exponential backoff and jitter. When the document becomes hidden, the library runs a normal flush with the headers, gzip and retry. While the document is hidden, a send of 60 KB or less uses `keepalive`. A mobile OS can stop a hidden page with no `pagehide`. On `pagehide`, `freeze` or OpenFin close, it sends pending records with `navigator.sendBeacon` if they are below 60 KB. With `headers`, it uses a keepalive fetch with the last headers, because a beacon cannot set a header. A larger payload goes to the emergency queue. `shutdown()` runs a normal flush before the exit flush. It then cancels a request that is still open. A stored batch of that request stays in storage. An action is an audit fact. When storage is over `retention.maxBatches` or over the quota of the browser, it removes the batches without an action first. Before startup, the hold buffers keep up to 2000 actions. The 500-record limit applies only to other records. `onDrop` tells the app about each loss.
672
- - **Server (Node):** On Node, for example during server-side rendering, the library runs console-only. It installs no capture, keeps the ids in memory, uses no storage and has no exit flush. If you set `endpoint`, `metricsEndpoint`, `tracesEndpoint` or `transport`, it reports `config.invalid` one time.
673
- - **One library version on a page:** If a copy of another version owns the page runtime, this copy runs console-only. It installs no capture and reports `runtime.version_mismatch`. Load one version of the library on the page.
674
- - **Emergency queue:** The emergency queue is best effort. With `storage: "memory"` or `"none"`, the exit flush does not use it. A batch that it cannot send is then lost, and `onDrop` reports `not_stored`. It writes to `localStorage` synchronously, because no other storage works while the page unloads. If the browser refuses the write, the library reports `storage.quota_exceeded`. The library then loses the batch.
675
- - **Configuration after startup:** A second `configure()` call merges accepted options into an unlocked live runtime. Isolation is on by default. Then `configure()` refuses changes to delivery settings and to the context ID. It keeps the values in force, reports `config.invalid` and applies the other settings. Use `rotateSecurityContext()` for these changes. `securityContext.isolation: false` restores ordinary mutable routing. The runtime also refuses these 5 changes and reports `config.invalid` for each:
676
- - A change to `storage`. The stored batches stay in the adapter that the runtime built at startup.
677
- - A change to `identity`. The ids exist from startup.
678
- - A change to `batching` or `retention` after the delivery stack loads. The stack reads them one time.
679
- - A change to `limits` or `journey.maxAgeMs` after the first `configure()`. The record builder and the journey engine read them one time.
680
- - An `endpoint` change to `null` or `""` after the delivery stack loads. Without an endpoint, the stored batches would be lost. With isolation off, a change to another endpoint URL is accepted.
681
- - **Deterministic sampling:** FNV-1a hashing applies one keep rate to a whole journey. Sampling always keeps an explicit action and each record at or above `sampling.alwaysSampleFrom`, default `"ERROR"`.
156
+ [Registered bus sources](docs/runtime-policies.md#registered-bus-sources) gives the permissions of a child. [Guides](docs/guides.md) also has [Testing](docs/guides.md#testing) and [Remote Sampling](docs/guides.md#remote-sampling). [Production recipes](docs/production-recipes.md) has login, logout, tenant rotation, token refresh and consent withdrawal.
682
157
 
683
158
  ---
684
159
 
685
- ## Ingest Server Requirements
686
-
687
- The ingest server must meet these requirements:
688
-
689
- 1. **Protocol:** Accept `POST` with `Content-Type: application/json` or `text/plain;charset=UTF-8`. `sendBeacon` sends the second one to avoid a CORS preflight.
690
- 2. **Preflight:** Answer `OPTIONS` on the ingest path, and allow the request headers:
691
-
692
- ```http
693
- Access-Control-Allow-Headers: content-type, content-encoding, x-uiobs-batch-id, x-uiobs-attempt
694
- ```
695
-
696
- - The transport sends `X-UiObs-Batch-Id` and `X-UiObs-Attempt` with each batch.
697
- - Above 1 KiB, it also sends `Content-Encoding: gzip`.
698
- - Each of these headers causes a CORS preflight. If the server does not allow them, each preflight fails.
699
- - After a failed preflight, the library tries the batch 5 more times. It then drops the batch.
700
- - Only the beacon records of the exit flush arrive, because a beacon sends no custom header.
701
-
702
- 3. **Deduplication:** Deduplicate on the `X-UiObs-Batch-Id` header and the `uiobs_batch_id` query parameter. Keep the ids for at least 24 hours.
703
- 4. **Throttling:** Return `429` or `503` with `Retry-After`. Expose the header with `Access-Control-Expose-Headers: retry-after`. The library waits 60 s at most.
704
- 5. **Status codes:** `200`, `202` and `204` accept the batch. `413` makes the library split the batch. With a `headers` function, a `401` or `403` gets one more send with new headers. The library drops a batch that gets any other `4xx`.
705
- 6. **Metrics and traces endpoints (optional):** With `metricsEndpoint`, the library sends each batch of metric records there as an OTLP/JSON `ExportMetricsServiceRequest`. With `tracesEndpoint`, it sends each batch of span records there as an OTLP/JSON `ExportTraceServiceRequest`. The rules 1 to 5 also apply to these endpoints. A throttle or a failed batch of one endpoint does not hold back the batches of another endpoint. `headers` applies to each endpoint. Each point is a delta from the previous point of its attribute set. A histogram point with a negative value has no `sum`.
706
- 7. **Remote sampling (optional):** To send sampling rules, add `X-UiObs-Sampling` to a `2xx` answer. Expose the header with `Access-Control-Expose-Headers: x-uiobs-sampling`.
707
- 8. **Clock offset (optional):** Expose the `Date` header with `Access-Control-Expose-Headers: date`. Each later log and span record then carries `uiobs.clock_offset_ms`.
708
-
709
- `tools/reference-collector.mjs` implements each rule with no dependencies. It is not part of the package. Run `node tools/reference-collector.mjs`. Set `ALLOWED_ORIGINS` to the origins of your app. Set `UPSTREAM_URL` to an OTLP/HTTP collector, for example `http://localhost:4318`, to forward each OTLP batch there. The file lists the other settings: `PORT`, `AUTH_TOKEN`, `SAMPLING_RULES`, `MAX_BODY_BYTES` and `MAX_REQUESTS_PER_SECOND`.
710
-
711
- ### Check an ingest server
712
-
713
- Run the command line tool against your ingest URL. Give the origin of your app.
714
-
715
- ```bash
716
- pnpm dlx @utk09/ui-observability doctor https://ingest.example/v1/logs --origin https://app.example
717
- ```
718
-
719
- The tool prints `PASS` or `FAIL` for each rule. The exit code is 0 when each rule passes, 1 when a rule fails and 2 for a wrong command.
720
-
721
- | Rule | Check |
722
- | ----------------- | ------------------------------------------------------------------------------------------- |
723
- | `preflight` | `OPTIONS` answers with a `2xx` status and permits the origin. |
724
- | `allowed headers` | The preflight allows each request header of the library. |
725
- | `test batch` | A `POST` of an OTLP batch gets a `2xx` status and permits the origin. |
726
- | `exposed headers` | The batch answer exposes `Retry-After`. The output names optional headers that stay hidden. |
727
- | `gzip` | A `POST` with `Content-Encoding: gzip` gets a `2xx` status. |
728
- | `deduplication` | A second `POST` with the same `X-UiObs-Batch-Id` gets a `2xx` status. |
729
-
730
- - The tool sends real test batches. Each record has `service.name: "uiobs-doctor"`. Expect three test batches in the store of the server.
731
- - The tool sends no credentials and no `Authorization` header. A server that requires them fails `test batch`.
732
- - A client cannot see the store of the server. `deduplication` proves only that the server accepts a repeated id.
733
- - The tool follows no redirect. A `3xx` answer is a failure, because a browser refuses a preflight that redirects.
734
- - An origin has no path and no trailing slash. A wrong command prints the usage and the arguments that the tool received.
735
- - The tool needs Node 22.22.3 or later.
160
+ ## Documentation
161
+
162
+ | Document | Content |
163
+ | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
164
+ | [API Reference](docs/api.md) | Each exported function, the delivery health, the flush result and the shutdown options. |
165
+ | [Configuration Options](docs/configuration.md) | Each config key and its default, auto-capture, spans and the browser storage keys. |
166
+ | [Guides](docs/guides.md) | Console output, custom transport, worker transport, testing and remote sampling. |
167
+ | [Production recipes](docs/production-recipes.md) | Login, logout, tenant rotation, token refresh, consent withdrawal and the initialization order. |
168
+ | [Ingest Server Requirements](docs/ingest-server.md) | The ingest contract and the `uiobs doctor` check of an ingest server. |
169
+ | [Migration to 1.0.0](docs/migration-v1.md) | Each change from 0.12.x, with the new code. |
170
+ | [Release and support](docs/release-and-support.md) | The stable API contract, the supported environments and the release evidence. |
171
+ | [Runtime policies and migration](docs/runtime-policies.md) | Each default, each range, security-context rotation and the upgrade steps. |
172
+ | [Delivery guarantees](docs/delivery-guarantees.md) | Duplicates, order, each loss and its `onDrop` reason, retention, the exit flush and rotation. |
173
+ | [Attribute reference](docs/attributes.md) | Each attribute that the library writes, and its type. |
174
+ | [Browser support](docs/browser-support.md) | The minimum browser versions, the browser APIs that the library uses, and the fallback for each. |
175
+ | [Architecture](docs/architecture.md) | The core architecture, the layers of the library and the path of a record. |
176
+ | [Threat model](docs/threat-model.md) | The trust boundaries, the threats and the controls. |
177
+ | [Performance](docs/performance.md) | The release benchmark, its baselines and its budgets. |
178
+ | [Development](docs/development.md) | The workspace, the checks and the example applications. |
179
+ | [Browser tests](e2e/README.md) | The Playwright tests and the coverage that is still missing. |
180
+ | [Collector check](e2e/collector/README.md) | The check against a pinned OpenTelemetry Collector. |
181
+ | [Playground guide](playground/README.md) | The five example applications and how to start each one. |
182
+ | [Security policy](SECURITY.md) | How to report a vulnerability. |
183
+ | [llms.txt](llms.txt) | A summary of the library for a large language model. The package includes it. |
736
184
 
737
185
  ---
738
186
 
739
187
  ## Development
740
188
 
741
- Use Node 22.22.3 or later and pnpm 12.18.0. `.nvmrc` selects the minimum Node version.
742
- The `packageManager` field pins pnpm. See the [pnpm installation instructions](https://pnpm.io/installation).
743
- Angular supports Node `^22.22.3 || ^24.15.0 || >=26.0.0`.
744
- Use one of these Node versions for the complete workspace.
745
-
746
- Install from the repository root. The first pnpm install creates `pnpm-lock.yaml`.
747
- Commit that file with dependency changes. Use `pnpm install --frozen-lockfile` for later installs that must keep the resolved versions.
748
-
749
- `pnpm-workspace.yaml` holds separate catalogs for `library`, `vanilla`, `react`, `angular`, `console-only`, `mf-host`, `mf-blotter` and `mf-ticket`.
750
- Each manifest uses its named catalog for external dependencies.
751
- The consumer playgrounds use `workspace:*` for the local library. The vanilla playground loads the library source.
752
- Change versions in the relevant catalog, then run `pnpm install`.
753
-
754
- Dependency versions use the current stable releases checked on 2026-11-07.
755
- TypeScript uses 6.0.3 because Angular 22 and typescript-eslint require TypeScript below 6.1.
756
- The workspace enables install scripts for `@parcel/watcher`, `esbuild`, `fsevents`, `lmdb` and `msgpackr-extract`.
189
+ Use Node 22.22.3 or later and pnpm 12.21.0.
757
190
 
758
191
  ```bash
759
192
  pnpm install
760
- pnpm run dev # Playground, mock ingest server and iframe host
761
- pnpm run verify # Format check, typecheck, build, lint, peer, size and dev-server checks, tests
762
- ```
763
-
764
- - Vanilla playground: `http://localhost:5173/playground/vanilla/index.html`. Add `?worker=1` to send through the transport worker.
765
- - Mock ingest server: `http://localhost:8787`. It accepts `/v1/logs`, `/v1/metrics` and `/v1/traces`. It prints one line for each record and for each metric point.
766
- - Cross-origin child frame: `http://localhost:5174`. The vanilla playground registers it and its same-origin child frame before they load.
767
- - The React example sends its counter, histogram and HTTP duration points to `/v1/metrics`.
768
- - After a build, run `node bin/uiobs.mjs doctor http://localhost:8787/v1/logs --origin http://localhost:5173` to test the command line tool on the mock server.
769
-
770
- After dependency changes, run these checks:
771
-
772
- ```bash
773
- pnpm run lint:fix
774
- pnpm run format
775
- pnpm run verify
776
- pnpm --filter './playground/**' --if-present run build
193
+ pnpm run dev # Playground, mock ingest server and iframe host
194
+ pnpm run verify # Format check, typecheck, build, lint, peer, size, dev-server and consumer checks, tests
777
195
  ```
778
196
 
779
- `verify` checks the library. The last command builds each consumer playground that has a build script.
780
- Check the vanilla frames, React and Angular in a browser before a release.
781
- To clear the React dependency cache, run `pnpm --filter @example/react run dev --force`.
782
-
783
- ### Example Applications
784
-
785
- Build the package first:
786
-
787
- ```bash
788
- pnpm run build
789
- pnpm run example:react # http://localhost:5180
790
- pnpm run example:angular # http://localhost:4200
791
- pnpm run example:microfrontend # Shell on http://localhost:5191, remotes on 5192 and 5193
792
- pnpm run example:console-only # http://localhost:5195
793
- ```
197
+ [Development](docs/development.md) gives the workspace rules, the release checks and the example applications.
794
198
 
795
199
  ---
796
200