@utk09/ui-observability 0.12.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (515) hide show
  1. package/CHANGELOG.md +420 -0
  2. package/README.md +72 -839
  3. package/dist/{batch-BjQUwjA6.js → batch-CXmPmTse.js} +4 -4
  4. package/dist/{batch-BjQUwjA6.js.map → batch-CXmPmTse.js.map} +1 -1
  5. package/dist/{batch-D5LlU4Q9.cjs → batch-mmPigCpi.cjs} +2 -2
  6. package/dist/{batch-D5LlU4Q9.cjs.map → batch-mmPigCpi.cjs.map} +1 -1
  7. package/dist/bus/bus.d.cts +331 -0
  8. package/dist/bus/bus.d.ts +60 -10
  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-ecxUNTja.js → bus-C39wspFV.js} +308 -193
  14. package/dist/bus-C39wspFV.js.map +1 -0
  15. package/dist/bus-_EaOVPGq.cjs +2 -0
  16. package/dist/bus-_EaOVPGq.cjs.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 +48 -0
  22. package/dist/capture/interactions.d.ts +1 -1
  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/profiler-frames.d.cts +44 -0
  30. package/dist/capture/profiler-frames.d.ts +1 -1
  31. package/dist/capture/replay-buffer.d.cts +45 -0
  32. package/dist/capture/replay-buffer.d.ts +9 -10
  33. package/dist/capture/replay-upload.d.cts +79 -0
  34. package/dist/capture/replay-upload.d.ts +7 -2
  35. package/dist/capture/replay.d.cts +114 -0
  36. package/dist/capture/replay.d.ts +1 -1
  37. package/dist/capture/reports.d.cts +17 -0
  38. package/dist/capture/reports.d.ts +1 -1
  39. package/dist/capture/resource-timing.d.cts +14 -0
  40. package/dist/capture/resource-timing.d.ts +1 -1
  41. package/dist/capture/server-timing.d.cts +19 -0
  42. package/dist/capture/storm.d.cts +13 -0
  43. package/dist/capture/storm.d.ts +5 -5
  44. package/dist/capture/types.d.cts +128 -0
  45. package/dist/capture/types.d.ts +10 -9
  46. package/dist/capture/unclean-exit.d.cts +31 -0
  47. package/dist/capture/unclean-exit.d.ts +1 -1
  48. package/dist/capture/user-timing.d.cts +22 -0
  49. package/dist/capture/user-timing.d.ts +2 -2
  50. package/dist/capture/web-socket.d.cts +40 -0
  51. package/dist/capture/web-socket.d.ts +3 -3
  52. package/dist/capture/web-vitals.d.cts +40 -0
  53. package/dist/capture/web-vitals.d.ts +1 -1
  54. package/dist/{compression-lD9abCcO.cjs → compression-CvED_Jel.cjs} +2 -2
  55. package/dist/{compression-lD9abCcO.cjs.map → compression-CvED_Jel.cjs.map} +1 -1
  56. package/dist/{compression-AJJCMBOa.js → compression-tVtXwVjX.js} +2 -2
  57. package/dist/{compression-AJJCMBOa.js.map → compression-tVtXwVjX.js.map} +1 -1
  58. package/dist/config-DUs7uHHt.cjs +2 -0
  59. package/dist/config-DUs7uHHt.cjs.map +1 -0
  60. package/dist/config-SgQcCP1_.js +560 -0
  61. package/dist/config-SgQcCP1_.js.map +1 -0
  62. package/dist/console-BGgGnjSi.js +81 -0
  63. package/dist/console-BGgGnjSi.js.map +1 -0
  64. package/dist/console-CSZ5_Vx5.cjs +2 -0
  65. package/dist/console-CSZ5_Vx5.cjs.map +1 -0
  66. package/dist/constants-CUyd9cTZ.js +357 -0
  67. package/dist/constants-CUyd9cTZ.js.map +1 -0
  68. package/dist/constants-CqdJhTxH.cjs +2 -0
  69. package/dist/constants-CqdJhTxH.cjs.map +1 -0
  70. package/dist/constants.d.cts +751 -0
  71. package/dist/constants.d.ts +88 -20
  72. package/dist/core/breadcrumbs.d.cts +54 -0
  73. package/dist/core/breadcrumbs.d.ts +5 -0
  74. package/dist/core/config.d.cts +45 -0
  75. package/dist/core/config.d.ts +30 -2
  76. package/dist/core/context.d.cts +24 -0
  77. package/dist/core/context.d.ts +3 -8
  78. package/dist/core/debug-buffer.d.cts +34 -0
  79. package/dist/core/debug-buffer.d.ts +3 -3
  80. package/dist/core/debug-bundle.d.cts +12 -0
  81. package/dist/core/debug-bundle.d.ts +3 -3
  82. package/dist/core/deferred.d.cts +7 -0
  83. package/dist/core/deferred.d.ts +2 -2
  84. package/dist/core/diagnostics.d.cts +86 -0
  85. package/dist/core/diagnostics.d.ts +1 -1
  86. package/dist/core/drops.d.cts +39 -0
  87. package/dist/core/drops.d.ts +16 -6
  88. package/dist/core/hold-buffer.d.cts +36 -0
  89. package/dist/core/hold-buffer.d.ts +16 -7
  90. package/dist/core/journey.d.cts +148 -0
  91. package/dist/core/journey.d.ts +7 -7
  92. package/dist/core/logger.d.cts +141 -0
  93. package/dist/core/logger.d.ts +23 -30
  94. package/dist/core/measure.d.cts +30 -0
  95. package/dist/core/measure.d.ts +14 -3
  96. package/dist/core/meter.d.cts +78 -0
  97. package/dist/core/meter.d.ts +14 -8
  98. package/dist/core/pipeline.d.cts +227 -0
  99. package/dist/core/pipeline.d.ts +73 -10
  100. package/dist/core/profile-buckets.d.cts +31 -0
  101. package/dist/core/profiler.d.cts +218 -0
  102. package/dist/core/profiler.d.ts +2 -2
  103. package/dist/core/record.d.cts +190 -0
  104. package/dist/core/record.d.ts +44 -12
  105. package/dist/core/remote-rules.d.cts +17 -0
  106. package/dist/core/remote-rules.d.ts +3 -3
  107. package/dist/core/remote-sampling.d.cts +74 -0
  108. package/dist/core/remote-sampling.d.ts +3 -3
  109. package/dist/core/rotation.d.cts +75 -0
  110. package/dist/core/rotation.d.ts +75 -0
  111. package/dist/core/runtime.d.cts +765 -0
  112. package/dist/core/runtime.d.ts +245 -70
  113. package/dist/core/sampling.d.cts +86 -0
  114. package/dist/core/sampling.d.ts +5 -5
  115. package/dist/core/sender.d.cts +161 -0
  116. package/dist/core/sender.d.ts +59 -15
  117. package/dist/core/spans.d.cts +39 -0
  118. package/dist/core/spans.d.ts +1 -1
  119. package/dist/debug-bundle-BXIlwDKM.cjs +2 -0
  120. package/dist/debug-bundle-BXIlwDKM.cjs.map +1 -0
  121. package/dist/debug-bundle-CRpYV_ui.js +35 -0
  122. package/dist/debug-bundle-CRpYV_ui.js.map +1 -0
  123. package/dist/defineProperty-X1c4tIPD.cjs +1 -0
  124. package/dist/defineProperty-s2S8BXUc.js +35 -0
  125. package/dist/doctor.cjs +1 -1
  126. package/dist/doctor.cjs.map +1 -1
  127. package/dist/doctor.d.cts +36 -0
  128. package/dist/doctor.d.ts +5 -2
  129. package/dist/doctor.js +121 -89
  130. package/dist/doctor.js.map +1 -1
  131. package/dist/errors-BE_EZV7Q.js +86 -0
  132. package/dist/errors-BE_EZV7Q.js.map +1 -0
  133. package/dist/errors-CNPbesMs.cjs +3 -0
  134. package/dist/errors-CNPbesMs.cjs.map +1 -0
  135. package/dist/factory-CTi0Is3F.js +404 -0
  136. package/dist/factory-CTi0Is3F.js.map +1 -0
  137. package/dist/factory-hRrH32v5.cjs +2 -0
  138. package/dist/factory-hRrH32v5.cjs.map +1 -0
  139. package/dist/guards-BlYGRK4l.js +10 -0
  140. package/dist/guards-BlYGRK4l.js.map +1 -0
  141. package/dist/guards-EjG3ahFp.cjs +2 -0
  142. package/dist/guards-EjG3ahFp.cjs.map +1 -0
  143. package/dist/{identity-BrQp_5J5.js → identity-DdhKgrpk.js} +20 -24
  144. package/dist/identity-DdhKgrpk.js.map +1 -0
  145. package/dist/identity-DlWRIuwy.cjs +2 -0
  146. package/dist/identity-DlWRIuwy.cjs.map +1 -0
  147. package/dist/index.cjs +1 -1
  148. package/dist/index.cjs.map +1 -1
  149. package/dist/index.d.cts +300 -0
  150. package/dist/index.d.ts +89 -98
  151. package/dist/index.js +1173 -1506
  152. package/dist/index.js.map +1 -1
  153. package/dist/indexeddb-storage-CL9uqBCy.cjs +2 -0
  154. package/dist/indexeddb-storage-CL9uqBCy.cjs.map +1 -0
  155. package/dist/{indexeddb-storage-DLXQzAGh.js → indexeddb-storage-GHdl0t8A.js} +51 -47
  156. package/dist/indexeddb-storage-GHdl0t8A.js.map +1 -0
  157. package/dist/interactions-CUkzK8sR.cjs +2 -0
  158. package/dist/interactions-CUkzK8sR.cjs.map +1 -0
  159. package/dist/{interactions-B6z2I4tU.js → interactions-DiFvCosX.js} +41 -49
  160. package/dist/interactions-DiFvCosX.js.map +1 -0
  161. package/dist/journey-B4Adltjm.cjs +2 -0
  162. package/dist/journey-B4Adltjm.cjs.map +1 -0
  163. package/dist/{journey-35yCMNFo.js → journey-D2_sia57.js} +45 -48
  164. package/dist/journey-D2_sia57.js.map +1 -0
  165. package/dist/{library-console-Dl_Ly6DQ.js → library-console-Btrzt814.js} +2 -2
  166. package/dist/{library-console-Dl_Ly6DQ.js.map → library-console-Btrzt814.js.map} +1 -1
  167. package/dist/{library-console-BFWEuQsl.cjs → library-console-CPW6bvZH.cjs} +2 -2
  168. package/dist/{library-console-BFWEuQsl.cjs.map → library-console-CPW6bvZH.cjs.map} +1 -1
  169. package/dist/{library-request-nI6pvI6I.js → library-request-BJ9PLRaD.js} +2 -2
  170. package/dist/{library-request-nI6pvI6I.js.map → library-request-BJ9PLRaD.js.map} +1 -1
  171. package/dist/{library-request-Da-CHKzT.cjs → library-request-D7OvTxZV.cjs} +2 -2
  172. package/dist/{library-request-Da-CHKzT.cjs.map → library-request-D7OvTxZV.cjs.map} +1 -1
  173. package/dist/{lifecycle-CZ6RRXc6.js → lifecycle-22CUCrc9.js} +21 -29
  174. package/dist/lifecycle-22CUCrc9.js.map +1 -0
  175. package/dist/lifecycle-IaAm1mOC.cjs +2 -0
  176. package/dist/lifecycle-IaAm1mOC.cjs.map +1 -0
  177. package/dist/{log-record-DIA6McNr.js → log-record-BNiLfqtL.js} +8 -7
  178. package/dist/log-record-BNiLfqtL.js.map +1 -0
  179. package/dist/log-record-CkivuiEl.cjs +2 -0
  180. package/dist/log-record-CkivuiEl.cjs.map +1 -0
  181. package/dist/long-frames-BUUbXd-B.cjs +2 -0
  182. package/dist/long-frames-BUUbXd-B.cjs.map +1 -0
  183. package/dist/{long-frames-430_85Da.js → long-frames-DNFaRnC3.js} +18 -22
  184. package/dist/long-frames-DNFaRnC3.js.map +1 -0
  185. package/dist/models/batch.d.cts +57 -0
  186. package/dist/models/batch.d.ts +2 -2
  187. package/dist/models/bus.d.cts +158 -0
  188. package/dist/models/bus.d.ts +22 -2
  189. package/dist/models/config.d.cts +1540 -0
  190. package/dist/models/config.d.ts +360 -259
  191. package/dist/models/drop.d.cts +54 -0
  192. package/dist/models/drop.d.ts +16 -3
  193. package/dist/models/health.d.cts +148 -0
  194. package/dist/models/health.d.ts +108 -12
  195. package/dist/models/log-record.d.cts +61 -0
  196. package/dist/models/metric.d.cts +139 -0
  197. package/dist/models/metric.d.ts +13 -2
  198. package/dist/models/plugin.d.cts +47 -0
  199. package/dist/models/plugin.d.ts +3 -3
  200. package/dist/models/replay.d.cts +60 -0
  201. package/dist/models/serializer.d.cts +23 -0
  202. package/dist/models/serializer.d.ts +1 -1
  203. package/dist/models/storage.d.cts +95 -0
  204. package/dist/models/storage.d.ts +7 -5
  205. package/dist/network-CGMLQ-mA.cjs +2 -0
  206. package/dist/network-CGMLQ-mA.cjs.map +1 -0
  207. package/dist/{network-C7SkLf4v.js → network-on2zZT6H.js} +51 -51
  208. package/dist/network-on2zZT6H.js.map +1 -0
  209. package/dist/{otlp-2MCrC3kd.cjs → otlp-BENHf3g9.cjs} +2 -2
  210. package/dist/{otlp-2MCrC3kd.cjs.map → otlp-BENHf3g9.cjs.map} +1 -1
  211. package/dist/{otlp-COq033e3.js → otlp-DimfrRor.js} +12 -12
  212. package/dist/{otlp-COq033e3.js.map → otlp-DimfrRor.js.map} +1 -1
  213. package/dist/{platform-CVewe4wQ.js → platform-BaaFIPCU.js} +10 -10
  214. package/dist/{platform-CVewe4wQ.js.map → platform-BaaFIPCU.js.map} +1 -1
  215. package/dist/{platform-12uR7kBQ.cjs → platform-CfA3-7sJ.cjs} +2 -2
  216. package/dist/{platform-12uR7kBQ.cjs.map → platform-CfA3-7sJ.cjs.map} +1 -1
  217. package/dist/{profiler-BVWIOgnq.js → profiler-BAZoh7A4.js} +89 -107
  218. package/dist/profiler-BAZoh7A4.js.map +1 -0
  219. package/dist/profiler-D4tJpDRc.cjs +2 -0
  220. package/dist/profiler-D4tJpDRc.cjs.map +1 -0
  221. package/dist/profiler-frames-C4xr7KfH.cjs +2 -0
  222. package/dist/profiler-frames-C4xr7KfH.cjs.map +1 -0
  223. package/dist/{profiler-frames-CLXlT_xL.js → profiler-frames-cJMx9wNM.js} +29 -37
  224. package/dist/profiler-frames-cJMx9wNM.js.map +1 -0
  225. package/dist/remote-rules-Dz9MRAsB.js +95 -0
  226. package/dist/remote-rules-Dz9MRAsB.js.map +1 -0
  227. package/dist/remote-rules-_tY0zj5o.cjs +2 -0
  228. package/dist/remote-rules-_tY0zj5o.cjs.map +1 -0
  229. package/dist/replay-B3gFXIZd.cjs +2 -0
  230. package/dist/replay-B3gFXIZd.cjs.map +1 -0
  231. package/dist/replay-Ds-ANH34.js +310 -0
  232. package/dist/replay-Ds-ANH34.js.map +1 -0
  233. package/dist/reports-BDSe4dFH.cjs +2 -0
  234. package/dist/reports-BDSe4dFH.cjs.map +1 -0
  235. package/dist/{reports-BuXekPOS.js → reports-C-thq-bk.js} +25 -30
  236. package/dist/reports-C-thq-bk.js.map +1 -0
  237. package/dist/resource-timing-C576gFIQ.cjs +2 -0
  238. package/dist/resource-timing-C576gFIQ.cjs.map +1 -0
  239. package/dist/{resource-timing-CXGHwFRD.js → resource-timing-eUl2dNgC.js} +20 -23
  240. package/dist/resource-timing-eUl2dNgC.js.map +1 -0
  241. package/dist/response-body-YdNl-HkR.cjs +3 -0
  242. package/dist/response-body-YdNl-HkR.cjs.map +1 -0
  243. package/dist/response-body-eoSQpLiH.js +331 -0
  244. package/dist/response-body-eoSQpLiH.js.map +1 -0
  245. package/dist/rotation-Cwct4ckk.js +94 -0
  246. package/dist/rotation-Cwct4ckk.js.map +1 -0
  247. package/dist/rotation-D4qUAHAu.cjs +2 -0
  248. package/dist/rotation-D4qUAHAu.cjs.map +1 -0
  249. package/dist/sampling-BlrI8jor.js +63 -0
  250. package/dist/sampling-BlrI8jor.js.map +1 -0
  251. package/dist/sampling-mXt4dstx.cjs +2 -0
  252. package/dist/sampling-mXt4dstx.cjs.map +1 -0
  253. package/dist/{sanitize-CNmsD9r3.js → sanitize-Ba0KqU06.js} +2 -2
  254. package/dist/sanitize-Ba0KqU06.js.map +1 -0
  255. package/dist/{sanitize-ChLn97Ch.cjs → sanitize-DQyiI_KY.cjs} +2 -2
  256. package/dist/sanitize-DQyiI_KY.cjs.map +1 -0
  257. package/dist/sender-BdRuNVhF.cjs +2 -0
  258. package/dist/sender-BdRuNVhF.cjs.map +1 -0
  259. package/dist/sender-Dv8rAmpV.js +979 -0
  260. package/dist/sender-Dv8rAmpV.js.map +1 -0
  261. package/dist/storage/context-storage.d.cts +90 -0
  262. package/dist/storage/context-storage.d.ts +5 -5
  263. package/dist/storage/emergency-queue.d.cts +27 -0
  264. package/dist/storage/emergency-queue.d.ts +4 -4
  265. package/dist/storage/eviction.d.cts +40 -0
  266. package/dist/storage/eviction.d.ts +1 -1
  267. package/dist/storage/factory.d.cts +21 -0
  268. package/dist/storage/factory.d.ts +3 -3
  269. package/dist/storage/gap.d.cts +20 -0
  270. package/dist/storage/gap.d.ts +3 -3
  271. package/dist/storage/idb-driver.d.cts +93 -0
  272. package/dist/storage/idb-driver.d.ts +1 -1
  273. package/dist/storage/indexeddb-storage.d.cts +97 -0
  274. package/dist/storage/indexeddb-storage.d.ts +12 -4
  275. package/dist/storage/keys.d.cts +17 -0
  276. package/dist/storage/keys.d.ts +2 -2
  277. package/dist/storage/local-storage.d.cts +139 -0
  278. package/dist/storage/local-storage.d.ts +11 -4
  279. package/dist/storage/memory-storage.d.cts +73 -0
  280. package/dist/storage/memory-storage.d.ts +4 -3
  281. package/dist/storage/persistence.d.cts +8 -0
  282. package/dist/storage/persistence.d.ts +2 -2
  283. package/dist/storage/stored-context.d.cts +34 -0
  284. package/dist/storage/stored-context.d.ts +34 -0
  285. package/dist/stored-context-B2EzVuYm.js +51 -0
  286. package/dist/stored-context-B2EzVuYm.js.map +1 -0
  287. package/dist/stored-context-CXt7eHZL.cjs +2 -0
  288. package/dist/stored-context-CXt7eHZL.cjs.map +1 -0
  289. package/dist/storm-C-zYSdDX.cjs +2 -0
  290. package/dist/storm-C-zYSdDX.cjs.map +1 -0
  291. package/dist/storm-DjKetLKZ.js +9 -0
  292. package/dist/storm-DjKetLKZ.js.map +1 -0
  293. package/dist/transport/compression.d.cts +7 -0
  294. package/dist/transport/custom-transport.d.cts +22 -0
  295. package/dist/transport/custom-transport.d.ts +6 -5
  296. package/dist/transport/errors.d.cts +31 -0
  297. package/dist/transport/exit-flush.d.cts +135 -0
  298. package/dist/transport/exit-flush.d.ts +30 -13
  299. package/dist/transport/headers.d.cts +8 -0
  300. package/dist/transport/headers.d.ts +2 -2
  301. package/dist/transport/http-transport.d.cts +116 -0
  302. package/dist/transport/http-transport.d.ts +20 -8
  303. package/dist/transport/memory-transport.d.cts +30 -0
  304. package/dist/transport/memory-transport.d.ts +2 -2
  305. package/dist/transport/response-body.d.cts +49 -0
  306. package/dist/transport/response-body.d.ts +49 -0
  307. package/dist/transport/retry-engine.d.cts +129 -0
  308. package/dist/transport/retry-engine.d.ts +27 -9
  309. package/dist/transport/serializers/ecs.d.cts +3 -0
  310. package/dist/transport/serializers/ecs.d.ts +1 -1
  311. package/dist/transport/serializers/otlp-metrics.d.cts +3 -0
  312. package/dist/transport/serializers/otlp-metrics.d.ts +1 -1
  313. package/dist/transport/serializers/otlp-traces.d.cts +3 -0
  314. package/dist/transport/serializers/otlp-traces.d.ts +1 -1
  315. package/dist/transport/serializers/otlp.d.cts +47 -0
  316. package/dist/transport/serializers/otlp.d.ts +2 -2
  317. package/dist/transport/serializers/select.d.cts +38 -0
  318. package/dist/transport/serializers/select.d.ts +5 -5
  319. package/dist/transport/status-transport.d.cts +129 -0
  320. package/dist/transport/status-transport.d.ts +25 -8
  321. package/dist/transport/worker-client.d.cts +23 -0
  322. package/dist/transport/worker-client.d.ts +12 -3
  323. package/dist/transport/worker-entry.d.cts +5 -0
  324. package/dist/transport/worker-entry.d.ts +1 -1
  325. package/dist/transport/worker-protocol.d.cts +38 -0
  326. package/dist/transport/worker-protocol.d.ts +4 -2
  327. package/dist/transport/worker-server.d.cts +3 -0
  328. package/dist/transport/worker-server.d.ts +1 -1
  329. package/dist/transport/worker-transport.d.cts +10 -0
  330. package/dist/transport/worker-transport.d.ts +5 -4
  331. package/dist/types-BAerHgCq.js.map +1 -1
  332. package/dist/types-C7WNpnG1.cjs.map +1 -1
  333. package/dist/{unclean-exit-Cob_jyTv.js → unclean-exit-DQD1cT7c.js} +23 -30
  334. package/dist/unclean-exit-DQD1cT7c.js.map +1 -0
  335. package/dist/unclean-exit-py99ApzT.cjs +2 -0
  336. package/dist/unclean-exit-py99ApzT.cjs.map +1 -0
  337. package/dist/{user-timing-DgHubxCI.js → user-timing-BePqb1uN.js} +15 -17
  338. package/dist/user-timing-BePqb1uN.js.map +1 -0
  339. package/dist/user-timing-D6XTmpuM.cjs +2 -0
  340. package/dist/user-timing-D6XTmpuM.cjs.map +1 -0
  341. package/dist/utils/console.d.cts +36 -0
  342. package/dist/utils/console.d.ts +4 -4
  343. package/dist/utils/deadline.d.cts +14 -0
  344. package/dist/utils/error-like.d.cts +25 -0
  345. package/dist/utils/fixed-window.d.cts +25 -0
  346. package/dist/utils/global-scope.d.cts +20 -0
  347. package/dist/utils/guards.d.cts +14 -0
  348. package/dist/utils/guards.d.ts +8 -0
  349. package/dist/utils/identity.d.cts +109 -0
  350. package/dist/utils/identity.d.ts +3 -4
  351. package/dist/utils/library-console.d.cts +11 -0
  352. package/dist/utils/library-request.d.cts +24 -0
  353. package/dist/utils/lock.d.cts +24 -0
  354. package/dist/utils/lock.d.ts +1 -1
  355. package/dist/utils/openfin.d.cts +48 -0
  356. package/dist/utils/patch.d.cts +9 -0
  357. package/dist/utils/platform.d.cts +62 -0
  358. package/dist/utils/platform.d.ts +2 -2
  359. package/dist/utils/sanitize.d.cts +52 -0
  360. package/dist/utils/sanitize.d.ts +1 -1
  361. package/dist/utils/sequence.d.cts +10 -0
  362. package/dist/utils/tracing.d.cts +158 -0
  363. package/dist/utils/tracing.d.ts +11 -4
  364. package/dist/utils/unref.d.cts +9 -0
  365. package/dist/web-socket-CoIUBM3C.cjs +2 -0
  366. package/dist/{web-socket-DthJuSAg.js.map → web-socket-CoIUBM3C.cjs.map} +1 -1
  367. package/dist/{web-socket-DthJuSAg.js → web-socket-DSHgDiZ6.js} +23 -28
  368. package/dist/web-socket-DSHgDiZ6.js.map +1 -0
  369. package/dist/{web-vitals-CsGCWnUr.js → web-vitals-4pWACwaR.js} +15 -21
  370. package/dist/web-vitals-4pWACwaR.js.map +1 -0
  371. package/dist/web-vitals-__X7t4pj.cjs +2 -0
  372. package/dist/web-vitals-__X7t4pj.cjs.map +1 -0
  373. package/dist/worker-protocol-QbvqNazn.cjs +2 -0
  374. package/dist/worker-protocol-QbvqNazn.cjs.map +1 -0
  375. package/dist/{worker-protocol-B0_8rWy5.js → worker-protocol-x074Rpet.js} +14 -11
  376. package/dist/worker-protocol-x074Rpet.js.map +1 -0
  377. package/dist/worker-server-CFe4nvos.cjs +2 -0
  378. package/dist/worker-server-CFe4nvos.cjs.map +1 -0
  379. package/dist/worker-server-iUVSjH8L.js +94 -0
  380. package/dist/worker-server-iUVSjH8L.js.map +1 -0
  381. package/dist/worker-transport-CRAX-09c.cjs +2 -0
  382. package/dist/worker-transport-CRAX-09c.cjs.map +1 -0
  383. package/dist/worker-transport-Dy1KMA7t.js +190 -0
  384. package/dist/worker-transport-Dy1KMA7t.js.map +1 -0
  385. package/llms.txt +397 -0
  386. package/package.json +54 -46
  387. package/dist/bus-D_7pd7RN.cjs +0 -2
  388. package/dist/bus-D_7pd7RN.cjs.map +0 -1
  389. package/dist/bus-ecxUNTja.js.map +0 -1
  390. package/dist/console-CLz_PvFn.cjs +0 -2
  391. package/dist/console-CLz_PvFn.cjs.map +0 -1
  392. package/dist/console-cwgHKXvM.js +0 -82
  393. package/dist/console-cwgHKXvM.js.map +0 -1
  394. package/dist/constants-Bwl_YtQi.js +0 -349
  395. package/dist/constants-Bwl_YtQi.js.map +0 -1
  396. package/dist/constants-DakMxVB2.cjs +0 -2
  397. package/dist/constants-DakMxVB2.cjs.map +0 -1
  398. package/dist/context-storage-BjzeBSxH.cjs +0 -2
  399. package/dist/context-storage-BjzeBSxH.cjs.map +0 -1
  400. package/dist/context-storage-BzkoHzkQ.js +0 -51
  401. package/dist/context-storage-BzkoHzkQ.js.map +0 -1
  402. package/dist/debug-bundle-BOdYmCeV.js +0 -32
  403. package/dist/debug-bundle-BOdYmCeV.js.map +0 -1
  404. package/dist/debug-bundle-Ex4L_LSP.cjs +0 -2
  405. package/dist/debug-bundle-Ex4L_LSP.cjs.map +0 -1
  406. package/dist/emergency-queue-B9WZxanZ.js +0 -67
  407. package/dist/emergency-queue-B9WZxanZ.js.map +0 -1
  408. package/dist/emergency-queue-HBpL5r3V.cjs +0 -2
  409. package/dist/emergency-queue-HBpL5r3V.cjs.map +0 -1
  410. package/dist/errors-D6bwgJtO.js +0 -92
  411. package/dist/errors-D6bwgJtO.js.map +0 -1
  412. package/dist/errors-DCOCRdSi.cjs +0 -3
  413. package/dist/errors-DCOCRdSi.cjs.map +0 -1
  414. package/dist/factory-DLFDjdLv.cjs +0 -2
  415. package/dist/factory-DLFDjdLv.cjs.map +0 -1
  416. package/dist/factory-e9Qo3K0z.js +0 -276
  417. package/dist/factory-e9Qo3K0z.js.map +0 -1
  418. package/dist/guards-Cidk71ME.js +0 -7
  419. package/dist/guards-Cidk71ME.js.map +0 -1
  420. package/dist/guards-nJ70syPt.cjs +0 -2
  421. package/dist/guards-nJ70syPt.cjs.map +0 -1
  422. package/dist/identity-BlvlgjrU.cjs +0 -2
  423. package/dist/identity-BlvlgjrU.cjs.map +0 -1
  424. package/dist/identity-BrQp_5J5.js.map +0 -1
  425. package/dist/indexeddb-storage-CtLvZH1r.cjs +0 -2
  426. package/dist/indexeddb-storage-CtLvZH1r.cjs.map +0 -1
  427. package/dist/indexeddb-storage-DLXQzAGh.js.map +0 -1
  428. package/dist/interactions-B6z2I4tU.js.map +0 -1
  429. package/dist/interactions-P6pz08Jn.cjs +0 -2
  430. package/dist/interactions-P6pz08Jn.cjs.map +0 -1
  431. package/dist/journey-35yCMNFo.js.map +0 -1
  432. package/dist/journey-DAGh5h9k.cjs +0 -2
  433. package/dist/journey-DAGh5h9k.cjs.map +0 -1
  434. package/dist/keys-BHhw_0Wh.cjs +0 -2
  435. package/dist/keys-BHhw_0Wh.cjs.map +0 -1
  436. package/dist/keys-BU9j5YqW.js +0 -16
  437. package/dist/keys-BU9j5YqW.js.map +0 -1
  438. package/dist/lifecycle-BGGOcN4N.cjs +0 -2
  439. package/dist/lifecycle-BGGOcN4N.cjs.map +0 -1
  440. package/dist/lifecycle-CZ6RRXc6.js.map +0 -1
  441. package/dist/log-record-D7bA1RPb.cjs +0 -2
  442. package/dist/log-record-D7bA1RPb.cjs.map +0 -1
  443. package/dist/log-record-DIA6McNr.js.map +0 -1
  444. package/dist/long-frames-430_85Da.js.map +0 -1
  445. package/dist/long-frames-Dd8tsi2U.cjs +0 -2
  446. package/dist/long-frames-Dd8tsi2U.cjs.map +0 -1
  447. package/dist/models/stats.d.ts +0 -11
  448. package/dist/network-C7SkLf4v.js.map +0 -1
  449. package/dist/network-pEX3PAJv.cjs +0 -2
  450. package/dist/network-pEX3PAJv.cjs.map +0 -1
  451. package/dist/profiler-BVWIOgnq.js.map +0 -1
  452. package/dist/profiler-eVCknCzS.cjs +0 -2
  453. package/dist/profiler-eVCknCzS.cjs.map +0 -1
  454. package/dist/profiler-frames-CLXlT_xL.js.map +0 -1
  455. package/dist/profiler-frames-Dg2OebB2.cjs +0 -2
  456. package/dist/profiler-frames-Dg2OebB2.cjs.map +0 -1
  457. package/dist/remote-rules-BJGDJGwA.js +0 -98
  458. package/dist/remote-rules-BJGDJGwA.js.map +0 -1
  459. package/dist/remote-rules-CJD3ToVk.cjs +0 -2
  460. package/dist/remote-rules-CJD3ToVk.cjs.map +0 -1
  461. package/dist/replay-0zAJv9T3.js +0 -338
  462. package/dist/replay-0zAJv9T3.js.map +0 -1
  463. package/dist/replay-DomJpXqW.cjs +0 -2
  464. package/dist/replay-DomJpXqW.cjs.map +0 -1
  465. package/dist/reports-BsbqmP8h.cjs +0 -2
  466. package/dist/reports-BsbqmP8h.cjs.map +0 -1
  467. package/dist/reports-BuXekPOS.js.map +0 -1
  468. package/dist/resource-timing-CXGHwFRD.js.map +0 -1
  469. package/dist/resource-timing-DkycFGDa.cjs +0 -2
  470. package/dist/resource-timing-DkycFGDa.cjs.map +0 -1
  471. package/dist/sampling-Dd0wllyq.cjs +0 -2
  472. package/dist/sampling-Dd0wllyq.cjs.map +0 -1
  473. package/dist/sampling-UUDbi3K0.js +0 -60
  474. package/dist/sampling-UUDbi3K0.js.map +0 -1
  475. package/dist/sanitize-CNmsD9r3.js.map +0 -1
  476. package/dist/sanitize-ChLn97Ch.cjs.map +0 -1
  477. package/dist/select-CTk-K5mG.cjs +0 -3
  478. package/dist/select-CTk-K5mG.cjs.map +0 -1
  479. package/dist/select-DPv_j6wq.js +0 -270
  480. package/dist/select-DPv_j6wq.js.map +0 -1
  481. package/dist/sender-15zEsZpr.js +0 -857
  482. package/dist/sender-15zEsZpr.js.map +0 -1
  483. package/dist/sender-Bfpv9tad.cjs +0 -2
  484. package/dist/sender-Bfpv9tad.cjs.map +0 -1
  485. package/dist/storage-BA9RqRO-.cjs +0 -2
  486. package/dist/storage-BA9RqRO-.cjs.map +0 -1
  487. package/dist/storage-DZwed89z.js +0 -16
  488. package/dist/storage-DZwed89z.js.map +0 -1
  489. package/dist/storm-BTSNTIWI.js +0 -9
  490. package/dist/storm-BTSNTIWI.js.map +0 -1
  491. package/dist/storm-D0_qZOEg.cjs +0 -2
  492. package/dist/storm-D0_qZOEg.cjs.map +0 -1
  493. package/dist/unclean-exit-ClGzrc2A.cjs +0 -2
  494. package/dist/unclean-exit-ClGzrc2A.cjs.map +0 -1
  495. package/dist/unclean-exit-Cob_jyTv.js.map +0 -1
  496. package/dist/user-timing-CdYqx3PF.cjs +0 -2
  497. package/dist/user-timing-CdYqx3PF.cjs.map +0 -1
  498. package/dist/user-timing-DgHubxCI.js.map +0 -1
  499. package/dist/utils/timer.d.ts +0 -19
  500. package/dist/web-socket-BTuvYoJI.cjs +0 -2
  501. package/dist/web-socket-BTuvYoJI.cjs.map +0 -1
  502. package/dist/web-vitals-Ch5BpDmo.cjs +0 -2
  503. package/dist/web-vitals-Ch5BpDmo.cjs.map +0 -1
  504. package/dist/web-vitals-CsGCWnUr.js.map +0 -1
  505. package/dist/worker-protocol-B0_8rWy5.js.map +0 -1
  506. package/dist/worker-protocol-BjzFORfq.cjs +0 -2
  507. package/dist/worker-protocol-BjzFORfq.cjs.map +0 -1
  508. package/dist/worker-server-4en-Lt-3.cjs +0 -2
  509. package/dist/worker-server-4en-Lt-3.cjs.map +0 -1
  510. package/dist/worker-server-Cne9MX9I.js +0 -83
  511. package/dist/worker-server-Cne9MX9I.js.map +0 -1
  512. package/dist/worker-transport-B-GF4Aqn.cjs +0 -2
  513. package/dist/worker-transport-B-GF4Aqn.cjs.map +0 -1
  514. package/dist/worker-transport-C3SjJAEC.js +0 -200
  515. package/dist/worker-transport-C3SjJAEC.js.map +0 -1
@@ -0,0 +1,51 @@
1
+ import { Et as e, Zn as t, zn as n } from "./constants-CUyd9cTZ.js";
2
+ import { f as r, n as i, p as a, s as o, t as s } from "./factory-CTi0Is3F.js";
3
+ import { i as c, t as l } from "./identity-DdhKgrpk.js";
4
+ // src/storage/stored-context.ts
5
+ var u = [
6
+ ["local", n],
7
+ ["session", t],
8
+ ["session", e]
9
+ ];
10
+ async function d(e, t) {
11
+ let { config: n, diagnostics: o, memory: c } = e, { backend: l, namespace: u } = n.storage, d = c ?? await s(l, i(u), a(n.retention), o, void 0, u), f = new r(d, n.securityContext, u);
12
+ try {
13
+ await t(f);
14
+ } finally {
15
+ d !== c && await f.close();
16
+ }
17
+ }
18
+ function f(e, t, n, r = !1) {
19
+ if (r) for (let [t, n] of u) e.diagnostics.guard("storage.unavailable", `The library could not remove ${n} from ${t}Storage.`, () => {
20
+ l[t]().removeItem(n);
21
+ });
22
+ return d(e, async (r) => {
23
+ for (let e of n) await r.remove(e);
24
+ t === "namespace" ? await r.clearNamespace() : await r.clear();
25
+ let { diagnostics: i, config: a } = e;
26
+ o(a.securityContext.id, i, r.namespace, t === "namespace");
27
+ });
28
+ }
29
+ function p(e, t, n) {
30
+ return d(e, async (r) => {
31
+ let i = [...n];
32
+ if (t.length > 0) {
33
+ let n = c(e.diagnostics);
34
+ i.push({
35
+ id: n,
36
+ records: [...t],
37
+ createdAt: Date.now(),
38
+ attempts: 0
39
+ });
40
+ }
41
+ for (let t of i) await r.save({
42
+ ...t,
43
+ attempts: 0,
44
+ routingContextId: e.config.securityContext.id,
45
+ persistenceNamespace: r.namespace
46
+ });
47
+ });
48
+ }
49
+ export { f as clearStored, p as keepStored };
50
+
51
+ //# sourceMappingURL=stored-context-B2EzVuYm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-context-B2EzVuYm.js","names":["JOURNEY_STORAGE_KEY","TAB_ID_KEY","SESSION_ID_KEY","ContextStorage","storageName","storageLimits","clearEmergencyContext","createStorage","newId","BROWSER_STORES","STORED_IDS","withStore","access","config","backing","memory","backend","namespace","diagnostics","store","work","clearStored","forgetIds","key","id","ids","scope","keepStored","all","batches","records","batch"],"sources":["../src/storage/stored-context.ts"],"sourcesContent":["// src/storage/stored-context.ts\n//\n// Reaches the configured store when no delivery stack runs. shutdown() with clearStorage and a\n// rotation with no old sender need it, because otherwise only a sender opens the store.\n\nimport { JOURNEY_STORAGE_KEY, SESSION_ID_KEY, TAB_ID_KEY } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { LogBatch } from \"../models/batch\";\nimport type { ResolvedConfig } from \"../models/config\";\nimport type { LogRecord } from \"../models/log-record\";\nimport { type StorageAdapter, storageLimits } from \"../models/storage\";\nimport { BROWSER_STORES, newId } from \"../utils/identity\";\nimport { ContextStorage } from \"./context-storage\";\nimport { clearEmergencyContext } from \"./emergency-queue\";\nimport { createStorage, storageName } from \"./factory\";\n\n/** The stored ids that a shutdown with clearStorage removes: the session, the tab and the journey. */\nconst STORED_IDS = [\n [\"local\", SESSION_ID_KEY],\n [\"session\", TAB_ID_KEY],\n [\"session\", JOURNEY_STORAGE_KEY],\n] as const;\n\n/** What opening the store needs. The active context is the one in `config.securityContext`. */\nexport interface StoreAccess {\n /** Active configuration instance. */\n config: ResolvedConfig;\n /** Diagnostics reporter. */\n diagnostics: Diagnostics;\n /** The memory store the runtime keeps across context changes, if it has one. */\n memory: StorageAdapter | undefined;\n}\n\n/**\n * Opens the store for the active context, runs the work, then closes the store again. The\n * memory store stays open, because it holds other contexts' records too.\n * @param access The config, the reporter and the kept memory store.\n * @param work What to do with the store.\n * @returns Promise that resolves once the work is done and the store is closed.\n */\nasync function withStore(\n access: StoreAccess,\n work: (store: ContextStorage) => Promise<void>,\n): Promise<void> {\n const { config, diagnostics, memory } = access;\n const { backend, namespace } = config.storage;\n const backing =\n memory ??\n (await createStorage(\n backend,\n storageName(namespace),\n storageLimits(config.retention),\n diagnostics,\n undefined,\n namespace,\n ));\n const store = new ContextStorage(backing, config.securityContext, namespace);\n try {\n await work(store);\n } finally {\n if (backing !== memory) {\n await store.close();\n }\n }\n}\n\n/**\n * Removes the active context's stored batches and its emergency entries, or the whole\n * namespace's. A discard rotation with no sender uses it, as Sender.retire() would, and so does\n * shutdown() with clearStorage.\n * @param access The config, the reporter and the kept memory store.\n * @param scope Whose stored records to remove: the context's or the namespace's.\n * @param ids More batches to remove by id, for example the ones a carry left under an older id.\n * @param forgetIds True to also remove the stored session id, tab id and journey.\n * @returns Promise that resolves once the batches are removed.\n */\nexport function clearStored(\n access: StoreAccess,\n scope: \"context\" | \"namespace\",\n ids: readonly string[],\n forgetIds = false,\n): Promise<void> {\n // The ids go first, so a store that won't open still leaves no session for the next user.\n if (forgetIds) {\n for (const [store, key] of STORED_IDS) {\n access.diagnostics.guard(\n \"storage.unavailable\",\n `The library could not remove ${key} from ${store}Storage.`,\n () => {\n BROWSER_STORES[store]().removeItem(key);\n },\n );\n }\n }\n\n return withStore(access, async (store) => {\n for (const id of ids) {\n await store.remove(id);\n }\n\n if (scope === \"namespace\") {\n await store.clearNamespace();\n } else {\n await store.clear();\n }\n\n const { diagnostics, config } = access;\n clearEmergencyContext(\n config.securityContext.id,\n diagnostics,\n store.namespace,\n scope === \"namespace\",\n );\n });\n}\n\n/**\n * Stores records and batches under the active context, as a retain rotation does with a sender.\n * The records go in one batch. A batch keeps its id, so its older copy is replaced.\n * @param access The config, the reporter and the kept memory store.\n * @param records Records that waited in memory.\n * @param batches Stored batches of an earlier context, for example the ones a carry left.\n * @returns Promise that resolves once each batch is stored.\n */\nexport function keepStored(\n access: StoreAccess,\n records: readonly LogRecord[],\n batches: readonly LogBatch[],\n): Promise<void> {\n return withStore(access, async (store) => {\n const all = [...batches];\n if (records.length > 0) {\n const id = newId(access.diagnostics);\n all.push({ id, records: [...records], createdAt: Date.now(), attempts: 0 });\n }\n\n for (const batch of all) {\n await store.save({\n ...batch,\n attempts: 0,\n routingContextId: access.config.securityContext.id,\n persistenceNamespace: store.namespace,\n });\n }\n });\n}\n"],"mappings":";;;;AAiBA,IAAMU,IAAa;CACjB,CAAC,SAASR,CAAc;CACxB,CAAC,WAAWD,CAAU;CACtB,CAAC,WAAWD,CAAmB;AACjC;AAmBA,eAAeW,EACb,GACA,GACe;CACf,IAAM,EAAE,WAAQ,gBAAa,cAAWC,GAClC,EAAE,YAAS,iBAAcC,EAAO,SAChCC,IACJC,KACC,MAAMR,EACLS,GACAZ,EAAYa,CAAS,GACrBZ,EAAcQ,EAAO,SAAS,GAC9BK,GACA,KAAA,GACAD,CACF,GACIE,IAAQ,IAAIhB,EAAeW,GAASD,EAAO,iBAAiBI,CAAS;CAC3E,IAAI;EACF,MAAMG,EAAKD,CAAK;CAClB,UAAU;EACR,AAAIL,MAAYC,KACd,MAAMI,EAAM,MAAM;CAEtB;AACF;AAYA,SAAgBE,EACd,GACA,GACA,GACA,IAAY,IACG;CAEf,IAAIC,GACF,KAAK,IAAM,CAACH,GAAOI,MAAQb,GACzB,EAAO,YAAY,MACjB,uBACA,gCAAgCa,EAAI,QAAQJ,EAAM,iBAC5C;EACJ,EAAeA,EAAM,CAAC,CAAC,CAAC,WAAWI,CAAG;CACxC,CACF;CAIJ,OAAOZ,EAAUC,GAAQ,OAAO,MAAU;EACxC,KAAK,IAAMY,KAAMC,GACf,MAAMN,EAAM,OAAOK,CAAE;EAGvB,AAAIE,MAAU,cACZ,MAAMP,EAAM,eAAe,IAE3B,MAAMA,EAAM,MAAM;EAGpB,IAAM,EAAE,gBAAa,cAAWP;EAChC,EACEC,EAAO,gBAAgB,IACvBK,GACAC,EAAM,WACNO,MAAU,WACZ;CACF,CAAC;AACH;AAUA,SAAgBC,EACd,GACA,GACA,GACe;CACf,OAAOhB,EAAUC,GAAQ,OAAO,MAAU;EACxC,IAAMgB,IAAM,CAAC,GAAGC,CAAO;EACvB,IAAIC,EAAQ,SAAS,GAAG;GACtB,IAAMN,IAAKhB,EAAMI,EAAO,WAAW;GACnC,EAAI,KAAK;IAAE;IAAI,SAAS,CAAC,GAAGkB,CAAO;IAAG,WAAW,KAAK,IAAI;IAAG,UAAU;GAAE,CAAC;EAC5E;EAEA,KAAK,IAAMC,KAASH,GAClB,MAAMT,EAAM,KAAK;GACf,GAAGY;GACH,UAAU;GACV,kBAAkBnB,EAAO,OAAO,gBAAgB;GAChD,sBAAsBO,EAAM;EAC9B,CAAC;CAEL,CAAC;AACH"}
@@ -0,0 +1,2 @@
1
+ const e=require("./constants-CqdJhTxH.cjs"),t=require("./factory-hRrH32v5.cjs"),n=require("./identity-DlWRIuwy.cjs");var r=[[`local`,e.zn],[`session`,e.Zn],[`session`,e.Et]];async function i(e,n){let{config:r,diagnostics:i,memory:a}=e,{backend:o,namespace:s}=r.storage,c=a??await t.t(o,t.n(s),t.p(r.retention),i,void 0,s),l=new t.f(c,r.securityContext,s);try{await n(l)}finally{c!==a&&await l.close()}}function a(e,a,o,s=!1){if(s)for(let[t,i]of r)e.diagnostics.guard(`storage.unavailable`,`The library could not remove ${i} from ${t}Storage.`,()=>{n.t[t]().removeItem(i)});return i(e,async n=>{for(let e of o)await n.remove(e);a===`namespace`?await n.clearNamespace():await n.clear();let{diagnostics:r,config:i}=e;t.s(i.securityContext.id,r,n.namespace,a===`namespace`)})}function o(e,t,r){return i(e,async i=>{let a=[...r];if(t.length>0){let r=n.i(e.diagnostics);a.push({id:r,records:[...t],createdAt:Date.now(),attempts:0})}for(let t of a)await i.save({...t,attempts:0,routingContextId:e.config.securityContext.id,persistenceNamespace:i.namespace})})}exports.clearStored=a,exports.keepStored=o;
2
+ //# sourceMappingURL=stored-context-CXt7eHZL.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-context-CXt7eHZL.cjs","names":["SESSION_ID_KEY","TAB_ID_KEY","JOURNEY_STORAGE_KEY","createStorage","storageName","storageLimits","ContextStorage","newId","require_constants","require_factory","require_identity","STORED_IDS","withStore","access","config","backing","memory","backend","namespace","diagnostics","store","work","clearStored","forgetIds","key","id","ids","scope","keepStored","all","batches","records","batch"],"sources":["../src/storage/stored-context.ts"],"sourcesContent":["// src/storage/stored-context.ts\n//\n// Reaches the configured store when no delivery stack runs. shutdown() with clearStorage and a\n// rotation with no old sender need it, because otherwise only a sender opens the store.\n\nimport { JOURNEY_STORAGE_KEY, SESSION_ID_KEY, TAB_ID_KEY } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { LogBatch } from \"../models/batch\";\nimport type { ResolvedConfig } from \"../models/config\";\nimport type { LogRecord } from \"../models/log-record\";\nimport { type StorageAdapter, storageLimits } from \"../models/storage\";\nimport { BROWSER_STORES, newId } from \"../utils/identity\";\nimport { ContextStorage } from \"./context-storage\";\nimport { clearEmergencyContext } from \"./emergency-queue\";\nimport { createStorage, storageName } from \"./factory\";\n\n/** The stored ids that a shutdown with clearStorage removes: the session, the tab and the journey. */\nconst STORED_IDS = [\n [\"local\", SESSION_ID_KEY],\n [\"session\", TAB_ID_KEY],\n [\"session\", JOURNEY_STORAGE_KEY],\n] as const;\n\n/** What opening the store needs. The active context is the one in `config.securityContext`. */\nexport interface StoreAccess {\n /** Active configuration instance. */\n config: ResolvedConfig;\n /** Diagnostics reporter. */\n diagnostics: Diagnostics;\n /** The memory store the runtime keeps across context changes, if it has one. */\n memory: StorageAdapter | undefined;\n}\n\n/**\n * Opens the store for the active context, runs the work, then closes the store again. The\n * memory store stays open, because it holds other contexts' records too.\n * @param access The config, the reporter and the kept memory store.\n * @param work What to do with the store.\n * @returns Promise that resolves once the work is done and the store is closed.\n */\nasync function withStore(\n access: StoreAccess,\n work: (store: ContextStorage) => Promise<void>,\n): Promise<void> {\n const { config, diagnostics, memory } = access;\n const { backend, namespace } = config.storage;\n const backing =\n memory ??\n (await createStorage(\n backend,\n storageName(namespace),\n storageLimits(config.retention),\n diagnostics,\n undefined,\n namespace,\n ));\n const store = new ContextStorage(backing, config.securityContext, namespace);\n try {\n await work(store);\n } finally {\n if (backing !== memory) {\n await store.close();\n }\n }\n}\n\n/**\n * Removes the active context's stored batches and its emergency entries, or the whole\n * namespace's. A discard rotation with no sender uses it, as Sender.retire() would, and so does\n * shutdown() with clearStorage.\n * @param access The config, the reporter and the kept memory store.\n * @param scope Whose stored records to remove: the context's or the namespace's.\n * @param ids More batches to remove by id, for example the ones a carry left under an older id.\n * @param forgetIds True to also remove the stored session id, tab id and journey.\n * @returns Promise that resolves once the batches are removed.\n */\nexport function clearStored(\n access: StoreAccess,\n scope: \"context\" | \"namespace\",\n ids: readonly string[],\n forgetIds = false,\n): Promise<void> {\n // The ids go first, so a store that won't open still leaves no session for the next user.\n if (forgetIds) {\n for (const [store, key] of STORED_IDS) {\n access.diagnostics.guard(\n \"storage.unavailable\",\n `The library could not remove ${key} from ${store}Storage.`,\n () => {\n BROWSER_STORES[store]().removeItem(key);\n },\n );\n }\n }\n\n return withStore(access, async (store) => {\n for (const id of ids) {\n await store.remove(id);\n }\n\n if (scope === \"namespace\") {\n await store.clearNamespace();\n } else {\n await store.clear();\n }\n\n const { diagnostics, config } = access;\n clearEmergencyContext(\n config.securityContext.id,\n diagnostics,\n store.namespace,\n scope === \"namespace\",\n );\n });\n}\n\n/**\n * Stores records and batches under the active context, as a retain rotation does with a sender.\n * The records go in one batch. A batch keeps its id, so its older copy is replaced.\n * @param access The config, the reporter and the kept memory store.\n * @param records Records that waited in memory.\n * @param batches Stored batches of an earlier context, for example the ones a carry left.\n * @returns Promise that resolves once each batch is stored.\n */\nexport function keepStored(\n access: StoreAccess,\n records: readonly LogRecord[],\n batches: readonly LogBatch[],\n): Promise<void> {\n return withStore(access, async (store) => {\n const all = [...batches];\n if (records.length > 0) {\n const id = newId(access.diagnostics);\n all.push({ id, records: [...records], createdAt: Date.now(), attempts: 0 });\n }\n\n for (const batch of all) {\n await store.save({\n ...batch,\n attempts: 0,\n routingContextId: access.config.securityContext.id,\n persistenceNamespace: store.namespace,\n });\n }\n });\n}\n"],"mappings":"A,qHAiBA,IAAMW,EAAa,CACjB,CAAC,QAASX,EAAAA,EAAc,EACxB,CAAC,UAAWC,EAAAA,EAAU,EACtB,CAAC,UAAWC,EAAAA,EAAmB,CACjC,EAmBA,eAAeU,EACb,EACA,EACe,CACf,GAAM,CAAE,SAAQ,cAAa,UAAWC,EAClC,CAAE,UAAS,aAAcC,EAAO,QAChCC,EACJC,GACC,MAAMb,EAAAA,EACLc,EACAb,EAAAA,EAAYc,CAAS,EACrBb,EAAAA,EAAcS,EAAO,SAAS,EAC9BK,EACA,IAAA,GACAD,CACF,EACIE,EAAQ,IAAId,EAAAA,EAAeS,EAASD,EAAO,gBAAiBI,CAAS,EAC3E,GAAI,CACF,MAAMG,EAAKD,CAAK,CAClB,QAAU,CACJL,IAAYC,GACd,MAAMI,EAAM,MAAM,CAEtB,CACF,CAYA,SAAgBE,EACd,EACA,EACA,EACA,EAAY,GACG,CAEf,GAAIC,EACF,IAAK,GAAM,CAACH,EAAOI,KAAQb,EACzBE,EAAO,YAAY,MACjB,sBACA,gCAAgCW,EAAI,QAAQJ,EAAM,cAC5C,CACJV,EAAA,EAAeU,EAAM,CAAC,CAAC,CAAC,WAAWI,CAAG,CACxC,CACF,EAIJ,OAAOZ,EAAUC,EAAQ,KAAO,IAAU,CACxC,IAAK,IAAMY,KAAMC,EACf,MAAMN,EAAM,OAAOK,CAAE,EAGnBE,IAAU,YACZ,MAAMP,EAAM,eAAe,EAE3B,MAAMA,EAAM,MAAM,EAGpB,GAAM,CAAE,cAAa,UAAWP,EAChCJ,EAAA,EACEK,EAAO,gBAAgB,GACvBK,EACAC,EAAM,UACNO,IAAU,WACZ,CACF,CAAC,CACH,CAUA,SAAgBC,EACd,EACA,EACA,EACe,CACf,OAAOhB,EAAUC,EAAQ,KAAO,IAAU,CACxC,IAAMgB,EAAM,CAAC,GAAGC,CAAO,EACvB,GAAIC,EAAQ,OAAS,EAAG,CACtB,IAAMN,EAAKlB,EAAAA,EAAMM,EAAO,WAAW,EACnCgB,EAAI,KAAK,CAAE,KAAI,QAAS,CAAC,GAAGE,CAAO,EAAG,UAAW,KAAK,IAAI,EAAG,SAAU,CAAE,CAAC,CAC5E,CAEA,IAAK,IAAMC,KAASH,EAClB,MAAMT,EAAM,KAAK,CACf,GAAGY,EACH,SAAU,EACV,iBAAkBnB,EAAO,OAAO,gBAAgB,GAChD,qBAAsBO,EAAM,SAC9B,CAAC,CAEL,CAAC,CACH,C"}
@@ -0,0 +1,2 @@
1
+ const e=require("./constants-CqdJhTxH.cjs"),t=require("./fixed-window-CvESpFYV.cjs");function n(n,r,i,a,o=e.nt){return r===null||t.t(n,r,o)?!0:(i.report(`capture.rate_limited`,`More than ${String(r)} ${a} occurred in ${String(o)} ms. The library ignores the other ${a} in this window.`),!1)}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
2
+ //# sourceMappingURL=storm-C-zYSdDX.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storm-C-zYSdDX.cjs","names":["ERROR_STORM_WINDOW_MS","countInWindow","require_constants","require_fixed_window","allowInWindow","limit","window","windowMs","diagnostics","what"],"sources":["../src/capture/storm.ts"],"sourcesContent":["// src/capture/storm.ts\n//\n// Fixed-window rate limit for the capture modules. A render loop that throws or freezes\n// produces thousands of events a second, and sending them all would flood the ingest endpoint.\n\nimport { ERROR_STORM_WINDOW_MS } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { countInWindow, type StormWindow } from \"../utils/fixed-window\";\n\nexport type { StormWindow } from \"../utils/fixed-window\";\n\n/**\n * Counts one event in a fixed window and reports every event over the limit.\n * @param window Window state to update.\n * @param limit Maximum events per window. 0 allows none, and null means no limit.\n * @param diagnostics Diagnostics reporter.\n * @param what Plural name of the events, for the diagnostic message.\n * @param windowMs Rate limit window, in milliseconds.\n * @returns False when the window has no allowance left. The caller must drop the event.\n */\nexport function allowInWindow(\n window: StormWindow,\n limit: number | null,\n diagnostics: Diagnostics,\n what: string,\n windowMs = ERROR_STORM_WINDOW_MS,\n): boolean {\n if (limit === null || countInWindow(window, limit, windowMs)) {\n return true;\n }\n\n diagnostics.report(\n \"capture.rate_limited\",\n `More than ${String(limit)} ${what} occurred in ${String(windowMs)} ms. The library ignores the other ${what} in this window.`,\n );\n return false;\n}\n"],"mappings":"A,qFAoBA,SAAgBI,EACd,EACA,EACA,EACA,EACA,EAAWJ,EAAAA,GACF,CAST,OARIK,IAAU,MAAQJ,EAAAA,EAAcK,EAAQD,EAAOE,CAAQ,EAClD,IAGTC,EAAY,OACV,uBACA,aAAa,OAAOH,CAAK,EAAE,GAAGI,EAAK,eAAe,OAAOF,CAAQ,EAAE,qCAAqCE,EAAK,iBAC/G,EACO,GACT,C"}
@@ -0,0 +1,9 @@
1
+ import { nt as e } from "./constants-CUyd9cTZ.js";
2
+ import { t } from "./fixed-window-Dq3MLUUv.js";
3
+ // src/capture/storm.ts
4
+ function n(n, r, i, a, o = e) {
5
+ return r === null || t(n, r, o) ? !0 : (i.report("capture.rate_limited", `More than ${String(r)} ${a} occurred in ${String(o)} ms. The library ignores the other ${a} in this window.`), !1);
6
+ }
7
+ export { n as t };
8
+
9
+ //# sourceMappingURL=storm-DjKetLKZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storm-DjKetLKZ.js","names":["ERROR_STORM_WINDOW_MS","allowInWindow","limit","countInWindow","window","windowMs","diagnostics","what"],"sources":["../src/capture/storm.ts"],"sourcesContent":["// src/capture/storm.ts\n//\n// Fixed-window rate limit for the capture modules. A render loop that throws or freezes\n// produces thousands of events a second, and sending them all would flood the ingest endpoint.\n\nimport { ERROR_STORM_WINDOW_MS } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { countInWindow, type StormWindow } from \"../utils/fixed-window\";\n\nexport type { StormWindow } from \"../utils/fixed-window\";\n\n/**\n * Counts one event in a fixed window and reports every event over the limit.\n * @param window Window state to update.\n * @param limit Maximum events per window. 0 allows none, and null means no limit.\n * @param diagnostics Diagnostics reporter.\n * @param what Plural name of the events, for the diagnostic message.\n * @param windowMs Rate limit window, in milliseconds.\n * @returns False when the window has no allowance left. The caller must drop the event.\n */\nexport function allowInWindow(\n window: StormWindow,\n limit: number | null,\n diagnostics: Diagnostics,\n what: string,\n windowMs = ERROR_STORM_WINDOW_MS,\n): boolean {\n if (limit === null || countInWindow(window, limit, windowMs)) {\n return true;\n }\n\n diagnostics.report(\n \"capture.rate_limited\",\n `More than ${String(limit)} ${what} occurred in ${String(windowMs)} ms. The library ignores the other ${what} in this window.`,\n );\n return false;\n}\n"],"mappings":";;;AAoBA,SAAgBC,EACd,GACA,GACA,GACA,GACA,IAAWD,GACF;CAST,OARIE,MAAU,QAAQC,EAAcC,GAAQF,GAAOG,CAAQ,IAClD,MAGTC,EAAY,OACV,wBACA,aAAa,OAAOJ,CAAK,EAAE,GAAGK,EAAK,eAAe,OAAOF,CAAQ,EAAE,qCAAqCE,EAAK,iBAC/G,GACO;AACT"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Compresses a string to gzip bytes with CompressionStream. The result is a
3
+ * Uint8Array on a non-shared ArrayBuffer, which fetch accepts as BodyInit.
4
+ * @param text Raw serialized payload to compress.
5
+ * @returns Promise that resolves to the gzip bytes, or null when there is no CompressionStream.
6
+ */
7
+ export declare function gzip(text: string): Promise<Uint8Array<ArrayBuffer> | null>;
@@ -0,0 +1,22 @@
1
+ import type { LogBatch } from "../models/batch.cjs";
2
+ import type { BatchKind, TransportRequest } from "../models/config.cjs";
3
+ import type { SerializedBatch } from "../models/serializer.cjs";
4
+ import { StatusTransport } from "./status-transport.cjs";
5
+ /**
6
+ * Builds the request that a custom transport and its exit hook receive.
7
+ * @param batch Batch to send.
8
+ * @param serialized Serialized form of the batch.
9
+ * @param kind Kind of the batch.
10
+ * @returns The transport request.
11
+ */
12
+ export declare function toTransportRequest(batch: LogBatch, serialized: SerializedBatch, kind: BatchKind): TransportRequest;
13
+ /** Sends batches through the consumer's transport function. */
14
+ export declare class CustomTransport extends StatusTransport {
15
+ /**
16
+ * Sends one batch through the configured transport function.
17
+ * @param batch Batch to send.
18
+ * @returns Promise that resolves to the records lost in a send that ends without an error.
19
+ * @throws TransportError when the batch is not accepted.
20
+ */
21
+ send(batch: LogBatch): Promise<number>;
22
+ }
@@ -1,7 +1,7 @@
1
- import type { LogBatch } from "../models/batch";
2
- import type { BatchKind, TransportRequest } from "../models/config";
3
- import type { SerializedBatch } from "../models/serializer";
4
- import { StatusTransport } from "./status-transport";
1
+ import type { LogBatch } from "../models/batch.js";
2
+ import type { BatchKind, TransportRequest } from "../models/config.js";
3
+ import type { SerializedBatch } from "../models/serializer.js";
4
+ import { StatusTransport } from "./status-transport.js";
5
5
  /**
6
6
  * Builds the request that a custom transport and its exit hook receive.
7
7
  * @param batch Batch to send.
@@ -15,7 +15,8 @@ export declare class CustomTransport extends StatusTransport {
15
15
  /**
16
16
  * Sends one batch through the configured transport function.
17
17
  * @param batch Batch to send.
18
+ * @returns Promise that resolves to the records lost in a send that ends without an error.
18
19
  * @throws TransportError when the batch is not accepted.
19
20
  */
20
- send(batch: LogBatch): Promise<void>;
21
+ send(batch: LogBatch): Promise<number>;
21
22
  }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The failure kind decides whether the engine retries, backs off or drops. Transient, offline
3
+ * and timeout failures are retried with backoff. A throttled failure waits for the server's
4
+ * delay, and a too_large failure splits the batch. A permanent failure is dropped, because the
5
+ * server will never accept that batch.
6
+ */
7
+ export type TransportFailureKind = "transient" | "throttled" | "too_large" | "permanent" | "timeout" | "offline";
8
+ /** A failed transport attempt, with its failure kind and metadata. */
9
+ export declare class TransportError extends Error {
10
+ readonly kind: TransportFailureKind;
11
+ readonly status?: number | undefined;
12
+ readonly retryAfterMs?: number | undefined;
13
+ readonly maxBytes?: number | undefined;
14
+ /**
15
+ * @param kind Failure classification.
16
+ * @param message Error description.
17
+ * @param status Optional HTTP response status code.
18
+ * @param retryAfterMs Delay requested by the server in milliseconds.
19
+ * @param maxBytes Maximum payload bytes suggested by a 413 response.
20
+ * @param cause Error that caused this failure.
21
+ */
22
+ constructor(kind: TransportFailureKind, message: string, status?: number | undefined, retryAfterMs?: number | undefined, maxBytes?: number | undefined, cause?: unknown);
23
+ }
24
+ /**
25
+ * Parses an HTTP Retry-After value into a delay in milliseconds. The value
26
+ * can be a number of seconds or an HTTP date. A date in the past gives a negative delay,
27
+ * which is clamped to zero.
28
+ * @param header Raw Retry-After header string or null.
29
+ * @returns Non-negative delay in milliseconds, or undefined if invalid or missing.
30
+ */
31
+ export declare function parseRetryAfter(header: string | null): number | undefined;
@@ -0,0 +1,135 @@
1
+ import type { Diagnostics } from "../core/diagnostics.cjs";
2
+ import type { LogBatch } from "../models/batch.cjs";
3
+ import type { ResolvedConfig } from "../models/config.cjs";
4
+ import type { LossReporter } from "../models/drop.cjs";
5
+ /** The lifecycle event or manual action that starts an exit flush. */
6
+ export type ExitReason = "hidden" | "pagehide" | "freeze" | "openfin-close" | "shutdown";
7
+ /** Dependencies of ExitFlush. */
8
+ export interface ExitFlushDeps {
9
+ /** The active configuration. */
10
+ config: ResolvedConfig;
11
+ /** Diagnostics reporter. */
12
+ diagnostics: Diagnostics;
13
+ /** Drains all buffered and unconfirmed records into one batch per kind. */
14
+ drainForExit: () => LogBatch[];
15
+ /**
16
+ * Runs a normal flush with headers, gzip and retry. Used for a hidden document.
17
+ * It doesn't touch an in-flight batch.
18
+ */
19
+ flushAlive: () => unknown;
20
+ /**
21
+ * Returns the headers that the HTTP transport sent last, or undefined. sendBeacon can't set
22
+ * a header, so when there are headers the exit flush uses a keepalive fetch.
23
+ */
24
+ exitHeaders: () => Record<string, string> | undefined;
25
+ /**
26
+ * Returns the bytes of the HTTP transport's keepalive requests that haven't settled, or
27
+ * undefined without an HTTP transport. A hidden page's sends use the exit sends' budget.
28
+ */
29
+ keepaliveInFlight: () => number | undefined;
30
+ /** Receives the records that the exit flush loses. */
31
+ onLoss?: LossReporter;
32
+ /** Pushes the open metric interval's points into the buffers. */
33
+ beforeExit?: () => void;
34
+ }
35
+ /**
36
+ * Flushes pending telemetry on document unload, with sendBeacon, a keepalive fetch or
37
+ * emergency storage.
38
+ */
39
+ export declare class ExitFlush {
40
+ private readonly deps;
41
+ /** True while we are listening for the unload events. */
42
+ private installed;
43
+ /**
44
+ * Bytes in flight against the browser's one budget for beacons and keepalive fetches. It
45
+ * starts at the transport's keepalive sends, and each batch of the current exit flush adds to it.
46
+ */
47
+ private keepaliveBytes;
48
+ /** Flushes on visibilitychange when the document becomes hidden. */
49
+ private readonly onVisibility;
50
+ /** Flushes on the window's pagehide event. */
51
+ private readonly onPageHide;
52
+ /** Flushes on the document's freeze event. */
53
+ private readonly onFreeze;
54
+ /** Flushes on the OpenFin close-requested event. */
55
+ private readonly onOpenFinClose;
56
+ /**
57
+ * @param deps Injected configuration, diagnostics, and drain callback.
58
+ */
59
+ constructor(deps: ExitFlushDeps);
60
+ /** Attaches the unload listeners to the document, the window and OpenFin. */
61
+ install(): void;
62
+ /** Removes all unload listeners and subscriptions. */
63
+ uninstall(): void;
64
+ /**
65
+ * Drains pending records synchronously and sends them with a beacon, a keepalive fetch or
66
+ * emergency storage. A hidden document gets a normal flush. Never awaits and never throws,
67
+ * because the caller is an unload listener.
68
+ * @param reason Reason code of the flush.
69
+ */
70
+ flush(reason: ExitReason): void;
71
+ /**
72
+ * Sends one exit batch with a beacon, a keepalive fetch or emergency storage.
73
+ * @param batch Batch to send.
74
+ * @param reason Reason code of the flush.
75
+ * @param url Endpoint of the batch.
76
+ */
77
+ private flushBatch;
78
+ /**
79
+ * Checks whether the endpoint is on the page's origin, where a request needs no CORS preflight.
80
+ * @param url Endpoint of the batch.
81
+ * @returns False for another origin, for an opaque origin, and when the origin global and
82
+ * location disagree or the host has no location.
83
+ */
84
+ private isSameOrigin;
85
+ /** Runs a hidden document's normal flush, and reports it if it throws or rejects. */
86
+ private flushAlive;
87
+ /**
88
+ * Hands the pending records to a custom transport's exit hook, because a closing page can't
89
+ * wait for the async transport. Without a hook, or when the hook refuses the batch, the
90
+ * batch goes to the emergency queue and the next page load sends it.
91
+ * @param reason Reason code of the flush.
92
+ * @param onExit The custom transport's synchronous exit hook.
93
+ */
94
+ private flushCustom;
95
+ /**
96
+ * Parks a batch in the localStorage emergency queue for the next page load. With the storage
97
+ * backend "memory" or "none" the app wants nothing kept on the device, so the batch is lost.
98
+ * @param batch Batch that the exit flush can't send.
99
+ */
100
+ private park;
101
+ /**
102
+ * Serializes the exit batch, and reports a serializer that throws.
103
+ * @param batch Batch to serialize.
104
+ * @param reason Reason code of the flush.
105
+ * @returns The serialized batch, or undefined if the serializer threw.
106
+ */
107
+ private serialize;
108
+ /**
109
+ * Parses the configured endpoint URL.
110
+ * @returns URL instance or null if missing or invalid.
111
+ */
112
+ private endpointUrl;
113
+ /**
114
+ * Sends the payload as text/plain with navigator.sendBeacon.
115
+ * @param url Target endpoint URL with query parameters.
116
+ * @param body Serialized payload string.
117
+ * @returns The browser's answer.
118
+ */
119
+ private beacon;
120
+ /**
121
+ * Sends the exit POST with fetch and `keepalive: true`. A keepalive request continues
122
+ * after the document closes, whereas the browser cancels a plain fetch at page close.
123
+ * A fetch that fails while the document is alive parks the batch in the emergency queue, and
124
+ * the server drops a second copy by its batch id. A rejection after the close parks nothing.
125
+ * @param url Target endpoint URL.
126
+ * @param batch Batch in the payload.
127
+ * @param body Serialized payload string.
128
+ * @param bytes Size of the body, which flushBatch has measured already.
129
+ * @param reason Reason code of the flush.
130
+ * @param headers Builds the request headers. To another origin without `headers` that is only
131
+ * a text/plain content type. A header value outside ISO-8859-1 makes the Headers constructor
132
+ * throw.
133
+ */
134
+ private keepaliveFetch;
135
+ }
@@ -1,7 +1,7 @@
1
- import type { Diagnostics } from "../core/diagnostics";
2
- import type { LogBatch } from "../models/batch";
3
- import type { ResolvedConfig } from "../models/config";
4
- import type { LossReporter } from "../models/drop";
1
+ import type { Diagnostics } from "../core/diagnostics.js";
2
+ import type { LogBatch } from "../models/batch.js";
3
+ import type { ResolvedConfig } from "../models/config.js";
4
+ import type { LossReporter } from "../models/drop.js";
5
5
  /** The lifecycle event or manual action that starts an exit flush. */
6
6
  export type ExitReason = "hidden" | "pagehide" | "freeze" | "openfin-close" | "shutdown";
7
7
  /** Dependencies of ExitFlush. */
@@ -16,12 +16,17 @@ export interface ExitFlushDeps {
16
16
  * Runs a normal flush with headers, gzip and retry. Used for a hidden document.
17
17
  * It doesn't touch an in-flight batch.
18
18
  */
19
- flushAlive: () => void | Promise<void>;
19
+ flushAlive: () => unknown;
20
20
  /**
21
21
  * Returns the headers that the HTTP transport sent last, or undefined. sendBeacon can't set
22
22
  * a header, so when there are headers the exit flush uses a keepalive fetch.
23
23
  */
24
24
  exitHeaders: () => Record<string, string> | undefined;
25
+ /**
26
+ * Returns the bytes of the HTTP transport's keepalive requests that haven't settled, or
27
+ * undefined without an HTTP transport. A hidden page's sends use the exit sends' budget.
28
+ */
29
+ keepaliveInFlight: () => number | undefined;
25
30
  /** Receives the records that the exit flush loses. */
26
31
  onLoss?: LossReporter;
27
32
  /** Pushes the open metric interval's points into the buffers. */
@@ -35,7 +40,10 @@ export declare class ExitFlush {
35
40
  private readonly deps;
36
41
  /** True while we are listening for the unload events. */
37
42
  private installed;
38
- /** Bytes used by the current exit flush's keepalive fetches. All batches share one budget. */
43
+ /**
44
+ * Bytes in flight against the browser's one budget for beacons and keepalive fetches. It
45
+ * starts at the transport's keepalive sends, and each batch of the current exit flush adds to it.
46
+ */
39
47
  private keepaliveBytes;
40
48
  /** Flushes on visibilitychange when the document becomes hidden. */
41
49
  private readonly onVisibility;
@@ -67,6 +75,13 @@ export declare class ExitFlush {
67
75
  * @param url Endpoint of the batch.
68
76
  */
69
77
  private flushBatch;
78
+ /**
79
+ * Checks whether the endpoint is on the page's origin, where a request needs no CORS preflight.
80
+ * @param url Endpoint of the batch.
81
+ * @returns False for another origin, for an opaque origin, and when the origin global and
82
+ * location disagree or the host has no location.
83
+ */
84
+ private isSameOrigin;
70
85
  /** Runs a hidden document's normal flush, and reports it if it throws or rejects. */
71
86
  private flushAlive;
72
87
  /**
@@ -78,8 +93,8 @@ export declare class ExitFlush {
78
93
  */
79
94
  private flushCustom;
80
95
  /**
81
- * Parks a batch in the localStorage emergency queue for the next page load. With storage
82
- * "memory" or "none" the app wants nothing kept on the device, so the batch is lost.
96
+ * Parks a batch in the localStorage emergency queue for the next page load. With the storage
97
+ * backend "memory" or "none" the app wants nothing kept on the device, so the batch is lost.
83
98
  * @param batch Batch that the exit flush can't send.
84
99
  */
85
100
  private park;
@@ -103,16 +118,18 @@ export declare class ExitFlush {
103
118
  */
104
119
  private beacon;
105
120
  /**
106
- * Sends a fallback POST with fetch and `keepalive: true`. A keepalive request continues
121
+ * Sends the exit POST with fetch and `keepalive: true`. A keepalive request continues
107
122
  * after the document closes, whereas the browser cancels a plain fetch at page close.
108
- * A failed fetch parks the batch in the emergency queue, and the server drops a second copy
109
- * by its batch id.
123
+ * A fetch that fails while the document is alive parks the batch in the emergency queue, and
124
+ * the server drops a second copy by its batch id. A rejection after the close parks nothing.
110
125
  * @param url Target endpoint URL.
111
126
  * @param batch Batch in the payload.
112
127
  * @param body Serialized payload string.
128
+ * @param bytes Size of the body, which flushBatch has measured already.
113
129
  * @param reason Reason code of the flush.
114
- * @param headers Builds the request headers. Without custom headers that is only a text/plain
115
- * content type. A header value outside ISO-8859-1 makes the Headers constructor throw.
130
+ * @param headers Builds the request headers. To another origin without `headers` that is only
131
+ * a text/plain content type. A header value outside ISO-8859-1 makes the Headers constructor
132
+ * throw.
116
133
  */
117
134
  private keepaliveFetch;
118
135
  }
@@ -0,0 +1,8 @@
1
+ import type { Diagnostics } from "../core/diagnostics.cjs";
2
+ import type { ResolvedConfig } from "../models/config.cjs";
3
+ /** Returns the last headers, but only while their source and all destinations are unchanged. */
4
+ export declare function lastHeaders(owner: object, config: ResolvedConfig): Record<string, string> | undefined;
5
+ /** Resolves a headers function on the main thread and keeps its result for the exit flush. */
6
+ export declare function resolveHeaders(owner: object, config: ResolvedConfig, diagnostics: Diagnostics): Promise<Record<string, string>>;
7
+ /** Forgets rejected credentials before the headers function is called again. */
8
+ export declare function resetHeaders(owner: object): void;
@@ -1,5 +1,5 @@
1
- import type { Diagnostics } from "../core/diagnostics";
2
- import type { ResolvedConfig } from "../models/config";
1
+ import type { Diagnostics } from "../core/diagnostics.js";
2
+ import type { ResolvedConfig } from "../models/config.js";
3
3
  /** Returns the last headers, but only while their source and all destinations are unchanged. */
4
4
  export declare function lastHeaders(owner: object, config: ResolvedConfig): Record<string, string> | undefined;
5
5
  /** Resolves a headers function on the main thread and keeps its result for the exit flush. */
@@ -0,0 +1,116 @@
1
+ import type { LogBatch } from "../models/batch.cjs";
2
+ import { StatusTransport } from "./status-transport.cjs";
3
+ /** Advice for an HTTP send answered with a 401 or a 403, on the main thread or in the worker. */
4
+ export declare const CREDENTIAL_ADVICE: string;
5
+ /**
6
+ * Sends serialized log batches over HTTP. Resolves headers, applies gzip compression and
7
+ * classifies errors.
8
+ */
9
+ export declare class HttpTransport extends StatusTransport {
10
+ /** Body bytes of this transport's keepalive requests that haven't settled yet. */
11
+ private keepaliveBytes;
12
+ /**
13
+ * Sends one log batch over HTTP. A metrics batch goes to metricsEndpoint and a traces batch
14
+ * to tracesEndpoint. A batch without an endpoint goes nowhere.
15
+ * @param batch Batch to send.
16
+ * @param onKeepalive Runs when one of the batch's requests starts with keepalive.
17
+ * @returns Promise that resolves to the records lost in a send that ends without an error.
18
+ * @throws TransportError on transient, throttled, 413, or permanent network failures.
19
+ */
20
+ send(batch: LogBatch, onKeepalive?: () => void): Promise<number>;
21
+ /**
22
+ * Returns the headers for the exit flush, because a closing document can't await headers().
23
+ * @returns The static headers, the last result of the current headers function, or undefined.
24
+ */
25
+ lastHeaders(): Record<string, string> | undefined;
26
+ /**
27
+ * Returns the body bytes of the keepalive requests that haven't settled. The browser has one
28
+ * budget for them and the exit sends, so the exit flush starts its count from this number.
29
+ * @returns Bytes in flight, or 0.
30
+ */
31
+ keepaliveInFlight(): number;
32
+ /**
33
+ * Serializes, encodes and sends a batch. Throws a classified TransportError
34
+ * on failure.
35
+ * @param batch Batch to deliver.
36
+ * @param kind Kind of the batch. The caller reads it together with the endpoint.
37
+ * @param endpoint Ingest URL. The caller reads it once, so a reconfigure during the send
38
+ * can't change it.
39
+ * @param onKeepalive Runs when one of the batch's requests starts with keepalive.
40
+ * @returns The records lost in an accepted batch, or all of them when serializing fails.
41
+ */
42
+ private post;
43
+ /**
44
+ * Checks whether a status rejects the credentials.
45
+ * @param status HTTP status code.
46
+ * @returns True for 401 and 403.
47
+ */
48
+ private rejectsCredentials;
49
+ /**
50
+ * Resolves the headers, encodes the body and sends one request. One deadline covers all
51
+ * three steps, otherwise a headers() that never settles holds a dispatch slot forever.
52
+ * @param batch Batch to deliver.
53
+ * @param endpoint Ingest URL.
54
+ * @param serialized Serialized batch.
55
+ * @param otlp True when the batch is in an OTLP format, so a 2xx can carry a partialSuccess.
56
+ * @param onKeepalive Runs when the request starts with keepalive.
57
+ * @returns Promise that resolves to the response and the body text its status needs.
58
+ * @throws TransportError on timeout or network failure.
59
+ */
60
+ private attempt;
61
+ /**
62
+ * Waits for a step until the deadline.
63
+ * @param work Step to wait for. It never rejects, so only the deadline rejects here.
64
+ * @param deadline Epoch time in milliseconds at which the request times out.
65
+ * @param endpoint Ingest URL of the request, for the timeout report.
66
+ * @returns Promise that resolves to the step's value.
67
+ * @throws TransportError of kind "timeout" at the deadline.
68
+ */
69
+ private before;
70
+ /**
71
+ * Reports a timeout and builds its error.
72
+ * @param endpoint Ingest URL of the request.
73
+ * @returns TransportError of kind "timeout".
74
+ */
75
+ private timeout;
76
+ /**
77
+ * Compresses the serialized payload when the config sets gzip and the payload is at or
78
+ * above the threshold.
79
+ * @param text Serialized payload string.
80
+ * @returns Promise that resolves to the original string or the compressed byte array.
81
+ */
82
+ private encodeBody;
83
+ /**
84
+ * Sends the HTTP POST request with a timeout, and maps network errors to
85
+ * TransportError.
86
+ * @param endpoint Ingest URL.
87
+ * @param headers HTTP request headers.
88
+ * @param body Request body string or byte array.
89
+ * @param deadline Epoch time in milliseconds at which the request times out.
90
+ * @param keepalive True if the request continues after unload.
91
+ * @param otlp True when the batch is in an OTLP format, so a 2xx can carry a partialSuccess.
92
+ * @returns Promise that resolves to the response and the body text its status needs.
93
+ * @throws TransportError on network failure, timeout, or offline status.
94
+ */
95
+ private dispatch;
96
+ /**
97
+ * Checks whether a send uses keepalive. A mobile OS can stop a hidden page without a
98
+ * pagehide, and a keepalive request continues after that. The browser limits the keepalive
99
+ * bodies in flight.
100
+ * @param bytes Size of the request body.
101
+ * @returns True for a hidden document and a body of BEACON_LIMIT_BYTES or less.
102
+ */
103
+ private keepalive;
104
+ /**
105
+ * Reads the optional maxBytes limit from a 413 response body.
106
+ * @param body The 413 body text.
107
+ * @returns The limit in bytes, or undefined.
108
+ */
109
+ private readMaxBytes;
110
+ /**
111
+ * Resolves the configured static or dynamic request headers, and keeps what headers()
112
+ * returned for the exit flush.
113
+ * @returns Promise that resolves to the header map.
114
+ */
115
+ private resolveHeaders;
116
+ }