@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,353 @@
1
+ import { SESSION_HEARTBEAT_INTERVAL_MS, SESSION_STORAGE_KEY, DEFAULT_SESSION_TIMEOUT_MS, SESSION_SYNC_CONSTANTS, } from '../constants';
2
+ import { EventType } from '../types';
3
+ import { SessionManager } from '../managers/session.manager';
4
+ import { SessionRecoveryManager } from '../managers/session-recovery.manager';
5
+ import { CrossTabSessionManager } from '../managers/cross-tab-session.manager';
6
+ import { StateManager } from '../managers/state.manager';
7
+ import { debugLog } from '../utils/logging';
8
+ export class SessionHandler extends StateManager {
9
+ get crossTabSessionManager() {
10
+ if (!this._crossTabSessionManager && !this._isInitializingCrossTab && this.shouldUseCrossTabs()) {
11
+ this._isInitializingCrossTab = true;
12
+ try {
13
+ const projectId = this.get('config')?.id;
14
+ if (projectId) {
15
+ this.initializeCrossTabSessionManager(projectId);
16
+ }
17
+ }
18
+ catch (error) {
19
+ debugLog.error('SessionHandler', 'Failed to initialize cross-tab session manager', {
20
+ error: error instanceof Error ? error.message : 'Unknown error',
21
+ });
22
+ }
23
+ finally {
24
+ this._isInitializingCrossTab = false;
25
+ }
26
+ }
27
+ return this._crossTabSessionManager;
28
+ }
29
+ shouldUseCrossTabs() {
30
+ // Only initialize if BroadcastChannel is supported (indicates potential for multiple tabs)
31
+ // and ServiceWorker is available (better cross-tab coordination)
32
+ return typeof BroadcastChannel !== 'undefined' && typeof navigator !== 'undefined' && 'serviceWorker' in navigator;
33
+ }
34
+ constructor(storageManager, eventManager) {
35
+ super();
36
+ this.sessionManager = null;
37
+ this.recoveryManager = null;
38
+ this._crossTabSessionManager = null;
39
+ this.heartbeatInterval = null;
40
+ this._isInitializingCrossTab = false;
41
+ this.eventManager = eventManager;
42
+ this.storageManager = storageManager;
43
+ this.sessionStorageKey = SESSION_STORAGE_KEY(this.get('config')?.id);
44
+ const projectId = this.get('config')?.id;
45
+ if (projectId) {
46
+ this.initializeSessionRecoveryManager(projectId);
47
+ // CrossTabSessionManager will be initialized lazily when needed via the getter
48
+ }
49
+ }
50
+ startTracking() {
51
+ if (this.sessionManager) {
52
+ debugLog.debug('SessionHandler', 'Session tracking already active');
53
+ return;
54
+ }
55
+ debugLog.debug('SessionHandler', 'Starting session tracking');
56
+ this.checkOrphanedSessions();
57
+ const onActivity = async () => {
58
+ if (this.crossTabSessionManager) {
59
+ this.crossTabSessionManager.updateSessionActivity();
60
+ }
61
+ if (this.get('sessionId')) {
62
+ return;
63
+ }
64
+ try {
65
+ const sessionResult = await this.createOrJoinSession();
66
+ this.set('sessionId', sessionResult.sessionId);
67
+ debugLog.info('SessionHandler', '🏁 Session started', {
68
+ sessionId: sessionResult.sessionId,
69
+ recovered: sessionResult.recovered,
70
+ crossTabActive: !!this.crossTabSessionManager,
71
+ });
72
+ this.trackSession(EventType.SESSION_START, sessionResult.recovered);
73
+ this.persistSession(sessionResult.sessionId);
74
+ this.startHeartbeat();
75
+ }
76
+ catch (error) {
77
+ debugLog.error('SessionHandler', `Session creation failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
78
+ this.forceCleanupSession();
79
+ }
80
+ };
81
+ const onInactivity = () => {
82
+ if (!this.get('sessionId')) {
83
+ return;
84
+ }
85
+ if (this.crossTabSessionManager && this.crossTabSessionManager.getEffectiveSessionTimeout() > 0) {
86
+ if (this.get('config')?.mode === 'qa' || this.get('config')?.mode === 'debug') {
87
+ debugLog.debug('SessionHandler', 'Session kept alive by cross-tab activity');
88
+ }
89
+ return;
90
+ }
91
+ this.sessionManager.endSessionManaged('inactivity')
92
+ .then((result) => {
93
+ debugLog.info('SessionHandler', '🛑 Session ended by inactivity', {
94
+ sessionId: this.get('sessionId'),
95
+ reason: result.reason,
96
+ success: result.success,
97
+ eventsFlushed: result.eventsFlushed,
98
+ });
99
+ if (this.crossTabSessionManager) {
100
+ this.crossTabSessionManager.endSession('inactivity');
101
+ }
102
+ this.clearPersistedSession();
103
+ this.stopHeartbeat();
104
+ })
105
+ .catch((error) => {
106
+ debugLog.error('SessionHandler', `Session end failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
107
+ this.forceCleanupSession();
108
+ });
109
+ };
110
+ const sessionEndConfig = {
111
+ enablePageUnloadHandlers: true,
112
+ debugMode: (this.get('config')?.mode === 'qa' || this.get('config')?.mode === 'debug') ?? false,
113
+ syncTimeoutMs: SESSION_SYNC_CONSTANTS.SYNC_TIMEOUT_MS,
114
+ maxRetries: SESSION_SYNC_CONSTANTS.MAX_RETRY_ATTEMPTS,
115
+ };
116
+ this.sessionManager = new SessionManager(onActivity, onInactivity, this.eventManager, this.storageManager, sessionEndConfig);
117
+ debugLog.debug('SessionHandler', 'Session manager initialized');
118
+ this.startInitialSession();
119
+ }
120
+ stopTracking() {
121
+ debugLog.info('SessionHandler', 'Stopping session tracking');
122
+ if (this.sessionManager) {
123
+ if (this.get('sessionId')) {
124
+ try {
125
+ this.sessionManager.endSessionSafely('manual_stop', { forceSync: true });
126
+ this.clearPersistedSession();
127
+ this.stopHeartbeat();
128
+ }
129
+ catch (error) {
130
+ debugLog.error('SessionHandler', `Manual session stop failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
131
+ this.forceCleanupSession();
132
+ }
133
+ }
134
+ this.sessionManager.destroy();
135
+ this.sessionManager = null;
136
+ }
137
+ if (this._crossTabSessionManager) {
138
+ this._crossTabSessionManager.destroy();
139
+ this._crossTabSessionManager = null;
140
+ }
141
+ // Reset cross-tab initialization flag
142
+ this._isInitializingCrossTab = false;
143
+ if (this.recoveryManager) {
144
+ this.recoveryManager.cleanupOldRecoveryAttempts();
145
+ this.recoveryManager = null;
146
+ }
147
+ }
148
+ initializeSessionRecoveryManager(projectId) {
149
+ this.recoveryManager = new SessionRecoveryManager(this.storageManager, projectId, this.eventManager);
150
+ debugLog.debug('SessionHandler', 'Session recovery manager initialized', { projectId });
151
+ }
152
+ initializeCrossTabSessionManager(projectId) {
153
+ const config = {
154
+ debugMode: (this.get('config')?.mode === 'qa' || this.get('config')?.mode === 'debug') ?? false,
155
+ };
156
+ const onSessionStart = (sessionId) => {
157
+ if (this.get('config')?.mode === 'qa' || this.get('config')?.mode === 'debug') {
158
+ debugLog.debug('SessionHandler', `Cross-tab session started: ${sessionId}`);
159
+ }
160
+ this.set('sessionId', sessionId);
161
+ this.trackSession(EventType.SESSION_START, false);
162
+ this.persistSession(sessionId);
163
+ this.startHeartbeat();
164
+ };
165
+ const onSessionEnd = (reason) => {
166
+ if (this.get('config')?.mode === 'qa' || this.get('config')?.mode === 'debug') {
167
+ debugLog.debug('SessionHandler', `Cross-tab session ended: ${reason}`);
168
+ }
169
+ this.clearPersistedSession();
170
+ this.trackSession(EventType.SESSION_END, false, reason);
171
+ };
172
+ const onTabActivity = () => {
173
+ if (this.get('config')?.mode === 'qa' || this.get('config')?.mode === 'debug') {
174
+ debugLog.debug('SessionHandler', 'Cross-tab activity detected');
175
+ }
176
+ };
177
+ const onCrossTabConflict = () => {
178
+ if (this.get('config')?.mode === 'qa' || this.get('config')?.mode === 'debug') {
179
+ debugLog.warn('SessionHandler', 'Cross-tab conflict detected');
180
+ }
181
+ // Track cross-tab conflict in session health
182
+ if (this.sessionManager) {
183
+ this.sessionManager.trackSessionHealth('conflict');
184
+ }
185
+ };
186
+ const callbacks = {
187
+ onSessionStart,
188
+ onSessionEnd,
189
+ onTabActivity,
190
+ onCrossTabConflict,
191
+ };
192
+ this._crossTabSessionManager = new CrossTabSessionManager(this.storageManager, projectId, config, callbacks);
193
+ debugLog.debug('SessionHandler', 'Cross-tab session manager initialized', { projectId });
194
+ }
195
+ async createOrJoinSession() {
196
+ if (this.crossTabSessionManager) {
197
+ const existingSessionId = this.crossTabSessionManager.getSessionId();
198
+ if (existingSessionId) {
199
+ return { sessionId: existingSessionId, recovered: false };
200
+ }
201
+ // If cross-tab manager exists but no session, create one through regular session manager
202
+ // The cross-tab manager will coordinate with other tabs automatically
203
+ const sessionResult = this.sessionManager.startSession();
204
+ return { sessionId: sessionResult.sessionId, recovered: sessionResult.recovered ?? false };
205
+ }
206
+ // Fallback: create regular session when no cross-tab manager
207
+ const sessionResult = this.sessionManager.startSession();
208
+ return { sessionId: sessionResult.sessionId, recovered: sessionResult.recovered ?? false };
209
+ }
210
+ forceCleanupSession() {
211
+ // Clear session state
212
+ this.set('sessionId', null);
213
+ // Clear persisted session data
214
+ this.clearPersistedSession();
215
+ // Stop heartbeat timer
216
+ this.stopHeartbeat();
217
+ // Clean up cross-tab session if exists
218
+ if (this.crossTabSessionManager) {
219
+ try {
220
+ this.crossTabSessionManager.endSession('orphaned_cleanup');
221
+ }
222
+ catch (error) {
223
+ // Silent cleanup - we're already in error recovery
224
+ if (this.get('config')?.mode === 'qa' || this.get('config')?.mode === 'debug') {
225
+ debugLog.warn('SessionHandler', `Cross-tab cleanup failed during force cleanup: ${error instanceof Error ? error.message : 'Unknown error'}`);
226
+ }
227
+ }
228
+ }
229
+ // Track session end for analytics
230
+ try {
231
+ this.trackSession(EventType.SESSION_END, false, 'orphaned_cleanup');
232
+ }
233
+ catch (error) {
234
+ // Silent tracking failure - we're already in error recovery
235
+ if (this.get('config')?.mode === 'qa' || this.get('config')?.mode === 'debug') {
236
+ debugLog.warn('SessionHandler', `Session tracking failed during force cleanup: ${error instanceof Error ? error.message : 'Unknown error'}`);
237
+ }
238
+ }
239
+ if (this.get('config')?.mode === 'qa' || this.get('config')?.mode === 'debug') {
240
+ debugLog.debug('SessionHandler', 'Forced session cleanup completed');
241
+ }
242
+ }
243
+ trackSession(eventType, sessionStartRecovered = false, sessionEndReason) {
244
+ this.eventManager.track({
245
+ type: eventType,
246
+ ...(eventType === EventType.SESSION_START &&
247
+ sessionStartRecovered && { session_start_recovered: sessionStartRecovered }),
248
+ ...(eventType === EventType.SESSION_END && { session_end_reason: sessionEndReason ?? 'orphaned_cleanup' }),
249
+ });
250
+ }
251
+ startInitialSession() {
252
+ if (this.get('sessionId')) {
253
+ debugLog.debug('SessionHandler', 'Session already exists, skipping initial session creation');
254
+ return;
255
+ }
256
+ debugLog.debug('SessionHandler', 'Starting initial session');
257
+ // Check if there's already a cross-tab session active
258
+ if (this.crossTabSessionManager) {
259
+ const existingSessionId = this.crossTabSessionManager.getSessionId();
260
+ if (existingSessionId) {
261
+ // Join existing cross-tab session
262
+ this.set('sessionId', existingSessionId);
263
+ this.persistSession(existingSessionId);
264
+ this.startHeartbeat();
265
+ return;
266
+ }
267
+ // No existing cross-tab session, so trigger activity to potentially create one
268
+ // The cross-tab session manager will handle session creation when activity occurs
269
+ return;
270
+ }
271
+ // Fallback: no cross-tab session manager, start regular session
272
+ debugLog.debug('SessionHandler', 'Starting regular session (no cross-tab)');
273
+ const sessionResult = this.sessionManager.startSession();
274
+ this.set('sessionId', sessionResult.sessionId);
275
+ this.trackSession(EventType.SESSION_START, sessionResult.recovered);
276
+ this.persistSession(sessionResult.sessionId);
277
+ this.startHeartbeat();
278
+ }
279
+ checkOrphanedSessions() {
280
+ const storedSessionData = this.storageManager.getItem(this.sessionStorageKey);
281
+ if (storedSessionData) {
282
+ try {
283
+ const session = JSON.parse(storedSessionData);
284
+ const now = Date.now();
285
+ const timeSinceLastHeartbeat = now - session.lastHeartbeat;
286
+ const sessionTimeout = this.get('config')?.sessionTimeout ?? DEFAULT_SESSION_TIMEOUT_MS;
287
+ if (timeSinceLastHeartbeat > sessionTimeout) {
288
+ const canRecover = this.recoveryManager?.hasRecoverableSession();
289
+ if (canRecover) {
290
+ if (this.recoveryManager) {
291
+ const sessionContext = {
292
+ sessionId: session.sessionId,
293
+ startTime: session.startTime,
294
+ lastActivity: session.lastHeartbeat,
295
+ tabCount: 1,
296
+ recoveryAttempts: 0,
297
+ metadata: {
298
+ userAgent: navigator.userAgent,
299
+ pageUrl: this.get('pageUrl'),
300
+ },
301
+ };
302
+ this.recoveryManager.storeSessionContextForRecovery(sessionContext);
303
+ if (this.get('config')?.mode === 'qa' || this.get('config')?.mode === 'debug') {
304
+ debugLog.debug('SessionHandler', `Orphaned session stored for recovery: ${session.sessionId}`);
305
+ }
306
+ }
307
+ }
308
+ this.trackSession(EventType.SESSION_END);
309
+ this.clearPersistedSession();
310
+ if (this.get('config')?.mode === 'qa' || this.get('config')?.mode === 'debug') {
311
+ debugLog.debug('SessionHandler', `Orphaned session ended: ${session.sessionId}, recovery available: ${canRecover}`);
312
+ }
313
+ }
314
+ }
315
+ catch {
316
+ this.clearPersistedSession();
317
+ }
318
+ }
319
+ }
320
+ persistSession(sessionId) {
321
+ const sessionData = {
322
+ sessionId,
323
+ startTime: Date.now(),
324
+ lastHeartbeat: Date.now(),
325
+ };
326
+ this.storageManager.setItem(this.sessionStorageKey, JSON.stringify(sessionData));
327
+ }
328
+ clearPersistedSession() {
329
+ this.storageManager.removeItem(this.sessionStorageKey);
330
+ }
331
+ startHeartbeat() {
332
+ this.stopHeartbeat();
333
+ this.heartbeatInterval = setInterval(() => {
334
+ const storedSessionData = this.storageManager.getItem(this.sessionStorageKey);
335
+ if (storedSessionData) {
336
+ try {
337
+ const session = JSON.parse(storedSessionData);
338
+ session.lastHeartbeat = Date.now();
339
+ this.storageManager.setItem(this.sessionStorageKey, JSON.stringify(session));
340
+ }
341
+ catch {
342
+ this.clearPersistedSession();
343
+ }
344
+ }
345
+ }, SESSION_HEARTBEAT_INTERVAL_MS);
346
+ }
347
+ stopHeartbeat() {
348
+ if (this.heartbeatInterval) {
349
+ clearInterval(this.heartbeatInterval);
350
+ this.heartbeatInterval = null;
351
+ }
352
+ }
353
+ }
@@ -0,0 +1,18 @@
1
+ import { MetadataType } from '../types';
2
+ import { StateManager } from '../managers/state.manager';
3
+ declare global {
4
+ interface Window {
5
+ gtag?: (...args: unknown[]) => void;
6
+ dataLayer?: unknown[];
7
+ }
8
+ }
9
+ export declare class GoogleAnalyticsIntegration extends StateManager {
10
+ private isInitialized;
11
+ constructor();
12
+ initialize(): Promise<void>;
13
+ trackEvent(eventName: string, metadata: Record<string, MetadataType>): void;
14
+ cleanup(): void;
15
+ private isScriptAlreadyLoaded;
16
+ private loadScript;
17
+ private configureGtag;
18
+ }
@@ -0,0 +1,155 @@
1
+ import { debugLog } from '../utils/logging';
2
+ import { StateManager } from '../managers/state.manager';
3
+ export class GoogleAnalyticsIntegration extends StateManager {
4
+ constructor() {
5
+ super();
6
+ this.isInitialized = false;
7
+ }
8
+ async initialize() {
9
+ if (this.isInitialized) {
10
+ return;
11
+ }
12
+ const measurementId = this.get('config').integrations?.googleAnalytics?.measurementId;
13
+ if (!measurementId?.trim()) {
14
+ debugLog.clientWarn('GoogleAnalytics', 'Google Analytics integration disabled - measurementId not configured', {
15
+ hasIntegrations: !!this.get('config').integrations,
16
+ hasGoogleAnalytics: !!this.get('config').integrations?.googleAnalytics,
17
+ });
18
+ return;
19
+ }
20
+ const userId = this.get('userId');
21
+ if (!userId?.trim()) {
22
+ debugLog.warn('GoogleAnalytics', 'Google Analytics initialization delayed - userId not available', {
23
+ measurementId: measurementId.substring(0, 8) + '...',
24
+ });
25
+ return;
26
+ }
27
+ try {
28
+ if (this.isScriptAlreadyLoaded()) {
29
+ debugLog.info('GoogleAnalytics', 'Google Analytics script already loaded', { measurementId });
30
+ this.isInitialized = true;
31
+ return;
32
+ }
33
+ await this.loadScript(measurementId);
34
+ this.configureGtag(measurementId, userId);
35
+ this.isInitialized = true;
36
+ debugLog.info('GoogleAnalytics', 'Google Analytics integration initialized successfully', {
37
+ measurementId,
38
+ userId,
39
+ });
40
+ }
41
+ catch (error) {
42
+ debugLog.error('GoogleAnalytics', 'Google Analytics initialization failed', {
43
+ error: error instanceof Error ? error.message : 'Unknown error',
44
+ measurementId,
45
+ userId,
46
+ });
47
+ }
48
+ }
49
+ trackEvent(eventName, metadata) {
50
+ if (!eventName?.trim()) {
51
+ debugLog.clientWarn('GoogleAnalytics', 'Event tracking skipped - invalid event name provided', {
52
+ eventName,
53
+ hasMetadata: !!metadata && Object.keys(metadata).length > 0,
54
+ });
55
+ return;
56
+ }
57
+ if (!this.isInitialized) {
58
+ return;
59
+ }
60
+ if (typeof window.gtag !== 'function') {
61
+ debugLog.warn('GoogleAnalytics', 'Event tracking failed - gtag function not available', {
62
+ eventName,
63
+ hasGtag: typeof window.gtag,
64
+ hasDataLayer: Array.isArray(window.dataLayer),
65
+ });
66
+ return;
67
+ }
68
+ try {
69
+ window.gtag('event', eventName, metadata);
70
+ }
71
+ catch (error) {
72
+ debugLog.error('GoogleAnalytics', 'Event tracking failed', {
73
+ eventName,
74
+ error: error instanceof Error ? error.message : 'Unknown error',
75
+ metadataKeys: Object.keys(metadata || {}),
76
+ });
77
+ }
78
+ }
79
+ cleanup() {
80
+ this.isInitialized = false;
81
+ const script = document.getElementById('tracelog-ga-script');
82
+ if (script) {
83
+ script.remove();
84
+ }
85
+ debugLog.info('GoogleAnalytics', 'Google Analytics integration cleanup completed');
86
+ }
87
+ isScriptAlreadyLoaded() {
88
+ const tracelogScript = document.getElementById('tracelog-ga-script');
89
+ if (tracelogScript) {
90
+ return true;
91
+ }
92
+ const existingGAScript = document.querySelector('script[src*="googletagmanager.com/gtag/js"]');
93
+ if (existingGAScript) {
94
+ debugLog.clientWarn('GoogleAnalytics', 'Google Analytics script already loaded from external source', {
95
+ scriptSrc: existingGAScript.getAttribute('src'),
96
+ hasGtag: typeof window.gtag === 'function',
97
+ });
98
+ return true;
99
+ }
100
+ return false;
101
+ }
102
+ async loadScript(measurementId) {
103
+ return new Promise((resolve, reject) => {
104
+ try {
105
+ const script = document.createElement('script');
106
+ script.id = 'tracelog-ga-script';
107
+ script.async = true;
108
+ script.src = `https://www.googletagmanager.com/gtag/js?id=${measurementId}`;
109
+ script.onload = () => {
110
+ resolve();
111
+ };
112
+ script.onerror = () => {
113
+ const error = new Error('Failed to load Google Analytics script');
114
+ debugLog.error('GoogleAnalytics', 'Google Analytics script load failed', {
115
+ measurementId,
116
+ error: error.message,
117
+ scriptSrc: script.src,
118
+ });
119
+ reject(error);
120
+ };
121
+ document.head.appendChild(script);
122
+ }
123
+ catch (error) {
124
+ const errorMsg = error instanceof Error ? error : new Error(String(error));
125
+ debugLog.error('GoogleAnalytics', 'Error creating Google Analytics script', {
126
+ measurementId,
127
+ error: errorMsg.message,
128
+ });
129
+ reject(errorMsg);
130
+ }
131
+ });
132
+ }
133
+ configureGtag(measurementId, userId) {
134
+ try {
135
+ const gaScriptConfig = document.createElement('script');
136
+ gaScriptConfig.innerHTML = `
137
+ window.dataLayer = window.dataLayer || [];
138
+ function gtag(){dataLayer.push(arguments);}
139
+ gtag('js', new Date());
140
+ gtag('config', '${measurementId}', {
141
+ 'user_id': '${userId}'
142
+ });
143
+ `;
144
+ document.head.appendChild(gaScriptConfig);
145
+ }
146
+ catch (error) {
147
+ debugLog.error('GoogleAnalytics', 'Failed to configure Google Analytics', {
148
+ measurementId,
149
+ userId,
150
+ error: error instanceof Error ? error.message : 'Unknown error',
151
+ });
152
+ throw error;
153
+ }
154
+ }
155
+ }
@@ -0,0 +1,8 @@
1
+ import { EventListenerManager } from './listeners.types';
2
+ export declare class ActivityListenerManager implements EventListenerManager {
3
+ private readonly onActivity;
4
+ private readonly options;
5
+ constructor(onActivity: () => void);
6
+ setup(): void;
7
+ cleanup(): void;
8
+ }
@@ -0,0 +1,28 @@
1
+ import { debugLog } from '../utils/logging';
2
+ export class ActivityListenerManager {
3
+ constructor(onActivity) {
4
+ this.options = { passive: true };
5
+ this.onActivity = onActivity;
6
+ }
7
+ setup() {
8
+ try {
9
+ window.addEventListener('scroll', this.onActivity, this.options);
10
+ window.addEventListener('resize', this.onActivity, this.options);
11
+ window.addEventListener('focus', this.onActivity, this.options);
12
+ }
13
+ catch (error) {
14
+ debugLog.error('ActivityListenerManager', 'Failed to setup activity listeners', { error });
15
+ throw error;
16
+ }
17
+ }
18
+ cleanup() {
19
+ try {
20
+ window.removeEventListener('scroll', this.onActivity);
21
+ window.removeEventListener('resize', this.onActivity);
22
+ window.removeEventListener('focus', this.onActivity);
23
+ }
24
+ catch (error) {
25
+ debugLog.warn('ActivityListenerManager', 'Error during activity listeners cleanup', { error });
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,6 @@
1
+ export { ActivityListenerManager } from './activity-listener-manager';
2
+ export { TouchListenerManager } from './touch-listener-manager';
3
+ export { MouseListenerManager, KeyboardListenerManager } from './input-listener-managers';
4
+ export { VisibilityListenerManager } from './visibility-listener-manager';
5
+ export { UnloadListenerManager } from './unload-listener-manager';
6
+ export type { EventListenerManager } from './listeners.types';
@@ -0,0 +1,5 @@
1
+ export { ActivityListenerManager } from './activity-listener-manager';
2
+ export { TouchListenerManager } from './touch-listener-manager';
3
+ export { MouseListenerManager, KeyboardListenerManager } from './input-listener-managers';
4
+ export { VisibilityListenerManager } from './visibility-listener-manager';
5
+ export { UnloadListenerManager } from './unload-listener-manager';
@@ -0,0 +1,15 @@
1
+ import { EventListenerManager } from './listeners.types';
2
+ export declare class MouseListenerManager implements EventListenerManager {
3
+ private readonly onActivity;
4
+ private readonly options;
5
+ constructor(onActivity: () => void);
6
+ setup(): void;
7
+ cleanup(): void;
8
+ }
9
+ export declare class KeyboardListenerManager implements EventListenerManager {
10
+ private readonly onActivity;
11
+ private readonly options;
12
+ constructor(onActivity: () => void);
13
+ setup(): void;
14
+ cleanup(): void;
15
+ }
@@ -0,0 +1,53 @@
1
+ import { debugLog } from '../utils/logging';
2
+ export class MouseListenerManager {
3
+ constructor(onActivity) {
4
+ this.options = { passive: true };
5
+ this.onActivity = onActivity;
6
+ }
7
+ setup() {
8
+ try {
9
+ window.addEventListener('mousemove', this.onActivity, this.options);
10
+ window.addEventListener('mousedown', this.onActivity, this.options);
11
+ window.addEventListener('wheel', this.onActivity, this.options);
12
+ }
13
+ catch (error) {
14
+ debugLog.error('MouseListenerManager', 'Failed to setup mouse listeners', { error });
15
+ throw error;
16
+ }
17
+ }
18
+ cleanup() {
19
+ try {
20
+ window.removeEventListener('mousemove', this.onActivity);
21
+ window.removeEventListener('mousedown', this.onActivity);
22
+ window.removeEventListener('wheel', this.onActivity);
23
+ }
24
+ catch (error) {
25
+ debugLog.warn('MouseListenerManager', 'Error during mouse listeners cleanup', { error });
26
+ }
27
+ }
28
+ }
29
+ export class KeyboardListenerManager {
30
+ constructor(onActivity) {
31
+ this.options = { passive: true };
32
+ this.onActivity = onActivity;
33
+ }
34
+ setup() {
35
+ try {
36
+ window.addEventListener('keydown', this.onActivity, this.options);
37
+ window.addEventListener('keypress', this.onActivity, this.options);
38
+ }
39
+ catch (error) {
40
+ debugLog.error('KeyboardListenerManager', 'Failed to setup keyboard listeners', { error });
41
+ throw error;
42
+ }
43
+ }
44
+ cleanup() {
45
+ try {
46
+ window.removeEventListener('keydown', this.onActivity);
47
+ window.removeEventListener('keypress', this.onActivity);
48
+ }
49
+ catch (error) {
50
+ debugLog.warn('KeyboardListenerManager', 'Error during keyboard listeners cleanup', { error });
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,4 @@
1
+ export interface EventListenerManager {
2
+ setup(): void;
3
+ cleanup(): void;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import { EventListenerManager } from './listeners.types';
2
+ export declare class TouchListenerManager implements EventListenerManager {
3
+ private readonly onActivity;
4
+ private readonly options;
5
+ private readonly motionThreshold;
6
+ constructor(onActivity: () => void, motionThreshold: number);
7
+ setup(): void;
8
+ cleanup(): void;
9
+ private readonly handleDeviceMotion;
10
+ }