@utk09/ui-observability 0.12.0 → 1.1.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 (523) hide show
  1. package/CHANGELOG.md +280 -10
  2. package/README.md +70 -839
  3. package/dist/{batch-BjQUwjA6.js → batch-D3NHhF9L.js} +4 -4
  4. package/dist/{batch-BjQUwjA6.js.map → batch-D3NHhF9L.js.map} +1 -1
  5. package/dist/{batch-D5LlU4Q9.cjs → batch-DnYRJqhU.cjs} +2 -2
  6. package/dist/{batch-D5LlU4Q9.cjs.map → batch-DnYRJqhU.cjs.map} +1 -1
  7. package/dist/bus/bus.d.cts +355 -0
  8. package/dist/bus/bus.d.ts +86 -12
  9. package/dist/bus/links.d.cts +132 -0
  10. package/dist/bus/links.d.ts +18 -3
  11. package/dist/bus/validation.d.cts +16 -0
  12. package/dist/bus/validation.d.ts +10 -1
  13. package/dist/bus-B__467mL.cjs +2 -0
  14. package/dist/bus-B__467mL.cjs.map +1 -0
  15. package/dist/bus-dw7T92sO.js +788 -0
  16. package/dist/bus-dw7T92sO.js.map +1 -0
  17. package/dist/capture/console.d.cts +37 -0
  18. package/dist/capture/console.d.ts +1 -1
  19. package/dist/capture/errors.d.cts +32 -0
  20. package/dist/capture/errors.d.ts +1 -1
  21. package/dist/capture/interactions.d.cts +80 -0
  22. package/dist/capture/interactions.d.ts +36 -4
  23. package/dist/capture/lifecycle.d.cts +20 -0
  24. package/dist/capture/lifecycle.d.ts +1 -1
  25. package/dist/capture/long-frames.d.cts +31 -0
  26. package/dist/capture/long-frames.d.ts +1 -1
  27. package/dist/capture/network.d.cts +57 -0
  28. package/dist/capture/network.d.ts +1 -1
  29. package/dist/capture/observed-windows.d.cts +51 -0
  30. package/dist/capture/observed-windows.d.ts +51 -0
  31. package/dist/capture/profiler-frames.d.cts +44 -0
  32. package/dist/capture/profiler-frames.d.ts +1 -1
  33. package/dist/capture/replay-buffer.d.cts +45 -0
  34. package/dist/capture/replay-buffer.d.ts +9 -10
  35. package/dist/capture/replay-upload.d.cts +79 -0
  36. package/dist/capture/replay-upload.d.ts +7 -2
  37. package/dist/capture/replay.d.cts +114 -0
  38. package/dist/capture/replay.d.ts +1 -1
  39. package/dist/capture/reports.d.cts +17 -0
  40. package/dist/capture/reports.d.ts +1 -1
  41. package/dist/capture/resource-timing.d.cts +14 -0
  42. package/dist/capture/resource-timing.d.ts +1 -1
  43. package/dist/capture/server-timing.d.cts +19 -0
  44. package/dist/capture/storm.d.cts +13 -0
  45. package/dist/capture/storm.d.ts +5 -5
  46. package/dist/capture/types.d.cts +128 -0
  47. package/dist/capture/types.d.ts +10 -9
  48. package/dist/capture/unclean-exit.d.cts +31 -0
  49. package/dist/capture/unclean-exit.d.ts +1 -1
  50. package/dist/capture/user-timing.d.cts +22 -0
  51. package/dist/capture/user-timing.d.ts +2 -2
  52. package/dist/capture/web-socket.d.cts +40 -0
  53. package/dist/capture/web-socket.d.ts +3 -3
  54. package/dist/capture/web-vitals.d.cts +40 -0
  55. package/dist/capture/web-vitals.d.ts +1 -1
  56. package/dist/{compression-lD9abCcO.cjs → compression-C0hUHKR-.cjs} +2 -2
  57. package/dist/{compression-lD9abCcO.cjs.map → compression-C0hUHKR-.cjs.map} +1 -1
  58. package/dist/{compression-AJJCMBOa.js → compression-SHPAvS4U.js} +2 -2
  59. package/dist/{compression-AJJCMBOa.js.map → compression-SHPAvS4U.js.map} +1 -1
  60. package/dist/config-CSNcS7OZ.js +558 -0
  61. package/dist/config-CSNcS7OZ.js.map +1 -0
  62. package/dist/config-CybPP5VM.cjs +2 -0
  63. package/dist/config-CybPP5VM.cjs.map +1 -0
  64. package/dist/console-BsM-fSCQ.js +81 -0
  65. package/dist/console-BsM-fSCQ.js.map +1 -0
  66. package/dist/console-Dkxs6IVQ.cjs +2 -0
  67. package/dist/console-Dkxs6IVQ.cjs.map +1 -0
  68. package/dist/constants-BwJDXzj6.js +357 -0
  69. package/dist/constants-BwJDXzj6.js.map +1 -0
  70. package/dist/constants-CtF52hIV.cjs +2 -0
  71. package/dist/constants-CtF52hIV.cjs.map +1 -0
  72. package/dist/constants.d.cts +763 -0
  73. package/dist/constants.d.ts +100 -20
  74. package/dist/core/breadcrumbs.d.cts +54 -0
  75. package/dist/core/breadcrumbs.d.ts +5 -0
  76. package/dist/core/config.d.cts +45 -0
  77. package/dist/core/config.d.ts +30 -2
  78. package/dist/core/context.d.cts +24 -0
  79. package/dist/core/context.d.ts +3 -8
  80. package/dist/core/debug-buffer.d.cts +34 -0
  81. package/dist/core/debug-buffer.d.ts +3 -3
  82. package/dist/core/debug-bundle.d.cts +12 -0
  83. package/dist/core/debug-bundle.d.ts +3 -3
  84. package/dist/core/deferred.d.cts +7 -0
  85. package/dist/core/deferred.d.ts +2 -2
  86. package/dist/core/diagnostics.d.cts +86 -0
  87. package/dist/core/diagnostics.d.ts +1 -1
  88. package/dist/core/drops.d.cts +39 -0
  89. package/dist/core/drops.d.ts +16 -6
  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 +7 -7
  94. package/dist/core/logger.d.cts +141 -0
  95. package/dist/core/logger.d.ts +23 -30
  96. package/dist/core/measure.d.cts +30 -0
  97. package/dist/core/measure.d.ts +14 -3
  98. package/dist/core/meter.d.cts +78 -0
  99. package/dist/core/meter.d.ts +14 -8
  100. package/dist/core/pipeline.d.cts +227 -0
  101. package/dist/core/pipeline.d.ts +73 -10
  102. package/dist/core/profile-buckets.d.cts +31 -0
  103. package/dist/core/profiler.d.cts +218 -0
  104. package/dist/core/profiler.d.ts +2 -2
  105. package/dist/core/record.d.cts +190 -0
  106. package/dist/core/record.d.ts +44 -12
  107. package/dist/core/remote-rules.d.cts +17 -0
  108. package/dist/core/remote-rules.d.ts +3 -3
  109. package/dist/core/remote-sampling.d.cts +74 -0
  110. package/dist/core/remote-sampling.d.ts +3 -3
  111. package/dist/core/rotation.d.cts +99 -0
  112. package/dist/core/rotation.d.ts +99 -0
  113. package/dist/core/runtime.d.cts +774 -0
  114. package/dist/core/runtime.d.ts +254 -70
  115. package/dist/core/sampling.d.cts +86 -0
  116. package/dist/core/sampling.d.ts +5 -5
  117. package/dist/core/sender.d.cts +161 -0
  118. package/dist/core/sender.d.ts +59 -15
  119. package/dist/core/spans.d.cts +39 -0
  120. package/dist/core/spans.d.ts +1 -1
  121. package/dist/debug-bundle-B2v6Cym-.cjs +2 -0
  122. package/dist/debug-bundle-B2v6Cym-.cjs.map +1 -0
  123. package/dist/debug-bundle-Cs_YWzTa.js +35 -0
  124. package/dist/debug-bundle-Cs_YWzTa.js.map +1 -0
  125. package/dist/defineProperty-X1c4tIPD.cjs +1 -0
  126. package/dist/defineProperty-s2S8BXUc.js +35 -0
  127. package/dist/doctor.cjs +1 -1
  128. package/dist/doctor.cjs.map +1 -1
  129. package/dist/doctor.d.cts +36 -0
  130. package/dist/doctor.d.ts +5 -2
  131. package/dist/doctor.js +119 -87
  132. package/dist/doctor.js.map +1 -1
  133. package/dist/errors-DP2RUm4V.cjs +3 -0
  134. package/dist/errors-DP2RUm4V.cjs.map +1 -0
  135. package/dist/errors-Q3Ng1ciC.js +86 -0
  136. package/dist/errors-Q3Ng1ciC.js.map +1 -0
  137. package/dist/factory-DV17sm2p.js +404 -0
  138. package/dist/factory-DV17sm2p.js.map +1 -0
  139. package/dist/factory-K8O6gpux.cjs +2 -0
  140. package/dist/factory-K8O6gpux.cjs.map +1 -0
  141. package/dist/guards-BlYGRK4l.js +10 -0
  142. package/dist/guards-BlYGRK4l.js.map +1 -0
  143. package/dist/guards-EjG3ahFp.cjs +2 -0
  144. package/dist/guards-EjG3ahFp.cjs.map +1 -0
  145. package/dist/{identity-BrQp_5J5.js → identity-BgtHyY4u.js} +33 -26
  146. package/dist/identity-BgtHyY4u.js.map +1 -0
  147. package/dist/identity-CvuyqZk7.cjs +2 -0
  148. package/dist/identity-CvuyqZk7.cjs.map +1 -0
  149. package/dist/index.cjs +1 -1
  150. package/dist/index.cjs.map +1 -1
  151. package/dist/index.d.cts +301 -0
  152. package/dist/index.d.ts +90 -98
  153. package/dist/index.js +1253 -1555
  154. package/dist/index.js.map +1 -1
  155. package/dist/indexeddb-storage-D4KVcqdD.cjs +2 -0
  156. package/dist/indexeddb-storage-D4KVcqdD.cjs.map +1 -0
  157. package/dist/{indexeddb-storage-DLXQzAGh.js → indexeddb-storage-e-13ZLWm.js} +61 -57
  158. package/dist/indexeddb-storage-e-13ZLWm.js.map +1 -0
  159. package/dist/interactions-Byxf1C82.js +207 -0
  160. package/dist/interactions-Byxf1C82.js.map +1 -0
  161. package/dist/interactions-OK85T-Dk.cjs +2 -0
  162. package/dist/interactions-OK85T-Dk.cjs.map +1 -0
  163. package/dist/{journey-35yCMNFo.js → journey-C93FTYcs.js} +46 -49
  164. package/dist/journey-C93FTYcs.js.map +1 -0
  165. package/dist/journey-nMbob3OB.cjs +2 -0
  166. package/dist/journey-nMbob3OB.cjs.map +1 -0
  167. package/dist/{library-console-BFWEuQsl.cjs → library-console-DJUQzcgM.cjs} +2 -2
  168. package/dist/{library-console-BFWEuQsl.cjs.map → library-console-DJUQzcgM.cjs.map} +1 -1
  169. package/dist/{library-console-Dl_Ly6DQ.js → library-console-DklSmucS.js} +2 -2
  170. package/dist/{library-console-Dl_Ly6DQ.js.map → library-console-DklSmucS.js.map} +1 -1
  171. package/dist/{library-request-nI6pvI6I.js → library-request-UGEwOHpf.js} +2 -2
  172. package/dist/{library-request-nI6pvI6I.js.map → library-request-UGEwOHpf.js.map} +1 -1
  173. package/dist/{library-request-Da-CHKzT.cjs → library-request-kY9iTpIF.cjs} +2 -2
  174. package/dist/{library-request-Da-CHKzT.cjs.map → library-request-kY9iTpIF.cjs.map} +1 -1
  175. package/dist/{lifecycle-CZ6RRXc6.js → lifecycle-B2PlIuQu.js} +21 -29
  176. package/dist/lifecycle-B2PlIuQu.js.map +1 -0
  177. package/dist/lifecycle-DaMdH_X7.cjs +2 -0
  178. package/dist/lifecycle-DaMdH_X7.cjs.map +1 -0
  179. package/dist/log-record-Bmx6etMh.cjs +2 -0
  180. package/dist/log-record-Bmx6etMh.cjs.map +1 -0
  181. package/dist/{log-record-DIA6McNr.js → log-record-DSt2P-Sr.js} +8 -7
  182. package/dist/log-record-DSt2P-Sr.js.map +1 -0
  183. package/dist/{long-frames-430_85Da.js → long-frames-Bamjs1WV.js} +18 -22
  184. package/dist/long-frames-Bamjs1WV.js.map +1 -0
  185. package/dist/long-frames-lhtONgGt.cjs +2 -0
  186. package/dist/long-frames-lhtONgGt.cjs.map +1 -0
  187. package/dist/models/batch.d.cts +57 -0
  188. package/dist/models/batch.d.ts +2 -2
  189. package/dist/models/bus.d.cts +163 -0
  190. package/dist/models/bus.d.ts +28 -3
  191. package/dist/models/config.d.cts +1555 -0
  192. package/dist/models/config.d.ts +377 -261
  193. package/dist/models/drop.d.cts +54 -0
  194. package/dist/models/drop.d.ts +16 -3
  195. package/dist/models/health.d.cts +148 -0
  196. package/dist/models/health.d.ts +108 -12
  197. package/dist/models/log-record.d.cts +61 -0
  198. package/dist/models/metric.d.cts +139 -0
  199. package/dist/models/metric.d.ts +13 -2
  200. package/dist/models/plugin.d.cts +47 -0
  201. package/dist/models/plugin.d.ts +3 -3
  202. package/dist/models/replay.d.cts +60 -0
  203. package/dist/models/serializer.d.cts +25 -0
  204. package/dist/models/serializer.d.ts +4 -2
  205. package/dist/models/storage.d.cts +95 -0
  206. package/dist/models/storage.d.ts +7 -5
  207. package/dist/network-BCn8Gn47.cjs +2 -0
  208. package/dist/network-BCn8Gn47.cjs.map +1 -0
  209. package/dist/{network-C7SkLf4v.js → network-Cg1L2w2r.js} +57 -57
  210. package/dist/network-Cg1L2w2r.js.map +1 -0
  211. package/dist/observed-windows-B3gJkdql.cjs +2 -0
  212. package/dist/observed-windows-B3gJkdql.cjs.map +1 -0
  213. package/dist/observed-windows-BrwaJNlj.js +64 -0
  214. package/dist/observed-windows-BrwaJNlj.js.map +1 -0
  215. package/dist/{otlp-2MCrC3kd.cjs → otlp-CrAWkQdO.cjs} +2 -2
  216. package/dist/{otlp-2MCrC3kd.cjs.map → otlp-CrAWkQdO.cjs.map} +1 -1
  217. package/dist/{otlp-COq033e3.js → otlp-D6dRZyB8.js} +9 -9
  218. package/dist/{otlp-COq033e3.js.map → otlp-D6dRZyB8.js.map} +1 -1
  219. package/dist/{platform-CVewe4wQ.js → platform-8DLhjddo.js} +9 -9
  220. package/dist/{platform-CVewe4wQ.js.map → platform-8DLhjddo.js.map} +1 -1
  221. package/dist/{platform-12uR7kBQ.cjs → platform-BqRc-7RO.cjs} +2 -2
  222. package/dist/{platform-12uR7kBQ.cjs.map → platform-BqRc-7RO.cjs.map} +1 -1
  223. package/dist/{profiler-BVWIOgnq.js → profiler-BaXSqCfz.js} +78 -96
  224. package/dist/profiler-BaXSqCfz.js.map +1 -0
  225. package/dist/profiler-BvWW2kNM.cjs +2 -0
  226. package/dist/profiler-BvWW2kNM.cjs.map +1 -0
  227. package/dist/{profiler-frames-CLXlT_xL.js → profiler-frames-C4ySHN0X.js} +21 -29
  228. package/dist/profiler-frames-C4ySHN0X.js.map +1 -0
  229. package/dist/profiler-frames-DeaBiB-5.cjs +2 -0
  230. package/dist/profiler-frames-DeaBiB-5.cjs.map +1 -0
  231. package/dist/remote-rules-D7L6D_D2.cjs +2 -0
  232. package/dist/remote-rules-D7L6D_D2.cjs.map +1 -0
  233. package/dist/remote-rules-Dq9xe7Qn.js +95 -0
  234. package/dist/remote-rules-Dq9xe7Qn.js.map +1 -0
  235. package/dist/replay-B0M8kWz_.js +310 -0
  236. package/dist/replay-B0M8kWz_.js.map +1 -0
  237. package/dist/replay-QOFBpAXh.cjs +2 -0
  238. package/dist/replay-QOFBpAXh.cjs.map +1 -0
  239. package/dist/{reports-BuXekPOS.js → reports--8APRLa-.js} +25 -30
  240. package/dist/reports--8APRLa-.js.map +1 -0
  241. package/dist/reports-ojuMKGO7.cjs +2 -0
  242. package/dist/reports-ojuMKGO7.cjs.map +1 -0
  243. package/dist/{resource-timing-CXGHwFRD.js → resource-timing-BzR05rE-.js} +20 -23
  244. package/dist/resource-timing-BzR05rE-.js.map +1 -0
  245. package/dist/resource-timing-pAG3ZhB5.cjs +2 -0
  246. package/dist/resource-timing-pAG3ZhB5.cjs.map +1 -0
  247. package/dist/response-body-BWvwKQ2p.js +331 -0
  248. package/dist/response-body-BWvwKQ2p.js.map +1 -0
  249. package/dist/response-body-CKEJ5itk.cjs +3 -0
  250. package/dist/response-body-CKEJ5itk.cjs.map +1 -0
  251. package/dist/rotation-BylN1B9e.js +93 -0
  252. package/dist/rotation-BylN1B9e.js.map +1 -0
  253. package/dist/rotation-E2eKClIs.cjs +2 -0
  254. package/dist/rotation-E2eKClIs.cjs.map +1 -0
  255. package/dist/sampling-B46LW0cy.cjs +2 -0
  256. package/dist/sampling-B46LW0cy.cjs.map +1 -0
  257. package/dist/sampling-zXA6r-Nw.js +63 -0
  258. package/dist/sampling-zXA6r-Nw.js.map +1 -0
  259. package/dist/{sanitize-CNmsD9r3.js → sanitize-DjnR6RXR.js} +2 -2
  260. package/dist/sanitize-DjnR6RXR.js.map +1 -0
  261. package/dist/{sanitize-ChLn97Ch.cjs → sanitize-Qj6LuZqp.cjs} +2 -2
  262. package/dist/sanitize-Qj6LuZqp.cjs.map +1 -0
  263. package/dist/sender-Bdp-TAS4.js +979 -0
  264. package/dist/sender-Bdp-TAS4.js.map +1 -0
  265. package/dist/sender-DR7ZycZY.cjs +2 -0
  266. package/dist/sender-DR7ZycZY.cjs.map +1 -0
  267. package/dist/storage/context-storage.d.cts +90 -0
  268. package/dist/storage/context-storage.d.ts +5 -5
  269. package/dist/storage/emergency-queue.d.cts +27 -0
  270. package/dist/storage/emergency-queue.d.ts +4 -4
  271. package/dist/storage/eviction.d.cts +40 -0
  272. package/dist/storage/eviction.d.ts +1 -1
  273. package/dist/storage/factory.d.cts +21 -0
  274. package/dist/storage/factory.d.ts +3 -3
  275. package/dist/storage/gap.d.cts +20 -0
  276. package/dist/storage/gap.d.ts +3 -3
  277. package/dist/storage/idb-driver.d.cts +93 -0
  278. package/dist/storage/idb-driver.d.ts +1 -1
  279. package/dist/storage/indexeddb-storage.d.cts +97 -0
  280. package/dist/storage/indexeddb-storage.d.ts +12 -4
  281. package/dist/storage/keys.d.cts +17 -0
  282. package/dist/storage/keys.d.ts +2 -2
  283. package/dist/storage/local-storage.d.cts +139 -0
  284. package/dist/storage/local-storage.d.ts +11 -4
  285. package/dist/storage/memory-storage.d.cts +73 -0
  286. package/dist/storage/memory-storage.d.ts +4 -3
  287. package/dist/storage/persistence.d.cts +8 -0
  288. package/dist/storage/persistence.d.ts +2 -2
  289. package/dist/storage/stored-context.d.cts +34 -0
  290. package/dist/storage/stored-context.d.ts +34 -0
  291. package/dist/stored-context-BOu54M8Y.cjs +2 -0
  292. package/dist/stored-context-BOu54M8Y.cjs.map +1 -0
  293. package/dist/stored-context-CSttrAsw.js +51 -0
  294. package/dist/stored-context-CSttrAsw.js.map +1 -0
  295. package/dist/storm-BHgI12iS.cjs +2 -0
  296. package/dist/storm-BHgI12iS.cjs.map +1 -0
  297. package/dist/storm-DKlpv0FL.js +9 -0
  298. package/dist/storm-DKlpv0FL.js.map +1 -0
  299. package/dist/transport/compression.d.cts +7 -0
  300. package/dist/transport/custom-transport.d.cts +22 -0
  301. package/dist/transport/custom-transport.d.ts +6 -5
  302. package/dist/transport/errors.d.cts +31 -0
  303. package/dist/transport/exit-flush.d.cts +135 -0
  304. package/dist/transport/exit-flush.d.ts +30 -13
  305. package/dist/transport/headers.d.cts +8 -0
  306. package/dist/transport/headers.d.ts +2 -2
  307. package/dist/transport/http-transport.d.cts +116 -0
  308. package/dist/transport/http-transport.d.ts +20 -8
  309. package/dist/transport/memory-transport.d.cts +30 -0
  310. package/dist/transport/memory-transport.d.ts +2 -2
  311. package/dist/transport/response-body.d.cts +49 -0
  312. package/dist/transport/response-body.d.ts +49 -0
  313. package/dist/transport/retry-engine.d.cts +129 -0
  314. package/dist/transport/retry-engine.d.ts +27 -9
  315. package/dist/transport/serializers/ecs.d.cts +3 -0
  316. package/dist/transport/serializers/ecs.d.ts +1 -1
  317. package/dist/transport/serializers/otlp-metrics.d.cts +3 -0
  318. package/dist/transport/serializers/otlp-metrics.d.ts +1 -1
  319. package/dist/transport/serializers/otlp-traces.d.cts +3 -0
  320. package/dist/transport/serializers/otlp-traces.d.ts +1 -1
  321. package/dist/transport/serializers/otlp.d.cts +47 -0
  322. package/dist/transport/serializers/otlp.d.ts +2 -2
  323. package/dist/transport/serializers/select.d.cts +38 -0
  324. package/dist/transport/serializers/select.d.ts +5 -5
  325. package/dist/transport/status-transport.d.cts +129 -0
  326. package/dist/transport/status-transport.d.ts +25 -8
  327. package/dist/transport/worker-client.d.cts +23 -0
  328. package/dist/transport/worker-client.d.ts +12 -3
  329. package/dist/transport/worker-entry.d.cts +5 -0
  330. package/dist/transport/worker-entry.d.ts +1 -1
  331. package/dist/transport/worker-protocol.d.cts +38 -0
  332. package/dist/transport/worker-protocol.d.ts +4 -2
  333. package/dist/transport/worker-server.d.cts +3 -0
  334. package/dist/transport/worker-server.d.ts +1 -1
  335. package/dist/transport/worker-transport.d.cts +10 -0
  336. package/dist/transport/worker-transport.d.ts +5 -4
  337. package/dist/types-BAerHgCq.js.map +1 -1
  338. package/dist/types-C7WNpnG1.cjs.map +1 -1
  339. package/dist/unclean-exit-BYPYYkQ5.cjs +2 -0
  340. package/dist/unclean-exit-BYPYYkQ5.cjs.map +1 -0
  341. package/dist/{unclean-exit-Cob_jyTv.js → unclean-exit-BcOB8A2e.js} +23 -30
  342. package/dist/unclean-exit-BcOB8A2e.js.map +1 -0
  343. package/dist/{user-timing-DgHubxCI.js → user-timing-4KIJ74Vi.js} +15 -17
  344. package/dist/user-timing-4KIJ74Vi.js.map +1 -0
  345. package/dist/user-timing-BsU2wQKE.cjs +2 -0
  346. package/dist/user-timing-BsU2wQKE.cjs.map +1 -0
  347. package/dist/utils/console.d.cts +36 -0
  348. package/dist/utils/console.d.ts +4 -4
  349. package/dist/utils/deadline.d.cts +14 -0
  350. package/dist/utils/error-like.d.cts +25 -0
  351. package/dist/utils/fixed-window.d.cts +25 -0
  352. package/dist/utils/global-scope.d.cts +20 -0
  353. package/dist/utils/guards.d.cts +14 -0
  354. package/dist/utils/guards.d.ts +8 -0
  355. package/dist/utils/identity.d.cts +114 -0
  356. package/dist/utils/identity.d.ts +8 -4
  357. package/dist/utils/library-console.d.cts +11 -0
  358. package/dist/utils/library-request.d.cts +24 -0
  359. package/dist/utils/lock.d.cts +24 -0
  360. package/dist/utils/lock.d.ts +1 -1
  361. package/dist/utils/openfin.d.cts +48 -0
  362. package/dist/utils/patch.d.cts +9 -0
  363. package/dist/utils/platform.d.cts +62 -0
  364. package/dist/utils/platform.d.ts +2 -2
  365. package/dist/utils/sanitize.d.cts +52 -0
  366. package/dist/utils/sanitize.d.ts +1 -1
  367. package/dist/utils/sequence.d.cts +10 -0
  368. package/dist/utils/tracing.d.cts +158 -0
  369. package/dist/utils/tracing.d.ts +11 -4
  370. package/dist/utils/unref.d.cts +9 -0
  371. package/dist/web-socket-Cs1ZbmmN.cjs +2 -0
  372. package/dist/{web-socket-DthJuSAg.js.map → web-socket-Cs1ZbmmN.cjs.map} +1 -1
  373. package/dist/{web-socket-DthJuSAg.js → web-socket-Zg0hj1LB.js} +23 -28
  374. package/dist/web-socket-Zg0hj1LB.js.map +1 -0
  375. package/dist/{web-vitals-CsGCWnUr.js → web-vitals-4pWACwaR.js} +15 -21
  376. package/dist/web-vitals-4pWACwaR.js.map +1 -0
  377. package/dist/web-vitals-__X7t4pj.cjs +2 -0
  378. package/dist/web-vitals-__X7t4pj.cjs.map +1 -0
  379. package/dist/{worker-protocol-B0_8rWy5.js → worker-protocol-CYpAbrVl.js} +14 -11
  380. package/dist/worker-protocol-CYpAbrVl.js.map +1 -0
  381. package/dist/worker-protocol-DFYXIFus.cjs +2 -0
  382. package/dist/worker-protocol-DFYXIFus.cjs.map +1 -0
  383. package/dist/worker-server--yGTadTA.cjs +2 -0
  384. package/dist/worker-server--yGTadTA.cjs.map +1 -0
  385. package/dist/worker-server-BokySIII.js +94 -0
  386. package/dist/worker-server-BokySIII.js.map +1 -0
  387. package/dist/worker-transport-BdEvh_-a.cjs +2 -0
  388. package/dist/worker-transport-BdEvh_-a.cjs.map +1 -0
  389. package/dist/worker-transport-JK-Fby9J.js +194 -0
  390. package/dist/worker-transport-JK-Fby9J.js.map +1 -0
  391. package/llms.txt +400 -0
  392. package/package.json +65 -49
  393. package/dist/bus-D_7pd7RN.cjs +0 -2
  394. package/dist/bus-D_7pd7RN.cjs.map +0 -1
  395. package/dist/bus-ecxUNTja.js +0 -660
  396. package/dist/bus-ecxUNTja.js.map +0 -1
  397. package/dist/console-CLz_PvFn.cjs +0 -2
  398. package/dist/console-CLz_PvFn.cjs.map +0 -1
  399. package/dist/console-cwgHKXvM.js +0 -82
  400. package/dist/console-cwgHKXvM.js.map +0 -1
  401. package/dist/constants-Bwl_YtQi.js +0 -349
  402. package/dist/constants-Bwl_YtQi.js.map +0 -1
  403. package/dist/constants-DakMxVB2.cjs +0 -2
  404. package/dist/constants-DakMxVB2.cjs.map +0 -1
  405. package/dist/context-storage-BjzeBSxH.cjs +0 -2
  406. package/dist/context-storage-BjzeBSxH.cjs.map +0 -1
  407. package/dist/context-storage-BzkoHzkQ.js +0 -51
  408. package/dist/context-storage-BzkoHzkQ.js.map +0 -1
  409. package/dist/debug-bundle-BOdYmCeV.js +0 -32
  410. package/dist/debug-bundle-BOdYmCeV.js.map +0 -1
  411. package/dist/debug-bundle-Ex4L_LSP.cjs +0 -2
  412. package/dist/debug-bundle-Ex4L_LSP.cjs.map +0 -1
  413. package/dist/emergency-queue-B9WZxanZ.js +0 -67
  414. package/dist/emergency-queue-B9WZxanZ.js.map +0 -1
  415. package/dist/emergency-queue-HBpL5r3V.cjs +0 -2
  416. package/dist/emergency-queue-HBpL5r3V.cjs.map +0 -1
  417. package/dist/errors-D6bwgJtO.js +0 -92
  418. package/dist/errors-D6bwgJtO.js.map +0 -1
  419. package/dist/errors-DCOCRdSi.cjs +0 -3
  420. package/dist/errors-DCOCRdSi.cjs.map +0 -1
  421. package/dist/factory-DLFDjdLv.cjs +0 -2
  422. package/dist/factory-DLFDjdLv.cjs.map +0 -1
  423. package/dist/factory-e9Qo3K0z.js +0 -276
  424. package/dist/factory-e9Qo3K0z.js.map +0 -1
  425. package/dist/guards-Cidk71ME.js +0 -7
  426. package/dist/guards-Cidk71ME.js.map +0 -1
  427. package/dist/guards-nJ70syPt.cjs +0 -2
  428. package/dist/guards-nJ70syPt.cjs.map +0 -1
  429. package/dist/identity-BlvlgjrU.cjs +0 -2
  430. package/dist/identity-BlvlgjrU.cjs.map +0 -1
  431. package/dist/identity-BrQp_5J5.js.map +0 -1
  432. package/dist/indexeddb-storage-CtLvZH1r.cjs +0 -2
  433. package/dist/indexeddb-storage-CtLvZH1r.cjs.map +0 -1
  434. package/dist/indexeddb-storage-DLXQzAGh.js.map +0 -1
  435. package/dist/interactions-B6z2I4tU.js +0 -119
  436. package/dist/interactions-B6z2I4tU.js.map +0 -1
  437. package/dist/interactions-P6pz08Jn.cjs +0 -2
  438. package/dist/interactions-P6pz08Jn.cjs.map +0 -1
  439. package/dist/journey-35yCMNFo.js.map +0 -1
  440. package/dist/journey-DAGh5h9k.cjs +0 -2
  441. package/dist/journey-DAGh5h9k.cjs.map +0 -1
  442. package/dist/keys-BHhw_0Wh.cjs +0 -2
  443. package/dist/keys-BHhw_0Wh.cjs.map +0 -1
  444. package/dist/keys-BU9j5YqW.js +0 -16
  445. package/dist/keys-BU9j5YqW.js.map +0 -1
  446. package/dist/lifecycle-BGGOcN4N.cjs +0 -2
  447. package/dist/lifecycle-BGGOcN4N.cjs.map +0 -1
  448. package/dist/lifecycle-CZ6RRXc6.js.map +0 -1
  449. package/dist/log-record-D7bA1RPb.cjs +0 -2
  450. package/dist/log-record-D7bA1RPb.cjs.map +0 -1
  451. package/dist/log-record-DIA6McNr.js.map +0 -1
  452. package/dist/long-frames-430_85Da.js.map +0 -1
  453. package/dist/long-frames-Dd8tsi2U.cjs +0 -2
  454. package/dist/long-frames-Dd8tsi2U.cjs.map +0 -1
  455. package/dist/models/stats.d.ts +0 -11
  456. package/dist/network-C7SkLf4v.js.map +0 -1
  457. package/dist/network-pEX3PAJv.cjs +0 -2
  458. package/dist/network-pEX3PAJv.cjs.map +0 -1
  459. package/dist/profiler-BVWIOgnq.js.map +0 -1
  460. package/dist/profiler-eVCknCzS.cjs +0 -2
  461. package/dist/profiler-eVCknCzS.cjs.map +0 -1
  462. package/dist/profiler-frames-CLXlT_xL.js.map +0 -1
  463. package/dist/profiler-frames-Dg2OebB2.cjs +0 -2
  464. package/dist/profiler-frames-Dg2OebB2.cjs.map +0 -1
  465. package/dist/remote-rules-BJGDJGwA.js +0 -98
  466. package/dist/remote-rules-BJGDJGwA.js.map +0 -1
  467. package/dist/remote-rules-CJD3ToVk.cjs +0 -2
  468. package/dist/remote-rules-CJD3ToVk.cjs.map +0 -1
  469. package/dist/replay-0zAJv9T3.js +0 -338
  470. package/dist/replay-0zAJv9T3.js.map +0 -1
  471. package/dist/replay-DomJpXqW.cjs +0 -2
  472. package/dist/replay-DomJpXqW.cjs.map +0 -1
  473. package/dist/reports-BsbqmP8h.cjs +0 -2
  474. package/dist/reports-BsbqmP8h.cjs.map +0 -1
  475. package/dist/reports-BuXekPOS.js.map +0 -1
  476. package/dist/resource-timing-CXGHwFRD.js.map +0 -1
  477. package/dist/resource-timing-DkycFGDa.cjs +0 -2
  478. package/dist/resource-timing-DkycFGDa.cjs.map +0 -1
  479. package/dist/sampling-Dd0wllyq.cjs +0 -2
  480. package/dist/sampling-Dd0wllyq.cjs.map +0 -1
  481. package/dist/sampling-UUDbi3K0.js +0 -60
  482. package/dist/sampling-UUDbi3K0.js.map +0 -1
  483. package/dist/sanitize-CNmsD9r3.js.map +0 -1
  484. package/dist/sanitize-ChLn97Ch.cjs.map +0 -1
  485. package/dist/select-CTk-K5mG.cjs +0 -3
  486. package/dist/select-CTk-K5mG.cjs.map +0 -1
  487. package/dist/select-DPv_j6wq.js +0 -270
  488. package/dist/select-DPv_j6wq.js.map +0 -1
  489. package/dist/sender-15zEsZpr.js +0 -857
  490. package/dist/sender-15zEsZpr.js.map +0 -1
  491. package/dist/sender-Bfpv9tad.cjs +0 -2
  492. package/dist/sender-Bfpv9tad.cjs.map +0 -1
  493. package/dist/storage-BA9RqRO-.cjs +0 -2
  494. package/dist/storage-BA9RqRO-.cjs.map +0 -1
  495. package/dist/storage-DZwed89z.js +0 -16
  496. package/dist/storage-DZwed89z.js.map +0 -1
  497. package/dist/storm-BTSNTIWI.js +0 -9
  498. package/dist/storm-BTSNTIWI.js.map +0 -1
  499. package/dist/storm-D0_qZOEg.cjs +0 -2
  500. package/dist/storm-D0_qZOEg.cjs.map +0 -1
  501. package/dist/unclean-exit-ClGzrc2A.cjs +0 -2
  502. package/dist/unclean-exit-ClGzrc2A.cjs.map +0 -1
  503. package/dist/unclean-exit-Cob_jyTv.js.map +0 -1
  504. package/dist/user-timing-CdYqx3PF.cjs +0 -2
  505. package/dist/user-timing-CdYqx3PF.cjs.map +0 -1
  506. package/dist/user-timing-DgHubxCI.js.map +0 -1
  507. package/dist/utils/timer.d.ts +0 -19
  508. package/dist/web-socket-BTuvYoJI.cjs +0 -2
  509. package/dist/web-socket-BTuvYoJI.cjs.map +0 -1
  510. package/dist/web-vitals-Ch5BpDmo.cjs +0 -2
  511. package/dist/web-vitals-Ch5BpDmo.cjs.map +0 -1
  512. package/dist/web-vitals-CsGCWnUr.js.map +0 -1
  513. package/dist/worker-protocol-B0_8rWy5.js.map +0 -1
  514. package/dist/worker-protocol-BjzFORfq.cjs +0 -2
  515. package/dist/worker-protocol-BjzFORfq.cjs.map +0 -1
  516. package/dist/worker-server-4en-Lt-3.cjs +0 -2
  517. package/dist/worker-server-4en-Lt-3.cjs.map +0 -1
  518. package/dist/worker-server-Cne9MX9I.js +0 -83
  519. package/dist/worker-server-Cne9MX9I.js.map +0 -1
  520. package/dist/worker-transport-B-GF4Aqn.cjs +0 -2
  521. package/dist/worker-transport-B-GF4Aqn.cjs.map +0 -1
  522. package/dist/worker-transport-C3SjJAEC.js +0 -200
  523. package/dist/worker-transport-C3SjJAEC.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants-DakMxVB2.cjs","names":["SESSION_IDLE_MS","SESSION_TOUCH_MS","OPENFIN_UA_PATTERN","ANDROID_WEBVIEW_UA_PATTERN","IOS_DEVICE_UA_PATTERN","MACINTOSH_UA_PATTERN","MOBILE_UA_PATTERN","SEVERITY_NUMBER","LEVEL_ORDER","ATTR_LOG_TYPE","ATTR_LOG_SEQ","ATTR_APP_NAMESPACE","ATTR_PAGE_URL","ATTR_URL_FULL","ATTR_JOURNEY_ID","ATTR_JOURNEY_NAME","ATTR_JOURNEY_PARENT_ID","ATTR_SANITIZE_FAILED","ATTR_ERROR_DATA","ATTR_BREADCRUMBS","ATTR_ATTRIBUTES_DROPPED","ATTR_ATTRIBUTES_BYTES","ATTR_CLOCK_OFFSET_MS","ATTR_DEBUG_BUFFER","RESOURCE_SERVICE_NAME","RESOURCE_SERVICE_VERSION","RESOURCE_DEPLOYMENT_ENVIRONMENT","RESOURCE_TELEMETRY_SDK_NAME","RESOURCE_TELEMETRY_SDK_VERSION","RESOURCE_TELEMETRY_SDK_LANGUAGE","RESOURCE_HOST_PLATFORM","RESOURCE_SESSION_ID","RESOURCE_TAB_ID","RESOURCE_CONTEXT_ID","RESOURCE_BROWSER_USER_AGENT","RESOURCE_OPENFIN_UUID","RESOURCE_OPENFIN_NAME","TELEMETRY_SDK_NAME","TELEMETRY_SDK_VERSION","TELEMETRY_SDK_LANGUAGE","SERIALIZER_NAME_OTLP","ECS_LEVEL_NAMES","ECS_VERSION","CONTENT_TYPE_JSON","CONTENT_TYPE_NDJSON","NANOS_PER_MILLI","NANOS_PATTERN","HEADER_CONTENT_TYPE","HEADER_CONTENT_ENCODING","HEADER_RETRY_AFTER","HEADER_BATCH_ID","HEADER_ATTEMPT","HEADER_SAMPLING","HEADER_DATE","ENCODING_GZIP","MILLIS_PER_SECOND","BEACON_LIMIT_BYTES","CONTENT_TYPE_TEXT_PLAIN","QUERY_PARAM_BATCH_ID","QUERY_PARAM_EXIT_REASON","BATCH_STORAGE_KEY_PREFIX","EMERGENCY_STORAGE_KEY_PREFIX","STORAGE_PROBE_KEY","QUOTA_EXCEEDED_ERROR","INDEXEDDB_STORE_NAME","INDEXEDDB_CREATED_AT_INDEX","STORAGE_NAME_INDEXEDDB","STORAGE_NAME_LOCAL","STORAGE_NAME_MEMORY","STORAGE_NAME_NONE","DRAIN_LOCK_NAME","EMERGENCY_LOCK_NAME","JOURNEY_STORAGE_KEY","JOURNEY_ID_PATTERN","JOURNEY_CLOCK_SKEW_MS","OPENFIN_OPTIONS_TIMEOUT_MS","OPENFIN_JOURNEY_CUSTOM_DATA_KEY","BASE64_PLUS_PATTERN","BASE64_SLASH_PATTERN","BASE64_PADDING_PATTERN","BASE64URL_DASH_PATTERN","BASE64URL_UNDERSCORE_PATTERN","TRACE_MAX_AGE_MS","TRACEPARENT_HEADER","FNV_OFFSET_BASIS","FNV_PRIME","UINT32_MAX","LEVEL_BYPASS_TYPES","LOG_TYPE_METRIC","LOG_TYPE_ACTION","LOG_TYPE_SPAN","BUS_PROTOCOL","BUS_TYPE","RUNTIME_GLOBAL_KEY","RUNTIME_STOPPED_KEY","LIBRARY_REQUEST_KEY","LIBRARY_CONSOLE_KEY","TRANSPORT_CALL_KEY","ERROR_STORM_WINDOW_MS","ACTION_ATTRIBUTE_DEFAULT","RAGE_CLICK_WINDOW_MS","DEAD_CLICK_MS","DEAD_CLICK_CONTROLS","CONSOLE_DEFAULT_STYLES","DURATION_PRECISION","GAP_REPORT_THROTTLE_MS","CAPTURE_NAMESPACE","STORAGE_NAMESPACE","DIAGNOSTICS_NAMESPACE","DEFAULT_METRIC_UNIT","METRIC_NAMESPACE","ATTR_METRIC_OVERFLOW","METRIC_DEFAULT_BOUNDARIES","METRIC_KEYS","PROFILE_MAX_US","PROFILER_FLUSH_INTERVAL_MS","PROFILE_METRIC_NAME","PROFILE_KEYS","PROFILE_FRAME_METRIC_NAME","PROFILE_FRAME_PROBE","INSTRUMENT_OPTIONS_FAULT","REPLAY_ID_KEY","REPLAY_UNMASK_ATTRIBUTE","PROFILER_PROBE_LIMIT","PROFILER_GLOBAL_KEY","PROFILER_CALIBRATION_PAIRS","TRACE_NAMESPACE","SPAN_KEYS","TRANSPORT_WORKER_PROTOCOL","TRANSPORT_WORKER_TYPE","TRANSPORT_WORKER_REFUSAL","DEFER_IDLE_TIMEOUT_MS","DEFER_QUEUE_LIMIT","RESOURCE_SLOW_MS","SERVER_TIMING_HEADER","SERVER_TIMING_MAX_CHARS","REMOTE_CAPTURE_FLAGS","UNKNOWN_SERVICE_NAME","REMOTE_SAMPLING_MAX_CHARS","REMOTE_SAMPLING_MAX_TTL_MS","REMOTE_SAMPLING_POLL_MS","UNDEFAULTED_CONFIG_KEYS","CONFIG_SECTIONS","UNDEFAULTED_SECTION_KEYS","CONSOLE_DEFAULT_LEVEL","LOG_FLUSH_INTERVAL_MS","METRIC_FLUSH_INTERVAL_MS","REQUEST_TIMEOUT_MS","COMPRESSION_THRESHOLD_BYTES","STORAGE_DB_NAME","STORAGE_LIMITS","STORAGE_DEADLINE_MS","RETRY_BASE_DELAY_MS","RETRY_MAX_DELAY_MS","RETRY_IDLE_DELAY_MS","JOURNEY_MAX_AGE_MS","JOURNEY_URL_PARAM","BUS_CHANNEL_NAME","BUS_HANDSHAKE_TIMEOUT_MS","BUS_MAX_BOOT_BUFFER_ACTIONS","ERROR_DEDUPE_MS","RECORD_LIMITS","DEFAULT_CONFIG"],"sources":["../src/constants.ts"],"sourcesContent":["// src/constants.ts\n//\n// Every limit, threshold, timing window, storage key, pattern and default the\n// library uses.\n\nimport type { ConsoleStyles, ResolvedConfig } from \"./models/config\";\nimport type { LogLevel, LogType } from \"./models/log-record\";\nimport type { StorageLimits } from \"./models/storage\";\n\n// ----------------------------------\n// Library-wide\n// ----------------------------------\n\n/** Prefix on console messages this library writes. */\nexport const LIBRARY_LOG_PREFIX = \"[ui-observability]\";\n\n// ----------------------------------\n// Diagnostics\n// ----------------------------------\n\n/**\n * Throttle window per diagnostic code, in milliseconds. Limits how often an error\n * loop can call the handler.\n */\nexport const DIAGNOSTIC_THROTTLE_MS = 1000;\n\n// ----------------------------------\n// Identity\n// ----------------------------------\n\n/** `localStorage` key for the session id and its last-seen time. */\nexport const SESSION_ID_KEY = \"ui-observability.session\";\n\n/** `sessionStorage` key for the tab id. */\nexport const TAB_ID_KEY = \"ui-observability.tab\";\n\n/** sessionStorage key for a live page's marker. A clean close removes it. */\nexport const ALIVE_KEY = \"ui-observability.alive\";\n\n/** How often the alive marker is updated, in milliseconds. */\nexport const ALIVE_UPDATE_MS = 30_000;\n\n/** Session idle timeout, in milliseconds. */\nexport const SESSION_IDLE_MS = 30 * 60 * 1000;\n\n/** Min gap between session last-seen writes, in milliseconds. */\nexport const SESSION_TOUCH_MS = 60_000;\n\n/** Random id length, in bytes, used when `crypto.randomUUID` is unavailable. */\nexport const ID_BYTE_LENGTH = 16;\n\n/** Distinct values in one byte (256). */\nexport const BYTE_VALUE_COUNT = 256;\n\n// ----------------------------------\n// Platform detection\n// ----------------------------------\n\n/** Matches OpenFin's user agent. */\nexport const OPENFIN_UA_PATTERN = /OpenFin/i;\n\n/** Matches Android's webview token (`wv`). */\nexport const ANDROID_WEBVIEW_UA_PATTERN = /\\bwv\\b/;\n\n/** Matches iOS hardware: iPhone, iPad, iPod. */\nexport const IOS_DEVICE_UA_PATTERN = /\\b(iPhone|iPad|iPod)\\b/;\n\n/** Matches desktop macOS in a user agent. */\nexport const MACINTOSH_UA_PATTERN = /\\bMacintosh\\b/;\n\n/** Matches the mobile token. */\nexport const MOBILE_UA_PATTERN = /\\bMobile\\b/;\n\n/** WebKit engine token, present in every WebKit browser including webviews. */\nexport const WEBKIT_UA_TOKEN = \"AppleWebKit\";\n\n/** Safari token sent by real iOS browsers, not in-app webviews. */\nexport const SAFARI_UA_TOKEN = \"Safari/\";\n\n// ----------------------------------\n// Sanitizing and size estimation\n// ----------------------------------\n\n/** First UTF-16 high surrogate code unit. */\nexport const HIGH_SURROGATE_MIN = 0xd800;\n\n/** Last UTF-16 high surrogate code unit. */\nexport const HIGH_SURROGATE_MAX = 0xdbff;\n\n/** Code units below this encode as one UTF-8 byte. */\nexport const UTF8_ONE_BYTE_CEILING = 0x80;\n\n/** Code units below this, and at or above the one-byte ceiling, encode as two UTF-8 bytes. */\nexport const UTF8_TWO_BYTE_CEILING = 0x800;\n\n/** Class names kept in a `describeNode` selector. */\nexport const MAX_NODE_CLASS_NAMES = 3;\n\n/** Byte cost of a null or undefined value. */\nexport const BYTES_PER_NULL = 4;\n\n/** Byte cost of a number (flat estimate). */\nexport const BYTES_PER_NUMBER = 8;\n\n/** Byte cost of a boolean. */\nexport const BYTES_PER_BOOLEAN = 5;\n\n/** Byte cost of an object or array's wrapping braces or brackets. */\nexport const BYTES_PER_CONTAINER = 2;\n\n/** Byte cost of a string's wrapping quotes. */\nexport const BYTES_PER_QUOTED_STRING = 2;\n\n/** Byte cost of one key's punctuation: quotes, colon, comma. */\nexport const BYTES_PER_KEY_OVERHEAD = 4;\n\n// ----------------------------------\n// Record model\n// ----------------------------------\n\n/**\n * Maps each log level to its OpenTelemetry severity number.\n * @see {@link LEVEL_ORDER}\n */\nexport const SEVERITY_NUMBER: Record<LogLevel, number> = {\n TRACE: 1,\n DEBUG: 5,\n INFO: 9,\n WARN: 13,\n ERROR: 17,\n FATAL: 21,\n};\n\n/**\n * Alias for `SEVERITY_NUMBER`, used by the level filter.\n * @see {@link SEVERITY_NUMBER}\n */\nexport const LEVEL_ORDER: Record<LogLevel, number> = SEVERITY_NUMBER;\n\n// ----------------------------------\n// Attribute and resource keys\n// ----------------------------------\n//\n// The attribute and resource key names records carry in the payload. They follow the\n// OpenTelemetry conventions, and the `uiobs.` prefix marks this library's own fields.\n\n/** Record kind attribute key. */\nexport const ATTR_LOG_TYPE = \"log.type\";\n\n/** A record's sequence number within its context. Starts at 1. */\nexport const ATTR_LOG_SEQ = \"log.seq\";\n\n/** Logger namespace attribute key. */\nexport const ATTR_APP_NAMESPACE = \"app.namespace\";\n\n/** The document URL at the time the record was built. */\nexport const ATTR_PAGE_URL = \"page.url\";\n\n/**\n * HTTP request URL attribute key, set by network capture. Don't reuse `ATTR_PAGE_URL` for it,\n * because the page URL overwrites the request target under that key.\n * @see {@link ATTR_PAGE_URL}\n */\nexport const ATTR_URL_FULL = \"url.full\";\n\n/** Journey id attribute key. */\nexport const ATTR_JOURNEY_ID = \"journey.id\";\n\n/** Journey name attribute key. */\nexport const ATTR_JOURNEY_NAME = \"journey.name\";\n\n/** Parent journey id, present only on a child journey. */\nexport const ATTR_JOURNEY_PARENT_ID = \"journey.parent_id\";\n\n/** Marks a record whose attributes failed to sanitize. */\nexport const ATTR_SANITIZE_FAILED = \"uiobs.sanitize_failed\";\n\n/** An Error reason's own fields, or the whole reason when it isn't an Error. */\nexport const ATTR_ERROR_DATA = \"error.data\";\n\n/** An error record's breadcrumb history. */\nexport const ATTR_BREADCRUMBS = \"breadcrumbs\";\n\n/**\n * Marks a record whose attributes were dropped for exceeding the byte budget.\n * @see {@link ATTR_ATTRIBUTES_BYTES}\n */\nexport const ATTR_ATTRIBUTES_DROPPED = \"uiobs.attributes_dropped\";\n\n/**\n * Byte size of the dropped attributes.\n * @see {@link ATTR_ATTRIBUTES_DROPPED}\n */\nexport const ATTR_ATTRIBUTES_BYTES = \"uiobs.attributes_bytes\";\n\n/** Server time minus client time, in milliseconds, from an accepted answer's Date header. */\nexport const ATTR_CLOCK_OFFSET_MS = \"uiobs.clock_offset_ms\";\n\n/** Marks a record the debug buffer held until an error. */\nexport const ATTR_DEBUG_BUFFER = \"uiobs.debug_buffer\";\n\n/** Half the HTTP Date header's resolution. Centers the clock offset's error. */\nexport const DATE_HEADER_HALF_STEP_MS = 500;\n\n/** Application name resource key. */\nexport const RESOURCE_SERVICE_NAME = \"service.name\";\n\n/** Application build version resource key. */\nexport const RESOURCE_SERVICE_VERSION = \"service.version\";\n\n/** Deployment environment resource key. */\nexport const RESOURCE_DEPLOYMENT_ENVIRONMENT = \"deployment.environment\";\n\n/**\n * Producer library name resource key.\n * @see {@link TELEMETRY_SDK_NAME}\n */\nexport const RESOURCE_TELEMETRY_SDK_NAME = \"telemetry.sdk.name\";\n\n/**\n * Producer library version resource key.\n * @see {@link TELEMETRY_SDK_VERSION}\n */\nexport const RESOURCE_TELEMETRY_SDK_VERSION = \"telemetry.sdk.version\";\n\n/**\n * Producer SDK language resource key.\n * @see {@link TELEMETRY_SDK_LANGUAGE}\n */\nexport const RESOURCE_TELEMETRY_SDK_LANGUAGE = \"telemetry.sdk.language\";\n\n/** Host platform resource key: browser, webview, or OpenFin. */\nexport const RESOURCE_HOST_PLATFORM = \"host.platform\";\n\n/** Session id resource key. */\nexport const RESOURCE_SESSION_ID = \"session.id\";\n\n/** Tab id resource key. */\nexport const RESOURCE_TAB_ID = \"tab.id\";\n\n/** Context (realm) id resource key. */\nexport const RESOURCE_CONTEXT_ID = \"context.id\";\n\n/** Raw user agent resource key. */\nexport const RESOURCE_BROWSER_USER_AGENT = \"browser.user_agent\";\n\n/** OpenFin application uuid resource key. */\nexport const RESOURCE_OPENFIN_UUID = \"openfin.uuid\";\n\n/** OpenFin window or view name resource key. */\nexport const RESOURCE_OPENFIN_NAME = \"openfin.name\";\n\n/**\n * Value of `telemetry.sdk.name`.\n * @see {@link RESOURCE_TELEMETRY_SDK_NAME}\n */\nexport const TELEMETRY_SDK_NAME = \"@utk09/ui-observability\";\n\n/**\n * Value of `telemetry.sdk.version`. The build writes the package.json version here.\n * @see {@link RESOURCE_TELEMETRY_SDK_VERSION}\n */\nexport const TELEMETRY_SDK_VERSION = __UIOBS_VERSION__;\n\n/**\n * Value of `telemetry.sdk.language`.\n * @see {@link RESOURCE_TELEMETRY_SDK_LANGUAGE}\n */\nexport const TELEMETRY_SDK_LANGUAGE = \"webjs\";\n\n// ----------------------------------\n// Serializers\n// ----------------------------------\n\n/** OTLP/JSON serializer name. */\nexport const SERIALIZER_NAME_OTLP = \"otlp\";\n\n/** ECS serializer name. */\nexport const SERIALIZER_NAME_ECS = \"ecs\";\n\n/**\n * ECS `log.level` names that differ from the lowercase severity text. ECS spells\n * the warning level out in full, and every other level matches in lowercase.\n * @see {@link SERIALIZER_NAME_ECS}\n */\nexport const ECS_LEVEL_NAMES: Partial<Record<LogLevel, string>> = { WARN: \"warning\" };\n\n/** The ECS version of the documents, the same one the Elastic ECS logging libraries write. */\nexport const ECS_VERSION = \"8.10.0\";\n\n/** Content type for an OTLP/JSON body. */\nexport const CONTENT_TYPE_JSON = \"application/json\";\n\n/** Content type for newline-delimited JSON. */\nexport const CONTENT_TYPE_NDJSON = \"application/x-ndjson\";\n\n/** Nanoseconds per millisecond. */\nexport const NANOS_PER_MILLI = 1000000n;\n\n/**\n * Matches a nanosecond epoch in decimal digits, for example \"1755543600123000000\".\n * @see {@link NANOS_PER_MILLI}\n */\nexport const NANOS_PATTERN = /^\\d+$/;\n\n// ----------------------------------\n// HTTP transport\n// ----------------------------------\n\n/** Content-Type header name. */\nexport const HEADER_CONTENT_TYPE = \"Content-Type\";\n\n/** Content-Encoding header name. */\nexport const HEADER_CONTENT_ENCODING = \"Content-Encoding\";\n\n/** Retry-After header name. */\nexport const HEADER_RETRY_AFTER = \"Retry-After\";\n\n/**\n * Batch deduplication key header name.\n * @see {@link QUERY_PARAM_BATCH_ID}\n */\nexport const HEADER_BATCH_ID = \"X-UiObs-Batch-Id\";\n\n/** Delivery attempt number header name. */\nexport const HEADER_ATTEMPT = \"X-UiObs-Attempt\";\n\n/** Response header that carries sampling rules from the ingest server. */\nexport const HEADER_SAMPLING = \"X-UiObs-Sampling\";\n\n/** Response header that gives the server time. The server must expose it to CORS. */\nexport const HEADER_DATE = \"Date\";\n\n/** Gzip encoding name. */\nexport const ENCODING_GZIP = \"gzip\";\n\n/** Lowest valid HTTP status code. */\nexport const HTTP_STATUS_MIN = 100;\n\n/** Highest valid HTTP status code. */\nexport const HTTP_STATUS_MAX = 599;\n\n/** Lowest HTTP status code that accepts a batch. */\nexport const HTTP_SUCCESS_MIN = 200;\n\n/** Lowest HTTP status code above the success range. */\nexport const HTTP_SUCCESS_END = 300;\n\n/** 401, credentials missing or rejected. */\nexport const HTTP_UNAUTHORIZED = 401;\n\n/** 403, valid credentials but access denied. */\nexport const HTTP_FORBIDDEN = 403;\n\n/** 408, the server closed the connection after a timeout. The transport can retry. */\nexport const HTTP_REQUEST_TIMEOUT = 408;\n\n/** 413, payload too large. The transport must split the batch. */\nexport const HTTP_PAYLOAD_TOO_LARGE = 413;\n\n/** 429, backpressure. */\nexport const HTTP_TOO_MANY_REQUESTS = 429;\n\n/** 500, floor for server-side errors. */\nexport const HTTP_SERVER_ERROR_MIN = 500;\n\n/** 503, temporary unavailability. */\nexport const HTTP_SERVICE_UNAVAILABLE = 503;\n\n/** Milliseconds per second. */\nexport const MILLIS_PER_SECOND = 1000;\n\n// ----------------------------------\n// Exit flush\n// ----------------------------------\n\n/** Max exit payload size, in bytes (`sendBeacon`/`fetch(keepalive)` shared budget). */\nexport const BEACON_LIMIT_BYTES = 60_000;\n\n/** Content type for an exit payload. CORS-safelisted, so it doesn't trigger a preflight. */\nexport const CONTENT_TYPE_TEXT_PLAIN = \"text/plain;charset=UTF-8\";\n\n/**\n * Batch id query param name, for the exit path.\n * @see {@link HEADER_BATCH_ID}\n */\nexport const QUERY_PARAM_BATCH_ID = \"uiobs_batch_id\";\n\n/** Exit reason query param name, for logs only. */\nexport const QUERY_PARAM_EXIT_REASON = \"uiobs_exit\";\n\n// ----------------------------------\n// Storage\n// ----------------------------------\n\n/** localStorage key prefix for a stored batch. */\nexport const BATCH_STORAGE_KEY_PREFIX = \"ui-observability.batch.\";\n\n/** Zero-padded digit width for the creation time in a batch key. */\nexport const BATCH_KEY_TIME_WIDTH = 14;\n\n/** localStorage key prefix for a batch stored by the exit flush. */\nexport const EMERGENCY_STORAGE_KEY_PREFIX = \"ui-observability.emergency.\";\n\n/** Maximum number of exit batches in the emergency queue. */\nexport const EMERGENCY_MAX_ENTRIES = 20;\n\n/** Key we write to check whether localStorage accepts writes. */\nexport const STORAGE_PROBE_KEY = \"ui-observability.probe\";\n\n/** Fraction of the store to evict on a quota error (1 in N). */\nexport const QUOTA_EVICTION_DIVISOR = 4;\n\n/** DOMException name for a full store. */\nexport const QUOTA_EXCEEDED_ERROR = \"QuotaExceededError\";\n\n/**\n * Native IndexedDB version. Version 11 replaced Dexie, and version 12 adds the context index.\n * Dexie opened this database at ten times its declared version, so a version below 11 makes\n * open() fail with VersionError on an existing installation, and then nothing can read its\n * batches.\n */\nexport const INDEXEDDB_SCHEMA_VERSION = 12;\n\n/** IndexedDB object store that holds the batches. The name dates from Dexie, since removed. */\nexport const INDEXEDDB_STORE_NAME = \"batches\";\n\n/** Index on the batch store that orders reads by creation time. */\nexport const INDEXEDDB_CREATED_AT_INDEX = \"createdAt\";\n\n/** IndexedDB adapter/strategy name. */\nexport const STORAGE_NAME_INDEXEDDB = \"indexeddb\";\n\n/** localStorage adapter/strategy name. */\nexport const STORAGE_NAME_LOCAL = \"localstorage\";\n\n/** In-memory adapter/strategy name. */\nexport const STORAGE_NAME_MEMORY = \"memory\";\n\n/** Name of the storage adapter that keeps nothing. */\nexport const STORAGE_NAME_NONE = \"none\";\n\n// ----------------------------------\n// Retry\n// ----------------------------------\n\n/**\n * Origin-wide lock name a drain runs under.\n * @see {@link EMERGENCY_LOCK_NAME}\n */\nexport const DRAIN_LOCK_NAME = \"ui-observability.drain\";\n\n/**\n * Lock name startup recovery runs under.\n * @see {@link DRAIN_LOCK_NAME}\n */\nexport const EMERGENCY_LOCK_NAME = \"ui-observability.emergency\";\n\n/** Batches sent per drain tick. */\nexport const BATCHES_PER_DRAIN = 20;\n\n// ----------------------------------\n// Journey\n// ----------------------------------\n\n/** `sessionStorage` key for the current journey. */\nexport const JOURNEY_STORAGE_KEY = \"ui-observability.journey\";\n\n/**\n * Max journey name length in a token, in characters.\n * @see {@link JOURNEY_TOKEN_MAX_CHARS}\n */\nexport const JOURNEY_TOKEN_NAME_MAX_CHARS = 64;\n\n/**\n * Max length of a journey id from startJourney(), in characters. A journey with an id this long\n * and a full-length name still gets a token below the token limit.\n * @see {@link JOURNEY_TOKEN_MAX_CHARS}\n */\nexport const JOURNEY_ID_MAX_CHARS = 64;\n\n/**\n * Accepted journey id from startJourney(): letters, digits, \"_\", \".\", \":\" and \"-\". Every\n * character is one byte in UTF-8. A multibyte id would push the token over its limit.\n */\nexport const JOURNEY_ID_PATTERN = new RegExp(`^[\\\\w.:-]{1,${String(JOURNEY_ID_MAX_CHARS)}}$`);\n\n/**\n * How far ahead of this clock a journey token's start time can be, in milliseconds. Two machines\n * can disagree on the time, but a token further ahead than this would never expire.\n */\nexport const JOURNEY_CLOCK_SKEW_MS = 5 * 60 * 1000;\n\n/**\n * Max whole-token length, in characters. This only rejects an oversized token. It doesn't\n * validate the token's content.\n * @see {@link JOURNEY_TOKEN_NAME_MAX_CHARS}\n */\nexport const JOURNEY_TOKEN_MAX_CHARS = 256;\n\n/**\n * How long to wait for `fin.me.getOptions()`, in milliseconds. After that, the\n * runtime carries on without a seeded journey.\n * @see {@link OPENFIN_JOURNEY_CUSTOM_DATA_KEY}\n */\nexport const OPENFIN_OPTIONS_TIMEOUT_MS = 2000;\n\n/** Key under an OpenFin window's `customData` carrying a seeded journey token. */\nexport const OPENFIN_JOURNEY_CUSTOM_DATA_KEY = \"uiObsJourney\";\n\n/** Matches `+` in standard base64 (`-` in URL-safe). */\nexport const BASE64_PLUS_PATTERN = /\\+/g;\n\n/** Matches `/` in standard base64 (`_` in URL-safe). */\nexport const BASE64_SLASH_PATTERN = /\\//g;\n\n/** Matches trailing `=` padding. */\nexport const BASE64_PADDING_PATTERN = /=+$/;\n\n/** Matches `-` in URL-safe base64 (`+` in standard). */\nexport const BASE64URL_DASH_PATTERN = /-/g;\n\n/** Matches `_` in URL-safe base64 (`/` in standard). */\nexport const BASE64URL_UNDERSCORE_PATTERN = /_/g;\n\n/** Base64 characters per 3-byte group. */\nexport const BASE64_GROUP_CHARS = 4;\n\n// ----------------------------------\n// Tracing\n// ----------------------------------\n\n/** W3C trace id width, in bytes. */\nexport const TRACE_ID_BYTES = 16;\n\n/** W3C span id width, in bytes. */\nexport const SPAN_ID_BYTES = 8;\n\n/** Max ambient trace lifetime with no activity, in milliseconds. */\nexport const TRACE_MAX_AGE_MS = 5 * 60 * 1000;\n\n/** trace-flags value with the sampled bit set. */\nexport const TRACE_FLAGS_SAMPLED = 1;\n\n/** Mask for the one-byte trace-flags field. */\nexport const TRACE_FLAGS_MASK = 0xff;\n\n/**\n * W3C trace context header name\n * @see {@link TRACEPARENT_VERSION}\n */\nexport const TRACEPARENT_HEADER = \"traceparent\";\n\n/** traceparent header version prefix. */\nexport const TRACEPARENT_VERSION = \"00\";\n\n// ----------------------------------\n// Breadcrumbs\n// ----------------------------------\n\n/** Smallest valid breadcrumb buffer capacity. */\nexport const BREADCRUMB_MIN_CAPACITY = 1;\n\n// ----------------------------------\n// Sampling\n// ----------------------------------\n//\n// FNV-1a hash constants. The sampler uses them to turn a sampling key into a\n// stable 0-1 fraction.\n\n/** FNV-1a 32-bit offset basis. */\nexport const FNV_OFFSET_BASIS = 0x811c9dc5;\n\n/** FNV-1a 32-bit prime. */\nexport const FNV_PRIME = 0x01000193;\n\n/** Largest 32-bit unsigned value. */\nexport const UINT32_MAX = 0xffffffff;\n\n/**\n * Types that minLevel never drops. An action is an audit fact, and a metric or a span is a\n * measurement. The remote rate cap for records below minLevel doesn't apply to them either.\n */\nexport const LEVEL_BYPASS_TYPES: readonly LogType[] = [\"action\", \"metric\", \"span\"];\n\n// ----------------------------------\n// Pipeline\n// ----------------------------------\n\n/** Record kind routed to the metric stream. */\nexport const LOG_TYPE_METRIC: LogType = \"metric\";\n\n/** Record kind of an audit fact. Storage and the hold buffers drop it last. */\nexport const LOG_TYPE_ACTION: LogType = \"action\";\n\n/** Record kind routed to the trace stream. */\nexport const LOG_TYPE_SPAN: LogType = \"span\";\n\n// ----------------------------------\n// Bus\n// ----------------------------------\n\n/** Protocol identifier for bus envelopes. The bus drops an envelope with a different version. */\nexport const BUS_PROTOCOL = \"ui-observability/2\";\n\n/**\n * Type tag for every bus message. Every frame must use the same values. The prefix makes a\n * message easy to spot in a postMessage log, but it is still the BUS_PROTOCOL envelope tag that\n * separates the bus from other traffic.\n */\nexport const BUS_TYPE = {\n hello: \"ui-observability.message.hello\",\n welcome: \"ui-observability.message.welcome\",\n records: \"ui-observability.message.records\",\n securityContext: \"ui-observability.message.security-context\",\n journey: \"ui-observability.message.journey\",\n journeyRequest: \"ui-observability.message.journey-request\",\n sampling: \"ui-observability.message.sampling\",\n samplingRequest: \"ui-observability.message.sampling-request\",\n tab: \"ui-observability.message.tab\",\n} as const;\n\n/** Global window property key used to locate a same-origin runtime instance. */\nexport const RUNTIME_GLOBAL_KEY = \"ui-observability.runtime\";\n\n/** Global key for the runtime shutdown() stopped. Calls go to it until the next configure(). */\nexport const RUNTIME_STOPPED_KEY = \"ui-observability.stopped\";\n\n/** Global symbol key for the library request scope count, shared by every copy on the page. */\nexport const LIBRARY_REQUEST_KEY = \"ui-observability.request-scope\";\n\n/** Global symbol key for the library console scope count, shared by every copy on the page. */\nexport const LIBRARY_CONSOLE_KEY = \"ui-observability.console-scope\";\n\n/** Global symbol key for the number of custom transport calls still waiting for an answer. */\nexport const TRANSPORT_CALL_KEY = \"ui-observability.transport-calls\";\n\n// ----------------------------------\n// Capture\n// ----------------------------------\n\n/** Maximum error records captured per throttling window before suppression. */\nexport const ERROR_STORM_MAX_PER_WINDOW = 20;\n\n/** Error rate-limiting window duration in milliseconds. */\nexport const ERROR_STORM_WINDOW_MS = 10_000;\n\n/**\n * Max ERROR and FATAL records the pipeline admits per storm window. This is a safety limit for\n * a render loop, not a way to shape normal traffic. ERROR and FATAL records skip sampling, so a\n * direct logger.error call has no other limit.\n */\nexport const ERROR_CEILING_MAX_PER_WINDOW = 500;\n\n/** Default minimum duration for a long frame to be recorded, in milliseconds. */\nexport const LONG_FRAME_THRESHOLD_MS = 100;\n\n/** Maximum long frames recorded per storm window, so a frozen tab can't flood the pipeline. */\nexport const LONG_FRAME_MAX_PER_WINDOW = 20;\n\n/** Max WebSocket events recorded per storm window, so a reconnect loop can't flood the pipeline. */\nexport const WEBSOCKET_MAX_PER_WINDOW = 20;\n\n/** Maximum character length of a console breadcrumb message. */\nexport const CONSOLE_BREADCRUMB_MAX_CHARS = 200;\n\n/** Maximum distinct error signatures tracked for deduplication before LRU eviction. */\nexport const MAX_TRACKED_ERROR_SIGNATURES = 200;\n\n/** Maximum characters of a clicked element's text kept in a breadcrumb. */\nexport const CLICK_TEXT_MAX_CHARS = 50;\n\n/** Attribute that names a click action, unless the app configures a different one. */\nexport const ACTION_ATTRIBUTE_DEFAULT = \"data-observability-action\";\n\n/** How many clicks on one element make a rage click, by default. */\nexport const RAGE_CLICK_COUNT = 3;\n\n/** The time window a rage click's clicks must fall within, in milliseconds, by default. */\nexport const RAGE_CLICK_WINDOW_MS = 1000;\n\n/** How long to wait for a visible response before a click counts as dead, in milliseconds. */\nexport const DEAD_CLICK_MS = 1000;\n\n/** Controls that should respond visibly to a click. Only these get a dead click check. */\nexport const DEAD_CLICK_CONTROLS =\n 'a, button, summary, input[type=\"button\"], input[type=\"submit\"], input[type=\"reset\"], [role=\"button\"], [role=\"link\"], [role=\"menuitem\"], [role=\"tab\"]';\n\n/** Maximum characters of an aria-label kept in a generated selector. */\nexport const ARIA_LABEL_MAX_CHARS = 40;\n\n/** Maximum class names per element in a generated CSS selector. */\nexport const SELECTOR_MAX_CLASSES = 2;\n\n/** Default CSS for the console prefix. The colors are readable in light and dark devtools. */\nexport const CONSOLE_DEFAULT_STYLES: Readonly<Required<ConsoleStyles>> = {\n namespace: \"color:#888\",\n TRACE: \"color:#888;font-weight:bold\",\n DEBUG: \"color:#888;font-weight:bold\",\n INFO: \"color:#1e6fd9;font-weight:bold\",\n WARN: \"color:#c77700;font-weight:bold\",\n ERROR: \"color:#d32f2f;font-weight:bold\",\n FATAL: \"color:#d32f2f;font-weight:bold\",\n};\n\n/** Scaling factor for rounding a duration to three decimal places. */\nexport const DURATION_PRECISION = 1000;\n\n// ----------------------------------\n// Runtime\n// ----------------------------------\n\n/** Minimum time between storage gap warning reports, in milliseconds. */\nexport const GAP_REPORT_THROTTLE_MS = 60_000;\n\n/** Default namespace for records the auto-capture modules emit. */\nexport const CAPTURE_NAMESPACE = \"uiobs.capture\";\n\n/** Default namespace for records the storage subsystems emit. */\nexport const STORAGE_NAMESPACE = \"uiobs.storage\";\n\n/** Namespace for the records `diagnostics.records` produces. */\nexport const DIAGNOSTICS_NAMESPACE = \"uiobs.diagnostics\";\n\n/** The measurement unit used when a call doesn't give one. */\nexport const DEFAULT_METRIC_UNIT = \"count\";\n\n/** Namespace for the points the counter and histogram instruments produce. */\nexport const METRIC_NAMESPACE = \"uiobs.metrics\";\n\n/** Maximum attribute sets per instrument per interval. Any more go into one overflow set. */\nexport const METRIC_MAX_SERIES = 100;\n\n/** Maximum bucket boundaries per histogram. More than that makes for a large point. */\nexport const METRIC_MAX_BOUNDARIES = 50;\n\n/** Attribute on the overflow set. OpenTelemetry uses the same key. */\nexport const ATTR_METRIC_OVERFLOW = \"otel.metric.overflow\";\n\n/** Default histogram boundaries, the same as OpenTelemetry's defaults. */\nexport const METRIC_DEFAULT_BOUNDARIES: readonly number[] = [\n 0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000,\n];\n\n/**\n * Attribute keys on an aggregated metric point, read by the OTLP metrics serializer.\n * Sampling keeps every record that has a start time, because sampling a sum gives a false sum.\n */\nexport const METRIC_KEYS = {\n start: \"metric.start_time_unix_nano\",\n attributeKeys: \"metric.attribute_keys\",\n count: \"metric.count\",\n sum: \"metric.sum\",\n min: \"metric.min\",\n max: \"metric.max\",\n bounds: \"metric.bounds\",\n buckets: \"metric.bucket_counts\",\n} as const;\n\n/** Precision of the profiler histogram: 2^4 = 16 sub-buckets per power of two. */\nexport const PROFILE_SUB_BITS = 4;\n\n/** Buckets per probe: 16 for 0 to 15 us, then 16 for each exponent from 4 to 25. */\nexport const PROFILE_BUCKETS = 368;\n\n/** Largest tracked duration in microseconds (2^26 - 1). Larger values go in the last bucket. */\nexport const PROFILE_MAX_US = 67_108_863;\n\n/** Cap on the buckets in one profiler summary record, to keep the payload small. */\nexport const PROFILE_POINT_BUCKETS = 100;\n\n/** Default interval between profiler summary records, in ms. */\nexport const PROFILER_FLUSH_INTERVAL_MS = 10_000;\n\n/** Default probe limit. The runtime fixes the limit at startup. */\nexport const PROFILER_MAX_PROBES = 64;\n\n/** Metric name for profiler summary records. */\nexport const PROFILE_METRIC_NAME = \"ui.profile.duration\";\n\n/** Attribute keys on profiler summary records. */\nexport const PROFILE_KEYS = {\n probe: \"profile.probe\",\n sampleEvery: \"profile.sample_every\",\n p50: \"profile.p50\",\n p90: \"profile.p90\",\n p99: \"profile.p99\",\n overhead: \"profile.overhead_ns\",\n selfP99: \"profile.self_p99\",\n framePhase: \"profile.frame_phase\",\n} as const;\n\n/** How deep spans can nest and still get a self time. Going deeper drops the frames below. */\nexport const PROFILER_STACK_DEPTH = 32;\n\n/** How many recent spans the profiler keeps for linking to long animation frames. */\nexport const PROFILER_RING_SPANS = 256;\n\n/** Shortest span, in ms, that gets linked to a long animation frame. */\nexport const PROFILER_LINK_MIN_MS = 1;\n\n/** Metric name for long animation frame phases, reported per probe in the frame. */\nexport const PROFILE_FRAME_METRIC_NAME = \"ui.profile.frame.duration\";\n\n/** Probe name for frame pacing. Each value is the time between two frames. */\nexport const PROFILE_FRAME_PROBE = \"frame.interval\";\n\n/** Reported when the library can't read an instrument's options. */\nexport const INSTRUMENT_OPTIONS_FAULT =\n \"The library could not read the options of an instrument. The library uses the defaults.\";\n\n/** Ambient attribute that ties every record to the session replay recording. */\nexport const REPLAY_ID_KEY = \"replay.id\";\n\n/** Put this attribute on an element to leave its text unmasked in session replay. */\nexport const REPLAY_UNMASK_ATTRIBUTE = \"data-observability-unmask\";\n\n/** Hard cap on registered probe names, and so the upper bound for profiler.maxProbes. */\nexport const PROFILER_PROBE_LIMIT = 1024;\n\n/** Global symbol key for the profiler core. Copies of the same library version share the core. */\nexport const PROFILER_GLOBAL_KEY = \"ui-observability.profiler\";\n\n/** Minimum window for the profiler's overhead measurement, in ms. */\nexport const PROFILER_CALIBRATION_MS = 2;\n\n/** Cap on begin()/end() pairs in the profiler's overhead measurement. */\nexport const PROFILER_CALIBRATION_PAIRS = 100_000;\n\n/** Namespace of the span records. */\nexport const TRACE_NAMESPACE = \"uiobs.traces\";\n\n/** Attribute keys for the span fields on a span record, read by the traces serializer. */\nexport const SPAN_KEYS = {\n kind: \"span.kind\",\n parentId: \"span.parent_id\",\n start: \"span.start_time_unix_nano\",\n end: \"span.end_time_unix_nano\",\n status: \"span.status\",\n linkTraceId: \"span.link.trace_id\",\n linkSpanId: \"span.link.span_id\",\n} as const;\n\n// ----------------------------------\n// Configuration\n// ----------------------------------\n\n/** Protocol for the private transport worker channel. */\nexport const TRANSPORT_WORKER_PROTOCOL = \"ui-observability.transport/1\";\n\n/** Type tags for the private transport worker messages. */\nexport const TRANSPORT_WORKER_TYPE = {\n connect: \"connect\",\n ready: \"ready\",\n send: \"send\",\n result: \"result\",\n cancel: \"cancel\",\n} as const;\n\n/** The worker entry's refusal message. A constant keeps the protocol code out of the main chunk. */\nexport const TRANSPORT_WORKER_REFUSAL = {\n p: TRANSPORT_WORKER_PROTOCOL,\n v: TELEMETRY_SDK_VERSION,\n t: TRANSPORT_WORKER_TYPE.ready,\n ok: false,\n} as const;\n\n/** Maximum requests in one transport worker. */\nexport const TRANSPORT_WORKER_MAX_JOBS = 64;\n\n/** Longest the deferred logger waits for idle time before it builds its records. */\nexport const DEFER_IDLE_TIMEOUT_MS = 1000;\n\n/** Maximum pending payload references per runtime. A full queue builds its records first. */\nexport const DEFER_QUEUE_LIMIT = 1000;\n\n/** Default minimum duration for a slow resource event, in milliseconds. */\nexport const RESOURCE_SLOW_MS = 1000;\n\n/** Response header with server duration entries. */\nexport const SERVER_TIMING_HEADER = \"Server-Timing\";\n\n/** Maximum Server-Timing header length and entry count. */\nexport const SERVER_TIMING_MAX_CHARS = 4096;\nexport const SERVER_TIMING_MAX_ENTRIES = 32;\n\n/** Capture switches a remote rule can change. Privacy controls stay local. */\nexport const REMOTE_CAPTURE_FLAGS = [\n \"errors\",\n \"rejections\",\n \"resourceErrors\",\n \"fetch\",\n \"xhr\",\n \"httpMetrics\",\n \"navigation\",\n \"webVitals\",\n \"longFrames\",\n \"interactions\",\n \"console\",\n \"webSocket\",\n \"uncleanExit\",\n \"userTiming\",\n \"serverTiming\",\n \"reports\",\n \"resourceTiming\",\n \"lifecycle\",\n] as const;\n\n/** Default `service.name` when a consumer sets none. */\nexport const UNKNOWN_SERVICE_NAME = \"unknown-service\";\n\n/** Lowest sampling rate (drop everything). */\nexport const SAMPLING_RATE_MIN = 0;\n\n/** Highest sampling rate (keep everything). */\nexport const SAMPLING_RATE_MAX = 1;\n\n/**\n * Fallback for an invalid sampling rate (keep everything).\n * @see {@link SAMPLING_RATE_MAX}\n */\nexport const SAMPLING_RATE_FALLBACK = 1;\n\n/** The remote sampling rules version this library accepts. */\nexport const REMOTE_SAMPLING_VERSION = 1;\n\n/** Maximum length of the sampling header, in characters. */\nexport const REMOTE_SAMPLING_MAX_CHARS = 4096;\n\n/** Longest that remote sampling rules stay in effect, in milliseconds. */\nexport const REMOTE_SAMPLING_MAX_TTL_MS = 60 * 60 * 1000;\n\n/** Maximum namespace rates in one set of remote sampling rules. */\nexport const REMOTE_SAMPLING_MAX_RATES = 100;\n\n/** How often a forwarder asks for the remote sampling rules, in milliseconds. */\nexport const REMOTE_SAMPLING_POLL_MS = 30_000;\n\n/**\n * Config keys with no default, excluded from `DEFAULT_CONFIG`.\n * @see {@link DEFAULT_CONFIG}\n */\nexport const UNDEFAULTED_CONFIG_KEYS = [\n \"contextProvider\",\n \"redact\",\n \"onDiagnostic\",\n \"onDrop\",\n \"headers\",\n \"serializer\",\n \"otelLoader\",\n \"transport\",\n \"transportOnExit\",\n \"transportWorker\",\n] as const;\n\n/**\n * Nested config section keys.\n * @see {@link ResolvedConfig}\n */\nexport const CONFIG_SECTIONS = [\n \"capturePolicy\",\n \"metadata\",\n \"persistence\",\n \"diagnostics\",\n \"correlation\",\n \"metrics\",\n \"buffering\",\n \"delivery\",\n \"loggerCache\",\n \"securityContext\",\n \"sampling\",\n \"bus\",\n \"journey\",\n \"batching\",\n \"retention\",\n \"limits\",\n \"capture\",\n \"debugBuffer\",\n \"profiler\",\n \"replay\",\n] as const;\n\n/**\n * Section keys with no default, excluded from their section of `DEFAULT_CONFIG`.\n * @see {@link UNDEFAULTED_CONFIG_KEYS}\n */\nexport const UNDEFAULTED_SECTION_KEYS: Record<(typeof CONFIG_SECTIONS)[number], string[]> = {\n capturePolicy: [],\n metadata: [],\n persistence: [],\n diagnostics: [],\n correlation: [],\n metrics: [],\n buffering: [],\n delivery: [],\n loggerCache: [],\n securityContext: [],\n sampling: [],\n bus: [],\n journey: [],\n batching: [],\n retention: [],\n limits: [],\n capture: [\"webVitalsLoader\", \"urlTransform\"],\n debugBuffer: [],\n profiler: [],\n replay: [],\n};\n\n/** Console mirroring level used when a consumer passes `console: true`. */\nexport const CONSOLE_DEFAULT_LEVEL: LogLevel = \"DEBUG\";\n\n// ----------------------------------\n// Batching\n// ----------------------------------\n\n/** Max time a partial log batch waits before the pipeline sends it, in milliseconds. */\nexport const LOG_FLUSH_INTERVAL_MS = 2000;\n\n/** Max records per log batch. At this count, the pipeline sends the batch early. */\nexport const LOG_BATCH_SIZE = 100;\n\n/**\n * Max time a partial metric batch waits before the pipeline sends it, in milliseconds.\n * Metric batches wait longer than log batches because metrics have a higher volume and\n * no caller is waiting for them.\n */\nexport const METRIC_FLUSH_INTERVAL_MS = 10_000;\n\n/** Max records per metric batch. At this count, the pipeline sends the batch early. */\nexport const METRIC_BATCH_SIZE = 500;\n\n/** Max concurrent ingest requests, across both streams. */\nexport const MAX_CONCURRENT_REQUESTS = 2;\n\n// ----------------------------------\n// HTTP transport\n// ----------------------------------\n\n/** Max time for one ingest request, in milliseconds. The transport then aborts and retries it. */\nexport const REQUEST_TIMEOUT_MS = 15_000;\n\n/** Min payload size to compress, in bytes. */\nexport const COMPRESSION_THRESHOLD_BYTES = 1024;\n\n// ----------------------------------\n// Storage retention\n// ----------------------------------\n\n/** IndexedDB database name. */\nexport const STORAGE_DB_NAME = \"UiObservability\";\n\n/** Capacity and retention thresholds every storage adapter enforces. */\nexport const STORAGE_LIMITS: StorageLimits = {\n maxBatches: 500,\n maxAgeMs: 24 * 60 * 60 * 1000,\n maxAttempts: 5,\n};\n\n/**\n * Max time for one storage call, in milliseconds. After that the call counts as failed, because\n * a call that never settles would hold on to a dispatch slot or the drain flag.\n */\nexport const STORAGE_DEADLINE_MS = 10_000;\n\n// ----------------------------------\n// Retry backoff\n// ----------------------------------\n\n/** First backoff step, in milliseconds. Doubles with every attempt. */\nexport const RETRY_BASE_DELAY_MS = 2000;\n\n/** Backoff ceiling, in milliseconds. */\nexport const RETRY_MAX_DELAY_MS = 60_000;\n\n/** How often to check for stored work when nothing has failed recently, in milliseconds. */\nexport const RETRY_IDLE_DELAY_MS = 30_000;\n\n// ----------------------------------\n// Journey lifetime\n// ----------------------------------\n\n/** Max time a journey stays open, in milliseconds. After that it counts as abandoned. */\nexport const JOURNEY_MAX_AGE_MS = 30 * 60 * 1000;\n\n/** True if the journey ends for all contexts when the owning context closes. */\nexport const JOURNEY_END_ON_OWNER_CLOSE = false;\n\n/** Query parameter checked at boot for a seeded journey token. */\nexport const JOURNEY_URL_PARAM = \"__uiobs_journey\";\n\n// ----------------------------------\n// Bus handshake\n// ----------------------------------\n\n/** BroadcastChannel name for the control plane. */\nexport const BUS_CHANNEL_NAME = \"ui_observability_control\";\n\n/** Max time a forwarder waits for an owner to answer before it promotes itself, in milliseconds. */\nexport const BUS_HANDSHAKE_TIMEOUT_MS = 1500;\n\n/** Handshake attempts allowed before a cross-origin forwarder promotes itself to sender. */\nexport const BUS_MAX_HANDSHAKE_ATTEMPTS = 3;\n\n/** Max non-action records in one hold buffer. A full buffer drops the oldest. */\nexport const BUS_MAX_BOOT_BUFFER_RECORDS = 500;\n\n/** Max action records in one hold buffer. Their own cap means a log storm can't push one out. */\nexport const BUS_MAX_BOOT_BUFFER_ACTIONS = 2000;\n\n/** Max distinct values in each list of an onDrop summary. */\nexport const DROP_SUMMARY_MAX_ITEMS = 20;\n\n/**\n * Max characters of an untrusted message type in a diagnostic detail, since the sender controls\n * that text. The longest BUS_TYPE value is 41 characters, so every valid type fits.\n */\nexport const BUS_TYPE_DETAIL_MAX_CHARS = 48;\n\n// ----------------------------------\n// Capture\n// ----------------------------------\n\n/** Breadcrumbs kept as context for the next error. */\nexport const MAX_BREADCRUMBS = 50;\n\n/** How long identical errors are counted without being sent again, in milliseconds. */\nexport const ERROR_DEDUPE_MS = 5000;\n\n// ----------------------------------\n// Per-record size caps\n// ----------------------------------\n\n/** Size caps for every record, applied after sanitize and after redact. */\nexport const RECORD_LIMITS = {\n maxBodyChars: 4096,\n maxAttributeChars: 8192,\n maxAttributeCount: 128,\n maxStackChars: 8192,\n maxDepth: 6,\n maxArrayLength: 100,\n maxNodes: 10_000,\n maxRecordBytes: 32_768,\n};\n\n// ----------------------------------\n// Config defaults\n// ----------------------------------\n\n/**\n * The default runtime config, before the consumer calls `configure()`. `serializer` is left\n * out, because `resolveConfig` supplies that default to avoid a circular import.\n * This sits below the constants it reads, since a const can't be read before its own line.\n * @see {@link ResolvedConfig}\n * @see {@link UNDEFAULTED_CONFIG_KEYS}\n */\nexport const DEFAULT_CONFIG: Omit<ResolvedConfig, \"serializer\"> = {\n capturePolicy: {\n breadcrumbs: MAX_BREADCRUMBS,\n errorDedupeMs: ERROR_DEDUPE_MS,\n maxErrorSignatures: MAX_TRACKED_ERROR_SIGNATURES,\n errorsPerWindow: 20,\n consolePerWindow: 20,\n longFramesPerWindow: 20,\n webSocketPerWindow: 20,\n reportsPerWindow: 20,\n resourcesPerWindow: 100,\n lifecyclePerWindow: 20,\n windowMs: 10000,\n errorCeiling: ERROR_CEILING_MAX_PER_WINDOW,\n },\n metadata: { pageUrl: true, userAgent: true, openfin: true, clockOffset: true },\n debugBuffer: { enabled: false, maxRecords: 200, maxAgeMs: 60_000 },\n profiler: {\n enabled: false,\n flushIntervalMs: PROFILER_FLUSH_INTERVAL_MS,\n maxProbes: PROFILER_MAX_PROBES,\n framePhases: false,\n framePacing: false,\n },\n replay: {\n enabled: false,\n mode: \"onError\",\n endpoint: \"\",\n requireConsent: false,\n bufferMs: 60_000,\n maxBufferBytes: 10_000_000,\n afterErrorMs: 5000,\n uploadsPerWindow: 3,\n batchSize: 200,\n batchBytes: 512_000,\n flushIntervalMs: 2000,\n maxQueueBytes: 20_000_000,\n maxAttempts: 3,\n maskText: true,\n maskInputs: true,\n recordCanvas: false,\n maskSelectors: [],\n blockSelectors: [],\n loader: null,\n onSegment: null,\n headers: null,\n plugins: [],\n recordOptions: {},\n },\n persistence: { namespace: \"\", requestPersistent: false },\n diagnostics: { throttleMs: 1000, consoleFallback: false, records: false },\n correlation: {\n sessionIdleMs: SESSION_IDLE_MS,\n sessionTouchMs: SESSION_TOUCH_MS,\n traceMaxAgeMs: TRACE_MAX_AGE_MS,\n },\n metrics: {\n maxSeries: METRIC_MAX_SERIES,\n maxInstruments: 1000,\n maxHistogramBoundaries: METRIC_MAX_BOUNDARIES,\n },\n buffering: { maxPendingRecords: 10000, maxPendingBytes: 16777216, overflow: \"drop-oldest\" },\n delivery: {\n requestTimeoutMs: REQUEST_TIMEOUT_MS,\n maxConcurrentRequests: MAX_CONCURRENT_REQUESTS,\n retryBaseDelayMs: RETRY_BASE_DELAY_MS,\n retryMaxDelayMs: RETRY_MAX_DELAY_MS,\n retryIdleDelayMs: RETRY_IDLE_DELAY_MS,\n batchesPerDrain: BATCHES_PER_DRAIN,\n priority: \"low\",\n },\n lockConfiguration: false,\n loggerCache: { maxEntries: 256 },\n securityContext: { id: \"\", isolation: true },\n endpoint: \"\",\n metricsEndpoint: \"\",\n tracesEndpoint: \"\",\n serviceName: \"\",\n serviceVersion: \"\",\n environment: \"\",\n enabled: true,\n payloadMode: \"copy\",\n minLevel: \"INFO\",\n minLevels: {},\n processors: [],\n compression: \"gzip\",\n credentials: \"omit\",\n storage: \"auto\",\n identity: \"storage\",\n sampling: {\n defaultRate: 1,\n rates: {},\n alwaysSampleTypes: [\"action\"],\n alwaysSampleFrom: \"ERROR\",\n remote: false,\n remoteMaxRate: 1,\n },\n bus: {\n mode: \"auto\",\n trustedOrigins: [],\n openFinRole: \"auto\",\n sourcePolicy: \"registered\",\n validation: \"strict\",\n maxMessageBytes: 262144,\n maxRecordsPerMessage: 100,\n maxMessagesPerSecond: 100,\n maxTrackedSources: 256,\n },\n journey: { scope: \"auto\", maxAgeMs: JOURNEY_MAX_AGE_MS },\n batching: {\n logFlushIntervalMs: LOG_FLUSH_INTERVAL_MS,\n logBatchSize: LOG_BATCH_SIZE,\n metricFlushIntervalMs: METRIC_FLUSH_INTERVAL_MS,\n metricBatchSize: METRIC_BATCH_SIZE,\n },\n retention: { mode: \"limited\", ...STORAGE_LIMITS },\n limits: { ...RECORD_LIMITS },\n capture: {\n errors: true,\n rejections: true,\n resourceErrors: false,\n fetch: false,\n xhr: false,\n httpMetrics: true,\n interactions: false,\n navigation: false,\n webVitals: false,\n longFrames: false,\n longFrameMs: LONG_FRAME_THRESHOLD_MS,\n console: false,\n fullUrls: false,\n ignoreUrls: [],\n propagateTraceHeaderTo: [],\n webSocket: false,\n uncleanExit: false,\n userTiming: false,\n remoteToggles: [],\n serverTiming: false,\n reports: false,\n resourceTiming: false,\n lifecycle: false,\n userTimingInclude: [],\n plugins: [],\n },\n console: { level: null, styles: CONSOLE_DEFAULT_STYLES },\n};\n"],"mappings":"AAcA,IA6BaA,EAAkB,KAGlBC,EAAmB,IAanBC,GAAqB,WAGrBC,EAA6B,SAG7BC,GAAwB,yBAGxBC,GAAuB,gBAGvBC,GAAoB,aAqDpBC,EAA4C,CACvD,MAAO,EACP,MAAO,EACP,KAAM,EACN,KAAM,GACN,MAAO,GACP,MAAO,EACT,EAMaC,GAAwCD,EAUxCE,GAAgB,WAGhBC,GAAe,UAGfC,GAAqB,gBAGrBC,GAAgB,WAOhBC,EAAgB,WAGhBC,EAAkB,aAGlBC,EAAoB,eAGpBC,EAAyB,oBAGzBC,EAAuB,wBAGvBC,EAAkB,aAGlBC,EAAmB,cAMnBC,EAA0B,2BAM1BC,EAAwB,yBAGxBC,EAAuB,wBAGvBC,EAAoB,qBAMpBC,EAAwB,eAGxBC,EAA2B,kBAG3BC,EAAkC,yBAMlCC,EAA8B,qBAM9BC,EAAiC,wBAMjCC,EAAkC,yBAGlCC,EAAyB,gBAGzBC,EAAsB,aAGtBC,EAAkB,SAGlBC,EAAsB,aAGtBC,EAA8B,qBAG9BC,EAAwB,eAGxBC,EAAwB,eAMxBC,EAAqB,0BAMrBC,EAAA,SAMAC,EAAyB,QAOzBC,EAAuB,OAUvBC,EAAqD,CAAE,KAAM,SAAU,EAGvEC,EAAc,SAGdC,EAAoB,mBAGpBC,EAAsB,uBAGtBC,EAAkB,SAMlBC,EAAgB,QAOhBC,EAAsB,eAGtBC,EAA0B,mBAG1BC,EAAqB,cAMrBC,EAAkB,mBAGlBC,EAAiB,kBAGjBC,EAAkB,mBAGlBC,EAAc,OAGdC,EAAgB,OAoChBC,GAAoB,IAOpBC,GAAqB,IAGrBC,GAA0B,2BAM1BC,GAAuB,iBAGvBC,GAA0B,aAO1BC,GAA2B,0BAM3BC,GAA+B,8BAM/BC,GAAoB,yB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AAgB,GAChB,MAAO,GACP,IAAK,GACL,YAAa,GACb,aAAc,GACd,WAAY,GACZ,UAAW,GACX,WAAY,GACZ,YAAA,IACA,QAAS,GACT,SAAU,GACV,WAAY,CAAC,EACb,uBAAwB,CAAC,EACzB,UAAW,GACX,YAAa,GACb,WAAY,GACZ,cAAe,CAAC,EAChB,aAAc,GACd,QAAS,GACT,eAAgB,GAChB,UAAW,GACX,kBAAmB,CAAC,EACpB,QAAS,CAAC,CACZ,EACA,QAAS,CAAE,MAAO,KAAM,OAAQ1D,CAAuB,CACzD,E"}
@@ -1,2 +0,0 @@
1
- var e=class{store;policy;namespace;name;active=!0;discard=!1;constructor(e,t,n=``){this.store=e,this.policy=t,this.namespace=n,this.name=e.name}accepts(e){return(e.persistenceNamespace??``)===this.namespace&&(!this.policy.isolation||!this.policy.id||e.routingContextId===this.policy.id)}async save(e){this.active&&this.accepts(e)&&(await this.store.save(e),this.discard&&await this.store.remove(e.id))}async take(e){return this.isolated()?this.store.takeContext?this.store.takeContext(this.policy.id,e):(await this.store.take(4294967295)).filter(e=>this.accepts(e)).slice(0,e):(await this.store.take(e)).filter(e=>this.accepts(e))}isolated(){return this.policy.isolation&&this.policy.id!==``}remove(e){return this.store.remove(e)}bumpAttempts(e,t){return this.store.bumpAttempts(e,t)}prune(){return this.store.prune()}async count(){return this.isolated()?this.store.countContext?this.store.countContext(this.policy.id):(await this.take(2**53-1)).length:this.store.count()}async clear(){for(let e of await this.take(2**53-1))await this.store.remove(e.id)}async retire(e){this.active=!1,this.discard=e,e&&await this.clear(),this.name!==`memory`&&await this.close()}clearNamespace(){return this.store.clear()}close(){return this.store.close()}};exports.ContextStorage=e;
2
- //# sourceMappingURL=context-storage-BjzeBSxH.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-storage-BjzeBSxH.cjs","names":["ContextStorage","store","policy","namespace","batch","limit","id","attempts","discard"],"sources":["../src/storage/context-storage.ts"],"sourcesContent":["// src/storage/context-storage.ts\n//\n// Scopes the shared batch store to one delivery context and one application namespace.\n\nimport type { SecurityContextOptions } from \"../models/config\";\nimport type { LogBatch } from \"../models/batch\";\nimport type { StorageAdapter } from \"../models/storage\";\n\n/** A view of one slice of the shared store. Other contexts' records are left alone. */\nexport class ContextStorage implements StorageAdapter {\n /** Name of the underlying adapter. */\n readonly name: string;\n /** False once this context store stops accepting writes. */\n private active = true;\n /** True if a late save has to remove its batch once it finishes. */\n private discard = false;\n\n /**\n * Scopes a store to one application namespace and delivery context.\n * @param store The underlying batch store.\n * @param policy The active context id and the isolation rule.\n * @param namespace The application's storage namespace.\n */\n constructor(\n private readonly store: StorageAdapter,\n private readonly policy: SecurityContextOptions,\n readonly namespace = \"\",\n ) {\n this.name = store.name;\n }\n\n /**\n * Checks whether a batch belongs to this namespace and context.\n * @param batch The batch to check.\n * @returns True if this adapter can accept the batch.\n */\n accepts(batch: LogBatch): boolean {\n return (\n (batch.persistenceNamespace ?? \"\") === this.namespace &&\n (!this.policy.isolation || !this.policy.id || batch.routingContextId === this.policy.id)\n );\n }\n\n /**\n * Stores a batch for this context. After a discard, a late save removes its own batch again.\n * @param batch The batch to store.\n * @returns A promise that resolves once the save, and any removal, is done.\n */\n async save(batch: LogBatch): Promise<void> {\n if (!this.active || !this.accepts(batch)) return;\n await this.store.save(batch);\n // A slow save can finish after the context change already cleared these records.\n if (this.discard) await this.store.remove(batch.id);\n }\n\n /**\n * Reads this context's stored batches, oldest first.\n * @param limit Maximum number of batches to return.\n * @returns The batches in creation order. They are not removed.\n */\n async take(limit: number): Promise<LogBatch[]> {\n // Read only this context's slice. A full read on every retry pass would parse all contexts.\n if (!this.isolated()) {\n return (await this.store.take(limit)).filter((batch) => this.accepts(batch));\n }\n\n if (this.store.takeContext) {\n return this.store.takeContext(this.policy.id, limit);\n }\n\n const all = await this.store.take(0xffffffff);\n return all.filter((batch) => this.accepts(batch)).slice(0, limit);\n }\n\n /**\n * Checks whether reads are limited to the active context.\n * @returns True if isolation is on and the context has an id.\n */\n private isolated(): boolean {\n return this.policy.isolation && this.policy.id !== \"\";\n }\n\n /**\n * Removes one stored batch.\n * @param id Batch id.\n * @returns A promise that resolves once the batch is removed.\n */\n remove(id: string): Promise<void> {\n return this.store.remove(id);\n }\n\n /**\n * Updates a stored batch's attempt count.\n * @param id Batch id.\n * @param attempts The total attempt count to store.\n * @returns A promise that resolves once the change is saved.\n */\n bumpAttempts(id: string, attempts: number): Promise<void> {\n return this.store.bumpAttempts(id, attempts);\n }\n\n /**\n * Applies the underlying store's retention and capacity limits.\n * @returns A summary of the batches and records it removed.\n */\n prune(): ReturnType<StorageAdapter[\"prune\"]> {\n return this.store.prune();\n }\n\n /**\n * Counts this context's stored batches.\n * @returns The number of batches in this context.\n */\n async count(): Promise<number> {\n if (!this.isolated()) {\n return this.store.count();\n }\n\n if (this.store.countContext) {\n return this.store.countContext(this.policy.id);\n }\n\n return (await this.take(Number.MAX_SAFE_INTEGER)).length;\n }\n\n /**\n * Removes this context's stored batches.\n * @returns A promise that resolves once they are removed.\n */\n async clear(): Promise<void> {\n for (const batch of await this.take(Number.MAX_SAFE_INTEGER)) await this.store.remove(batch.id);\n }\n\n /**\n * Stops new writes and, if asked, clears this context. The memory store is left open for\n * other contexts.\n * @param discard True to remove this context's batches before closing the store.\n * @returns A promise that resolves once the removal and the close are done.\n */\n async retire(discard: boolean): Promise<void> {\n this.active = false;\n this.discard = discard;\n if (discard) await this.clear();\n // Keep the memory store around for later context changes. It may hold other contexts' records.\n if (this.name !== \"memory\") await this.close();\n }\n\n /**\n * Removes every batch in the application namespace.\n * @returns A promise that resolves once they are removed.\n */\n clearNamespace(): Promise<void> {\n return this.store.clear();\n }\n\n /**\n * Closes the underlying store.\n * @returns A promise that resolves once it is closed.\n */\n close(): Promise<void> {\n return this.store.close();\n }\n}\n"],"mappings":"AASA,IAAaA,EAAb,KAAsD,CAejC,MACA,OACR,UAfX,KAEA,OAAiB,GAEjB,QAAkB,GAQlB,YACE,EACA,EACA,EAAqB,GACrB,CAH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MAAM,KAAK,MAAM,OAAOA,EAAM,EAAE,CAChG,CAQA,MAAM,OAAO,EAAiC,CAC5C,KAAK,OAAS,GACd,KAAK,QAAUI,EACXA,GAAS,MAAM,KAAK,MAAM,EAE1B,KAAK,OAAS,UAAU,MAAM,KAAK,MAAM,CAC/C,CAMA,gBAAgC,CAC9B,OAAO,KAAK,MAAM,MAAM,CAC1B,CAMA,OAAuB,CACrB,OAAO,KAAK,MAAM,MAAM,CAC1B,CACF,E"}
@@ -1,51 +0,0 @@
1
- // src/storage/context-storage.ts
2
- var e = class {
3
- store;
4
- policy;
5
- namespace;
6
- name;
7
- active = !0;
8
- discard = !1;
9
- constructor(e, t, n = "") {
10
- this.store = e, this.policy = t, this.namespace = n, this.name = e.name;
11
- }
12
- accepts(e) {
13
- return (e.persistenceNamespace ?? "") === this.namespace && (!this.policy.isolation || !this.policy.id || e.routingContextId === this.policy.id);
14
- }
15
- async save(e) {
16
- this.active && this.accepts(e) && (await this.store.save(e), this.discard && await this.store.remove(e.id));
17
- }
18
- async take(e) {
19
- return this.isolated() ? this.store.takeContext ? this.store.takeContext(this.policy.id, e) : (await this.store.take(4294967295)).filter((e) => this.accepts(e)).slice(0, e) : (await this.store.take(e)).filter((e) => this.accepts(e));
20
- }
21
- isolated() {
22
- return this.policy.isolation && this.policy.id !== "";
23
- }
24
- remove(e) {
25
- return this.store.remove(e);
26
- }
27
- bumpAttempts(e, t) {
28
- return this.store.bumpAttempts(e, t);
29
- }
30
- prune() {
31
- return this.store.prune();
32
- }
33
- async count() {
34
- return this.isolated() ? this.store.countContext ? this.store.countContext(this.policy.id) : (await this.take(2 ** 53 - 1)).length : this.store.count();
35
- }
36
- async clear() {
37
- for (let e of await this.take(2 ** 53 - 1)) await this.store.remove(e.id);
38
- }
39
- async retire(e) {
40
- this.active = !1, this.discard = e, e && await this.clear(), this.name !== "memory" && await this.close();
41
- }
42
- clearNamespace() {
43
- return this.store.clear();
44
- }
45
- close() {
46
- return this.store.close();
47
- }
48
- };
49
- export { e as ContextStorage };
50
-
51
- //# sourceMappingURL=context-storage-BzkoHzkQ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-storage-BzkoHzkQ.js","names":["ContextStorage","store","policy","namespace","batch","limit","id","attempts","discard"],"sources":["../src/storage/context-storage.ts"],"sourcesContent":["// src/storage/context-storage.ts\n//\n// Scopes the shared batch store to one delivery context and one application namespace.\n\nimport type { SecurityContextOptions } from \"../models/config\";\nimport type { LogBatch } from \"../models/batch\";\nimport type { StorageAdapter } from \"../models/storage\";\n\n/** A view of one slice of the shared store. Other contexts' records are left alone. */\nexport class ContextStorage implements StorageAdapter {\n /** Name of the underlying adapter. */\n readonly name: string;\n /** False once this context store stops accepting writes. */\n private active = true;\n /** True if a late save has to remove its batch once it finishes. */\n private discard = false;\n\n /**\n * Scopes a store to one application namespace and delivery context.\n * @param store The underlying batch store.\n * @param policy The active context id and the isolation rule.\n * @param namespace The application's storage namespace.\n */\n constructor(\n private readonly store: StorageAdapter,\n private readonly policy: SecurityContextOptions,\n readonly namespace = \"\",\n ) {\n this.name = store.name;\n }\n\n /**\n * Checks whether a batch belongs to this namespace and context.\n * @param batch The batch to check.\n * @returns True if this adapter can accept the batch.\n */\n accepts(batch: LogBatch): boolean {\n return (\n (batch.persistenceNamespace ?? \"\") === this.namespace &&\n (!this.policy.isolation || !this.policy.id || batch.routingContextId === this.policy.id)\n );\n }\n\n /**\n * Stores a batch for this context. After a discard, a late save removes its own batch again.\n * @param batch The batch to store.\n * @returns A promise that resolves once the save, and any removal, is done.\n */\n async save(batch: LogBatch): Promise<void> {\n if (!this.active || !this.accepts(batch)) return;\n await this.store.save(batch);\n // A slow save can finish after the context change already cleared these records.\n if (this.discard) await this.store.remove(batch.id);\n }\n\n /**\n * Reads this context's stored batches, oldest first.\n * @param limit Maximum number of batches to return.\n * @returns The batches in creation order. They are not removed.\n */\n async take(limit: number): Promise<LogBatch[]> {\n // Read only this context's slice. A full read on every retry pass would parse all contexts.\n if (!this.isolated()) {\n return (await this.store.take(limit)).filter((batch) => this.accepts(batch));\n }\n\n if (this.store.takeContext) {\n return this.store.takeContext(this.policy.id, limit);\n }\n\n const all = await this.store.take(0xffffffff);\n return all.filter((batch) => this.accepts(batch)).slice(0, limit);\n }\n\n /**\n * Checks whether reads are limited to the active context.\n * @returns True if isolation is on and the context has an id.\n */\n private isolated(): boolean {\n return this.policy.isolation && this.policy.id !== \"\";\n }\n\n /**\n * Removes one stored batch.\n * @param id Batch id.\n * @returns A promise that resolves once the batch is removed.\n */\n remove(id: string): Promise<void> {\n return this.store.remove(id);\n }\n\n /**\n * Updates a stored batch's attempt count.\n * @param id Batch id.\n * @param attempts The total attempt count to store.\n * @returns A promise that resolves once the change is saved.\n */\n bumpAttempts(id: string, attempts: number): Promise<void> {\n return this.store.bumpAttempts(id, attempts);\n }\n\n /**\n * Applies the underlying store's retention and capacity limits.\n * @returns A summary of the batches and records it removed.\n */\n prune(): ReturnType<StorageAdapter[\"prune\"]> {\n return this.store.prune();\n }\n\n /**\n * Counts this context's stored batches.\n * @returns The number of batches in this context.\n */\n async count(): Promise<number> {\n if (!this.isolated()) {\n return this.store.count();\n }\n\n if (this.store.countContext) {\n return this.store.countContext(this.policy.id);\n }\n\n return (await this.take(Number.MAX_SAFE_INTEGER)).length;\n }\n\n /**\n * Removes this context's stored batches.\n * @returns A promise that resolves once they are removed.\n */\n async clear(): Promise<void> {\n for (const batch of await this.take(Number.MAX_SAFE_INTEGER)) await this.store.remove(batch.id);\n }\n\n /**\n * Stops new writes and, if asked, clears this context. The memory store is left open for\n * other contexts.\n * @param discard True to remove this context's batches before closing the store.\n * @returns A promise that resolves once the removal and the close are done.\n */\n async retire(discard: boolean): Promise<void> {\n this.active = false;\n this.discard = discard;\n if (discard) await this.clear();\n // Keep the memory store around for later context changes. It may hold other contexts' records.\n if (this.name !== \"memory\") await this.close();\n }\n\n /**\n * Removes every batch in the application namespace.\n * @returns A promise that resolves once they are removed.\n */\n clearNamespace(): Promise<void> {\n return this.store.clear();\n }\n\n /**\n * Closes the underlying store.\n * @returns A promise that resolves once it is closed.\n */\n close(): Promise<void> {\n return this.store.close();\n }\n}\n"],"mappings":";AASA,IAAaA,IAAb,MAAsD;CAejC;CACA;CACR;CAfX;CAEA,SAAiB;CAEjB,UAAkB;CAQlB,YACE,GACA,GACA,IAAqB,IACrB;EACA,AAJiB,KAAA,QAAAC,GACA,KAAA,SAAAC,GACR,KAAA,YAAAC,GAET,KAAK,OAAOF,EAAM;CACpB;CAOA,QAAQ,GAA0B;EAChC,QACGG,EAAM,wBAAwB,QAAQ,KAAK,cAC3C,CAAC,KAAK,OAAO,aAAa,CAAC,KAAK,OAAO,MAAMA,EAAM,qBAAqB,KAAK,OAAO;CAEzF;CAOA,MAAM,KAAK,GAAgC;EACzC,AAAK,KAAK,UAAW,KAAK,QAAQA,CAAK,MACvC,MAAM,KAAK,MAAM,KAAKA,CAAK,GAEvB,KAAK,WAAS,MAAM,KAAK,MAAM,OAAOA,EAAM,EAAE;CACpD;CAOA,MAAM,KAAK,GAAoC;EAW7C,OATK,KAAK,SAAS,IAIf,KAAK,MAAM,cACN,KAAK,MAAM,YAAY,KAAK,OAAO,IAAIC,CAAK,KAI9C,MADW,KAAK,MAAM,KAAK,UAAU,EAAA,CACjC,QAAQ,MAAU,KAAK,QAAQD,CAAK,CAAC,CAAC,CAAC,MAAM,GAAGC,CAAK,KARtD,MAAM,KAAK,MAAM,KAAKA,CAAK,EAAA,CAAG,QAAQ,MAAU,KAAK,QAAQD,CAAK,CAAC;CAS/E;CAMA,WAA4B;EAC1B,OAAO,KAAK,OAAO,aAAa,KAAK,OAAO,OAAO;CACrD;CAOA,OAAO,GAA2B;EAChC,OAAO,KAAK,MAAM,OAAOE,CAAE;CAC7B;CAQA,aAAa,GAAY,GAAiC;EACxD,OAAO,KAAK,MAAM,aAAaA,GAAIC,CAAQ;CAC7C;CAMA,QAA6C;EAC3C,OAAO,KAAK,MAAM,MAAM;CAC1B;CAMA,MAAM,QAAyB;EAS7B,OARK,KAAK,SAAS,IAIf,KAAK,MAAM,eACN,KAAK,MAAM,aAAa,KAAK,OAAO,EAAE,KAGvC,MAAM,KAAK,gBAA4B,EAAA,CAAG,SAPzC,KAAK,MAAM,MAAM;CAQ5B;CAMA,MAAM,QAAuB;EAC3B,KAAK,IAAMH,KAAS,MAAM,KAAK,gBAA4B,GAAG,MAAM,KAAK,MAAM,OAAOA,EAAM,EAAE;CAChG;CAQA,MAAM,OAAO,GAAiC;EAK5C,AAJA,KAAK,SAAS,IACd,KAAK,UAAUI,GACXA,KAAS,MAAM,KAAK,MAAM,GAE1B,KAAK,SAAS,YAAU,MAAM,KAAK,MAAM;CAC/C;CAMA,iBAAgC;EAC9B,OAAO,KAAK,MAAM,MAAM;CAC1B;CAMA,QAAuB;EACrB,OAAO,KAAK,MAAM,MAAM;CAC1B;AACF"}
@@ -1,32 +0,0 @@
1
- import { t as e } from "./guards-Cidk71ME.js";
2
- import { i as t } from "./platform-CVewe4wQ.js";
3
- import { n } from "./sanitize-CNmsD9r3.js";
4
- // src/core/debug-bundle.ts
5
- function r(n) {
6
- return typeof n == "string" ? /^[a-z][a-z\d+.-]*:\/\//i.test(n) ? t(n, !1) : n : Array.isArray(n) ? n.map(r) : e(n) ? Object.fromEntries(Object.entries(n).map(([e, t]) => [e, r(t)])) : n;
7
- }
8
- function i(e, i, a) {
9
- let o = (e) => typeof e == "string" ? t(e, !1) : e, { capture: s, serializer: c } = e, l = {
10
- ...e,
11
- endpoint: o(e.endpoint),
12
- metricsEndpoint: o(e.metricsEndpoint),
13
- tracesEndpoint: o(e.tracesEndpoint),
14
- serializer: typeof c == "string" ? c : c.name,
15
- capture: {
16
- ...s,
17
- ignoreUrls: s.ignoreUrls.map(o),
18
- plugins: s.plugins.map((e) => e.name)
19
- },
20
- replay: {
21
- ...e.replay,
22
- endpoint: o(e.replay.endpoint),
23
- headers: e.replay.headers !== null,
24
- plugins: e.replay.plugins.length,
25
- recordOptions: Object.keys(e.replay.recordOptions)
26
- }
27
- };
28
- return Reflect.deleteProperty(l, "headers"), r(n(l, i, a));
29
- }
30
- export { i as configSummary };
31
-
32
- //# sourceMappingURL=debug-bundle-BOdYmCeV.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debug-bundle-BOdYmCeV.js","names":["isObject","recordedUrl","stripUrls","value","key","entry","configSummary","cut","config","copy","serializer","capture","plugin","sanitize","limits","diagnostics"],"sources":["../src/core/debug-bundle.ts"],"sourcesContent":["// src/core/debug-bundle.ts\n//\n// Builds the config summary for a debug bundle. The runtime loads this module only when the\n// app asks for a bundle.\n\nimport type { ResolvedConfig } from \"../models/config\";\nimport { isObject } from \"../utils/guards\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { sanitize, type SanitizeLimits } from \"../utils/sanitize\";\nimport type { Diagnostics } from \"./diagnostics\";\n\n/**\n * Strips the user info, query and fragment from every absolute URL in a JSON-safe value. The\n * endpoints also end up in `capture.ignoreUrls`, where the library puts them.\n * @param value JSON-safe value.\n * @returns The value with every URL trimmed.\n */\nfunction stripUrls(value: unknown): unknown {\n if (typeof value === \"string\") {\n return /^[a-z][a-z\\d+.-]*:\\/\\//i.test(value) ? recordedUrl(value, false) : value;\n }\n\n if (Array.isArray(value)) {\n return value.map(stripUrls);\n }\n\n if (isObject(value)) {\n return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, stripUrls(entry)]));\n }\n\n return value;\n}\n\n/**\n * Copies the config for a support ticket, without the headers and with every URL trimmed. A\n * function becomes its name and a RegExp its text.\n * @param config Active configuration.\n * @param limits Limits for the copy, the same as for record attributes.\n * @param diagnostics Diagnostics reporter.\n * @returns JSON-safe copy of the config.\n */\nexport function configSummary(\n config: ResolvedConfig,\n limits: SanitizeLimits,\n diagnostics: Diagnostics,\n): Record<string, unknown> {\n // A relative endpoint has no scheme, so stripUrls() doesn't see it as a URL.\n const cut = (value: unknown): unknown =>\n typeof value === \"string\" ? recordedUrl(value, false) : value;\n const { capture, serializer } = config;\n const copy: Record<string, unknown> = {\n ...config,\n endpoint: cut(config.endpoint),\n metricsEndpoint: cut(config.metricsEndpoint),\n tracesEndpoint: cut(config.tracesEndpoint),\n // An object from the app can hold a key in any field, so only its name goes out.\n serializer: typeof serializer === \"string\" ? serializer : serializer.name,\n capture: {\n ...capture,\n ignoreUrls: capture.ignoreUrls.map(cut),\n plugins: capture.plugins.map((plugin) => plugin.name),\n },\n // The replay headers can carry a token, and recordOptions is the app's own object.\n replay: {\n ...config.replay,\n endpoint: cut(config.replay.endpoint),\n headers: config.replay.headers !== null,\n plugins: config.replay.plugins.length,\n recordOptions: Object.keys(config.replay.recordOptions),\n },\n };\n // Static headers can hold a token.\n Reflect.deleteProperty(copy, \"headers\");\n\n return stripUrls(sanitize(copy, limits, diagnostics)) as Record<string, unknown>;\n}\n"],"mappings":";;;;AAiBA,SAASE,EAAU,GAAyB;CAa1C,OAZI,OAAOC,KAAU,WACZ,0BAA0B,KAAKA,CAAK,IAAIF,EAAYE,GAAO,EAAK,IAAIA,IAGzE,MAAM,QAAQA,CAAK,IACdA,EAAM,IAAID,CAAS,IAGxBF,EAASG,CAAK,IACT,OAAO,YAAY,OAAO,QAAQA,CAAK,CAAC,CAAC,KAAK,CAACC,GAAKC,OAAW,CAACD,GAAKF,EAAUG,CAAK,CAAC,CAAC,CAAC,IAGzFF;AACT;AAUA,SAAgBG,EACd,GACA,GACA,GACyB;CAEzB,IAAMC,KAAO,MACX,OAAOJ,KAAU,WAAWF,EAAYE,GAAO,EAAK,IAAIA,GACpD,EAAE,YAAS,kBAAeK,GAC1BC,IAAgC;EACpC,GAAGD;EACH,UAAUD,EAAIC,EAAO,QAAQ;EAC7B,iBAAiBD,EAAIC,EAAO,eAAe;EAC3C,gBAAgBD,EAAIC,EAAO,cAAc;EAEzC,YAAY,OAAOE,KAAe,WAAWA,IAAaA,EAAW;EACrE,SAAS;GACP,GAAGC;GACH,YAAYA,EAAQ,WAAW,IAAIJ,CAAG;GACtC,SAASI,EAAQ,QAAQ,KAAK,MAAWC,EAAO,IAAI;EACtD;EAEA,QAAQ;GACN,GAAGJ,EAAO;GACV,UAAUD,EAAIC,EAAO,OAAO,QAAQ;GACpC,SAASA,EAAO,OAAO,YAAY;GACnC,SAASA,EAAO,OAAO,QAAQ;GAC/B,eAAe,OAAO,KAAKA,EAAO,OAAO,aAAa;EACxD;CACF;CAIA,OAFA,QAAQ,eAAeC,GAAM,SAAS,GAE/BP,EAAUW,EAASJ,GAAMK,GAAQC,CAAW,CAAC;AACtD"}
@@ -1,2 +0,0 @@
1
- const e=require("./guards-nJ70syPt.cjs"),t=require("./platform-12uR7kBQ.cjs"),n=require("./sanitize-ChLn97Ch.cjs");function r(n){return typeof n==`string`?/^[a-z][a-z\d+.-]*:\/\//i.test(n)?t.i(n,!1):n:Array.isArray(n)?n.map(r):e.t(n)?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,r(t)])):n}function i(e,i,a){let o=e=>typeof e==`string`?t.i(e,!1):e,{capture:s,serializer:c}=e,l={...e,endpoint:o(e.endpoint),metricsEndpoint:o(e.metricsEndpoint),tracesEndpoint:o(e.tracesEndpoint),serializer:typeof c==`string`?c:c.name,capture:{...s,ignoreUrls:s.ignoreUrls.map(o),plugins:s.plugins.map(e=>e.name)},replay:{...e.replay,endpoint:o(e.replay.endpoint),headers:e.replay.headers!==null,plugins:e.replay.plugins.length,recordOptions:Object.keys(e.replay.recordOptions)}};return Reflect.deleteProperty(l,`headers`),r(n.n(l,i,a))}exports.configSummary=i;
2
- //# sourceMappingURL=debug-bundle-Ex4L_LSP.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debug-bundle-Ex4L_LSP.cjs","names":["recordedUrl","isObject","sanitize","require_guards","require_platform","require_sanitize","stripUrls","value","key","entry","configSummary","cut","config","copy","serializer","capture","plugin","limits","diagnostics"],"sources":["../src/core/debug-bundle.ts"],"sourcesContent":["// src/core/debug-bundle.ts\n//\n// Builds the config summary for a debug bundle. The runtime loads this module only when the\n// app asks for a bundle.\n\nimport type { ResolvedConfig } from \"../models/config\";\nimport { isObject } from \"../utils/guards\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { sanitize, type SanitizeLimits } from \"../utils/sanitize\";\nimport type { Diagnostics } from \"./diagnostics\";\n\n/**\n * Strips the user info, query and fragment from every absolute URL in a JSON-safe value. The\n * endpoints also end up in `capture.ignoreUrls`, where the library puts them.\n * @param value JSON-safe value.\n * @returns The value with every URL trimmed.\n */\nfunction stripUrls(value: unknown): unknown {\n if (typeof value === \"string\") {\n return /^[a-z][a-z\\d+.-]*:\\/\\//i.test(value) ? recordedUrl(value, false) : value;\n }\n\n if (Array.isArray(value)) {\n return value.map(stripUrls);\n }\n\n if (isObject(value)) {\n return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, stripUrls(entry)]));\n }\n\n return value;\n}\n\n/**\n * Copies the config for a support ticket, without the headers and with every URL trimmed. A\n * function becomes its name and a RegExp its text.\n * @param config Active configuration.\n * @param limits Limits for the copy, the same as for record attributes.\n * @param diagnostics Diagnostics reporter.\n * @returns JSON-safe copy of the config.\n */\nexport function configSummary(\n config: ResolvedConfig,\n limits: SanitizeLimits,\n diagnostics: Diagnostics,\n): Record<string, unknown> {\n // A relative endpoint has no scheme, so stripUrls() doesn't see it as a URL.\n const cut = (value: unknown): unknown =>\n typeof value === \"string\" ? recordedUrl(value, false) : value;\n const { capture, serializer } = config;\n const copy: Record<string, unknown> = {\n ...config,\n endpoint: cut(config.endpoint),\n metricsEndpoint: cut(config.metricsEndpoint),\n tracesEndpoint: cut(config.tracesEndpoint),\n // An object from the app can hold a key in any field, so only its name goes out.\n serializer: typeof serializer === \"string\" ? serializer : serializer.name,\n capture: {\n ...capture,\n ignoreUrls: capture.ignoreUrls.map(cut),\n plugins: capture.plugins.map((plugin) => plugin.name),\n },\n // The replay headers can carry a token, and recordOptions is the app's own object.\n replay: {\n ...config.replay,\n endpoint: cut(config.replay.endpoint),\n headers: config.replay.headers !== null,\n plugins: config.replay.plugins.length,\n recordOptions: Object.keys(config.replay.recordOptions),\n },\n };\n // Static headers can hold a token.\n Reflect.deleteProperty(copy, \"headers\");\n\n return stripUrls(sanitize(copy, limits, diagnostics)) as Record<string, unknown>;\n}\n"],"mappings":"A,mHAiBA,SAASM,EAAU,EAAyB,CAa1C,OAZI,OAAOC,GAAU,SACZ,0BAA0B,KAAKA,CAAK,EAAIP,EAAAA,EAAYO,EAAO,EAAK,EAAIA,EAGzE,MAAM,QAAQA,CAAK,EACdA,EAAM,IAAID,CAAS,EAGxBL,EAAAA,EAASM,CAAK,EACT,OAAO,YAAY,OAAO,QAAQA,CAAK,CAAC,CAAC,KAAK,CAACC,EAAKC,KAAW,CAACD,EAAKF,EAAUG,CAAK,CAAC,CAAC,CAAC,EAGzFF,CACT,CAUA,SAAgBG,EACd,EACA,EACA,EACyB,CAEzB,IAAMC,EAAO,GACX,OAAOJ,GAAU,SAAWP,EAAAA,EAAYO,EAAO,EAAK,EAAIA,EACpD,CAAE,UAAS,cAAeK,EAC1BC,EAAgC,CACpC,GAAGD,EACH,SAAUD,EAAIC,EAAO,QAAQ,EAC7B,gBAAiBD,EAAIC,EAAO,eAAe,EAC3C,eAAgBD,EAAIC,EAAO,cAAc,EAEzC,WAAY,OAAOE,GAAe,SAAWA,EAAaA,EAAW,KACrE,QAAS,CACP,GAAGC,EACH,WAAYA,EAAQ,WAAW,IAAIJ,CAAG,EACtC,QAASI,EAAQ,QAAQ,IAAK,GAAWC,EAAO,IAAI,CACtD,EAEA,OAAQ,CACN,GAAGJ,EAAO,OACV,SAAUD,EAAIC,EAAO,OAAO,QAAQ,EACpC,QAASA,EAAO,OAAO,UAAY,KACnC,QAASA,EAAO,OAAO,QAAQ,OAC/B,cAAe,OAAO,KAAKA,EAAO,OAAO,aAAa,CACxD,CACF,EAIA,OAFA,QAAQ,eAAeC,EAAM,SAAS,EAE/BP,EAAUJ,EAAAA,EAASW,EAAMI,EAAQC,CAAW,CAAC,CACtD,C"}
@@ -1,67 +0,0 @@
1
- import { Fn as e, et as t } from "./constants-Bwl_YtQi.js";
2
- import { i as n } from "./batch-BjQUwjA6.js";
3
- import { n as r } from "./deadline-C4ccAuk5.js";
4
- import { n as i, t as a } from "./keys-BU9j5YqW.js";
5
- // src/utils/lock.ts
6
- function o(e, t, n, { skipIfBusy: r = !0 } = {}) {
7
- let i = globalThis.navigator?.locks;
8
- return i?.request ? t.guardAsync("storage.degraded", `The library could not get the lock ${e}.`, () => i.request(e, { ifAvailable: r }, (e) => e ? n() : Promise.resolve(void 0))) : n();
9
- }
10
- function s(e, t) {
11
- return t ? `${e}:${encodeURIComponent(t)}` : e;
12
- }
13
- // src/storage/emergency-queue.ts
14
- function c(e, t) {
15
- let r = t.guard("storage.degraded", "An emergency entry is not valid JSON. The library dropped it.", () => JSON.parse(e));
16
- return r === void 0 ? null : n(r) ? r : (t.report("storage.degraded", "An emergency entry is not a batch. The library dropped it."), null);
17
- }
18
- async function l(t, n, a, o) {
19
- let s = 0;
20
- for (let l of i(o, n)) {
21
- let i = n.guard("storage.unavailable", "The library could not read the emergency queue.", () => {
22
- let e = localStorage.getItem(l), t = e ? c(e, n) : null;
23
- return t && !a(t) ? null : (localStorage.removeItem(l), t);
24
- });
25
- if (i) try {
26
- await r(t.save(i), e), s++;
27
- } catch (e) {
28
- n.report("storage.degraded", "The library could not recover an emergency batch.", { key: l }, e);
29
- }
30
- }
31
- return s;
32
- }
33
- function u(e, t, n) {
34
- let r = p(e.persistenceNamespace), o = `writing the emergency queue, ${String(e.records.length)} records`, s = [], l = t.guard("storage.quota_exceeded", o, () => {
35
- let n = i(r, t);
36
- for (let e of n.slice(0, Math.max(0, n.length - 20 + 1))) {
37
- let n = c(String(localStorage.getItem(e)), t);
38
- n !== null && s.push(n), localStorage.removeItem(e);
39
- }
40
- return localStorage.setItem(a(r, e), JSON.stringify(e)), !0;
41
- });
42
- t.guard("pipeline.crashed", "The loss report of the emergency queue failed.", () => {
43
- if (s.length > 0) {
44
- let e = s.flatMap((e) => e.records);
45
- n?.("exit_queue_full", e, s.map((e) => e.id));
46
- }
47
- l !== !0 && n?.("quota", e.records, [e.id]);
48
- });
49
- }
50
- async function d(e, t, n = () => !0, r = "") {
51
- return await o(s("ui-observability.emergency", r), t, () => l(e, t, n, p(r)), { skipIfBusy: !1 }) ?? 0;
52
- }
53
- function f(e, t, n = "", r = !1) {
54
- let a = p(n);
55
- t.guard("storage.unavailable", "The library could not clear the retired emergency queue.", () => {
56
- for (let n of i(a, t)) {
57
- let i = localStorage.getItem(n);
58
- i && (r || c(i, t)?.routingContextId === e) && localStorage.removeItem(n);
59
- }
60
- });
61
- }
62
- function p(e = "") {
63
- return e ? `ui-observability:namespaced:${encodeURIComponent(e)}:emergency:` : t;
64
- }
65
- export { f as clearEmergencyContext, d as drainEmergencyQueue, o as n, u as saveToEmergencyQueue, s as t };
66
-
67
- //# sourceMappingURL=emergency-queue-B9WZxanZ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"emergency-queue-B9WZxanZ.js","names":["STORAGE_DEADLINE_MS","EMERGENCY_STORAGE_KEY_PREFIX","isLogBatch","withDeadline","keysWithPrefix","batchKey","withDrainLock","locks","diagnostics","name","skipIfBusy","lock","fn","lockName","namespace","readBatch","parsed","raw","importAll","moved","key","prefix","batch","value","accepts","storage","error","saveToEmergencyQueue","emergencyPrefix","context","evicted","saved","keys","old","dropped","records","one","onLoss","drainEmergencyQueue","clearEmergencyContext","all","id"],"sources":["../src/utils/lock.ts","../src/storage/emergency-queue.ts"],"sourcesContent":["// src/utils/lock.ts\n//\n// Coordinates batch draining across the origin with the Web Locks API. Without the lock,\n// every window on the origin would drain and send the same batches.\n\nimport type { Diagnostics } from \"../core/diagnostics\";\n\n/** Lock grant object, or null when the lock isn't available. */\ntype LockGrant = { name: string } | null;\n\n/** Structural interface for navigator.locks operations. */\ninterface LockManagerLike {\n /**\n * Requests a lock and executes a callback under the acquired lock grant.\n * @param name Lock name.\n * @param options Lock request options.\n * @param callback Callback that runs with the lock grant.\n */\n request<T>(\n name: string,\n options: { ifAvailable?: boolean },\n callback: (lock: LockGrant) => Promise<T>,\n ): Promise<T>;\n}\n\n/**\n * Runs an async function under an origin-wide Web Locks API lock. Runs the task directly when\n * the Web Locks API isn't available.\n * @param name Origin-scoped lock identifier.\n * @param diagnostics Diagnostics reporter.\n * @param fn The async task to run while holding the lock.\n * @param options Lock acquisition options.\n * @param options.skipIfBusy When true, the task doesn't run if another context holds the lock.\n * @returns A promise of the task's result. Resolves to undefined when another context holds\n * the lock. A caller that reads undefined as a task result stops rescheduling.\n */\nexport function withDrainLock<T>(\n name: string,\n diagnostics: Diagnostics,\n fn: () => Promise<T>,\n { skipIfBusy = true }: { skipIfBusy?: boolean } = {},\n): Promise<T | undefined> {\n const locks = (globalThis as { navigator?: { locks?: LockManagerLike } }).navigator?.locks;\n\n // Run the task without a lock when the Web Locks API isn't available.\n if (!locks?.request) {\n return fn();\n }\n\n return diagnostics.guardAsync(\n \"storage.degraded\",\n `The library could not get the lock ${name}.`,\n () =>\n locks.request(name, { ifAvailable: skipIfBusy }, (lock) =>\n lock ? fn() : Promise.resolve(undefined),\n ),\n );\n}\n\n/**\n * Returns the lock name for one application namespace, so two namespaces on one origin don't\n * wait for each other. Otherwise one application's retry pass would be skipped while the\n * other holds the lock.\n * @param name Base lock name.\n * @param namespace Application storage namespace. An empty value keeps the base name.\n * @returns The lock name for this namespace.\n */\nexport function lockName(name: string, namespace: string): string {\n return namespace ? `${name}:${encodeURIComponent(namespace)}` : name;\n}\n","// src/storage/emergency-queue.ts\n//\n// A synchronous localStorage queue that holds oversized batches during unload, to be recovered\n// on the next startup. Everything here is synchronous and never throws, because it runs while\n// the browser is destroying the document and no promise settles at that point.\n\nimport {\n EMERGENCY_LOCK_NAME,\n EMERGENCY_MAX_ENTRIES,\n EMERGENCY_STORAGE_KEY_PREFIX,\n STORAGE_DEADLINE_MS,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { isLogBatch, type LogBatch } from \"../models/batch\";\nimport type { LossReporter } from \"../models/drop\";\nimport type { StorageAdapter } from \"../models/storage\";\nimport { withDeadline } from \"../utils/deadline\";\nimport { lockName, withDrainLock } from \"../utils/lock\";\nimport { batchKey, keysWithPrefix } from \"./keys\";\n\n/**\n * Parses a raw storage string and validates it as a LogBatch.\n * @param raw The raw serialized string from storage.\n * @param diagnostics Diagnostics reporter.\n * @returns The validated LogBatch, or null if it can't be parsed or is malformed.\n */\nfunction readBatch(raw: string, diagnostics: Diagnostics): LogBatch | null {\n const parsed = diagnostics.guard(\n \"storage.degraded\",\n \"An emergency entry is not valid JSON. The library dropped it.\",\n () => JSON.parse(raw) as unknown,\n );\n\n // The guard above already reported a parse failure.\n if (parsed === undefined) {\n return null;\n }\n\n if (!isLogBatch(parsed)) {\n diagnostics.report(\n \"storage.degraded\",\n \"An emergency entry is not a batch. The library dropped it.\",\n );\n return null;\n }\n\n return parsed;\n}\n\n/**\n * Imports every emergency queue entry into the target adapter, in FIFO order.\n * @param storage The destination storage adapter.\n * @param diagnostics Diagnostics reporter.\n * @returns The total number of recovered batches.\n */\nasync function importAll(\n storage: StorageAdapter,\n diagnostics: Diagnostics,\n accepts: (batch: LogBatch) => boolean,\n prefix: string,\n): Promise<number> {\n let moved = 0;\n\n for (const key of keysWithPrefix(prefix, diagnostics)) {\n // Read and remove the key in one synchronous step, before the async save, so a second\n // window importing at the same time can't take the same batch. Each entry is parsed once.\n // A batch that belongs to another context stays in the queue.\n const batch = diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not read the emergency queue.\",\n (): LogBatch | null => {\n const value = localStorage.getItem(key);\n const parsed = value ? readBatch(value, diagnostics) : null;\n if (parsed && !accepts(parsed)) {\n return null;\n }\n localStorage.removeItem(key);\n return parsed;\n },\n );\n\n if (!batch) {\n continue;\n }\n\n try {\n // This runs during startup, so set a deadline. A save that never settles would keep the\n // runtime from becoming ready, and every record would go to the boot buffer.\n await withDeadline(storage.save(batch), STORAGE_DEADLINE_MS);\n moved++;\n } catch (error) {\n diagnostics.report(\n \"storage.degraded\",\n \"The library could not recover an emergency batch.\",\n { key },\n error,\n );\n }\n }\n\n return moved;\n}\n\n/**\n * Synchronously writes an unsent batch to the emergency queue during unload.\n * @param batch The oversized log batch.\n * @param diagnostics Diagnostics reporter.\n * @param onLoss Receives the records of old entries the queue drops, and of a batch the\n * store refuses.\n */\nexport function saveToEmergencyQueue(\n batch: LogBatch,\n diagnostics: Diagnostics,\n onLoss?: LossReporter,\n): void {\n // Name the record count, because a full localStorage drops this batch for good. Removing\n // emergency keys can't free quota that other applications' keys are using.\n const prefix = emergencyPrefix(batch.persistenceNamespace);\n const context = `writing the emergency queue, ${String(batch.records.length)} records`;\n const evicted: LogBatch[] = [];\n\n const saved = diagnostics.guard(\"storage.quota_exceeded\", context, () => {\n const keys = keysWithPrefix(prefix, diagnostics);\n\n // Remove the oldest entries to keep the queue within its capacity.\n for (const old of keys.slice(0, Math.max(0, keys.length - EMERGENCY_MAX_ENTRIES + 1))) {\n // A key that another window already removed reads as null, and readBatch rejects it.\n const dropped = readBatch(String(localStorage.getItem(old)), diagnostics);\n if (dropped !== null) {\n evicted.push(dropped);\n }\n localStorage.removeItem(old);\n }\n\n localStorage.setItem(batchKey(prefix, batch), JSON.stringify(batch));\n return true;\n });\n\n // The exit flush calls this, and a throw here would skip the sender's shutdown.\n diagnostics.guard(\"pipeline.crashed\", \"The loss report of the emergency queue failed.\", () => {\n if (evicted.length > 0) {\n const records = evicted.flatMap((one) => one.records);\n onLoss?.(\n \"exit_queue_full\",\n records,\n evicted.map((one) => one.id),\n );\n }\n\n if (saved !== true) {\n onLoss?.(\"quota\", batch.records, [batch.id]);\n }\n });\n}\n\n/**\n * Recovers the batches that earlier shutdowns saved to emergency storage.\n * @param storage The destination storage adapter.\n * @param diagnostics Diagnostics reporter.\n * @returns A promise that resolves to the number of recovered batches.\n */\nexport async function drainEmergencyQueue(\n storage: StorageAdapter,\n diagnostics: Diagnostics,\n accepts: (batch: LogBatch) => boolean = () => true,\n namespace = \"\",\n): Promise<number> {\n const moved = await withDrainLock(\n lockName(EMERGENCY_LOCK_NAME, namespace),\n diagnostics,\n () => importAll(storage, diagnostics, accepts, emergencyPrefix(namespace)),\n { skipIfBusy: false },\n );\n\n return moved ?? 0;\n}\n\n/**\n * Removes one context's emergency entries, or every entry in its namespace.\n * @param id Delivery context id.\n * @param diagnostics Diagnostics reporter.\n * @param namespace The application's storage namespace.\n * @param all True to remove the entries of every context in this namespace.\n */\nexport function clearEmergencyContext(\n id: string,\n diagnostics: Diagnostics,\n namespace = \"\",\n all = false,\n): void {\n const prefix = emergencyPrefix(namespace);\n diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not clear the retired emergency queue.\",\n () => {\n for (const key of keysWithPrefix(prefix, diagnostics)) {\n const raw = localStorage.getItem(key);\n if (raw && (all || readBatch(raw, diagnostics)?.routingContextId === id))\n localStorage.removeItem(key);\n }\n },\n );\n}\n\n/**\n * Returns the emergency storage prefix for one application namespace.\n * @param namespace Application namespace. An empty value uses the previous prefix.\n * @returns The prefix of this application's emergency queue.\n */\nfunction emergencyPrefix(namespace = \"\"): string {\n return namespace\n ? `ui-observability:namespaced:${encodeURIComponent(namespace)}:emergency:`\n : EMERGENCY_STORAGE_KEY_PREFIX;\n}\n"],"mappings":";;;;;AAoCA,SAAgBM,EACd,GACA,GACA,GACA,EAAE,gBAAa,OAAmC,CAAC,GAC3B;CACxB,IAAMC,IAAS,WAA2D,WAAW;CAOrF,OAJKA,GAAO,UAILC,EAAY,WACjB,oBACA,sCAAsCC,EAAK,UAEzCF,EAAM,QAAQE,GAAM,EAAE,aAAaC,EAAW,IAAI,MAChDC,IAAOC,EAAG,IAAI,QAAQ,QAAQ,KAAA,CAAS,CACzC,CACJ,IAVSA,EAAG;AAWd;AAUA,SAAgBC,EAAS,GAAc,GAA2B;CAChE,OAAOC,IAAY,GAAGL,EAAK,GAAG,mBAAmBK,CAAS,MAAML;AAClE;;AC3CA,SAASM,EAAU,GA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Q5B,EAASgB,GAAQC,CAAK,GAAG,KAAK,UAAUA,CAAK,CAAC,GAC5D;CACT,CAAC;CAGD,EAAY,MAAM,oBAAoB,wDAAwD;EAC5F,IAAIQ,EAAQ,SAAS,GAAG;GACtB,IAAMK,IAAUL,EAAQ,SAAS,MAAQM,EAAI,OAAO;GACpD,IACE,mBACAD,GACAL,EAAQ,KAAK,MAAQM,EAAI,EAAE,CAC7B;EACF;EAEA,AAAIL,MAAU,MACZM,IAAS,SAASf,EAAM,SAAS,CAACA,EAAM,EAAE,CAAC;CAE/C,CAAC;AACH;AAQA,eAAsBgB,EACpB,GACA,GACA,UAA8C,IAC9C,IAAY,IACK;CAQjB,OAAO,MAPahC,EAClBO,EAAA,8BAA8BC,CAAS,GACvCN,SACMU,EAAUO,GAASjB,GAAagB,GAASI,EAAgBd,CAAS,CAAC,GACzE,EAAE,YAAY,GAAM,CACtB,KAEgB;AAClB;AASA,SAAgByB,EACd,GACA,GACA,IAAY,IACZ,IAAM,IACA;CACN,IAAMlB,IAASO,EAAgBd,CAAS;CACxC,EAAY,MACV,uBACA,kEACM;EACJ,KAAK,IAAMM,KAAOhB,EAAeiB,GAAQb,CAAW,GAAG;GACrD,IAAMS,IAAM,aAAa,QAAQG,CAAG;GACpC,AAAIH,MAAQuB,KAAOzB,EAAUE,GAAKT,CAAW,CAAC,EAAE,qBAAqBiC,MACnE,aAAa,WAAWrB,CAAG;EAC/B;CACF,CACF;AACF;AAOA,SAASQ,EAAgB,IAAY,IAAY;CAC/C,OAAOd,IACH,+BAA+B,mBAAmBA,CAAS,EAAE,eAC7Db;AACN"}
@@ -1,2 +0,0 @@
1
- const e=require("./constants-DakMxVB2.cjs"),t=require("./batch-D5LlU4Q9.cjs"),n=require("./deadline-CUGbto-y.cjs"),r=require("./keys-BHhw_0Wh.cjs");function i(e,t,n,{skipIfBusy:r=!0}={}){let i=globalThis.navigator?.locks;return i?.request?t.guardAsync(`storage.degraded`,`The library could not get the lock ${e}.`,()=>i.request(e,{ifAvailable:r},e=>e?n():Promise.resolve(void 0))):n()}function a(e,t){return t?`${e}:${encodeURIComponent(t)}`:e}function o(e,n){let r=n.guard(`storage.degraded`,`An emergency entry is not valid JSON. The library dropped it.`,()=>JSON.parse(e));return r===void 0?null:t.i(r)?r:(n.report(`storage.degraded`,`An emergency entry is not a batch. The library dropped it.`),null)}async function s(t,i,a,s){let c=0;for(let l of r.n(s,i)){let r=i.guard(`storage.unavailable`,`The library could not read the emergency queue.`,()=>{let e=localStorage.getItem(l),t=e?o(e,i):null;return t&&!a(t)?null:(localStorage.removeItem(l),t)});if(r)try{await n.n(t.save(r),e.Fn),c++}catch(e){i.report(`storage.degraded`,`The library could not recover an emergency batch.`,{key:l},e)}}return c}function c(e,t,n){let i=d(e.persistenceNamespace),a=`writing the emergency queue, ${String(e.records.length)} records`,s=[],c=t.guard(`storage.quota_exceeded`,a,()=>{let n=r.n(i,t);for(let e of n.slice(0,Math.max(0,n.length-20+1))){let n=o(String(localStorage.getItem(e)),t);n!==null&&s.push(n),localStorage.removeItem(e)}return localStorage.setItem(r.t(i,e),JSON.stringify(e)),!0});t.guard(`pipeline.crashed`,`The loss report of the emergency queue failed.`,()=>{if(s.length>0){let e=s.flatMap(e=>e.records);n?.(`exit_queue_full`,e,s.map(e=>e.id))}c!==!0&&n?.(`quota`,e.records,[e.id])})}async function l(e,t,n=()=>!0,r=``){return await i(a(`ui-observability.emergency`,r),t,()=>s(e,t,n,d(r)),{skipIfBusy:!1})??0}function u(e,t,n=``,i=!1){let a=d(n);t.guard(`storage.unavailable`,`The library could not clear the retired emergency queue.`,()=>{for(let n of r.n(a,t)){let r=localStorage.getItem(n);r&&(i||o(r,t)?.routingContextId===e)&&localStorage.removeItem(n)}})}function d(t=``){return t?`ui-observability:namespaced:${encodeURIComponent(t)}:emergency:`:e.et}exports.clearEmergencyContext=u,exports.drainEmergencyQueue=l,exports.n=i,exports.saveToEmergencyQueue=c,exports.t=a;
2
- //# sourceMappingURL=emergency-queue-HBpL5r3V.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"emergency-queue-HBpL5r3V.cjs","names":["isLogBatch","keysWithPrefix","withDeadline","STORAGE_DEADLINE_MS","batchKey","EMERGENCY_STORAGE_KEY_PREFIX","require_constants","require_batch","require_deadline","require_keys","withDrainLock","locks","diagnostics","name","skipIfBusy","lock","fn","lockName","namespace","readBatch","parsed","raw","importAll","moved","key","prefix","batch","value","accepts","storage","error","saveToEmergencyQueue","emergencyPrefix","context","evicted","saved","keys","old","dropped","records","one","onLoss","drainEmergencyQueue","clearEmergencyContext","all","id"],"sources":["../src/utils/lock.ts","../src/storage/emergency-queue.ts"],"sourcesContent":["// src/utils/lock.ts\n//\n// Coordinates batch draining across the origin with the Web Locks API. Without the lock,\n// every window on the origin would drain and send the same batches.\n\nimport type { Diagnostics } from \"../core/diagnostics\";\n\n/** Lock grant object, or null when the lock isn't available. */\ntype LockGrant = { name: string } | null;\n\n/** Structural interface for navigator.locks operations. */\ninterface LockManagerLike {\n /**\n * Requests a lock and executes a callback under the acquired lock grant.\n * @param name Lock name.\n * @param options Lock request options.\n * @param callback Callback that runs with the lock grant.\n */\n request<T>(\n name: string,\n options: { ifAvailable?: boolean },\n callback: (lock: LockGrant) => Promise<T>,\n ): Promise<T>;\n}\n\n/**\n * Runs an async function under an origin-wide Web Locks API lock. Runs the task directly when\n * the Web Locks API isn't available.\n * @param name Origin-scoped lock identifier.\n * @param diagnostics Diagnostics reporter.\n * @param fn The async task to run while holding the lock.\n * @param options Lock acquisition options.\n * @param options.skipIfBusy When true, the task doesn't run if another context holds the lock.\n * @returns A promise of the task's result. Resolves to undefined when another context holds\n * the lock. A caller that reads undefined as a task result stops rescheduling.\n */\nexport function withDrainLock<T>(\n name: string,\n diagnostics: Diagnostics,\n fn: () => Promise<T>,\n { skipIfBusy = true }: { skipIfBusy?: boolean } = {},\n): Promise<T | undefined> {\n const locks = (globalThis as { navigator?: { locks?: LockManagerLike } }).navigator?.locks;\n\n // Run the task without a lock when the Web Locks API isn't available.\n if (!locks?.request) {\n return fn();\n }\n\n return diagnostics.guardAsync(\n \"storage.degraded\",\n `The library could not get the lock ${name}.`,\n () =>\n locks.request(name, { ifAvailable: skipIfBusy }, (lock) =>\n lock ? fn() : Promise.resolve(undefined),\n ),\n );\n}\n\n/**\n * Returns the lock name for one application namespace, so two namespaces on one origin don't\n * wait for each other. Otherwise one application's retry pass would be skipped while the\n * other holds the lock.\n * @param name Base lock name.\n * @param namespace Application storage namespace. An empty value keeps the base name.\n * @returns The lock name for this namespace.\n */\nexport function lockName(name: string, namespace: string): string {\n return namespace ? `${name}:${encodeURIComponent(namespace)}` : name;\n}\n","// src/storage/emergency-queue.ts\n//\n// A synchronous localStorage queue that holds oversized batches during unload, to be recovered\n// on the next startup. Everything here is synchronous and never throws, because it runs while\n// the browser is destroying the document and no promise settles at that point.\n\nimport {\n EMERGENCY_LOCK_NAME,\n EMERGENCY_MAX_ENTRIES,\n EMERGENCY_STORAGE_KEY_PREFIX,\n STORAGE_DEADLINE_MS,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { isLogBatch, type LogBatch } from \"../models/batch\";\nimport type { LossReporter } from \"../models/drop\";\nimport type { StorageAdapter } from \"../models/storage\";\nimport { withDeadline } from \"../utils/deadline\";\nimport { lockName, withDrainLock } from \"../utils/lock\";\nimport { batchKey, keysWithPrefix } from \"./keys\";\n\n/**\n * Parses a raw storage string and validates it as a LogBatch.\n * @param raw The raw serialized string from storage.\n * @param diagnostics Diagnostics reporter.\n * @returns The validated LogBatch, or null if it can't be parsed or is malformed.\n */\nfunction readBatch(raw: string, diagnostics: Diagnostics): LogBatch | null {\n const parsed = diagnostics.guard(\n \"storage.degraded\",\n \"An emergency entry is not valid JSON. The library dropped it.\",\n () => JSON.parse(raw) as unknown,\n );\n\n // The guard above already reported a parse failure.\n if (parsed === undefined) {\n return null;\n }\n\n if (!isLogBatch(parsed)) {\n diagnostics.report(\n \"storage.degraded\",\n \"An emergency entry is not a batch. The library dropped it.\",\n );\n return null;\n }\n\n return parsed;\n}\n\n/**\n * Imports every emergency queue entry into the target adapter, in FIFO order.\n * @param storage The destination storage adapter.\n * @param diagnostics Diagnostics reporter.\n * @returns The total number of recovered batches.\n */\nasync function importAll(\n storage: StorageAdapter,\n diagnostics: Diagnostics,\n accepts: (batch: LogBatch) => boolean,\n prefix: string,\n): Promise<number> {\n let moved = 0;\n\n for (const key of keysWithPrefix(prefix, diagnostics)) {\n // Read and remove the key in one synchronous step, before the async save, so a second\n // window importing at the same time can't take the same batch. Each entry is parsed once.\n // A batch that belongs to another context stays in the queue.\n const batch = diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not read the emergency queue.\",\n (): LogBatch | null => {\n const value = localStorage.getItem(key);\n const parsed = value ? readBatch(value, diagnostics) : null;\n if (parsed && !accepts(parsed)) {\n return null;\n }\n localStorage.removeItem(key);\n return parsed;\n },\n );\n\n if (!batch) {\n continue;\n }\n\n try {\n // This runs during startup, so set a deadline. A save that never settles would keep the\n // runtime from becoming ready, and every record would go to the boot buffer.\n await withDeadline(storage.save(batch), STORAGE_DEADLINE_MS);\n moved++;\n } catch (error) {\n diagnostics.report(\n \"storage.degraded\",\n \"The library could not recover an emergency batch.\",\n { key },\n error,\n );\n }\n }\n\n return moved;\n}\n\n/**\n * Synchronously writes an unsent batch to the emergency queue during unload.\n * @param batch The oversized log batch.\n * @param diagnostics Diagnostics reporter.\n * @param onLoss Receives the records of old entries the queue drops, and of a batch the\n * store refuses.\n */\nexport function saveToEmergencyQueue(\n batch: LogBatch,\n diagnostics: Diagnostics,\n onLoss?: LossReporter,\n): void {\n // Name the record count, because a full localStorage drops this batch for good. Removing\n // emergency keys can't free quota that other applications' keys are using.\n const prefix = emergencyPrefix(batch.persistenceNamespace);\n const context = `writing the emergency queue, ${String(batch.records.length)} records`;\n const evicted: LogBatch[] = [];\n\n const saved = diagnostics.guard(\"storage.quota_exceeded\", context, () => {\n const keys = keysWithPrefix(prefix, diagnostics);\n\n // Remove the oldest entries to keep the queue within its capacity.\n for (const old of keys.slice(0, Math.max(0, keys.length - EMERGENCY_MAX_ENTRIES + 1))) {\n // A key that another window already removed reads as null, and readBatch rejects it.\n const dropped = readBatch(String(localStorage.getItem(old)), diagnostics);\n if (dropped !== null) {\n evicted.push(dropped);\n }\n localStorage.removeItem(old);\n }\n\n localStorage.setItem(batchKey(prefix, batch), JSON.stringify(batch));\n return true;\n });\n\n // The exit flush calls this, and a throw here would skip the sender's shutdown.\n diagnostics.guard(\"pipeline.crashed\", \"The loss report of the emergency queue failed.\", () => {\n if (evicted.length > 0) {\n const records = evicted.flatMap((one) => one.records);\n onLoss?.(\n \"exit_queue_full\",\n records,\n evicted.map((one) => one.id),\n );\n }\n\n if (saved !== true) {\n onLoss?.(\"quota\", batch.records, [batch.id]);\n }\n });\n}\n\n/**\n * Recovers the batches that earlier shutdowns saved to emergency storage.\n * @param storage The destination storage adapter.\n * @param diagnostics Diagnostics reporter.\n * @returns A promise that resolves to the number of recovered batches.\n */\nexport async function drainEmergencyQueue(\n storage: StorageAdapter,\n diagnostics: Diagnostics,\n accepts: (batch: LogBatch) => boolean = () => true,\n namespace = \"\",\n): Promise<number> {\n const moved = await withDrainLock(\n lockName(EMERGENCY_LOCK_NAME, namespace),\n diagnostics,\n () => importAll(storage, diagnostics, accepts, emergencyPrefix(namespace)),\n { skipIfBusy: false },\n );\n\n return moved ?? 0;\n}\n\n/**\n * Removes one context's emergency entries, or every entry in its namespace.\n * @param id Delivery context id.\n * @param diagnostics Diagnostics reporter.\n * @param namespace The application's storage namespace.\n * @param all True to remove the entries of every context in this namespace.\n */\nexport function clearEmergencyContext(\n id: string,\n diagnostics: Diagnostics,\n namespace = \"\",\n all = false,\n): void {\n const prefix = emergencyPrefix(namespace);\n diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not clear the retired emergency queue.\",\n () => {\n for (const key of keysWithPrefix(prefix, diagnostics)) {\n const raw = localStorage.getItem(key);\n if (raw && (all || readBatch(raw, diagnostics)?.routingContextId === id))\n localStorage.removeItem(key);\n }\n },\n );\n}\n\n/**\n * Returns the emergency storage prefix for one application namespace.\n * @param namespace Application namespace. An empty value uses the previous prefix.\n * @returns The prefix of this application's emergency queue.\n */\nfunction emergencyPrefix(namespace = \"\"): string {\n return namespace\n ? `ui-observability:namespaced:${encodeURIComponent(namespace)}:emergency:`\n : EMERGENCY_STORAGE_KEY_PREFIX;\n}\n"],"mappings":"A,oJAoCA,SAAgBU,EACd,EACA,EACA,EACA,CAAE,aAAa,IAAmC,CAAC,EAC3B,CACxB,IAAMC,EAAS,WAA2D,WAAW,MAOrF,OAJKA,GAAO,QAILC,EAAY,WACjB,mBACA,sCAAsCC,EAAK,OAEzCF,EAAM,QAAQE,EAAM,CAAE,YAAaC,CAAW,EAAI,GAChDC,EAAOC,EAAG,EAAI,QAAQ,QAAQ,IAAA,EAAS,CACzC,CACJ,EAVSA,EAAG,CAWd,CAUA,SAAgBC,EAAS,EAAc,EAA2B,CAChE,OAAOC,EAAY,GAAGL,EAAK,GAAG,mBAAmBK,CAAS,IAAML,CAClE,CC3CA,SAASM,EAAU,EAAa,EAA2C,CACzE,IAAMC,EAASR,EAAY,MACzB,mBACA,oEACM,KAAK,MAAMS,CAAG,CACtB,EAeA,OAZID,IAAW,IAAA,GACN,KAGJpB,EAAAA,EAAWoB,CAAM,EAQfA,GAPLR,EAAY,OACV,mBACA,4DACF,EACO,KAIX,CAQA,eAAeU,EACb,EACA,EACA,EACA,EACiB,CACjB,IAAIC,EAAQ,EAEZ,IAAK,IAAMC,KAAOvB,EAAAA,EAAewB,EAAQb,CAAW,EAAG,CAIrD,IAAMc,EAAQd,EAAY,MACxB,sBACA,sDACuB,CACrB,IAAMe,EAAQ,aAAa,QAAQH,CAAG,EAChCJ,EAASO,EAAQR,EAAUQ,EAAOf,CAAW,EAAI,KAKvD,OAJIQ,GAAU,CAACQ,EAAQR,CAAM,EACpB,MAET,aAAa,WAAWI,CAAG,EACpBJ,EAC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agB,EAASI,EAAgBd,CAAS,CAAC,EACzE,CAAE,WAAY,EAAM,CACtB,GAEgB,CAClB,CASA,SAAgByB,EACd,EACA,EACA,EAAY,GACZ,EAAM,GACA,CACN,IAAMlB,EAASO,EAAgBd,CAAS,EACxCN,EAAY,MACV,sBACA,+DACM,CACJ,IAAK,IAAMY,KAAOvB,EAAAA,EAAewB,EAAQb,CAAW,EAAG,CACrD,IAAMS,EAAM,aAAa,QAAQG,CAAG,EAChCH,IAAQuB,GAAOzB,EAAUE,EAAKT,CAAW,CAAC,EAAE,mBAAqBiC,IACnE,aAAa,WAAWrB,CAAG,CAC/B,CACF,CACF,CACF,CAOA,SAASQ,EAAgB,EAAY,GAAY,CAC/C,OAAOd,EACH,+BAA+B,mBAAmBA,CAAS,EAAE,aAC7Db,EAAAA,EACN,C"}
@@ -1,92 +0,0 @@
1
- import { r as e } from "./error-like-B11pB4aL.js";
2
- import { i as t } from "./platform-CVewe4wQ.js";
3
- import { t as n } from "./storm-BTSNTIWI.js";
4
- // src/capture/errors.ts
5
- function r(t) {
6
- if (e(t)) {
7
- let e = (t.stack ?? "").split("\n")[1] ?? "";
8
- return {
9
- message: t.message,
10
- key: `${t.name}|${t.message}|${e}`
11
- };
12
- }
13
- let n = String(t);
14
- return {
15
- message: n,
16
- key: `${typeof t}|${n}|`
17
- };
18
- }
19
- var i = class {
20
- ctx;
21
- name = "errors";
22
- installed = !1;
23
- seen = /* @__PURE__ */ new Map();
24
- window = {
25
- start: 0,
26
- count: 0
27
- };
28
- constructor(e) {
29
- this.ctx = e;
30
- }
31
- install() {
32
- this.installed || typeof addEventListener > "u" || (this.installed = !0, addEventListener("error", this.onError, !0), addEventListener("unhandledrejection", this.onRejection));
33
- }
34
- uninstall() {
35
- this.installed && (this.installed = !1, removeEventListener("error", this.onError, !0), removeEventListener("unhandledrejection", this.onRejection), this.seen.clear());
36
- }
37
- onError = (e) => {
38
- let n = e.target, r = n?.src ?? n?.href ?? "";
39
- if (n !== null && n !== globalThis && r !== "") {
40
- if (!this.ctx.config.capture.resourceErrors) return;
41
- let e = t(r, this.ctx.config.capture.fullUrls, this.ctx.config.capture.urlTransform, this.ctx.diagnostics);
42
- this.ctx.breadcrumbs.push({
43
- t: Date.now(),
44
- category: "http",
45
- message: `resource failed: ${e}`
46
- }), this.ctx.logger.warn("resource failed to load", {
47
- "error.type": "resource",
48
- "resource.url": e,
49
- "resource.tag": n.tagName.toLowerCase()
50
- });
51
- return;
52
- }
53
- if (!this.ctx.config.capture.errors) return;
54
- let i = e, a = i.message === "" ? "unknown error" : i.message, o = i.error ?? Error(a);
55
- this.report("window.onerror", o, {
56
- "error.source": t(i.filename, this.ctx.config.capture.fullUrls, this.ctx.config.capture.urlTransform, this.ctx.diagnostics),
57
- "error.line": i.lineno,
58
- "error.column": i.colno
59
- });
60
- };
61
- onRejection = (e) => {
62
- this.ctx.config.capture.rejections && this.report("unhandledrejection", e.reason, { "error.type": "unhandledrejection" });
63
- };
64
- report(e, t, i) {
65
- if (!n(this.window, this.ctx.config.capturePolicy.errorsPerWindow, this.ctx.diagnostics, "errors", this.ctx.config.capturePolicy.windowMs)) return;
66
- let a = Date.now(), { message: o, key: s } = this.ctx.diagnostics.guard("capture.record_failed", "The library could not read the error reason. It records the error without its message.", () => r(t)) ?? {
67
- message: "",
68
- key: `${typeof t}||`
69
- }, c = this.seen.get(s);
70
- if (c && a - c.at < this.ctx.config.capturePolicy.errorDedupeMs) {
71
- c.count++, c.at = a;
72
- return;
73
- }
74
- let l = c ? c.count - 1 : 0;
75
- if (this.seen.delete(s), this.seen.set(s, {
76
- at: a,
77
- count: 1
78
- }), this.ctx.config.capturePolicy.maxErrorSignatures > 0 && this.seen.size > this.ctx.config.capturePolicy.maxErrorSignatures) {
79
- let [e] = this.seen.keys();
80
- this.seen.delete(e);
81
- }
82
- let u = t === void 0 ? Error(o) : t;
83
- this.ctx.logger.error(o === "" ? e : o, u, {
84
- ...i,
85
- "error.captured_by": e,
86
- "error.suppressed_count": l
87
- });
88
- }
89
- };
90
- export { i as ErrorCapture };
91
-
92
- //# sourceMappingURL=errors-D6bwgJtO.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors-D6bwgJtO.js","names":["isErrorLike","recordedUrl","allowInWindow","signatureOf","value","frame","message","ErrorCapture","ctx","target","event","resourceUrl","url","errorEvent","fallback","error","now","previous","key","suppressed","oldest","reason","source","extra"],"sources":["../src/capture/errors.ts"],"sourcesContent":["// src/capture/errors.ts\n//\n// Captures uncaught errors, unhandled rejections and failed resource loads.\n\nimport { isErrorLike } from \"../utils/error-like\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext } from \"./types\";\n\n/** Tracking metadata for a deduplicated error signature. */\ninterface SeenError {\n /** When the signature was last reported, in epoch milliseconds. */\n at: number;\n /** Occurrences recorded since the last report. */\n count: number;\n}\n\n/** A thrown value's message and deduplication key. */\ninterface Signature {\n /** The record's message. */\n message: string;\n /** Deduplication key. */\n key: string;\n}\n\n/**\n * Reads a thrown value's message and deduplication key.\n * Duck typing lets it read an error from another realm, which fails `instanceof Error`.\n * @param value Thrown value or rejection reason.\n * @returns The signature.\n * @throws When a getter or the value's text form throws. Call it inside a guard.\n */\nfunction signatureOf(value: unknown): Signature {\n if (isErrorLike(value)) {\n const frame = (value.stack ?? \"\").split(\"\\n\")[1] ?? \"\";\n return { message: value.message, key: `${value.name}|${value.message}|${frame}` };\n }\n\n const message = String(value);\n return { message, key: `${typeof value}|${message}|` };\n}\n\n/** Captures uncaught exceptions, unhandled promise rejections, and failed resource loads. */\nexport class ErrorCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"errors\";\n\n /** Prevents duplicate listener registration. */\n private installed = false;\n\n /** Recently reported error signatures in LRU order. */\n private readonly seen = new Map<string, SeenError>();\n\n /** This capture's own rate limit. Console noise has a separate window and can't use it. */\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n /**\n * @param ctx Capture context: configuration, diagnostics, logger and breadcrumbs.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Subscribes to global error and unhandledrejection events. */\n install(): void {\n if (this.installed || typeof addEventListener === \"undefined\") {\n return;\n }\n this.installed = true;\n\n // Resource load errors don't bubble, so listen in the capture phase.\n addEventListener(\"error\", this.onError, true);\n addEventListener(\"unhandledrejection\", this.onRejection);\n }\n\n /** Removes event listeners and clears tracked error signatures. */\n uninstall(): void {\n if (!this.installed) {\n return;\n }\n this.installed = false;\n\n removeEventListener(\"error\", this.onError, true);\n removeEventListener(\"unhandledrejection\", this.onRejection);\n this.seen.clear();\n }\n\n /** Routes resource load failures and uncaught script errors. */\n private readonly onError = (event: ErrorEvent | Event): void => {\n const target = event.target as (HTMLElement & { src?: string; href?: string }) | null;\n const resourceUrl = target?.src ?? target?.href ?? \"\";\n\n // An event from an element with a URL is a failed resource load, not a script error.\n if (\n target !== null &&\n target !== (globalThis as unknown as EventTarget) &&\n resourceUrl !== \"\"\n ) {\n if (!this.ctx.config.capture.resourceErrors) {\n return;\n }\n\n // A cache buster is noise and a signed URL is a credential, so the record keeps neither\n // unless you set fullUrls.\n const url = recordedUrl(\n resourceUrl,\n this.ctx.config.capture.fullUrls,\n this.ctx.config.capture.urlTransform,\n this.ctx.diagnostics,\n );\n\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"http\",\n message: `resource failed: ${url}`,\n });\n this.ctx.logger.warn(\"resource failed to load\", {\n \"error.type\": \"resource\",\n \"resource.url\": url,\n \"resource.tag\": target.tagName.toLowerCase(),\n });\n return;\n }\n\n if (!this.ctx.config.capture.errors) {\n return;\n }\n\n const errorEvent = event as ErrorEvent;\n const fallback = errorEvent.message === \"\" ? \"unknown error\" : errorEvent.message;\n const thrown: unknown = errorEvent.error;\n const error = thrown ?? new Error(fallback);\n\n this.report(\"window.onerror\", error, {\n // A signed script URL is a credential.\n \"error.source\": recordedUrl(\n errorEvent.filename,\n this.ctx.config.capture.fullUrls,\n this.ctx.config.capture.urlTransform,\n this.ctx.diagnostics,\n ),\n \"error.line\": errorEvent.lineno,\n \"error.column\": errorEvent.colno,\n });\n };\n\n /** Captures unhandled promise rejections. */\n private readonly onRejection = (event: PromiseRejectionEvent): void => {\n if (!this.ctx.config.capture.rejections) {\n return;\n }\n\n this.report(\"unhandledrejection\", event.reason, {\n \"error.type\": \"unhandledrejection\",\n });\n };\n\n /**\n * Rate limits, deduplicates and logs a captured error.\n * @param source Name of the capture event it came from.\n * @param error The caught error or thrown value.\n * @param extra Extra error attributes for the record.\n */\n private report(source: string, error: unknown, extra: Record<string, unknown>): void {\n if (\n !allowInWindow(\n this.window,\n this.ctx.config.capturePolicy.errorsPerWindow,\n this.ctx.diagnostics,\n \"errors\",\n this.ctx.config.capturePolicy.windowMs,\n )\n ) {\n return;\n }\n\n const now = Date.now();\n // A reason with no text form, for example a null-prototype object, gets an empty message,\n // and the record then uses the source as its message.\n const { message, key } = this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read the error reason. It records the error without its message.\",\n () => signatureOf(error),\n ) ?? { message: \"\", key: `${typeof error}||` };\n const previous = this.seen.get(key);\n\n if (previous && now - previous.at < this.ctx.config.capturePolicy.errorDedupeMs) {\n previous.count++;\n previous.at = now;\n return;\n }\n\n // How many occurrences deduplication dropped since the last report. Without this count,\n // many errors look like a few.\n const suppressed = previous ? previous.count - 1 : 0;\n\n // Delete, then set, to move the key to the end of the map. That keeps the map in\n // least-recently-reported order, which the eviction below relies on.\n this.seen.delete(key);\n this.seen.set(key, { at: now, count: 1 });\n\n // A page can throw with a new message on every render, for example from a template literal\n // in a loop. Without this cap, the map grows until the document closes.\n if (\n this.ctx.config.capturePolicy.maxErrorSignatures > 0 &&\n this.seen.size > this.ctx.config.capturePolicy.maxErrorSignatures\n ) {\n const [oldest] = this.seen.keys();\n this.seen.delete(oldest);\n }\n\n // Hand the logger the original value, so it converts the reason and keeps its data.\n // With no reason at all, the record still needs error.message and error.stack_trace.\n const reason = error === undefined ? new Error(message) : error;\n this.ctx.logger.error(message === \"\" ? source : message, reason, {\n ...extra,\n \"error.captured_by\": source,\n \"error.suppressed_count\": suppressed,\n });\n }\n}\n"],"mappings":";;;;AAgCA,SAASG,EAAY,GAA2B;CAC9C,IAAIH,EAAYI,CAAK,GAAG;EACtB,IAAMC,KAASD,EAAM,SAAS,GAAA,CAAI,MAAM,IAAI,CAAC,CAAC,MAAM;EACpD,OAAO;GAAE,SAASA,EAAM;GAAS,KAAK,GAAGA,EAAM,KAAK,GAAGA,EAAM,QAAQ,GAAGC;EAAQ;CAClF;CAEA,IAAMC,IAAU,OAAOF,CAAK;CAC5B,OAAO;EAAE;EAAS,KAAK,GAAG,OAAOA,EAAM,GAAGE,EAAQ;CAAG;AACvD;AAGA,IAAaC,IAAb,MAA6C;CAgBd;CAd7B,OAAgB;CAGhB,YAAoB;CAGpB,uBAAwB,IAAI,IAAuB;CAGnD,SAAuC;EAAE,OAAO;EAAG,OAAO;CAAE;CAK5D,YAAY,GAAsC;EAArB,KAAA,MAAAC;CAAsB;CAGnD,UAAgB;EACd,AAAI,KAAK,aAAa,OAAO,mBAAqB,QAGlD,KAAK,YAAY,IAGjB,iBAAiB,SAAS,KAAK,SAAS,EAAI,GAC5C,iBAAiB,sBAAsB,KAAK,WAAW;CACzD;CAGA,YAAkB;EAChB,AAAK,KAAK,cAGV,KAAK,YAAY,IAEjB,oBAAoB,SAAS,KAAK,SAAS,EAAI,GAC/C,oBAAoB,sBAAsB,KAAK,WAAW,GAC1D,KAAK,KAAK,MAAM;CAClB;CAGA,WAA4B,MAAoC;EAC9D,IAAMC,IAASC,EAAM,QACfC,IAAcF,GAAQ,OAAOA,GAAQ,QAAQ;EAGnD,IACEA,MAAW,QACXA,MAAY,cACZE,MAAgB,IAChB;GACA,IAAI,CAAC,KAAK,IAAI,OAAO,QAAQ,gBAC3B;GAKF,IAAMC,IAAMX,EACVU,GACA,KAAK,IAAI,OAAO,QAAQ,UACxB,KAAK,IAAI,OAAO,QAAQ,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AAMG,IAAaF,IAAWA,EAAS,QAAQ,IAAI;EASnD,IALA,KAAK,KAAK,OAAOC,CAAG,GACpB,KAAK,KAAK,IAAIA,GAAK;GAAE,IAAIF;GAAK,OAAO;EAAE,CAAC,GAKtC,KAAK,IAAI,OAAO,cAAc,qBAAqB,KACnD,KAAK,KAAK,OAAO,KAAK,IAAI,OAAO,cAAc,oBAC/C;GACA,IAAM,CAACI,KAAU,KAAK,KAAK,KAAK;GAChC,KAAK,KAAK,OAAOA,CAAM;EACzB;EAIA,IAAMC,IAASN,MAAU,KAAA,IAAgB,MAAMT,CAAO,IAAIS;EAC1D,KAAK,IAAI,OAAO,MAAMT,MAAY,KAAKgB,IAAShB,GAASe,GAAQ;GAC/D,GAAGE;GACH,qBAAqBD;GACrB,0BAA0BH;EAC5B,CAAC;CACH;AACF"}
@@ -1,3 +0,0 @@
1
- const e=require("./error-like-gGRx2s36.cjs"),t=require("./platform-12uR7kBQ.cjs"),n=require("./storm-D0_qZOEg.cjs");function r(t){if(e.r(t)){let e=(t.stack??``).split(`
2
- `)[1]??``;return{message:t.message,key:`${t.name}|${t.message}|${e}`}}let n=String(t);return{message:n,key:`${typeof t}|${n}|`}}var i=class{ctx;name=`errors`;installed=!1;seen=new Map;window={start:0,count:0};constructor(e){this.ctx=e}install(){this.installed||typeof addEventListener>`u`||(this.installed=!0,addEventListener(`error`,this.onError,!0),addEventListener(`unhandledrejection`,this.onRejection))}uninstall(){this.installed&&(this.installed=!1,removeEventListener(`error`,this.onError,!0),removeEventListener(`unhandledrejection`,this.onRejection),this.seen.clear())}onError=e=>{let n=e.target,r=n?.src??n?.href??``;if(n!==null&&n!==globalThis&&r!==``){if(!this.ctx.config.capture.resourceErrors)return;let e=t.i(r,this.ctx.config.capture.fullUrls,this.ctx.config.capture.urlTransform,this.ctx.diagnostics);this.ctx.breadcrumbs.push({t:Date.now(),category:`http`,message:`resource failed: ${e}`}),this.ctx.logger.warn(`resource failed to load`,{"error.type":`resource`,"resource.url":e,"resource.tag":n.tagName.toLowerCase()});return}if(!this.ctx.config.capture.errors)return;let i=e,a=i.message===``?`unknown error`:i.message,o=i.error??Error(a);this.report(`window.onerror`,o,{"error.source":t.i(i.filename,this.ctx.config.capture.fullUrls,this.ctx.config.capture.urlTransform,this.ctx.diagnostics),"error.line":i.lineno,"error.column":i.colno})};onRejection=e=>{this.ctx.config.capture.rejections&&this.report(`unhandledrejection`,e.reason,{"error.type":`unhandledrejection`})};report(e,t,i){if(!n.t(this.window,this.ctx.config.capturePolicy.errorsPerWindow,this.ctx.diagnostics,`errors`,this.ctx.config.capturePolicy.windowMs))return;let a=Date.now(),{message:o,key:s}=this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not read the error reason. It records the error without its message.`,()=>r(t))??{message:``,key:`${typeof t}||`},c=this.seen.get(s);if(c&&a-c.at<this.ctx.config.capturePolicy.errorDedupeMs){c.count++,c.at=a;return}let l=c?c.count-1:0;if(this.seen.delete(s),this.seen.set(s,{at:a,count:1}),this.ctx.config.capturePolicy.maxErrorSignatures>0&&this.seen.size>this.ctx.config.capturePolicy.maxErrorSignatures){let[e]=this.seen.keys();this.seen.delete(e)}let u=t===void 0?Error(o):t;this.ctx.logger.error(o===``?e:o,u,{...i,"error.captured_by":e,"error.suppressed_count":l})}};exports.ErrorCapture=i;
3
- //# sourceMappingURL=errors-DCOCRdSi.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors-DCOCRdSi.cjs","names":["isErrorLike","recordedUrl","allowInWindow","require_error_like","require_platform","require_storm","signatureOf","value","frame","message","ErrorCapture","ctx","target","event","resourceUrl","url","errorEvent","fallback","error","now","previous","key","suppressed","oldest","reason","source","extra"],"sources":["../src/capture/errors.ts"],"sourcesContent":["// src/capture/errors.ts\n//\n// Captures uncaught errors, unhandled rejections and failed resource loads.\n\nimport { isErrorLike } from \"../utils/error-like\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext } from \"./types\";\n\n/** Tracking metadata for a deduplicated error signature. */\ninterface SeenError {\n /** When the signature was last reported, in epoch milliseconds. */\n at: number;\n /** Occurrences recorded since the last report. */\n count: number;\n}\n\n/** A thrown value's message and deduplication key. */\ninterface Signature {\n /** The record's message. */\n message: string;\n /** Deduplication key. */\n key: string;\n}\n\n/**\n * Reads a thrown value's message and deduplication key.\n * Duck typing lets it read an error from another realm, which fails `instanceof Error`.\n * @param value Thrown value or rejection reason.\n * @returns The signature.\n * @throws When a getter or the value's text form throws. Call it inside a guard.\n */\nfunction signatureOf(value: unknown): Signature {\n if (isErrorLike(value)) {\n const frame = (value.stack ?? \"\").split(\"\\n\")[1] ?? \"\";\n return { message: value.message, key: `${value.name}|${value.message}|${frame}` };\n }\n\n const message = String(value);\n return { message, key: `${typeof value}|${message}|` };\n}\n\n/** Captures uncaught exceptions, unhandled promise rejections, and failed resource loads. */\nexport class ErrorCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"errors\";\n\n /** Prevents duplicate listener registration. */\n private installed = false;\n\n /** Recently reported error signatures in LRU order. */\n private readonly seen = new Map<string, SeenError>();\n\n /** This capture's own rate limit. Console noise has a separate window and can't use it. */\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n /**\n * @param ctx Capture context: configuration, diagnostics, logger and breadcrumbs.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Subscribes to global error and unhandledrejection events. */\n install(): void {\n if (this.installed || typeof addEventListener === \"undefined\") {\n return;\n }\n this.installed = true;\n\n // Resource load errors don't bubble, so listen in the capture phase.\n addEventListener(\"error\", this.onError, true);\n addEventListener(\"unhandledrejection\", this.onRejection);\n }\n\n /** Removes event listeners and clears tracked error signatures. */\n uninstall(): void {\n if (!this.installed) {\n return;\n }\n this.installed = false;\n\n removeEventListener(\"error\", this.onError, true);\n removeEventListener(\"unhandledrejection\", this.onRejection);\n this.seen.clear();\n }\n\n /** Routes resource load failures and uncaught script errors. */\n private readonly onError = (event: ErrorEvent | Event): void => {\n const target = event.target as (HTMLElement & { src?: string; href?: string }) | null;\n const resourceUrl = target?.src ?? target?.href ?? \"\";\n\n // An event from an element with a URL is a failed resource load, not a script error.\n if (\n target !== null &&\n target !== (globalThis as unknown as EventTarget) &&\n resourceUrl !== \"\"\n ) {\n if (!this.ctx.config.capture.resourceErrors) {\n return;\n }\n\n // A cache buster is noise and a signed URL is a credential, so the record keeps neither\n // unless you set fullUrls.\n const url = recordedUrl(\n resourceUrl,\n this.ctx.config.capture.fullUrls,\n this.ctx.config.capture.urlTransform,\n this.ctx.diagnostics,\n );\n\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"http\",\n message: `resource failed: ${url}`,\n });\n this.ctx.logger.warn(\"resource failed to load\", {\n \"error.type\": \"resource\",\n \"resource.url\": url,\n \"resource.tag\": target.tagName.toLowerCase(),\n });\n return;\n }\n\n if (!this.ctx.config.capture.errors) {\n return;\n }\n\n const errorEvent = event as ErrorEvent;\n const fallback = errorEvent.message === \"\" ? \"unknown error\" : errorEvent.message;\n const thrown: unknown = errorEvent.error;\n const error = thrown ?? new Error(fallback);\n\n this.report(\"window.onerror\", error, {\n // A signed script URL is a credential.\n \"error.source\": recordedUrl(\n errorEvent.filename,\n this.ctx.config.capture.fullUrls,\n this.ctx.config.capture.urlTransform,\n this.ctx.diagnostics,\n ),\n \"error.line\": errorEvent.lineno,\n \"error.column\": errorEvent.colno,\n });\n };\n\n /** Captures unhandled promise rejections. */\n private readonly onRejection = (event: PromiseRejectionEvent): void => {\n if (!this.ctx.config.capture.rejections) {\n return;\n }\n\n this.report(\"unhandledrejection\", event.reason, {\n \"error.type\": \"unhandledrejection\",\n });\n };\n\n /**\n * Rate limits, deduplicates and logs a captured error.\n * @param source Name of the capture event it came from.\n * @param error The caught error or thrown value.\n * @param extra Extra error attributes for the record.\n */\n private report(source: string, error: unknown, extra: Record<string, unknown>): void {\n if (\n !allowInWindow(\n this.window,\n this.ctx.config.capturePolicy.errorsPerWindow,\n this.ctx.diagnostics,\n \"errors\",\n this.ctx.config.capturePolicy.windowMs,\n )\n ) {\n return;\n }\n\n const now = Date.now();\n // A reason with no text form, for example a null-prototype object, gets an empty message,\n // and the record then uses the source as its message.\n const { message, key } = this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read the error reason. It records the error without its message.\",\n () => signatureOf(error),\n ) ?? { message: \"\", key: `${typeof error}||` };\n const previous = this.seen.get(key);\n\n if (previous && now - previous.at < this.ctx.config.capturePolicy.errorDedupeMs) {\n previous.count++;\n previous.at = now;\n return;\n }\n\n // How many occurrences deduplication dropped since the last report. Without this count,\n // many errors look like a few.\n const suppressed = previous ? previous.count - 1 : 0;\n\n // Delete, then set, to move the key to the end of the map. That keeps the map in\n // least-recently-reported order, which the eviction below relies on.\n this.seen.delete(key);\n this.seen.set(key, { at: now, count: 1 });\n\n // A page can throw with a new message on every render, for example from a template literal\n // in a loop. Without this cap, the map grows until the document closes.\n if (\n this.ctx.config.capturePolicy.maxErrorSignatures > 0 &&\n this.seen.size > this.ctx.config.capturePolicy.maxErrorSignatures\n ) {\n const [oldest] = this.seen.keys();\n this.seen.delete(oldest);\n }\n\n // Hand the logger the original value, so it converts the reason and keeps its data.\n // With no reason at all, the record still needs error.message and error.stack_trace.\n const reason = error === undefined ? new Error(message) : error;\n this.ctx.logger.error(message === \"\" ? source : message, reason, {\n ...extra,\n \"error.captured_by\": source,\n \"error.suppressed_count\": suppressed,\n });\n }\n}\n"],"mappings":"A,oHAgCA,SAASM,EAAY,EAA2B,CAC9C,GAAIN,EAAAA,EAAYO,CAAK,EAAG,CACtB,IAAMC,GAASD,EAAM,OAAS,GAAA,CAAI,MAAM;CAAI,CAAC,CAAC,IAAM,GACpD,MAAO,CAAE,QAASA,EAAM,QAAS,IAAK,GAAGA,EAAM,KAAK,GAAGA,EAAM,QAAQ,GAAGC,GAAQ,CAClF,CAEA,IAAMC,EAAU,OAAOF,CAAK,EAC5B,MAAO,CAAE,UAAS,IAAK,GAAG,OAAOA,EA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