@tracelog/lib 0.11.2 → 0.11.3

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 (539) hide show
  1. package/dist/public-api.cjs +4387 -0
  2. package/dist/public-api.cjs.map +1 -0
  3. package/dist/public-api.d.mts +913 -0
  4. package/dist/public-api.d.ts +913 -0
  5. package/dist/public-api.js +4348 -0
  6. package/dist/public-api.js.map +1 -0
  7. package/package.json +18 -18
  8. package/dist/browser/tracelog.esm.js +0 -2983
  9. package/dist/browser/tracelog.esm.js.map +0 -1
  10. package/dist/browser/tracelog.js +0 -8
  11. package/dist/browser/tracelog.js.map +0 -1
  12. package/dist/cjs/api.d.ts +0 -19
  13. package/dist/cjs/api.d.ts.map +0 -1
  14. package/dist/cjs/api.js +0 -183
  15. package/dist/cjs/api.js.map +0 -1
  16. package/dist/cjs/app.constants.d.ts +0 -80
  17. package/dist/cjs/app.constants.d.ts.map +0 -1
  18. package/dist/cjs/app.constants.js +0 -94
  19. package/dist/cjs/app.constants.js.map +0 -1
  20. package/dist/cjs/app.d.ts +0 -43
  21. package/dist/cjs/app.d.ts.map +0 -1
  22. package/dist/cjs/app.js +0 -165
  23. package/dist/cjs/app.js.map +0 -1
  24. package/dist/cjs/constants/config.constants.d.ts +0 -109
  25. package/dist/cjs/constants/config.constants.d.ts.map +0 -1
  26. package/dist/cjs/constants/config.constants.js +0 -216
  27. package/dist/cjs/constants/config.constants.js.map +0 -1
  28. package/dist/cjs/constants/error.constants.d.ts +0 -56
  29. package/dist/cjs/constants/error.constants.d.ts.map +0 -1
  30. package/dist/cjs/constants/error.constants.js +0 -89
  31. package/dist/cjs/constants/error.constants.js.map +0 -1
  32. package/dist/cjs/constants/index.d.ts +0 -5
  33. package/dist/cjs/constants/index.d.ts.map +0 -1
  34. package/dist/cjs/constants/index.js +0 -21
  35. package/dist/cjs/constants/index.js.map +0 -1
  36. package/dist/cjs/constants/performance.constants.d.ts +0 -29
  37. package/dist/cjs/constants/performance.constants.d.ts.map +0 -1
  38. package/dist/cjs/constants/performance.constants.js +0 -44
  39. package/dist/cjs/constants/performance.constants.js.map +0 -1
  40. package/dist/cjs/constants/storage.constants.d.ts +0 -11
  41. package/dist/cjs/constants/storage.constants.d.ts.map +0 -1
  42. package/dist/cjs/constants/storage.constants.js +0 -23
  43. package/dist/cjs/constants/storage.constants.js.map +0 -1
  44. package/dist/cjs/handlers/click.handler.d.ts +0 -36
  45. package/dist/cjs/handlers/click.handler.d.ts.map +0 -1
  46. package/dist/cjs/handlers/click.handler.js +0 -263
  47. package/dist/cjs/handlers/click.handler.js.map +0 -1
  48. package/dist/cjs/handlers/error.handler.d.ts +0 -28
  49. package/dist/cjs/handlers/error.handler.d.ts.map +0 -1
  50. package/dist/cjs/handlers/error.handler.js +0 -168
  51. package/dist/cjs/handlers/error.handler.js.map +0 -1
  52. package/dist/cjs/handlers/page-view.handler.d.ts +0 -17
  53. package/dist/cjs/handlers/page-view.handler.d.ts.map +0 -1
  54. package/dist/cjs/handlers/page-view.handler.js +0 -100
  55. package/dist/cjs/handlers/page-view.handler.js.map +0 -1
  56. package/dist/cjs/handlers/performance.handler.d.ts +0 -23
  57. package/dist/cjs/handlers/performance.handler.d.ts.map +0 -1
  58. package/dist/cjs/handlers/performance.handler.js +0 -274
  59. package/dist/cjs/handlers/performance.handler.js.map +0 -1
  60. package/dist/cjs/handlers/scroll.handler.d.ts +0 -40
  61. package/dist/cjs/handlers/scroll.handler.d.ts.map +0 -1
  62. package/dist/cjs/handlers/scroll.handler.js +0 -327
  63. package/dist/cjs/handlers/scroll.handler.js.map +0 -1
  64. package/dist/cjs/handlers/session.handler.d.ts +0 -16
  65. package/dist/cjs/handlers/session.handler.d.ts.map +0 -1
  66. package/dist/cjs/handlers/session.handler.js +0 -74
  67. package/dist/cjs/handlers/session.handler.js.map +0 -1
  68. package/dist/cjs/handlers/viewport.handler.d.ts +0 -44
  69. package/dist/cjs/handlers/viewport.handler.d.ts.map +0 -1
  70. package/dist/cjs/handlers/viewport.handler.js +0 -286
  71. package/dist/cjs/handlers/viewport.handler.js.map +0 -1
  72. package/dist/cjs/integrations/google-analytics.integration.d.ts +0 -18
  73. package/dist/cjs/integrations/google-analytics.integration.d.ts.map +0 -1
  74. package/dist/cjs/integrations/google-analytics.integration.js +0 -90
  75. package/dist/cjs/integrations/google-analytics.integration.js.map +0 -1
  76. package/dist/cjs/listeners/activity-listener-manager.d.ts +0 -9
  77. package/dist/cjs/listeners/activity-listener-manager.d.ts.map +0 -1
  78. package/dist/cjs/listeners/activity-listener-manager.js +0 -33
  79. package/dist/cjs/listeners/activity-listener-manager.js.map +0 -1
  80. package/dist/cjs/listeners/index.d.ts +0 -7
  81. package/dist/cjs/listeners/index.d.ts.map +0 -1
  82. package/dist/cjs/listeners/index.js +0 -15
  83. package/dist/cjs/listeners/index.js.map +0 -1
  84. package/dist/cjs/listeners/input-listener-managers.d.ts +0 -25
  85. package/dist/cjs/listeners/input-listener-managers.d.ts.map +0 -1
  86. package/dist/cjs/listeners/input-listener-managers.js +0 -50
  87. package/dist/cjs/listeners/input-listener-managers.js.map +0 -1
  88. package/dist/cjs/listeners/listeners.types.d.ts +0 -5
  89. package/dist/cjs/listeners/listeners.types.d.ts.map +0 -1
  90. package/dist/cjs/listeners/listeners.types.js +0 -3
  91. package/dist/cjs/listeners/listeners.types.js.map +0 -1
  92. package/dist/cjs/listeners/touch-listener-manager.d.ts +0 -9
  93. package/dist/cjs/listeners/touch-listener-manager.d.ts.map +0 -1
  94. package/dist/cjs/listeners/touch-listener-manager.js +0 -35
  95. package/dist/cjs/listeners/touch-listener-manager.js.map +0 -1
  96. package/dist/cjs/listeners/unload-listener-manager.d.ts +0 -9
  97. package/dist/cjs/listeners/unload-listener-manager.d.ts.map +0 -1
  98. package/dist/cjs/listeners/unload-listener-manager.js +0 -31
  99. package/dist/cjs/listeners/unload-listener-manager.js.map +0 -1
  100. package/dist/cjs/listeners/visibility-listener-manager.d.ts +0 -10
  101. package/dist/cjs/listeners/visibility-listener-manager.d.ts.map +0 -1
  102. package/dist/cjs/listeners/visibility-listener-manager.js +0 -48
  103. package/dist/cjs/listeners/visibility-listener-manager.js.map +0 -1
  104. package/dist/cjs/managers/event.manager.d.ts +0 -62
  105. package/dist/cjs/managers/event.manager.d.ts.map +0 -1
  106. package/dist/cjs/managers/event.manager.js +0 -508
  107. package/dist/cjs/managers/event.manager.js.map +0 -1
  108. package/dist/cjs/managers/sender.manager.d.ts +0 -32
  109. package/dist/cjs/managers/sender.manager.d.ts.map +0 -1
  110. package/dist/cjs/managers/sender.manager.js +0 -271
  111. package/dist/cjs/managers/sender.manager.js.map +0 -1
  112. package/dist/cjs/managers/session.manager.d.ts +0 -40
  113. package/dist/cjs/managers/session.manager.d.ts.map +0 -1
  114. package/dist/cjs/managers/session.manager.js +0 -282
  115. package/dist/cjs/managers/session.manager.js.map +0 -1
  116. package/dist/cjs/managers/state.manager.d.ts +0 -9
  117. package/dist/cjs/managers/state.manager.d.ts.map +0 -1
  118. package/dist/cjs/managers/state.manager.js +0 -27
  119. package/dist/cjs/managers/state.manager.js.map +0 -1
  120. package/dist/cjs/managers/storage.manager.d.ts +0 -60
  121. package/dist/cjs/managers/storage.manager.d.ts.map +0 -1
  122. package/dist/cjs/managers/storage.manager.js +0 -277
  123. package/dist/cjs/managers/storage.manager.js.map +0 -1
  124. package/dist/cjs/managers/user.manager.d.ts +0 -17
  125. package/dist/cjs/managers/user.manager.d.ts.map +0 -1
  126. package/dist/cjs/managers/user.manager.js +0 -31
  127. package/dist/cjs/managers/user.manager.js.map +0 -1
  128. package/dist/cjs/public-api.d.ts +0 -11
  129. package/dist/cjs/public-api.d.ts.map +0 -1
  130. package/dist/cjs/public-api.js +0 -32
  131. package/dist/cjs/public-api.js.map +0 -1
  132. package/dist/cjs/test-bridge.d.ts +0 -47
  133. package/dist/cjs/test-bridge.d.ts.map +0 -1
  134. package/dist/cjs/test-bridge.js +0 -165
  135. package/dist/cjs/test-bridge.js.map +0 -1
  136. package/dist/cjs/types/common.types.d.ts +0 -6
  137. package/dist/cjs/types/common.types.d.ts.map +0 -1
  138. package/dist/cjs/types/common.types.js +0 -3
  139. package/dist/cjs/types/common.types.js.map +0 -1
  140. package/dist/cjs/types/config.types.d.ts +0 -49
  141. package/dist/cjs/types/config.types.d.ts.map +0 -1
  142. package/dist/cjs/types/config.types.js +0 -9
  143. package/dist/cjs/types/config.types.js.map +0 -1
  144. package/dist/cjs/types/device.types.d.ts +0 -7
  145. package/dist/cjs/types/device.types.d.ts.map +0 -1
  146. package/dist/cjs/types/device.types.js +0 -11
  147. package/dist/cjs/types/device.types.js.map +0 -1
  148. package/dist/cjs/types/emitter.types.d.ts +0 -12
  149. package/dist/cjs/types/emitter.types.d.ts.map +0 -1
  150. package/dist/cjs/types/emitter.types.js +0 -9
  151. package/dist/cjs/types/emitter.types.js.map +0 -1
  152. package/dist/cjs/types/error.types.d.ts +0 -12
  153. package/dist/cjs/types/error.types.d.ts.map +0 -1
  154. package/dist/cjs/types/error.types.js +0 -23
  155. package/dist/cjs/types/error.types.js.map +0 -1
  156. package/dist/cjs/types/event.types.d.ts +0 -235
  157. package/dist/cjs/types/event.types.d.ts.map +0 -1
  158. package/dist/cjs/types/event.types.js +0 -48
  159. package/dist/cjs/types/event.types.js.map +0 -1
  160. package/dist/cjs/types/index.d.ts +0 -17
  161. package/dist/cjs/types/index.d.ts.map +0 -1
  162. package/dist/cjs/types/index.js +0 -33
  163. package/dist/cjs/types/index.js.map +0 -1
  164. package/dist/cjs/types/log.types.d.ts +0 -5
  165. package/dist/cjs/types/log.types.d.ts.map +0 -1
  166. package/dist/cjs/types/log.types.js +0 -3
  167. package/dist/cjs/types/log.types.js.map +0 -1
  168. package/dist/cjs/types/mode.types.d.ts +0 -7
  169. package/dist/cjs/types/mode.types.d.ts.map +0 -1
  170. package/dist/cjs/types/mode.types.js +0 -11
  171. package/dist/cjs/types/mode.types.js.map +0 -1
  172. package/dist/cjs/types/queue.types.d.ts +0 -19
  173. package/dist/cjs/types/queue.types.d.ts.map +0 -1
  174. package/dist/cjs/types/queue.types.js +0 -3
  175. package/dist/cjs/types/queue.types.js.map +0 -1
  176. package/dist/cjs/types/scroll.types.d.ts +0 -16
  177. package/dist/cjs/types/scroll.types.d.ts.map +0 -1
  178. package/dist/cjs/types/scroll.types.js +0 -12
  179. package/dist/cjs/types/scroll.types.js.map +0 -1
  180. package/dist/cjs/types/session.types.d.ts +0 -2
  181. package/dist/cjs/types/session.types.d.ts.map +0 -1
  182. package/dist/cjs/types/session.types.js +0 -3
  183. package/dist/cjs/types/session.types.js.map +0 -1
  184. package/dist/cjs/types/state.types.d.ts +0 -16
  185. package/dist/cjs/types/state.types.d.ts.map +0 -1
  186. package/dist/cjs/types/state.types.js +0 -3
  187. package/dist/cjs/types/state.types.js.map +0 -1
  188. package/dist/cjs/types/test-bridge.types.d.ts +0 -40
  189. package/dist/cjs/types/test-bridge.types.d.ts.map +0 -1
  190. package/dist/cjs/types/test-bridge.types.js +0 -3
  191. package/dist/cjs/types/test-bridge.types.js.map +0 -1
  192. package/dist/cjs/types/validation-error.types.d.ts +0 -44
  193. package/dist/cjs/types/validation-error.types.d.ts.map +0 -1
  194. package/dist/cjs/types/validation-error.types.js +0 -70
  195. package/dist/cjs/types/validation-error.types.js.map +0 -1
  196. package/dist/cjs/types/viewport.types.d.ts +0 -55
  197. package/dist/cjs/types/viewport.types.d.ts.map +0 -1
  198. package/dist/cjs/types/viewport.types.js +0 -3
  199. package/dist/cjs/types/viewport.types.js.map +0 -1
  200. package/dist/cjs/types/window.types.d.ts +0 -16
  201. package/dist/cjs/types/window.types.d.ts.map +0 -1
  202. package/dist/cjs/types/window.types.js +0 -3
  203. package/dist/cjs/types/window.types.js.map +0 -1
  204. package/dist/cjs/utils/browser/device-detector.utils.d.ts +0 -7
  205. package/dist/cjs/utils/browser/device-detector.utils.d.ts.map +0 -1
  206. package/dist/cjs/utils/browser/device-detector.utils.js +0 -50
  207. package/dist/cjs/utils/browser/device-detector.utils.js.map +0 -1
  208. package/dist/cjs/utils/browser/index.d.ts +0 -4
  209. package/dist/cjs/utils/browser/index.d.ts.map +0 -1
  210. package/dist/cjs/utils/browser/index.js +0 -20
  211. package/dist/cjs/utils/browser/index.js.map +0 -1
  212. package/dist/cjs/utils/browser/qa-mode.utils.d.ts +0 -14
  213. package/dist/cjs/utils/browser/qa-mode.utils.d.ts.map +0 -1
  214. package/dist/cjs/utils/browser/qa-mode.utils.js +0 -44
  215. package/dist/cjs/utils/browser/qa-mode.utils.js.map +0 -1
  216. package/dist/cjs/utils/browser/utm-params.utils.d.ts +0 -7
  217. package/dist/cjs/utils/browser/utm-params.utils.d.ts.map +0 -1
  218. package/dist/cjs/utils/browser/utm-params.utils.js +0 -23
  219. package/dist/cjs/utils/browser/utm-params.utils.js.map +0 -1
  220. package/dist/cjs/utils/data/index.d.ts +0 -2
  221. package/dist/cjs/utils/data/index.d.ts.map +0 -1
  222. package/dist/cjs/utils/data/index.js +0 -18
  223. package/dist/cjs/utils/data/index.js.map +0 -1
  224. package/dist/cjs/utils/data/uuid.utils.d.ts +0 -19
  225. package/dist/cjs/utils/data/uuid.utils.d.ts.map +0 -1
  226. package/dist/cjs/utils/data/uuid.utils.js +0 -57
  227. package/dist/cjs/utils/data/uuid.utils.js.map +0 -1
  228. package/dist/cjs/utils/emitter.utils.d.ts +0 -9
  229. package/dist/cjs/utils/emitter.utils.d.ts.map +0 -1
  230. package/dist/cjs/utils/emitter.utils.js +0 -36
  231. package/dist/cjs/utils/emitter.utils.js.map +0 -1
  232. package/dist/cjs/utils/index.d.ts +0 -8
  233. package/dist/cjs/utils/index.d.ts.map +0 -1
  234. package/dist/cjs/utils/index.js +0 -24
  235. package/dist/cjs/utils/index.js.map +0 -1
  236. package/dist/cjs/utils/logging.utils.d.ts +0 -22
  237. package/dist/cjs/utils/logging.utils.d.ts.map +0 -1
  238. package/dist/cjs/utils/logging.utils.js +0 -87
  239. package/dist/cjs/utils/logging.utils.js.map +0 -1
  240. package/dist/cjs/utils/network/index.d.ts +0 -2
  241. package/dist/cjs/utils/network/index.d.ts.map +0 -1
  242. package/dist/cjs/utils/network/index.js +0 -18
  243. package/dist/cjs/utils/network/index.js.map +0 -1
  244. package/dist/cjs/utils/network/url.utils.d.ts +0 -16
  245. package/dist/cjs/utils/network/url.utils.d.ts.map +0 -1
  246. package/dist/cjs/utils/network/url.utils.js +0 -92
  247. package/dist/cjs/utils/network/url.utils.js.map +0 -1
  248. package/dist/cjs/utils/security/index.d.ts +0 -2
  249. package/dist/cjs/utils/security/index.d.ts.map +0 -1
  250. package/dist/cjs/utils/security/index.js +0 -18
  251. package/dist/cjs/utils/security/index.js.map +0 -1
  252. package/dist/cjs/utils/security/sanitize.utils.d.ts +0 -14
  253. package/dist/cjs/utils/security/sanitize.utils.d.ts.map +0 -1
  254. package/dist/cjs/utils/security/sanitize.utils.js +0 -123
  255. package/dist/cjs/utils/security/sanitize.utils.js.map +0 -1
  256. package/dist/cjs/utils/validations/config-validations.utils.d.ts +0 -19
  257. package/dist/cjs/utils/validations/config-validations.utils.d.ts.map +0 -1
  258. package/dist/cjs/utils/validations/config-validations.utils.js +0 -236
  259. package/dist/cjs/utils/validations/config-validations.utils.js.map +0 -1
  260. package/dist/cjs/utils/validations/event-validations.utils.d.ts +0 -13
  261. package/dist/cjs/utils/validations/event-validations.utils.d.ts.map +0 -1
  262. package/dist/cjs/utils/validations/event-validations.utils.js +0 -37
  263. package/dist/cjs/utils/validations/event-validations.utils.js.map +0 -1
  264. package/dist/cjs/utils/validations/index.d.ts +0 -5
  265. package/dist/cjs/utils/validations/index.d.ts.map +0 -1
  266. package/dist/cjs/utils/validations/index.js +0 -21
  267. package/dist/cjs/utils/validations/index.js.map +0 -1
  268. package/dist/cjs/utils/validations/metadata-validations.utils.d.ts +0 -23
  269. package/dist/cjs/utils/validations/metadata-validations.utils.d.ts.map +0 -1
  270. package/dist/cjs/utils/validations/metadata-validations.utils.js +0 -153
  271. package/dist/cjs/utils/validations/metadata-validations.utils.js.map +0 -1
  272. package/dist/cjs/utils/validations/type-guards.utils.d.ts +0 -9
  273. package/dist/cjs/utils/validations/type-guards.utils.d.ts.map +0 -1
  274. package/dist/cjs/utils/validations/type-guards.utils.js +0 -90
  275. package/dist/cjs/utils/validations/type-guards.utils.js.map +0 -1
  276. package/dist/esm/api.d.ts +0 -19
  277. package/dist/esm/api.d.ts.map +0 -1
  278. package/dist/esm/api.js +0 -173
  279. package/dist/esm/api.js.map +0 -1
  280. package/dist/esm/app.constants.d.ts +0 -80
  281. package/dist/esm/app.constants.d.ts.map +0 -1
  282. package/dist/esm/app.constants.js +0 -82
  283. package/dist/esm/app.constants.js.map +0 -1
  284. package/dist/esm/app.d.ts +0 -43
  285. package/dist/esm/app.d.ts.map +0 -1
  286. package/dist/esm/app.js +0 -161
  287. package/dist/esm/app.js.map +0 -1
  288. package/dist/esm/constants/config.constants.d.ts +0 -109
  289. package/dist/esm/constants/config.constants.d.ts.map +0 -1
  290. package/dist/esm/constants/config.constants.js +0 -212
  291. package/dist/esm/constants/config.constants.js.map +0 -1
  292. package/dist/esm/constants/error.constants.d.ts +0 -56
  293. package/dist/esm/constants/error.constants.d.ts.map +0 -1
  294. package/dist/esm/constants/error.constants.js +0 -86
  295. package/dist/esm/constants/error.constants.js.map +0 -1
  296. package/dist/esm/constants/index.d.ts +0 -5
  297. package/dist/esm/constants/index.d.ts.map +0 -1
  298. package/dist/esm/constants/index.js +0 -5
  299. package/dist/esm/constants/index.js.map +0 -1
  300. package/dist/esm/constants/performance.constants.d.ts +0 -29
  301. package/dist/esm/constants/performance.constants.d.ts.map +0 -1
  302. package/dist/esm/constants/performance.constants.js +0 -41
  303. package/dist/esm/constants/performance.constants.js.map +0 -1
  304. package/dist/esm/constants/storage.constants.d.ts +0 -11
  305. package/dist/esm/constants/storage.constants.d.ts.map +0 -1
  306. package/dist/esm/constants/storage.constants.js +0 -13
  307. package/dist/esm/constants/storage.constants.js.map +0 -1
  308. package/dist/esm/handlers/click.handler.d.ts +0 -36
  309. package/dist/esm/handlers/click.handler.d.ts.map +0 -1
  310. package/dist/esm/handlers/click.handler.js +0 -259
  311. package/dist/esm/handlers/click.handler.js.map +0 -1
  312. package/dist/esm/handlers/error.handler.d.ts +0 -28
  313. package/dist/esm/handlers/error.handler.d.ts.map +0 -1
  314. package/dist/esm/handlers/error.handler.js +0 -164
  315. package/dist/esm/handlers/error.handler.js.map +0 -1
  316. package/dist/esm/handlers/page-view.handler.d.ts +0 -17
  317. package/dist/esm/handlers/page-view.handler.d.ts.map +0 -1
  318. package/dist/esm/handlers/page-view.handler.js +0 -96
  319. package/dist/esm/handlers/page-view.handler.js.map +0 -1
  320. package/dist/esm/handlers/performance.handler.d.ts +0 -23
  321. package/dist/esm/handlers/performance.handler.d.ts.map +0 -1
  322. package/dist/esm/handlers/performance.handler.js +0 -237
  323. package/dist/esm/handlers/performance.handler.js.map +0 -1
  324. package/dist/esm/handlers/scroll.handler.d.ts +0 -40
  325. package/dist/esm/handlers/scroll.handler.d.ts.map +0 -1
  326. package/dist/esm/handlers/scroll.handler.js +0 -323
  327. package/dist/esm/handlers/scroll.handler.js.map +0 -1
  328. package/dist/esm/handlers/session.handler.d.ts +0 -16
  329. package/dist/esm/handlers/session.handler.d.ts.map +0 -1
  330. package/dist/esm/handlers/session.handler.js +0 -70
  331. package/dist/esm/handlers/session.handler.js.map +0 -1
  332. package/dist/esm/handlers/viewport.handler.d.ts +0 -44
  333. package/dist/esm/handlers/viewport.handler.d.ts.map +0 -1
  334. package/dist/esm/handlers/viewport.handler.js +0 -282
  335. package/dist/esm/handlers/viewport.handler.js.map +0 -1
  336. package/dist/esm/integrations/google-analytics.integration.d.ts +0 -18
  337. package/dist/esm/integrations/google-analytics.integration.d.ts.map +0 -1
  338. package/dist/esm/integrations/google-analytics.integration.js +0 -86
  339. package/dist/esm/integrations/google-analytics.integration.js.map +0 -1
  340. package/dist/esm/listeners/activity-listener-manager.d.ts +0 -9
  341. package/dist/esm/listeners/activity-listener-manager.d.ts.map +0 -1
  342. package/dist/esm/listeners/activity-listener-manager.js +0 -29
  343. package/dist/esm/listeners/activity-listener-manager.js.map +0 -1
  344. package/dist/esm/listeners/index.d.ts +0 -7
  345. package/dist/esm/listeners/index.d.ts.map +0 -1
  346. package/dist/esm/listeners/index.js +0 -6
  347. package/dist/esm/listeners/index.js.map +0 -1
  348. package/dist/esm/listeners/input-listener-managers.d.ts +0 -25
  349. package/dist/esm/listeners/input-listener-managers.d.ts.map +0 -1
  350. package/dist/esm/listeners/input-listener-managers.js +0 -45
  351. package/dist/esm/listeners/input-listener-managers.js.map +0 -1
  352. package/dist/esm/listeners/listeners.types.d.ts +0 -5
  353. package/dist/esm/listeners/listeners.types.d.ts.map +0 -1
  354. package/dist/esm/listeners/listeners.types.js +0 -2
  355. package/dist/esm/listeners/listeners.types.js.map +0 -1
  356. package/dist/esm/listeners/touch-listener-manager.d.ts +0 -9
  357. package/dist/esm/listeners/touch-listener-manager.d.ts.map +0 -1
  358. package/dist/esm/listeners/touch-listener-manager.js +0 -31
  359. package/dist/esm/listeners/touch-listener-manager.js.map +0 -1
  360. package/dist/esm/listeners/unload-listener-manager.d.ts +0 -9
  361. package/dist/esm/listeners/unload-listener-manager.d.ts.map +0 -1
  362. package/dist/esm/listeners/unload-listener-manager.js +0 -27
  363. package/dist/esm/listeners/unload-listener-manager.js.map +0 -1
  364. package/dist/esm/listeners/visibility-listener-manager.d.ts +0 -10
  365. package/dist/esm/listeners/visibility-listener-manager.d.ts.map +0 -1
  366. package/dist/esm/listeners/visibility-listener-manager.js +0 -44
  367. package/dist/esm/listeners/visibility-listener-manager.js.map +0 -1
  368. package/dist/esm/managers/event.manager.d.ts +0 -62
  369. package/dist/esm/managers/event.manager.d.ts.map +0 -1
  370. package/dist/esm/managers/event.manager.js +0 -504
  371. package/dist/esm/managers/event.manager.js.map +0 -1
  372. package/dist/esm/managers/sender.manager.d.ts +0 -32
  373. package/dist/esm/managers/sender.manager.d.ts.map +0 -1
  374. package/dist/esm/managers/sender.manager.js +0 -267
  375. package/dist/esm/managers/sender.manager.js.map +0 -1
  376. package/dist/esm/managers/session.manager.d.ts +0 -40
  377. package/dist/esm/managers/session.manager.d.ts.map +0 -1
  378. package/dist/esm/managers/session.manager.js +0 -278
  379. package/dist/esm/managers/session.manager.js.map +0 -1
  380. package/dist/esm/managers/state.manager.d.ts +0 -9
  381. package/dist/esm/managers/state.manager.d.ts.map +0 -1
  382. package/dist/esm/managers/state.manager.js +0 -21
  383. package/dist/esm/managers/state.manager.js.map +0 -1
  384. package/dist/esm/managers/storage.manager.d.ts +0 -60
  385. package/dist/esm/managers/storage.manager.d.ts.map +0 -1
  386. package/dist/esm/managers/storage.manager.js +0 -273
  387. package/dist/esm/managers/storage.manager.js.map +0 -1
  388. package/dist/esm/managers/user.manager.d.ts +0 -17
  389. package/dist/esm/managers/user.manager.d.ts.map +0 -1
  390. package/dist/esm/managers/user.manager.js +0 -27
  391. package/dist/esm/managers/user.manager.js.map +0 -1
  392. package/dist/esm/public-api.d.ts +0 -11
  393. package/dist/esm/public-api.d.ts.map +0 -1
  394. package/dist/esm/public-api.js +0 -15
  395. package/dist/esm/public-api.js.map +0 -1
  396. package/dist/esm/test-bridge.d.ts +0 -47
  397. package/dist/esm/test-bridge.d.ts.map +0 -1
  398. package/dist/esm/test-bridge.js +0 -161
  399. package/dist/esm/test-bridge.js.map +0 -1
  400. package/dist/esm/types/common.types.d.ts +0 -6
  401. package/dist/esm/types/common.types.d.ts.map +0 -1
  402. package/dist/esm/types/common.types.js +0 -2
  403. package/dist/esm/types/common.types.js.map +0 -1
  404. package/dist/esm/types/config.types.d.ts +0 -49
  405. package/dist/esm/types/config.types.d.ts.map +0 -1
  406. package/dist/esm/types/config.types.js +0 -6
  407. package/dist/esm/types/config.types.js.map +0 -1
  408. package/dist/esm/types/device.types.d.ts +0 -7
  409. package/dist/esm/types/device.types.d.ts.map +0 -1
  410. package/dist/esm/types/device.types.js +0 -8
  411. package/dist/esm/types/device.types.js.map +0 -1
  412. package/dist/esm/types/emitter.types.d.ts +0 -12
  413. package/dist/esm/types/emitter.types.d.ts.map +0 -1
  414. package/dist/esm/types/emitter.types.js +0 -6
  415. package/dist/esm/types/emitter.types.js.map +0 -1
  416. package/dist/esm/types/error.types.d.ts +0 -12
  417. package/dist/esm/types/error.types.d.ts.map +0 -1
  418. package/dist/esm/types/error.types.js +0 -19
  419. package/dist/esm/types/error.types.js.map +0 -1
  420. package/dist/esm/types/event.types.d.ts +0 -235
  421. package/dist/esm/types/event.types.d.ts.map +0 -1
  422. package/dist/esm/types/event.types.js +0 -45
  423. package/dist/esm/types/event.types.js.map +0 -1
  424. package/dist/esm/types/index.d.ts +0 -17
  425. package/dist/esm/types/index.d.ts.map +0 -1
  426. package/dist/esm/types/index.js +0 -17
  427. package/dist/esm/types/index.js.map +0 -1
  428. package/dist/esm/types/log.types.d.ts +0 -5
  429. package/dist/esm/types/log.types.d.ts.map +0 -1
  430. package/dist/esm/types/log.types.js +0 -2
  431. package/dist/esm/types/log.types.js.map +0 -1
  432. package/dist/esm/types/mode.types.d.ts +0 -7
  433. package/dist/esm/types/mode.types.d.ts.map +0 -1
  434. package/dist/esm/types/mode.types.js +0 -8
  435. package/dist/esm/types/mode.types.js.map +0 -1
  436. package/dist/esm/types/queue.types.d.ts +0 -19
  437. package/dist/esm/types/queue.types.d.ts.map +0 -1
  438. package/dist/esm/types/queue.types.js +0 -2
  439. package/dist/esm/types/queue.types.js.map +0 -1
  440. package/dist/esm/types/scroll.types.d.ts +0 -16
  441. package/dist/esm/types/scroll.types.d.ts.map +0 -1
  442. package/dist/esm/types/scroll.types.js +0 -8
  443. package/dist/esm/types/scroll.types.js.map +0 -1
  444. package/dist/esm/types/session.types.d.ts +0 -2
  445. package/dist/esm/types/session.types.d.ts.map +0 -1
  446. package/dist/esm/types/session.types.js +0 -2
  447. package/dist/esm/types/session.types.js.map +0 -1
  448. package/dist/esm/types/state.types.d.ts +0 -16
  449. package/dist/esm/types/state.types.d.ts.map +0 -1
  450. package/dist/esm/types/state.types.js +0 -2
  451. package/dist/esm/types/state.types.js.map +0 -1
  452. package/dist/esm/types/test-bridge.types.d.ts +0 -40
  453. package/dist/esm/types/test-bridge.types.d.ts.map +0 -1
  454. package/dist/esm/types/test-bridge.types.js +0 -2
  455. package/dist/esm/types/test-bridge.types.js.map +0 -1
  456. package/dist/esm/types/validation-error.types.d.ts +0 -44
  457. package/dist/esm/types/validation-error.types.d.ts.map +0 -1
  458. package/dist/esm/types/validation-error.types.js +0 -61
  459. package/dist/esm/types/validation-error.types.js.map +0 -1
  460. package/dist/esm/types/viewport.types.d.ts +0 -55
  461. package/dist/esm/types/viewport.types.d.ts.map +0 -1
  462. package/dist/esm/types/viewport.types.js +0 -2
  463. package/dist/esm/types/viewport.types.js.map +0 -1
  464. package/dist/esm/types/window.types.d.ts +0 -16
  465. package/dist/esm/types/window.types.d.ts.map +0 -1
  466. package/dist/esm/types/window.types.js +0 -2
  467. package/dist/esm/types/window.types.js.map +0 -1
  468. package/dist/esm/utils/browser/device-detector.utils.d.ts +0 -7
  469. package/dist/esm/utils/browser/device-detector.utils.d.ts.map +0 -1
  470. package/dist/esm/utils/browser/device-detector.utils.js +0 -46
  471. package/dist/esm/utils/browser/device-detector.utils.js.map +0 -1
  472. package/dist/esm/utils/browser/index.d.ts +0 -4
  473. package/dist/esm/utils/browser/index.d.ts.map +0 -1
  474. package/dist/esm/utils/browser/index.js +0 -4
  475. package/dist/esm/utils/browser/index.js.map +0 -1
  476. package/dist/esm/utils/browser/qa-mode.utils.d.ts +0 -14
  477. package/dist/esm/utils/browser/qa-mode.utils.d.ts.map +0 -1
  478. package/dist/esm/utils/browser/qa-mode.utils.js +0 -40
  479. package/dist/esm/utils/browser/qa-mode.utils.js.map +0 -1
  480. package/dist/esm/utils/browser/utm-params.utils.d.ts +0 -7
  481. package/dist/esm/utils/browser/utm-params.utils.d.ts.map +0 -1
  482. package/dist/esm/utils/browser/utm-params.utils.js +0 -19
  483. package/dist/esm/utils/browser/utm-params.utils.js.map +0 -1
  484. package/dist/esm/utils/data/index.d.ts +0 -2
  485. package/dist/esm/utils/data/index.d.ts.map +0 -1
  486. package/dist/esm/utils/data/index.js +0 -2
  487. package/dist/esm/utils/data/index.js.map +0 -1
  488. package/dist/esm/utils/data/uuid.utils.d.ts +0 -19
  489. package/dist/esm/utils/data/uuid.utils.d.ts.map +0 -1
  490. package/dist/esm/utils/data/uuid.utils.js +0 -52
  491. package/dist/esm/utils/data/uuid.utils.js.map +0 -1
  492. package/dist/esm/utils/emitter.utils.d.ts +0 -9
  493. package/dist/esm/utils/emitter.utils.d.ts.map +0 -1
  494. package/dist/esm/utils/emitter.utils.js +0 -32
  495. package/dist/esm/utils/emitter.utils.js.map +0 -1
  496. package/dist/esm/utils/index.d.ts +0 -8
  497. package/dist/esm/utils/index.d.ts.map +0 -1
  498. package/dist/esm/utils/index.js +0 -8
  499. package/dist/esm/utils/index.js.map +0 -1
  500. package/dist/esm/utils/logging.utils.d.ts +0 -22
  501. package/dist/esm/utils/logging.utils.d.ts.map +0 -1
  502. package/dist/esm/utils/logging.utils.js +0 -82
  503. package/dist/esm/utils/logging.utils.js.map +0 -1
  504. package/dist/esm/utils/network/index.d.ts +0 -2
  505. package/dist/esm/utils/network/index.d.ts.map +0 -1
  506. package/dist/esm/utils/network/index.js +0 -2
  507. package/dist/esm/utils/network/index.js.map +0 -1
  508. package/dist/esm/utils/network/url.utils.d.ts +0 -16
  509. package/dist/esm/utils/network/url.utils.d.ts.map +0 -1
  510. package/dist/esm/utils/network/url.utils.js +0 -87
  511. package/dist/esm/utils/network/url.utils.js.map +0 -1
  512. package/dist/esm/utils/security/index.d.ts +0 -2
  513. package/dist/esm/utils/security/index.d.ts.map +0 -1
  514. package/dist/esm/utils/security/index.js +0 -2
  515. package/dist/esm/utils/security/index.js.map +0 -1
  516. package/dist/esm/utils/security/sanitize.utils.d.ts +0 -14
  517. package/dist/esm/utils/security/sanitize.utils.d.ts.map +0 -1
  518. package/dist/esm/utils/security/sanitize.utils.js +0 -118
  519. package/dist/esm/utils/security/sanitize.utils.js.map +0 -1
  520. package/dist/esm/utils/validations/config-validations.utils.d.ts +0 -19
  521. package/dist/esm/utils/validations/config-validations.utils.d.ts.map +0 -1
  522. package/dist/esm/utils/validations/config-validations.utils.js +0 -231
  523. package/dist/esm/utils/validations/config-validations.utils.js.map +0 -1
  524. package/dist/esm/utils/validations/event-validations.utils.d.ts +0 -13
  525. package/dist/esm/utils/validations/event-validations.utils.d.ts.map +0 -1
  526. package/dist/esm/utils/validations/event-validations.utils.js +0 -33
  527. package/dist/esm/utils/validations/event-validations.utils.js.map +0 -1
  528. package/dist/esm/utils/validations/index.d.ts +0 -5
  529. package/dist/esm/utils/validations/index.d.ts.map +0 -1
  530. package/dist/esm/utils/validations/index.js +0 -5
  531. package/dist/esm/utils/validations/index.js.map +0 -1
  532. package/dist/esm/utils/validations/metadata-validations.utils.d.ts +0 -23
  533. package/dist/esm/utils/validations/metadata-validations.utils.d.ts.map +0 -1
  534. package/dist/esm/utils/validations/metadata-validations.utils.js +0 -148
  535. package/dist/esm/utils/validations/metadata-validations.utils.js.map +0 -1
  536. package/dist/esm/utils/validations/type-guards.utils.d.ts +0 -9
  537. package/dist/esm/utils/validations/type-guards.utils.d.ts.map +0 -1
  538. package/dist/esm/utils/validations/type-guards.utils.js +0 -86
  539. package/dist/esm/utils/validations/type-guards.utils.js.map +0 -1
@@ -1,2983 +0,0 @@
1
- const jt = 120, Yt = 8192, Kt = 10, qt = 10, Zt = 20, Jt = 1;
2
- const er = 1e3, tr = 500, rr = 100;
3
- const v = "data-tlog", Ue = [
4
- "button",
5
- "a",
6
- 'input[type="button"]',
7
- 'input[type="submit"]',
8
- 'input[type="reset"]',
9
- 'input[type="checkbox"]',
10
- 'input[type="radio"]',
11
- "select",
12
- "textarea",
13
- '[role="button"]',
14
- '[role="link"]',
15
- '[role="tab"]',
16
- '[role="menuitem"]',
17
- '[role="option"]',
18
- '[role="checkbox"]',
19
- '[role="radio"]',
20
- '[role="switch"]',
21
- "[routerLink]",
22
- "[ng-click]",
23
- "[data-action]",
24
- "[data-click]",
25
- "[data-navigate]",
26
- "[data-toggle]",
27
- "[onclick]",
28
- ".btn",
29
- ".button",
30
- ".clickable",
31
- ".nav-link",
32
- ".menu-item",
33
- "[data-testid]",
34
- '[tabindex="0"]'
35
- ], He = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], xe = [
36
- "token",
37
- "auth",
38
- "key",
39
- "session",
40
- "reset",
41
- "password",
42
- "api_key",
43
- "apikey",
44
- "secret",
45
- "access_token",
46
- "refresh_token",
47
- "verification",
48
- "code",
49
- "otp"
50
- ];
51
- const h = {
52
- INVALID_SESSION_TIMEOUT: "Session timeout must be between 30000ms (30 seconds) and 86400000ms (24 hours)",
53
- INVALID_SAMPLING_RATE: "Sampling rate must be between 0 and 1",
54
- INVALID_ERROR_SAMPLING_RATE: "Error sampling must be between 0 and 1",
55
- INVALID_TRACELOG_PROJECT_ID: "TraceLog project ID is required when integration is enabled",
56
- INVALID_CUSTOM_API_URL: "Custom API URL is required when integration is enabled",
57
- INVALID_GOOGLE_ANALYTICS_ID: "Google Analytics measurement ID is required when integration is enabled",
58
- INVALID_GLOBAL_METADATA: "Global metadata must be an object",
59
- INVALID_SENSITIVE_QUERY_PARAMS: "Sensitive query params must be an array of strings",
60
- INVALID_PRIMARY_SCROLL_SELECTOR: "Primary scroll selector must be a non-empty string",
61
- INVALID_PRIMARY_SCROLL_SELECTOR_SYNTAX: "Invalid CSS selector syntax for primaryScrollSelector",
62
- INVALID_PAGE_VIEW_THROTTLE: "Page view throttle must be a non-negative number",
63
- INVALID_CLICK_THROTTLE: "Click throttle must be a non-negative number",
64
- INVALID_MAX_SAME_EVENT_PER_MINUTE: "Max same event per minute must be a positive number",
65
- INVALID_VIEWPORT_CONFIG: "Viewport config must be an object",
66
- INVALID_VIEWPORT_ELEMENTS: "Viewport elements must be a non-empty array",
67
- INVALID_VIEWPORT_ELEMENT: "Each viewport element must have a valid selector string",
68
- INVALID_VIEWPORT_ELEMENT_ID: "Viewport element id must be a non-empty string",
69
- INVALID_VIEWPORT_ELEMENT_NAME: "Viewport element name must be a non-empty string",
70
- INVALID_VIEWPORT_THRESHOLD: "Viewport threshold must be a number between 0 and 1",
71
- INVALID_VIEWPORT_MIN_DWELL_TIME: "Viewport minDwellTime must be a non-negative number",
72
- INVALID_VIEWPORT_COOLDOWN_PERIOD: "Viewport cooldownPeriod must be a non-negative number",
73
- INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS: "Viewport maxTrackedElements must be a positive number"
74
- }, Fe = [
75
- /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
76
- /javascript:/gi,
77
- /on\w+\s*=/gi,
78
- /<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
79
- /<embed\b[^>]*>/gi,
80
- /<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
81
- ];
82
- var q = /* @__PURE__ */ ((n) => (n.Localhost = "localhost:8080", n.Fail = "localhost:9999", n))(q || {}), w = /* @__PURE__ */ ((n) => (n.Mobile = "mobile", n.Tablet = "tablet", n.Desktop = "desktop", n.Unknown = "unknown", n))(w || {}), Z = /* @__PURE__ */ ((n) => (n.EVENT = "event", n.QUEUE = "queue", n))(Z || {});
83
- class R extends Error {
84
- constructor(e, t) {
85
- super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, R);
86
- }
87
- }
88
- var u = /* @__PURE__ */ ((n) => (n.PAGE_VIEW = "page_view", n.CLICK = "click", n.SCROLL = "scroll", n.SESSION_START = "session_start", n.SESSION_END = "session_end", n.CUSTOM = "custom", n.WEB_VITALS = "web_vitals", n.ERROR = "error", n.VIEWPORT_VISIBLE = "viewport_visible", n))(u || {}), H = /* @__PURE__ */ ((n) => (n.UP = "up", n.DOWN = "down", n))(H || {}), P = /* @__PURE__ */ ((n) => (n.JS_ERROR = "js_error", n.PROMISE_REJECTION = "promise_rejection", n))(P || {}), D = /* @__PURE__ */ ((n) => (n.QA = "qa", n))(D || {});
89
- function nr(n) {
90
- return n.type === u.SCROLL && "scroll_data" in n && n.scroll_data.is_primary === !0;
91
- }
92
- function sr(n) {
93
- return n.type === u.SCROLL && "scroll_data" in n && n.scroll_data.is_primary === !1;
94
- }
95
- class V extends Error {
96
- constructor(e, t, r) {
97
- super(e), this.errorCode = t, this.layer = r, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
98
- }
99
- }
100
- class f extends V {
101
- constructor(e, t = "config") {
102
- super(e, "APP_CONFIG_INVALID", t);
103
- }
104
- }
105
- class Ge extends V {
106
- constructor(e, t = "config") {
107
- super(e, "SESSION_TIMEOUT_INVALID", t);
108
- }
109
- }
110
- class he extends V {
111
- constructor(e, t = "config") {
112
- super(e, "SAMPLING_RATE_INVALID", t);
113
- }
114
- }
115
- class M extends V {
116
- constructor(e, t = "config") {
117
- super(e, "INTEGRATION_INVALID", t);
118
- }
119
- }
120
- class ir extends V {
121
- constructor(e, t, r = "runtime") {
122
- super(e, "INITIALIZATION_TIMEOUT", r), this.timeoutMs = t;
123
- }
124
- }
125
- const We = (n, e) => {
126
- if (e) {
127
- if (e instanceof Error) {
128
- const t = e.message.replace(/\s+at\s+.*$/gm, "").replace(/\(.*?:\d+:\d+\)/g, "");
129
- return `[TraceLog] ${n}: ${t}`;
130
- }
131
- return `[TraceLog] ${n}: ${e instanceof Error ? e.message : "Unknown error"}`;
132
- }
133
- return `[TraceLog] ${n}`;
134
- }, a = (n, e, t) => {
135
- const { error: r, data: s, showToClient: i = !1 } = t ?? {}, o = r ? We(e, r) : `[TraceLog] ${e}`, l = n === "error" ? "error" : n === "warn" ? "warn" : "log";
136
- if (!(n === "debug" || n === "info" && !i))
137
- if (s !== void 0) {
138
- const c = Be(s);
139
- console[l](o, c);
140
- } else s !== void 0 ? console[l](o, s) : console[l](o);
141
- }, Be = (n) => {
142
- const e = {}, t = ["token", "password", "secret", "key", "apikey", "api_key", "sessionid", "session_id"];
143
- for (const [r, s] of Object.entries(n)) {
144
- const i = r.toLowerCase();
145
- t.some((o) => i.includes(o)) ? e[r] = "[REDACTED]" : e[r] = s;
146
- }
147
- return e;
148
- };
149
- let J, we;
150
- const Xe = () => {
151
- typeof window < "u" && !J && (J = window.matchMedia("(pointer: coarse)"), we = window.matchMedia("(hover: none)"));
152
- }, $e = () => {
153
- try {
154
- const n = navigator;
155
- if (n.userAgentData && typeof n.userAgentData.mobile == "boolean")
156
- return n.userAgentData.platform && /ipad|tablet/i.test(n.userAgentData.platform) ? w.Tablet : n.userAgentData.mobile ? w.Mobile : w.Desktop;
157
- Xe();
158
- const e = window.innerWidth, t = J?.matches ?? !1, r = we?.matches ?? !1, s = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = navigator.userAgent.toLowerCase(), o = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(i), l = /tablet|ipad|android(?!.*mobile)/.test(i);
159
- return e <= 767 || o && s ? w.Mobile : e >= 768 && e <= 1024 || l || t && r && s ? w.Tablet : w.Desktop;
160
- } catch (n) {
161
- return a("warn", "Device detection failed, defaulting to desktop", { error: n }), w.Desktop;
162
- }
163
- }, y = "tlog", fe = `${y}:qa_mode`, ze = `${y}:uid`, Qe = (n) => n ? `${y}:${n}:queue` : `${y}:queue`, je = (n) => n ? `${y}:${n}:session` : `${y}:session`, Ye = (n) => n ? `${y}:${n}:broadcast` : `${y}:broadcast`, ye = {
164
- LCP: 4e3,
165
- FCP: 1800,
166
- CLS: 0.25,
167
- INP: 200,
168
- TTFB: 800,
169
- LONG_TASK: 50
170
- }, Ke = 1e3, le = [
171
- // Email addresses
172
- /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/gi,
173
- // US Phone numbers (various formats)
174
- /\b\d{3}[-.]?\d{3}[-.]?\d{4}\b/g,
175
- // Credit card numbers (16 digits with optional separators)
176
- /\b\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}\b/g,
177
- // IBAN (International Bank Account Number)
178
- /\b[A-Z]{2}\d{2}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}\b/gi,
179
- // API keys/tokens (sk_test_, sk_live_, pk_test_, pk_live_, etc.)
180
- /\b[sp]k_(test|live)_[a-zA-Z0-9]{10,}\b/gi,
181
- // Bearer tokens (JWT-like patterns - matches complete and partial tokens)
182
- /Bearer\s+[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?(?:\.[A-Za-z0-9_-]+)?/gi,
183
- // Passwords in connection strings (protocol://user:password@host)
184
- /:\/\/[^:/]+:([^@]+)@/gi
185
- ], Ee = 500, ge = 5e3, x = 50, qe = x * 2, Le = 1, Ze = 1e3, Je = 10, me = 5e3, et = 6e4, Se = "tlog_mode", tt = "qa", rt = () => {
186
- if (sessionStorage.getItem(fe) === "true")
187
- return !0;
188
- const e = new URLSearchParams(window.location.search), r = e.get(Se) === tt;
189
- if (r) {
190
- sessionStorage.setItem(fe, "true"), e.delete(Se);
191
- const s = e.toString(), i = `${window.location.pathname}${s ? "?" + s : ""}${window.location.hash}`;
192
- try {
193
- window.history.replaceState({}, "", i);
194
- } catch (o) {
195
- a("warn", "History API not available, cannot replace URL", { error: o });
196
- }
197
- console.log(
198
- "%c[TraceLog] QA Mode ACTIVE",
199
- "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;"
200
- );
201
- }
202
- return r;
203
- }, _e = () => {
204
- const n = new URLSearchParams(window.location.search), e = {};
205
- return He.forEach((r) => {
206
- const s = n.get(r);
207
- if (s) {
208
- const i = r.split("utm_")[1];
209
- e[i] = s;
210
- }
211
- }), Object.keys(e).length ? e : void 0;
212
- }, nt = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (n) => {
213
- const e = Math.random() * 16 | 0;
214
- return (n === "x" ? e : e & 3 | 8).toString(16);
215
- }), st = () => {
216
- const n = Date.now();
217
- let e = "";
218
- try {
219
- if (typeof crypto < "u" && crypto.getRandomValues) {
220
- const t = crypto.getRandomValues(new Uint8Array(4));
221
- t && (e = Array.from(t, (r) => r.toString(16).padStart(2, "0")).join(""));
222
- }
223
- } catch {
224
- }
225
- return e || (e = Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")), `${n}-${e}`;
226
- }, Te = (n, e = !1) => {
227
- try {
228
- const t = new URL(n), r = t.protocol === "https:", s = t.protocol === "http:";
229
- return r || e && s;
230
- } catch {
231
- return !1;
232
- }
233
- }, it = (n) => {
234
- if (n.integrations?.tracelog?.projectId) {
235
- const s = new URL(window.location.href).hostname.split(".");
236
- if (s.length === 0)
237
- throw new Error("Invalid URL");
238
- const i = n.integrations.tracelog.projectId, o = s.slice(-2).join("."), l = `https://${i}.${o}/collect`;
239
- if (!Te(l))
240
- throw new Error("Invalid URL");
241
- return l;
242
- }
243
- const e = n.integrations?.custom?.collectApiUrl;
244
- if (e) {
245
- const t = n.integrations?.custom?.allowHttp ?? !1;
246
- if (!Te(e, t))
247
- throw new Error("Invalid URL");
248
- return e;
249
- }
250
- return "";
251
- }, ee = (n, e = []) => {
252
- try {
253
- const t = new URL(n), r = t.searchParams, s = [.../* @__PURE__ */ new Set([...xe, ...e])];
254
- let i = !1;
255
- const o = [];
256
- return s.forEach((c) => {
257
- r.has(c) && (r.delete(c), i = !0, o.push(c));
258
- }), !i && n.includes("?") ? n : (t.search = r.toString(), t.toString());
259
- } catch (t) {
260
- return a("warn", "URL normalization failed, returning original", { error: t, data: { url: n.slice(0, 100) } }), n;
261
- }
262
- }, pe = (n) => {
263
- if (!n || typeof n != "string" || n.trim().length === 0)
264
- return "";
265
- let e = n;
266
- n.length > 1e3 && (e = n.slice(0, Math.max(0, 1e3)));
267
- let t = 0;
268
- for (const s of Fe) {
269
- const i = e;
270
- e = e.replace(s, ""), i !== e && t++;
271
- }
272
- return t > 0 && a("warn", "XSS patterns detected and removed", {
273
- data: {
274
- patternMatches: t,
275
- originalValue: n.slice(0, 100)
276
- }
277
- }), e = e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#x27;").replaceAll("/", "&#x2F;"), e.trim();
278
- }, te = (n, e = 0) => {
279
- if (e > 3 || n == null)
280
- return null;
281
- if (typeof n == "string")
282
- return pe(n);
283
- if (typeof n == "number")
284
- return !Number.isFinite(n) || n < -Number.MAX_SAFE_INTEGER || n > Number.MAX_SAFE_INTEGER ? 0 : n;
285
- if (typeof n == "boolean")
286
- return n;
287
- if (Array.isArray(n))
288
- return n.slice(0, 100).map((s) => te(s, e + 1)).filter((s) => s !== null);
289
- if (typeof n == "object") {
290
- const t = {}, s = Object.entries(n).slice(0, 20);
291
- for (const [i, o] of s) {
292
- const l = pe(i);
293
- if (l) {
294
- const c = te(o, e + 1);
295
- c !== null && (t[l] = c);
296
- }
297
- }
298
- return t;
299
- }
300
- return null;
301
- }, ot = (n) => {
302
- if (typeof n != "object" || n === null)
303
- return {};
304
- try {
305
- const e = te(n);
306
- return typeof e == "object" && e !== null ? e : {};
307
- } catch (e) {
308
- const t = e instanceof Error ? e.message : String(e);
309
- throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
310
- }
311
- }, at = (n) => {
312
- if (n !== void 0 && (n === null || typeof n != "object"))
313
- throw new f("Configuration must be an object", "config");
314
- if (n) {
315
- if (n.sessionTimeout !== void 0 && (typeof n.sessionTimeout != "number" || n.sessionTimeout < 3e4 || n.sessionTimeout > 864e5))
316
- throw new Ge(h.INVALID_SESSION_TIMEOUT, "config");
317
- if (n.globalMetadata !== void 0 && (typeof n.globalMetadata != "object" || n.globalMetadata === null))
318
- throw new f(h.INVALID_GLOBAL_METADATA, "config");
319
- if (n.integrations && ct(n.integrations), n.sensitiveQueryParams !== void 0) {
320
- if (!Array.isArray(n.sensitiveQueryParams))
321
- throw new f(h.INVALID_SENSITIVE_QUERY_PARAMS, "config");
322
- for (const e of n.sensitiveQueryParams)
323
- if (typeof e != "string")
324
- throw new f("All sensitive query params must be strings", "config");
325
- }
326
- if (n.errorSampling !== void 0 && (typeof n.errorSampling != "number" || n.errorSampling < 0 || n.errorSampling > 1))
327
- throw new he(h.INVALID_ERROR_SAMPLING_RATE, "config");
328
- if (n.samplingRate !== void 0 && (typeof n.samplingRate != "number" || n.samplingRate < 0 || n.samplingRate > 1))
329
- throw new he(h.INVALID_SAMPLING_RATE, "config");
330
- if (n.primaryScrollSelector !== void 0) {
331
- if (typeof n.primaryScrollSelector != "string" || !n.primaryScrollSelector.trim())
332
- throw new f(h.INVALID_PRIMARY_SCROLL_SELECTOR, "config");
333
- if (n.primaryScrollSelector !== "window")
334
- try {
335
- document.querySelector(n.primaryScrollSelector);
336
- } catch {
337
- throw new f(
338
- `${h.INVALID_PRIMARY_SCROLL_SELECTOR_SYNTAX}: "${n.primaryScrollSelector}"`,
339
- "config"
340
- );
341
- }
342
- }
343
- if (n.pageViewThrottleMs !== void 0 && (typeof n.pageViewThrottleMs != "number" || n.pageViewThrottleMs < 0))
344
- throw new f(h.INVALID_PAGE_VIEW_THROTTLE, "config");
345
- if (n.clickThrottleMs !== void 0 && (typeof n.clickThrottleMs != "number" || n.clickThrottleMs < 0))
346
- throw new f(h.INVALID_CLICK_THROTTLE, "config");
347
- if (n.maxSameEventPerMinute !== void 0 && (typeof n.maxSameEventPerMinute != "number" || n.maxSameEventPerMinute <= 0))
348
- throw new f(h.INVALID_MAX_SAME_EVENT_PER_MINUTE, "config");
349
- n.viewport !== void 0 && lt(n.viewport);
350
- }
351
- }, lt = (n) => {
352
- if (typeof n != "object" || n === null)
353
- throw new f(h.INVALID_VIEWPORT_CONFIG, "config");
354
- if (!n.elements || !Array.isArray(n.elements))
355
- throw new f(h.INVALID_VIEWPORT_ELEMENTS, "config");
356
- if (n.elements.length === 0)
357
- throw new f(h.INVALID_VIEWPORT_ELEMENTS, "config");
358
- const e = /* @__PURE__ */ new Set();
359
- for (const t of n.elements) {
360
- if (!t.selector || typeof t.selector != "string" || !t.selector.trim())
361
- throw new f(h.INVALID_VIEWPORT_ELEMENT, "config");
362
- const r = t.selector.trim();
363
- if (e.has(r))
364
- throw new f(
365
- `Duplicate viewport selector found: "${r}". Each selector should appear only once.`,
366
- "config"
367
- );
368
- if (e.add(r), t.id !== void 0 && (typeof t.id != "string" || !t.id.trim()))
369
- throw new f(h.INVALID_VIEWPORT_ELEMENT_ID, "config");
370
- if (t.name !== void 0 && (typeof t.name != "string" || !t.name.trim()))
371
- throw new f(h.INVALID_VIEWPORT_ELEMENT_NAME, "config");
372
- }
373
- if (n.threshold !== void 0 && (typeof n.threshold != "number" || n.threshold < 0 || n.threshold > 1))
374
- throw new f(h.INVALID_VIEWPORT_THRESHOLD, "config");
375
- if (n.minDwellTime !== void 0 && (typeof n.minDwellTime != "number" || n.minDwellTime < 0))
376
- throw new f(h.INVALID_VIEWPORT_MIN_DWELL_TIME, "config");
377
- if (n.cooldownPeriod !== void 0 && (typeof n.cooldownPeriod != "number" || n.cooldownPeriod < 0))
378
- throw new f(h.INVALID_VIEWPORT_COOLDOWN_PERIOD, "config");
379
- if (n.maxTrackedElements !== void 0 && (typeof n.maxTrackedElements != "number" || n.maxTrackedElements <= 0))
380
- throw new f(h.INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS, "config");
381
- }, ct = (n) => {
382
- if (n) {
383
- if (n.tracelog && (!n.tracelog.projectId || typeof n.tracelog.projectId != "string" || n.tracelog.projectId.trim() === ""))
384
- throw new M(h.INVALID_TRACELOG_PROJECT_ID, "config");
385
- if (n.custom) {
386
- if (!n.custom.collectApiUrl || typeof n.custom.collectApiUrl != "string" || n.custom.collectApiUrl.trim() === "")
387
- throw new M(h.INVALID_CUSTOM_API_URL, "config");
388
- if (n.custom.allowHttp !== void 0 && typeof n.custom.allowHttp != "boolean")
389
- throw new M("allowHttp must be a boolean", "config");
390
- const e = n.custom.collectApiUrl.trim();
391
- if (!e.startsWith("http://") && !e.startsWith("https://"))
392
- throw new M('Custom API URL must start with "http://" or "https://"', "config");
393
- if (!(n.custom.allowHttp ?? !1) && e.startsWith("http://"))
394
- throw new M(
395
- "Custom API URL must use HTTPS in production. Set allowHttp: true in integration config to allow HTTP (not recommended)",
396
- "config"
397
- );
398
- }
399
- if (n.googleAnalytics) {
400
- if (!n.googleAnalytics.measurementId || typeof n.googleAnalytics.measurementId != "string" || n.googleAnalytics.measurementId.trim() === "")
401
- throw new M(h.INVALID_GOOGLE_ANALYTICS_ID, "config");
402
- if (!n.googleAnalytics.measurementId.trim().match(/^(G-|UA-)/))
403
- throw new M('Google Analytics measurement ID must start with "G-" or "UA-"', "config");
404
- }
405
- }
406
- }, ut = (n) => {
407
- at(n);
408
- const e = {
409
- ...n ?? {},
410
- sessionTimeout: n?.sessionTimeout ?? 9e5,
411
- globalMetadata: n?.globalMetadata ?? {},
412
- sensitiveQueryParams: n?.sensitiveQueryParams ?? [],
413
- errorSampling: n?.errorSampling ?? Le,
414
- samplingRate: n?.samplingRate ?? 1,
415
- pageViewThrottleMs: n?.pageViewThrottleMs ?? 1e3,
416
- clickThrottleMs: n?.clickThrottleMs ?? 300,
417
- maxSameEventPerMinute: n?.maxSameEventPerMinute ?? 60
418
- };
419
- return e.integrations?.custom && (e.integrations.custom = {
420
- ...e.integrations.custom,
421
- allowHttp: e.integrations.custom.allowHttp ?? !1
422
- }), e.viewport && (e.viewport = {
423
- ...e.viewport,
424
- threshold: e.viewport.threshold ?? 0.5,
425
- minDwellTime: e.viewport.minDwellTime ?? 2e3,
426
- cooldownPeriod: e.viewport.cooldownPeriod ?? 6e4,
427
- maxTrackedElements: e.viewport.maxTrackedElements ?? 100
428
- }), e;
429
- }, dt = (n) => {
430
- if (typeof n == "string")
431
- return !0;
432
- if (typeof n == "object" && n !== null && !Array.isArray(n)) {
433
- const e = Object.entries(n);
434
- if (e.length > 20)
435
- return !1;
436
- for (const [, t] of e) {
437
- if (t == null)
438
- continue;
439
- const r = typeof t;
440
- if (r !== "string" && r !== "number" && r !== "boolean")
441
- return !1;
442
- }
443
- return !0;
444
- }
445
- return !1;
446
- }, Me = (n, e = 0) => {
447
- if (typeof n != "object" || n === null || e > 1)
448
- return !1;
449
- for (const t of Object.values(n)) {
450
- if (t == null)
451
- continue;
452
- const r = typeof t;
453
- if (!(r === "string" || r === "number" || r === "boolean")) {
454
- if (Array.isArray(t)) {
455
- if (t.length === 0)
456
- continue;
457
- if (typeof t[0] == "string") {
458
- if (!t.every((o) => typeof o == "string"))
459
- return !1;
460
- } else if (!t.every((o) => dt(o)))
461
- return !1;
462
- continue;
463
- }
464
- if (r === "object" && e === 0) {
465
- if (!Me(t, e + 1))
466
- return !1;
467
- continue;
468
- }
469
- return !1;
470
- }
471
- }
472
- return !0;
473
- }, ht = (n) => typeof n != "string" ? {
474
- valid: !1,
475
- error: "Event name must be a string"
476
- } : n.length === 0 ? {
477
- valid: !1,
478
- error: "Event name cannot be empty"
479
- } : n.length > 120 ? {
480
- valid: !1,
481
- error: "Event name is too long (max 120 characters)"
482
- } : n.includes("<") || n.includes(">") || n.includes("&") ? {
483
- valid: !1,
484
- error: "Event name contains invalid characters"
485
- } : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(n.toLowerCase()) ? {
486
- valid: !1,
487
- error: "Event name cannot be a reserved word"
488
- } : { valid: !0 }, Ie = (n, e, t) => {
489
- const r = ot(e), s = `${t} "${n}" metadata error`;
490
- if (!Me(r))
491
- return {
492
- valid: !1,
493
- error: `${s}: object has invalid types. Valid types are string, number, boolean or string arrays.`
494
- };
495
- let i;
496
- try {
497
- i = JSON.stringify(r);
498
- } catch {
499
- return {
500
- valid: !1,
501
- error: `${s}: object contains circular references or cannot be serialized.`
502
- };
503
- }
504
- if (i.length > 8192)
505
- return {
506
- valid: !1,
507
- error: `${s}: object is too large (max ${8192 / 1024} KB).`
508
- };
509
- if (Object.keys(r).length > 10)
510
- return {
511
- valid: !1,
512
- error: `${s}: object has too many keys (max 10 keys).`
513
- };
514
- for (const [l, c] of Object.entries(r)) {
515
- if (Array.isArray(c)) {
516
- if (c.length > 10)
517
- return {
518
- valid: !1,
519
- error: `${s}: array property "${l}" is too large (max 10 items).`
520
- };
521
- for (const d of c)
522
- if (typeof d == "string" && d.length > 500)
523
- return {
524
- valid: !1,
525
- error: `${s}: array property "${l}" contains strings that are too long (max 500 characters).`
526
- };
527
- }
528
- if (typeof c == "string" && c.length > 1e3)
529
- return {
530
- valid: !1,
531
- error: `${s}: property "${l}" is too long (max 1000 characters).`
532
- };
533
- }
534
- return {
535
- valid: !0,
536
- sanitizedMetadata: r
537
- };
538
- }, ft = (n, e, t) => {
539
- if (Array.isArray(e)) {
540
- const r = [], s = `${t} "${n}" metadata error`;
541
- for (let i = 0; i < e.length; i++) {
542
- const o = e[i];
543
- if (typeof o != "object" || o === null || Array.isArray(o))
544
- return {
545
- valid: !1,
546
- error: `${s}: array item at index ${i} must be an object.`
547
- };
548
- const l = Ie(n, o, t);
549
- if (!l.valid)
550
- return {
551
- valid: !1,
552
- error: `${s}: array item at index ${i} is invalid: ${l.error}`
553
- };
554
- l.sanitizedMetadata && r.push(l.sanitizedMetadata);
555
- }
556
- return {
557
- valid: !0,
558
- sanitizedMetadata: r
559
- };
560
- }
561
- return Ie(n, e, t);
562
- }, Et = (n, e) => {
563
- const t = ht(n);
564
- if (!t.valid)
565
- return a("error", "Event name validation failed", {
566
- showToClient: !0,
567
- data: { eventName: n, error: t.error }
568
- }), t;
569
- if (!e)
570
- return { valid: !0 };
571
- const r = ft(n, e, "customEvent");
572
- return r.valid || a("error", "Event metadata validation failed", {
573
- showToClient: !0,
574
- data: {
575
- eventName: n,
576
- error: r.error
577
- }
578
- }), r;
579
- };
580
- class gt {
581
- listeners = /* @__PURE__ */ new Map();
582
- on(e, t) {
583
- this.listeners.has(e) || this.listeners.set(e, []), this.listeners.get(e).push(t);
584
- }
585
- off(e, t) {
586
- const r = this.listeners.get(e);
587
- if (r) {
588
- const s = r.indexOf(t);
589
- s > -1 && r.splice(s, 1);
590
- }
591
- }
592
- emit(e, t) {
593
- const r = this.listeners.get(e);
594
- r && r.forEach((s) => {
595
- s(t);
596
- });
597
- }
598
- removeAllListeners() {
599
- this.listeners.clear();
600
- }
601
- }
602
- const j = {};
603
- class S {
604
- get(e) {
605
- return j[e];
606
- }
607
- set(e, t) {
608
- j[e] = t;
609
- }
610
- getState() {
611
- return { ...j };
612
- }
613
- }
614
- class mt extends S {
615
- storeManager;
616
- lastPermanentErrorLog = null;
617
- constructor(e) {
618
- super(), this.storeManager = e;
619
- }
620
- getQueueStorageKey() {
621
- const e = this.get("userId") || "anonymous";
622
- return Qe(e);
623
- }
624
- sendEventsQueueSync(e) {
625
- return this.shouldSkipSend() ? !0 : this.get("config")?.integrations?.custom?.collectApiUrl === q.Fail ? (a("warn", "Fail mode: simulating network failure (sync)", {
626
- data: { events: e.events.length }
627
- }), !1) : this.sendQueueSyncInternal(e);
628
- }
629
- async sendEventsQueue(e, t) {
630
- try {
631
- const r = await this.send(e);
632
- return r ? (this.clearPersistedEvents(), t?.onSuccess?.(e.events.length, e.events, e)) : (this.persistEvents(e), t?.onFailure?.()), r;
633
- } catch (r) {
634
- return r instanceof R ? (this.logPermanentError("Permanent error, not retrying", r), this.clearPersistedEvents(), t?.onFailure?.(), !1) : (this.persistEvents(e), t?.onFailure?.(), !1);
635
- }
636
- }
637
- async recoverPersistedEvents(e) {
638
- try {
639
- const t = this.getPersistedData();
640
- if (!t || !this.isDataRecent(t) || t.events.length === 0) {
641
- this.clearPersistedEvents();
642
- return;
643
- }
644
- const r = this.createRecoveryBody(t);
645
- await this.send(r) ? (this.clearPersistedEvents(), e?.onSuccess?.(t.events.length, t.events, r)) : e?.onFailure?.();
646
- } catch (t) {
647
- if (t instanceof R) {
648
- this.logPermanentError("Permanent error during recovery, clearing persisted events", t), this.clearPersistedEvents(), e?.onFailure?.();
649
- return;
650
- }
651
- a("error", "Failed to recover persisted events", { error: t });
652
- }
653
- }
654
- stop() {
655
- }
656
- async send(e) {
657
- if (this.shouldSkipSend())
658
- return this.simulateSuccessfulSend();
659
- if (this.get("config")?.integrations?.custom?.collectApiUrl === q.Fail)
660
- return a("warn", "Fail mode: simulating network failure", {
661
- data: { events: e.events.length }
662
- }), !1;
663
- const { url: r, payload: s } = this.prepareRequest(e);
664
- try {
665
- return (await this.sendWithTimeout(r, s)).ok;
666
- } catch (i) {
667
- if (i instanceof R)
668
- throw i;
669
- return a("error", "Send request failed", {
670
- error: i,
671
- data: {
672
- events: e.events.length,
673
- url: r.replace(/\/\/[^/]+/, "//[DOMAIN]")
674
- }
675
- }), !1;
676
- }
677
- }
678
- async sendWithTimeout(e, t) {
679
- const r = new AbortController(), s = setTimeout(() => {
680
- r.abort();
681
- }, 1e4);
682
- try {
683
- const i = await fetch(e, {
684
- method: "POST",
685
- body: t,
686
- keepalive: !0,
687
- credentials: "include",
688
- signal: r.signal,
689
- headers: {
690
- "Content-Type": "application/json"
691
- }
692
- });
693
- if (!i.ok)
694
- throw i.status >= 400 && i.status < 500 ? new R(`HTTP ${i.status}: ${i.statusText}`, i.status) : new Error(`HTTP ${i.status}: ${i.statusText}`);
695
- return i;
696
- } finally {
697
- clearTimeout(s);
698
- }
699
- }
700
- sendQueueSyncInternal(e) {
701
- const { url: t, payload: r } = this.prepareRequest(e);
702
- if (r.length > 65536)
703
- return a("warn", "Payload exceeds sendBeacon limit, persisting for recovery", {
704
- data: {
705
- size: r.length,
706
- limit: 65536,
707
- events: e.events.length
708
- }
709
- }), this.persistEvents(e), !1;
710
- const s = new Blob([r], { type: "application/json" });
711
- if (!this.isSendBeaconAvailable())
712
- return a("warn", "sendBeacon not available, persisting events for recovery"), this.persistEvents(e), !1;
713
- const i = navigator.sendBeacon(t, s);
714
- return i || (a("warn", "sendBeacon rejected request, persisting events for recovery"), this.persistEvents(e)), i;
715
- }
716
- prepareRequest(e) {
717
- const t = {
718
- ...e,
719
- _metadata: {
720
- referer: typeof window < "u" ? window.location.href : void 0,
721
- timestamp: Date.now()
722
- }
723
- };
724
- return {
725
- url: this.get("collectApiUrl"),
726
- payload: JSON.stringify(t)
727
- };
728
- }
729
- getPersistedData() {
730
- try {
731
- const e = this.getQueueStorageKey(), t = this.storeManager.getItem(e);
732
- if (t)
733
- return JSON.parse(t);
734
- } catch (e) {
735
- a("warn", "Failed to parse persisted data", { error: e }), this.clearPersistedEvents();
736
- }
737
- return null;
738
- }
739
- isDataRecent(e) {
740
- return !e.timestamp || typeof e.timestamp != "number" ? !1 : (Date.now() - e.timestamp) / (1e3 * 60 * 60) < 2;
741
- }
742
- createRecoveryBody(e) {
743
- return {
744
- user_id: e.userId,
745
- session_id: e.sessionId,
746
- device: e.device,
747
- events: e.events,
748
- ...e.global_metadata && { global_metadata: e.global_metadata }
749
- };
750
- }
751
- persistEvents(e) {
752
- try {
753
- const t = {
754
- userId: e.user_id,
755
- sessionId: e.session_id,
756
- device: e.device,
757
- events: e.events,
758
- timestamp: Date.now(),
759
- ...e.global_metadata && { global_metadata: e.global_metadata }
760
- }, r = this.getQueueStorageKey();
761
- return this.storeManager.setItem(r, JSON.stringify(t)), !!this.storeManager.getItem(r);
762
- } catch (t) {
763
- return a("warn", "Failed to persist events", { error: t }), !1;
764
- }
765
- }
766
- clearPersistedEvents() {
767
- try {
768
- const e = this.getQueueStorageKey();
769
- this.storeManager.removeItem(e);
770
- } catch (e) {
771
- a("warn", "Failed to clear persisted events", { error: e });
772
- }
773
- }
774
- shouldSkipSend() {
775
- return !this.get("collectApiUrl");
776
- }
777
- async simulateSuccessfulSend() {
778
- const e = Math.random() * 400 + 100;
779
- return await new Promise((t) => setTimeout(t, e)), !0;
780
- }
781
- isSendBeaconAvailable() {
782
- return typeof navigator < "u" && typeof navigator.sendBeacon == "function";
783
- }
784
- logPermanentError(e, t) {
785
- const r = Date.now();
786
- (!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || r - this.lastPermanentErrorLog.timestamp >= et) && (a("error", e, {
787
- data: { status: t.statusCode, message: t.message }
788
- }), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: r });
789
- }
790
- }
791
- class St extends S {
792
- googleAnalytics;
793
- dataSender;
794
- emitter;
795
- eventsQueue = [];
796
- pendingEventsBuffer = [];
797
- recentEventFingerprints = /* @__PURE__ */ new Map();
798
- // Time-based deduplication cache
799
- sendIntervalId = null;
800
- rateLimitCounter = 0;
801
- rateLimitWindowStart = 0;
802
- perEventRateLimits = /* @__PURE__ */ new Map();
803
- sessionEventCounts = {
804
- total: 0,
805
- [u.CLICK]: 0,
806
- [u.PAGE_VIEW]: 0,
807
- [u.CUSTOM]: 0,
808
- [u.VIEWPORT_VISIBLE]: 0,
809
- [u.SCROLL]: 0
810
- };
811
- lastSessionId = null;
812
- constructor(e, t = null, r = null) {
813
- super(), this.googleAnalytics = t, this.dataSender = new mt(e), this.emitter = r;
814
- }
815
- async recoverPersistedEvents() {
816
- await this.dataSender.recoverPersistedEvents({
817
- onSuccess: (e, t, r) => {
818
- if (t && t.length > 0) {
819
- const s = t.map((i) => i.id);
820
- this.removeProcessedEvents(s), r && this.emitEventsQueue(r);
821
- }
822
- },
823
- onFailure: () => {
824
- a("warn", "Failed to recover persisted events");
825
- }
826
- });
827
- }
828
- track({
829
- type: e,
830
- page_url: t,
831
- from_page_url: r,
832
- scroll_data: s,
833
- click_data: i,
834
- custom_event: o,
835
- web_vitals: l,
836
- error_data: c,
837
- session_end_reason: d,
838
- viewport_data: _
839
- }) {
840
- if (!e) {
841
- a("error", "Event type is required - event will be ignored");
842
- return;
843
- }
844
- const g = this.get("sessionId");
845
- if (!g) {
846
- this.pendingEventsBuffer.length >= 100 && (this.pendingEventsBuffer.shift(), a("warn", "Pending events buffer full - dropping oldest event", {
847
- data: { maxBufferSize: 100 }
848
- })), this.pendingEventsBuffer.push({
849
- type: e,
850
- page_url: t,
851
- from_page_url: r,
852
- scroll_data: s,
853
- click_data: i,
854
- custom_event: o,
855
- web_vitals: l,
856
- error_data: c,
857
- session_end_reason: d,
858
- viewport_data: _
859
- });
860
- return;
861
- }
862
- this.lastSessionId !== g && (this.lastSessionId = g, this.sessionEventCounts = {
863
- total: 0,
864
- [u.CLICK]: 0,
865
- [u.PAGE_VIEW]: 0,
866
- [u.CUSTOM]: 0,
867
- [u.VIEWPORT_VISIBLE]: 0,
868
- [u.SCROLL]: 0
869
- });
870
- const L = e === u.SESSION_START || e === u.SESSION_END;
871
- if (!L && !this.checkRateLimit())
872
- return;
873
- const m = e;
874
- if (!L) {
875
- if (this.sessionEventCounts.total >= 1e3) {
876
- a("warn", "Session event limit reached", {
877
- data: {
878
- type: m,
879
- total: this.sessionEventCounts.total,
880
- limit: 1e3
881
- }
882
- });
883
- return;
884
- }
885
- const A = this.getTypeLimitForEvent(m);
886
- if (A) {
887
- const Q = this.sessionEventCounts[m];
888
- if (Q !== void 0 && Q >= A) {
889
- a("warn", "Session event type limit reached", {
890
- data: {
891
- type: m,
892
- count: Q,
893
- limit: A
894
- }
895
- });
896
- return;
897
- }
898
- }
899
- }
900
- if (m === u.CUSTOM && o?.name) {
901
- const A = this.get("config")?.maxSameEventPerMinute ?? 60;
902
- if (!this.checkPerEventRateLimit(o.name, A))
903
- return;
904
- }
905
- const Ve = m === u.SESSION_START, ke = t || this.get("pageUrl"), z = this.buildEventPayload({
906
- type: m,
907
- page_url: ke,
908
- from_page_url: r,
909
- scroll_data: s,
910
- click_data: i,
911
- custom_event: o,
912
- web_vitals: l,
913
- error_data: c,
914
- session_end_reason: d,
915
- viewport_data: _
916
- });
917
- if (!(!L && !this.shouldSample())) {
918
- if (Ve) {
919
- const A = this.get("sessionId");
920
- if (!A) {
921
- a("error", "Session start event requires sessionId - event will be ignored");
922
- return;
923
- }
924
- if (this.get("hasStartSession")) {
925
- a("warn", "Duplicate session_start detected", {
926
- data: { sessionId: A }
927
- });
928
- return;
929
- }
930
- this.set("hasStartSession", !0);
931
- }
932
- if (!this.isDuplicateEvent(z)) {
933
- if (this.get("mode") === D.QA && m === u.CUSTOM && o) {
934
- console.log("[TraceLog] Event", {
935
- name: o.name,
936
- ...o.metadata && { metadata: o.metadata }
937
- }), this.emitEvent(z);
938
- return;
939
- }
940
- this.addToQueue(z), L || (this.sessionEventCounts.total++, this.sessionEventCounts[m] !== void 0 && this.sessionEventCounts[m]++);
941
- }
942
- }
943
- }
944
- stop() {
945
- this.sendIntervalId && (clearInterval(this.sendIntervalId), this.sendIntervalId = null), this.eventsQueue = [], this.pendingEventsBuffer = [], this.recentEventFingerprints.clear(), this.rateLimitCounter = 0, this.rateLimitWindowStart = 0, this.perEventRateLimits.clear(), this.sessionEventCounts = {
946
- total: 0,
947
- [u.CLICK]: 0,
948
- [u.PAGE_VIEW]: 0,
949
- [u.CUSTOM]: 0,
950
- [u.VIEWPORT_VISIBLE]: 0,
951
- [u.SCROLL]: 0
952
- }, this.lastSessionId = null, this.dataSender.stop();
953
- }
954
- async flushImmediately() {
955
- return this.flushEvents(!1);
956
- }
957
- flushImmediatelySync() {
958
- return this.flushEvents(!0);
959
- }
960
- getQueueLength() {
961
- return this.eventsQueue.length;
962
- }
963
- flushPendingEvents() {
964
- if (this.pendingEventsBuffer.length === 0)
965
- return;
966
- if (!this.get("sessionId")) {
967
- a("warn", "Cannot flush pending events: session not initialized - keeping in buffer", {
968
- data: { bufferedEventCount: this.pendingEventsBuffer.length }
969
- });
970
- return;
971
- }
972
- const t = [...this.pendingEventsBuffer];
973
- this.pendingEventsBuffer = [], t.forEach((r) => {
974
- this.track(r);
975
- });
976
- }
977
- clearSendInterval() {
978
- this.sendIntervalId && (clearInterval(this.sendIntervalId), this.sendIntervalId = null);
979
- }
980
- flushEvents(e) {
981
- if (this.eventsQueue.length === 0)
982
- return e ? !0 : Promise.resolve(!0);
983
- const t = this.buildEventsPayload(), r = [...this.eventsQueue], s = r.map((i) => i.id);
984
- if (e) {
985
- const i = this.dataSender.sendEventsQueueSync(t);
986
- return i && (this.removeProcessedEvents(s), this.clearSendInterval(), this.emitEventsQueue(t)), i;
987
- } else
988
- return this.dataSender.sendEventsQueue(t, {
989
- onSuccess: () => {
990
- this.removeProcessedEvents(s), this.clearSendInterval(), this.emitEventsQueue(t);
991
- },
992
- onFailure: () => {
993
- a("warn", "Async flush failed", {
994
- data: { eventCount: r.length }
995
- });
996
- }
997
- });
998
- }
999
- async sendEventsQueue() {
1000
- if (!this.get("sessionId") || this.eventsQueue.length === 0)
1001
- return;
1002
- const e = this.buildEventsPayload(), t = [...this.eventsQueue], r = t.map((s) => s.id);
1003
- await this.dataSender.sendEventsQueue(e, {
1004
- onSuccess: () => {
1005
- this.removeProcessedEvents(r), this.emitEventsQueue(e);
1006
- },
1007
- onFailure: () => {
1008
- a("warn", "Events send failed, keeping in queue", {
1009
- data: { eventCount: t.length }
1010
- });
1011
- }
1012
- });
1013
- }
1014
- buildEventsPayload() {
1015
- const e = /* @__PURE__ */ new Map(), t = [];
1016
- for (const s of this.eventsQueue) {
1017
- const i = this.createEventSignature(s);
1018
- e.has(i) || t.push(i), e.set(i, s);
1019
- }
1020
- const r = t.map((s) => e.get(s)).filter((s) => !!s).sort((s, i) => s.timestamp - i.timestamp);
1021
- return {
1022
- user_id: this.get("userId"),
1023
- session_id: this.get("sessionId"),
1024
- device: this.get("device"),
1025
- events: r,
1026
- ...this.get("config")?.globalMetadata && { global_metadata: this.get("config")?.globalMetadata }
1027
- };
1028
- }
1029
- buildEventPayload(e) {
1030
- const t = e.type === u.SESSION_START, r = e.page_url ?? this.get("pageUrl");
1031
- return {
1032
- id: st(),
1033
- type: e.type,
1034
- page_url: r,
1035
- timestamp: Date.now(),
1036
- ...t && { referrer: document.referrer || "Direct" },
1037
- ...e.from_page_url && { from_page_url: e.from_page_url },
1038
- ...e.scroll_data && { scroll_data: e.scroll_data },
1039
- ...e.click_data && { click_data: e.click_data },
1040
- ...e.custom_event && { custom_event: e.custom_event },
1041
- ...e.web_vitals && { web_vitals: e.web_vitals },
1042
- ...e.error_data && { error_data: e.error_data },
1043
- ...e.session_end_reason && { session_end_reason: e.session_end_reason },
1044
- ...e.viewport_data && { viewport_data: e.viewport_data },
1045
- ...t && _e() && { utm: _e() }
1046
- };
1047
- }
1048
- /**
1049
- * Checks if event is a duplicate using time-based cache
1050
- * Tracks recent event fingerprints with timestamp-based cleanup
1051
- */
1052
- isDuplicateEvent(e) {
1053
- const t = Date.now(), r = this.createEventFingerprint(e), s = this.recentEventFingerprints.get(r);
1054
- return s && t - s < 500 ? (this.recentEventFingerprints.set(r, t), !0) : (this.recentEventFingerprints.set(r, t), this.recentEventFingerprints.size > 1e3 && this.pruneOldFingerprints(), this.recentEventFingerprints.size > 2e3 && (this.recentEventFingerprints.clear(), this.recentEventFingerprints.set(r, t), a("warn", "Event fingerprint cache exceeded hard limit, cleared", {
1055
- data: { hardLimit: 2e3 }
1056
- })), !1);
1057
- }
1058
- /**
1059
- * Prunes old fingerprints from cache based on timestamp
1060
- * Removes entries older than 10x the duplicate threshold (5 seconds)
1061
- */
1062
- pruneOldFingerprints() {
1063
- const e = Date.now(), t = 500 * 10;
1064
- for (const [r, s] of this.recentEventFingerprints.entries())
1065
- e - s > t && this.recentEventFingerprints.delete(r);
1066
- a("debug", "Pruned old event fingerprints", {
1067
- data: {
1068
- remaining: this.recentEventFingerprints.size,
1069
- cutoffMs: t
1070
- }
1071
- });
1072
- }
1073
- createEventFingerprint(e) {
1074
- let t = `${e.type}_${e.page_url}`;
1075
- if (e.click_data) {
1076
- const r = Math.round((e.click_data.x || 0) / 10) * 10, s = Math.round((e.click_data.y || 0) / 10) * 10;
1077
- t += `_click_${r}_${s}`;
1078
- }
1079
- return e.scroll_data && (t += `_scroll_${e.scroll_data.depth}_${e.scroll_data.direction}`), e.custom_event && (t += `_custom_${e.custom_event.name}`), e.web_vitals && (t += `_vitals_${e.web_vitals.type}`), e.error_data && (t += `_error_${e.error_data.type}_${e.error_data.message}`), t;
1080
- }
1081
- createEventSignature(e) {
1082
- return this.createEventFingerprint(e);
1083
- }
1084
- addToQueue(e) {
1085
- if (this.eventsQueue.push(e), this.emitEvent(e), this.eventsQueue.length > 100) {
1086
- const t = this.eventsQueue.findIndex(
1087
- (s) => s.type !== u.SESSION_START && s.type !== u.SESSION_END
1088
- ), r = t >= 0 ? this.eventsQueue.splice(t, 1)[0] : this.eventsQueue.shift();
1089
- a("warn", "Event queue overflow, oldest non-critical event removed", {
1090
- data: {
1091
- maxLength: 100,
1092
- currentLength: this.eventsQueue.length,
1093
- removedEventType: r?.type,
1094
- wasCritical: r?.type === u.SESSION_START || r?.type === u.SESSION_END
1095
- }
1096
- });
1097
- }
1098
- this.sendIntervalId || this.startSendInterval(), this.eventsQueue.length >= 50 && this.sendEventsQueue(), this.handleGoogleAnalyticsIntegration(e);
1099
- }
1100
- startSendInterval() {
1101
- this.sendIntervalId = window.setInterval(() => {
1102
- this.eventsQueue.length > 0 && this.sendEventsQueue();
1103
- }, 1e4);
1104
- }
1105
- handleGoogleAnalyticsIntegration(e) {
1106
- if (this.googleAnalytics && e.type === u.CUSTOM && e.custom_event) {
1107
- if (this.get("mode") === D.QA)
1108
- return;
1109
- this.googleAnalytics.trackEvent(e.custom_event.name, e.custom_event.metadata ?? {});
1110
- }
1111
- }
1112
- shouldSample() {
1113
- const e = this.get("config")?.samplingRate ?? 1;
1114
- return Math.random() < e;
1115
- }
1116
- checkRateLimit() {
1117
- const e = Date.now();
1118
- return e - this.rateLimitWindowStart > 1e3 && (this.rateLimitCounter = 0, this.rateLimitWindowStart = e), this.rateLimitCounter >= 50 ? !1 : (this.rateLimitCounter++, !0);
1119
- }
1120
- /**
1121
- * Checks per-event-name rate limiting to prevent infinite loops in user code
1122
- * Tracks timestamps per event name and limits to maxSameEventPerMinute per minute
1123
- */
1124
- checkPerEventRateLimit(e, t) {
1125
- const r = Date.now(), i = (this.perEventRateLimits.get(e) ?? []).filter((o) => r - o < 6e4);
1126
- return i.length >= t ? (a("warn", "Per-event rate limit exceeded for custom event", {
1127
- data: {
1128
- eventName: e,
1129
- limit: t,
1130
- window: `${6e4 / 1e3}s`
1131
- }
1132
- }), !1) : (i.push(r), this.perEventRateLimits.set(e, i), !0);
1133
- }
1134
- /**
1135
- * Gets the per-session limit for a specific event type (Phase 3)
1136
- */
1137
- getTypeLimitForEvent(e) {
1138
- return {
1139
- [u.CLICK]: 500,
1140
- [u.PAGE_VIEW]: 100,
1141
- [u.CUSTOM]: 500,
1142
- [u.VIEWPORT_VISIBLE]: 200,
1143
- [u.SCROLL]: 120
1144
- }[e] ?? null;
1145
- }
1146
- removeProcessedEvents(e) {
1147
- const t = new Set(e);
1148
- this.eventsQueue = this.eventsQueue.filter((r) => !t.has(r.id));
1149
- }
1150
- emitEvent(e) {
1151
- this.emitter && this.emitter.emit(Z.EVENT, e);
1152
- }
1153
- emitEventsQueue(e) {
1154
- this.emitter && this.emitter.emit(Z.QUEUE, e);
1155
- }
1156
- }
1157
- class _t {
1158
- /**
1159
- * Gets or creates a unique user ID for the given project.
1160
- * The user ID is persisted in localStorage and reused across sessions.
1161
- *
1162
- * @param storageManager - Storage manager instance
1163
- * @param projectId - Project identifier for namespacing
1164
- * @returns Persistent unique user ID
1165
- */
1166
- static getId(e) {
1167
- const t = ze, r = e.getItem(t);
1168
- if (r)
1169
- return r;
1170
- const s = nt();
1171
- return e.setItem(t, s), s;
1172
- }
1173
- }
1174
- class Tt extends S {
1175
- storageManager;
1176
- eventManager;
1177
- projectId;
1178
- sessionTimeoutId = null;
1179
- broadcastChannel = null;
1180
- activityHandler = null;
1181
- visibilityChangeHandler = null;
1182
- beforeUnloadHandler = null;
1183
- isTracking = !1;
1184
- constructor(e, t, r) {
1185
- super(), this.storageManager = e, this.eventManager = t, this.projectId = r;
1186
- }
1187
- initCrossTabSync() {
1188
- if (typeof BroadcastChannel > "u") {
1189
- a("warn", "BroadcastChannel not supported");
1190
- return;
1191
- }
1192
- const e = this.getProjectId();
1193
- this.broadcastChannel = new BroadcastChannel(Ye(e)), this.broadcastChannel.onmessage = (t) => {
1194
- const { action: r, sessionId: s, timestamp: i, projectId: o } = t.data ?? {};
1195
- if (o === e) {
1196
- if (r === "session_end") {
1197
- this.resetSessionState();
1198
- return;
1199
- }
1200
- s && typeof i == "number" && i > Date.now() - 5e3 && (this.set("sessionId", s), this.set("hasStartSession", !0), this.persistSession(s, i), this.isTracking && this.setupSessionTimeout());
1201
- }
1202
- };
1203
- }
1204
- shareSession(e) {
1205
- this.broadcastChannel && typeof this.broadcastChannel.postMessage == "function" && this.broadcastChannel.postMessage({
1206
- action: "session_start",
1207
- projectId: this.getProjectId(),
1208
- sessionId: e,
1209
- timestamp: Date.now()
1210
- });
1211
- }
1212
- broadcastSessionEnd(e, t) {
1213
- if (e && this.broadcastChannel && typeof this.broadcastChannel.postMessage == "function")
1214
- try {
1215
- this.broadcastChannel.postMessage({
1216
- action: "session_end",
1217
- projectId: this.getProjectId(),
1218
- sessionId: e,
1219
- reason: t,
1220
- timestamp: Date.now()
1221
- });
1222
- } catch (r) {
1223
- a("warn", "Failed to broadcast session end", { error: r, data: { sessionId: e, reason: t } });
1224
- }
1225
- }
1226
- cleanupCrossTabSync() {
1227
- this.broadcastChannel && (typeof this.broadcastChannel.close == "function" && this.broadcastChannel.close(), this.broadcastChannel = null);
1228
- }
1229
- recoverSession() {
1230
- const e = this.loadStoredSession();
1231
- if (!e)
1232
- return null;
1233
- const t = this.get("config")?.sessionTimeout ?? 9e5;
1234
- return Date.now() - e.lastActivity > t ? (this.clearStoredSession(), null) : e.id;
1235
- }
1236
- persistSession(e, t = Date.now()) {
1237
- this.saveStoredSession({
1238
- id: e,
1239
- lastActivity: t
1240
- });
1241
- }
1242
- clearStoredSession() {
1243
- const e = this.getSessionStorageKey();
1244
- this.storageManager.removeItem(e);
1245
- }
1246
- loadStoredSession() {
1247
- const e = this.getSessionStorageKey(), t = this.storageManager.getItem(e);
1248
- if (!t)
1249
- return null;
1250
- try {
1251
- const r = JSON.parse(t);
1252
- return !r.id || typeof r.lastActivity != "number" ? null : r;
1253
- } catch {
1254
- return this.storageManager.removeItem(e), null;
1255
- }
1256
- }
1257
- saveStoredSession(e) {
1258
- const t = this.getSessionStorageKey();
1259
- this.storageManager.setItem(t, JSON.stringify(e));
1260
- }
1261
- getSessionStorageKey() {
1262
- return je(this.getProjectId());
1263
- }
1264
- getProjectId() {
1265
- return this.projectId;
1266
- }
1267
- startTracking() {
1268
- if (this.isTracking) {
1269
- a("warn", "Session tracking already active");
1270
- return;
1271
- }
1272
- const e = this.recoverSession(), t = e ?? this.generateSessionId(), r = !!e;
1273
- this.isTracking = !0;
1274
- try {
1275
- this.set("sessionId", t), this.persistSession(t), r || this.eventManager.track({
1276
- type: u.SESSION_START
1277
- }), this.initCrossTabSync(), this.shareSession(t), this.setupSessionTimeout(), this.setupActivityListeners(), this.setupLifecycleListeners();
1278
- } catch (s) {
1279
- throw this.isTracking = !1, this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.set("sessionId", null), s;
1280
- }
1281
- }
1282
- generateSessionId() {
1283
- return `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
1284
- }
1285
- setupSessionTimeout() {
1286
- this.clearSessionTimeout();
1287
- const e = this.get("config")?.sessionTimeout ?? 9e5;
1288
- this.sessionTimeoutId = setTimeout(() => {
1289
- this.endSession("inactivity");
1290
- }, e);
1291
- }
1292
- resetSessionTimeout() {
1293
- this.setupSessionTimeout();
1294
- const e = this.get("sessionId");
1295
- e && this.persistSession(e);
1296
- }
1297
- clearSessionTimeout() {
1298
- this.sessionTimeoutId && (clearTimeout(this.sessionTimeoutId), this.sessionTimeoutId = null);
1299
- }
1300
- setupActivityListeners() {
1301
- this.activityHandler = () => {
1302
- this.resetSessionTimeout();
1303
- }, document.addEventListener("click", this.activityHandler, { passive: !0 }), document.addEventListener("keydown", this.activityHandler, { passive: !0 }), document.addEventListener("scroll", this.activityHandler, { passive: !0 });
1304
- }
1305
- cleanupActivityListeners() {
1306
- this.activityHandler && (document.removeEventListener("click", this.activityHandler), document.removeEventListener("keydown", this.activityHandler), document.removeEventListener("scroll", this.activityHandler), this.activityHandler = null);
1307
- }
1308
- setupLifecycleListeners() {
1309
- this.visibilityChangeHandler || this.beforeUnloadHandler || (this.visibilityChangeHandler = () => {
1310
- document.hidden ? this.clearSessionTimeout() : this.get("sessionId") && this.setupSessionTimeout();
1311
- }, this.beforeUnloadHandler = () => {
1312
- this.endSession("page_unload");
1313
- }, document.addEventListener("visibilitychange", this.visibilityChangeHandler), window.addEventListener("beforeunload", this.beforeUnloadHandler));
1314
- }
1315
- cleanupLifecycleListeners() {
1316
- this.visibilityChangeHandler && (document.removeEventListener("visibilitychange", this.visibilityChangeHandler), this.visibilityChangeHandler = null), this.beforeUnloadHandler && (window.removeEventListener("beforeunload", this.beforeUnloadHandler), this.beforeUnloadHandler = null);
1317
- }
1318
- endSession(e) {
1319
- const t = this.get("sessionId");
1320
- if (!t) {
1321
- a("warn", "endSession called without active session", { data: { reason: e } }), this.resetSessionState(e);
1322
- return;
1323
- }
1324
- this.eventManager.track({
1325
- type: u.SESSION_END,
1326
- session_end_reason: e
1327
- }), this.eventManager.flushImmediatelySync() || a("warn", "Sync flush failed during session end, events persisted for recovery", {
1328
- data: { reason: e, sessionId: t }
1329
- }), this.broadcastSessionEnd(t, e), this.resetSessionState(e);
1330
- }
1331
- resetSessionState(e) {
1332
- this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), e !== "page_unload" && this.clearStoredSession(), this.set("sessionId", null), this.set("hasStartSession", !1), this.isTracking = !1;
1333
- }
1334
- stopTracking() {
1335
- this.endSession("manual_stop");
1336
- }
1337
- destroy() {
1338
- this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.set("hasStartSession", !1);
1339
- }
1340
- }
1341
- class pt extends S {
1342
- eventManager;
1343
- storageManager;
1344
- sessionManager = null;
1345
- destroyed = !1;
1346
- constructor(e, t) {
1347
- super(), this.eventManager = t, this.storageManager = e;
1348
- }
1349
- startTracking() {
1350
- if (this.isActive())
1351
- return;
1352
- if (this.destroyed) {
1353
- a("warn", "Cannot start tracking on destroyed handler");
1354
- return;
1355
- }
1356
- const e = this.get("config"), t = e?.integrations?.tracelog?.projectId ?? e?.integrations?.custom?.collectApiUrl ?? "default";
1357
- if (!t)
1358
- throw new Error("Cannot start session tracking: config not available");
1359
- try {
1360
- this.sessionManager = new Tt(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
1361
- } catch (r) {
1362
- if (this.sessionManager) {
1363
- try {
1364
- this.sessionManager.destroy();
1365
- } catch {
1366
- }
1367
- this.sessionManager = null;
1368
- }
1369
- throw a("error", "Failed to start session tracking", { error: r }), r;
1370
- }
1371
- }
1372
- isActive() {
1373
- return this.sessionManager !== null && !this.destroyed;
1374
- }
1375
- cleanupSessionManager() {
1376
- this.sessionManager && (this.sessionManager.stopTracking(), this.sessionManager.destroy(), this.sessionManager = null);
1377
- }
1378
- stopTracking() {
1379
- this.cleanupSessionManager();
1380
- }
1381
- destroy() {
1382
- this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0, this.set("hasStartSession", !1));
1383
- }
1384
- }
1385
- class It extends S {
1386
- eventManager;
1387
- onTrack;
1388
- originalPushState;
1389
- originalReplaceState;
1390
- lastPageViewTime = 0;
1391
- constructor(e, t) {
1392
- super(), this.eventManager = e, this.onTrack = t;
1393
- }
1394
- startTracking() {
1395
- this.trackInitialPageView(), window.addEventListener("popstate", this.trackCurrentPage, !0), window.addEventListener("hashchange", this.trackCurrentPage, !0), this.patchHistory("pushState"), this.patchHistory("replaceState");
1396
- }
1397
- stopTracking() {
1398
- window.removeEventListener("popstate", this.trackCurrentPage, !0), window.removeEventListener("hashchange", this.trackCurrentPage, !0), this.originalPushState && (window.history.pushState = this.originalPushState), this.originalReplaceState && (window.history.replaceState = this.originalReplaceState), this.lastPageViewTime = 0;
1399
- }
1400
- patchHistory(e) {
1401
- const t = window.history[e];
1402
- e === "pushState" && !this.originalPushState ? this.originalPushState = t : e === "replaceState" && !this.originalReplaceState && (this.originalReplaceState = t), window.history[e] = (...r) => {
1403
- t.apply(window.history, r), this.trackCurrentPage();
1404
- };
1405
- }
1406
- trackCurrentPage = () => {
1407
- const e = window.location.href, t = ee(e, this.get("config").sensitiveQueryParams);
1408
- if (this.get("pageUrl") === t)
1409
- return;
1410
- const r = Date.now(), s = this.get("config").pageViewThrottleMs ?? 1e3;
1411
- if (r - this.lastPageViewTime < s)
1412
- return;
1413
- this.lastPageViewTime = r, this.onTrack();
1414
- const i = this.get("pageUrl");
1415
- this.set("pageUrl", t);
1416
- const o = this.extractPageViewData();
1417
- this.eventManager.track({
1418
- type: u.PAGE_VIEW,
1419
- page_url: this.get("pageUrl"),
1420
- from_page_url: i,
1421
- ...o && { page_view: o }
1422
- });
1423
- };
1424
- trackInitialPageView() {
1425
- const e = ee(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
1426
- this.lastPageViewTime = Date.now(), this.eventManager.track({
1427
- type: u.PAGE_VIEW,
1428
- page_url: e,
1429
- ...t && { page_view: t }
1430
- }), this.onTrack();
1431
- }
1432
- extractPageViewData() {
1433
- const { pathname: e, search: t, hash: r } = window.location, { referrer: s } = document, { title: i } = document;
1434
- return !s && !i && !e && !t && !r ? void 0 : {
1435
- ...s && { referrer: s },
1436
- ...i && { title: i },
1437
- ...e && { pathname: e },
1438
- ...t && { search: t },
1439
- ...r && { hash: r }
1440
- };
1441
- }
1442
- }
1443
- class vt extends S {
1444
- eventManager;
1445
- clickHandler;
1446
- lastClickTimes = /* @__PURE__ */ new Map();
1447
- constructor(e) {
1448
- super(), this.eventManager = e;
1449
- }
1450
- startTracking() {
1451
- this.clickHandler || (this.clickHandler = (e) => {
1452
- const t = e, r = t.target, s = typeof HTMLElement < "u" && r instanceof HTMLElement ? r : typeof HTMLElement < "u" && r instanceof Node && r.parentElement instanceof HTMLElement ? r.parentElement : null;
1453
- if (!s) {
1454
- a("warn", "Click target not found or not an element");
1455
- return;
1456
- }
1457
- if (this.shouldIgnoreElement(s))
1458
- return;
1459
- const i = this.get("config")?.clickThrottleMs ?? 300;
1460
- if (i > 0 && !this.checkClickThrottle(s, i))
1461
- return;
1462
- const o = this.findTrackingElement(s), l = this.getRelevantClickElement(s), c = this.calculateClickCoordinates(t, s);
1463
- if (o) {
1464
- const _ = this.extractTrackingData(o);
1465
- if (_) {
1466
- const g = this.createCustomEventData(_);
1467
- this.eventManager.track({
1468
- type: u.CUSTOM,
1469
- custom_event: {
1470
- name: g.name,
1471
- ...g.value && { metadata: { value: g.value } }
1472
- }
1473
- });
1474
- }
1475
- }
1476
- const d = this.generateClickData(s, l, c);
1477
- this.eventManager.track({
1478
- type: u.CLICK,
1479
- click_data: d
1480
- });
1481
- }, window.addEventListener("click", this.clickHandler, !0));
1482
- }
1483
- stopTracking() {
1484
- this.clickHandler && (window.removeEventListener("click", this.clickHandler, !0), this.clickHandler = void 0), this.lastClickTimes.clear();
1485
- }
1486
- shouldIgnoreElement(e) {
1487
- return e.hasAttribute(`${v}-ignore`) ? !0 : e.closest(`[${v}-ignore]`) !== null;
1488
- }
1489
- /**
1490
- * Checks per-element click throttling to prevent double-clicks and rapid spam
1491
- * Returns true if the click should be tracked, false if throttled
1492
- */
1493
- checkClickThrottle(e, t) {
1494
- const r = this.getElementSignature(e), s = Date.now(), i = this.lastClickTimes.get(r);
1495
- return i !== void 0 && s - i < t ? (a("debug", "ClickHandler: Click suppressed by throttle", {
1496
- data: {
1497
- signature: r,
1498
- throttleRemaining: t - (s - i)
1499
- }
1500
- }), !1) : (this.lastClickTimes.set(r, s), !0);
1501
- }
1502
- /**
1503
- * Creates a stable signature for an element to track throttling
1504
- * Priority: id > data-testid > data-tlog-name > DOM path
1505
- */
1506
- getElementSignature(e) {
1507
- if (e.id)
1508
- return `#${e.id}`;
1509
- const t = e.getAttribute("data-testid");
1510
- if (t)
1511
- return `[data-testid="${t}"]`;
1512
- const r = e.getAttribute(`${v}-name`);
1513
- return r ? `[${v}-name="${r}"]` : this.getElementPath(e);
1514
- }
1515
- /**
1516
- * Generates a DOM path for an element (e.g., "body>div>button")
1517
- */
1518
- getElementPath(e) {
1519
- const t = [];
1520
- let r = e;
1521
- for (; r && r !== document.body; ) {
1522
- let s = r.tagName.toLowerCase();
1523
- if (r.className) {
1524
- const i = r.className.split(" ")[0];
1525
- i && (s += `.${i}`);
1526
- }
1527
- t.unshift(s), r = r.parentElement;
1528
- }
1529
- return t.join(">") || "unknown";
1530
- }
1531
- findTrackingElement(e) {
1532
- return e.hasAttribute(`${v}-name`) ? e : e.closest(`[${v}-name]`);
1533
- }
1534
- getRelevantClickElement(e) {
1535
- for (const t of Ue)
1536
- try {
1537
- if (e.matches(t))
1538
- return e;
1539
- const r = e.closest(t);
1540
- if (r)
1541
- return r;
1542
- } catch (r) {
1543
- a("warn", "Invalid selector in element search", { error: r, data: { selector: t } });
1544
- continue;
1545
- }
1546
- return e;
1547
- }
1548
- clamp(e) {
1549
- return Math.max(0, Math.min(1, Number(e.toFixed(3))));
1550
- }
1551
- calculateClickCoordinates(e, t) {
1552
- const r = t.getBoundingClientRect(), s = e.clientX, i = e.clientY, o = r.width > 0 ? this.clamp((s - r.left) / r.width) : 0, l = r.height > 0 ? this.clamp((i - r.top) / r.height) : 0;
1553
- return { x: s, y: i, relativeX: o, relativeY: l };
1554
- }
1555
- extractTrackingData(e) {
1556
- const t = e.getAttribute(`${v}-name`), r = e.getAttribute(`${v}-value`);
1557
- if (t)
1558
- return {
1559
- element: e,
1560
- name: t,
1561
- ...r && { value: r }
1562
- };
1563
- }
1564
- generateClickData(e, t, r) {
1565
- const { x: s, y: i, relativeX: o, relativeY: l } = r, c = this.getRelevantText(e, t), d = this.extractElementAttributes(t);
1566
- return {
1567
- x: s,
1568
- y: i,
1569
- relativeX: o,
1570
- relativeY: l,
1571
- tag: t.tagName.toLowerCase(),
1572
- ...t.id && { id: t.id },
1573
- ...t.className && { class: t.className },
1574
- ...c && { text: c },
1575
- ...d.href && { href: d.href },
1576
- ...d.title && { title: d.title },
1577
- ...d.alt && { alt: d.alt },
1578
- ...d.role && { role: d.role },
1579
- ...d["aria-label"] && { ariaLabel: d["aria-label"] },
1580
- ...Object.keys(d).length > 0 && { dataAttributes: d }
1581
- };
1582
- }
1583
- sanitizeText(e) {
1584
- let t = e;
1585
- for (const r of le) {
1586
- const s = new RegExp(r.source, r.flags);
1587
- t = t.replace(s, "[REDACTED]");
1588
- }
1589
- return t;
1590
- }
1591
- getRelevantText(e, t) {
1592
- const r = e.textContent?.trim() ?? "", s = t.textContent?.trim() ?? "";
1593
- if (!r && !s)
1594
- return "";
1595
- let i = "";
1596
- return r && r.length <= 255 ? i = r : s.length <= 255 ? i = s : i = s.slice(0, 252) + "...", this.sanitizeText(i);
1597
- }
1598
- extractElementAttributes(e) {
1599
- const t = [
1600
- "id",
1601
- "class",
1602
- "data-testid",
1603
- "aria-label",
1604
- "title",
1605
- "href",
1606
- "type",
1607
- "name",
1608
- "alt",
1609
- "role"
1610
- ], r = {};
1611
- for (const s of t) {
1612
- const i = e.getAttribute(s);
1613
- i && (r[s] = i);
1614
- }
1615
- return r;
1616
- }
1617
- createCustomEventData(e) {
1618
- return {
1619
- name: e.name,
1620
- ...e.value && { value: e.value }
1621
- };
1622
- }
1623
- }
1624
- class At extends S {
1625
- eventManager;
1626
- containers = [];
1627
- limitWarningLogged = !1;
1628
- minDepthChange = 5;
1629
- minIntervalMs = 500;
1630
- maxEventsPerSession = 120;
1631
- windowScrollableCache = null;
1632
- retryTimeoutId = null;
1633
- constructor(e) {
1634
- super(), this.eventManager = e;
1635
- }
1636
- startTracking() {
1637
- this.limitWarningLogged = !1, this.applyConfigOverrides(), this.set("scrollEventCount", 0), this.tryDetectScrollContainers(0);
1638
- }
1639
- stopTracking() {
1640
- this.retryTimeoutId !== null && (clearTimeout(this.retryTimeoutId), this.retryTimeoutId = null);
1641
- for (const e of this.containers)
1642
- this.clearContainerTimer(e), e.element instanceof Window ? window.removeEventListener("scroll", e.listener) : e.element.removeEventListener("scroll", e.listener);
1643
- this.containers.length = 0, this.set("scrollEventCount", 0), this.limitWarningLogged = !1, this.windowScrollableCache = null;
1644
- }
1645
- tryDetectScrollContainers(e) {
1646
- const t = this.findScrollableElements();
1647
- if (t.length > 0) {
1648
- for (const r of t) {
1649
- const s = this.getElementSelector(r);
1650
- this.setupScrollContainer(r, s);
1651
- }
1652
- this.applyPrimaryScrollSelectorIfConfigured();
1653
- return;
1654
- }
1655
- if (e < 5) {
1656
- this.retryTimeoutId = window.setTimeout(() => {
1657
- this.retryTimeoutId = null, this.tryDetectScrollContainers(e + 1);
1658
- }, 200);
1659
- return;
1660
- }
1661
- this.containers.length === 0 && this.setupScrollContainer(window, "window"), this.applyPrimaryScrollSelectorIfConfigured();
1662
- }
1663
- applyPrimaryScrollSelectorIfConfigured() {
1664
- const e = this.get("config");
1665
- e?.primaryScrollSelector && this.applyPrimaryScrollSelector(e.primaryScrollSelector);
1666
- }
1667
- findScrollableElements() {
1668
- if (!document.body)
1669
- return [];
1670
- const e = [], t = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT, {
1671
- acceptNode: (s) => {
1672
- const i = s;
1673
- if (!i.isConnected || !i.offsetParent)
1674
- return NodeFilter.FILTER_SKIP;
1675
- const o = getComputedStyle(i);
1676
- return o.overflowY === "auto" || o.overflowY === "scroll" || o.overflow === "auto" || o.overflow === "scroll" ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
1677
- }
1678
- });
1679
- let r;
1680
- for (; (r = t.nextNode()) && e.length < 10; ) {
1681
- const s = r;
1682
- this.isElementScrollable(s) && e.push(s);
1683
- }
1684
- return e;
1685
- }
1686
- getElementSelector(e) {
1687
- if (e === window)
1688
- return "window";
1689
- const t = e;
1690
- if (t.id)
1691
- return `#${t.id}`;
1692
- if (t.className && typeof t.className == "string") {
1693
- const r = t.className.split(" ").filter((s) => s.trim())[0];
1694
- if (r)
1695
- return `.${r}`;
1696
- }
1697
- return t.tagName.toLowerCase();
1698
- }
1699
- determineIfPrimary(e) {
1700
- return this.isWindowScrollable() ? e === window : this.containers.length === 0;
1701
- }
1702
- setupScrollContainer(e, t) {
1703
- if (this.containers.some((d) => d.element === e) || e !== window && !this.isElementScrollable(e))
1704
- return;
1705
- const s = () => {
1706
- this.get("suppressNextScroll") || (this.clearContainerTimer(c), c.debounceTimer = window.setTimeout(() => {
1707
- const d = this.calculateScrollData(c);
1708
- if (d) {
1709
- const _ = Date.now();
1710
- this.processScrollEvent(c, d, _);
1711
- }
1712
- c.debounceTimer = null;
1713
- }, 250));
1714
- }, i = this.getScrollTop(e), o = this.calculateScrollDepth(
1715
- i,
1716
- this.getScrollHeight(e),
1717
- this.getViewportHeight(e)
1718
- ), l = this.determineIfPrimary(e), c = {
1719
- element: e,
1720
- selector: t,
1721
- isPrimary: l,
1722
- lastScrollPos: i,
1723
- lastDepth: o,
1724
- lastDirection: H.DOWN,
1725
- lastEventTime: 0,
1726
- maxDepthReached: o,
1727
- debounceTimer: null,
1728
- listener: s
1729
- };
1730
- this.containers.push(c), e instanceof Window ? window.addEventListener("scroll", s, { passive: !0 }) : e.addEventListener("scroll", s, { passive: !0 });
1731
- }
1732
- processScrollEvent(e, t, r) {
1733
- if (!this.shouldEmitScrollEvent(e, t, r))
1734
- return;
1735
- e.lastEventTime = r, e.lastDepth = t.depth, e.lastDirection = t.direction;
1736
- const s = this.get("scrollEventCount") ?? 0;
1737
- this.set("scrollEventCount", s + 1), this.eventManager.track({
1738
- type: u.SCROLL,
1739
- scroll_data: {
1740
- ...t,
1741
- container_selector: e.selector,
1742
- is_primary: e.isPrimary
1743
- }
1744
- });
1745
- }
1746
- shouldEmitScrollEvent(e, t, r) {
1747
- return this.hasReachedSessionLimit() ? (this.logLimitOnce(), !1) : !(!this.hasElapsedMinimumInterval(e, r) || !this.hasSignificantDepthChange(e, t.depth));
1748
- }
1749
- hasReachedSessionLimit() {
1750
- return (this.get("scrollEventCount") ?? 0) >= this.maxEventsPerSession;
1751
- }
1752
- hasElapsedMinimumInterval(e, t) {
1753
- return e.lastEventTime === 0 ? !0 : t - e.lastEventTime >= this.minIntervalMs;
1754
- }
1755
- hasSignificantDepthChange(e, t) {
1756
- return Math.abs(t - e.lastDepth) >= this.minDepthChange;
1757
- }
1758
- logLimitOnce() {
1759
- this.limitWarningLogged || (this.limitWarningLogged = !0, a("warn", "Max scroll events per session reached", {
1760
- data: { limit: this.maxEventsPerSession }
1761
- }));
1762
- }
1763
- applyConfigOverrides() {
1764
- this.minDepthChange = 5, this.minIntervalMs = 500, this.maxEventsPerSession = 120;
1765
- }
1766
- isWindowScrollable() {
1767
- return this.windowScrollableCache !== null ? this.windowScrollableCache : (this.windowScrollableCache = document.documentElement.scrollHeight > window.innerHeight, this.windowScrollableCache);
1768
- }
1769
- clearContainerTimer(e) {
1770
- e.debounceTimer !== null && (clearTimeout(e.debounceTimer), e.debounceTimer = null);
1771
- }
1772
- getScrollDirection(e, t) {
1773
- return e > t ? H.DOWN : H.UP;
1774
- }
1775
- calculateScrollDepth(e, t, r) {
1776
- if (t <= r)
1777
- return 0;
1778
- const s = t - r;
1779
- return Math.min(100, Math.max(0, Math.floor(e / s * 100)));
1780
- }
1781
- calculateScrollData(e) {
1782
- const { element: t, lastScrollPos: r, lastEventTime: s } = e, i = this.getScrollTop(t), o = Date.now(), l = Math.abs(i - r);
1783
- if (l < 10 || t === window && !this.isWindowScrollable())
1784
- return null;
1785
- const c = this.getViewportHeight(t), d = this.getScrollHeight(t), _ = this.getScrollDirection(i, r), g = this.calculateScrollDepth(i, d, c), L = s > 0 ? o - s : 0, m = L > 0 ? Math.round(l / L * 1e3) : 0;
1786
- return g > e.maxDepthReached && (e.maxDepthReached = g), e.lastScrollPos = i, {
1787
- depth: g,
1788
- direction: _,
1789
- velocity: m,
1790
- max_depth_reached: e.maxDepthReached
1791
- };
1792
- }
1793
- getScrollTop(e) {
1794
- return e instanceof Window ? window.scrollY : e.scrollTop;
1795
- }
1796
- getViewportHeight(e) {
1797
- return e instanceof Window ? window.innerHeight : e.clientHeight;
1798
- }
1799
- getScrollHeight(e) {
1800
- return e instanceof Window ? document.documentElement.scrollHeight : e.scrollHeight;
1801
- }
1802
- isElementScrollable(e) {
1803
- const t = getComputedStyle(e), r = t.overflowY === "auto" || t.overflowY === "scroll" || t.overflowX === "auto" || t.overflowX === "scroll" || t.overflow === "auto" || t.overflow === "scroll", s = e.scrollHeight > e.clientHeight || e.scrollWidth > e.clientWidth;
1804
- return r && s;
1805
- }
1806
- applyPrimaryScrollSelector(e) {
1807
- let t;
1808
- if (e === "window")
1809
- t = window;
1810
- else {
1811
- const s = document.querySelector(e);
1812
- if (!(s instanceof HTMLElement)) {
1813
- a("warn", `Selector "${e}" did not match an HTMLElement`);
1814
- return;
1815
- }
1816
- t = s;
1817
- }
1818
- this.containers.forEach((s) => {
1819
- this.updateContainerPrimary(s, s.element === t);
1820
- }), !this.containers.some((s) => s.element === t) && t instanceof HTMLElement && this.isElementScrollable(t) && this.setupScrollContainer(t, e);
1821
- }
1822
- updateContainerPrimary(e, t) {
1823
- e.isPrimary = t;
1824
- }
1825
- }
1826
- class wt extends S {
1827
- eventManager;
1828
- trackedElements = /* @__PURE__ */ new Map();
1829
- observer = null;
1830
- mutationObserver = null;
1831
- mutationDebounceTimer = null;
1832
- config = null;
1833
- constructor(e) {
1834
- super(), this.eventManager = e;
1835
- }
1836
- /**
1837
- * Starts tracking viewport visibility for configured elements
1838
- */
1839
- startTracking() {
1840
- const e = this.get("config");
1841
- if (this.config = e.viewport ?? null, !this.config?.elements || this.config.elements.length === 0)
1842
- return;
1843
- const t = this.config.threshold ?? 0.5, r = this.config.minDwellTime ?? 1e3;
1844
- if (t < 0 || t > 1) {
1845
- a("warn", "ViewportHandler: Invalid threshold, must be between 0 and 1");
1846
- return;
1847
- }
1848
- if (r < 0) {
1849
- a("warn", "ViewportHandler: Invalid minDwellTime, must be non-negative");
1850
- return;
1851
- }
1852
- if (typeof IntersectionObserver > "u") {
1853
- a("warn", "ViewportHandler: IntersectionObserver not supported in this browser");
1854
- return;
1855
- }
1856
- this.observer = new IntersectionObserver(this.handleIntersection, {
1857
- threshold: t
1858
- }), this.observeElements(), this.setupMutationObserver();
1859
- }
1860
- /**
1861
- * Stops tracking and cleans up resources
1862
- */
1863
- stopTracking() {
1864
- this.observer && (this.observer.disconnect(), this.observer = null), this.mutationObserver && (this.mutationObserver.disconnect(), this.mutationObserver = null), this.mutationDebounceTimer !== null && (window.clearTimeout(this.mutationDebounceTimer), this.mutationDebounceTimer = null);
1865
- for (const e of this.trackedElements.values())
1866
- e.timeoutId !== null && window.clearTimeout(e.timeoutId);
1867
- this.trackedElements.clear();
1868
- }
1869
- /**
1870
- * Query and observe all elements matching configured elements
1871
- */
1872
- observeElements() {
1873
- if (!this.config || !this.observer) return;
1874
- const e = this.config.maxTrackedElements ?? 100;
1875
- let t = this.trackedElements.size;
1876
- for (const r of this.config.elements)
1877
- try {
1878
- const s = document.querySelectorAll(r.selector);
1879
- for (const i of Array.from(s)) {
1880
- if (t >= e) {
1881
- a("warn", "ViewportHandler: Maximum tracked elements reached", {
1882
- data: {
1883
- limit: e,
1884
- selector: r.selector,
1885
- message: "Some elements will not be tracked. Consider more specific selectors."
1886
- }
1887
- });
1888
- return;
1889
- }
1890
- i.hasAttribute(`${v}-ignore`) || this.trackedElements.has(i) || (this.trackedElements.set(i, {
1891
- element: i,
1892
- selector: r.selector,
1893
- id: r.id,
1894
- name: r.name,
1895
- startTime: null,
1896
- timeoutId: null,
1897
- lastFiredTime: null
1898
- }), this.observer?.observe(i), t++);
1899
- }
1900
- } catch (s) {
1901
- a("warn", `ViewportHandler: Invalid selector "${r.selector}"`, { error: s });
1902
- }
1903
- a("debug", "ViewportHandler: Elements tracked", {
1904
- data: { count: t, limit: e }
1905
- });
1906
- }
1907
- /**
1908
- * Handles intersection events from IntersectionObserver
1909
- */
1910
- handleIntersection = (e) => {
1911
- if (!this.config) return;
1912
- const t = this.config.minDwellTime ?? 1e3;
1913
- for (const r of e) {
1914
- const s = this.trackedElements.get(r.target);
1915
- s && (r.isIntersecting ? s.startTime === null && (s.startTime = performance.now(), s.timeoutId = window.setTimeout(() => {
1916
- this.fireViewportEvent(s, r.intersectionRatio);
1917
- }, t)) : s.startTime !== null && (s.timeoutId !== null && (window.clearTimeout(s.timeoutId), s.timeoutId = null), s.startTime = null));
1918
- }
1919
- };
1920
- /**
1921
- * Fires a viewport visible event
1922
- */
1923
- fireViewportEvent(e, t) {
1924
- if (e.startTime === null) return;
1925
- const r = Math.round(performance.now() - e.startTime);
1926
- if (e.element.hasAttribute("data-tlog-ignore"))
1927
- return;
1928
- const s = this.config?.cooldownPeriod ?? 6e4, i = Date.now();
1929
- if (e.lastFiredTime !== null && i - e.lastFiredTime < s) {
1930
- a("debug", "ViewportHandler: Event suppressed by cooldown period", {
1931
- data: {
1932
- selector: e.selector,
1933
- cooldownRemaining: s - (i - e.lastFiredTime)
1934
- }
1935
- }), e.startTime = null, e.timeoutId = null;
1936
- return;
1937
- }
1938
- const o = {
1939
- selector: e.selector,
1940
- dwellTime: r,
1941
- visibilityRatio: t,
1942
- ...e.id !== void 0 && { id: e.id },
1943
- ...e.name !== void 0 && { name: e.name }
1944
- };
1945
- this.eventManager.track({
1946
- type: u.VIEWPORT_VISIBLE,
1947
- viewport_data: o
1948
- }), e.startTime = null, e.timeoutId = null, e.lastFiredTime = i;
1949
- }
1950
- /**
1951
- * Sets up MutationObserver to detect dynamically added elements
1952
- */
1953
- setupMutationObserver() {
1954
- if (!(!this.config || typeof MutationObserver > "u")) {
1955
- if (!document.body) {
1956
- a("warn", "ViewportHandler: document.body not available, skipping MutationObserver setup");
1957
- return;
1958
- }
1959
- this.mutationObserver = new MutationObserver((e) => {
1960
- let t = !1;
1961
- for (const r of e)
1962
- r.type === "childList" && (r.addedNodes.length > 0 && (t = !0), r.removedNodes.length > 0 && this.cleanupRemovedNodes(r.removedNodes));
1963
- t && (this.mutationDebounceTimer !== null && window.clearTimeout(this.mutationDebounceTimer), this.mutationDebounceTimer = window.setTimeout(() => {
1964
- this.observeElements(), this.mutationDebounceTimer = null;
1965
- }, 100));
1966
- }), this.mutationObserver.observe(document.body, {
1967
- childList: !0,
1968
- subtree: !0
1969
- });
1970
- }
1971
- }
1972
- /**
1973
- * Cleans up tracking for removed DOM nodes
1974
- */
1975
- cleanupRemovedNodes(e) {
1976
- e.forEach((t) => {
1977
- if (t.nodeType !== 1) return;
1978
- const r = t, s = this.trackedElements.get(r);
1979
- s && (s.timeoutId !== null && window.clearTimeout(s.timeoutId), this.observer?.unobserve(r), this.trackedElements.delete(r)), Array.from(this.trackedElements.keys()).filter((o) => r.contains(o)).forEach((o) => {
1980
- const l = this.trackedElements.get(o);
1981
- l && l.timeoutId !== null && window.clearTimeout(l.timeoutId), this.observer?.unobserve(o), this.trackedElements.delete(o);
1982
- });
1983
- });
1984
- }
1985
- }
1986
- class yt extends S {
1987
- isInitialized = !1;
1988
- async initialize() {
1989
- if (this.isInitialized)
1990
- return;
1991
- const e = this.get("config").integrations?.googleAnalytics?.measurementId, t = this.get("userId");
1992
- if (!(!e?.trim() || !t?.trim()))
1993
- try {
1994
- if (this.isScriptAlreadyLoaded()) {
1995
- this.isInitialized = !0;
1996
- return;
1997
- }
1998
- await this.loadScript(e), this.configureGtag(e, t), this.isInitialized = !0;
1999
- } catch (r) {
2000
- a("error", "Google Analytics initialization failed", { error: r });
2001
- }
2002
- }
2003
- trackEvent(e, t) {
2004
- if (!(!e?.trim() || !this.isInitialized || typeof window.gtag != "function"))
2005
- try {
2006
- const r = Array.isArray(t) ? { items: t } : t;
2007
- window.gtag("event", e, r);
2008
- } catch (r) {
2009
- a("error", "Google Analytics event tracking failed", { error: r });
2010
- }
2011
- }
2012
- cleanup() {
2013
- this.isInitialized = !1;
2014
- const e = document.getElementById("tracelog-ga-script");
2015
- e && e.remove();
2016
- }
2017
- isScriptAlreadyLoaded() {
2018
- return document.getElementById("tracelog-ga-script") ? !0 : !!document.querySelector('script[src*="googletagmanager.com/gtag/js"]');
2019
- }
2020
- async loadScript(e) {
2021
- return new Promise((t, r) => {
2022
- const s = document.createElement("script");
2023
- s.id = "tracelog-ga-script", s.async = !0, s.src = `https://www.googletagmanager.com/gtag/js?id=${e}`, s.onload = () => {
2024
- t();
2025
- }, s.onerror = () => {
2026
- r(new Error("Failed to load Google Analytics script"));
2027
- }, document.head.appendChild(s);
2028
- });
2029
- }
2030
- configureGtag(e, t) {
2031
- const r = document.createElement("script");
2032
- r.innerHTML = `
2033
- window.dataLayer = window.dataLayer || [];
2034
- function gtag(){dataLayer.push(arguments);}
2035
- gtag('js', new Date());
2036
- gtag('config', '${e}', {
2037
- 'user_id': '${t}'
2038
- });
2039
- `, document.head.appendChild(r);
2040
- }
2041
- }
2042
- class Lt {
2043
- storage;
2044
- sessionStorageRef;
2045
- fallbackStorage = /* @__PURE__ */ new Map();
2046
- fallbackSessionStorage = /* @__PURE__ */ new Map();
2047
- hasQuotaExceededError = !1;
2048
- constructor() {
2049
- this.storage = this.initializeStorage("localStorage"), this.sessionStorageRef = this.initializeStorage("sessionStorage"), this.storage || a("warn", "localStorage not available, using memory fallback"), this.sessionStorageRef || a("warn", "sessionStorage not available, using memory fallback");
2050
- }
2051
- /**
2052
- * Retrieves an item from storage
2053
- */
2054
- getItem(e) {
2055
- try {
2056
- return this.storage ? this.storage.getItem(e) : this.fallbackStorage.get(e) ?? null;
2057
- } catch {
2058
- return this.fallbackStorage.get(e) ?? null;
2059
- }
2060
- }
2061
- /**
2062
- * Stores an item in storage
2063
- */
2064
- setItem(e, t) {
2065
- this.fallbackStorage.set(e, t);
2066
- try {
2067
- if (this.storage) {
2068
- this.storage.setItem(e, t);
2069
- return;
2070
- }
2071
- } catch (r) {
2072
- if (r instanceof DOMException && r.name === "QuotaExceededError")
2073
- if (this.hasQuotaExceededError = !0, a("warn", "localStorage quota exceeded, attempting cleanup", {
2074
- data: { key: e, valueSize: t.length }
2075
- }), this.cleanupOldData())
2076
- try {
2077
- if (this.storage) {
2078
- this.storage.setItem(e, t);
2079
- return;
2080
- }
2081
- } catch (i) {
2082
- a("error", "localStorage quota exceeded even after cleanup - data will not persist", {
2083
- error: i,
2084
- data: { key: e, valueSize: t.length }
2085
- });
2086
- }
2087
- else
2088
- a("error", "localStorage quota exceeded and no data to cleanup - data will not persist", {
2089
- error: r,
2090
- data: { key: e, valueSize: t.length }
2091
- });
2092
- }
2093
- }
2094
- /**
2095
- * Removes an item from storage
2096
- */
2097
- removeItem(e) {
2098
- try {
2099
- this.storage && this.storage.removeItem(e);
2100
- } catch {
2101
- }
2102
- this.fallbackStorage.delete(e);
2103
- }
2104
- /**
2105
- * Clears all TracLog-related items from storage
2106
- */
2107
- clear() {
2108
- if (!this.storage) {
2109
- this.fallbackStorage.clear();
2110
- return;
2111
- }
2112
- try {
2113
- const e = [];
2114
- for (let t = 0; t < this.storage.length; t++) {
2115
- const r = this.storage.key(t);
2116
- r?.startsWith("tracelog_") && e.push(r);
2117
- }
2118
- e.forEach((t) => {
2119
- this.storage.removeItem(t);
2120
- }), this.fallbackStorage.clear();
2121
- } catch (e) {
2122
- a("error", "Failed to clear storage", { error: e }), this.fallbackStorage.clear();
2123
- }
2124
- }
2125
- /**
2126
- * Checks if storage is available
2127
- */
2128
- isAvailable() {
2129
- return this.storage !== null;
2130
- }
2131
- /**
2132
- * Checks if a QuotaExceededError has occurred
2133
- * This indicates localStorage is full and data may not persist
2134
- */
2135
- hasQuotaError() {
2136
- return this.hasQuotaExceededError;
2137
- }
2138
- /**
2139
- * Attempts to cleanup old TraceLog data from storage to free up space
2140
- * Returns true if any data was removed, false otherwise
2141
- */
2142
- cleanupOldData() {
2143
- if (!this.storage)
2144
- return !1;
2145
- try {
2146
- const e = [], t = [];
2147
- for (let i = 0; i < this.storage.length; i++) {
2148
- const o = this.storage.key(i);
2149
- o?.startsWith("tracelog_") && (e.push(o), o.startsWith("tracelog_persisted_events_") && t.push(o));
2150
- }
2151
- if (t.length > 0)
2152
- return t.forEach((i) => {
2153
- try {
2154
- this.storage.removeItem(i);
2155
- } catch {
2156
- }
2157
- }), !0;
2158
- const r = ["tracelog_session_", "tracelog_user_id", "tracelog_device_id", "tracelog_config"], s = e.filter((i) => !r.some((o) => i.startsWith(o)));
2159
- return s.length > 0 ? (s.slice(0, 5).forEach((o) => {
2160
- try {
2161
- this.storage.removeItem(o);
2162
- } catch {
2163
- }
2164
- }), !0) : !1;
2165
- } catch (e) {
2166
- return a("error", "Failed to cleanup old data", { error: e }), !1;
2167
- }
2168
- }
2169
- /**
2170
- * Initialize storage (localStorage or sessionStorage) with feature detection
2171
- */
2172
- initializeStorage(e) {
2173
- if (typeof window > "u")
2174
- return null;
2175
- try {
2176
- const t = e === "localStorage" ? window.localStorage : window.sessionStorage, r = "__tracelog_test__";
2177
- return t.setItem(r, "test"), t.removeItem(r), t;
2178
- } catch {
2179
- return null;
2180
- }
2181
- }
2182
- /**
2183
- * Retrieves an item from sessionStorage
2184
- */
2185
- getSessionItem(e) {
2186
- try {
2187
- return this.sessionStorageRef ? this.sessionStorageRef.getItem(e) : this.fallbackSessionStorage.get(e) ?? null;
2188
- } catch {
2189
- return this.fallbackSessionStorage.get(e) ?? null;
2190
- }
2191
- }
2192
- /**
2193
- * Stores an item in sessionStorage
2194
- */
2195
- setSessionItem(e, t) {
2196
- this.fallbackSessionStorage.set(e, t);
2197
- try {
2198
- if (this.sessionStorageRef) {
2199
- this.sessionStorageRef.setItem(e, t);
2200
- return;
2201
- }
2202
- } catch (r) {
2203
- r instanceof DOMException && r.name === "QuotaExceededError" && a("error", "sessionStorage quota exceeded - data will not persist", {
2204
- error: r,
2205
- data: { key: e, valueSize: t.length }
2206
- });
2207
- }
2208
- }
2209
- /**
2210
- * Removes an item from sessionStorage
2211
- */
2212
- removeSessionItem(e) {
2213
- try {
2214
- this.sessionStorageRef && this.sessionStorageRef.removeItem(e);
2215
- } catch {
2216
- }
2217
- this.fallbackSessionStorage.delete(e);
2218
- }
2219
- }
2220
- class Mt extends S {
2221
- eventManager;
2222
- reportedByNav = /* @__PURE__ */ new Map();
2223
- observers = [];
2224
- lastLongTaskSentAt = 0;
2225
- vitalThresholds = ye;
2226
- constructor(e) {
2227
- super(), this.eventManager = e;
2228
- }
2229
- async startTracking() {
2230
- await this.initWebVitals(), this.observeLongTasks();
2231
- }
2232
- stopTracking() {
2233
- this.observers.forEach((e, t) => {
2234
- try {
2235
- e.disconnect();
2236
- } catch (r) {
2237
- a("warn", "Failed to disconnect performance observer", { error: r, data: { observerIndex: t } });
2238
- }
2239
- }), this.observers.length = 0, this.reportedByNav.clear();
2240
- }
2241
- observeWebVitalsFallback() {
2242
- this.reportTTFB(), this.safeObserve(
2243
- "largest-contentful-paint",
2244
- (r) => {
2245
- const s = r.getEntries(), i = s[s.length - 1];
2246
- i && this.sendVital({ type: "LCP", value: Number(i.startTime.toFixed(2)) });
2247
- },
2248
- { type: "largest-contentful-paint", buffered: !0 },
2249
- !0
2250
- );
2251
- let e = 0, t = this.getNavigationId();
2252
- this.safeObserve(
2253
- "layout-shift",
2254
- (r) => {
2255
- const s = this.getNavigationId();
2256
- s !== t && (e = 0, t = s);
2257
- const i = r.getEntries();
2258
- for (const o of i) {
2259
- if (o.hadRecentInput === !0)
2260
- continue;
2261
- const l = typeof o.value == "number" ? o.value : 0;
2262
- e += l;
2263
- }
2264
- this.sendVital({ type: "CLS", value: Number(e.toFixed(2)) });
2265
- },
2266
- { type: "layout-shift", buffered: !0 }
2267
- ), this.safeObserve(
2268
- "paint",
2269
- (r) => {
2270
- for (const s of r.getEntries())
2271
- s.name === "first-contentful-paint" && this.sendVital({ type: "FCP", value: Number(s.startTime.toFixed(2)) });
2272
- },
2273
- { type: "paint", buffered: !0 },
2274
- !0
2275
- ), this.safeObserve(
2276
- "event",
2277
- (r) => {
2278
- let s = 0;
2279
- const i = r.getEntries();
2280
- for (const o of i) {
2281
- const l = (o.processingEnd ?? 0) - (o.startTime ?? 0);
2282
- s = Math.max(s, l);
2283
- }
2284
- s > 0 && this.sendVital({ type: "INP", value: Number(s.toFixed(2)) });
2285
- },
2286
- { type: "event", buffered: !0 }
2287
- );
2288
- }
2289
- async initWebVitals() {
2290
- try {
2291
- const { onLCP: e, onCLS: t, onFCP: r, onTTFB: s, onINP: i } = await Promise.resolve().then(() => Qt), o = (l) => (c) => {
2292
- const d = Number(c.value.toFixed(2));
2293
- this.sendVital({ type: l, value: d });
2294
- };
2295
- e(o("LCP"), { reportAllChanges: !1 }), t(o("CLS"), { reportAllChanges: !1 }), r(o("FCP"), { reportAllChanges: !1 }), s(o("TTFB"), { reportAllChanges: !1 }), i(o("INP"), { reportAllChanges: !1 });
2296
- } catch (e) {
2297
- a("warn", "Failed to load web-vitals library, using fallback", { error: e }), this.observeWebVitalsFallback();
2298
- }
2299
- }
2300
- reportTTFB() {
2301
- try {
2302
- const e = performance.getEntriesByType("navigation")[0];
2303
- if (!e)
2304
- return;
2305
- const t = e.responseStart;
2306
- typeof t == "number" && Number.isFinite(t) && this.sendVital({ type: "TTFB", value: Number(t.toFixed(2)) });
2307
- } catch (e) {
2308
- a("warn", "Failed to report TTFB", { error: e });
2309
- }
2310
- }
2311
- observeLongTasks() {
2312
- this.safeObserve(
2313
- "longtask",
2314
- (e) => {
2315
- const t = e.getEntries();
2316
- for (const r of t) {
2317
- const s = Number(r.duration.toFixed(2)), i = Date.now();
2318
- i - this.lastLongTaskSentAt >= Ke && (this.shouldSendVital("LONG_TASK", s) && this.trackWebVital("LONG_TASK", s), this.lastLongTaskSentAt = i);
2319
- }
2320
- },
2321
- { type: "longtask", buffered: !0 }
2322
- );
2323
- }
2324
- sendVital(e) {
2325
- if (!this.shouldSendVital(e.type, e.value))
2326
- return;
2327
- const t = this.getNavigationId();
2328
- if (t) {
2329
- const r = this.reportedByNav.get(t);
2330
- if (r?.has(e.type))
2331
- return;
2332
- r ? r.add(e.type) : this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type]));
2333
- }
2334
- this.trackWebVital(e.type, e.value);
2335
- }
2336
- trackWebVital(e, t) {
2337
- if (!Number.isFinite(t)) {
2338
- a("warn", "Invalid web vital value", { data: { type: e, value: t } });
2339
- return;
2340
- }
2341
- this.eventManager.track({
2342
- type: u.WEB_VITALS,
2343
- web_vitals: {
2344
- type: e,
2345
- value: t
2346
- }
2347
- });
2348
- }
2349
- getNavigationId() {
2350
- try {
2351
- const e = performance.getEntriesByType("navigation")[0];
2352
- if (!e)
2353
- return null;
2354
- const t = e.startTime || performance.now(), r = Math.random().toString(36).substr(2, 5);
2355
- return `${t.toFixed(2)}_${window.location.pathname}_${r}`;
2356
- } catch (e) {
2357
- return a("warn", "Failed to get navigation ID", { error: e }), null;
2358
- }
2359
- }
2360
- isObserverSupported(e) {
2361
- if (typeof PerformanceObserver > "u") return !1;
2362
- const t = PerformanceObserver.supportedEntryTypes;
2363
- return !t || t.includes(e);
2364
- }
2365
- safeObserve(e, t, r, s = !1) {
2366
- try {
2367
- if (!this.isObserverSupported(e))
2368
- return !1;
2369
- const i = new PerformanceObserver((o, l) => {
2370
- try {
2371
- t(o, l);
2372
- } catch (c) {
2373
- a("warn", "Observer callback failed", {
2374
- error: c,
2375
- data: { type: e }
2376
- });
2377
- }
2378
- if (s)
2379
- try {
2380
- l.disconnect();
2381
- } catch {
2382
- }
2383
- });
2384
- return i.observe(r ?? { type: e, buffered: !0 }), s || this.observers.push(i), !0;
2385
- } catch (i) {
2386
- return a("warn", "Failed to create performance observer", {
2387
- error: i,
2388
- data: { type: e }
2389
- }), !1;
2390
- }
2391
- }
2392
- shouldSendVital(e, t) {
2393
- if (typeof t != "number" || !Number.isFinite(t))
2394
- return a("warn", "Invalid web vital value", { data: { type: e, value: t } }), !1;
2395
- const r = this.vitalThresholds[e];
2396
- return !(typeof r == "number" && t <= r);
2397
- }
2398
- }
2399
- class Nt extends S {
2400
- eventManager;
2401
- recentErrors = /* @__PURE__ */ new Map();
2402
- errorBurstCounter = 0;
2403
- burstWindowStart = 0;
2404
- burstBackoffUntil = 0;
2405
- constructor(e) {
2406
- super(), this.eventManager = e;
2407
- }
2408
- startTracking() {
2409
- window.addEventListener("error", this.handleError), window.addEventListener("unhandledrejection", this.handleRejection);
2410
- }
2411
- stopTracking() {
2412
- window.removeEventListener("error", this.handleError), window.removeEventListener("unhandledrejection", this.handleRejection), this.recentErrors.clear(), this.errorBurstCounter = 0, this.burstWindowStart = 0, this.burstBackoffUntil = 0;
2413
- }
2414
- /**
2415
- * Checks sampling rate and burst detection (Phase 3)
2416
- * Returns false if in cooldown period after burst detection
2417
- */
2418
- shouldSample() {
2419
- const e = Date.now();
2420
- if (e < this.burstBackoffUntil)
2421
- return !1;
2422
- if (e - this.burstWindowStart > Ze && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > Je)
2423
- return this.burstBackoffUntil = e + me, a("warn", "Error burst detected - entering cooldown", {
2424
- data: {
2425
- errorsInWindow: this.errorBurstCounter,
2426
- cooldownMs: me
2427
- }
2428
- }), !1;
2429
- const r = this.get("config")?.errorSampling ?? Le;
2430
- return Math.random() < r;
2431
- }
2432
- handleError = (e) => {
2433
- if (!this.shouldSample())
2434
- return;
2435
- const t = this.sanitize(e.message || "Unknown error");
2436
- this.shouldSuppressError(P.JS_ERROR, t) || this.eventManager.track({
2437
- type: u.ERROR,
2438
- error_data: {
2439
- type: P.JS_ERROR,
2440
- message: t,
2441
- ...e.filename && { filename: e.filename },
2442
- ...e.lineno && { line: e.lineno },
2443
- ...e.colno && { column: e.colno }
2444
- }
2445
- });
2446
- };
2447
- handleRejection = (e) => {
2448
- if (!this.shouldSample())
2449
- return;
2450
- const t = this.extractRejectionMessage(e.reason), r = this.sanitize(t);
2451
- this.shouldSuppressError(P.PROMISE_REJECTION, r) || this.eventManager.track({
2452
- type: u.ERROR,
2453
- error_data: {
2454
- type: P.PROMISE_REJECTION,
2455
- message: r
2456
- }
2457
- });
2458
- };
2459
- extractRejectionMessage(e) {
2460
- if (!e) return "Unknown rejection";
2461
- if (typeof e == "string") return e;
2462
- if (e instanceof Error)
2463
- return e.stack ?? e.message ?? e.toString();
2464
- if (typeof e == "object" && "message" in e)
2465
- return String(e.message);
2466
- try {
2467
- return JSON.stringify(e);
2468
- } catch {
2469
- return String(e);
2470
- }
2471
- }
2472
- sanitize(e) {
2473
- let t = e.length > Ee ? e.slice(0, Ee) + "..." : e;
2474
- for (const r of le) {
2475
- const s = new RegExp(r.source, r.flags);
2476
- t = t.replace(s, "[REDACTED]");
2477
- }
2478
- return t;
2479
- }
2480
- shouldSuppressError(e, t) {
2481
- const r = Date.now(), s = `${e}:${t}`, i = this.recentErrors.get(s);
2482
- return i && r - i < ge ? (this.recentErrors.set(s, r), !0) : (this.recentErrors.set(s, r), this.recentErrors.size > qe ? (this.recentErrors.clear(), this.recentErrors.set(s, r), !1) : (this.recentErrors.size > x && this.pruneOldErrors(), !1));
2483
- }
2484
- pruneOldErrors() {
2485
- const e = Date.now();
2486
- for (const [s, i] of this.recentErrors.entries())
2487
- e - i > ge && this.recentErrors.delete(s);
2488
- if (this.recentErrors.size <= x)
2489
- return;
2490
- const t = Array.from(this.recentErrors.entries()).sort((s, i) => s[1] - i[1]), r = this.recentErrors.size - x;
2491
- for (let s = 0; s < r; s += 1) {
2492
- const i = t[s];
2493
- i && this.recentErrors.delete(i[0]);
2494
- }
2495
- }
2496
- }
2497
- class Rt extends S {
2498
- isInitialized = !1;
2499
- suppressNextScrollTimer = null;
2500
- emitter = new gt();
2501
- managers = {};
2502
- handlers = {};
2503
- integrations = {};
2504
- get initialized() {
2505
- return this.isInitialized;
2506
- }
2507
- async init(e = {}) {
2508
- if (!this.isInitialized) {
2509
- this.managers.storage = new Lt();
2510
- try {
2511
- this.setupState(e), await this.setupIntegrations(), this.managers.event = new St(this.managers.storage, this.integrations.googleAnalytics, this.emitter), this.initializeHandlers(), await this.managers.event.recoverPersistedEvents().catch((t) => {
2512
- a("warn", "Failed to recover persisted events", { error: t });
2513
- }), this.isInitialized = !0;
2514
- } catch (t) {
2515
- this.destroy(!0);
2516
- const r = t instanceof Error ? t.message : String(t);
2517
- throw new Error(`[TraceLog] TraceLog initialization failed: ${r}`);
2518
- }
2519
- }
2520
- }
2521
- sendCustomEvent(e, t) {
2522
- if (!this.managers.event)
2523
- return;
2524
- const { valid: r, error: s, sanitizedMetadata: i } = Et(e, t);
2525
- if (!r) {
2526
- if (this.get("mode") === D.QA)
2527
- throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${s}`);
2528
- return;
2529
- }
2530
- this.managers.event.track({
2531
- type: u.CUSTOM,
2532
- custom_event: {
2533
- name: e,
2534
- ...i && { metadata: i }
2535
- }
2536
- });
2537
- }
2538
- on(e, t) {
2539
- this.emitter.on(e, t);
2540
- }
2541
- off(e, t) {
2542
- this.emitter.off(e, t);
2543
- }
2544
- destroy(e = !1) {
2545
- !this.isInitialized && !e || (this.integrations.googleAnalytics?.cleanup(), Object.values(this.handlers).filter(Boolean).forEach((t) => {
2546
- try {
2547
- t.stopTracking();
2548
- } catch (r) {
2549
- a("warn", "Failed to stop tracking", { error: r });
2550
- }
2551
- }), this.suppressNextScrollTimer && (clearTimeout(this.suppressNextScrollTimer), this.suppressNextScrollTimer = null), this.managers.event?.flushImmediatelySync(), this.managers.event?.stop(), this.emitter.removeAllListeners(), this.set("hasStartSession", !1), this.set("suppressNextScroll", !1), this.set("sessionId", null), this.isInitialized = !1, this.handlers = {});
2552
- }
2553
- setupState(e = {}) {
2554
- this.set("config", e);
2555
- const t = _t.getId(this.managers.storage);
2556
- this.set("userId", t);
2557
- const r = it(e);
2558
- this.set("collectApiUrl", r);
2559
- const s = $e();
2560
- this.set("device", s);
2561
- const i = ee(window.location.href, e.sensitiveQueryParams);
2562
- this.set("pageUrl", i);
2563
- const o = rt() ? D.QA : void 0;
2564
- o && this.set("mode", o);
2565
- }
2566
- async setupIntegrations() {
2567
- if (this.get("config").integrations?.googleAnalytics?.measurementId?.trim())
2568
- try {
2569
- this.integrations.googleAnalytics = new yt(), await this.integrations.googleAnalytics.initialize();
2570
- } catch {
2571
- this.integrations.googleAnalytics = void 0;
2572
- }
2573
- }
2574
- initializeHandlers() {
2575
- this.handlers.session = new pt(
2576
- this.managers.storage,
2577
- this.managers.event
2578
- ), this.handlers.session.startTracking();
2579
- const e = () => {
2580
- this.set("suppressNextScroll", !0), this.suppressNextScrollTimer && clearTimeout(this.suppressNextScrollTimer), this.suppressNextScrollTimer = window.setTimeout(() => {
2581
- this.set("suppressNextScroll", !1);
2582
- }, 500);
2583
- };
2584
- this.handlers.pageView = new It(this.managers.event, e), this.handlers.pageView.startTracking(), this.handlers.click = new vt(this.managers.event), this.handlers.click.startTracking(), this.handlers.scroll = new At(this.managers.event), this.handlers.scroll.startTracking(), this.handlers.performance = new Mt(this.managers.event), this.handlers.performance.startTracking().catch((t) => {
2585
- a("warn", "Failed to start performance tracking", { error: t });
2586
- }), this.handlers.error = new Nt(this.managers.event), this.handlers.error.startTracking(), this.get("config").viewport && (this.handlers.viewport = new wt(this.managers.event), this.handlers.viewport.startTracking());
2587
- }
2588
- }
2589
- const N = [];
2590
- let E = null, C = !1, F = !1;
2591
- const Ot = async (n) => {
2592
- if (!(typeof window > "u" || typeof document > "u") && !window.__traceLogDisabled && !E && !C) {
2593
- C = !0;
2594
- try {
2595
- const e = ut(n ?? {}), t = new Rt();
2596
- try {
2597
- N.forEach(({ event: i, callback: o }) => {
2598
- t.on(i, o);
2599
- }), N.length = 0;
2600
- const r = t.init(e), s = new Promise((i, o) => {
2601
- setTimeout(() => {
2602
- o(new Error("[TraceLog] Initialization timeout after 10000ms"));
2603
- }, 1e4);
2604
- });
2605
- await Promise.race([r, s]), E = t;
2606
- } catch (r) {
2607
- try {
2608
- t.destroy(!0);
2609
- } catch (s) {
2610
- a("error", "Failed to cleanup partially initialized app", { error: s });
2611
- }
2612
- throw r;
2613
- }
2614
- } catch (e) {
2615
- throw E = null, e;
2616
- } finally {
2617
- C = !1;
2618
- }
2619
- }
2620
- }, Ct = (n, e) => {
2621
- if (!(typeof window > "u" || typeof document > "u")) {
2622
- if (!E)
2623
- throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
2624
- if (F)
2625
- throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
2626
- E.sendCustomEvent(n, e);
2627
- }
2628
- }, bt = (n, e) => {
2629
- if (!(typeof window > "u" || typeof document > "u")) {
2630
- if (!E || C) {
2631
- N.push({ event: n, callback: e });
2632
- return;
2633
- }
2634
- E.on(n, e);
2635
- }
2636
- }, Pt = (n, e) => {
2637
- if (!(typeof window > "u" || typeof document > "u")) {
2638
- if (!E) {
2639
- const t = N.findIndex((r) => r.event === n && r.callback === e);
2640
- t !== -1 && N.splice(t, 1);
2641
- return;
2642
- }
2643
- E.off(n, e);
2644
- }
2645
- }, Dt = () => typeof window > "u" || typeof document > "u" ? !1 : E !== null, Vt = () => {
2646
- if (!(typeof window > "u" || typeof document > "u")) {
2647
- if (F)
2648
- throw new Error("[TraceLog] Destroy operation already in progress");
2649
- if (!E)
2650
- throw new Error("[TraceLog] App not initialized");
2651
- F = !0;
2652
- try {
2653
- E.destroy(), E = null, C = !1, N.length = 0;
2654
- } catch (n) {
2655
- E = null, C = !1, N.length = 0, a("warn", "Error during destroy, forced cleanup completed", { error: n });
2656
- } finally {
2657
- F = !1;
2658
- }
2659
- }
2660
- }, or = {
2661
- WEB_VITALS_THRESHOLDS: ye
2662
- // Business thresholds for performance analysis
2663
- }, ar = {
2664
- PII_PATTERNS: le
2665
- // Patterns for sensitive data protection
2666
- }, lr = {
2667
- LOW_ACTIVITY_EVENT_COUNT: 50,
2668
- HIGH_ACTIVITY_EVENT_COUNT: 1e3,
2669
- MIN_EVENTS_FOR_DYNAMIC_CALCULATION: 100,
2670
- MIN_EVENTS_FOR_TREND_ANALYSIS: 30,
2671
- BOUNCE_RATE_SESSION_THRESHOLD: 1,
2672
- // Sessions with 1 page view = bounce
2673
- MIN_ENGAGED_SESSION_DURATION_MS: 30 * 1e3,
2674
- MIN_SCROLL_DEPTH_ENGAGEMENT: 25
2675
- // 25% scroll depth for engagement
2676
- }, cr = {
2677
- INACTIVITY_TIMEOUT_MS: 1800 * 1e3,
2678
- // 30min for analytics (vs 15min client)
2679
- SHORT_SESSION_THRESHOLD_MS: 30 * 1e3,
2680
- MEDIUM_SESSION_THRESHOLD_MS: 300 * 1e3,
2681
- LONG_SESSION_THRESHOLD_MS: 1800 * 1e3,
2682
- MAX_REALISTIC_SESSION_DURATION_MS: 480 * 60 * 1e3
2683
- // Filter outliers
2684
- }, ur = {
2685
- MOBILE_MAX_WIDTH: 768,
2686
- TABLET_MAX_WIDTH: 1024,
2687
- MOBILE_PERFORMANCE_FACTOR: 1.5,
2688
- // Mobile typically 1.5x slower
2689
- TABLET_PERFORMANCE_FACTOR: 1.2
2690
- }, dr = {
2691
- MIN_TEXT_LENGTH_FOR_ANALYSIS: 10,
2692
- MIN_CLICKS_FOR_HOT_ELEMENT: 10,
2693
- // Popular element threshold
2694
- MIN_SCROLL_COMPLETION_PERCENT: 80,
2695
- // Page consumption threshold
2696
- MIN_TIME_ON_PAGE_FOR_READ_MS: 15 * 1e3
2697
- }, hr = {
2698
- SIGNIFICANT_CHANGE_PERCENT: 20,
2699
- MAJOR_CHANGE_PERCENT: 50,
2700
- MIN_EVENTS_FOR_INSIGHT: 100,
2701
- MIN_SESSIONS_FOR_INSIGHT: 10,
2702
- MIN_CORRELATION_STRENGTH: 0.7,
2703
- // Strong correlation threshold
2704
- LOW_ERROR_RATE_PERCENT: 1,
2705
- HIGH_ERROR_RATE_PERCENT: 5,
2706
- CRITICAL_ERROR_RATE_PERCENT: 10
2707
- }, fr = {
2708
- SHORT_TERM_TREND_HOURS: 24,
2709
- MEDIUM_TERM_TREND_DAYS: 7,
2710
- LONG_TERM_TREND_DAYS: 30,
2711
- MIN_DATA_POINTS_FOR_TREND: 5,
2712
- WEEKLY_PATTERN_MIN_WEEKS: 4,
2713
- DAILY_PATTERN_MIN_DAYS: 14
2714
- }, Er = {
2715
- MIN_SEGMENT_SIZE: 10,
2716
- MIN_COHORT_SIZE: 5,
2717
- COHORT_ANALYSIS_DAYS: [1, 3, 7, 14, 30],
2718
- MIN_FUNNEL_EVENTS: 20
2719
- }, gr = {
2720
- DEFAULT_EVENTS_LIMIT: 5,
2721
- DEFAULT_SESSIONS_LIMIT: 5,
2722
- DEFAULT_PAGES_LIMIT: 5,
2723
- MAX_EVENTS_FOR_DEEP_ANALYSIS: 1e4,
2724
- MAX_TIME_RANGE_DAYS: 365,
2725
- ANALYTICS_BATCH_SIZE: 1e3
2726
- // For historical analysis
2727
- }, mr = {
2728
- ANOMALY_THRESHOLD_SIGMA: 2.5,
2729
- STRONG_ANOMALY_THRESHOLD_SIGMA: 3,
2730
- TRAFFIC_DROP_ALERT_PERCENT: -30,
2731
- TRAFFIC_SPIKE_ALERT_PERCENT: 200,
2732
- MIN_BASELINE_DAYS: 7,
2733
- MIN_EVENTS_FOR_ANOMALY_DETECTION: 50
2734
- }, Sr = {
2735
- PAGE_URL_EXCLUDED: "excluded",
2736
- PAGE_URL_UNKNOWN: "unknown"
2737
- }, _r = {
2738
- init: Ot,
2739
- event: Ct,
2740
- on: bt,
2741
- off: Pt,
2742
- isInitialized: Dt,
2743
- destroy: Vt
2744
- };
2745
- var re, Ne = -1, b = function(n) {
2746
- addEventListener("pageshow", (function(e) {
2747
- e.persisted && (Ne = e.timeStamp, n(e));
2748
- }), !0);
2749
- }, ce = function() {
2750
- var n = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
2751
- if (n && n.responseStart > 0 && n.responseStart < performance.now()) return n;
2752
- }, B = function() {
2753
- var n = ce();
2754
- return n && n.activationStart || 0;
2755
- }, p = function(n, e) {
2756
- var t = ce(), r = "navigate";
2757
- return Ne >= 0 ? r = "back-forward-cache" : t && (document.prerendering || B() > 0 ? r = "prerender" : document.wasDiscarded ? r = "restore" : t.type && (r = t.type.replace(/_/g, "-"))), { name: n, value: e === void 0 ? -1 : e, rating: "good", delta: 0, entries: [], id: "v4-".concat(Date.now(), "-").concat(Math.floor(8999999999999 * Math.random()) + 1e12), navigationType: r };
2758
- }, k = function(n, e, t) {
2759
- try {
2760
- if (PerformanceObserver.supportedEntryTypes.includes(n)) {
2761
- var r = new PerformanceObserver((function(s) {
2762
- Promise.resolve().then((function() {
2763
- e(s.getEntries());
2764
- }));
2765
- }));
2766
- return r.observe(Object.assign({ type: n, buffered: !0 }, t || {})), r;
2767
- }
2768
- } catch {
2769
- }
2770
- }, I = function(n, e, t, r) {
2771
- var s, i;
2772
- return function(o) {
2773
- e.value >= 0 && (o || r) && ((i = e.value - (s || 0)) || s === void 0) && (s = e.value, e.delta = i, e.rating = (function(l, c) {
2774
- return l > c[1] ? "poor" : l > c[0] ? "needs-improvement" : "good";
2775
- })(e.value, t), n(e));
2776
- };
2777
- }, ue = function(n) {
2778
- requestAnimationFrame((function() {
2779
- return requestAnimationFrame((function() {
2780
- return n();
2781
- }));
2782
- }));
2783
- }, X = function(n) {
2784
- document.addEventListener("visibilitychange", (function() {
2785
- document.visibilityState === "hidden" && n();
2786
- }));
2787
- }, de = function(n) {
2788
- var e = !1;
2789
- return function() {
2790
- e || (n(), e = !0);
2791
- };
2792
- }, O = -1, ve = function() {
2793
- return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
2794
- }, W = function(n) {
2795
- document.visibilityState === "hidden" && O > -1 && (O = n.type === "visibilitychange" ? n.timeStamp : 0, kt());
2796
- }, Ae = function() {
2797
- addEventListener("visibilitychange", W, !0), addEventListener("prerenderingchange", W, !0);
2798
- }, kt = function() {
2799
- removeEventListener("visibilitychange", W, !0), removeEventListener("prerenderingchange", W, !0);
2800
- }, Re = function() {
2801
- return O < 0 && (O = ve(), Ae(), b((function() {
2802
- setTimeout((function() {
2803
- O = ve(), Ae();
2804
- }), 0);
2805
- }))), { get firstHiddenTime() {
2806
- return O;
2807
- } };
2808
- }, $ = function(n) {
2809
- document.prerendering ? addEventListener("prerenderingchange", (function() {
2810
- return n();
2811
- }), !0) : n();
2812
- }, ne = [1800, 3e3], Oe = function(n, e) {
2813
- e = e || {}, $((function() {
2814
- var t, r = Re(), s = p("FCP"), i = k("paint", (function(o) {
2815
- o.forEach((function(l) {
2816
- l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (s.value = Math.max(l.startTime - B(), 0), s.entries.push(l), t(!0)));
2817
- }));
2818
- }));
2819
- i && (t = I(n, s, ne, e.reportAllChanges), b((function(o) {
2820
- s = p("FCP"), t = I(n, s, ne, e.reportAllChanges), ue((function() {
2821
- s.value = performance.now() - o.timeStamp, t(!0);
2822
- }));
2823
- })));
2824
- }));
2825
- }, se = [0.1, 0.25], Ut = function(n, e) {
2826
- e = e || {}, Oe(de((function() {
2827
- var t, r = p("CLS", 0), s = 0, i = [], o = function(c) {
2828
- c.forEach((function(d) {
2829
- if (!d.hadRecentInput) {
2830
- var _ = i[0], g = i[i.length - 1];
2831
- s && d.startTime - g.startTime < 1e3 && d.startTime - _.startTime < 5e3 ? (s += d.value, i.push(d)) : (s = d.value, i = [d]);
2832
- }
2833
- })), s > r.value && (r.value = s, r.entries = i, t());
2834
- }, l = k("layout-shift", o);
2835
- l && (t = I(n, r, se, e.reportAllChanges), X((function() {
2836
- o(l.takeRecords()), t(!0);
2837
- })), b((function() {
2838
- s = 0, r = p("CLS", 0), t = I(n, r, se, e.reportAllChanges), ue((function() {
2839
- return t();
2840
- }));
2841
- })), setTimeout(t, 0));
2842
- })));
2843
- }, Ce = 0, Y = 1 / 0, U = 0, Ht = function(n) {
2844
- n.forEach((function(e) {
2845
- e.interactionId && (Y = Math.min(Y, e.interactionId), U = Math.max(U, e.interactionId), Ce = U ? (U - Y) / 7 + 1 : 0);
2846
- }));
2847
- }, be = function() {
2848
- return re ? Ce : performance.interactionCount || 0;
2849
- }, xt = function() {
2850
- "interactionCount" in performance || re || (re = k("event", Ht, { type: "event", buffered: !0, durationThreshold: 0 }));
2851
- }, T = [], G = /* @__PURE__ */ new Map(), Pe = 0, Ft = function() {
2852
- var n = Math.min(T.length - 1, Math.floor((be() - Pe) / 50));
2853
- return T[n];
2854
- }, Gt = [], Wt = function(n) {
2855
- if (Gt.forEach((function(s) {
2856
- return s(n);
2857
- })), n.interactionId || n.entryType === "first-input") {
2858
- var e = T[T.length - 1], t = G.get(n.interactionId);
2859
- if (t || T.length < 10 || n.duration > e.latency) {
2860
- if (t) n.duration > t.latency ? (t.entries = [n], t.latency = n.duration) : n.duration === t.latency && n.startTime === t.entries[0].startTime && t.entries.push(n);
2861
- else {
2862
- var r = { id: n.interactionId, latency: n.duration, entries: [n] };
2863
- G.set(r.id, r), T.push(r);
2864
- }
2865
- T.sort((function(s, i) {
2866
- return i.latency - s.latency;
2867
- })), T.length > 10 && T.splice(10).forEach((function(s) {
2868
- return G.delete(s.id);
2869
- }));
2870
- }
2871
- }
2872
- }, De = function(n) {
2873
- var e = self.requestIdleCallback || self.setTimeout, t = -1;
2874
- return n = de(n), document.visibilityState === "hidden" ? n() : (t = e(n), X(n)), t;
2875
- }, ie = [200, 500], Bt = function(n, e) {
2876
- "PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, $((function() {
2877
- var t;
2878
- xt();
2879
- var r, s = p("INP"), i = function(l) {
2880
- De((function() {
2881
- l.forEach(Wt);
2882
- var c = Ft();
2883
- c && c.latency !== s.value && (s.value = c.latency, s.entries = c.entries, r());
2884
- }));
2885
- }, o = k("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
2886
- r = I(n, s, ie, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), X((function() {
2887
- i(o.takeRecords()), r(!0);
2888
- })), b((function() {
2889
- Pe = be(), T.length = 0, G.clear(), s = p("INP"), r = I(n, s, ie, e.reportAllChanges);
2890
- })));
2891
- })));
2892
- }, oe = [2500, 4e3], K = {}, Xt = function(n, e) {
2893
- e = e || {}, $((function() {
2894
- var t, r = Re(), s = p("LCP"), i = function(c) {
2895
- e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(d) {
2896
- d.startTime < r.firstHiddenTime && (s.value = Math.max(d.startTime - B(), 0), s.entries = [d], t());
2897
- }));
2898
- }, o = k("largest-contentful-paint", i);
2899
- if (o) {
2900
- t = I(n, s, oe, e.reportAllChanges);
2901
- var l = de((function() {
2902
- K[s.id] || (i(o.takeRecords()), o.disconnect(), K[s.id] = !0, t(!0));
2903
- }));
2904
- ["keydown", "click"].forEach((function(c) {
2905
- addEventListener(c, (function() {
2906
- return De(l);
2907
- }), { once: !0, capture: !0 });
2908
- })), X(l), b((function(c) {
2909
- s = p("LCP"), t = I(n, s, oe, e.reportAllChanges), ue((function() {
2910
- s.value = performance.now() - c.timeStamp, K[s.id] = !0, t(!0);
2911
- }));
2912
- }));
2913
- }
2914
- }));
2915
- }, ae = [800, 1800], $t = function n(e) {
2916
- document.prerendering ? $((function() {
2917
- return n(e);
2918
- })) : document.readyState !== "complete" ? addEventListener("load", (function() {
2919
- return n(e);
2920
- }), !0) : setTimeout(e, 0);
2921
- }, zt = function(n, e) {
2922
- e = e || {};
2923
- var t = p("TTFB"), r = I(n, t, ae, e.reportAllChanges);
2924
- $t((function() {
2925
- var s = ce();
2926
- s && (t.value = Math.max(s.responseStart - B(), 0), t.entries = [s], r(!0), b((function() {
2927
- t = p("TTFB", 0), (r = I(n, t, ae, e.reportAllChanges))(!0);
2928
- })));
2929
- }));
2930
- };
2931
- const Qt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2932
- __proto__: null,
2933
- CLSThresholds: se,
2934
- FCPThresholds: ne,
2935
- INPThresholds: ie,
2936
- LCPThresholds: oe,
2937
- TTFBThresholds: ae,
2938
- onCLS: Ut,
2939
- onFCP: Oe,
2940
- onINP: Bt,
2941
- onLCP: Xt,
2942
- onTTFB: zt
2943
- }, Symbol.toStringTag, { value: "Module" }));
2944
- export {
2945
- gr as ANALYTICS_QUERY_LIMITS,
2946
- mr as ANOMALY_DETECTION,
2947
- f as AppConfigValidationError,
2948
- dr as CONTENT_ANALYTICS,
2949
- ar as DATA_PROTECTION,
2950
- ur as DEVICE_ANALYTICS,
2951
- w as DeviceType,
2952
- lr as ENGAGEMENT_THRESHOLDS,
2953
- Z as EmitterEvent,
2954
- P as ErrorType,
2955
- u as EventType,
2956
- hr as INSIGHT_THRESHOLDS,
2957
- ir as InitializationTimeoutError,
2958
- M as IntegrationValidationError,
2959
- rr as MAX_ARRAY_LENGTH,
2960
- qt as MAX_CUSTOM_EVENT_ARRAY_SIZE,
2961
- Kt as MAX_CUSTOM_EVENT_KEYS,
2962
- jt as MAX_CUSTOM_EVENT_NAME_LENGTH,
2963
- Yt as MAX_CUSTOM_EVENT_STRING_SIZE,
2964
- Jt as MAX_METADATA_NESTING_DEPTH,
2965
- Zt as MAX_NESTED_OBJECT_KEYS,
2966
- er as MAX_STRING_LENGTH,
2967
- tr as MAX_STRING_LENGTH_IN_ARRAY,
2968
- D as Mode,
2969
- or as PERFORMANCE_CONFIG,
2970
- R as PermanentError,
2971
- Er as SEGMENTATION_ANALYTICS,
2972
- cr as SESSION_ANALYTICS,
2973
- Sr as SPECIAL_PAGE_URLS,
2974
- he as SamplingRateValidationError,
2975
- H as ScrollDirection,
2976
- Ge as SessionTimeoutValidationError,
2977
- q as SpecialApiUrl,
2978
- fr as TEMPORAL_ANALYSIS,
2979
- V as TraceLogValidationError,
2980
- nr as isPrimaryScrollEvent,
2981
- sr as isSecondaryScrollEvent,
2982
- _r as tracelog
2983
- };