@utk09/ui-observability 1.0.0 → 1.2.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 (298) hide show
  1. package/CHANGELOG.md +111 -219
  2. package/README.md +24 -26
  3. package/dist/{batch-CXmPmTse.js → batch-120Kc9jr.js} +3 -3
  4. package/dist/{batch-CXmPmTse.js.map → batch-120Kc9jr.js.map} +1 -1
  5. package/dist/{batch-mmPigCpi.cjs → batch-C3uNp5kU.cjs} +2 -2
  6. package/dist/{batch-mmPigCpi.cjs.map → batch-C3uNp5kU.cjs.map} +1 -1
  7. package/dist/bus/bus.d.cts +31 -2
  8. package/dist/bus/bus.d.ts +31 -2
  9. package/dist/bus-Dj8IEVcC.cjs +2 -0
  10. package/dist/bus-Dj8IEVcC.cjs.map +1 -0
  11. package/dist/{bus-C39wspFV.js → bus-DyNafxZN.js} +127 -104
  12. package/dist/bus-DyNafxZN.js.map +1 -0
  13. package/dist/capture/errors.d.cts +10 -0
  14. package/dist/capture/errors.d.ts +10 -0
  15. package/dist/capture/interactions.d.cts +35 -3
  16. package/dist/capture/interactions.d.ts +35 -3
  17. package/dist/capture/observed-windows.d.cts +51 -0
  18. package/dist/capture/observed-windows.d.ts +51 -0
  19. package/dist/capture/replay.d.cts +1 -1
  20. package/dist/capture/replay.d.ts +1 -1
  21. package/dist/capture/types.d.cts +5 -0
  22. package/dist/capture/types.d.ts +5 -0
  23. package/dist/capture/web-vitals.d.cts +1 -0
  24. package/dist/capture/web-vitals.d.ts +1 -0
  25. package/dist/{compression-tVtXwVjX.js → compression-BWkDWY3v.js} +2 -2
  26. package/dist/{compression-tVtXwVjX.js.map → compression-BWkDWY3v.js.map} +1 -1
  27. package/dist/{compression-CvED_Jel.cjs → compression-CEVe7NPX.cjs} +2 -2
  28. package/dist/{compression-CvED_Jel.cjs.map → compression-CEVe7NPX.cjs.map} +1 -1
  29. package/dist/config-C0PtemvC.cjs +2 -0
  30. package/dist/config-C0PtemvC.cjs.map +1 -0
  31. package/dist/config-DK1Zf7jn.js +556 -0
  32. package/dist/config-DK1Zf7jn.js.map +1 -0
  33. package/dist/{console-BGgGnjSi.js → console-CAyCQOpm.js} +5 -5
  34. package/dist/{console-BGgGnjSi.js.map → console-CAyCQOpm.js.map} +1 -1
  35. package/dist/{console-CSZ5_Vx5.cjs → console-Dk6GH4yj.cjs} +2 -2
  36. package/dist/{console-CSZ5_Vx5.cjs.map → console-Dk6GH4yj.cjs.map} +1 -1
  37. package/dist/{constants-CUyd9cTZ.js → constants-CEHN6KuY.js} +46 -25
  38. package/dist/constants-CEHN6KuY.js.map +1 -0
  39. package/dist/constants-NtiQDWL_.cjs +2 -0
  40. package/dist/constants-NtiQDWL_.cjs.map +1 -0
  41. package/dist/constants.d.cts +23 -0
  42. package/dist/constants.d.ts +23 -0
  43. package/dist/core/config.d.cts +9 -3
  44. package/dist/core/config.d.ts +9 -3
  45. package/dist/core/diagnostics.d.cts +1 -1
  46. package/dist/core/diagnostics.d.ts +1 -1
  47. package/dist/core/pipeline.d.cts +11 -0
  48. package/dist/core/pipeline.d.ts +11 -0
  49. package/dist/core/record.d.cts +2 -2
  50. package/dist/core/record.d.ts +2 -2
  51. package/dist/core/rotation.d.cts +26 -2
  52. package/dist/core/rotation.d.ts +26 -2
  53. package/dist/core/runtime.d.cts +9 -0
  54. package/dist/core/runtime.d.ts +9 -0
  55. package/dist/core/sender.d.cts +3 -2
  56. package/dist/core/sender.d.ts +3 -2
  57. package/dist/{debug-bundle-BXIlwDKM.cjs → debug-bundle-DMzUfiQc.cjs} +2 -2
  58. package/dist/{debug-bundle-BXIlwDKM.cjs.map → debug-bundle-DMzUfiQc.cjs.map} +1 -1
  59. package/dist/{debug-bundle-CRpYV_ui.js → debug-bundle-w78W46zr.js} +4 -4
  60. package/dist/{debug-bundle-CRpYV_ui.js.map → debug-bundle-w78W46zr.js.map} +1 -1
  61. package/dist/doctor.cjs +1 -1
  62. package/dist/doctor.js +36 -36
  63. package/dist/doctor.js.map +1 -1
  64. package/dist/errors-07pmZ7VY.cjs +3 -0
  65. package/dist/errors-07pmZ7VY.cjs.map +1 -0
  66. package/dist/{errors-BE_EZV7Q.js → errors-C-LYbqyB.js} +27 -24
  67. package/dist/errors-C-LYbqyB.js.map +1 -0
  68. package/dist/{factory-CTi0Is3F.js → factory-BHYrcSaU.js} +39 -28
  69. package/dist/factory-BHYrcSaU.js.map +1 -0
  70. package/dist/factory-DsaNdcXp.cjs +2 -0
  71. package/dist/factory-DsaNdcXp.cjs.map +1 -0
  72. package/dist/{identity-DdhKgrpk.js → identity-Byh3gCdT.js} +35 -24
  73. package/dist/identity-Byh3gCdT.js.map +1 -0
  74. package/dist/identity-BzAzdQyv.cjs +2 -0
  75. package/dist/identity-BzAzdQyv.cjs.map +1 -0
  76. package/dist/index.cjs +1 -1
  77. package/dist/index.cjs.map +1 -1
  78. package/dist/index.d.cts +1 -0
  79. package/dist/index.d.ts +1 -0
  80. package/dist/index.js +453 -417
  81. package/dist/index.js.map +1 -1
  82. package/dist/{indexeddb-storage-GHdl0t8A.js → indexeddb-storage-BYywz-v6.js} +17 -17
  83. package/dist/{indexeddb-storage-GHdl0t8A.js.map → indexeddb-storage-BYywz-v6.js.map} +1 -1
  84. package/dist/{indexeddb-storage-CL9uqBCy.cjs → indexeddb-storage-BfqGkLFe.cjs} +2 -2
  85. package/dist/{indexeddb-storage-CL9uqBCy.cjs.map → indexeddb-storage-BfqGkLFe.cjs.map} +1 -1
  86. package/dist/interactions-BXzEel4F.cjs +2 -0
  87. package/dist/interactions-BXzEel4F.cjs.map +1 -0
  88. package/dist/interactions-DdKPMWIN.js +207 -0
  89. package/dist/interactions-DdKPMWIN.js.map +1 -0
  90. package/dist/{journey-B4Adltjm.cjs → journey-BUmsrgaw.cjs} +2 -2
  91. package/dist/{journey-B4Adltjm.cjs.map → journey-BUmsrgaw.cjs.map} +1 -1
  92. package/dist/{journey-D2_sia57.js → journey-Nu655gEO.js} +14 -14
  93. package/dist/{journey-D2_sia57.js.map → journey-Nu655gEO.js.map} +1 -1
  94. package/dist/{library-console-CPW6bvZH.cjs → library-console-DdIlzzph.cjs} +2 -2
  95. package/dist/{library-console-CPW6bvZH.cjs.map → library-console-DdIlzzph.cjs.map} +1 -1
  96. package/dist/{library-console-Btrzt814.js → library-console-amePMnP8.js} +2 -2
  97. package/dist/{library-console-Btrzt814.js.map → library-console-amePMnP8.js.map} +1 -1
  98. package/dist/{library-request-BJ9PLRaD.js → library-request-Cv7C05jf.js} +2 -2
  99. package/dist/{library-request-BJ9PLRaD.js.map → library-request-Cv7C05jf.js.map} +1 -1
  100. package/dist/{library-request-D7OvTxZV.cjs → library-request-DO3Ec7KE.cjs} +2 -2
  101. package/dist/{library-request-D7OvTxZV.cjs.map → library-request-DO3Ec7KE.cjs.map} +1 -1
  102. package/dist/{lifecycle-IaAm1mOC.cjs → lifecycle-B5yfH5is.cjs} +2 -2
  103. package/dist/{lifecycle-IaAm1mOC.cjs.map → lifecycle-B5yfH5is.cjs.map} +1 -1
  104. package/dist/{lifecycle-22CUCrc9.js → lifecycle-CMHz2Zbs.js} +2 -2
  105. package/dist/{lifecycle-22CUCrc9.js.map → lifecycle-CMHz2Zbs.js.map} +1 -1
  106. package/dist/{log-record-BNiLfqtL.js → log-record-B_nSqxoe.js} +2 -2
  107. package/dist/{log-record-BNiLfqtL.js.map → log-record-B_nSqxoe.js.map} +1 -1
  108. package/dist/{log-record-CkivuiEl.cjs → log-record-Bdywwg0k.cjs} +2 -2
  109. package/dist/{log-record-CkivuiEl.cjs.map → log-record-Bdywwg0k.cjs.map} +1 -1
  110. package/dist/{long-frames-DNFaRnC3.js → long-frames-6NGl1-uN.js} +3 -3
  111. package/dist/{long-frames-DNFaRnC3.js.map → long-frames-6NGl1-uN.js.map} +1 -1
  112. package/dist/{long-frames-BUUbXd-B.cjs → long-frames-D9DfSWqv.cjs} +2 -2
  113. package/dist/{long-frames-BUUbXd-B.cjs.map → long-frames-D9DfSWqv.cjs.map} +1 -1
  114. package/dist/models/bus.d.cts +6 -1
  115. package/dist/models/bus.d.ts +6 -1
  116. package/dist/models/config.d.cts +27 -11
  117. package/dist/models/config.d.ts +27 -11
  118. package/dist/models/serializer.d.cts +3 -1
  119. package/dist/models/serializer.d.ts +3 -1
  120. package/dist/{network-CGMLQ-mA.cjs → network-BNHBI0Fc.cjs} +2 -2
  121. package/dist/{network-CGMLQ-mA.cjs.map → network-BNHBI0Fc.cjs.map} +1 -1
  122. package/dist/{network-on2zZT6H.js → network-Cc3tSB7e.js} +5 -5
  123. package/dist/{network-on2zZT6H.js.map → network-Cc3tSB7e.js.map} +1 -1
  124. package/dist/observed-windows-8JtCsIr1.js +64 -0
  125. package/dist/observed-windows-8JtCsIr1.js.map +1 -0
  126. package/dist/observed-windows-BlE25nrn.cjs +2 -0
  127. package/dist/observed-windows-BlE25nrn.cjs.map +1 -0
  128. package/dist/openfin-Bxelt0yg.js.map +1 -1
  129. package/dist/openfin-DtH2f7zX.cjs.map +1 -1
  130. package/dist/{otlp-DimfrRor.js → otlp-Btix3EBa.js} +7 -7
  131. package/dist/{otlp-DimfrRor.js.map → otlp-Btix3EBa.js.map} +1 -1
  132. package/dist/{otlp-BENHf3g9.cjs → otlp-CFSW-Dno.cjs} +2 -2
  133. package/dist/{otlp-BENHf3g9.cjs.map → otlp-CFSW-Dno.cjs.map} +1 -1
  134. package/dist/patch-DlcKzIi-.cjs +2 -0
  135. package/dist/patch-DlcKzIi-.cjs.map +1 -0
  136. package/dist/patch-Sr1wKg7W.js +9 -0
  137. package/dist/patch-Sr1wKg7W.js.map +1 -0
  138. package/dist/platform-BZjp9wp1.cjs +2 -0
  139. package/dist/platform-BZjp9wp1.cjs.map +1 -0
  140. package/dist/platform-Dba6R3Hp.js +75 -0
  141. package/dist/platform-Dba6R3Hp.js.map +1 -0
  142. package/dist/{profiler-BAZoh7A4.js → profiler-DNKcqu09.js} +60 -60
  143. package/dist/{profiler-BAZoh7A4.js.map → profiler-DNKcqu09.js.map} +1 -1
  144. package/dist/{profiler-D4tJpDRc.cjs → profiler-DpoPi1hH.cjs} +2 -2
  145. package/dist/{profiler-D4tJpDRc.cjs.map → profiler-DpoPi1hH.cjs.map} +1 -1
  146. package/dist/{profiler-frames-C4xr7KfH.cjs → profiler-frames-C9zJNd8_.cjs} +2 -2
  147. package/dist/{profiler-frames-C4xr7KfH.cjs.map → profiler-frames-C9zJNd8_.cjs.map} +1 -1
  148. package/dist/{profiler-frames-cJMx9wNM.js → profiler-frames-CGXZeZ_3.js} +16 -16
  149. package/dist/{profiler-frames-cJMx9wNM.js.map → profiler-frames-CGXZeZ_3.js.map} +1 -1
  150. package/dist/{remote-rules-Dz9MRAsB.js → remote-rules-DNK96vLa.js} +25 -25
  151. package/dist/{remote-rules-Dz9MRAsB.js.map → remote-rules-DNK96vLa.js.map} +1 -1
  152. package/dist/{remote-rules-_tY0zj5o.cjs → remote-rules-DuMFRlit.cjs} +2 -2
  153. package/dist/{remote-rules-_tY0zj5o.cjs.map → remote-rules-DuMFRlit.cjs.map} +1 -1
  154. package/dist/replay-Cab-lSit.cjs +2 -0
  155. package/dist/replay-Cab-lSit.cjs.map +1 -0
  156. package/dist/{replay-Ds-ANH34.js → replay-Dy6OiaOZ.js} +104 -77
  157. package/dist/replay-Dy6OiaOZ.js.map +1 -0
  158. package/dist/{reports-BDSe4dFH.cjs → reports-CGK9YQch.cjs} +2 -2
  159. package/dist/{reports-BDSe4dFH.cjs.map → reports-CGK9YQch.cjs.map} +1 -1
  160. package/dist/{reports-C-thq-bk.js → reports-CX57-S9s.js} +3 -3
  161. package/dist/{reports-C-thq-bk.js.map → reports-CX57-S9s.js.map} +1 -1
  162. package/dist/{resource-timing-eUl2dNgC.js → resource-timing-CWVDCbrY.js} +4 -4
  163. package/dist/{resource-timing-eUl2dNgC.js.map → resource-timing-CWVDCbrY.js.map} +1 -1
  164. package/dist/{resource-timing-C576gFIQ.cjs → resource-timing-DalulXiR.cjs} +2 -2
  165. package/dist/{resource-timing-C576gFIQ.cjs.map → resource-timing-DalulXiR.cjs.map} +1 -1
  166. package/dist/response-body-Cpz5__4g.cjs +3 -0
  167. package/dist/response-body-Cpz5__4g.cjs.map +1 -0
  168. package/dist/{response-body-eoSQpLiH.js → response-body-yi92Rpvo.js} +109 -109
  169. package/dist/response-body-yi92Rpvo.js.map +1 -0
  170. package/dist/{rotation-Cwct4ckk.js → rotation-ChBbNDE2.js} +27 -28
  171. package/dist/rotation-ChBbNDE2.js.map +1 -0
  172. package/dist/rotation-fTnNJcfH.cjs +2 -0
  173. package/dist/rotation-fTnNJcfH.cjs.map +1 -0
  174. package/dist/{sampling-BlrI8jor.js → sampling-DZTOD28D.js} +16 -16
  175. package/dist/{sampling-BlrI8jor.js.map → sampling-DZTOD28D.js.map} +1 -1
  176. package/dist/{sampling-mXt4dstx.cjs → sampling-wAVJIZXp.cjs} +2 -2
  177. package/dist/{sampling-mXt4dstx.cjs.map → sampling-wAVJIZXp.cjs.map} +1 -1
  178. package/dist/{sanitize-Ba0KqU06.js → sanitize-B2GKlSFp.js} +2 -2
  179. package/dist/{sanitize-Ba0KqU06.js.map → sanitize-B2GKlSFp.js.map} +1 -1
  180. package/dist/{sanitize-DQyiI_KY.cjs → sanitize-BZdhoghq.cjs} +2 -2
  181. package/dist/{sanitize-DQyiI_KY.cjs.map → sanitize-BZdhoghq.cjs.map} +1 -1
  182. package/dist/{sender-Dv8rAmpV.js → sender-BRSpc7R8.js} +192 -178
  183. package/dist/sender-BRSpc7R8.js.map +1 -0
  184. package/dist/sender-CFu98DAB.cjs +2 -0
  185. package/dist/sender-CFu98DAB.cjs.map +1 -0
  186. package/dist/storage/emergency-queue.d.cts +3 -1
  187. package/dist/storage/emergency-queue.d.ts +3 -1
  188. package/dist/storage/stored-context.d.cts +3 -2
  189. package/dist/storage/stored-context.d.ts +3 -2
  190. package/dist/stored-context-CPLlzgpm.cjs +2 -0
  191. package/dist/stored-context-CPLlzgpm.cjs.map +1 -0
  192. package/dist/{stored-context-B2EzVuYm.js → stored-context-df1dEnht.js} +12 -10
  193. package/dist/stored-context-df1dEnht.js.map +1 -0
  194. package/dist/{storm-DjKetLKZ.js → storm-U3_ek1nA.js} +2 -2
  195. package/dist/{storm-DjKetLKZ.js.map → storm-U3_ek1nA.js.map} +1 -1
  196. package/dist/{storm-C-zYSdDX.cjs → storm-qiE_AMC7.cjs} +2 -2
  197. package/dist/{storm-C-zYSdDX.cjs.map → storm-qiE_AMC7.cjs.map} +1 -1
  198. package/dist/transport/exit-flush.d.cts +23 -0
  199. package/dist/transport/exit-flush.d.ts +23 -0
  200. package/dist/transport/http-transport.d.cts +3 -2
  201. package/dist/transport/http-transport.d.ts +3 -2
  202. package/dist/transport/retry-engine.d.cts +11 -3
  203. package/dist/transport/retry-engine.d.ts +11 -3
  204. package/dist/types-BAerHgCq.js.map +1 -1
  205. package/dist/types-C7WNpnG1.cjs.map +1 -1
  206. package/dist/{unclean-exit-DQD1cT7c.js → unclean-exit-Bj6gYHeL.js} +2 -2
  207. package/dist/{unclean-exit-DQD1cT7c.js.map → unclean-exit-Bj6gYHeL.js.map} +1 -1
  208. package/dist/{unclean-exit-py99ApzT.cjs → unclean-exit-CuBh-ee5.cjs} +2 -2
  209. package/dist/{unclean-exit-py99ApzT.cjs.map → unclean-exit-CuBh-ee5.cjs.map} +1 -1
  210. package/dist/{user-timing-D6XTmpuM.cjs → user-timing-BWqzYF2Q.cjs} +2 -2
  211. package/dist/{user-timing-D6XTmpuM.cjs.map → user-timing-BWqzYF2Q.cjs.map} +1 -1
  212. package/dist/{user-timing-BePqb1uN.js → user-timing-Duz0d-OA.js} +2 -2
  213. package/dist/{user-timing-BePqb1uN.js.map → user-timing-Duz0d-OA.js.map} +1 -1
  214. package/dist/utils/identity.d.cts +5 -0
  215. package/dist/utils/identity.d.ts +5 -0
  216. package/dist/utils/lock.d.cts +3 -2
  217. package/dist/utils/lock.d.ts +3 -2
  218. package/dist/utils/openfin.d.cts +18 -6
  219. package/dist/utils/openfin.d.ts +18 -6
  220. package/dist/utils/patch.d.cts +1 -1
  221. package/dist/utils/patch.d.ts +1 -1
  222. package/dist/utils/platform.d.cts +6 -0
  223. package/dist/utils/platform.d.ts +6 -0
  224. package/dist/{web-socket-DSHgDiZ6.js → web-socket-CE_9Q22z.js} +5 -5
  225. package/dist/{web-socket-DSHgDiZ6.js.map → web-socket-CE_9Q22z.js.map} +1 -1
  226. package/dist/{web-socket-CoIUBM3C.cjs → web-socket-sm3rD-A_.cjs} +2 -2
  227. package/dist/{web-socket-CoIUBM3C.cjs.map → web-socket-sm3rD-A_.cjs.map} +1 -1
  228. package/dist/{web-vitals-4pWACwaR.js → web-vitals-CGwXGF-M.js} +4 -4
  229. package/dist/web-vitals-CGwXGF-M.js.map +1 -0
  230. package/dist/web-vitals-Df4Wsfx9.cjs +2 -0
  231. package/dist/web-vitals-Df4Wsfx9.cjs.map +1 -0
  232. package/dist/{worker-protocol-QbvqNazn.cjs → worker-protocol-D5VnCdWY.cjs} +2 -2
  233. package/dist/{worker-protocol-QbvqNazn.cjs.map → worker-protocol-D5VnCdWY.cjs.map} +1 -1
  234. package/dist/{worker-protocol-x074Rpet.js → worker-protocol-h4-tRWqy.js} +6 -6
  235. package/dist/{worker-protocol-x074Rpet.js.map → worker-protocol-h4-tRWqy.js.map} +1 -1
  236. package/dist/{worker-server-CFe4nvos.cjs → worker-server-CF1yatXq.cjs} +2 -2
  237. package/dist/{worker-server-CFe4nvos.cjs.map → worker-server-CF1yatXq.cjs.map} +1 -1
  238. package/dist/worker-server-FYfKHQhJ.js +94 -0
  239. package/dist/{worker-server-iUVSjH8L.js.map → worker-server-FYfKHQhJ.js.map} +1 -1
  240. package/dist/worker-transport-COgY4RX8.cjs +2 -0
  241. package/dist/worker-transport-COgY4RX8.cjs.map +1 -0
  242. package/dist/{worker-transport-Dy1KMA7t.js → worker-transport-jzX1IusG.js} +49 -45
  243. package/dist/worker-transport-jzX1IusG.js.map +1 -0
  244. package/llms.txt +14 -12
  245. package/package.json +13 -5
  246. package/dist/bus-C39wspFV.js.map +0 -1
  247. package/dist/bus-_EaOVPGq.cjs +0 -2
  248. package/dist/bus-_EaOVPGq.cjs.map +0 -1
  249. package/dist/config-DUs7uHHt.cjs +0 -2
  250. package/dist/config-DUs7uHHt.cjs.map +0 -1
  251. package/dist/config-SgQcCP1_.js +0 -560
  252. package/dist/config-SgQcCP1_.js.map +0 -1
  253. package/dist/constants-CUyd9cTZ.js.map +0 -1
  254. package/dist/constants-CqdJhTxH.cjs +0 -2
  255. package/dist/constants-CqdJhTxH.cjs.map +0 -1
  256. package/dist/errors-BE_EZV7Q.js.map +0 -1
  257. package/dist/errors-CNPbesMs.cjs +0 -3
  258. package/dist/errors-CNPbesMs.cjs.map +0 -1
  259. package/dist/factory-CTi0Is3F.js.map +0 -1
  260. package/dist/factory-hRrH32v5.cjs +0 -2
  261. package/dist/factory-hRrH32v5.cjs.map +0 -1
  262. package/dist/identity-DdhKgrpk.js.map +0 -1
  263. package/dist/identity-DlWRIuwy.cjs +0 -2
  264. package/dist/identity-DlWRIuwy.cjs.map +0 -1
  265. package/dist/interactions-CUkzK8sR.cjs +0 -2
  266. package/dist/interactions-CUkzK8sR.cjs.map +0 -1
  267. package/dist/interactions-DiFvCosX.js +0 -111
  268. package/dist/interactions-DiFvCosX.js.map +0 -1
  269. package/dist/patch-BX8KrPCT.cjs +0 -2
  270. package/dist/patch-BX8KrPCT.cjs.map +0 -1
  271. package/dist/patch-UdPz1ea8.js +0 -8
  272. package/dist/patch-UdPz1ea8.js.map +0 -1
  273. package/dist/platform-BaaFIPCU.js +0 -62
  274. package/dist/platform-BaaFIPCU.js.map +0 -1
  275. package/dist/platform-CfA3-7sJ.cjs +0 -2
  276. package/dist/platform-CfA3-7sJ.cjs.map +0 -1
  277. package/dist/replay-B3gFXIZd.cjs +0 -2
  278. package/dist/replay-B3gFXIZd.cjs.map +0 -1
  279. package/dist/replay-Ds-ANH34.js.map +0 -1
  280. package/dist/response-body-YdNl-HkR.cjs +0 -3
  281. package/dist/response-body-YdNl-HkR.cjs.map +0 -1
  282. package/dist/response-body-eoSQpLiH.js.map +0 -1
  283. package/dist/rotation-Cwct4ckk.js.map +0 -1
  284. package/dist/rotation-D4qUAHAu.cjs +0 -2
  285. package/dist/rotation-D4qUAHAu.cjs.map +0 -1
  286. package/dist/sender-BdRuNVhF.cjs +0 -2
  287. package/dist/sender-BdRuNVhF.cjs.map +0 -1
  288. package/dist/sender-Dv8rAmpV.js.map +0 -1
  289. package/dist/stored-context-B2EzVuYm.js.map +0 -1
  290. package/dist/stored-context-CXt7eHZL.cjs +0 -2
  291. package/dist/stored-context-CXt7eHZL.cjs.map +0 -1
  292. package/dist/web-vitals-4pWACwaR.js.map +0 -1
  293. package/dist/web-vitals-__X7t4pj.cjs +0 -2
  294. package/dist/web-vitals-__X7t4pj.cjs.map +0 -1
  295. package/dist/worker-server-iUVSjH8L.js +0 -94
  296. package/dist/worker-transport-CRAX-09c.cjs +0 -2
  297. package/dist/worker-transport-CRAX-09c.cjs.map +0 -1
  298. package/dist/worker-transport-Dy1KMA7t.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"identity-DdhKgrpk.js","names":["SESSION_IDLE_MS","TAB_ID_KEY","SESSION_ID_KEY","_defineProperty","BROWSER_STORES","memoryStores","wrap","map","key","value","localStore","sessionStore","randomHex","bytes","byteLength","i","b","newId","safeRead","diagnostics","store","stores","safeWrite","liveSession","raw","parsed","idleMs","now","resolveIdentity","contextId","minted","sessionId","session","tabId","persistTabId","SessionTouch","stored"],"sources":["../src/utils/identity.ts"],"sourcesContent":["// src/utils/identity.ts\n//\n// Creates and keeps the session, tab, and context correlation identifiers. In a sandboxed\n// iframe and in private mode, Storage throws instead of returning null, so an unguarded read\n// would break the library at import.\n\nimport {\n BYTE_VALUE_COUNT,\n ID_BYTE_LENGTH,\n SESSION_ID_KEY,\n SESSION_IDLE_MS,\n SESSION_TOUCH_MS,\n TAB_ID_KEY,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\n\n/** Correlation identifiers attached to log records across session, tab, and realm scopes. */\nexport interface Identity {\n /** Origin-wide user session identifier surviving across tabs until idle expiration. */\n sessionId: string;\n /** Browser tab or desktop window identifier surviving document reloads. */\n tabId: string;\n /** Unique execution realm identifier regenerated on every document load. */\n contextId: string;\n}\n\n/** The three Storage methods that identity and journey code use. */\nexport interface KeyValueStore {\n /**\n * Reads one value.\n * @param key Storage key.\n * @returns Stored value, or null.\n */\n getItem(key: string): string | null;\n /**\n * Writes one value.\n * @param key Storage key.\n * @param value Value to write.\n */\n setItem(key: string, value: string): void;\n /**\n * Removes one value.\n * @param key Storage key.\n */\n removeItem(key: string): void;\n}\n\n/** Stores for identity and journey keys. A getter can throw in a sandboxed frame. */\nexport interface IdentityStores {\n /** Store that lasts across tabs and reloads. */\n local(): KeyValueStore;\n /** Store that lasts for one tab. */\n session(): KeyValueStore;\n}\n\n/** Stores that write to the browser. Used by the `identity: \"storage\"` option. */\nexport const BROWSER_STORES: IdentityStores = {\n local: () => localStorage,\n session: () => sessionStorage,\n};\n\n/**\n * Creates stores that keep values in memory only. Used by the `identity: \"memory\"` option.\n * @returns Stores that write nothing to the browser.\n */\nexport function memoryStores(): IdentityStores {\n const wrap = (map: Map<string, string>): KeyValueStore => ({\n getItem: (key) => map.get(key) ?? null,\n setItem: (key, value) => {\n map.set(key, value);\n },\n removeItem: (key) => {\n map.delete(key);\n },\n });\n\n const localStore = wrap(new Map());\n const sessionStore = wrap(new Map());\n\n return { local: () => localStore, session: () => sessionStore };\n}\n\n/**\n * Generates a random lowercase hexadecimal string of the given byte length. Uses\n * crypto.getRandomValues when it is available, and Math.random otherwise.\n * @param byteLength Number of random bytes to generate.\n * @returns Hexadecimal string of length byteLength * 2.\n */\nexport function randomHex(byteLength: number): string {\n const bytes = new Uint8Array(byteLength);\n if (typeof crypto !== \"undefined\" && typeof crypto.getRandomValues === \"function\") {\n crypto.getRandomValues(bytes);\n } else {\n for (let i = 0; i < byteLength; i++) {\n bytes[i] = Math.floor(Math.random() * BYTE_VALUE_COUNT);\n }\n }\n return Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\n/**\n * Generates a unique identifier with crypto.randomUUID, falling back to randomHex.\n * @param diagnostics Diagnostics reporter. Counts a blocked crypto.randomUUID call.\n * @returns A UUID or a random hex identifier.\n */\nexport function newId(diagnostics: Diagnostics): string {\n try {\n if (typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n } catch {\n // A sandbox can block crypto.randomUUID with a SecurityError: the method exists but the\n // call throws. Count the fault, because a report for every id would be noise.\n diagnostics.count(\"platform.api_blocked\");\n }\n return randomHex(ID_BYTE_LENGTH);\n}\n\n/**\n * Reads a value from the local or session store, reporting any storage error to diagnostics.\n * @param stores Identity stores.\n * @param store Storage target (\"local\" or \"session\").\n * @param key Storage key.\n * @param diagnostics Diagnostics reporter.\n * @returns The stored string, or null if it is unreadable or absent.\n */\nfunction safeRead(\n stores: IdentityStores,\n store: \"local\" | \"session\",\n key: string,\n diagnostics: Diagnostics,\n): string | null {\n return (\n diagnostics.guard(\"storage.unavailable\", `The library could not read ${store}Storage.`, () =>\n stores[store]().getItem(key),\n ) ?? null\n );\n}\n\n/**\n * Writes a key-value pair to the local or session store, reporting any storage error to\n * diagnostics.\n * @param stores Identity stores.\n * @param store Storage target (\"local\" or \"session\").\n * @param key Storage key.\n * @param value The string value to store.\n * @param diagnostics Diagnostics reporter.\n */\nfunction safeWrite(\n stores: IdentityStores,\n store: \"local\" | \"session\",\n key: string,\n value: string,\n diagnostics: Diagnostics,\n): void {\n diagnostics.guard(\n \"storage.unavailable\",\n `The library could not write to ${store}Storage.`,\n () => {\n stores[store]().setItem(key, value);\n },\n );\n}\n\n/**\n * Reads the session id from the local store. Reports a record that isn't valid JSON.\n * @param stores Identity stores.\n * @param diagnostics Diagnostics reporter.\n * @param now Epoch time in milliseconds.\n * @param idleMs Idle time after which the session expires, in milliseconds. null means never.\n * @returns The stored id, or undefined when it is absent or expired.\n */\nfunction liveSession(\n stores: IdentityStores,\n diagnostics: Diagnostics,\n now: number,\n idleMs: number | null,\n): string | undefined {\n const raw = safeRead(stores, \"local\", SESSION_ID_KEY, diagnostics);\n if (!raw) {\n return undefined;\n }\n\n try {\n const parsed = JSON.parse(raw) as { id?: string; lastSeenAt?: number };\n return parsed.id && (idleMs === null || now - (parsed.lastSeenAt ?? 0) < idleMs)\n ? parsed.id\n : undefined;\n } catch {\n diagnostics.report(\n \"storage.degraded\",\n \"The session record is not valid JSON. The library starts a new session.\",\n );\n return undefined;\n }\n}\n\n/**\n * Resolves or initializes the session, tab, and context identifiers for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @param stores Identity stores.\n * @returns The populated Identity object.\n */\nexport function resolveIdentity(\n diagnostics: Diagnostics,\n stores: IdentityStores = BROWSER_STORES,\n idleMs: number | null = SESSION_IDLE_MS,\n): Identity {\n const contextId = newId(diagnostics);\n const now = Date.now();\n\n const minted = newId(diagnostics);\n const sessionId = liveSession(stores, diagnostics, now, idleMs) ?? minted;\n const session = JSON.stringify({ id: sessionId, lastSeenAt: now });\n safeWrite(stores, \"local\", SESSION_ID_KEY, session, diagnostics);\n\n let tabId = safeRead(stores, \"session\", TAB_ID_KEY, diagnostics) ?? \"\";\n if (!tabId) {\n tabId = newId(diagnostics);\n safeWrite(stores, \"session\", TAB_ID_KEY, tabId, diagnostics);\n }\n\n return { sessionId, tabId, contextId };\n}\n\n/**\n * Writes a new tab id to the session store.\n * @param tabId New tab identifier.\n * @param diagnostics Diagnostics reporter.\n * @param stores Identity stores.\n */\nexport function persistTabId(\n tabId: string,\n diagnostics: Diagnostics,\n stores: IdentityStores,\n): void {\n safeWrite(stores, \"session\", TAB_ID_KEY, tabId, diagnostics);\n}\n\n/**\n * Writes the session's last-seen timestamp, throttled by `SESSION_TOUCH_MS`. The throttle\n * state lives on the instance, not the module, so two runtimes in one document don't block\n * each other's session writes.\n */\nexport class SessionTouch {\n /** Epoch milliseconds of the last write this instance made. */\n private lastTouchAt = 0;\n\n /**\n * @param diagnostics Diagnostics reporter.\n * @param stores Identity stores.\n */\n constructor(\n private diagnostics: Diagnostics,\n private readonly stores: IdentityStores = BROWSER_STORES,\n private readonly idleMs: number | null = SESSION_IDLE_MS,\n ) {}\n\n /**\n * Writes the session activity time to the local store, at most once per throttle window.\n * @param sessionId The active session identifier.\n */\n touch(sessionId: string): void {\n const now = Date.now();\n\n if (now - this.lastTouchAt < SESSION_TOUCH_MS) {\n return;\n }\n\n // Another tab can hold a newer session, for example after newSession(). Don't write the old\n // id back, or a reload would resume the old session.\n const stored = liveSession(this.stores, this.diagnostics, now, this.idleMs);\n if (stored !== undefined && stored !== sessionId) {\n this.lastTouchAt = now;\n return;\n }\n\n this.write(sessionId, now);\n }\n\n /**\n * Reads the live session id from the local store.\n * @returns The stored session id, or undefined if no session is live.\n */\n stored(): string | undefined {\n return liveSession(this.stores, this.diagnostics, Date.now(), this.idleMs);\n }\n\n /**\n * Writes a new session id to the local store right away, bypassing the throttle.\n * @param sessionId The new session identifier.\n */\n restart(sessionId: string): void {\n this.write(sessionId, Date.now());\n }\n\n /**\n * Writes the session record and starts a new throttle window.\n * @param sessionId Session identifier.\n * @param now Epoch time in milliseconds.\n */\n private write(sessionId: string, now: number): void {\n this.lastTouchAt = now;\n const session = JSON.stringify({ id: sessionId, lastSeenAt: now });\n safeWrite(this.stores, \"local\", SESSION_ID_KEY, session, this.diagnostics);\n }\n}\n"],"mappings":";;;AAwDA,IAAaI,IAAiC;CAC5C,aAAa;CACb,eAAe;AACjB;AAMA,SAAgBC,IAA+B;CAC7C,IAAMC,KAAQ,OAA6C;EACzD,UAAU,MAAQC,EAAI,IAAIC,CAAG,KAAK;EAClC,UAAU,GAAK,MAAU;GACvB,EAAI,IAAIA,GAAKC,CAAK;EACpB;EACA,aAAa,MAAQ;GACnB,EAAI,OAAOD,CAAG;EAChB;CACF,IAEME,IAAaJ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,OAAOJ,EAAY,KAAK,QAAQ,KAAK,aAAa,KAAK,IAAI,GAAG,KAAK,MAAM;CAC3E;CAMA,QAAQ,GAAyB;EAC/B,KAAK,MAAMQ,GAAW,KAAK,IAAI,CAAC;CAClC;CAOA,MAAc,GAAmB,GAAmB;EAClD,KAAK,cAAcJ;EACnB,IAAMK,IAAU,KAAK,UAAU;GAAE,IAAID;GAAW,YAAYJ;EAAI,CAAC;EACjE,EAAU,KAAK,QAAQ,SAASzB,GAAgB8B,GAAS,KAAK,WAAW;CAC3E;AACF"}
@@ -1,2 +0,0 @@
1
- const e=require("./constants-CqdJhTxH.cjs"),t=require("./defineProperty-X1c4tIPD.cjs");var n={local:()=>localStorage,session:()=>sessionStorage};function r(){let e=e=>({getItem:t=>e.get(t)??null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}),t=e(new Map),n=e(new Map);return{local:()=>t,session:()=>n}}function i(e){let t=new Uint8Array(e);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(t);else for(let n=0;n<e;n++)t[n]=Math.floor(Math.random()*256);return Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)}function a(e){try{if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID()}catch{e.count(`platform.api_blocked`)}return i(16)}function o(e,t,n,r){return r.guard(`storage.unavailable`,`The library could not read ${t}Storage.`,()=>e[t]().getItem(n))??null}function s(e,t,n,r,i){i.guard(`storage.unavailable`,`The library could not write to ${t}Storage.`,()=>{e[t]().setItem(n,r)})}function c(t,n,r,i){let a=o(t,`local`,e.zn,n);if(a)try{let e=JSON.parse(a);return e.id&&(i===null||r-(e.lastSeenAt??0)<i)?e.id:void 0}catch{n.report(`storage.degraded`,`The session record is not valid JSON. The library starts a new session.`);return}}function l(t,r=n,i=e.Rn){let l=a(t),u=Date.now(),d=a(t),f=c(r,t,u,i)??d,p=JSON.stringify({id:f,lastSeenAt:u});s(r,`local`,e.zn,p,t);let m=o(r,`session`,`ui-observability.tab`,t)??``;return m||(m=a(t),s(r,`session`,e.Zn,m,t)),{sessionId:f,tabId:m,contextId:l}}function u(t,n,r){s(r,`session`,e.Zn,t,n)}var d=class{constructor(r,i=n,a=e.Rn){t.t(this,`diagnostics`,void 0),t.t(this,`stores`,void 0),t.t(this,`idleMs`,void 0),t.t(this,`lastTouchAt`,0),this.diagnostics=r,this.stores=i,this.idleMs=a}touch(e){let t=Date.now();if(t-this.lastTouchAt<6e4)return;let n=c(this.stores,this.diagnostics,t,this.idleMs);n!==void 0&&n!==e?this.lastTouchAt=t:this.write(e,t)}stored(){return c(this.stores,this.diagnostics,Date.now(),this.idleMs)}restart(e){this.write(e,Date.now())}write(t,n){this.lastTouchAt=n;let r=JSON.stringify({id:t,lastSeenAt:n});s(this.stores,`local`,e.zn,r,this.diagnostics)}};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
2
- //# sourceMappingURL=identity-DlWRIuwy.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"identity-DlWRIuwy.cjs","names":["SESSION_ID_KEY","SESSION_IDLE_MS","TAB_ID_KEY","require_constants","require_defineProperty","BROWSER_STORES","memoryStores","wrap","map","key","value","localStore","sessionStore","randomHex","bytes","byteLength","i","b","newId","diagnostics","safeRead","store","stores","safeWrite","liveSession","raw","parsed","idleMs","now","resolveIdentity","contextId","minted","sessionId","session","tabId","persistTabId","SessionTouch","stored"],"sources":["../src/utils/identity.ts"],"sourcesContent":["// src/utils/identity.ts\n//\n// Creates and keeps the session, tab, and context correlation identifiers. In a sandboxed\n// iframe and in private mode, Storage throws instead of returning null, so an unguarded read\n// would break the library at import.\n\nimport {\n BYTE_VALUE_COUNT,\n ID_BYTE_LENGTH,\n SESSION_ID_KEY,\n SESSION_IDLE_MS,\n SESSION_TOUCH_MS,\n TAB_ID_KEY,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\n\n/** Correlation identifiers attached to log records across session, tab, and realm scopes. */\nexport interface Identity {\n /** Origin-wide user session identifier surviving across tabs until idle expiration. */\n sessionId: string;\n /** Browser tab or desktop window identifier surviving document reloads. */\n tabId: string;\n /** Unique execution realm identifier regenerated on every document load. */\n contextId: string;\n}\n\n/** The three Storage methods that identity and journey code use. */\nexport interface KeyValueStore {\n /**\n * Reads one value.\n * @param key Storage key.\n * @returns Stored value, or null.\n */\n getItem(key: string): string | null;\n /**\n * Writes one value.\n * @param key Storage key.\n * @param value Value to write.\n */\n setItem(key: string, value: string): void;\n /**\n * Removes one value.\n * @param key Storage key.\n */\n removeItem(key: string): void;\n}\n\n/** Stores for identity and journey keys. A getter can throw in a sandboxed frame. */\nexport interface IdentityStores {\n /** Store that lasts across tabs and reloads. */\n local(): KeyValueStore;\n /** Store that lasts for one tab. */\n session(): KeyValueStore;\n}\n\n/** Stores that write to the browser. Used by the `identity: \"storage\"` option. */\nexport const BROWSER_STORES: IdentityStores = {\n local: () => localStorage,\n session: () => sessionStorage,\n};\n\n/**\n * Creates stores that keep values in memory only. Used by the `identity: \"memory\"` option.\n * @returns Stores that write nothing to the browser.\n */\nexport function memoryStores(): IdentityStores {\n const wrap = (map: Map<string, string>): KeyValueStore => ({\n getItem: (key) => map.get(key) ?? null,\n setItem: (key, value) => {\n map.set(key, value);\n },\n removeItem: (key) => {\n map.delete(key);\n },\n });\n\n const localStore = wrap(new Map());\n const sessionStore = wrap(new Map());\n\n return { local: () => localStore, session: () => sessionStore };\n}\n\n/**\n * Generates a random lowercase hexadecimal string of the given byte length. Uses\n * crypto.getRandomValues when it is available, and Math.random otherwise.\n * @param byteLength Number of random bytes to generate.\n * @returns Hexadecimal string of length byteLength * 2.\n */\nexport function randomHex(byteLength: number): string {\n const bytes = new Uint8Array(byteLength);\n if (typeof crypto !== \"undefined\" && typeof crypto.getRandomValues === \"function\") {\n crypto.getRandomValues(bytes);\n } else {\n for (let i = 0; i < byteLength; i++) {\n bytes[i] = Math.floor(Math.random() * BYTE_VALUE_COUNT);\n }\n }\n return Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\n/**\n * Generates a unique identifier with crypto.randomUUID, falling back to randomHex.\n * @param diagnostics Diagnostics reporter. Counts a blocked crypto.randomUUID call.\n * @returns A UUID or a random hex identifier.\n */\nexport function newId(diagnostics: Diagnostics): string {\n try {\n if (typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n } catch {\n // A sandbox can block crypto.randomUUID with a SecurityError: the method exists but the\n // call throws. Count the fault, because a report for every id would be noise.\n diagnostics.count(\"platform.api_blocked\");\n }\n return randomHex(ID_BYTE_LENGTH);\n}\n\n/**\n * Reads a value from the local or session store, reporting any storage error to diagnostics.\n * @param stores Identity stores.\n * @param store Storage target (\"local\" or \"session\").\n * @param key Storage key.\n * @param diagnostics Diagnostics reporter.\n * @returns The stored string, or null if it is unreadable or absent.\n */\nfunction safeRead(\n stores: IdentityStores,\n store: \"local\" | \"session\",\n key: string,\n diagnostics: Diagnostics,\n): string | null {\n return (\n diagnostics.guard(\"storage.unavailable\", `The library could not read ${store}Storage.`, () =>\n stores[store]().getItem(key),\n ) ?? null\n );\n}\n\n/**\n * Writes a key-value pair to the local or session store, reporting any storage error to\n * diagnostics.\n * @param stores Identity stores.\n * @param store Storage target (\"local\" or \"session\").\n * @param key Storage key.\n * @param value The string value to store.\n * @param diagnostics Diagnostics reporter.\n */\nfunction safeWrite(\n stores: IdentityStores,\n store: \"local\" | \"session\",\n key: string,\n value: string,\n diagnostics: Diagnostics,\n): void {\n diagnostics.guard(\n \"storage.unavailable\",\n `The library could not write to ${store}Storage.`,\n () => {\n stores[store]().setItem(key, value);\n },\n );\n}\n\n/**\n * Reads the session id from the local store. Reports a record that isn't valid JSON.\n * @param stores Identity stores.\n * @param diagnostics Diagnostics reporter.\n * @param now Epoch time in milliseconds.\n * @param idleMs Idle time after which the session expires, in milliseconds. null means never.\n * @returns The stored id, or undefined when it is absent or expired.\n */\nfunction liveSession(\n stores: IdentityStores,\n diagnostics: Diagnostics,\n now: number,\n idleMs: number | null,\n): string | undefined {\n const raw = safeRead(stores, \"local\", SESSION_ID_KEY, diagnostics);\n if (!raw) {\n return undefined;\n }\n\n try {\n const parsed = JSON.parse(raw) as { id?: string; lastSeenAt?: number };\n return parsed.id && (idleMs === null || now - (parsed.lastSeenAt ?? 0) < idleMs)\n ? parsed.id\n : undefined;\n } catch {\n diagnostics.report(\n \"storage.degraded\",\n \"The session record is not valid JSON. The library starts a new session.\",\n );\n return undefined;\n }\n}\n\n/**\n * Resolves or initializes the session, tab, and context identifiers for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @param stores Identity stores.\n * @returns The populated Identity object.\n */\nexport function resolveIdentity(\n diagnostics: Diagnostics,\n stores: IdentityStores = BROWSER_STORES,\n idleMs: number | null = SESSION_IDLE_MS,\n): Identity {\n const contextId = newId(diagnostics);\n const now = Date.now();\n\n const minted = newId(diagnostics);\n const sessionId = liveSession(stores, diagnostics, now, idleMs) ?? minted;\n const session = JSON.stringify({ id: sessionId, lastSeenAt: now });\n safeWrite(stores, \"local\", SESSION_ID_KEY, session, diagnostics);\n\n let tabId = safeRead(stores, \"session\", TAB_ID_KEY, diagnostics) ?? \"\";\n if (!tabId) {\n tabId = newId(diagnostics);\n safeWrite(stores, \"session\", TAB_ID_KEY, tabId, diagnostics);\n }\n\n return { sessionId, tabId, contextId };\n}\n\n/**\n * Writes a new tab id to the session store.\n * @param tabId New tab identifier.\n * @param diagnostics Diagnostics reporter.\n * @param stores Identity stores.\n */\nexport function persistTabId(\n tabId: string,\n diagnostics: Diagnostics,\n stores: IdentityStores,\n): void {\n safeWrite(stores, \"session\", TAB_ID_KEY, tabId, diagnostics);\n}\n\n/**\n * Writes the session's last-seen timestamp, throttled by `SESSION_TOUCH_MS`. The throttle\n * state lives on the instance, not the module, so two runtimes in one document don't block\n * each other's session writes.\n */\nexport class SessionTouch {\n /** Epoch milliseconds of the last write this instance made. */\n private lastTouchAt = 0;\n\n /**\n * @param diagnostics Diagnostics reporter.\n * @param stores Identity stores.\n */\n constructor(\n private diagnostics: Diagnostics,\n private readonly stores: IdentityStores = BROWSER_STORES,\n private readonly idleMs: number | null = SESSION_IDLE_MS,\n ) {}\n\n /**\n * Writes the session activity time to the local store, at most once per throttle window.\n * @param sessionId The active session identifier.\n */\n touch(sessionId: string): void {\n const now = Date.now();\n\n if (now - this.lastTouchAt < SESSION_TOUCH_MS) {\n return;\n }\n\n // Another tab can hold a newer session, for example after newSession(). Don't write the old\n // id back, or a reload would resume the old session.\n const stored = liveSession(this.stores, this.diagnostics, now, this.idleMs);\n if (stored !== undefined && stored !== sessionId) {\n this.lastTouchAt = now;\n return;\n }\n\n this.write(sessionId, now);\n }\n\n /**\n * Reads the live session id from the local store.\n * @returns The stored session id, or undefined if no session is live.\n */\n stored(): string | undefined {\n return liveSession(this.stores, this.diagnostics, Date.now(), this.idleMs);\n }\n\n /**\n * Writes a new session id to the local store right away, bypassing the throttle.\n * @param sessionId The new session identifier.\n */\n restart(sessionId: string): void {\n this.write(sessionId, Date.now());\n }\n\n /**\n * Writes the session record and starts a new throttle window.\n * @param sessionId Session identifier.\n * @param now Epoch time in milliseconds.\n */\n private write(sessionId: string, now: number): void {\n this.lastTouchAt = now;\n const session = JSON.stringify({ id: sessionId, lastSeenAt: now });\n safeWrite(this.stores, \"local\", SESSION_ID_KEY, session, this.diagnostics);\n }\n}\n"],"mappings":"A,uFAwDA,IAAaK,EAAiC,CAC5C,UAAa,aACb,YAAe,cACjB,EAMA,SAAgBC,GAA+B,CAC7C,IAAMC,EAAQ,IAA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AAI,EAErB,GAAIA,EAAM,KAAK,YAAA,IACb,OAKF,IAAMS,EAASb,EAAY,KAAK,OAAQ,KAAK,YAAaI,EAAK,KAAK,MAAM,EACtES,IAAW,IAAA,IAAaA,IAAWL,EACrC,KAAK,YAAcJ,EAIrB,KAAK,MAAMI,EAAWJ,CAAG,CAC3B,CAMA,QAA6B,CAC3B,OAAOJ,EAAY,KAAK,OAAQ,KAAK,YAAa,KAAK,IAAI,EAAG,KAAK,MAAM,CAC3E,CAMA,QAAQ,EAAyB,CAC/B,KAAK,MAAMQ,EAAW,KAAK,IAAI,CAAC,CAClC,CAOA,MAAc,EAAmB,EAAmB,CAClD,KAAK,YAAcJ,EACnB,IAAMK,EAAU,KAAK,UAAU,CAAE,GAAID,EAAW,WAAYJ,CAAI,CAAC,EACjEL,EAAU,KAAK,OAAQ,QAASvB,EAAAA,GAAgBiC,EAAS,KAAK,WAAW,CAC3E,CACF,E"}
@@ -1,2 +0,0 @@
1
- const e=require("./constants-CqdJhTxH.cjs"),t=require("./patch-BX8KrPCT.cjs"),n=require("./platform-CfA3-7sJ.cjs"),r=require("./defineProperty-X1c4tIPD.cjs");var i=`a[target="_blank"], a[download]`;function a(e){let t=e.tagName.toLowerCase(),n=e.getAttribute(`data-testid`)??e.getAttribute(`data-test-id`);if(n!==null)return`[data-testid="${n}"]`;if(e.id!==``)return`#${e.id}`;let r=e.getAttribute(`aria-label`);if(r!==null)return`${t}[aria-label="${r.slice(0,40)}"]`;let i=e.getAttribute(`class`)?.trim()??``;return i===``?t:`${t}.${i.split(/\s+/).slice(0,2).join(`.`)}`}function o(){return history}var s=class{constructor(t){r.t(this,`ctx`,void 0),r.t(this,`name`,`interactions`),r.t(this,`installed`,!1),r.t(this,`restores`,[]),r.t(this,`lastUrl`,``),r.t(this,`burst`,{target:null,times:[],reported:!1}),r.t(this,`stopDeadCheck`,void 0),r.t(this,`onClick`,t=>{if(this.ctx.isActive?.()===!1)return;let n=t.target;if(!(n instanceof Element))return;let r=this.ctx.config.capture.interactions,o=typeof r==`object`?r:{},s=o.ignoreSelector===void 0?e.vt:o.ignoreSelector;if(s&&n.closest(s))return;let c=o.actionAttribute??`data-observability-action`,l=((n.closest(`[${c}]`)?.getAttribute(c)??``)||`unknown-click`).slice(0,this.ctx.config.limits.maxBodyChars),u={};o.selector&&(u.selector=a(n)),o.text&&(u.text=n.textContent.trim().slice(0,o.maxTextChars??50)),this.ctx.tracing.rotate(`interaction`),this.ctx.breadcrumbs.push({t:Date.now(),category:`click`,message:l,data:Object.keys(u).length>0?u:void 0}),o.rageClicks&&this.countRage(n,l,o),o.deadClicks&&n.closest(`a, button, summary, input[type="button"], input[type="submit"], input[type="reset"], [role="button"], [role="link"], [role="menuitem"], [role="tab"], [${c}]`)&&!n.closest(i)&&this.watchDead(l,o)}),r.t(this,`onNavigate`,()=>{let e=this.lastUrl,t=location.href;if(e===t||(this.lastUrl=t,this.ctx.isActive?.()===!1))return;let r=this.ctx.config.capture.fullUrls,{urlTransform:i}=this.ctx.config.capture,a=n.i(e,r,i,this.ctx.diagnostics),o=n.i(t,r,i,this.ctx.diagnostics);this.ctx.tracing.rotate(`navigation`),this.ctx.breadcrumbs.push({t:Date.now(),category:`navigation`,message:`${a} -> ${o}`}),this.ctx.logger.logEvent(`NAVIGATION`,{"page.url.previous":a})}),this.ctx=t}install(){this.installed||typeof document>`u`||(this.installed=!0,this.lastUrl=location.href,this.ctx.config.capture.interactions&&addEventListener(`click`,this.onClick,!0),this.ctx.config.capture.navigation&&(this.installHistory(),addEventListener(`popstate`,this.onNavigate),addEventListener(`hashchange`,this.onNavigate)))}uninstall(){if(this.installed){this.installed=!1,removeEventListener(`click`,this.onClick,!0),removeEventListener(`popstate`,this.onNavigate),removeEventListener(`hashchange`,this.onNavigate);for(let e of this.restores.splice(0))e();this.stopDeadCheck?.(),this.burst={target:null,times:[],reported:!1}}}countRage(e,t,n){let r=Date.now(),i=n.rageClickWindowMs??1e3,a=n.rageClickCount??3,o=this.burst.target===e?this.burst.times.filter(e=>r-e<i):[],s=o.length>0&&this.burst.reported;o.push(r);let c=o.length>=a;this.burst={target:e,times:o,reported:s||c},c&&!s&&this.ctx.logger.logEvent(`ui.rage_click`,{"click.action":t,"click.count":a})}watchDead(e,t){if(this.stopDeadCheck||typeof MutationObserver>`u`)return;let n=location.href,r=!1,i=()=>{r=!0},a=new MutationObserver(i);a.observe(document,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),addEventListener(`scroll`,i,{capture:!0,passive:!0});let o=()=>{clearTimeout(s),a.disconnect(),removeEventListener(`scroll`,i,!0),this.stopDeadCheck=void 0},s=setTimeout(()=>{o(),!r&&location.href===n&&this.ctx.isActive?.()!==!1&&this.ctx.logger.logEvent(`ui.dead_click`,{"click.action":e})},t.deadClickMs??1e3);this.stopDeadCheck=o}installHistory(){if(typeof history>`u`)return;let e=o(),n=this.onNavigate,r=!0,i=t.t(e,`pushState`,e=>function(...t){e.apply(this,t),r&&queueMicrotask(n)}),a=t.t(e,`replaceState`,e=>function(...t){e.apply(this,t),r&&queueMicrotask(n)});this.restores.push(()=>{r=!1,i(),a()})}};exports.InteractionCapture=s;
2
- //# sourceMappingURL=interactions-CUkzK8sR.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interactions-CUkzK8sR.cjs","names":["IGNORE_SELECTOR","recordedUrl","patch","require_constants","require_patch","require_platform","require_defineProperty","LEAVING_LINKS","describeElement","tag","element","testId","label","classAttribute","historyMethods","InteractionCapture","target","event","settings","options","ignore","attribute","message","data","from","to","full","fromUrl","urlTransform","toUrl","ctx","restore","now","windowMs","count","times","t","reported","reached","action","href","responded","respond","observer","stop","timer","onNavigate","active","restorePushState","args","original","restoreReplaceState"],"sources":["../src/capture/interactions.ts"],"sourcesContent":["// src/capture/interactions.ts\n//\n// Captures clicks and in-page navigations as breadcrumbs and trace boundaries. Also detects\n// rage clicks and dead clicks.\n\nimport {\n ACTION_ATTRIBUTE_DEFAULT,\n ARIA_LABEL_MAX_CHARS,\n CLICK_TEXT_MAX_CHARS,\n DEAD_CLICK_CONTROLS,\n DEAD_CLICK_MS,\n IGNORE_SELECTOR,\n RAGE_CLICK_COUNT,\n RAGE_CLICK_WINDOW_MS,\n SELECTOR_MAX_CLASSES,\n} from \"../constants\";\nimport type { InteractionOptions } from \"../models/config\";\nimport { patch } from \"../utils/patch\";\nimport { recordedUrl } from \"../utils/platform\";\nimport type { Capture, CaptureContext } from \"./types\";\n\n/** Links that open elsewhere. The page shows no response, but the click isn't dead. */\nconst LEAVING_LINKS = 'a[target=\"_blank\"], a[download]';\n\n/**\n * Builds a short CSS selector for an element. Prefers the test ID, then the ID, then the\n * aria-label, then the class names.\n * @param element Target DOM element.\n * @returns The selector.\n */\nfunction describeElement(element: Element): string {\n const tag = element.tagName.toLowerCase();\n\n const testId = element.getAttribute(\"data-testid\") ?? element.getAttribute(\"data-test-id\");\n if (testId !== null) {\n return `[data-testid=\"${testId}\"]`;\n }\n if (element.id !== \"\") {\n return `#${element.id}`;\n }\n\n const label = element.getAttribute(\"aria-label\");\n if (label !== null) {\n return `${tag}[aria-label=\"${label.slice(0, ARIA_LABEL_MAX_CHARS)}\"]`;\n }\n\n // Read the class through getAttribute. On an SVG element, `className` is an\n // SVGAnimatedString, and slicing it throws.\n const classAttribute = element.getAttribute(\"class\")?.trim() ?? \"\";\n if (classAttribute === \"\") {\n return tag;\n }\n\n const classes = classAttribute.split(/\\s+/).slice(0, SELECTOR_MAX_CLASSES).join(\".\");\n return `${tag}.${classes}`;\n}\n\n/**\n * The two History members this module replaces. They are declared as properties, not\n * methods, so the original functions stay unbound. With a bound copy, uninstall would\n * restore a different function from the one it replaced, and every install cycle would\n * stack one more bind on top of the last.\n */\ninterface HistoryMethods {\n pushState: (this: History, ...args: never[]) => void;\n replaceState: (this: History, ...args: never[]) => void;\n}\n\n/**\n * Returns the History object, typed so that its methods stay unbound.\n * @returns The global history.\n */\nfunction historyMethods(): HistoryMethods {\n return history;\n}\n\n/** Captures user clicks and single-page navigations. */\nexport class InteractionCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"interactions\";\n\n /** Prevents duplicate listener registration. */\n private installed = false;\n\n /** Restore functions for the history wrappers. */\n private readonly restores: (() => void)[] = [];\n\n /** The URL before the latest navigation. */\n private lastUrl = \"\";\n\n /** The element of the current click burst, and when each of its clicks happened. */\n private burst: { target: Element | null; times: number[]; reported: boolean } = {\n target: null,\n times: [],\n reported: false,\n };\n\n /** Stops the dead click check that is running now. */\n private stopDeadCheck: (() => void) | undefined;\n\n /**\n * @param ctx Capture context: configuration, diagnostics, logger, breadcrumbs and tracing.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Registers click listeners and patches history navigation APIs. */\n install(): void {\n if (this.installed || typeof document === \"undefined\") {\n return;\n }\n this.installed = true;\n this.lastUrl = location.href;\n\n if (this.ctx.config.capture.interactions) {\n // In the capture phase we see the click before a page handler can stop propagation.\n addEventListener(\"click\", this.onClick, true);\n }\n if (this.ctx.config.capture.navigation) {\n this.installHistory();\n addEventListener(\"popstate\", this.onNavigate);\n addEventListener(\"hashchange\", this.onNavigate);\n }\n }\n\n /**\n * Removes the interaction listeners and restores every history method that still holds our\n * wrapper. A wrapper that another script wrapped again stays in place and records nothing.\n */\n uninstall(): void {\n if (!this.installed) {\n return;\n }\n this.installed = false;\n\n removeEventListener(\"click\", this.onClick, true);\n removeEventListener(\"popstate\", this.onNavigate);\n removeEventListener(\"hashchange\", this.onNavigate);\n\n for (const restore of this.restores.splice(0)) {\n restore();\n }\n\n this.stopDeadCheck?.();\n this.burst = { target: null, times: [], reported: false };\n }\n\n /** Rotates the trace context and records a click breadcrumb. */\n private readonly onClick = (event: Event): void => {\n if (this.ctx.isActive?.() === false) {\n return;\n }\n const target = event.target;\n if (!(target instanceof Element)) {\n return;\n }\n const settings = this.ctx.config.capture.interactions;\n const options = typeof settings === \"object\" ? settings : {};\n const ignore = options.ignoreSelector === undefined ? IGNORE_SELECTOR : options.ignoreSelector;\n if (ignore && target.closest(ignore)) {\n return;\n }\n // A missing or empty attribute gives \"\", and the message is then \"unknown-click\".\n const attribute = options.actionAttribute ?? ACTION_ATTRIBUTE_DEFAULT;\n const action = target.closest(`[${attribute}]`)?.getAttribute(attribute) ?? \"\";\n const message = (action || \"unknown-click\").slice(0, this.ctx.config.limits.maxBodyChars);\n const data: Record<string, unknown> = {};\n if (options.selector) {\n data.selector = describeElement(target);\n }\n if (options.text) {\n data.text = target.textContent.trim().slice(0, options.maxTextChars ?? CLICK_TEXT_MAX_CHARS);\n }\n this.ctx.tracing.rotate(\"interaction\");\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"click\",\n message,\n data: Object.keys(data).length > 0 ? data : undefined,\n });\n\n if (options.rageClicks) {\n this.countRage(target, message, options);\n }\n if (\n options.deadClicks &&\n target.closest(`${DEAD_CLICK_CONTROLS}, [${attribute}]`) &&\n !target.closest(LEAVING_LINKS)\n ) {\n this.watchDead(message, options);\n }\n };\n\n /**\n * Counts the clicks on one element and records `ui.rage_click` once per burst.\n * @param target Clicked element.\n * @param action The click's action name.\n * @param options Interaction options.\n */\n private countRage(target: Element, action: string, options: InteractionOptions): void {\n const now = Date.now();\n const windowMs = options.rageClickWindowMs ?? RAGE_CLICK_WINDOW_MS;\n const count = options.rageClickCount ?? RAGE_CLICK_COUNT;\n const times =\n this.burst.target === target ? this.burst.times.filter((t) => now - t < windowMs) : [];\n // A burst only ends once no click is left in the window, so clicks that keep sliding\n // through it don't fire a second event.\n const reported = times.length > 0 && this.burst.reported;\n times.push(now);\n const reached = times.length >= count;\n this.burst = { target, times, reported: reported || reached };\n\n if (reached && !reported) {\n this.ctx.logger.logEvent(\"ui.rage_click\", { \"click.action\": action, \"click.count\": count });\n }\n }\n\n /**\n * Watches the page after a click on a control. If there's no DOM change, navigation or scroll\n * within `deadClickMs`, it records `ui.dead_click`. Only one check runs at a time.\n * @param action The click's action name.\n * @param options Interaction options.\n */\n private watchDead(action: string, options: InteractionOptions): void {\n if (this.stopDeadCheck || typeof MutationObserver === \"undefined\") {\n return;\n }\n\n const href = location.href;\n let responded = false;\n const respond = (): void => {\n responded = true;\n };\n const observer = new MutationObserver(respond);\n observer.observe(document, {\n subtree: true,\n childList: true,\n attributes: true,\n characterData: true,\n });\n addEventListener(\"scroll\", respond, { capture: true, passive: true });\n\n const stop = (): void => {\n // timer is declared after stop, but stop can only run once that line has executed.\n clearTimeout(timer);\n observer.disconnect();\n removeEventListener(\"scroll\", respond, true);\n this.stopDeadCheck = undefined;\n };\n const timer = setTimeout(() => {\n stop();\n if (!responded && location.href === href && this.ctx.isActive?.() !== false) {\n this.ctx.logger.logEvent(\"ui.dead_click\", { \"click.action\": action });\n }\n }, options.deadClickMs ?? DEAD_CLICK_MS);\n this.stopDeadCheck = stop;\n }\n\n /** On a URL change, rotates the trace context and records a breadcrumb and an event. */\n private readonly onNavigate = (): void => {\n const from = this.lastUrl;\n const to = location.href;\n if (from === to) {\n return;\n }\n this.lastUrl = to;\n if (this.ctx.isActive?.() === false) {\n return;\n }\n\n // The comparison above uses the full URL, so a query-only change still counts as a\n // navigation. The record doesn't keep the query unless you set fullUrls.\n const full = this.ctx.config.capture.fullUrls;\n const { urlTransform } = this.ctx.config.capture;\n const fromUrl = recordedUrl(from, full, urlTransform, this.ctx.diagnostics);\n const toUrl = recordedUrl(to, full, urlTransform, this.ctx.diagnostics);\n\n this.ctx.tracing.rotate(\"navigation\");\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"navigation\",\n message: `${fromUrl} -> ${toUrl}`,\n });\n\n // The event carries only the previous URL, and the record builder adds the current one as\n // `page.url`. Putting the new URL in `url.full` would make a navigation look like an HTTP\n // request.\n this.ctx.logger.logEvent(\"NAVIGATION\", { \"page.url.previous\": fromUrl });\n };\n\n /** Patches History.pushState and replaceState to observe programmatic navigations. */\n private installHistory(): void {\n if (typeof history === \"undefined\") {\n return;\n }\n\n // Wrap the instance, not History.prototype. Reading from the prototype would skip a patch\n // that a router installed on the instance. patch keeps the originals unbound.\n const target = historyMethods();\n const onNavigate = this.onNavigate;\n // Uninstall clears the flag, so a wrapper that stays in place only calls the original.\n let active = true;\n\n const restorePushState = patch(\n target,\n \"pushState\",\n (original) =>\n function (this: History, ...args: never[]): void {\n original.apply(this, args);\n // Queue the handler. The browser only updates location.href after the call returns,\n // so a synchronous read would report the previous URL as the new one.\n if (active) {\n queueMicrotask(onNavigate);\n }\n },\n );\n\n const restoreReplaceState = patch(\n target,\n \"replaceState\",\n (original) =>\n function (this: History, ...args: never[]): void {\n original.apply(this, args);\n if (active) {\n queueMicrotask(onNavigate);\n }\n },\n );\n\n this.restores.push(() => {\n active = false;\n restorePushState();\n restoreReplaceState();\n });\n }\n}\n"],"mappings":"A,8JAsBA,IAAMO,EAAgB,kCAQtB,SAASC,EAAgB,EAA0B,CACjD,IAAMC,EAAMC,EAAQ,QAAQ,YAAY,EAElCC,EAASD,EAAQ,aAAa,aAAa,GAAKA,EAAQ,aAAa,cAAc,EACzF,GAAIC,IAAW,KACb,MAAO,iBAAiBA,EAAO,IAEjC,GAAID,EAAQ,KAAO,GACjB,MAAO,IAAIA,EAAQ,KAGrB,IAAME,EAAQF,EAAQ,aAAa,YAAY,EAC/C,GAAIE,IAAU,KACZ,MAAO,GAAGH,EAAI,eAAeG,EAAM,MAAM,EAAA,EAAuB,EAAE,IAKpE,IAAMC,EAAiBH,EAAQ,aAAa,OAAO,CAAC,EAAE,KAAK,GAAK,GAMhE,OALIG,IAAmB,GACdJ,EAIF,GAAGA,EAAI,GADEI,EAAe,MAAM,KAAK,CAAC,CAAC,MAAM,EAAA,CAAuB,CAAC,CAAC,KAAK,GAC/D,GACnB,CAiBA,SAASC,GAAiC,CACxC,OAAO,OACT,CAGA,IAAaC,EAAb,KAAmD,CA0BjD,YAAY,EAAsC,CAArBT,EAAA,EAAA,KAAA,MAAA,IAAA,EAAA,EAxB7BA,EAAA,EAAA,KAAA,OAAgB,cAAA,EAGhBA,EAAA,EAAA,KAAA,YAAoB,EAAA,EAGpBA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gBAA+B,CAC7B,GAAI,OAAO,QAAY,IACrB,OAKF,IAAM5B,EAASF,EAAe,EACxBgC,EAAa,KAAK,WAEpBC,EAAS,GAEPC,EAAmB9C,EAAAA,EACvBc,EACA,YACC,GACC,SAAyB,GAAGiC,EAAqB,CAC/CC,EAAS,MAAM,KAAMD,CAAI,EAGrBF,GACF,eAAeD,CAAU,CAE7B,CACJ,EAEMK,EAAsBjD,EAAAA,EAC1Bc,EACA,eACC,GACC,SAAyB,GAAGiC,EAAqB,CAC/CC,EAAS,MAAM,KAAMD,CAAI,EACrBF,GACF,eAAeD,CAAU,CAE7B,CACJ,EAEA,KAAK,SAAS,SAAW,CACvB,EAAS,GACTE,EAAiB,EACjBG,EAAoB,CACtB,CAAC,CACH,CACF,E"}
@@ -1,111 +0,0 @@
1
- import { vt as e } from "./constants-CUyd9cTZ.js";
2
- import { t } from "./patch-UdPz1ea8.js";
3
- import { i as n } from "./platform-BaaFIPCU.js";
4
- import { t as r } from "./defineProperty-s2S8BXUc.js";
5
- // src/capture/interactions.ts
6
- var i = "a[target=\"_blank\"], a[download]";
7
- function a(e) {
8
- let t = e.tagName.toLowerCase(), n = e.getAttribute("data-testid") ?? e.getAttribute("data-test-id");
9
- if (n !== null) return `[data-testid="${n}"]`;
10
- if (e.id !== "") return `#${e.id}`;
11
- let r = e.getAttribute("aria-label");
12
- if (r !== null) return `${t}[aria-label="${r.slice(0, 40)}"]`;
13
- let i = e.getAttribute("class")?.trim() ?? "";
14
- return i === "" ? t : `${t}.${i.split(/\s+/).slice(0, 2).join(".")}`;
15
- }
16
- function o() {
17
- return history;
18
- }
19
- var s = class {
20
- constructor(t) {
21
- r(this, "ctx", void 0), r(this, "name", "interactions"), r(this, "installed", !1), r(this, "restores", []), r(this, "lastUrl", ""), r(this, "burst", {
22
- target: null,
23
- times: [],
24
- reported: !1
25
- }), r(this, "stopDeadCheck", void 0), r(this, "onClick", (t) => {
26
- if (this.ctx.isActive?.() === !1) return;
27
- let n = t.target;
28
- if (!(n instanceof Element)) return;
29
- let r = this.ctx.config.capture.interactions, o = typeof r == "object" ? r : {}, s = o.ignoreSelector === void 0 ? e : o.ignoreSelector;
30
- if (s && n.closest(s)) return;
31
- let c = o.actionAttribute ?? "data-observability-action", l = ((n.closest(`[${c}]`)?.getAttribute(c) ?? "") || "unknown-click").slice(0, this.ctx.config.limits.maxBodyChars), u = {};
32
- o.selector && (u.selector = a(n)), o.text && (u.text = n.textContent.trim().slice(0, o.maxTextChars ?? 50)), this.ctx.tracing.rotate("interaction"), this.ctx.breadcrumbs.push({
33
- t: Date.now(),
34
- category: "click",
35
- message: l,
36
- data: Object.keys(u).length > 0 ? u : void 0
37
- }), o.rageClicks && this.countRage(n, l, o), o.deadClicks && n.closest(`a, button, summary, input[type="button"], input[type="submit"], input[type="reset"], [role="button"], [role="link"], [role="menuitem"], [role="tab"], [${c}]`) && !n.closest(i) && this.watchDead(l, o);
38
- }), r(this, "onNavigate", () => {
39
- let e = this.lastUrl, t = location.href;
40
- if (e === t || (this.lastUrl = t, this.ctx.isActive?.() === !1)) return;
41
- let r = this.ctx.config.capture.fullUrls, { urlTransform: i } = this.ctx.config.capture, a = n(e, r, i, this.ctx.diagnostics), o = n(t, r, i, this.ctx.diagnostics);
42
- this.ctx.tracing.rotate("navigation"), this.ctx.breadcrumbs.push({
43
- t: Date.now(),
44
- category: "navigation",
45
- message: `${a} -> ${o}`
46
- }), this.ctx.logger.logEvent("NAVIGATION", { "page.url.previous": a });
47
- }), this.ctx = t;
48
- }
49
- install() {
50
- this.installed || typeof document > "u" || (this.installed = !0, this.lastUrl = location.href, this.ctx.config.capture.interactions && addEventListener("click", this.onClick, !0), this.ctx.config.capture.navigation && (this.installHistory(), addEventListener("popstate", this.onNavigate), addEventListener("hashchange", this.onNavigate)));
51
- }
52
- uninstall() {
53
- if (this.installed) {
54
- this.installed = !1, removeEventListener("click", this.onClick, !0), removeEventListener("popstate", this.onNavigate), removeEventListener("hashchange", this.onNavigate);
55
- for (let e of this.restores.splice(0)) e();
56
- this.stopDeadCheck?.(), this.burst = {
57
- target: null,
58
- times: [],
59
- reported: !1
60
- };
61
- }
62
- }
63
- countRage(e, t, n) {
64
- let r = Date.now(), i = n.rageClickWindowMs ?? 1e3, a = n.rageClickCount ?? 3, o = this.burst.target === e ? this.burst.times.filter((e) => r - e < i) : [], s = o.length > 0 && this.burst.reported;
65
- o.push(r);
66
- let c = o.length >= a;
67
- this.burst = {
68
- target: e,
69
- times: o,
70
- reported: s || c
71
- }, c && !s && this.ctx.logger.logEvent("ui.rage_click", {
72
- "click.action": t,
73
- "click.count": a
74
- });
75
- }
76
- watchDead(e, t) {
77
- if (this.stopDeadCheck || typeof MutationObserver > "u") return;
78
- let n = location.href, r = !1, i = () => {
79
- r = !0;
80
- }, a = new MutationObserver(i);
81
- a.observe(document, {
82
- subtree: !0,
83
- childList: !0,
84
- attributes: !0,
85
- characterData: !0
86
- }), addEventListener("scroll", i, {
87
- capture: !0,
88
- passive: !0
89
- });
90
- let o = () => {
91
- clearTimeout(s), a.disconnect(), removeEventListener("scroll", i, !0), this.stopDeadCheck = void 0;
92
- }, s = setTimeout(() => {
93
- o(), !r && location.href === n && this.ctx.isActive?.() !== !1 && this.ctx.logger.logEvent("ui.dead_click", { "click.action": e });
94
- }, t.deadClickMs ?? 1e3);
95
- this.stopDeadCheck = o;
96
- }
97
- installHistory() {
98
- if (typeof history > "u") return;
99
- let e = o(), n = this.onNavigate, r = !0, i = t(e, "pushState", (e) => function(...t) {
100
- e.apply(this, t), r && queueMicrotask(n);
101
- }), a = t(e, "replaceState", (e) => function(...t) {
102
- e.apply(this, t), r && queueMicrotask(n);
103
- });
104
- this.restores.push(() => {
105
- r = !1, i(), a();
106
- });
107
- }
108
- };
109
- export { s as InteractionCapture };
110
-
111
- //# sourceMappingURL=interactions-DiFvCosX.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interactions-DiFvCosX.js","names":["IGNORE_SELECTOR","recordedUrl","_defineProperty","LEAVING_LINKS","describeElement","tag","element","testId","label","classAttribute","historyMethods","InteractionCapture","target","event","settings","options","ignore","attribute","message","data","from","to","full","fromUrl","urlTransform","toUrl","ctx","restore","now","windowMs","count","times","t","reported","reached","action","href","responded","respond","observer","stop","timer","onNavigate","active","restorePushState","patch","args","original","restoreReplaceState"],"sources":["../src/capture/interactions.ts"],"sourcesContent":["// src/capture/interactions.ts\n//\n// Captures clicks and in-page navigations as breadcrumbs and trace boundaries. Also detects\n// rage clicks and dead clicks.\n\nimport {\n ACTION_ATTRIBUTE_DEFAULT,\n ARIA_LABEL_MAX_CHARS,\n CLICK_TEXT_MAX_CHARS,\n DEAD_CLICK_CONTROLS,\n DEAD_CLICK_MS,\n IGNORE_SELECTOR,\n RAGE_CLICK_COUNT,\n RAGE_CLICK_WINDOW_MS,\n SELECTOR_MAX_CLASSES,\n} from \"../constants\";\nimport type { InteractionOptions } from \"../models/config\";\nimport { patch } from \"../utils/patch\";\nimport { recordedUrl } from \"../utils/platform\";\nimport type { Capture, CaptureContext } from \"./types\";\n\n/** Links that open elsewhere. The page shows no response, but the click isn't dead. */\nconst LEAVING_LINKS = 'a[target=\"_blank\"], a[download]';\n\n/**\n * Builds a short CSS selector for an element. Prefers the test ID, then the ID, then the\n * aria-label, then the class names.\n * @param element Target DOM element.\n * @returns The selector.\n */\nfunction describeElement(element: Element): string {\n const tag = element.tagName.toLowerCase();\n\n const testId = element.getAttribute(\"data-testid\") ?? element.getAttribute(\"data-test-id\");\n if (testId !== null) {\n return `[data-testid=\"${testId}\"]`;\n }\n if (element.id !== \"\") {\n return `#${element.id}`;\n }\n\n const label = element.getAttribute(\"aria-label\");\n if (label !== null) {\n return `${tag}[aria-label=\"${label.slice(0, ARIA_LABEL_MAX_CHARS)}\"]`;\n }\n\n // Read the class through getAttribute. On an SVG element, `className` is an\n // SVGAnimatedString, and slicing it throws.\n const classAttribute = element.getAttribute(\"class\")?.trim() ?? \"\";\n if (classAttribute === \"\") {\n return tag;\n }\n\n const classes = classAttribute.split(/\\s+/).slice(0, SELECTOR_MAX_CLASSES).join(\".\");\n return `${tag}.${classes}`;\n}\n\n/**\n * The two History members this module replaces. They are declared as properties, not\n * methods, so the original functions stay unbound. With a bound copy, uninstall would\n * restore a different function from the one it replaced, and every install cycle would\n * stack one more bind on top of the last.\n */\ninterface HistoryMethods {\n pushState: (this: History, ...args: never[]) => void;\n replaceState: (this: History, ...args: never[]) => void;\n}\n\n/**\n * Returns the History object, typed so that its methods stay unbound.\n * @returns The global history.\n */\nfunction historyMethods(): HistoryMethods {\n return history;\n}\n\n/** Captures user clicks and single-page navigations. */\nexport class InteractionCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"interactions\";\n\n /** Prevents duplicate listener registration. */\n private installed = false;\n\n /** Restore functions for the history wrappers. */\n private readonly restores: (() => void)[] = [];\n\n /** The URL before the latest navigation. */\n private lastUrl = \"\";\n\n /** The element of the current click burst, and when each of its clicks happened. */\n private burst: { target: Element | null; times: number[]; reported: boolean } = {\n target: null,\n times: [],\n reported: false,\n };\n\n /** Stops the dead click check that is running now. */\n private stopDeadCheck: (() => void) | undefined;\n\n /**\n * @param ctx Capture context: configuration, diagnostics, logger, breadcrumbs and tracing.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Registers click listeners and patches history navigation APIs. */\n install(): void {\n if (this.installed || typeof document === \"undefined\") {\n return;\n }\n this.installed = true;\n this.lastUrl = location.href;\n\n if (this.ctx.config.capture.interactions) {\n // In the capture phase we see the click before a page handler can stop propagation.\n addEventListener(\"click\", this.onClick, true);\n }\n if (this.ctx.config.capture.navigation) {\n this.installHistory();\n addEventListener(\"popstate\", this.onNavigate);\n addEventListener(\"hashchange\", this.onNavigate);\n }\n }\n\n /**\n * Removes the interaction listeners and restores every history method that still holds our\n * wrapper. A wrapper that another script wrapped again stays in place and records nothing.\n */\n uninstall(): void {\n if (!this.installed) {\n return;\n }\n this.installed = false;\n\n removeEventListener(\"click\", this.onClick, true);\n removeEventListener(\"popstate\", this.onNavigate);\n removeEventListener(\"hashchange\", this.onNavigate);\n\n for (const restore of this.restores.splice(0)) {\n restore();\n }\n\n this.stopDeadCheck?.();\n this.burst = { target: null, times: [], reported: false };\n }\n\n /** Rotates the trace context and records a click breadcrumb. */\n private readonly onClick = (event: Event): void => {\n if (this.ctx.isActive?.() === false) {\n return;\n }\n const target = event.target;\n if (!(target instanceof Element)) {\n return;\n }\n const settings = this.ctx.config.capture.interactions;\n const options = typeof settings === \"object\" ? settings : {};\n const ignore = options.ignoreSelector === undefined ? IGNORE_SELECTOR : options.ignoreSelector;\n if (ignore && target.closest(ignore)) {\n return;\n }\n // A missing or empty attribute gives \"\", and the message is then \"unknown-click\".\n const attribute = options.actionAttribute ?? ACTION_ATTRIBUTE_DEFAULT;\n const action = target.closest(`[${attribute}]`)?.getAttribute(attribute) ?? \"\";\n const message = (action || \"unknown-click\").slice(0, this.ctx.config.limits.maxBodyChars);\n const data: Record<string, unknown> = {};\n if (options.selector) {\n data.selector = describeElement(target);\n }\n if (options.text) {\n data.text = target.textContent.trim().slice(0, options.maxTextChars ?? CLICK_TEXT_MAX_CHARS);\n }\n this.ctx.tracing.rotate(\"interaction\");\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"click\",\n message,\n data: Object.keys(data).length > 0 ? data : undefined,\n });\n\n if (options.rageClicks) {\n this.countRage(target, message, options);\n }\n if (\n options.deadClicks &&\n target.closest(`${DEAD_CLICK_CONTROLS}, [${attribute}]`) &&\n !target.closest(LEAVING_LINKS)\n ) {\n this.watchDead(message, options);\n }\n };\n\n /**\n * Counts the clicks on one element and records `ui.rage_click` once per burst.\n * @param target Clicked element.\n * @param action The click's action name.\n * @param options Interaction options.\n */\n private countRage(target: Element, action: string, options: InteractionOptions): void {\n const now = Date.now();\n const windowMs = options.rageClickWindowMs ?? RAGE_CLICK_WINDOW_MS;\n const count = options.rageClickCount ?? RAGE_CLICK_COUNT;\n const times =\n this.burst.target === target ? this.burst.times.filter((t) => now - t < windowMs) : [];\n // A burst only ends once no click is left in the window, so clicks that keep sliding\n // through it don't fire a second event.\n const reported = times.length > 0 && this.burst.reported;\n times.push(now);\n const reached = times.length >= count;\n this.burst = { target, times, reported: reported || reached };\n\n if (reached && !reported) {\n this.ctx.logger.logEvent(\"ui.rage_click\", { \"click.action\": action, \"click.count\": count });\n }\n }\n\n /**\n * Watches the page after a click on a control. If there's no DOM change, navigation or scroll\n * within `deadClickMs`, it records `ui.dead_click`. Only one check runs at a time.\n * @param action The click's action name.\n * @param options Interaction options.\n */\n private watchDead(action: string, options: InteractionOptions): void {\n if (this.stopDeadCheck || typeof MutationObserver === \"undefined\") {\n return;\n }\n\n const href = location.href;\n let responded = false;\n const respond = (): void => {\n responded = true;\n };\n const observer = new MutationObserver(respond);\n observer.observe(document, {\n subtree: true,\n childList: true,\n attributes: true,\n characterData: true,\n });\n addEventListener(\"scroll\", respond, { capture: true, passive: true });\n\n const stop = (): void => {\n // timer is declared after stop, but stop can only run once that line has executed.\n clearTimeout(timer);\n observer.disconnect();\n removeEventListener(\"scroll\", respond, true);\n this.stopDeadCheck = undefined;\n };\n const timer = setTimeout(() => {\n stop();\n if (!responded && location.href === href && this.ctx.isActive?.() !== false) {\n this.ctx.logger.logEvent(\"ui.dead_click\", { \"click.action\": action });\n }\n }, options.deadClickMs ?? DEAD_CLICK_MS);\n this.stopDeadCheck = stop;\n }\n\n /** On a URL change, rotates the trace context and records a breadcrumb and an event. */\n private readonly onNavigate = (): void => {\n const from = this.lastUrl;\n const to = location.href;\n if (from === to) {\n return;\n }\n this.lastUrl = to;\n if (this.ctx.isActive?.() === false) {\n return;\n }\n\n // The comparison above uses the full URL, so a query-only change still counts as a\n // navigation. The record doesn't keep the query unless you set fullUrls.\n const full = this.ctx.config.capture.fullUrls;\n const { urlTransform } = this.ctx.config.capture;\n const fromUrl = recordedUrl(from, full, urlTransform, this.ctx.diagnostics);\n const toUrl = recordedUrl(to, full, urlTransform, this.ctx.diagnostics);\n\n this.ctx.tracing.rotate(\"navigation\");\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"navigation\",\n message: `${fromUrl} -> ${toUrl}`,\n });\n\n // The event carries only the previous URL, and the record builder adds the current one as\n // `page.url`. Putting the new URL in `url.full` would make a navigation look like an HTTP\n // request.\n this.ctx.logger.logEvent(\"NAVIGATION\", { \"page.url.previous\": fromUrl });\n };\n\n /** Patches History.pushState and replaceState to observe programmatic navigations. */\n private installHistory(): void {\n if (typeof history === \"undefined\") {\n return;\n }\n\n // Wrap the instance, not History.prototype. Reading from the prototype would skip a patch\n // that a router installed on the instance. patch keeps the originals unbound.\n const target = historyMethods();\n const onNavigate = this.onNavigate;\n // Uninstall clears the flag, so a wrapper that stays in place only calls the original.\n let active = true;\n\n const restorePushState = patch(\n target,\n \"pushState\",\n (original) =>\n function (this: History, ...args: never[]): void {\n original.apply(this, args);\n // Queue the handler. The browser only updates location.href after the call returns,\n // so a synchronous read would report the previous URL as the new one.\n if (active) {\n queueMicrotask(onNavigate);\n }\n },\n );\n\n const restoreReplaceState = patch(\n target,\n \"replaceState\",\n (original) =>\n function (this: History, ...args: never[]): void {\n original.apply(this, args);\n if (active) {\n queueMicrotask(onNavigate);\n }\n },\n );\n\n this.restores.push(() => {\n active = false;\n restorePushState();\n restoreReplaceState();\n });\n }\n}\n"],"mappings":";;;;;AAsBA,IAAMG,IAAgB;AAQtB,SAASC,EAAgB,GAA0B;CACjD,IAAMC,IAAMC,EAAQ,QAAQ,YAAY,GAElCC,IAASD,EAAQ,aAAa,aAAa,KAAKA,EAAQ,aAAa,cAAc;CACzF,IAAIC,MAAW,MACb,OAAO,iBAAiBA,EAAO;CAEjC,IAAID,EAAQ,OAAO,IACjB,OAAO,IAAIA,EAAQ;CAGrB,IAAME,IAAQF,EAAQ,aAAa,YAAY;CAC/C,IAAIE,MAAU,MACZ,OAAO,GAAGH,EAAI,eAAeG,EAAM,MAAM,GAAA,EAAuB,EAAE;CAKpE,IAAMC,IAAiBH,EAAQ,aAAa,OAAO,CAA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E,IAAME,UAAmB;GAKvB,AAHA,aAAaC,CAAK,GAClBF,EAAS,WAAW,GACpB,oBAAoB,UAAUD,GAAS,EAAI,GAC3C,KAAK,gBAAgB,KAAA;EACvB,GACMG,IAAQ,iBAAiB;GAE7B,AADAD,EAAK,GACD,CAACH,KAAa,SAAS,SAASD,KAAQ,KAAK,IAAI,WAAW,MAAM,MACpE,KAAK,IAAI,OAAO,SAAS,iBAAiB,EAAE,gBAAgBD,EAAO,CAAC;EAExE,GAAGpB,EAAQ,eAAA,GAA4B;EACvC,KAAK,gBAAgByB;CACvB;CAmCA,iBAA+B;EAC7B,IAAI,OAAO,UAAY,KACrB;EAKF,IAAM5B,IAASF,EAAe,GACxBgC,IAAa,KAAK,YAEpBC,IAAS,IAEPC,IAAmBC,EACvBjC,GACA,cACC,MACC,SAAyB,GAAGkC,GAAqB;GAI/C,AAHAC,EAAS,MAAM,MAAMD,CAAI,GAGrBH,KACF,eAAeD,CAAU;EAE7B,CACJ,GAEMM,IAAsBH,EAC1BjC,GACA,iBACC,MACC,SAAyB,GAAGkC,GAAqB;GAE/C,AADAC,EAAS,MAAM,MAAMD,CAAI,GACrBH,KACF,eAAeD,CAAU;EAE7B,CACJ;EAEA,KAAK,SAAS,WAAW;GAGvB,AAFA,IAAS,IACTE,EAAiB,GACjBI,EAAoB;EACtB,CAAC;CACH;AACF"}
@@ -1,2 +0,0 @@
1
- function e(e,t,n){let r=e[t],i=n(r);return e[t]=i,()=>e[t]===i&&(e[t]=r,!0)}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return e}});
2
- //# sourceMappingURL=patch-BX8KrPCT.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"patch-BX8KrPCT.cjs","names":["patch","original","target","key","wrapper","wrap"],"sources":["../src/utils/patch.ts"],"sourcesContent":["// src/utils/patch.ts\n//\n// Replaces a host function with a wrapper and returns a safe restore. A router or a second\n// SDK can wrap the same function after we do, and a blind restore would remove that wrapper\n// and break the host page.\n\n/**\n * Replaces `target[key]` with a wrapper around the current value.\n * @param target The object that holds the function, for example `console` or `globalThis`.\n * @param key The property to replace.\n * @param wrap Builds the wrapper from the original value.\n * @returns A restore function. It writes the original back and returns true only if the\n * property still holds the wrapper. Otherwise it changes nothing and returns false.\n */\nexport function patch<T extends object, K extends keyof T>(\n target: T,\n key: K,\n wrap: (original: T[K]) => T[K],\n): () => boolean {\n const original = target[key];\n const wrapper = wrap(original);\n target[key] = wrapper;\n\n return () => {\n // Another script wrapped the property after us. Keep its wrapper.\n if (target[key] !== wrapper) {\n return false;\n }\n\n target[key] = original;\n return true;\n };\n}\n"],"mappings":"AAcA,SAAgBA,EACd,EACA,EACA,EACe,CACf,IAAMC,EAAWC,EAAOC,GAClBC,EAAUC,EAAKJ,CAAQ,EAG7B,MAFA,GAAOE,GAAOC,MAIRF,EAAOC,KAASC,IAIpB,EAAOD,GAAOF,EACP,GAEX,C"}
@@ -1,8 +0,0 @@
1
- // src/utils/patch.ts
2
- function e(e, t, n) {
3
- let r = e[t], i = n(r);
4
- return e[t] = i, () => e[t] === i && (e[t] = r, !0);
5
- }
6
- export { e as t };
7
-
8
- //# sourceMappingURL=patch-UdPz1ea8.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"patch-UdPz1ea8.js","names":["patch","original","target","key","wrapper","wrap"],"sources":["../src/utils/patch.ts"],"sourcesContent":["// src/utils/patch.ts\n//\n// Replaces a host function with a wrapper and returns a safe restore. A router or a second\n// SDK can wrap the same function after we do, and a blind restore would remove that wrapper\n// and break the host page.\n\n/**\n * Replaces `target[key]` with a wrapper around the current value.\n * @param target The object that holds the function, for example `console` or `globalThis`.\n * @param key The property to replace.\n * @param wrap Builds the wrapper from the original value.\n * @returns A restore function. It writes the original back and returns true only if the\n * property still holds the wrapper. Otherwise it changes nothing and returns false.\n */\nexport function patch<T extends object, K extends keyof T>(\n target: T,\n key: K,\n wrap: (original: T[K]) => T[K],\n): () => boolean {\n const original = target[key];\n const wrapper = wrap(original);\n target[key] = wrapper;\n\n return () => {\n // Another script wrapped the property after us. Keep its wrapper.\n if (target[key] !== wrapper) {\n return false;\n }\n\n target[key] = original;\n return true;\n };\n}\n"],"mappings":";AAcA,SAAgBA,EACd,GACA,GACA,GACe;CACf,IAAMC,IAAWC,EAAOC,IAClBC,IAAUC,EAAKJ,CAAQ;CAG7B,OAFA,EAAOE,KAAOC,SAIRF,EAAOC,OAASC,MAIpB,EAAOD,KAAOF,GACP;AAEX"}
@@ -1,62 +0,0 @@
1
- import { Ht as e, It as t, St as n, i as r, qt as i } from "./constants-CUyd9cTZ.js";
2
- import { t as a } from "./openfin-Bxelt0yg.js";
3
- // src/utils/platform.ts
4
- var o = null;
5
- function s(e, t) {
6
- let n = e[t];
7
- return n !== void 0 && e instanceof n;
8
- }
9
- function c(e) {
10
- if (o) return o;
11
- let t = globalThis, n = t.navigator?.userAgent ?? "", r = "browser", c, d, f = !1, p = a()?.me;
12
- return s(t, "ServiceWorkerGlobalScope") ? (r = "service_worker", f = !0) : s(t, "SharedWorkerGlobalScope") ? (r = "shared_worker", f = !0) : s(t, "WorkerGlobalScope") ? (r = "web_worker", f = !0) : p === void 0 ? t.Capacitor !== void 0 || t.Ionic !== void 0 ? r = "ionic" : t.cordova !== void 0 || l(n) ? r = "mobile_webview" : typeof document > "u" && typeof process < "u" && (r = "node") : (r = i.test(n) ? "openfin" : "openfin_web", e.guard("openfin.unavailable", "The library could not read fin.me.identity.", () => {
13
- let e = p.identity;
14
- c = e?.uuid, d = e?.name;
15
- })), o = {
16
- platform: r,
17
- openfinUuid: c,
18
- openfinName: d,
19
- userAgent: n,
20
- isWorker: f,
21
- isTopLevelDocument: u(e)
22
- }, o;
23
- }
24
- function l(i) {
25
- return r.test(i) ? !0 : (n.test(i) || t.test(i) && e.test(i)) && i.includes("AppleWebKit") && !i.includes("Safari/");
26
- }
27
- function u(e) {
28
- if (typeof window > "u") return !1;
29
- try {
30
- return window.self === window.top;
31
- } catch {
32
- return e.count("platform.api_blocked"), !1;
33
- }
34
- }
35
- function d(e) {
36
- try {
37
- return typeof location < "u" ? location.href : "";
38
- } catch {
39
- return e.count("platform.api_blocked"), "";
40
- }
41
- }
42
- var f = /^([a-z][a-z\d+.-]*:\/\/)[^/?#]*@/i;
43
- function p(e, t, n, r) {
44
- if (n) try {
45
- let t = n(e);
46
- return typeof t == "string" ? t : "";
47
- } catch (e) {
48
- return r?.report("capture.record_failed", "capture.urlTransform threw an error. The library records an empty URL.", void 0, e), "";
49
- }
50
- let i = e.replace(f, "$1");
51
- return t ? i : m(i);
52
- }
53
- function m(e) {
54
- let t = e.search(/[?#]/);
55
- return t === -1 ? e : e.slice(0, t);
56
- }
57
- function h() {
58
- return globalThis.navigator?.onLine !== !1;
59
- }
60
- export { p as i, c as n, h as r, d as t };
61
-
62
- //# sourceMappingURL=platform-BaaFIPCU.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"platform-BaaFIPCU.js","names":["MOBILE_UA_PATTERN","MACINTOSH_UA_PATTERN","IOS_DEVICE_UA_PATTERN","ANDROID_WEBVIEW_UA_PATTERN","OPENFIN_UA_PATTERN","getFin","cached","isGlobalScope","scope","g","name","detectPlatform","ua","platform","openfinUuid","openfinName","isWorker","finMe","isWebView","diagnostics","identity","isTopLevel","currentUrl","USER_INFO_PATTERN","recordedUrl","transform","value","url","error","bare","fullUrls","stripUrlQuery","cut","isOnline"],"sources":["../src/utils/platform.ts"],"sourcesContent":["// src/utils/platform.ts\n//\n// Detects host platform capabilities, OpenFin container metadata, and worker execution\n// realms. The result is cached, because it doesn't change during the life of a realm. A\n// webview is also a browser, so test for a webview first.\n\nimport {\n ANDROID_WEBVIEW_UA_PATTERN,\n IOS_DEVICE_UA_PATTERN,\n MACINTOSH_UA_PATTERN,\n MOBILE_UA_PATTERN,\n OPENFIN_UA_PATTERN,\n SAFARI_UA_TOKEN,\n WEBKIT_UA_TOKEN,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { getFin } from \"./openfin\";\n\n/** Host runtime environment classification attached to resource attributes. */\nexport type PlatformType =\n | \"openfin\"\n | \"openfin_web\"\n | \"browser\"\n | \"mobile_webview\"\n | \"ionic\"\n | \"web_worker\"\n | \"shared_worker\"\n | \"service_worker\"\n | \"node\";\n\n/** Host environment and runtime container metadata resolved at startup. */\nexport interface PlatformMetadata {\n /** Detected platform runtime classification. */\n platform: PlatformType;\n /** OpenFin application UUID if running inside an OpenFin container. */\n openfinUuid?: string;\n /** OpenFin window or view identifier. */\n openfinName?: string;\n /** Raw navigator user agent string or empty string if unavailable. */\n userAgent: string;\n /** True if the code runs in a worker realm. */\n isWorker: boolean;\n /** True if this context is the top-level document rather than an iframe. */\n isTopLevelDocument: boolean;\n}\n\n/** Indexed globalThis type for probing runtime globals. */\ntype Global = typeof globalThis & Record<string, unknown>;\n\n/** Cached platform metadata instance. */\nlet cached: PlatformMetadata | null = null;\n\n/** Abstract constructor type for global scope prototype checks. */\ntype ScopeConstructor = abstract new (...args: never[]) => object;\n\n/**\n * Checks whether globalThis is an instance of the given global scope constructor.\n * @param g Global scope object.\n * @param name Name of the scope constructor to check.\n * @returns True if globalThis inherits from the named scope constructor.\n */\nfunction isGlobalScope(g: Global, name: string): boolean {\n const scope = g[name];\n if (scope === undefined) {\n return false;\n }\n return g instanceof (scope as ScopeConstructor);\n}\n\n/**\n * Detects and caches host platform metadata for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @returns Detected PlatformMetadata.\n */\nexport function detectPlatform(diagnostics: Diagnostics): PlatformMetadata {\n if (cached) {\n return cached;\n }\n const g = globalThis as Global;\n\n const ua = (g.navigator as Navigator | undefined)?.userAgent ?? \"\";\n let platform: PlatformType = \"browser\";\n let openfinUuid: string | undefined;\n let openfinName: string | undefined;\n let isWorker = false;\n\n const finMe = getFin()?.me;\n\n if (isGlobalScope(g, \"ServiceWorkerGlobalScope\")) {\n platform = \"service_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"SharedWorkerGlobalScope\")) {\n platform = \"shared_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"WorkerGlobalScope\")) {\n platform = \"web_worker\";\n isWorker = true;\n } else if (finMe !== undefined) {\n platform = OPENFIN_UA_PATTERN.test(ua) ? \"openfin\" : \"openfin_web\";\n diagnostics.guard(\"openfin.unavailable\", \"The library could not read fin.me.identity.\", () => {\n const identity = finMe.identity;\n openfinUuid = identity?.uuid;\n openfinName = identity?.name;\n });\n } else if (g.Capacitor !== undefined || g.Ionic !== undefined) {\n platform = \"ionic\";\n } else if (g.cordova !== undefined || isWebView(ua)) {\n platform = \"mobile_webview\";\n } else if (typeof document === \"undefined\" && typeof process !== \"undefined\") {\n platform = \"node\";\n }\n\n cached = {\n platform,\n openfinUuid,\n openfinName,\n userAgent: ua,\n isWorker,\n isTopLevelDocument: isTopLevel(diagnostics),\n };\n return cached;\n}\n\n/**\n * Checks whether a user agent string belongs to an embedded mobile webview.\n * @param ua User agent string.\n * @returns True if the user agent matches Android or iOS webview signatures.\n */\nfunction isWebView(ua: string): boolean {\n if (ANDROID_WEBVIEW_UA_PATTERN.test(ua)) {\n return true;\n }\n const ios =\n IOS_DEVICE_UA_PATTERN.test(ua) || (MACINTOSH_UA_PATTERN.test(ua) && MOBILE_UA_PATTERN.test(ua));\n return ios && ua.includes(WEBKIT_UA_TOKEN) && !ua.includes(SAFARI_UA_TOKEN);\n}\n\n/**\n * Checks whether the current window is the top-level browsing context.\n * @param diagnostics Diagnostics reporter. Counts a blocked read of window.top.\n * @returns True if top-level, false if framed or inaccessible due to cross-origin boundaries.\n */\nexport function isTopLevel(diagnostics: Diagnostics): boolean {\n if (typeof window === \"undefined\") {\n return false;\n }\n try {\n return window.self === window.top;\n } catch {\n // A cross-origin parent blocks the read, which proves a frame. Count it, but don't report it.\n diagnostics.count(\"platform.api_blocked\");\n return false;\n }\n}\n\n/**\n * Reads the current document URL without caching.\n * @param diagnostics Diagnostics reporter. Counts a blocked read of location.href.\n * @returns The current location.href, or an empty string.\n */\nexport function currentUrl(diagnostics: Diagnostics): string {\n try {\n return typeof location !== \"undefined\" ? location.href : \"\";\n } catch {\n // A sandbox can block the read. Count the fault, because a report per record would be noise.\n diagnostics.count(\"platform.api_blocked\");\n return \"\";\n }\n}\n\n/** Matches the user info of an absolute URL, for example \"user:pass@\". */\nconst USER_INFO_PATTERN = /^([a-z][a-z\\d+.-]*:\\/\\/)[^/?#]*@/i;\n\n/**\n * Returns the form of a URL that the library records. A transform's result is recorded as is,\n * or \"\" if it throws or returns no string. Without a transform, the user info is always\n * removed, because it is a credential, and without fullUrls the query and the fragment go too.\n * @param url Absolute or relative URL.\n * @param fullUrls Value of `capture.fullUrls`.\n * @param transform Value of `capture.urlTransform`. Replaces the default rule.\n * @param diagnostics Diagnostics reporter for a transform that throws.\n * @returns The URL to record.\n */\nexport function recordedUrl(\n url: string,\n fullUrls: boolean,\n transform?: ((url: string) => string | null) | null,\n diagnostics?: Diagnostics,\n): string {\n if (transform) {\n try {\n const value = transform(url);\n return typeof value === \"string\" ? value : \"\";\n } catch (error) {\n // Report the fault. Otherwise every recorded URL is empty with no visible cause.\n diagnostics?.report(\n \"capture.record_failed\",\n \"capture.urlTransform threw an error. The library records an empty URL.\",\n undefined,\n error,\n );\n return \"\";\n }\n }\n const bare = url.replace(USER_INFO_PATTERN, \"$1\");\n return fullUrls ? bare : stripUrlQuery(bare);\n}\n\n/**\n * Drops the query string and fragment from a URL. Cuts the string instead of parsing it,\n * because a relative request target has no base URL.\n * @param url Absolute or relative URL.\n * @returns The URL up to the first \"?\" or \"#\".\n */\nexport function stripUrlQuery(url: string): string {\n const cut = url.search(/[?#]/);\n\n return cut === -1 ? url : url.slice(0, cut);\n}\n\n/**\n * Checks whether the browser can reach the network. A host without navigator.onLine counts as\n * online.\n * @returns False only when navigator.onLine is false.\n */\nexport function isOnline(): boolean {\n return (globalThis as { navigator?: { onLine?: boolean } }).navigator?.onLine !== false;\n}\n\n/** Resets the cached platform metadata for testing. */\nexport function resetPlatformCache(): void {\n cached = null;\n}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O,OAAO,SAAS,OAAO;CAChC,QAAQ;EAGN,OADAF,EAAY,MAAM,sBAAsB,GACjC;CACT;AACF;AAOA,SAAgBG,EAAW,GAAkC;CAC3D,IAAI;EACF,OAAO,OAAO,WAAa,MAAc,SAAS,OAAO;CAC3D,QAAQ;EAGN,OADAH,EAAY,MAAM,sBAAsB,GACjC;CACT;AACF;AAGA,IAAMI,IAAoB;AAY1B,SAAgBC,EACd,GACA,GACA,GACA,GACQ;CACR,IAAIC,GACF,IAAI;EACF,IAAMC,IAAQD,EAAUE,CAAG;EAC3B,OAAO,OAAOD,KAAU,WAAWA,IAAQ;CAC7C,SAASE,GAAO;EAQd,OANAT,GAAa,OACX,yBACA,0EACA,KAAA,GACAS,CACF,GACO;CACT;CAEF,IAAMC,IAAOF,EAAI,QAAQJ,GAAmB,IAAI;CAChD,OAAOO,IAAWD,IAAOE,EAAcF,CAAI;AAC7C;AAQA,SAAgBE,EAAc,GAAqB;CACjD,IAAMC,IAAML,EAAI,OAAO,MAAM;CAE7B,OAAOK,MAAQ,KAAKL,IAAMA,EAAI,MAAM,GAAGK,CAAG;AAC5C;AAOA,SAAgBC,IAAoB;CAClC,OAAQ,WAAoD,WAAW,WAAW;AACpF"}
@@ -1,2 +0,0 @@
1
- const e=require("./constants-CqdJhTxH.cjs"),t=require("./openfin-DtH2f7zX.cjs");var n=null;function r(e,t){let n=e[t];return n!==void 0&&e instanceof n}function i(i){if(n)return n;let s=globalThis,c=s.navigator?.userAgent??``,l=`browser`,u,d,f=!1,p=t.t()?.me;return r(s,`ServiceWorkerGlobalScope`)?(l=`service_worker`,f=!0):r(s,`SharedWorkerGlobalScope`)?(l=`shared_worker`,f=!0):r(s,`WorkerGlobalScope`)?(l=`web_worker`,f=!0):p===void 0?s.Capacitor!==void 0||s.Ionic!==void 0?l=`ionic`:s.cordova!==void 0||a(c)?l=`mobile_webview`:typeof document>`u`&&typeof process<`u`&&(l=`node`):(l=e.qt.test(c)?`openfin`:`openfin_web`,i.guard(`openfin.unavailable`,`The library could not read fin.me.identity.`,()=>{let e=p.identity;u=e?.uuid,d=e?.name})),n={platform:l,openfinUuid:u,openfinName:d,userAgent:c,isWorker:f,isTopLevelDocument:o(i)},n}function a(t){return e.i.test(t)?!0:(e.St.test(t)||e.It.test(t)&&e.Ht.test(t))&&t.includes(`AppleWebKit`)&&!t.includes(`Safari/`)}function o(e){if(typeof window>`u`)return!1;try{return window.self===window.top}catch{return e.count(`platform.api_blocked`),!1}}function s(e){try{return typeof location<`u`?location.href:``}catch{return e.count(`platform.api_blocked`),``}}var c=/^([a-z][a-z\d+.-]*:\/\/)[^/?#]*@/i;function l(e,t,n,r){if(n)try{let t=n(e);return typeof t==`string`?t:``}catch(e){return r?.report(`capture.record_failed`,`capture.urlTransform threw an error. The library records an empty URL.`,void 0,e),``}let i=e.replace(c,`$1`);return t?i:u(i)}function u(e){let t=e.search(/[?#]/);return t===-1?e:e.slice(0,t)}function d(){return globalThis.navigator?.onLine!==!1}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
2
- //# sourceMappingURL=platform-CfA3-7sJ.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"platform-CfA3-7sJ.cjs","names":["getFin","OPENFIN_UA_PATTERN","ANDROID_WEBVIEW_UA_PATTERN","IOS_DEVICE_UA_PATTERN","MACINTOSH_UA_PATTERN","MOBILE_UA_PATTERN","require_constants","require_openfin","cached","isGlobalScope","scope","g","name","detectPlatform","ua","platform","openfinUuid","openfinName","isWorker","finMe","isWebView","diagnostics","identity","isTopLevel","currentUrl","USER_INFO_PATTERN","recordedUrl","transform","value","url","error","bare","fullUrls","stripUrlQuery","cut","isOnline"],"sources":["../src/utils/platform.ts"],"sourcesContent":["// src/utils/platform.ts\n//\n// Detects host platform capabilities, OpenFin container metadata, and worker execution\n// realms. The result is cached, because it doesn't change during the life of a realm. A\n// webview is also a browser, so test for a webview first.\n\nimport {\n ANDROID_WEBVIEW_UA_PATTERN,\n IOS_DEVICE_UA_PATTERN,\n MACINTOSH_UA_PATTERN,\n MOBILE_UA_PATTERN,\n OPENFIN_UA_PATTERN,\n SAFARI_UA_TOKEN,\n WEBKIT_UA_TOKEN,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { getFin } from \"./openfin\";\n\n/** Host runtime environment classification attached to resource attributes. */\nexport type PlatformType =\n | \"openfin\"\n | \"openfin_web\"\n | \"browser\"\n | \"mobile_webview\"\n | \"ionic\"\n | \"web_worker\"\n | \"shared_worker\"\n | \"service_worker\"\n | \"node\";\n\n/** Host environment and runtime container metadata resolved at startup. */\nexport interface PlatformMetadata {\n /** Detected platform runtime classification. */\n platform: PlatformType;\n /** OpenFin application UUID if running inside an OpenFin container. */\n openfinUuid?: string;\n /** OpenFin window or view identifier. */\n openfinName?: string;\n /** Raw navigator user agent string or empty string if unavailable. */\n userAgent: string;\n /** True if the code runs in a worker realm. */\n isWorker: boolean;\n /** True if this context is the top-level document rather than an iframe. */\n isTopLevelDocument: boolean;\n}\n\n/** Indexed globalThis type for probing runtime globals. */\ntype Global = typeof globalThis & Record<string, unknown>;\n\n/** Cached platform metadata instance. */\nlet cached: PlatformMetadata | null = null;\n\n/** Abstract constructor type for global scope prototype checks. */\ntype ScopeConstructor = abstract new (...args: never[]) => object;\n\n/**\n * Checks whether globalThis is an instance of the given global scope constructor.\n * @param g Global scope object.\n * @param name Name of the scope constructor to check.\n * @returns True if globalThis inherits from the named scope constructor.\n */\nfunction isGlobalScope(g: Global, name: string): boolean {\n const scope = g[name];\n if (scope === undefined) {\n return false;\n }\n return g instanceof (scope as ScopeConstructor);\n}\n\n/**\n * Detects and caches host platform metadata for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @returns Detected PlatformMetadata.\n */\nexport function detectPlatform(diagnostics: Diagnostics): PlatformMetadata {\n if (cached) {\n return cached;\n }\n const g = globalThis as Global;\n\n const ua = (g.navigator as Navigator | undefined)?.userAgent ?? \"\";\n let platform: PlatformType = \"browser\";\n let openfinUuid: string | undefined;\n let openfinName: string | undefined;\n let isWorker = false;\n\n const finMe = getFin()?.me;\n\n if (isGlobalScope(g, \"ServiceWorkerGlobalScope\")) {\n platform = \"service_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"SharedWorkerGlobalScope\")) {\n platform = \"shared_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"WorkerGlobalScope\")) {\n platform = \"web_worker\";\n isWorker = true;\n } else if (finMe !== undefined) {\n platform = OPENFIN_UA_PATTERN.test(ua) ? \"openfin\" : \"openfin_web\";\n diagnostics.guard(\"openfin.unavailable\", \"The library could not read fin.me.identity.\", () => {\n const identity = finMe.identity;\n openfinUuid = identity?.uuid;\n openfinName = identity?.name;\n });\n } else if (g.Capacitor !== undefined || g.Ionic !== undefined) {\n platform = \"ionic\";\n } else if (g.cordova !== undefined || isWebView(ua)) {\n platform = \"mobile_webview\";\n } else if (typeof document === \"undefined\" && typeof process !== \"undefined\") {\n platform = \"node\";\n }\n\n cached = {\n platform,\n openfinUuid,\n openfinName,\n userAgent: ua,\n isWorker,\n isTopLevelDocument: isTopLevel(diagnostics),\n };\n return cached;\n}\n\n/**\n * Checks whether a user agent string belongs to an embedded mobile webview.\n * @param ua User agent string.\n * @returns True if the user agent matches Android or iOS webview signatures.\n */\nfunction isWebView(ua: string): boolean {\n if (ANDROID_WEBVIEW_UA_PATTERN.test(ua)) {\n return true;\n }\n const ios =\n IOS_DEVICE_UA_PATTERN.test(ua) || (MACINTOSH_UA_PATTERN.test(ua) && MOBILE_UA_PATTERN.test(ua));\n return ios && ua.includes(WEBKIT_UA_TOKEN) && !ua.includes(SAFARI_UA_TOKEN);\n}\n\n/**\n * Checks whether the current window is the top-level browsing context.\n * @param diagnostics Diagnostics reporter. Counts a blocked read of window.top.\n * @returns True if top-level, false if framed or inaccessible due to cross-origin boundaries.\n */\nexport function isTopLevel(diagnostics: Diagnostics): boolean {\n if (typeof window === \"undefined\") {\n return false;\n }\n try {\n return window.self === window.top;\n } catch {\n // A cross-origin parent blocks the read, which proves a frame. Count it, but don't report it.\n diagnostics.count(\"platform.api_blocked\");\n return false;\n }\n}\n\n/**\n * Reads the current document URL without caching.\n * @param diagnostics Diagnostics reporter. Counts a blocked read of location.href.\n * @returns The current location.href, or an empty string.\n */\nexport function currentUrl(diagnostics: Diagnostics): string {\n try {\n return typeof location !== \"undefined\" ? location.href : \"\";\n } catch {\n // A sandbox can block the read. Count the fault, because a report per record would be noise.\n diagnostics.count(\"platform.api_blocked\");\n return \"\";\n }\n}\n\n/** Matches the user info of an absolute URL, for example \"user:pass@\". */\nconst USER_INFO_PATTERN = /^([a-z][a-z\\d+.-]*:\\/\\/)[^/?#]*@/i;\n\n/**\n * Returns the form of a URL that the library records. A transform's result is recorded as is,\n * or \"\" if it throws or returns no string. Without a transform, the user info is always\n * removed, because it is a credential, and without fullUrls the query and the fragment go too.\n * @param url Absolute or relative URL.\n * @param fullUrls Value of `capture.fullUrls`.\n * @param transform Value of `capture.urlTransform`. Replaces the default rule.\n * @param diagnostics Diagnostics reporter for a transform that throws.\n * @returns The URL to record.\n */\nexport function recordedUrl(\n url: string,\n fullUrls: boolean,\n transform?: ((url: string) => string | null) | null,\n diagnostics?: Diagnostics,\n): string {\n if (transform) {\n try {\n const value = transform(url);\n return typeof value === \"string\" ? value : \"\";\n } catch (error) {\n // Report the fault. Otherwise every recorded URL is empty with no visible cause.\n diagnostics?.report(\n \"capture.record_failed\",\n \"capture.urlTransform threw an error. The library records an empty URL.\",\n undefined,\n error,\n );\n return \"\";\n }\n }\n const bare = url.replace(USER_INFO_PATTERN, \"$1\");\n return fullUrls ? bare : stripUrlQuery(bare);\n}\n\n/**\n * Drops the query string and fragment from a URL. Cuts the string instead of parsing it,\n * because a relative request target has no base URL.\n * @param url Absolute or relative URL.\n * @returns The URL up to the first \"?\" or \"#\".\n */\nexport function stripUrlQuery(url: string): string {\n const cut = url.search(/[?#]/);\n\n return cut === -1 ? url : url.slice(0, cut);\n}\n\n/**\n * Checks whether the browser can reach the network. A host without navigator.onLine counts as\n * online.\n * @returns False only when navigator.onLine is false.\n */\nexport function isOnline(): boolean {\n return (globalThis as { navigator?: { onLine?: boolean } }).navigator?.onLine !== false;\n}\n\n/** Resets the cached platform metadata for testing. */\nexport function resetPlatformCache(): void {\n cached = null;\n}\n"],"mappings":"A,gFAkDA,IAAIQ,EAAkC,KAWtC,SAASC,EAAc,EAAW,EAAuB,CACvD,IAAMC,EAAQC,EAAEC,GAIhB,OAHIF,IAAU,IAAA,IAGPC,aAAcD,CACvB,CAOA,SAAgBG,EAAe,EAA4C,CACzE,GAAIL,EACF,OAAOA,EAET,IAAMG,EAAI,WAEJG,EAAMH,EAAE,WAAqC,WAAa,GAC5DI,EAAyB,UACzBC,EACAC,EACAC,EAAW,GAETC,EAAQnB,EAAAA,EAAO,CAAC,EAAE,GAkCxB,OAhCIS,EAAcE,EAAG,0BAA0B,GAC7C,EAAW,iBACX,EAAW,IACFF,EAAcE,EAAG,yBAAyB,GACnD,EAAW,gBACX,EAAW,IACFF,EAAcE,EAAG,mBAAmB,GAC7C,EAAW,aACX,EAAW,IACFQ,IAAU,IAAA,GAOVR,EAAE,YAAc,IAAA,IAAaA,EAAE,QAAU,IAAA,GAClD,EAAW,QACFA,EAAE,UAAY,IAAA,IAAaS,EAAUN,CAAE,EAChD,EAAW,iBACF,OAAO,SAAa,KAAe,OAAO,QAAY,MAC/D,EAAW,SAXX,EAAWb,EAAAA,GAAmB,KAAKa,CAAE,EAAI,UAAY,cACrDO,EAAY,MAAM,sBAAuB,kDAAqD,CAC5F,IAAMC,EAAWH,EAAM,SACvB,EAAcG,GAAU,KACxB,EAAcA,GAAU,IAC1B,CAAC,GASH,EAAS,CACP,WACA,cACA,cACA,UAAWR,EACX,WACA,mBAAoBS,EAAWF,CAAW,CAC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s"),i=require("./defineProperty-X1c4tIPD.cjs"),a=require("./compression-CvED_Jel.cjs"),o=require("./deadline-CUGbto-y.cjs"),s=require("./storm-C-zYSdDX.cjs"),c=require("./types-C7WNpnG1.cjs");var l=4,u=3,d=class{constructor(e){i.t(this,`maxBytes`,void 0),i.t(this,`parts`,[]),i.t(this,`sizes`,[]),i.t(this,`total`,0),i.t(this,`starved`,!1),i.t(this,`lost`,0),this.maxBytes=e}add(e,t,n){let r=n&&t===l;if(this.starved&&!r)return this.lost++,!1;(r||this.parts.length===0)&&(this.starved=!1,this.parts.push([]),this.sizes.push(0),this.parts.length>u&&this.dropOldest());let i=this.parts.length-1;this.parts[i].push(e),this.sizes[i]+=e.length,this.total+=e.length;let a=this.maxBytes();for(;this.total>a&&this.parts.length>0;)this.starved=this.parts.length===1,this.lost+=this.dropOldest();return this.starved}take(){let e={texts:this.parts.flat(),lost:this.lost};return this.parts=[],this.sizes=[],this.total=0,this.lost=0,e}clear(){this.parts=[],this.sizes=[],this.total=0,this.starved=!1,this.lost=0}dropOldest(){let[e]=this.parts.splice(0,1),[t]=this.sizes.splice(0,1);return this.total-=t,e.length}},f=[401,403],p=`Error`,m=429,h=500,g=class{constructor(e,t){i.t(this,`config`,void 0),i.t(this,`diagnostics`,void 0),i.t(this,`open`,[]),i.t(this,`openBytes`,0),i.t(this,`flushTimer`,void 0),i.t(this,`queue`,[]),i.t(this,`queueBytes`,0),i.t(this,`busy`,!1),i.t(this,`retryTimer`,void 0),i.t(this,`ids`,void 0),i.t(this,`sequence`,0),i.t(this,`generation`,0),i.t(this,`inFlight`,void 0),this.config=e,this.diagnostics=t}begin(e){e.replayId!==this.ids?.replayId&&(this.sequence=0),this.ids=e}push(e){let{maxSegmentEvents:t,maxSegmentBytes:n,flushIntervalMs:i}=this.config().replay;for(let r of e)this.open.length>0&&this.openBytes+r.length>n&&this.flush(),this.open.push(r),this.openBytes+=r.length,(this.open.length>=t||this.openBytes>=n)&&this.flush();this.open.length>0&&this.flushTimer===void 0&&(this.flushTimer=setTimeout(()=>{this.flushTimer=void 0,this.flush()},i),r.t(this.flushTimer))}flush(){clearTimeout(this.flushTimer),this.flushTimer=void 0;let{ids:e}=this;if(this.open.length===0||!e)return;let t=`[${this.open.join(`,`)}]`,n={"replay.id":e.replayId,"session.id":e.sessionId,"tab.id":e.tabId,"service.name":this.config().serviceName,sequence:this.sequence++,events:this.open.length,bytes:t.length,payload:t};this.open=[],this.openBytes=0,this.queue.push(n),this.queueBytes+=n.bytes;let r=0;for(;this.queueBytes>this.config().replay.maxQueueBytes&&this.queue.length>1;){let[e]=this.queue.splice(0,1);this.queueBytes-=e.bytes,r++}r>0&&this.diagnostics.report(`transport.dropped_permanent`,`The replay queue is above replay.maxQueueBytes. The library dropped ${String(r)} segments.`),this.drain()}discardOpen(){clearTimeout(this.flushTimer),this.flushTimer=void 0,this.open=[],this.openBytes=0}stop(){this.generation++,this.inFlight?.abort(),this.inFlight=void 0,clearTimeout(this.retryTimer),this.retryTimer=void 0,this.discardOpen(),this.queue=[],this.queueBytes=0,this.busy=!1}drain(){if(this.busy||this.queue.length===0)return;let[e]=this.queue.splice(0,1);this.queueBytes-=e.bytes,this.busy=!0,this.deliver(e,1,this.generation)}async deliver(e,t,n){let i=await this.send(e,t,n);if(n!==this.generation)return;let{replay:a,delivery:o}=this.config();if(i===`retry`&&t<a.maxAttempts){let i=Math.min(o.retryBaseDelayMs*2**(t-1),o.retryMaxDelayMs);this.retryTimer=setTimeout(()=>{this.retryTimer=void 0,this.deliver(e,t+1,n)},i),r.t(this.retryTimer)}else i!==`sent`&&this.diagnostics.report(`transport.dropped_permanent`,`The library dropped the replay segment ${String(e.sequence)} after ${String(t)} attempts.`,{"replay.id":e[`replay.id`],sequence:e.sequence}),this.busy=!1,this.drain()}async send(t,i,s){let c=this.config(),{onSegment:l,endpoint:u,headers:d}=c.replay,g=c.delivery.requestTimeoutMs;if(l)try{return await o.n(Promise.resolve(l(t)),g),`sent`}catch(e){return this.diagnostics.report(`capture.record_failed`,`The replay.onSegment function threw an error, or it did not end in ${String(g)} ms.`,void 0,e),`drop`}if(u===null)return`drop`;let _=new AbortController,v=setTimeout(()=>{_.abort()},g);r.t(v);try{let r=typeof d==`function`?await o.n(Promise.resolve(d()),g):d,l=new Headers(r??{});l.set(e.ft,e.z),l.set(e.ut,`${t[`replay.id`]}-${String(t.sequence)}`),l.set(e.lt,String(i-1));let{payload:p,events:v,...y}=t,b=`${JSON.stringify(y).slice(0,-1)},"events":${p}}`,x=b;if(c.compression===`gzip`&&b.length>=1024){let t=await a.t(b);t&&(x=t,l.set(e.dt,e.tt))}if(s!==this.generation)return`drop`;this.inFlight=_;let S=await n.r(()=>fetch(u,{method:`POST`,headers:l,body:x,credentials:c.credentials,cache:`no-store`,signal:_.signal}));return S.ok?`sent`:(this.diagnostics.report(`transport.http_error`,`The replay endpoint returned ${String(S.status)}.`),f.includes(S.status)||S.status===m||S.status>=h?`retry`:`drop`)}catch(e){return this.diagnostics.report(`transport.http_error`,`The replay request failed with ${e instanceof Error?e.name:p}.`),`retry`}finally{clearTimeout(v),this.inFlight=void 0}}},_=`session.id`,v=`tab.id`,y=`*`,b=[`sampling`,`slimDOMOptions`,`ignoreClass`,`ignoreSelector`,`ignoreCSSAttributes`,`userTriggeredOnInput`,`recordAfter`,`inlineStylesheet`,`dataURLOptions`],x={input:!0,textarea:!0,select:!0},S=`********`,C=4,w=3,T=0,E=3,D=class{constructor(e){i.t(this,`ctx`,void 0),i.t(this,`name`,`replay`),i.t(this,`buffer`,void 0),i.t(this,`uploader`,void 0),i.t(this,`window`,{start:0,count:0}),i.t(this,`record`,void 0),i.t(this,`stopRecorder`,void 0),i.t(this,`replayId`,``),i.t(this,`installed`,!1),i.t(this,`starting`,!1),i.t(this,`generation`,0),i.t(this,`live`,!1),i.t(this,`starvedReported`,!1),i.t(this,`liveTimer`,void 0),i.t(this,`maskText`,(e,t)=>{let{maskText:n,maskSelectors:r}=this.ctx.config.replay,i=r.length>0&&t?.closest(r.join(`,`));return n&&!i&&t?.closest(`[data-observability-unmask]`)?e:e.replace(/\S/g,y)}),i.t(this,`maskInput`,e=>e===``?``:S),i.t(this,`transformRequest`,e=>{try{let{capture:t}=this.ctx.config,r=e.name;return n.t()||c.t(r,t.ignoreUrls)?void 0:t.fullUrls?e:{...e,name:r.split(/[?#]/)[0]}}catch(e){this.onFault(e);return}}),i.t(this,`emit`,(e,t)=>{try{this.scrub(e);let n=JSON.stringify(e);if(this.live){this.uploader.push([n]);return}this.buffer.add(n,e.type,t===!0)&&!this.starvedReported&&(this.starvedReported=!0,this.ctx.diagnostics.report(`capture.rate_limited`,`One part of the replay is above replay.maxBufferBytes. The buffer is empty until the next full snapshot. The replay of an error in that time starts at the error, with no events from before it. Raise the limit, or block a large element with replay.blockSelectors.`))}catch(e){this.onFault(e)}}),i.t(this,`onFault`,e=>{this.ctx.diagnostics.report(`capture.record_failed`,`The replay recorder had an error.`,void 0,e)}),i.t(this,`onError`,e=>{let{diagnostics:t,config:n}=this.ctx;t.guard(`capture.record_failed`,`The replay upload did not start.`,()=>{if(!this.record)return;let{afterErrorMs:i,uploadsPerWindow:a}=n.replay;if(this.live||!s.t(this.window,a,t,`replay uploads`,n.replay.uploadWindowMs))return;let{texts:o,lost:c}=this.buffer.take();c>0&&t.report(`capture.rate_limited`,`The replay buffer was above replay.maxBufferBytes. The library dropped ${String(c)} events.`);let{takeFullSnapshot:l}=this.record;if(o.length!==0||l){if(this.uploader.begin({replayId:this.replayId,sessionId:String(e.resource[_]),tabId:String(e.resource[v])}),this.live=!0,o.length===0){if(!t.guard(`capture.record_failed`,`The replay recorder did not take a full snapshot. The library sends no replay for this error.`,()=>(this.record?.takeFullSnapshot?.(!0),!0))){this.live=!1,this.uploader.discardOpen(),this.window.count=Math.max(0,this.window.count-1);return}}else this.uploader.push(o);this.liveTimer=setTimeout(this.endLive,i),r.t(this.liveTimer)}})}),i.t(this,`endLive`,()=>{this.liveTimer=void 0,this.live=!1,this.uploader.flush(),this.ctx.diagnostics.guard(`capture.record_failed`,`The replay recorder did not take a full snapshot.`,()=>{this.record?.takeFullSnapshot?.(!0)})}),this.ctx=e,this.buffer=new d(()=>this.ctx.config.replay.maxBufferBytes),this.uploader=new g(()=>this.ctx.config,this.ctx.diagnostics)}install(){this.installed||(this.installed=!0,this.ctx.onError?.(this.onError),(this.ctx.replayConsent?.()??!this.ctx.config.replay.requireConsent)&&this.start())}uninstall(){this.installed=!1,this.ctx.onError?.(void 0),this.stop()}async start(){let{diagnostics:n}=this.ctx,{loader:r,endpoint:i,onSegment:a,plugins:o}=this.ctx.config.replay;if(!this.installed||this.record||this.starting)return;if(typeof document>`u`){this.reportOnce(`This context has no document. The session replay is off.`);return}if(!r||i===null&&!a){n.report(`config.invalid`,`The session replay needs replay.loader, and replay.endpoint or replay.onSegment. The session replay is off.`);return}let s=this.selectors();if(!s)return;let{generation:c}=this;this.starting=!0;let l=await n.guardAsync(`capture.install_failed`,`The library could not load the replay recorder.`,r),u={transformRequest:this.transformRequest},d=await Promise.all(o.map(e=>n.guardAsync(`capture.install_failed`,`The library could not load a replay plugin.`,()=>Promise.resolve(e(u)))));if(c!==this.generation||(this.starting=!1,!l))return;let{record:f}=l;if(typeof f!=`function`){n.report(`capture.install_failed`,`The replay loader gave no record function. The session replay is off.`);return}let p=this.ctx.config.replay;n.guard(`capture.install_failed`,`The replay recorder did not start.`,()=>{let r={},i=[];for(let[e,t]of Object.entries(p.recordOptions))b.includes(e)?r[e]=t:i.push(e);i.length>0&&n.report(`config.invalid`,`The library ignores these keys of replay.recordOptions: ${i.join(`, `)}. It sets the mask, block, canvas, plugin and event options itself.`),this.starvedReported=!1;let a=f({...r,emit:this.emit,checkoutEveryNms:p.bufferMs/2,maskAllInputs:!1,maskInputOptions:p.maskInputs?x:{password:!0},maskInputFn:this.maskInput,maskTextSelector:s.mask,maskTextFn:this.maskText,blockSelector:s.block,recordCanvas:p.recordCanvas,errorHandler:this.onFault,plugins:d.filter(e=>e!==void 0)});typeof a==`function`?(this.stopRecorder=a,this.record=f,this.replayId=t.i(this.ctx.diagnostics),this.ctx.setContext?.(e.dn,this.replayId)):n.report(`capture.install_failed`,`The replay recorder did not start.`)})}reset(){let e=this.record!==void 0||this.starting;this.stop(),e&&this.start()}stop(){let{stopRecorder:t}=this;this.generation++,this.starting=!1,this.record=void 0,this.stopRecorder=void 0,this.live=!1,clearTimeout(this.liveTimer),this.liveTimer=void 0,this.buffer.clear(),this.uploader.stop(),t&&(this.ctx.setContext?.(e.dn,void 0),this.ctx.diagnostics.guard(`capture.install_failed`,`The replay recorder did not stop.`,t))}selectors(){let{maskText:t,maskSelectors:n,blockSelectors:r}=this.ctx.config.replay;for(let e of[...n,...r])try{document.createDocumentFragment().querySelector(e)}catch(t){this.ctx.diagnostics.report(`config.invalid`,`The replay selector ${e} is not a valid CSS selector. The session replay is off.`,void 0,t);return}return{mask:t?`*`:(e=>e.length>0?e.join(`,`):void 0)(n),block:[e.vt,...r].join(`,`)}}scrub(e){let{data:t}=e;if(t){if(e.type===C)typeof t.href==`string`&&!this.ctx.config.capture.fullUrls&&(t.href=t.href.split(/[?#]/)[0]);else if(e.type===w&&t.source===T){for(let e of t.texts??[])e.value=this.shadowText(e.value,e.id);for(let e of t.adds??[])e.node?.type===E&&(e.node={...e.node,textContent:this.shadowText(e.node.textContent,e.node.id)})}}}shadowText(e,t){let n=this.record?.mirror?.getNode(t);if(typeof e!=`string`||!n||n.parentElement)return e;let{maskText:r,maskSelectors:i}=this.ctx.config.replay,a=n.parentNode?.host??null;return r?this.maskText(e,a):i.length>0&&a?.closest(i.join(`,`))?e.replace(/\S/g,y):e}reportOnce(e){let{once:t}=this.ctx;t.replay||(t.replay=!0,this.ctx.diagnostics.report(`capture.install_failed`,e))}};exports.ReplayCapture=D;
2
- //# sourceMappingURL=replay-B3gFXIZd.cjs.map