@tracelog/lib 0.0.1

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 (301) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +217 -0
  3. package/dist/browser/tracelog.js +4040 -0
  4. package/dist/browser/web-vitals-CCnqwnC8.mjs +198 -0
  5. package/dist/cjs/api.d.ts +46 -0
  6. package/dist/cjs/api.js +224 -0
  7. package/dist/cjs/app.constants.d.ts +1 -0
  8. package/dist/cjs/app.constants.js +5 -0
  9. package/dist/cjs/app.d.ts +59 -0
  10. package/dist/cjs/app.js +272 -0
  11. package/dist/cjs/app.types.d.ts +6 -0
  12. package/dist/cjs/app.types.js +22 -0
  13. package/dist/cjs/constants/api.constants.d.ts +4 -0
  14. package/dist/cjs/constants/api.constants.js +18 -0
  15. package/dist/cjs/constants/browser.constants.d.ts +3 -0
  16. package/dist/cjs/constants/browser.constants.js +41 -0
  17. package/dist/cjs/constants/index.d.ts +8 -0
  18. package/dist/cjs/constants/index.js +24 -0
  19. package/dist/cjs/constants/initialization.constants.d.ts +40 -0
  20. package/dist/cjs/constants/initialization.constants.js +48 -0
  21. package/dist/cjs/constants/limits.constants.d.ts +25 -0
  22. package/dist/cjs/constants/limits.constants.js +40 -0
  23. package/dist/cjs/constants/security.constants.d.ts +1 -0
  24. package/dist/cjs/constants/security.constants.js +12 -0
  25. package/dist/cjs/constants/storage.constants.d.ts +9 -0
  26. package/dist/cjs/constants/storage.constants.js +22 -0
  27. package/dist/cjs/constants/timing.constants.d.ts +22 -0
  28. package/dist/cjs/constants/timing.constants.js +34 -0
  29. package/dist/cjs/constants/validation.constants.d.ts +13 -0
  30. package/dist/cjs/constants/validation.constants.js +31 -0
  31. package/dist/cjs/handlers/click.handler.d.ts +17 -0
  32. package/dist/cjs/handlers/click.handler.js +199 -0
  33. package/dist/cjs/handlers/error.handler.d.ts +15 -0
  34. package/dist/cjs/handlers/error.handler.js +97 -0
  35. package/dist/cjs/handlers/network.handler.d.ts +16 -0
  36. package/dist/cjs/handlers/network.handler.js +136 -0
  37. package/dist/cjs/handlers/page-view.handler.d.ts +15 -0
  38. package/dist/cjs/handlers/page-view.handler.js +83 -0
  39. package/dist/cjs/handlers/performance.handler.d.ts +19 -0
  40. package/dist/cjs/handlers/performance.handler.js +255 -0
  41. package/dist/cjs/handlers/scroll.handler.d.ts +16 -0
  42. package/dist/cjs/handlers/scroll.handler.js +138 -0
  43. package/dist/cjs/handlers/session.handler.d.ts +29 -0
  44. package/dist/cjs/handlers/session.handler.js +357 -0
  45. package/dist/cjs/integrations/google-analytics.integration.d.ts +18 -0
  46. package/dist/cjs/integrations/google-analytics.integration.js +159 -0
  47. package/dist/cjs/listeners/activity-listener-manager.d.ts +8 -0
  48. package/dist/cjs/listeners/activity-listener-manager.js +32 -0
  49. package/dist/cjs/listeners/index.d.ts +6 -0
  50. package/dist/cjs/listeners/index.js +14 -0
  51. package/dist/cjs/listeners/input-listener-managers.d.ts +15 -0
  52. package/dist/cjs/listeners/input-listener-managers.js +58 -0
  53. package/dist/cjs/listeners/listeners.types.d.ts +4 -0
  54. package/dist/cjs/listeners/listeners.types.js +2 -0
  55. package/dist/cjs/listeners/touch-listener-manager.d.ts +10 -0
  56. package/dist/cjs/listeners/touch-listener-manager.js +56 -0
  57. package/dist/cjs/listeners/unload-listener-manager.d.ts +8 -0
  58. package/dist/cjs/listeners/unload-listener-manager.js +30 -0
  59. package/dist/cjs/listeners/visibility-listener-manager.d.ts +12 -0
  60. package/dist/cjs/listeners/visibility-listener-manager.js +83 -0
  61. package/dist/cjs/managers/api.manager.d.ts +3 -0
  62. package/dist/cjs/managers/api.manager.js +14 -0
  63. package/dist/cjs/managers/config.manager.d.ts +7 -0
  64. package/dist/cjs/managers/config.manager.js +94 -0
  65. package/dist/cjs/managers/cross-tab-session.manager.d.ts +170 -0
  66. package/dist/cjs/managers/cross-tab-session.manager.js +730 -0
  67. package/dist/cjs/managers/event.manager.d.ts +61 -0
  68. package/dist/cjs/managers/event.manager.js +508 -0
  69. package/dist/cjs/managers/sampling.manager.d.ts +8 -0
  70. package/dist/cjs/managers/sampling.manager.js +53 -0
  71. package/dist/cjs/managers/sender.manager.d.ts +46 -0
  72. package/dist/cjs/managers/sender.manager.js +304 -0
  73. package/dist/cjs/managers/session-recovery.manager.d.ts +65 -0
  74. package/dist/cjs/managers/session-recovery.manager.js +237 -0
  75. package/dist/cjs/managers/session.manager.d.ts +72 -0
  76. package/dist/cjs/managers/session.manager.js +587 -0
  77. package/dist/cjs/managers/state.manager.d.ts +5 -0
  78. package/dist/cjs/managers/state.manager.js +23 -0
  79. package/dist/cjs/managers/storage.manager.d.ts +10 -0
  80. package/dist/cjs/managers/storage.manager.js +81 -0
  81. package/dist/cjs/managers/tags.manager.d.ts +12 -0
  82. package/dist/cjs/managers/tags.manager.js +289 -0
  83. package/dist/cjs/managers/user.manager.d.ts +7 -0
  84. package/dist/cjs/managers/user.manager.js +22 -0
  85. package/dist/cjs/public-api.d.ts +1 -0
  86. package/dist/cjs/public-api.js +37 -0
  87. package/dist/cjs/types/api.types.d.ts +21 -0
  88. package/dist/cjs/types/api.types.js +25 -0
  89. package/dist/cjs/types/common.types.d.ts +1 -0
  90. package/dist/cjs/types/common.types.js +2 -0
  91. package/dist/cjs/types/config.types.d.ts +104 -0
  92. package/dist/cjs/types/config.types.js +2 -0
  93. package/dist/cjs/types/device.types.d.ts +6 -0
  94. package/dist/cjs/types/device.types.js +10 -0
  95. package/dist/cjs/types/event.types.d.ts +104 -0
  96. package/dist/cjs/types/event.types.js +25 -0
  97. package/dist/cjs/types/index.d.ts +13 -0
  98. package/dist/cjs/types/index.js +29 -0
  99. package/dist/cjs/types/log.types.d.ts +4 -0
  100. package/dist/cjs/types/log.types.js +2 -0
  101. package/dist/cjs/types/mode.types.d.ts +7 -0
  102. package/dist/cjs/types/mode.types.js +11 -0
  103. package/dist/cjs/types/queue.types.d.ts +23 -0
  104. package/dist/cjs/types/queue.types.js +2 -0
  105. package/dist/cjs/types/session.types.d.ts +65 -0
  106. package/dist/cjs/types/session.types.js +2 -0
  107. package/dist/cjs/types/state.types.d.ts +12 -0
  108. package/dist/cjs/types/state.types.js +2 -0
  109. package/dist/cjs/types/tag.types.d.ts +43 -0
  110. package/dist/cjs/types/tag.types.js +31 -0
  111. package/dist/cjs/types/validation-error.types.d.ts +42 -0
  112. package/dist/cjs/types/validation-error.types.js +68 -0
  113. package/dist/cjs/types/web-vitals.types.d.ts +6 -0
  114. package/dist/cjs/types/web-vitals.types.js +2 -0
  115. package/dist/cjs/types/window.types.d.ts +17 -0
  116. package/dist/cjs/types/window.types.js +2 -0
  117. package/dist/cjs/utils/browser/device-detector.utils.d.ts +6 -0
  118. package/dist/cjs/utils/browser/device-detector.utils.js +71 -0
  119. package/dist/cjs/utils/browser/index.d.ts +2 -0
  120. package/dist/cjs/utils/browser/index.js +18 -0
  121. package/dist/cjs/utils/browser/utm-params.utils.d.ts +6 -0
  122. package/dist/cjs/utils/browser/utm-params.utils.js +37 -0
  123. package/dist/cjs/utils/data/index.d.ts +1 -0
  124. package/dist/cjs/utils/data/index.js +17 -0
  125. package/dist/cjs/utils/data/uuid.utils.d.ts +5 -0
  126. package/dist/cjs/utils/data/uuid.utils.js +18 -0
  127. package/dist/cjs/utils/index.d.ts +6 -0
  128. package/dist/cjs/utils/index.js +22 -0
  129. package/dist/cjs/utils/logging/debug-logger.utils.d.ts +56 -0
  130. package/dist/cjs/utils/logging/debug-logger.utils.js +139 -0
  131. package/dist/cjs/utils/logging/index.d.ts +1 -0
  132. package/dist/cjs/utils/logging/index.js +5 -0
  133. package/dist/cjs/utils/network/index.d.ts +1 -0
  134. package/dist/cjs/utils/network/index.js +17 -0
  135. package/dist/cjs/utils/network/url.utils.d.ts +20 -0
  136. package/dist/cjs/utils/network/url.utils.js +172 -0
  137. package/dist/cjs/utils/security/index.d.ts +1 -0
  138. package/dist/cjs/utils/security/index.js +17 -0
  139. package/dist/cjs/utils/security/sanitize.utils.d.ts +32 -0
  140. package/dist/cjs/utils/security/sanitize.utils.js +319 -0
  141. package/dist/cjs/utils/validations/config-validations.utils.d.ts +42 -0
  142. package/dist/cjs/utils/validations/config-validations.utils.js +297 -0
  143. package/dist/cjs/utils/validations/event-validations.utils.d.ts +12 -0
  144. package/dist/cjs/utils/validations/event-validations.utils.js +30 -0
  145. package/dist/cjs/utils/validations/index.d.ts +5 -0
  146. package/dist/cjs/utils/validations/index.js +21 -0
  147. package/dist/cjs/utils/validations/metadata-validations.utils.d.ts +22 -0
  148. package/dist/cjs/utils/validations/metadata-validations.utils.js +115 -0
  149. package/dist/cjs/utils/validations/type-guards.utils.d.ts +6 -0
  150. package/dist/cjs/utils/validations/type-guards.utils.js +31 -0
  151. package/dist/cjs/utils/validations/url-validations.utils.d.ts +15 -0
  152. package/dist/cjs/utils/validations/url-validations.utils.js +47 -0
  153. package/dist/esm/api.d.ts +46 -0
  154. package/dist/esm/api.js +183 -0
  155. package/dist/esm/app.constants.d.ts +1 -0
  156. package/dist/esm/app.constants.js +1 -0
  157. package/dist/esm/app.d.ts +59 -0
  158. package/dist/esm/app.js +268 -0
  159. package/dist/esm/app.types.d.ts +6 -0
  160. package/dist/esm/app.types.js +6 -0
  161. package/dist/esm/constants/api.constants.d.ts +4 -0
  162. package/dist/esm/constants/api.constants.js +14 -0
  163. package/dist/esm/constants/browser.constants.d.ts +3 -0
  164. package/dist/esm/constants/browser.constants.js +38 -0
  165. package/dist/esm/constants/index.d.ts +8 -0
  166. package/dist/esm/constants/index.js +8 -0
  167. package/dist/esm/constants/initialization.constants.d.ts +40 -0
  168. package/dist/esm/constants/initialization.constants.js +45 -0
  169. package/dist/esm/constants/limits.constants.d.ts +25 -0
  170. package/dist/esm/constants/limits.constants.js +37 -0
  171. package/dist/esm/constants/security.constants.d.ts +1 -0
  172. package/dist/esm/constants/security.constants.js +9 -0
  173. package/dist/esm/constants/storage.constants.d.ts +9 -0
  174. package/dist/esm/constants/storage.constants.js +11 -0
  175. package/dist/esm/constants/timing.constants.d.ts +22 -0
  176. package/dist/esm/constants/timing.constants.js +31 -0
  177. package/dist/esm/constants/validation.constants.d.ts +13 -0
  178. package/dist/esm/constants/validation.constants.js +28 -0
  179. package/dist/esm/handlers/click.handler.d.ts +17 -0
  180. package/dist/esm/handlers/click.handler.js +195 -0
  181. package/dist/esm/handlers/error.handler.d.ts +15 -0
  182. package/dist/esm/handlers/error.handler.js +93 -0
  183. package/dist/esm/handlers/network.handler.d.ts +16 -0
  184. package/dist/esm/handlers/network.handler.js +132 -0
  185. package/dist/esm/handlers/page-view.handler.d.ts +15 -0
  186. package/dist/esm/handlers/page-view.handler.js +79 -0
  187. package/dist/esm/handlers/performance.handler.d.ts +19 -0
  188. package/dist/esm/handlers/performance.handler.js +218 -0
  189. package/dist/esm/handlers/scroll.handler.d.ts +16 -0
  190. package/dist/esm/handlers/scroll.handler.js +134 -0
  191. package/dist/esm/handlers/session.handler.d.ts +29 -0
  192. package/dist/esm/handlers/session.handler.js +353 -0
  193. package/dist/esm/integrations/google-analytics.integration.d.ts +18 -0
  194. package/dist/esm/integrations/google-analytics.integration.js +155 -0
  195. package/dist/esm/listeners/activity-listener-manager.d.ts +8 -0
  196. package/dist/esm/listeners/activity-listener-manager.js +28 -0
  197. package/dist/esm/listeners/index.d.ts +6 -0
  198. package/dist/esm/listeners/index.js +5 -0
  199. package/dist/esm/listeners/input-listener-managers.d.ts +15 -0
  200. package/dist/esm/listeners/input-listener-managers.js +53 -0
  201. package/dist/esm/listeners/listeners.types.d.ts +4 -0
  202. package/dist/esm/listeners/listeners.types.js +1 -0
  203. package/dist/esm/listeners/touch-listener-manager.d.ts +10 -0
  204. package/dist/esm/listeners/touch-listener-manager.js +52 -0
  205. package/dist/esm/listeners/unload-listener-manager.d.ts +8 -0
  206. package/dist/esm/listeners/unload-listener-manager.js +26 -0
  207. package/dist/esm/listeners/visibility-listener-manager.d.ts +12 -0
  208. package/dist/esm/listeners/visibility-listener-manager.js +79 -0
  209. package/dist/esm/managers/api.manager.d.ts +3 -0
  210. package/dist/esm/managers/api.manager.js +10 -0
  211. package/dist/esm/managers/config.manager.d.ts +7 -0
  212. package/dist/esm/managers/config.manager.js +90 -0
  213. package/dist/esm/managers/cross-tab-session.manager.d.ts +170 -0
  214. package/dist/esm/managers/cross-tab-session.manager.js +726 -0
  215. package/dist/esm/managers/event.manager.d.ts +61 -0
  216. package/dist/esm/managers/event.manager.js +504 -0
  217. package/dist/esm/managers/sampling.manager.d.ts +8 -0
  218. package/dist/esm/managers/sampling.manager.js +49 -0
  219. package/dist/esm/managers/sender.manager.d.ts +46 -0
  220. package/dist/esm/managers/sender.manager.js +300 -0
  221. package/dist/esm/managers/session-recovery.manager.d.ts +65 -0
  222. package/dist/esm/managers/session-recovery.manager.js +233 -0
  223. package/dist/esm/managers/session.manager.d.ts +72 -0
  224. package/dist/esm/managers/session.manager.js +583 -0
  225. package/dist/esm/managers/state.manager.d.ts +5 -0
  226. package/dist/esm/managers/state.manager.js +19 -0
  227. package/dist/esm/managers/storage.manager.d.ts +10 -0
  228. package/dist/esm/managers/storage.manager.js +77 -0
  229. package/dist/esm/managers/tags.manager.d.ts +12 -0
  230. package/dist/esm/managers/tags.manager.js +285 -0
  231. package/dist/esm/managers/user.manager.d.ts +7 -0
  232. package/dist/esm/managers/user.manager.js +18 -0
  233. package/dist/esm/public-api.d.ts +1 -0
  234. package/dist/esm/public-api.js +1 -0
  235. package/dist/esm/types/api.types.d.ts +21 -0
  236. package/dist/esm/types/api.types.js +22 -0
  237. package/dist/esm/types/common.types.d.ts +1 -0
  238. package/dist/esm/types/common.types.js +1 -0
  239. package/dist/esm/types/config.types.d.ts +104 -0
  240. package/dist/esm/types/config.types.js +1 -0
  241. package/dist/esm/types/device.types.d.ts +6 -0
  242. package/dist/esm/types/device.types.js +7 -0
  243. package/dist/esm/types/event.types.d.ts +104 -0
  244. package/dist/esm/types/event.types.js +22 -0
  245. package/dist/esm/types/index.d.ts +13 -0
  246. package/dist/esm/types/index.js +13 -0
  247. package/dist/esm/types/log.types.d.ts +4 -0
  248. package/dist/esm/types/log.types.js +1 -0
  249. package/dist/esm/types/mode.types.d.ts +7 -0
  250. package/dist/esm/types/mode.types.js +8 -0
  251. package/dist/esm/types/queue.types.d.ts +23 -0
  252. package/dist/esm/types/queue.types.js +1 -0
  253. package/dist/esm/types/session.types.d.ts +65 -0
  254. package/dist/esm/types/session.types.js +1 -0
  255. package/dist/esm/types/state.types.d.ts +12 -0
  256. package/dist/esm/types/state.types.js +1 -0
  257. package/dist/esm/types/tag.types.d.ts +43 -0
  258. package/dist/esm/types/tag.types.js +28 -0
  259. package/dist/esm/types/validation-error.types.d.ts +42 -0
  260. package/dist/esm/types/validation-error.types.js +59 -0
  261. package/dist/esm/types/web-vitals.types.d.ts +6 -0
  262. package/dist/esm/types/web-vitals.types.js +1 -0
  263. package/dist/esm/types/window.types.d.ts +17 -0
  264. package/dist/esm/types/window.types.js +1 -0
  265. package/dist/esm/utils/browser/device-detector.utils.d.ts +6 -0
  266. package/dist/esm/utils/browser/device-detector.utils.js +67 -0
  267. package/dist/esm/utils/browser/index.d.ts +2 -0
  268. package/dist/esm/utils/browser/index.js +2 -0
  269. package/dist/esm/utils/browser/utm-params.utils.d.ts +6 -0
  270. package/dist/esm/utils/browser/utm-params.utils.js +33 -0
  271. package/dist/esm/utils/data/index.d.ts +1 -0
  272. package/dist/esm/utils/data/index.js +1 -0
  273. package/dist/esm/utils/data/uuid.utils.d.ts +5 -0
  274. package/dist/esm/utils/data/uuid.utils.js +14 -0
  275. package/dist/esm/utils/index.d.ts +6 -0
  276. package/dist/esm/utils/index.js +6 -0
  277. package/dist/esm/utils/logging/debug-logger.utils.d.ts +56 -0
  278. package/dist/esm/utils/logging/debug-logger.utils.js +136 -0
  279. package/dist/esm/utils/logging/index.d.ts +1 -0
  280. package/dist/esm/utils/logging/index.js +1 -0
  281. package/dist/esm/utils/network/index.d.ts +1 -0
  282. package/dist/esm/utils/network/index.js +1 -0
  283. package/dist/esm/utils/network/url.utils.d.ts +20 -0
  284. package/dist/esm/utils/network/url.utils.js +166 -0
  285. package/dist/esm/utils/security/index.d.ts +1 -0
  286. package/dist/esm/utils/security/index.js +1 -0
  287. package/dist/esm/utils/security/sanitize.utils.d.ts +32 -0
  288. package/dist/esm/utils/security/sanitize.utils.js +311 -0
  289. package/dist/esm/utils/validations/config-validations.utils.d.ts +42 -0
  290. package/dist/esm/utils/validations/config-validations.utils.js +289 -0
  291. package/dist/esm/utils/validations/event-validations.utils.d.ts +12 -0
  292. package/dist/esm/utils/validations/event-validations.utils.js +26 -0
  293. package/dist/esm/utils/validations/index.d.ts +5 -0
  294. package/dist/esm/utils/validations/index.js +5 -0
  295. package/dist/esm/utils/validations/metadata-validations.utils.d.ts +22 -0
  296. package/dist/esm/utils/validations/metadata-validations.utils.js +110 -0
  297. package/dist/esm/utils/validations/type-guards.utils.d.ts +6 -0
  298. package/dist/esm/utils/validations/type-guards.utils.js +27 -0
  299. package/dist/esm/utils/validations/url-validations.utils.d.ts +15 -0
  300. package/dist/esm/utils/validations/url-validations.utils.js +42 -0
  301. package/package.json +80 -0
@@ -0,0 +1,198 @@
1
+ var P, R = -1, h = function(e) {
2
+ addEventListener("pageshow", function(t) {
3
+ t.persisted && (R = t.timeStamp, e(t));
4
+ }, !0);
5
+ }, S = function() {
6
+ var e = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
7
+ if (e && e.responseStart > 0 && e.responseStart < performance.now()) return e;
8
+ }, y = function() {
9
+ var e = S();
10
+ return e && e.activationStart || 0;
11
+ }, d = function(e, t) {
12
+ var n = S(), i = "navigate";
13
+ return R >= 0 ? i = "back-forward-cache" : n && (document.prerendering || y() > 0 ? i = "prerender" : document.wasDiscarded ? i = "restore" : n.type && (i = n.type.replace(/_/g, "-"))), { name: e, value: t === void 0 ? -1 : t, rating: "good", delta: 0, entries: [], id: "v4-".concat(Date.now(), "-").concat(Math.floor(8999999999999 * Math.random()) + 1e12), navigationType: i };
14
+ }, p = function(e, t, n) {
15
+ try {
16
+ if (PerformanceObserver.supportedEntryTypes.includes(e)) {
17
+ var i = new PerformanceObserver(function(r) {
18
+ Promise.resolve().then(function() {
19
+ t(r.getEntries());
20
+ });
21
+ });
22
+ return i.observe(Object.assign({ type: e, buffered: !0 }, n || {})), i;
23
+ }
24
+ } catch {
25
+ }
26
+ }, l = function(e, t, n, i) {
27
+ var r, o;
28
+ return function(u) {
29
+ t.value >= 0 && (u || i) && ((o = t.value - (r || 0)) || r === void 0) && (r = t.value, t.delta = o, t.rating = function(c, a) {
30
+ return c > a[1] ? "poor" : c > a[0] ? "needs-improvement" : "good";
31
+ }(t.value, n), e(t));
32
+ };
33
+ }, A = function(e) {
34
+ requestAnimationFrame(function() {
35
+ return requestAnimationFrame(function() {
36
+ return e();
37
+ });
38
+ });
39
+ }, C = function(e) {
40
+ document.addEventListener("visibilitychange", function() {
41
+ document.visibilityState === "hidden" && e();
42
+ });
43
+ }, I = function(e) {
44
+ var t = !1;
45
+ return function() {
46
+ t || (e(), t = !0);
47
+ };
48
+ }, v = -1, w = function() {
49
+ return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
50
+ }, T = function(e) {
51
+ document.visibilityState === "hidden" && v > -1 && (v = e.type === "visibilitychange" ? e.timeStamp : 0, G());
52
+ }, F = function() {
53
+ addEventListener("visibilitychange", T, !0), addEventListener("prerenderingchange", T, !0);
54
+ }, G = function() {
55
+ removeEventListener("visibilitychange", T, !0), removeEventListener("prerenderingchange", T, !0);
56
+ }, q = function() {
57
+ return v < 0 && (v = w(), F(), h(function() {
58
+ setTimeout(function() {
59
+ v = w(), F();
60
+ }, 0);
61
+ })), { get firstHiddenTime() {
62
+ return v;
63
+ } };
64
+ }, E = function(e) {
65
+ document.prerendering ? addEventListener("prerenderingchange", function() {
66
+ return e();
67
+ }, !0) : e();
68
+ }, M = [1800, 3e3], J = function(e, t) {
69
+ t = t || {}, E(function() {
70
+ var n, i = q(), r = d("FCP"), o = p("paint", function(u) {
71
+ u.forEach(function(c) {
72
+ c.name === "first-contentful-paint" && (o.disconnect(), c.startTime < i.firstHiddenTime && (r.value = Math.max(c.startTime - y(), 0), r.entries.push(c), n(!0)));
73
+ });
74
+ });
75
+ o && (n = l(e, r, M, t.reportAllChanges), h(function(u) {
76
+ r = d("FCP"), n = l(e, r, M, t.reportAllChanges), A(function() {
77
+ r.value = performance.now() - u.timeStamp, n(!0);
78
+ });
79
+ }));
80
+ });
81
+ }, k = [0.1, 0.25], Y = function(e, t) {
82
+ t = t || {}, J(I(function() {
83
+ var n, i = d("CLS", 0), r = 0, o = [], u = function(a) {
84
+ a.forEach(function(s) {
85
+ if (!s.hadRecentInput) {
86
+ var _ = o[0], z = o[o.length - 1];
87
+ r && s.startTime - z.startTime < 1e3 && s.startTime - _.startTime < 5e3 ? (r += s.value, o.push(s)) : (r = s.value, o = [s]);
88
+ }
89
+ }), r > i.value && (i.value = r, i.entries = o, n());
90
+ }, c = p("layout-shift", u);
91
+ c && (n = l(e, i, k, t.reportAllChanges), C(function() {
92
+ u(c.takeRecords()), n(!0);
93
+ }), h(function() {
94
+ r = 0, i = d("CLS", 0), n = l(e, i, k, t.reportAllChanges), A(function() {
95
+ return n();
96
+ });
97
+ }), setTimeout(n, 0));
98
+ }));
99
+ }, H = 0, b = 1 / 0, m = 0, K = function(e) {
100
+ e.forEach(function(t) {
101
+ t.interactionId && (b = Math.min(b, t.interactionId), m = Math.max(m, t.interactionId), H = m ? (m - b) / 7 + 1 : 0);
102
+ });
103
+ }, O = function() {
104
+ return P ? H : performance.interactionCount || 0;
105
+ }, Q = function() {
106
+ "interactionCount" in performance || P || (P = p("event", K, { type: "event", buffered: !0, durationThreshold: 0 }));
107
+ }, f = [], g = /* @__PURE__ */ new Map(), D = 0, U = function() {
108
+ var e = Math.min(f.length - 1, Math.floor((O() - D) / 50));
109
+ return f[e];
110
+ }, V = [], W = function(e) {
111
+ if (V.forEach(function(r) {
112
+ return r(e);
113
+ }), e.interactionId || e.entryType === "first-input") {
114
+ var t = f[f.length - 1], n = g.get(e.interactionId);
115
+ if (n || f.length < 10 || e.duration > t.latency) {
116
+ if (n) e.duration > n.latency ? (n.entries = [e], n.latency = e.duration) : e.duration === n.latency && e.startTime === n.entries[0].startTime && n.entries.push(e);
117
+ else {
118
+ var i = { id: e.interactionId, latency: e.duration, entries: [e] };
119
+ g.set(i.id, i), f.push(i);
120
+ }
121
+ f.sort(function(r, o) {
122
+ return o.latency - r.latency;
123
+ }), f.length > 10 && f.splice(10).forEach(function(r) {
124
+ return g.delete(r.id);
125
+ });
126
+ }
127
+ }
128
+ }, j = function(e) {
129
+ var t = self.requestIdleCallback || self.setTimeout, n = -1;
130
+ return e = I(e), document.visibilityState === "hidden" ? e() : (n = t(e), C(e)), n;
131
+ }, B = [200, 500], Z = function(e, t) {
132
+ "PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (t = t || {}, E(function() {
133
+ var n;
134
+ Q();
135
+ var i, r = d("INP"), o = function(c) {
136
+ j(function() {
137
+ c.forEach(W);
138
+ var a = U();
139
+ a && a.latency !== r.value && (r.value = a.latency, r.entries = a.entries, i());
140
+ });
141
+ }, u = p("event", o, { durationThreshold: (n = t.durationThreshold) !== null && n !== void 0 ? n : 40 });
142
+ i = l(e, r, B, t.reportAllChanges), u && (u.observe({ type: "first-input", buffered: !0 }), C(function() {
143
+ o(u.takeRecords()), i(!0);
144
+ }), h(function() {
145
+ D = O(), f.length = 0, g.clear(), r = d("INP"), i = l(e, r, B, t.reportAllChanges);
146
+ }));
147
+ }));
148
+ }, x = [2500, 4e3], L = {}, $ = function(e, t) {
149
+ t = t || {}, E(function() {
150
+ var n, i = q(), r = d("LCP"), o = function(a) {
151
+ t.reportAllChanges || (a = a.slice(-1)), a.forEach(function(s) {
152
+ s.startTime < i.firstHiddenTime && (r.value = Math.max(s.startTime - y(), 0), r.entries = [s], n());
153
+ });
154
+ }, u = p("largest-contentful-paint", o);
155
+ if (u) {
156
+ n = l(e, r, x, t.reportAllChanges);
157
+ var c = I(function() {
158
+ L[r.id] || (o(u.takeRecords()), u.disconnect(), L[r.id] = !0, n(!0));
159
+ });
160
+ ["keydown", "click"].forEach(function(a) {
161
+ addEventListener(a, function() {
162
+ return j(c);
163
+ }, { once: !0, capture: !0 });
164
+ }), C(c), h(function(a) {
165
+ r = d("LCP"), n = l(e, r, x, t.reportAllChanges), A(function() {
166
+ r.value = performance.now() - a.timeStamp, L[r.id] = !0, n(!0);
167
+ });
168
+ });
169
+ }
170
+ });
171
+ }, N = [800, 1800], X = function e(t) {
172
+ document.prerendering ? E(function() {
173
+ return e(t);
174
+ }) : document.readyState !== "complete" ? addEventListener("load", function() {
175
+ return e(t);
176
+ }, !0) : setTimeout(t, 0);
177
+ }, ee = function(e, t) {
178
+ t = t || {};
179
+ var n = d("TTFB"), i = l(e, n, N, t.reportAllChanges);
180
+ X(function() {
181
+ var r = S();
182
+ r && (n.value = Math.max(r.responseStart - y(), 0), n.entries = [r], i(!0), h(function() {
183
+ n = d("TTFB", 0), (i = l(e, n, N, t.reportAllChanges))(!0);
184
+ }));
185
+ });
186
+ };
187
+ export {
188
+ k as CLSThresholds,
189
+ M as FCPThresholds,
190
+ B as INPThresholds,
191
+ x as LCPThresholds,
192
+ N as TTFBThresholds,
193
+ Y as onCLS,
194
+ J as onFCP,
195
+ Z as onINP,
196
+ $ as onLCP,
197
+ ee as onTTFB
198
+ };
@@ -0,0 +1,46 @@
1
+ import { MetadataType } from './types/common.types';
2
+ import { AppConfig } from './types/config.types';
3
+ import './types/window.types';
4
+ export * as Types from './app.types';
5
+ export * as Constants from './app.constants';
6
+ /**
7
+ * Initializes the tracelog app with the provided configuration.
8
+ * If already initialized, this function returns early without error.
9
+ * @param appConfig - The configuration object for the app
10
+ * @throws {Error} If initialization is currently in progress
11
+ * @example
12
+ * await init({ id: 'my-project-id' });
13
+ */
14
+ export declare const init: (appConfig: AppConfig) => Promise<void>;
15
+ /**
16
+ * Sends a custom event with the specified name and metadata.
17
+ * @param name - The name of the custom event.
18
+ * @param metadata - Optional metadata to attach to the event.
19
+ * @example
20
+ * // Send a custom event with metadata
21
+ * event('user_signup', { method: 'email', plan: 'premium' });
22
+ * @example
23
+ * // Send a custom event without metadata
24
+ * event('user_login');
25
+ * @remarks
26
+ * This function should be called after the app has been initialized using the `init` function.
27
+ */
28
+ export declare const event: (name: string, metadata?: Record<string, MetadataType>) => void;
29
+ /**
30
+ * Checks if the app has been initialized.
31
+ * @returns true if the app is initialized, false otherwise
32
+ */
33
+ export declare const isInitialized: () => boolean;
34
+ /**
35
+ * Gets the current initialization status for debugging purposes.
36
+ * @returns Object with detailed initialization state
37
+ */
38
+ export declare const getInitializationStatus: () => {
39
+ isInitialized: boolean;
40
+ isInitializing: boolean;
41
+ hasInstance: boolean;
42
+ };
43
+ /**
44
+ * Destroys the current app instance and cleans up resources.
45
+ */
46
+ export declare const destroy: () => void;
@@ -0,0 +1,224 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.destroy = exports.getInitializationStatus = exports.isInitialized = exports.event = exports.init = exports.Constants = exports.Types = void 0;
37
+ const app_1 = require("./app");
38
+ const logging_1 = require("./utils/logging");
39
+ const validations_1 = require("./utils/validations");
40
+ const constants_1 = require("./constants");
41
+ require("./types/window.types");
42
+ exports.Types = __importStar(require("./app.types"));
43
+ exports.Constants = __importStar(require("./app.constants"));
44
+ let app = null;
45
+ let isInitializing = false;
46
+ /**
47
+ * Initializes the tracelog app with the provided configuration.
48
+ * If already initialized, this function returns early without error.
49
+ * @param appConfig - The configuration object for the app
50
+ * @throws {Error} If initialization is currently in progress
51
+ * @example
52
+ * await init({ id: 'my-project-id' });
53
+ */
54
+ const init = async (appConfig) => {
55
+ try {
56
+ logging_1.debugLog.info('API', 'Library initialization started', { id: appConfig.id });
57
+ if (typeof window === 'undefined' || typeof document === 'undefined') {
58
+ logging_1.debugLog.clientError('API', 'Browser environment required - this library can only be used in a browser environment', {
59
+ hasWindow: typeof window !== 'undefined',
60
+ hasDocument: typeof document !== 'undefined',
61
+ });
62
+ throw new Error('This library can only be used in a browser environment');
63
+ }
64
+ if (app) {
65
+ logging_1.debugLog.debug('API', 'Library already initialized, skipping duplicate initialization', {
66
+ projectId: appConfig.id,
67
+ });
68
+ return;
69
+ }
70
+ if (isInitializing) {
71
+ logging_1.debugLog.debug('API', 'Concurrent initialization detected, waiting for completion', { projectId: appConfig.id });
72
+ let retries = 0;
73
+ const maxRetries = constants_1.INITIALIZATION_CONSTANTS.MAX_CONCURRENT_RETRIES;
74
+ const retryDelay = constants_1.INITIALIZATION_CONSTANTS.CONCURRENT_RETRY_DELAY_MS;
75
+ while (isInitializing && retries < maxRetries) {
76
+ await new Promise((resolve) => setTimeout(resolve, retryDelay));
77
+ retries++;
78
+ }
79
+ if (app) {
80
+ logging_1.debugLog.debug('API', 'Concurrent initialization completed successfully', {
81
+ projectId: appConfig.id,
82
+ retriesUsed: retries,
83
+ });
84
+ return;
85
+ }
86
+ if (isInitializing) {
87
+ logging_1.debugLog.error('API', 'Initialization timeout - concurrent initialization took too long', {
88
+ projectId: appConfig.id,
89
+ retriesUsed: retries,
90
+ maxRetries,
91
+ });
92
+ throw new Error('App initialization timeout - concurrent initialization took too long');
93
+ }
94
+ }
95
+ isInitializing = true;
96
+ logging_1.debugLog.debug('API', 'Validating and normalizing configuration', { projectId: appConfig.id });
97
+ const validatedConfig = (0, validations_1.validateAndNormalizeConfig)(appConfig);
98
+ logging_1.debugLog.debug('API', 'Creating App instance', { projectId: validatedConfig.id });
99
+ const instance = new app_1.App();
100
+ await instance.init(validatedConfig);
101
+ app = instance;
102
+ logging_1.debugLog.info('API', 'Library initialization completed successfully', {
103
+ projectId: validatedConfig.id,
104
+ });
105
+ }
106
+ catch (error) {
107
+ // Ensure complete cleanup on initialization failure
108
+ if (app && !app.initialized) {
109
+ // Clean up partially initialized app instance
110
+ try {
111
+ app.destroy();
112
+ }
113
+ catch (cleanupError) {
114
+ logging_1.debugLog.warn('API', 'Failed to cleanup partially initialized app', { cleanupError });
115
+ }
116
+ }
117
+ app = null;
118
+ logging_1.debugLog.error('API', 'Initialization failed', { error });
119
+ throw error;
120
+ }
121
+ finally {
122
+ isInitializing = false;
123
+ }
124
+ };
125
+ exports.init = init;
126
+ /**
127
+ * Sends a custom event with the specified name and metadata.
128
+ * @param name - The name of the custom event.
129
+ * @param metadata - Optional metadata to attach to the event.
130
+ * @example
131
+ * // Send a custom event with metadata
132
+ * event('user_signup', { method: 'email', plan: 'premium' });
133
+ * @example
134
+ * // Send a custom event without metadata
135
+ * event('user_login');
136
+ * @remarks
137
+ * This function should be called after the app has been initialized using the `init` function.
138
+ */
139
+ const event = (name, metadata) => {
140
+ try {
141
+ if (!app) {
142
+ logging_1.debugLog.clientError('API', 'Custom event failed - Library not initialized. Please call TraceLog.init() first', {
143
+ eventName: name,
144
+ hasMetadata: !!metadata,
145
+ });
146
+ throw new Error('App not initialized');
147
+ }
148
+ logging_1.debugLog.debug('API', 'Sending custom event', {
149
+ eventName: name,
150
+ hasMetadata: !!metadata,
151
+ metadataKeys: metadata ? Object.keys(metadata) : [],
152
+ });
153
+ app.sendCustomEvent(name, metadata);
154
+ }
155
+ catch (error) {
156
+ logging_1.debugLog.error('API', 'Event tracking failed', { eventName: name, error, hasMetadata: !!metadata });
157
+ if (error instanceof Error &&
158
+ (error.message === 'App not initialized' || error.message.includes('validation failed'))) {
159
+ throw error;
160
+ }
161
+ }
162
+ };
163
+ exports.event = event;
164
+ /**
165
+ * Checks if the app has been initialized.
166
+ * @returns true if the app is initialized, false otherwise
167
+ */
168
+ const isInitialized = () => {
169
+ return app !== null;
170
+ };
171
+ exports.isInitialized = isInitialized;
172
+ /**
173
+ * Gets the current initialization status for debugging purposes.
174
+ * @returns Object with detailed initialization state
175
+ */
176
+ const getInitializationStatus = () => {
177
+ return {
178
+ isInitialized: app !== null,
179
+ isInitializing: isInitializing,
180
+ hasInstance: app !== null,
181
+ };
182
+ };
183
+ exports.getInitializationStatus = getInitializationStatus;
184
+ /**
185
+ * Destroys the current app instance and cleans up resources.
186
+ */
187
+ const destroy = () => {
188
+ try {
189
+ logging_1.debugLog.info('API', 'Library cleanup initiated');
190
+ if (!app) {
191
+ logging_1.debugLog.warn('API', 'Cleanup called but Library was not initialized');
192
+ throw new Error('App not initialized');
193
+ }
194
+ app.destroy();
195
+ app = null;
196
+ isInitializing = false;
197
+ logging_1.debugLog.info('API', 'Library cleanup completed successfully');
198
+ }
199
+ catch (error) {
200
+ logging_1.debugLog.error('API', 'Cleanup failed', { error, hadApp: !!app, wasInitializing: isInitializing });
201
+ }
202
+ };
203
+ exports.destroy = destroy;
204
+ class TestBridge extends app_1.App {
205
+ isInitializing() {
206
+ return isInitializing;
207
+ }
208
+ }
209
+ // Auto-inject testing bridge only in development/testing environments
210
+ if (process.env.NODE_ENV === 'dev') {
211
+ if (typeof window !== 'undefined') {
212
+ // Wait for DOM to be ready before injecting
213
+ const injectTestingBridge = () => {
214
+ window.__traceLogBridge = new TestBridge();
215
+ };
216
+ // Inject immediately if DOM is ready, otherwise wait
217
+ if (document.readyState === 'loading') {
218
+ document.addEventListener('DOMContentLoaded', injectTestingBridge);
219
+ }
220
+ else {
221
+ injectTestingBridge();
222
+ }
223
+ }
224
+ }
@@ -0,0 +1 @@
1
+ export { DEFAULT_SESSION_TIMEOUT_MS } from './constants';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_SESSION_TIMEOUT_MS = void 0;
4
+ var constants_1 = require("./constants");
5
+ Object.defineProperty(exports, "DEFAULT_SESSION_TIMEOUT_MS", { enumerable: true, get: function () { return constants_1.DEFAULT_SESSION_TIMEOUT_MS; } });
@@ -0,0 +1,59 @@
1
+ import { EventManager } from './managers/event.manager';
2
+ import { AppConfig } from './types/config.types';
3
+ import { StateManager } from './managers/state.manager';
4
+ import { SessionHandler } from './handlers/session.handler';
5
+ import { PageViewHandler } from './handlers/page-view.handler';
6
+ import { ClickHandler } from './handlers/click.handler';
7
+ import { ScrollHandler } from './handlers/scroll.handler';
8
+ import { GoogleAnalyticsIntegration } from './integrations/google-analytics.integration';
9
+ import { StorageManager } from './managers/storage.manager';
10
+ import { PerformanceHandler } from './handlers/performance.handler';
11
+ import { ErrorHandler } from './handlers/error.handler';
12
+ import { NetworkHandler } from './handlers/network.handler';
13
+ export declare class App extends StateManager {
14
+ protected isInitialized: boolean;
15
+ protected googleAnalytics: GoogleAnalyticsIntegration | null;
16
+ protected storageManager: StorageManager;
17
+ protected eventManager: EventManager;
18
+ protected sessionHandler: SessionHandler;
19
+ protected pageViewHandler: PageViewHandler;
20
+ protected clickHandler: ClickHandler;
21
+ protected scrollHandler: ScrollHandler;
22
+ protected performanceHandler: PerformanceHandler;
23
+ protected errorHandler: ErrorHandler;
24
+ protected networkHandler: NetworkHandler;
25
+ protected suppressNextScrollTimer: number | null;
26
+ /**
27
+ * Returns the initialization status of the app
28
+ * @returns true if the app is fully initialized, false otherwise
29
+ */
30
+ get initialized(): boolean;
31
+ init(appConfig: AppConfig): Promise<void>;
32
+ /**
33
+ * Validates that the app is ready to initialize with the provided config
34
+ * This is a lightweight runtime validation layer that ensures the app receives proper config
35
+ * @param appConfig - The validated and normalized configuration
36
+ * @throws {ProjectIdValidationError} If project ID is invalid at runtime
37
+ */
38
+ private validateAppReadiness;
39
+ sendCustomEvent(name: string, metadata?: Record<string, unknown>): void;
40
+ destroy(): void;
41
+ private setState;
42
+ private setApiUrl;
43
+ private setConfig;
44
+ private setUserId;
45
+ private setDevice;
46
+ private setPageUrl;
47
+ private setIntegrations;
48
+ private initHandlers;
49
+ private initStorage;
50
+ private setEventManager;
51
+ private initSessionHandler;
52
+ private initPageViewHandler;
53
+ private onPageViewTrack;
54
+ private initClickHandler;
55
+ private initScrollHandler;
56
+ private initPerformanceHandler;
57
+ private initErrorHandler;
58
+ private initNetworkHandler;
59
+ }