@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,8 @@
1
+ /**
2
+ * App modes for the TraceLog Library
3
+ */
4
+ export var Mode;
5
+ (function (Mode) {
6
+ Mode["QA"] = "qa";
7
+ Mode["DEBUG"] = "debug";
8
+ })(Mode || (Mode = {}));
@@ -0,0 +1,23 @@
1
+ import { MetadataType } from './common.types';
2
+ import { DeviceType } from './device.types';
3
+ import { EventData } from './event.types';
4
+ export interface BaseEventsQueueDto {
5
+ user_id: string;
6
+ session_id: string;
7
+ device: DeviceType;
8
+ events: EventData[];
9
+ global_metadata?: Record<string, MetadataType>;
10
+ }
11
+ export interface ExtendedEventsQueueDto extends BaseEventsQueueDto {
12
+ project: string;
13
+ source: string;
14
+ ip: string;
15
+ }
16
+ export interface PersistedQueueData {
17
+ userId: string;
18
+ sessionId: string;
19
+ device: BaseEventsQueueDto['device'];
20
+ events: BaseEventsQueueDto['events'];
21
+ timestamp: number;
22
+ global_metadata?: BaseEventsQueueDto['global_metadata'];
23
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,65 @@
1
+ export type SessionEndReason = 'inactivity' | 'page_unload' | 'manual_stop' | 'orphaned_cleanup' | 'tab_closed';
2
+ export interface SessionEndConfig {
3
+ enablePageUnloadHandlers: boolean;
4
+ syncTimeoutMs: number;
5
+ maxRetries: number;
6
+ debugMode: boolean;
7
+ }
8
+ export interface SessionEndResult {
9
+ success: boolean;
10
+ reason: SessionEndReason;
11
+ timestamp: number;
12
+ eventsFlushed: number;
13
+ method: 'async' | 'sync';
14
+ }
15
+ export interface SessionEndStats {
16
+ totalSessionEnds: number;
17
+ successfulEnds: number;
18
+ failedEnds: number;
19
+ duplicatePrevented: number;
20
+ reasonCounts: Record<SessionEndReason, number>;
21
+ }
22
+ export interface CrossTabSessionConfig {
23
+ tabHeartbeatIntervalMs: number;
24
+ tabElectionTimeoutMs: number;
25
+ debugMode: boolean;
26
+ }
27
+ export interface TabInfo {
28
+ id: string;
29
+ lastHeartbeat: number;
30
+ isLeader: boolean;
31
+ sessionId: string;
32
+ startTime: number;
33
+ }
34
+ export interface CrossTabMessage {
35
+ type: 'heartbeat' | 'session_start' | 'session_end' | 'tab_closing' | 'election_request' | 'election_response';
36
+ tabId: string;
37
+ sessionId?: string;
38
+ timestamp: number;
39
+ data?: Record<string, unknown>;
40
+ }
41
+ export interface SessionRecoveryConfig {
42
+ recoveryWindowMs: number;
43
+ maxRecoveryAttempts: number;
44
+ contextPreservation: boolean;
45
+ }
46
+ export interface SessionContext {
47
+ sessionId: string;
48
+ startTime: number;
49
+ lastActivity: number;
50
+ tabCount: number;
51
+ recoveryAttempts: number;
52
+ metadata?: Record<string, unknown>;
53
+ }
54
+ export interface RecoveryAttempt {
55
+ sessionId: string;
56
+ timestamp: number;
57
+ attempt: number;
58
+ context: SessionContext;
59
+ }
60
+ export interface SessionHealth {
61
+ recoveryAttempts: number;
62
+ sessionTimeouts: number;
63
+ crossTabConflicts: number;
64
+ lastHealthCheck: number;
65
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import { Config } from './config.types';
2
+ import { DeviceType } from './device.types';
3
+ export interface State {
4
+ apiUrl: string;
5
+ config: Config;
6
+ sessionId: string | null;
7
+ userId: string;
8
+ device: DeviceType;
9
+ pageUrl: string;
10
+ hasStartSession: boolean;
11
+ suppressNextScroll: boolean;
12
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
1
+ import { EventType } from './event.types';
2
+ export declare enum TagLogicalOperator {
3
+ AND = "AND",
4
+ OR = "OR"
5
+ }
6
+ export declare enum TagConditionType {
7
+ URL_MATCHES = "url_matches",
8
+ ELEMENT_MATCHES = "element_matches",
9
+ DEVICE_TYPE = "device_type",
10
+ ELEMENT_TEXT = "element_text",
11
+ ELEMENT_ATTRIBUTE = "element_attribute",
12
+ UTM_SOURCE = "utm_source",
13
+ UTM_MEDIUM = "utm_medium",
14
+ UTM_CAMPAIGN = "utm_campaign"
15
+ }
16
+ export declare enum TagConditionOperator {
17
+ EQUALS = "equals",
18
+ CONTAINS = "contains",
19
+ STARTS_WITH = "starts_with",
20
+ ENDS_WITH = "ends_with",
21
+ REGEX = "regex",
22
+ GREATER_THAN = "greater_than",
23
+ LESS_THAN = "less_than",
24
+ EXISTS = "exists",
25
+ NOT_EXISTS = "not_exists"
26
+ }
27
+ export type TagConfig = Pick<Tag, 'key' | 'triggerType' | 'logicalOperator' | 'conditions'> & {
28
+ id: string;
29
+ };
30
+ export interface Tag {
31
+ key: string;
32
+ name: string;
33
+ description?: string;
34
+ active: boolean;
35
+ triggerType: EventType;
36
+ logicalOperator?: TagLogicalOperator;
37
+ conditions: TagCondition[];
38
+ }
39
+ export interface TagCondition {
40
+ type: TagConditionType;
41
+ operator: TagConditionOperator;
42
+ value: string;
43
+ }
@@ -0,0 +1,28 @@
1
+ export var TagLogicalOperator;
2
+ (function (TagLogicalOperator) {
3
+ TagLogicalOperator["AND"] = "AND";
4
+ TagLogicalOperator["OR"] = "OR";
5
+ })(TagLogicalOperator || (TagLogicalOperator = {}));
6
+ export var TagConditionType;
7
+ (function (TagConditionType) {
8
+ TagConditionType["URL_MATCHES"] = "url_matches";
9
+ TagConditionType["ELEMENT_MATCHES"] = "element_matches";
10
+ TagConditionType["DEVICE_TYPE"] = "device_type";
11
+ TagConditionType["ELEMENT_TEXT"] = "element_text";
12
+ TagConditionType["ELEMENT_ATTRIBUTE"] = "element_attribute";
13
+ TagConditionType["UTM_SOURCE"] = "utm_source";
14
+ TagConditionType["UTM_MEDIUM"] = "utm_medium";
15
+ TagConditionType["UTM_CAMPAIGN"] = "utm_campaign";
16
+ })(TagConditionType || (TagConditionType = {}));
17
+ export var TagConditionOperator;
18
+ (function (TagConditionOperator) {
19
+ TagConditionOperator["EQUALS"] = "equals";
20
+ TagConditionOperator["CONTAINS"] = "contains";
21
+ TagConditionOperator["STARTS_WITH"] = "starts_with";
22
+ TagConditionOperator["ENDS_WITH"] = "ends_with";
23
+ TagConditionOperator["REGEX"] = "regex";
24
+ TagConditionOperator["GREATER_THAN"] = "greater_than";
25
+ TagConditionOperator["LESS_THAN"] = "less_than";
26
+ TagConditionOperator["EXISTS"] = "exists";
27
+ TagConditionOperator["NOT_EXISTS"] = "not_exists";
28
+ })(TagConditionOperator || (TagConditionOperator = {}));
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Custom error classes for TraceLog validation errors
3
+ * Provides better error handling and consistency across validation layers
4
+ */
5
+ /**
6
+ * Base class for all TraceLog validation errors
7
+ */
8
+ export declare abstract class TraceLogValidationError extends Error {
9
+ readonly errorCode: string;
10
+ readonly layer: 'config' | 'app' | 'runtime';
11
+ constructor(message: string, errorCode: string, layer: 'config' | 'app' | 'runtime');
12
+ }
13
+ /**
14
+ * Thrown when project ID validation fails
15
+ */
16
+ export declare class ProjectIdValidationError extends TraceLogValidationError {
17
+ constructor(message?: string, layer?: 'config' | 'app' | 'runtime');
18
+ }
19
+ /**
20
+ * Thrown when app configuration validation fails
21
+ */
22
+ export declare class AppConfigValidationError extends TraceLogValidationError {
23
+ constructor(message: string, layer?: 'config' | 'app' | 'runtime');
24
+ }
25
+ /**
26
+ * Thrown when session timeout validation fails
27
+ */
28
+ export declare class SessionTimeoutValidationError extends TraceLogValidationError {
29
+ constructor(message: string, layer?: 'config' | 'app' | 'runtime');
30
+ }
31
+ /**
32
+ * Thrown when sampling rate validation fails
33
+ */
34
+ export declare class SamplingRateValidationError extends TraceLogValidationError {
35
+ constructor(message: string, layer?: 'config' | 'app' | 'runtime');
36
+ }
37
+ /**
38
+ * Thrown when integrations validation fails
39
+ */
40
+ export declare class IntegrationValidationError extends TraceLogValidationError {
41
+ constructor(message: string, layer?: 'config' | 'app' | 'runtime');
42
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Custom error classes for TraceLog validation errors
3
+ * Provides better error handling and consistency across validation layers
4
+ */
5
+ /**
6
+ * Base class for all TraceLog validation errors
7
+ */
8
+ export class TraceLogValidationError extends Error {
9
+ constructor(message, errorCode, layer) {
10
+ super(message);
11
+ this.errorCode = errorCode;
12
+ this.layer = layer;
13
+ this.name = this.constructor.name;
14
+ // Maintains proper stack trace for where error was thrown (only available on V8)
15
+ if (Error.captureStackTrace) {
16
+ Error.captureStackTrace(this, this.constructor);
17
+ }
18
+ }
19
+ }
20
+ /**
21
+ * Thrown when project ID validation fails
22
+ */
23
+ export class ProjectIdValidationError extends TraceLogValidationError {
24
+ constructor(message = 'Project ID is required', layer = 'config') {
25
+ super(message, 'PROJECT_ID_INVALID', layer);
26
+ }
27
+ }
28
+ /**
29
+ * Thrown when app configuration validation fails
30
+ */
31
+ export class AppConfigValidationError extends TraceLogValidationError {
32
+ constructor(message, layer = 'config') {
33
+ super(message, 'APP_CONFIG_INVALID', layer);
34
+ }
35
+ }
36
+ /**
37
+ * Thrown when session timeout validation fails
38
+ */
39
+ export class SessionTimeoutValidationError extends TraceLogValidationError {
40
+ constructor(message, layer = 'config') {
41
+ super(message, 'SESSION_TIMEOUT_INVALID', layer);
42
+ }
43
+ }
44
+ /**
45
+ * Thrown when sampling rate validation fails
46
+ */
47
+ export class SamplingRateValidationError extends TraceLogValidationError {
48
+ constructor(message, layer = 'config') {
49
+ super(message, 'SAMPLING_RATE_INVALID', layer);
50
+ }
51
+ }
52
+ /**
53
+ * Thrown when integrations validation fails
54
+ */
55
+ export class IntegrationValidationError extends TraceLogValidationError {
56
+ constructor(message, layer = 'config') {
57
+ super(message, 'INTEGRATION_INVALID', layer);
58
+ }
59
+ }
@@ -0,0 +1,6 @@
1
+ import { WebVitalType } from './event.types';
2
+ export type NavigationId = string;
3
+ export interface VitalSample {
4
+ type: WebVitalType;
5
+ value: number;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { App } from '../app';
2
+ /**
3
+ * Testing bridge interface for E2E tests
4
+ * Only available when NODE_ENV=dev
5
+ */
6
+ export interface TraceLogTestBridge extends App {
7
+ isInitializing(): boolean;
8
+ }
9
+ declare global {
10
+ interface Window {
11
+ /**
12
+ * Testing bridge for E2E tests
13
+ * Only available when NODE_ENV=dev
14
+ */
15
+ __traceLogBridge?: TraceLogTestBridge;
16
+ }
17
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { DeviceType } from '../../types/device.types';
2
+ /**
3
+ * Detects the device type based on screen size, user agent, and browser capabilities
4
+ * @returns The detected device type
5
+ */
6
+ export declare const getDeviceType: () => DeviceType;
@@ -0,0 +1,67 @@
1
+ import { DeviceType } from '../../types/device.types';
2
+ import { debugLog } from '../logging';
3
+ let coarsePointerQuery;
4
+ let noHoverQuery;
5
+ const initMediaQueries = () => {
6
+ if (typeof window !== 'undefined' && !coarsePointerQuery) {
7
+ coarsePointerQuery = window.matchMedia('(pointer: coarse)');
8
+ noHoverQuery = window.matchMedia('(hover: none)');
9
+ }
10
+ };
11
+ /**
12
+ * Detects the device type based on screen size, user agent, and browser capabilities
13
+ * @returns The detected device type
14
+ */
15
+ export const getDeviceType = () => {
16
+ try {
17
+ debugLog.debug('DeviceDetector', 'Starting device detection');
18
+ const nav = navigator;
19
+ if (nav.userAgentData && typeof nav.userAgentData.mobile === 'boolean') {
20
+ debugLog.debug('DeviceDetector', 'Using modern User-Agent Client Hints API', {
21
+ mobile: nav.userAgentData.mobile,
22
+ platform: nav.userAgentData.platform,
23
+ });
24
+ if (nav.userAgentData.platform && /ipad|tablet/i.test(nav.userAgentData.platform)) {
25
+ debugLog.debug('DeviceDetector', 'Device detected as tablet via platform hint');
26
+ return DeviceType.Tablet;
27
+ }
28
+ const result = nav.userAgentData.mobile ? DeviceType.Mobile : DeviceType.Desktop;
29
+ debugLog.debug('DeviceDetector', 'Device detected via User-Agent hints', { result });
30
+ return result;
31
+ }
32
+ debugLog.debug('DeviceDetector', 'Using fallback detection methods');
33
+ initMediaQueries();
34
+ const width = window.innerWidth;
35
+ const hasCoarsePointer = coarsePointerQuery?.matches ?? false;
36
+ const hasNoHover = noHoverQuery?.matches ?? false;
37
+ const hasTouchSupport = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
38
+ const ua = navigator.userAgent.toLowerCase();
39
+ const isMobileUA = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(ua);
40
+ const isTabletUA = /tablet|ipad|android(?!.*mobile)/.test(ua);
41
+ const detectionData = {
42
+ width,
43
+ hasCoarsePointer,
44
+ hasNoHover,
45
+ hasTouchSupport,
46
+ isMobileUA,
47
+ isTabletUA,
48
+ maxTouchPoints: navigator.maxTouchPoints,
49
+ };
50
+ if (width <= 767 || (isMobileUA && hasTouchSupport)) {
51
+ debugLog.debug('DeviceDetector', 'Device detected as mobile', detectionData);
52
+ return DeviceType.Mobile;
53
+ }
54
+ if ((width >= 768 && width <= 1024) || isTabletUA || (hasCoarsePointer && hasNoHover && hasTouchSupport)) {
55
+ debugLog.debug('DeviceDetector', 'Device detected as tablet', detectionData);
56
+ return DeviceType.Tablet;
57
+ }
58
+ debugLog.debug('DeviceDetector', 'Device detected as desktop', detectionData);
59
+ return DeviceType.Desktop;
60
+ }
61
+ catch (error) {
62
+ debugLog.warn('DeviceDetector', 'Device detection failed, defaulting to desktop', {
63
+ error: error instanceof Error ? error.message : error,
64
+ });
65
+ return DeviceType.Desktop;
66
+ }
67
+ };
@@ -0,0 +1,2 @@
1
+ export * from './device-detector.utils';
2
+ export * from './utm-params.utils';
@@ -0,0 +1,2 @@
1
+ export * from './device-detector.utils';
2
+ export * from './utm-params.utils';
@@ -0,0 +1,6 @@
1
+ import { UTM } from '../../types/event.types';
2
+ /**
3
+ * Extracts UTM parameters from the current URL
4
+ * @returns UTM parameters object or undefined if none found
5
+ */
6
+ export declare const getUTMParameters: () => UTM | undefined;
@@ -0,0 +1,33 @@
1
+ import { UTM_PARAMS } from '../../constants';
2
+ import { debugLog } from '../logging';
3
+ /**
4
+ * Extracts UTM parameters from the current URL
5
+ * @returns UTM parameters object or undefined if none found
6
+ */
7
+ export const getUTMParameters = () => {
8
+ debugLog.debug('UTMParams', 'Extracting UTM parameters from URL', {
9
+ url: window.location.href,
10
+ search: window.location.search,
11
+ });
12
+ const urlParams = new URLSearchParams(window.location.search);
13
+ const utmParams = {};
14
+ UTM_PARAMS.forEach((param) => {
15
+ const value = urlParams.get(param);
16
+ if (value) {
17
+ const key = param.split('utm_')[1];
18
+ utmParams[key] = value;
19
+ debugLog.debug('UTMParams', 'Found UTM parameter', { param, key, value });
20
+ }
21
+ });
22
+ const result = Object.keys(utmParams).length ? utmParams : undefined;
23
+ if (result) {
24
+ debugLog.debug('UTMParams', 'UTM parameters extracted successfully', {
25
+ parameterCount: Object.keys(result).length,
26
+ parameters: Object.keys(result),
27
+ });
28
+ }
29
+ else {
30
+ debugLog.debug('UTMParams', 'No UTM parameters found in URL');
31
+ }
32
+ return result;
33
+ };
@@ -0,0 +1 @@
1
+ export * from './uuid.utils';
@@ -0,0 +1 @@
1
+ export * from './uuid.utils';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generates a RFC4122 compliant UUID v4
3
+ * @returns A UUID string
4
+ */
5
+ export declare const generateUUID: () => string;
@@ -0,0 +1,14 @@
1
+ import { debugLog } from '../logging';
2
+ /**
3
+ * Generates a RFC4122 compliant UUID v4
4
+ * @returns A UUID string
5
+ */
6
+ export const generateUUID = () => {
7
+ const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
8
+ const r = (Math.random() * 16) | 0;
9
+ const v = c === 'x' ? r : (r & 0x3) | 0x8;
10
+ return v.toString(16);
11
+ });
12
+ debugLog.verbose('UUIDUtils', 'Generated new UUID', { uuid });
13
+ return uuid;
14
+ };
@@ -0,0 +1,6 @@
1
+ export * from './browser';
2
+ export * from './data';
3
+ export * from './logging';
4
+ export * from './network';
5
+ export * from './security';
6
+ export * from './validations';
@@ -0,0 +1,6 @@
1
+ export * from './browser';
2
+ export * from './data';
3
+ export * from './logging';
4
+ export * from './network';
5
+ export * from './security';
6
+ export * from './validations';
@@ -0,0 +1,56 @@
1
+ import { StateManager } from '../../managers/state.manager';
2
+ /**
3
+ * Debug logger class that extends StateManager for clean access to global state
4
+ */
5
+ declare class DebugLogger extends StateManager {
6
+ /**
7
+ * Client-facing error - Configuration/usage errors by the client
8
+ * Console: qa and debug modes | Events: NODE_ENV=dev
9
+ */
10
+ clientError(namespace: string, message: string, data?: unknown): void;
11
+ /**
12
+ * Client-facing warning - Configuration/usage warnings by the client
13
+ * Console: qa and debug modes | Events: NODE_ENV=dev
14
+ */
15
+ clientWarn(namespace: string, message: string, data?: unknown): void;
16
+ /**
17
+ * General operational information
18
+ * Console: qa and debug modes | Events: NODE_ENV=dev
19
+ */
20
+ info(namespace: string, message: string, data?: unknown): void;
21
+ /**
22
+ * Internal library errors
23
+ * Console: debug mode only | Events: NODE_ENV=dev
24
+ */
25
+ error(namespace: string, message: string, data?: unknown): void;
26
+ /**
27
+ * Internal library warnings
28
+ * Console: debug mode only | Events: NODE_ENV=dev
29
+ */
30
+ warn(namespace: string, message: string, data?: unknown): void;
31
+ /**
32
+ * Strategic debug information
33
+ * Console: debug mode only | Events: NODE_ENV=dev
34
+ */
35
+ debug(namespace: string, message: string, data?: unknown): void;
36
+ /**
37
+ * Detailed trace information
38
+ * Console: debug mode only | Events: NODE_ENV=dev
39
+ */
40
+ verbose(namespace: string, message: string, data?: unknown): void;
41
+ private getCurrentMode;
42
+ private shouldShowLog;
43
+ private formatMessage;
44
+ private getConsoleMethod;
45
+ private logMessage;
46
+ /**
47
+ * Dispatches tracelog:log events for E2E testing and development debugging
48
+ */
49
+ private dispatchEvent;
50
+ }
51
+ /**
52
+ * Singleton debug logger instance
53
+ * Provides the same API as before: debugLog.clientError(), debugLog.info(), etc.
54
+ */
55
+ export declare const debugLog: DebugLogger;
56
+ export {};