@utk09/ui-observability 0.9.5 → 0.11.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 (259) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +315 -99
  3. package/bin/uiobs.mjs +8 -0
  4. package/dist/{batch-BQFtb3i5.cjs → batch-C8OcWR2L.cjs} +2 -2
  5. package/dist/{batch-BQFtb3i5.cjs.map → batch-C8OcWR2L.cjs.map} +1 -1
  6. package/dist/{batch-BUJh-1jZ.js → batch-CL9uWYY3.js} +5 -6
  7. package/dist/{batch-BUJh-1jZ.js.map → batch-CL9uWYY3.js.map} +1 -1
  8. package/dist/bus/bus.d.ts +15 -0
  9. package/dist/{bus-DeOPHWaD.js → bus-BZ0GldpT.js} +125 -112
  10. package/dist/bus-BZ0GldpT.js.map +1 -0
  11. package/dist/bus-VWlmM5xs.cjs +2 -0
  12. package/dist/bus-VWlmM5xs.cjs.map +1 -0
  13. package/dist/capture/interactions.d.ts +18 -0
  14. package/dist/capture/lifecycle.d.ts +20 -0
  15. package/dist/capture/reports.d.ts +17 -0
  16. package/dist/capture/resource-timing.d.ts +14 -0
  17. package/dist/capture/server-timing.d.ts +19 -0
  18. package/dist/capture/types.d.ts +13 -0
  19. package/dist/capture/unclean-exit.d.ts +31 -0
  20. package/dist/capture/user-timing.d.ts +22 -0
  21. package/dist/console-BPZCuSLc.cjs +2 -0
  22. package/dist/console-BPZCuSLc.cjs.map +1 -0
  23. package/dist/{console-DbAZYJuy.js → console-BeCF7n59.js} +20 -20
  24. package/dist/{console-DbAZYJuy.js.map → console-BeCF7n59.js.map} +1 -1
  25. package/dist/constants-DqKJH_MP.cjs +2 -0
  26. package/dist/constants-DqKJH_MP.cjs.map +1 -0
  27. package/dist/constants-zyrqveN4.js +304 -0
  28. package/dist/constants-zyrqveN4.js.map +1 -0
  29. package/dist/constants.d.ts +58 -2
  30. package/dist/context-storage-BjzeBSxH.cjs.map +1 -1
  31. package/dist/{context-storage-DxZf4Gfh.js → context-storage-BzkoHzkQ.js} +2 -3
  32. package/dist/{context-storage-DxZf4Gfh.js.map → context-storage-BzkoHzkQ.js.map} +1 -1
  33. package/dist/core/debug-buffer.d.ts +34 -0
  34. package/dist/core/debug-bundle.d.ts +12 -0
  35. package/dist/core/deferred.d.ts +7 -0
  36. package/dist/core/logger.d.ts +7 -2
  37. package/dist/core/measure.d.ts +19 -0
  38. package/dist/core/pipeline.d.ts +6 -1
  39. package/dist/core/record.d.ts +20 -1
  40. package/dist/core/remote-sampling.d.ts +5 -1
  41. package/dist/core/runtime.d.ts +45 -2
  42. package/dist/core/sampling.d.ts +5 -4
  43. package/dist/core/sender.d.ts +3 -1
  44. package/dist/core/spans.d.ts +5 -0
  45. package/dist/{deadline-5_PecIl5.js → deadline-BOjOxNHj.js} +3 -5
  46. package/dist/{deadline-5_PecIl5.js.map → deadline-BOjOxNHj.js.map} +1 -1
  47. package/dist/deadline-XSnm95pg.cjs.map +1 -1
  48. package/dist/debug-bundle-BzJNpbF0.cjs +2 -0
  49. package/dist/debug-bundle-BzJNpbF0.cjs.map +1 -0
  50. package/dist/debug-bundle-C7UkHZ-q.js +25 -0
  51. package/dist/debug-bundle-C7UkHZ-q.js.map +1 -0
  52. package/dist/doctor.cjs +2 -0
  53. package/dist/doctor.cjs.map +1 -0
  54. package/dist/doctor.d.ts +23 -0
  55. package/dist/doctor.js +98 -0
  56. package/dist/doctor.js.map +1 -0
  57. package/dist/{emergency-queue-Cs1hrjsC.cjs → emergency-queue-CNTRui5t.cjs} +2 -2
  58. package/dist/{emergency-queue-Cs1hrjsC.cjs.map → emergency-queue-CNTRui5t.cjs.map} +1 -1
  59. package/dist/{emergency-queue-BYUyDHGD.js → emergency-queue-Zy6lNafo.js} +17 -19
  60. package/dist/{emergency-queue-BYUyDHGD.js.map → emergency-queue-Zy6lNafo.js.map} +1 -1
  61. package/dist/{error-like-Ywo5uRHo.js → error-like-B11pB4aL.js} +2 -3
  62. package/dist/{error-like-Ywo5uRHo.js.map → error-like-B11pB4aL.js.map} +1 -1
  63. package/dist/error-like-gGRx2s36.cjs.map +1 -1
  64. package/dist/{errors-BhC7HTSt.js → errors-Dh7kef0i.js} +5 -6
  65. package/dist/{errors-BhC7HTSt.js.map → errors-Dh7kef0i.js.map} +1 -1
  66. package/dist/{errors-CgY633cG.cjs → errors-tfEr48bS.cjs} +2 -2
  67. package/dist/{errors-CgY633cG.cjs.map → errors-tfEr48bS.cjs.map} +1 -1
  68. package/dist/{factory-C5TujXlU.js → factory-BonqI3NL.js} +16 -20
  69. package/dist/{factory-C5TujXlU.js.map → factory-BonqI3NL.js.map} +1 -1
  70. package/dist/{factory-CNj4DH3n.cjs → factory-CJXVYp0R.cjs} +2 -2
  71. package/dist/{factory-CNj4DH3n.cjs.map → factory-CJXVYp0R.cjs.map} +1 -1
  72. package/dist/fixed-window-CvESpFYV.cjs.map +1 -1
  73. package/dist/{fixed-window-CtaFHanJ.js → fixed-window-Dq3MLUUv.js} +2 -3
  74. package/dist/{fixed-window-CtaFHanJ.js.map → fixed-window-Dq3MLUUv.js.map} +1 -1
  75. package/dist/global-scope-BN-Io_yv.cjs.map +1 -1
  76. package/dist/{global-scope-dp2jADRl.js → global-scope-D9I8s-oN.js} +2 -3
  77. package/dist/{global-scope-dp2jADRl.js.map → global-scope-D9I8s-oN.js.map} +1 -1
  78. package/dist/guards-Cidk71ME.js +7 -0
  79. package/dist/guards-Cidk71ME.js.map +1 -0
  80. package/dist/guards-nJ70syPt.cjs +2 -0
  81. package/dist/guards-nJ70syPt.cjs.map +1 -0
  82. package/dist/{identity-Da9TkuKd.cjs → identity-Cxgj6pZX.cjs} +2 -2
  83. package/dist/{identity-Da9TkuKd.cjs.map → identity-Cxgj6pZX.cjs.map} +1 -1
  84. package/dist/{identity-8vKkyAWm.js → identity-DT5VmvXy.js} +15 -16
  85. package/dist/{identity-8vKkyAWm.js.map → identity-DT5VmvXy.js.map} +1 -1
  86. package/dist/index.cjs +1 -1
  87. package/dist/index.cjs.map +1 -1
  88. package/dist/index.d.ts +27 -7
  89. package/dist/index.js +980 -604
  90. package/dist/index.js.map +1 -1
  91. package/dist/{indexeddb-storage-CCA1LvtO.js → indexeddb-storage-BJVtiQKm.js} +29 -30
  92. package/dist/{indexeddb-storage-CCA1LvtO.js.map → indexeddb-storage-BJVtiQKm.js.map} +1 -1
  93. package/dist/{indexeddb-storage-BTfIFRHF.cjs → indexeddb-storage-CIoW21Xd.cjs} +2 -2
  94. package/dist/{indexeddb-storage-BTfIFRHF.cjs.map → indexeddb-storage-CIoW21Xd.cjs.map} +1 -1
  95. package/dist/interactions-DTgKy_6K.js +119 -0
  96. package/dist/interactions-DTgKy_6K.js.map +1 -0
  97. package/dist/interactions-fEN6FbVo.cjs +2 -0
  98. package/dist/interactions-fEN6FbVo.cjs.map +1 -0
  99. package/dist/{journey-BUJ4WJxP.js → journey-CuJrHzEg.js} +18 -19
  100. package/dist/{journey-BUJ4WJxP.js.map → journey-CuJrHzEg.js.map} +1 -1
  101. package/dist/{journey-B_tTnvac.cjs → journey-pffMVMfa.cjs} +2 -2
  102. package/dist/{journey-B_tTnvac.cjs.map → journey-pffMVMfa.cjs.map} +1 -1
  103. package/dist/keys-BHhw_0Wh.cjs.map +1 -1
  104. package/dist/{keys-D5r_GH9q.js → keys-BU9j5YqW.js} +2 -3
  105. package/dist/{keys-D5r_GH9q.js.map → keys-BU9j5YqW.js.map} +1 -1
  106. package/dist/library-console-C1m6g1BR.js +13 -0
  107. package/dist/library-console-C1m6g1BR.js.map +1 -0
  108. package/dist/library-console-D2GY9Or6.cjs +2 -0
  109. package/dist/library-console-D2GY9Or6.cjs.map +1 -0
  110. package/dist/{library-request-BaZOi4eg.cjs → library-request-1BX_UlaX.cjs} +2 -2
  111. package/dist/{library-request-BaZOi4eg.cjs.map → library-request-1BX_UlaX.cjs.map} +1 -1
  112. package/dist/library-request-BQBT9N9Q.js +24 -0
  113. package/dist/{library-request-BKOcaKtQ.js.map → library-request-BQBT9N9Q.js.map} +1 -1
  114. package/dist/lifecycle-2EtUaRpo.cjs +2 -0
  115. package/dist/lifecycle-2EtUaRpo.cjs.map +1 -0
  116. package/dist/lifecycle-BaKx_-32.js +55 -0
  117. package/dist/lifecycle-BaKx_-32.js.map +1 -0
  118. package/dist/log-record-CAoGBBf3.js +16 -0
  119. package/dist/log-record-CAoGBBf3.js.map +1 -0
  120. package/dist/log-record-i9zOTkpQ.cjs +2 -0
  121. package/dist/log-record-i9zOTkpQ.cjs.map +1 -0
  122. package/dist/{long-frames-CF3qiSAX.cjs → long-frames-BVg4i5SC.cjs} +2 -2
  123. package/dist/{long-frames-CF3qiSAX.cjs.map → long-frames-BVg4i5SC.cjs.map} +1 -1
  124. package/dist/{long-frames-DI5ypfAF.js → long-frames-Czk7IupC.js} +4 -5
  125. package/dist/{long-frames-DI5ypfAF.js.map → long-frames-Czk7IupC.js.map} +1 -1
  126. package/dist/models/config.d.ts +168 -4
  127. package/dist/models/health.d.ts +25 -0
  128. package/dist/models/metric.d.ts +13 -0
  129. package/dist/models/storage.d.ts +5 -0
  130. package/dist/{network-DdzXDI3J.js → network-DBNwApoF.js} +117 -70
  131. package/dist/network-DBNwApoF.js.map +1 -0
  132. package/dist/network-xbbuvG_6.cjs +2 -0
  133. package/dist/network-xbbuvG_6.cjs.map +1 -0
  134. package/dist/openfin-Bxelt0yg.js +7 -0
  135. package/dist/{openfin-BwEN0uj4.js.map → openfin-Bxelt0yg.js.map} +1 -1
  136. package/dist/openfin-DtH2f7zX.cjs.map +1 -1
  137. package/dist/otlp-BDvFrLnc.cjs +2 -0
  138. package/dist/otlp-BDvFrLnc.cjs.map +1 -0
  139. package/dist/otlp-BTJdIa6F.js +81 -0
  140. package/dist/otlp-BTJdIa6F.js.map +1 -0
  141. package/dist/patch-BX8KrPCT.cjs.map +1 -1
  142. package/dist/{patch-CCWfuEY7.js → patch-UdPz1ea8.js} +2 -3
  143. package/dist/{patch-CCWfuEY7.js.map → patch-UdPz1ea8.js.map} +1 -1
  144. package/dist/{platform-DBSKTvFn.cjs → platform-C2Ez5kDc.cjs} +2 -2
  145. package/dist/{platform-DBSKTvFn.cjs.map → platform-C2Ez5kDc.cjs.map} +1 -1
  146. package/dist/{platform-Bw1btWCT.js → platform-DkcuXwe-.js} +5 -6
  147. package/dist/{platform-Bw1btWCT.js.map → platform-DkcuXwe-.js.map} +1 -1
  148. package/dist/remote-rules-Cfb4K-Nl.js +98 -0
  149. package/dist/remote-rules-Cfb4K-Nl.js.map +1 -0
  150. package/dist/remote-rules-vzvk7aKf.cjs +2 -0
  151. package/dist/remote-rules-vzvk7aKf.cjs.map +1 -0
  152. package/dist/reports-Dk2YhKIh.cjs +2 -0
  153. package/dist/reports-Dk2YhKIh.cjs.map +1 -0
  154. package/dist/reports-TA-zInnq.js +70 -0
  155. package/dist/reports-TA-zInnq.js.map +1 -0
  156. package/dist/resource-timing-BLv3EA2A.js +76 -0
  157. package/dist/resource-timing-BLv3EA2A.js.map +1 -0
  158. package/dist/resource-timing-Cysw1S1f.cjs +2 -0
  159. package/dist/resource-timing-Cysw1S1f.cjs.map +1 -0
  160. package/dist/sampling-C4VV-1MS.js +60 -0
  161. package/dist/sampling-C4VV-1MS.js.map +1 -0
  162. package/dist/sampling-Ckh2yW9k.cjs +2 -0
  163. package/dist/sampling-Ckh2yW9k.cjs.map +1 -0
  164. package/dist/sanitize-6ymPlVvP.js +112 -0
  165. package/dist/sanitize-6ymPlVvP.js.map +1 -0
  166. package/dist/sanitize-BAWzkZt0.cjs +2 -0
  167. package/dist/sanitize-BAWzkZt0.cjs.map +1 -0
  168. package/dist/select-ZF4by-lF.cjs +3 -0
  169. package/dist/select-ZF4by-lF.cjs.map +1 -0
  170. package/dist/select-xtQaenIi.js +270 -0
  171. package/dist/select-xtQaenIi.js.map +1 -0
  172. package/dist/{sender-DUUmSglb.js → sender-CiMHC9YG.js} +202 -509
  173. package/dist/sender-CiMHC9YG.js.map +1 -0
  174. package/dist/sender-D5wBoXA8.cjs +2 -0
  175. package/dist/sender-D5wBoXA8.cjs.map +1 -0
  176. package/dist/storage/persistence.d.ts +8 -0
  177. package/dist/storage-BA9RqRO-.cjs.map +1 -1
  178. package/dist/{storage-w7Tslvlq.js → storage-DZwed89z.js} +2 -3
  179. package/dist/storage-DZwed89z.js.map +1 -0
  180. package/dist/storm-CYi9Swpx.cjs +2 -0
  181. package/dist/{storm-CNZjsw4T.cjs.map → storm-CYi9Swpx.cjs.map} +1 -1
  182. package/dist/{storm-Daq2jGHU.js → storm-VR024_QN.js} +4 -5
  183. package/dist/{storm-Daq2jGHU.js.map → storm-VR024_QN.js.map} +1 -1
  184. package/dist/transport/headers.d.ts +8 -0
  185. package/dist/transport/http-transport.d.ts +2 -6
  186. package/dist/transport/serializers/otlp.d.ts +14 -0
  187. package/dist/transport/status-transport.d.ts +5 -2
  188. package/dist/transport/worker-client.d.ts +14 -0
  189. package/dist/transport/worker-entry.d.ts +5 -0
  190. package/dist/transport/worker-protocol.d.ts +36 -0
  191. package/dist/transport/worker-server.d.ts +3 -0
  192. package/dist/transport/worker-transport.d.ts +9 -0
  193. package/dist/{types-BR9t_w28.js → types-BAerHgCq.js} +2 -3
  194. package/dist/types-BAerHgCq.js.map +1 -0
  195. package/dist/types-C7WNpnG1.cjs.map +1 -1
  196. package/dist/unclean-exit-CwcUhFOn.js +62 -0
  197. package/dist/unclean-exit-CwcUhFOn.js.map +1 -0
  198. package/dist/unclean-exit-DFUN57wY.cjs +2 -0
  199. package/dist/unclean-exit-DFUN57wY.cjs.map +1 -0
  200. package/dist/user-timing-C9kfRq3J.cjs +2 -0
  201. package/dist/user-timing-C9kfRq3J.cjs.map +1 -0
  202. package/dist/user-timing-_jZIhDKI.js +63 -0
  203. package/dist/user-timing-_jZIhDKI.js.map +1 -0
  204. package/dist/{web-socket-BacvKOvD.cjs → web-socket-BWUoqBh8.cjs} +2 -2
  205. package/dist/{web-socket-BacvKOvD.cjs.map → web-socket-BWUoqBh8.cjs.map} +1 -1
  206. package/dist/{web-socket-CpsD8WAa.js → web-socket-CV7yIMnm.js} +7 -8
  207. package/dist/{web-socket-CpsD8WAa.js.map → web-socket-CV7yIMnm.js.map} +1 -1
  208. package/dist/{web-vitals-Bflr5jSA.js → web-vitals-Bq4WFHQo.js} +2 -3
  209. package/dist/{web-vitals-Bflr5jSA.js.map → web-vitals-Bq4WFHQo.js.map} +1 -1
  210. package/dist/web-vitals-DFuoTQbZ.cjs.map +1 -1
  211. package/dist/worker-protocol-Bai7GAIA.cjs +2 -0
  212. package/dist/worker-protocol-Bai7GAIA.cjs.map +1 -0
  213. package/dist/worker-protocol-CrsdSDLn.js +49 -0
  214. package/dist/worker-protocol-CrsdSDLn.js.map +1 -0
  215. package/dist/worker-server-BrIYkfoa.cjs +2 -0
  216. package/dist/worker-server-BrIYkfoa.cjs.map +1 -0
  217. package/dist/worker-server-Dp5HYm4b.js +83 -0
  218. package/dist/worker-server-Dp5HYm4b.js.map +1 -0
  219. package/dist/worker-transport-Bwej4N2e.cjs +2 -0
  220. package/dist/worker-transport-Bwej4N2e.cjs.map +1 -0
  221. package/dist/worker-transport-D6jtgpqN.js +199 -0
  222. package/dist/worker-transport-D6jtgpqN.js.map +1 -0
  223. package/package.json +31 -41
  224. package/dist/bus-BW6N-pY8.cjs +0 -2
  225. package/dist/bus-BW6N-pY8.cjs.map +0 -1
  226. package/dist/bus-DeOPHWaD.js.map +0 -1
  227. package/dist/console-Ce6heqZZ.cjs +0 -2
  228. package/dist/console-Ce6heqZZ.cjs.map +0 -1
  229. package/dist/constants-CN7GE1Lt.js +0 -246
  230. package/dist/constants-CN7GE1Lt.js.map +0 -1
  231. package/dist/constants-CW-MlHdY.cjs +0 -2
  232. package/dist/constants-CW-MlHdY.cjs.map +0 -1
  233. package/dist/interactions-BUDLxbv1.js +0 -74
  234. package/dist/interactions-BUDLxbv1.js.map +0 -1
  235. package/dist/interactions-NHbLKrqe.cjs +0 -2
  236. package/dist/interactions-NHbLKrqe.cjs.map +0 -1
  237. package/dist/library-request-BKOcaKtQ.js +0 -25
  238. package/dist/network-CF8UO5PK.cjs +0 -2
  239. package/dist/network-CF8UO5PK.cjs.map +0 -1
  240. package/dist/network-DdzXDI3J.js.map +0 -1
  241. package/dist/openfin-BwEN0uj4.js +0 -8
  242. package/dist/remote-rules-DIcC5vVC.js +0 -91
  243. package/dist/remote-rules-DIcC5vVC.js.map +0 -1
  244. package/dist/remote-rules-DpFmOef2.cjs +0 -2
  245. package/dist/remote-rules-DpFmOef2.cjs.map +0 -1
  246. package/dist/sampling-BVjspJWu.cjs +0 -2
  247. package/dist/sampling-BVjspJWu.cjs.map +0 -1
  248. package/dist/sampling-Cm3WhI0a.js +0 -76
  249. package/dist/sampling-Cm3WhI0a.js.map +0 -1
  250. package/dist/sanitize-C-ahCFsG.js +0 -123
  251. package/dist/sanitize-C-ahCFsG.js.map +0 -1
  252. package/dist/sanitize-DHucKGdi.cjs +0 -2
  253. package/dist/sanitize-DHucKGdi.cjs.map +0 -1
  254. package/dist/sender-D3fRCR8d.cjs +0 -3
  255. package/dist/sender-D3fRCR8d.cjs.map +0 -1
  256. package/dist/sender-DUUmSglb.js.map +0 -1
  257. package/dist/storage-w7Tslvlq.js.map +0 -1
  258. package/dist/storm-CNZjsw4T.cjs +0 -2
  259. package/dist/types-BR9t_w28.js.map +0 -1
package/README.md CHANGED
@@ -10,8 +10,17 @@ The library batches records and sends them over HTTP as OTLP/JSON. It stores a b
10
10
 
11
11
  ## Installation
12
12
 
13
+ Use one command for your package manager. Each command saves an exact version.
14
+
13
15
  ```bash
14
- npm install @utk09/ui-observability
16
+ # npm
17
+ npm install --save-exact @utk09/ui-observability
18
+
19
+ # pnpm
20
+ pnpm add --save-exact @utk09/ui-observability
21
+
22
+ # Yarn
23
+ yarn add --exact @utk09/ui-observability
15
24
  ```
16
25
 
17
26
  ### Peer Dependencies
@@ -164,10 +173,48 @@ configure({
164
173
  - Without `transportOnExit`, the last batch goes to the emergency queue when the page closes. The next page load sends it.
165
174
  - With `storage: "none"`, the next page load cannot keep that batch. Set `transportOnExit`, or the library loses the last batch.
166
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`.
167
178
  - After the delivery stack loads, you cannot add or remove `transport`. You can replace it with another function.
168
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.
169
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.
170
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
+
171
218
  ### Testing
172
219
 
173
220
  Use `createMemoryTransport()` to check what your code logs. It needs no network and no `fetch` mock.
@@ -242,7 +289,7 @@ X-UiObs-Sampling: {"v":1,"ttlMs":600000,"defaultRate":0.1,"rates":{"blotter.grid
242
289
  | Function | Description |
243
290
  | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
244
291
  | `configure(config)` | Starts the runtime singleton, or updates it. |
245
- | `shutdown()` | Sends pending records and stops every subsystem. Later calls do nothing until the next `configure()`. |
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()`. |
246
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). |
247
294
  | `setConfigurationLocked(locked)` | Locks or unlocks changes through `configure()`. |
248
295
 
@@ -264,11 +311,31 @@ X-UiObs-Sampling: {"v":1,"ttlMs":600000,"defaultRate":0.1,"rates":{"blotter.grid
264
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. |
265
312
  | `timeSync(label, fn, attrs?)` | Times a function and emits a duration histogram with `status` `SUCCESS` or `FAILURE`. |
266
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). |
267
315
 
268
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`.
269
317
 
270
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.
271
319
 
320
+ ### Measures
321
+
322
+ `startMeasure()` times an operation with named phases.
323
+
324
+ ```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
+ ```
332
+
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
+
272
339
  ### Context & Correlation
273
340
 
274
341
  | Function | Description |
@@ -290,16 +357,19 @@ The level methods give records with `log.type: "log"`. Records of the library it
290
357
 
291
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.
292
359
 
360
+ `serveTransportWorker({ onDiagnostic? })` starts the dedicated transport worker service. It returns a function that stops the service.
361
+
293
362
  ### Delivery & Diagnostics
294
363
 
295
- | Function | Description |
296
- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
297
- | `flush()` | Sends the records held in the pipeline or the forward buffer, and waits for the batches in flight. |
298
- | `getQueueDepth()` | Returns the number of batches in storage. |
299
- | `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. |
300
- | `getDiagnosticCounters()` | Returns the count of each diagnostic code. |
301
- | `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. |
302
- | `clearPersistedLogs(scope?)` | Removes the stored records of the active context. With `"namespace"`, it removes the stored records of each context in the persistence namespace. |
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. |
303
373
 
304
374
  ---
305
375
 
@@ -307,74 +377,124 @@ See [runtime policies, operational budgets and migration](docs/runtime-policies.
307
377
 
308
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.
309
379
 
310
- | Key | Default | Description |
311
- | ------------------------------------------------------------------------------------------------------ | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
312
- | `endpoint` | `""` | HTTP endpoint that receives the batches. `null` selects console-only mode. `""` reports `config.invalid`. |
313
- | `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`. |
314
- | `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). |
315
- | `serviceName` | `""` | `service.name` on every record. |
316
- | `serviceVersion` | `""` | `service.version` on every record. |
317
- | `environment` | `""` | `deployment.environment` on every record. |
318
- | `enabled` | `true` | Set `false` to stop all logging. Every log call then does nothing. |
319
- | `minLevel` | `"INFO"` | Lowest level that the library sends (`TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `FATAL`). It does not drop actions and metrics. |
320
- | `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. |
321
- | `compression` | `"gzip"` | `gzip` or `none`. The library compresses a payload above 1 KB only. |
322
- | `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`. |
323
- | `credentials` | `"omit"` | Fetch credentials mode. Set `"include"` for cookie auth. |
324
- | `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. |
325
- | `storage` | `"auto"` | Store for undelivered batches: `auto`, `indexeddb`, `localstorage`, `memory` or `none`. Fixed at startup. |
326
- | `identity` | `"storage"` | Store for session, tab and journey ids. `memory` writes no key. Fixed at startup. |
327
- | `sampling.defaultRate` | `1` | Keep rate for a namespace with no rule. |
328
- | `sampling.rates` | `{}` | Keep rate per namespace. The longest matching prefix wins. |
329
- | `sampling.alwaysSampleTypes` | `["action"]` | Record types that ignore the rate. |
330
- | `sampling.remote` | `false` | Reads sampling rules from the `X-UiObs-Sampling` header of each accepted batch (see Remote Sampling). |
331
- | `sampling.remoteMaxRate` | `1` | Highest rate that a remote rule can set. It applies to the remote `defaultRate` and to each remote namespace rate. |
332
- | `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. |
333
- | `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. |
334
- | `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`. |
335
- | `bus.validation` | `"strict"` | `strict` checks the fields of each bus message. `envelope` checks the envelope only. |
336
- | `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. |
337
- | `bus.openFinRole` | `"auto"` | `auto`, `provider` or `client`. |
338
- | `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. |
339
- | `journey.maxAgeMs` | `1800000` | Maximum open time of a journey, in milliseconds. Then the library ends it. The range is 60000 to 86400000. |
340
- | `batching.logFlushIntervalMs` | `2000` | Maximum wait of a partial log batch, in milliseconds. The range is 100 to 60000. |
341
- | `batching.logBatchSize` | `100` | Maximum records in one log batch. The range is 1 to 1000. |
342
- | `batching.metricFlushIntervalMs` | `10000` | Maximum wait of a partial metric batch, in milliseconds. The range is 100 to 60000. |
343
- | `batching.metricBatchSize` | `500` | Maximum records in one metric batch. The range is 1 to 1000. |
344
- | `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. |
345
- | `retention.maxBatches` | `500` | Maximum stored batches. A new batch evicts the oldest batch without an action first. The range is 1 to 5000. |
346
- | `retention.maxAgeMs` | `86400000` | Maximum age of a stored batch, in milliseconds. The range is 60000 to 604800000. |
347
- | `retention.maxAttempts` | `5` | Maximum send attempts of a stored batch. The range is 1 to 20. |
348
- | `limits.maxBodyChars` | `4096` | Maximum body length, in characters. The range is 256 to 65536. |
349
- | `limits.maxAttributeChars` | `8192` | Maximum length of a string attribute, in characters. The range is 256 to 65536. |
350
- | `limits.maxAttributeCount` | `128` | Maximum keys in one object. The range is 1 to 1024. |
351
- | `limits.maxStackChars` | `8192` | Maximum length of an error stack, in characters. The range is 256 to 65536. |
352
- | `limits.maxDepth` | `6` | Maximum depth of a nested value. The range is 1 to 16. |
353
- | `limits.maxArrayLength` | `100` | Maximum items in one array, set or map. The range is 1 to 10000. |
354
- | `limits.maxNodes` | `10000` | Maximum values in one sanitize pass. The range is 100 to 100000. |
355
- | `limits.maxRecordBytes` | `32768` | Maximum attribute bytes of one record. Above it, the library drops the caller attributes. The range is 1024 to 60000. |
356
- | `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. |
357
- | `securityContext.isolation` | `true` | Keeps the stored batches of each identity apart. Delivery changes then need `rotateSecurityContext()`. |
358
- | `lockConfiguration` | `false` | Refuses changes through `configure()`. Identical repeated settings are accepted. `setConfigurationLocked(false)` unlocks. |
359
- | `loggerCache.maxEntries` | `256` | LRU limit of cached loggers. `0` turns the cache off. `null` sets no limit. |
360
- | `delivery` | See policies | Request timeout, request concurrency, retry delays and batches in one retry pass. |
361
- | `buffering` | 10,000 records, 16 MiB, `"drop-oldest"` | Limits of the live buffers, and the overflow rule. |
362
- | `metrics` | See policies | Limits of instrument names, attribute sets and histogram boundaries. |
363
- | `correlation` | See policies | Session idle time, session write interval and trace age. Fixed at startup. |
364
- | `capturePolicy` | See policies | Breadcrumb capacity, error duplicate check, capture rate limits and the error ceiling. |
365
- | `diagnostics` | `{ throttleMs: 1000, consoleFallback: false }` | Report interval of each diagnostic code, and the console fallback when `onDiagnostic` throws. |
366
- | `persistence.namespace` | `""` | Separates the batch stores, the emergency queue and the retry locks of one application. Fixed at startup. |
367
- | `metadata` | All `true` | `pageUrl`, `userAgent` and `openfin` include `page.url`, `browser.user_agent` and the OpenFin fields. |
368
- | `capture` | See below | Auto-capture settings. |
369
- | `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`. |
370
- | `transport(request)` | `undefined` | Sends batches through a channel of your app in place of HTTP (see Custom Transport). |
371
- | `transportOnExit(request)` | `undefined` | Sends the last batch while the page closes. It must return a boolean and must not wait. |
372
- | `otelLoader()` | `undefined` | Loads `@opentelemetry/api`. Without it, OTel is off. |
373
- | `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. |
374
- | `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. |
375
- | `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. |
376
- | `onDiagnostic(event)` | `undefined` | Receives the faults of the library itself. |
377
- | `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. |
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
464
+
465
+ ```ts
466
+ configure({ payloadMode: "defer" });
467
+ const payload = { status: "before" };
468
+ getLogger("orders").info("Order state", payload);
469
+ payload.status = "after";
470
+ ```
471
+
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
+ ```ts
485
+ configure({
486
+ sampling: { remote: true },
487
+ capture: { remoteToggles: ["fetch", "resourceTiming", "lifecycle"] },
488
+ });
489
+ ```
490
+
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.
378
498
 
379
499
  ### Auto-Capture Options
380
500
 
@@ -387,7 +507,8 @@ capture: {
387
507
  xhr: false, // XMLHttpRequest duration and status codes
388
508
  httpMetrics: true, // http.client.request.duration histogram of fetch and xhr requests, in seconds.
389
509
  // Attributes: http.request.method, http.response.status_code, server.address, error.type
390
- interactions: false, // Click action names. The object form sets actionAttribute, text and selector
510
+ interactions: false, // Click action names. The object form sets actionAttribute, text, selector,
511
+ // rageClicks and deadClicks
391
512
  navigation: false, // Single-page navigation URL changes
392
513
  webVitals: false, // Core Web Vitals (LCP, CLS, INP, FCP, TTFB)
393
514
  longFrames: false, // Frames that freeze the page, as ui.long_frame.duration
@@ -398,10 +519,44 @@ capture: {
398
519
  ignoreUrls: [], // URL patterns excluded from network capture
399
520
  propagateTraceHeaderTo: [], // Origins, or RegExp patterns, that receive traceparent
400
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
401
530
  plugins: [], // Capture plugins of your app
402
531
  }
403
532
  ```
404
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
+
405
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.
406
561
 
407
562
  - The library observes `long-animation-frame`. A browser without it gives `longtask` entries, with no script attributes.
@@ -471,6 +626,7 @@ With `tracesEndpoint`, the library sends spans. The backend then has a root span
471
626
 
472
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`.
473
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.
474
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.
475
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.
476
632
  - **OpenTelemetry:** With `otelLoader`, a trace from the OpenTelemetry API keeps its own spans. The library sends no span for it.
@@ -479,14 +635,15 @@ With `tracesEndpoint`, the library sends spans. The backend then has a root span
479
635
 
480
636
  ### Browser Storage Keys
481
637
 
482
- | Key | Store | Written when | Option that stops it |
483
- | ------------------------------ | ---------------- | ---------------------------------------------------------------- | ------------------------------------------------- |
484
- | `ui-observability.session` | `localStorage` | At startup, then at most one time each minute while logging | `identity: "memory"` |
485
- | `ui-observability.tab` | `sessionStorage` | At startup, and when the bus finds a duplicated tab | `identity: "memory"` |
486
- | `ui-observability.journey` | `sessionStorage` | When a journey starts or ends | `identity: "memory"` |
487
- | `ui-observability.batch.*` | `localStorage` | When a send fails and the `localstorage` adapter holds the batch | `storage` other than `auto` or `localstorage` |
488
- | `ui-observability.emergency.*` | `localStorage` | When the exit flush cannot send a batch | `endpoint: null`, `storage: "memory"` or `"none"` |
489
- | `ui-observability.probe` | `localStorage` | One write and one remove, when the library tests `localStorage` | `storage` other than `auto` or `localstorage` |
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` |
490
647
 
491
648
  IndexedDB holds undelivered batches with `storage: "auto"` or `"indexeddb"`, in the database `UiObservability`.
492
649
 
@@ -498,8 +655,9 @@ With `persistence.namespace`, the batch keys start with `ui-observability:namesp
498
655
 
499
656
  - [Attribute reference](docs/attributes.md): each attribute that the library writes, and its type.
500
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.
501
659
  - [Threat model](docs/threat-model.md): the trust boundaries, the threats and the controls.
502
- - [Runtime policies and migration](docs/runtime-policies.md): the defaults, the overrides, security-context rotation, registered bus sources, health and the upgrade steps for 0.9.5.
660
+ - [Runtime policies and migration](docs/runtime-policies.md): the defaults, the overrides, security-context rotation, registered bus sources, health and the upgrade steps.
503
661
 
504
662
  ---
505
663
 
@@ -510,7 +668,7 @@ With `persistence.namespace`, the batch keys start with `ui-observability:namesp
510
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.
511
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.
512
670
  - **Five correlation ids:** Each record carries `session.id`, `tab.id`, `context.id`, `journey.id` and `trace_id`.
513
- - **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. 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.
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.
514
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.
515
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.
516
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.
@@ -520,7 +678,7 @@ With `persistence.namespace`, the batch keys start with `ui-observability:namesp
520
678
  - A change to `batching` or `retention` after the delivery stack loads. The stack reads them one time.
521
679
  - A change to `limits` or `journey.maxAgeMs` after the first `configure()`. The record builder and the journey engine read them one time.
522
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.
523
- - **Deterministic sampling:** FNV-1a hashing applies one keep rate to a whole journey. An error and an explicit action are always kept.
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"`.
524
682
 
525
683
  ---
526
684
 
@@ -546,34 +704,92 @@ The ingest server must meet these requirements:
546
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`.
547
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`.
548
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`.
549
708
 
550
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`.
551
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.
736
+
552
737
  ---
553
738
 
554
739
  ## Development
555
740
 
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`.
757
+
556
758
  ```bash
557
- npm install
558
- npm run dev # Playground, mock ingest server and iframe host
559
- npm run verify # Format check, typecheck, build, lint, peer, size and dev-server checks, tests
759
+ 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
560
762
  ```
561
763
 
562
- - Vanilla playground: `http://localhost:5173/playground/vanilla/index.html`
764
+ - Vanilla playground: `http://localhost:5173/playground/vanilla/index.html`. Add `?worker=1` to send through the transport worker.
563
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.
564
766
  - Cross-origin child frame: `http://localhost:5174`. The vanilla playground registers it and its same-origin child frame before they load.
565
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
777
+ ```
778
+
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`.
566
782
 
567
783
  ### Example Applications
568
784
 
569
785
  Build the package first:
570
786
 
571
787
  ```bash
572
- npm run build
573
- npm run example:react # http://localhost:5180
574
- npm run example:angular # http://localhost:4200
575
- npm run example:microfrontend # Shell on http://localhost:5191, remotes on 5192 and 5193
576
- npm run example:console-only # http://localhost:5195
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
577
793
  ```
578
794
 
579
795
  ---