@multiplayer-app/session-recorder-react-native 1.0.1-beta.3 → 1.0.1-beta.5

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 (463) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +216 -155
  3. package/SessionRecorderNative.podspec +9 -14
  4. package/android/build.gradle +21 -44
  5. package/android/gradle.properties +4 -4
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/com/multiplayer/sessionrecordernative/SessionRecorderNativeConfig.kt +52 -0
  8. package/android/src/main/java/com/multiplayer/sessionrecordernative/SessionRecorderNativeModule.kt +860 -0
  9. package/android/src/main/java/com/multiplayer/sessionrecordernative/SessionRecorderNativePackage.kt +33 -0
  10. package/android/src/main/java/com/multiplayer/sessionrecordernative/model/TargetInfo.kt +9 -0
  11. package/android/src/main/java/com/multiplayer/sessionrecordernative/util/ViewUtils.kt +72 -0
  12. package/ios/SessionRecorderNative.podspec +4 -2
  13. package/ios/SessionRecorderNative.swift +1 -1
  14. package/ios/SessionRecorderNativeSpec.swift +3 -3
  15. package/lib/module/components/ScreenRecorderView/ScreenRecorderView.js +23 -0
  16. package/lib/module/components/ScreenRecorderView/ScreenRecorderView.js.map +1 -0
  17. package/lib/module/components/ScreenRecorderView/index.js +4 -0
  18. package/lib/module/components/ScreenRecorderView/index.js.map +1 -0
  19. package/lib/module/components/SessionRecorderWidget/ErrorBanner.js +64 -0
  20. package/lib/module/components/SessionRecorderWidget/ErrorBanner.js.map +1 -0
  21. package/lib/module/components/SessionRecorderWidget/FinalPopover.js +74 -0
  22. package/lib/module/components/SessionRecorderWidget/FinalPopover.js.map +1 -0
  23. package/lib/module/components/SessionRecorderWidget/FloatingButton.js +191 -0
  24. package/lib/module/components/SessionRecorderWidget/FloatingButton.js.map +1 -0
  25. package/lib/module/components/SessionRecorderWidget/InitialPopover.js +138 -0
  26. package/lib/module/components/SessionRecorderWidget/InitialPopover.js.map +1 -0
  27. package/lib/module/components/SessionRecorderWidget/ModalContainer.js +177 -0
  28. package/lib/module/components/SessionRecorderWidget/ModalContainer.js.map +1 -0
  29. package/lib/module/components/SessionRecorderWidget/ModalHeader.js +27 -0
  30. package/lib/module/components/SessionRecorderWidget/ModalHeader.js.map +1 -0
  31. package/lib/module/components/SessionRecorderWidget/SessionRecorderWidget.js +133 -0
  32. package/lib/module/components/SessionRecorderWidget/SessionRecorderWidget.js.map +1 -0
  33. package/lib/module/components/SessionRecorderWidget/icons.js +93 -0
  34. package/lib/module/components/SessionRecorderWidget/icons.js.map +1 -0
  35. package/lib/module/components/SessionRecorderWidget/index.js +5 -0
  36. package/lib/module/components/SessionRecorderWidget/index.js.map +1 -0
  37. package/lib/module/components/SessionRecorderWidget/styles.js +173 -0
  38. package/lib/module/components/SessionRecorderWidget/styles.js.map +1 -0
  39. package/lib/module/components/index.js +5 -0
  40. package/lib/module/components/index.js.map +1 -0
  41. package/lib/module/config/constants.js +42 -0
  42. package/lib/module/config/constants.js.map +1 -0
  43. package/lib/module/config/defaults.js +81 -0
  44. package/lib/module/config/defaults.js.map +1 -0
  45. package/lib/module/config/index.js +9 -0
  46. package/lib/module/config/index.js.map +1 -0
  47. package/lib/module/config/masking.js +35 -0
  48. package/lib/module/config/masking.js.map +1 -0
  49. package/lib/module/config/session-recorder.js +44 -0
  50. package/lib/module/config/session-recorder.js.map +1 -0
  51. package/lib/module/config/validators.js +28 -0
  52. package/lib/module/config/validators.js.map +1 -0
  53. package/lib/module/config/widget.js +35 -0
  54. package/lib/module/config/widget.js.map +1 -0
  55. package/lib/module/context/SessionRecorderContext.js +93 -0
  56. package/lib/module/context/SessionRecorderContext.js.map +1 -0
  57. package/lib/module/context/SessionRecorderStore.js +12 -0
  58. package/lib/module/context/SessionRecorderStore.js.map +1 -0
  59. package/lib/module/context/useSessionRecorderStore.js +20 -0
  60. package/lib/module/context/useSessionRecorderStore.js.map +1 -0
  61. package/lib/module/context/useStoreSelector.js +27 -0
  62. package/lib/module/context/useStoreSelector.js.map +1 -0
  63. package/lib/module/index.js +13 -0
  64. package/lib/module/index.js.map +1 -0
  65. package/lib/module/native/SessionRecorderNative.js +74 -0
  66. package/lib/module/native/SessionRecorderNative.js.map +1 -0
  67. package/lib/module/native/index.js +4 -0
  68. package/lib/module/native/index.js.map +1 -0
  69. package/lib/module/otel/helpers.js +218 -0
  70. package/lib/module/otel/helpers.js.map +1 -0
  71. package/lib/module/otel/index.js +95 -0
  72. package/lib/module/otel/index.js.map +1 -0
  73. package/lib/module/otel/instrumentations/index.js +102 -0
  74. package/lib/module/otel/instrumentations/index.js.map +1 -0
  75. package/lib/module/package.json +1 -0
  76. package/lib/module/patch/index.js +4 -0
  77. package/lib/module/patch/index.js.map +1 -0
  78. package/lib/module/patch/xhr.js +116 -0
  79. package/lib/module/patch/xhr.js.map +1 -0
  80. package/lib/module/recorder/eventExporter.js +130 -0
  81. package/lib/module/recorder/eventExporter.js.map +1 -0
  82. package/lib/module/recorder/gestureRecorder.js +641 -0
  83. package/lib/module/recorder/gestureRecorder.js.map +1 -0
  84. package/lib/module/recorder/index.js +168 -0
  85. package/lib/module/recorder/index.js.map +1 -0
  86. package/lib/module/recorder/navigationTracker.js +228 -0
  87. package/lib/module/recorder/navigationTracker.js.map +1 -0
  88. package/lib/module/recorder/screenRecorder.js +495 -0
  89. package/lib/module/recorder/screenRecorder.js.map +1 -0
  90. package/lib/module/services/api.service.js +149 -0
  91. package/lib/module/services/api.service.js.map +1 -0
  92. package/lib/module/services/network.service.js +178 -0
  93. package/lib/module/services/network.service.js.map +1 -0
  94. package/lib/module/services/screenMaskingService.js +107 -0
  95. package/lib/module/services/screenMaskingService.js.map +1 -0
  96. package/lib/module/services/storage.service.js +179 -0
  97. package/lib/module/services/storage.service.js.map +1 -0
  98. package/lib/module/session-recorder.js +541 -0
  99. package/lib/module/session-recorder.js.map +1 -0
  100. package/lib/module/types/configs.js +4 -0
  101. package/lib/module/types/configs.js.map +1 -0
  102. package/lib/module/types/expo-constants.d.js +2 -0
  103. package/lib/module/types/expo-constants.d.js.map +1 -0
  104. package/lib/module/types/index.js +11 -0
  105. package/lib/module/types/index.js.map +1 -0
  106. package/lib/module/types/session-recorder.js +68 -0
  107. package/lib/module/types/session-recorder.js.map +1 -0
  108. package/lib/module/types/session.js +9 -0
  109. package/lib/module/types/session.js.map +1 -0
  110. package/lib/module/utils/app-metadata.js +28 -0
  111. package/lib/module/utils/app-metadata.js.map +1 -0
  112. package/lib/module/utils/constants.optional.expo.js +6 -0
  113. package/lib/module/utils/constants.optional.expo.js.map +1 -0
  114. package/lib/module/utils/constants.optional.js +8 -0
  115. package/lib/module/utils/constants.optional.js.map +1 -0
  116. package/lib/module/utils/createStore.js +27 -0
  117. package/lib/module/utils/createStore.js.map +1 -0
  118. package/lib/module/utils/index.js +11 -0
  119. package/lib/module/utils/index.js.map +1 -0
  120. package/lib/module/utils/logger.js +185 -0
  121. package/lib/module/utils/logger.js.map +1 -0
  122. package/lib/module/utils/platform.js +340 -0
  123. package/lib/module/utils/platform.js.map +1 -0
  124. package/lib/module/utils/request-utils.js +58 -0
  125. package/lib/module/utils/request-utils.js.map +1 -0
  126. package/lib/module/utils/rrweb-events.js +276 -0
  127. package/lib/module/utils/rrweb-events.js.map +1 -0
  128. package/lib/module/utils/session.js +21 -0
  129. package/lib/module/utils/session.js.map +1 -0
  130. package/lib/module/utils/shallowEqual.js +17 -0
  131. package/lib/module/utils/shallowEqual.js.map +1 -0
  132. package/lib/module/utils/time.js +17 -0
  133. package/lib/module/utils/time.js.map +1 -0
  134. package/lib/module/utils/type-utils.js +69 -0
  135. package/lib/module/utils/type-utils.js.map +1 -0
  136. package/lib/module/version.js +4 -0
  137. package/lib/module/version.js.map +1 -0
  138. package/lib/typescript/package.json +1 -0
  139. package/lib/typescript/src/components/ScreenRecorderView/ScreenRecorderView.d.ts +6 -0
  140. package/lib/typescript/src/components/ScreenRecorderView/ScreenRecorderView.d.ts.map +1 -0
  141. package/lib/typescript/src/components/ScreenRecorderView/index.d.ts +2 -0
  142. package/lib/typescript/src/components/ScreenRecorderView/index.d.ts.map +1 -0
  143. package/{dist → lib/typescript/src}/components/SessionRecorderWidget/ErrorBanner.d.ts +1 -0
  144. package/lib/typescript/src/components/SessionRecorderWidget/ErrorBanner.d.ts.map +1 -0
  145. package/{dist → lib/typescript/src}/components/SessionRecorderWidget/FinalPopover.d.ts +2 -1
  146. package/lib/typescript/src/components/SessionRecorderWidget/FinalPopover.d.ts.map +1 -0
  147. package/{dist → lib/typescript/src}/components/SessionRecorderWidget/FloatingButton.d.ts +1 -0
  148. package/lib/typescript/src/components/SessionRecorderWidget/FloatingButton.d.ts.map +1 -0
  149. package/{dist → lib/typescript/src}/components/SessionRecorderWidget/InitialPopover.d.ts +2 -1
  150. package/lib/typescript/src/components/SessionRecorderWidget/InitialPopover.d.ts.map +1 -0
  151. package/{dist → lib/typescript/src}/components/SessionRecorderWidget/ModalContainer.d.ts +1 -0
  152. package/lib/typescript/src/components/SessionRecorderWidget/ModalContainer.d.ts.map +1 -0
  153. package/{dist → lib/typescript/src}/components/SessionRecorderWidget/ModalHeader.d.ts +1 -0
  154. package/lib/typescript/src/components/SessionRecorderWidget/ModalHeader.d.ts.map +1 -0
  155. package/{dist → lib/typescript/src}/components/SessionRecorderWidget/SessionRecorderWidget.d.ts +1 -0
  156. package/lib/typescript/src/components/SessionRecorderWidget/SessionRecorderWidget.d.ts.map +1 -0
  157. package/{dist → lib/typescript/src}/components/SessionRecorderWidget/icons.d.ts +1 -0
  158. package/lib/typescript/src/components/SessionRecorderWidget/icons.d.ts.map +1 -0
  159. package/lib/typescript/src/components/SessionRecorderWidget/index.d.ts +3 -0
  160. package/lib/typescript/src/components/SessionRecorderWidget/index.d.ts.map +1 -0
  161. package/{dist → lib/typescript/src}/components/SessionRecorderWidget/styles.d.ts +4 -3
  162. package/lib/typescript/src/components/SessionRecorderWidget/styles.d.ts.map +1 -0
  163. package/lib/typescript/src/components/index.d.ts +3 -0
  164. package/lib/typescript/src/components/index.d.ts.map +1 -0
  165. package/{dist → lib/typescript/src}/config/constants.d.ts +1 -0
  166. package/lib/typescript/src/config/constants.d.ts.map +1 -0
  167. package/{dist → lib/typescript/src}/config/defaults.d.ts +2 -1
  168. package/lib/typescript/src/config/defaults.d.ts.map +1 -0
  169. package/{dist → lib/typescript/src}/config/index.d.ts +1 -0
  170. package/lib/typescript/src/config/index.d.ts.map +1 -0
  171. package/lib/typescript/src/config/masking.d.ts +3 -0
  172. package/lib/typescript/src/config/masking.d.ts.map +1 -0
  173. package/lib/typescript/src/config/session-recorder.d.ts +3 -0
  174. package/lib/typescript/src/config/session-recorder.d.ts.map +1 -0
  175. package/{dist → lib/typescript/src}/config/validators.d.ts +1 -0
  176. package/lib/typescript/src/config/validators.d.ts.map +1 -0
  177. package/{dist → lib/typescript/src}/config/widget.d.ts +2 -1
  178. package/lib/typescript/src/config/widget.d.ts.map +1 -0
  179. package/{dist → lib/typescript/src}/context/SessionRecorderContext.d.ts +3 -2
  180. package/lib/typescript/src/context/SessionRecorderContext.d.ts.map +1 -0
  181. package/{dist → lib/typescript/src}/context/SessionRecorderStore.d.ts +2 -1
  182. package/lib/typescript/src/context/SessionRecorderStore.d.ts.map +1 -0
  183. package/{dist → lib/typescript/src}/context/useSessionRecorderStore.d.ts +4 -3
  184. package/lib/typescript/src/context/useSessionRecorderStore.d.ts.map +1 -0
  185. package/{dist → lib/typescript/src}/context/useStoreSelector.d.ts +2 -1
  186. package/lib/typescript/src/context/useStoreSelector.d.ts.map +1 -0
  187. package/{dist → lib/typescript/src}/index.d.ts +1 -0
  188. package/lib/typescript/src/index.d.ts.map +1 -0
  189. package/{dist → lib/typescript/src}/native/SessionRecorderNative.d.ts +21 -3
  190. package/lib/typescript/src/native/SessionRecorderNative.d.ts.map +1 -0
  191. package/lib/typescript/src/native/index.d.ts +2 -0
  192. package/lib/typescript/src/native/index.d.ts.map +1 -0
  193. package/{dist → lib/typescript/src}/otel/helpers.d.ts +3 -2
  194. package/lib/typescript/src/otel/helpers.d.ts.map +1 -0
  195. package/{dist → lib/typescript/src}/otel/index.d.ts +2 -2
  196. package/lib/typescript/src/otel/index.d.ts.map +1 -0
  197. package/{dist → lib/typescript/src}/otel/instrumentations/index.d.ts +2 -1
  198. package/lib/typescript/src/otel/instrumentations/index.d.ts.map +1 -0
  199. package/lib/typescript/src/patch/index.d.ts +2 -0
  200. package/lib/typescript/src/patch/index.d.ts.map +1 -0
  201. package/{dist → lib/typescript/src}/patch/xhr.d.ts +1 -0
  202. package/lib/typescript/src/patch/xhr.d.ts.map +1 -0
  203. package/{dist → lib/typescript/src}/recorder/eventExporter.d.ts +2 -1
  204. package/lib/typescript/src/recorder/eventExporter.d.ts.map +1 -0
  205. package/{dist → lib/typescript/src}/recorder/gestureRecorder.d.ts +3 -2
  206. package/lib/typescript/src/recorder/gestureRecorder.d.ts.map +1 -0
  207. package/{dist → lib/typescript/src}/recorder/index.d.ts +3 -2
  208. package/lib/typescript/src/recorder/index.d.ts.map +1 -0
  209. package/{dist → lib/typescript/src}/recorder/navigationTracker.d.ts +2 -1
  210. package/lib/typescript/src/recorder/navigationTracker.d.ts.map +1 -0
  211. package/{dist → lib/typescript/src}/recorder/screenRecorder.d.ts +4 -4
  212. package/lib/typescript/src/recorder/screenRecorder.d.ts.map +1 -0
  213. package/{dist → lib/typescript/src}/services/api.service.d.ts +2 -1
  214. package/lib/typescript/src/services/api.service.d.ts.map +1 -0
  215. package/{dist → lib/typescript/src}/services/network.service.d.ts +1 -0
  216. package/lib/typescript/src/services/network.service.d.ts.map +1 -0
  217. package/{dist → lib/typescript/src}/services/screenMaskingService.d.ts +2 -1
  218. package/lib/typescript/src/services/screenMaskingService.d.ts.map +1 -0
  219. package/{dist → lib/typescript/src}/services/storage.service.d.ts +2 -1
  220. package/lib/typescript/src/services/storage.service.d.ts.map +1 -0
  221. package/{dist → lib/typescript/src}/session-recorder.d.ts +3 -2
  222. package/lib/typescript/src/session-recorder.d.ts.map +1 -0
  223. package/{dist → lib/typescript/src}/types/configs.d.ts +3 -2
  224. package/lib/typescript/src/types/configs.d.ts.map +1 -0
  225. package/{dist → lib/typescript/src}/types/index.d.ts +1 -0
  226. package/lib/typescript/src/types/index.d.ts.map +1 -0
  227. package/{dist → lib/typescript/src}/types/session-recorder.d.ts +7 -6
  228. package/lib/typescript/src/types/session-recorder.d.ts.map +1 -0
  229. package/{dist → lib/typescript/src}/types/session.d.ts +1 -0
  230. package/lib/typescript/src/types/session.d.ts.map +1 -0
  231. package/{dist → lib/typescript/src}/utils/app-metadata.d.ts +1 -0
  232. package/lib/typescript/src/utils/app-metadata.d.ts.map +1 -0
  233. package/{dist → lib/typescript/src}/utils/constants.optional.d.ts +1 -0
  234. package/lib/typescript/src/utils/constants.optional.d.ts.map +1 -0
  235. package/{dist → lib/typescript/src}/utils/constants.optional.expo.d.ts +1 -0
  236. package/lib/typescript/src/utils/constants.optional.expo.d.ts.map +1 -0
  237. package/{dist → lib/typescript/src}/utils/createStore.d.ts +1 -0
  238. package/lib/typescript/src/utils/createStore.d.ts.map +1 -0
  239. package/lib/typescript/src/utils/index.d.ts +8 -0
  240. package/lib/typescript/src/utils/index.d.ts.map +1 -0
  241. package/{dist → lib/typescript/src}/utils/logger.d.ts +2 -1
  242. package/lib/typescript/src/utils/logger.d.ts.map +1 -0
  243. package/{dist → lib/typescript/src}/utils/platform.d.ts +2 -1
  244. package/lib/typescript/src/utils/platform.d.ts.map +1 -0
  245. package/{dist → lib/typescript/src}/utils/request-utils.d.ts +1 -0
  246. package/lib/typescript/src/utils/request-utils.d.ts.map +1 -0
  247. package/{dist → lib/typescript/src}/utils/rrweb-events.d.ts +2 -1
  248. package/lib/typescript/src/utils/rrweb-events.d.ts.map +1 -0
  249. package/{dist → lib/typescript/src}/utils/session.d.ts +1 -0
  250. package/lib/typescript/src/utils/session.d.ts.map +1 -0
  251. package/{dist → lib/typescript/src}/utils/shallowEqual.d.ts +1 -0
  252. package/lib/typescript/src/utils/shallowEqual.d.ts.map +1 -0
  253. package/{dist → lib/typescript/src}/utils/time.d.ts +1 -0
  254. package/lib/typescript/src/utils/time.d.ts.map +1 -0
  255. package/{dist → lib/typescript/src}/utils/type-utils.d.ts +1 -0
  256. package/lib/typescript/src/utils/type-utils.d.ts.map +1 -0
  257. package/{dist → lib/typescript/src}/version.d.ts +1 -0
  258. package/lib/typescript/src/version.d.ts.map +1 -0
  259. package/package.json +133 -44
  260. package/src/components/ScreenRecorderView/ScreenRecorderView.tsx +20 -0
  261. package/src/components/ScreenRecorderView/index.ts +1 -0
  262. package/src/components/SessionRecorderWidget/ErrorBanner.tsx +58 -0
  263. package/src/components/SessionRecorderWidget/FinalPopover.tsx +96 -0
  264. package/src/components/SessionRecorderWidget/FloatingButton.tsx +176 -0
  265. package/src/components/SessionRecorderWidget/InitialPopover.tsx +167 -0
  266. package/src/components/SessionRecorderWidget/ModalContainer.tsx +189 -0
  267. package/src/components/SessionRecorderWidget/ModalHeader.tsx +26 -0
  268. package/src/components/SessionRecorderWidget/SessionRecorderWidget.tsx +150 -0
  269. package/src/components/SessionRecorderWidget/icons.tsx +80 -0
  270. package/src/components/SessionRecorderWidget/index.ts +3 -0
  271. package/src/components/SessionRecorderWidget/styles.ts +168 -0
  272. package/src/config/constants.ts +67 -0
  273. package/src/config/defaults.ts +105 -0
  274. package/src/config/index.ts +6 -0
  275. package/src/config/masking.ts +60 -0
  276. package/src/config/session-recorder.ts +87 -0
  277. package/src/config/validators.ts +54 -0
  278. package/src/config/widget.ts +47 -0
  279. package/src/context/SessionRecorderContext.tsx +138 -0
  280. package/src/context/SessionRecorderStore.ts +22 -0
  281. package/src/context/useSessionRecorderStore.ts +34 -0
  282. package/src/context/useStoreSelector.ts +36 -0
  283. package/src/index.ts +10 -0
  284. package/src/native/SessionRecorderNative.ts +180 -0
  285. package/src/native/index.ts +5 -0
  286. package/src/otel/helpers.ts +290 -0
  287. package/src/otel/index.ts +132 -0
  288. package/src/otel/instrumentations/index.ts +118 -0
  289. package/src/patch/xhr.ts +148 -0
  290. package/src/recorder/eventExporter.ts +150 -0
  291. package/src/recorder/gestureRecorder.ts +828 -0
  292. package/src/recorder/index.ts +203 -0
  293. package/src/recorder/navigationTracker.ts +268 -0
  294. package/src/recorder/screenRecorder.ts +600 -0
  295. package/src/services/api.service.ts +216 -0
  296. package/src/services/network.service.ts +191 -0
  297. package/src/services/screenMaskingService.ts +153 -0
  298. package/src/services/storage.service.ts +248 -0
  299. package/src/session-recorder.ts +647 -0
  300. package/src/types/configs.ts +118 -0
  301. package/src/types/expo-constants.d.ts +7 -0
  302. package/src/types/index.ts +27 -0
  303. package/src/types/session-recorder.ts +381 -0
  304. package/src/types/session.ts +65 -0
  305. package/src/utils/app-metadata.ts +31 -0
  306. package/src/utils/constants.optional.expo.ts +5 -0
  307. package/src/utils/constants.optional.ts +18 -0
  308. package/src/utils/createStore.ts +32 -0
  309. package/{dist/utils/index.d.ts → src/utils/index.ts} +1 -0
  310. package/src/utils/logger.ts +245 -0
  311. package/src/utils/platform.ts +401 -0
  312. package/src/utils/request-utils.ts +61 -0
  313. package/src/utils/rrweb-events.ts +329 -0
  314. package/src/utils/session.ts +22 -0
  315. package/src/utils/shallowEqual.ts +20 -0
  316. package/src/utils/time.ts +20 -0
  317. package/src/utils/type-utils.ts +75 -0
  318. package/src/version.ts +1 -0
  319. package/REACT_NATIVE_SETUP.md +0 -91
  320. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  321. package/android/gradle/wrapper/gradle-wrapper.properties +0 -7
  322. package/android/gradlew +0 -249
  323. package/android/gradlew.bat +0 -92
  324. package/copy-react-native-dist.sh +0 -56
  325. package/dist/components/ScreenRecorderView/ScreenRecorderView.d.ts +0 -5
  326. package/dist/components/ScreenRecorderView/ScreenRecorderView.js +0 -1
  327. package/dist/components/ScreenRecorderView/ScreenRecorderView.js.map +0 -1
  328. package/dist/components/ScreenRecorderView/index.d.ts +0 -1
  329. package/dist/components/ScreenRecorderView/index.js +0 -1
  330. package/dist/components/ScreenRecorderView/index.js.map +0 -1
  331. package/dist/components/SessionRecorderWidget/ErrorBanner.js +0 -1
  332. package/dist/components/SessionRecorderWidget/ErrorBanner.js.map +0 -1
  333. package/dist/components/SessionRecorderWidget/FinalPopover.js +0 -1
  334. package/dist/components/SessionRecorderWidget/FinalPopover.js.map +0 -1
  335. package/dist/components/SessionRecorderWidget/FloatingButton.js +0 -1
  336. package/dist/components/SessionRecorderWidget/FloatingButton.js.map +0 -1
  337. package/dist/components/SessionRecorderWidget/InitialPopover.js +0 -1
  338. package/dist/components/SessionRecorderWidget/InitialPopover.js.map +0 -1
  339. package/dist/components/SessionRecorderWidget/ModalContainer.js +0 -1
  340. package/dist/components/SessionRecorderWidget/ModalContainer.js.map +0 -1
  341. package/dist/components/SessionRecorderWidget/ModalHeader.js +0 -1
  342. package/dist/components/SessionRecorderWidget/ModalHeader.js.map +0 -1
  343. package/dist/components/SessionRecorderWidget/SessionRecorderWidget.js +0 -1
  344. package/dist/components/SessionRecorderWidget/SessionRecorderWidget.js.map +0 -1
  345. package/dist/components/SessionRecorderWidget/icons.js +0 -1
  346. package/dist/components/SessionRecorderWidget/icons.js.map +0 -1
  347. package/dist/components/SessionRecorderWidget/index.d.ts +0 -2
  348. package/dist/components/SessionRecorderWidget/index.js +0 -1
  349. package/dist/components/SessionRecorderWidget/index.js.map +0 -1
  350. package/dist/components/SessionRecorderWidget/styles.js +0 -1
  351. package/dist/components/SessionRecorderWidget/styles.js.map +0 -1
  352. package/dist/components/index.js +0 -1
  353. package/dist/components/index.js.map +0 -1
  354. package/dist/config/constants.js +0 -1
  355. package/dist/config/constants.js.map +0 -1
  356. package/dist/config/defaults.js +0 -1
  357. package/dist/config/defaults.js.map +0 -1
  358. package/dist/config/index.js +0 -1
  359. package/dist/config/index.js.map +0 -1
  360. package/dist/config/masking.d.ts +0 -2
  361. package/dist/config/masking.js +0 -1
  362. package/dist/config/masking.js.map +0 -1
  363. package/dist/config/session-recorder.d.ts +0 -2
  364. package/dist/config/session-recorder.js +0 -1
  365. package/dist/config/session-recorder.js.map +0 -1
  366. package/dist/config/validators.js +0 -1
  367. package/dist/config/validators.js.map +0 -1
  368. package/dist/config/widget.js +0 -1
  369. package/dist/config/widget.js.map +0 -1
  370. package/dist/context/SessionRecorderContext.js +0 -1
  371. package/dist/context/SessionRecorderContext.js.map +0 -1
  372. package/dist/context/SessionRecorderStore.js +0 -1
  373. package/dist/context/SessionRecorderStore.js.map +0 -1
  374. package/dist/context/useSessionRecorderStore.js +0 -1
  375. package/dist/context/useSessionRecorderStore.js.map +0 -1
  376. package/dist/context/useStoreSelector.js +0 -1
  377. package/dist/context/useStoreSelector.js.map +0 -1
  378. package/dist/index.js +0 -1
  379. package/dist/index.js.map +0 -1
  380. package/dist/native/GestureRecorderNative.d.ts +0 -57
  381. package/dist/native/GestureRecorderNative.js +0 -1
  382. package/dist/native/GestureRecorderNative.js.map +0 -1
  383. package/dist/native/GestureRecorderNativeTurboSpec.d.ts +0 -31
  384. package/dist/native/GestureRecorderNativeTurboSpec.js +0 -1
  385. package/dist/native/GestureRecorderNativeTurboSpec.js.map +0 -1
  386. package/dist/native/SessionRecorderNative.js +0 -1
  387. package/dist/native/SessionRecorderNative.js.map +0 -1
  388. package/dist/native/SessionRecorderNativeTurboSpec.d.ts +0 -17
  389. package/dist/native/SessionRecorderNativeTurboSpec.js +0 -1
  390. package/dist/native/SessionRecorderNativeTurboSpec.js.map +0 -1
  391. package/dist/native/index.d.ts +0 -1
  392. package/dist/native/index.js +0 -1
  393. package/dist/native/index.js.map +0 -1
  394. package/dist/otel/helpers.js +0 -1
  395. package/dist/otel/helpers.js.map +0 -1
  396. package/dist/otel/index.js +0 -1
  397. package/dist/otel/index.js.map +0 -1
  398. package/dist/otel/instrumentations/index.js +0 -1
  399. package/dist/otel/instrumentations/index.js.map +0 -1
  400. package/dist/patch/index.js +0 -1
  401. package/dist/patch/index.js.map +0 -1
  402. package/dist/patch/xhr.js +0 -1
  403. package/dist/patch/xhr.js.map +0 -1
  404. package/dist/recorder/eventExporter.js +0 -1
  405. package/dist/recorder/eventExporter.js.map +0 -1
  406. package/dist/recorder/gestureRecorder.js +0 -1
  407. package/dist/recorder/gestureRecorder.js.map +0 -1
  408. package/dist/recorder/index.js +0 -1
  409. package/dist/recorder/index.js.map +0 -1
  410. package/dist/recorder/navigationTracker.js +0 -1
  411. package/dist/recorder/navigationTracker.js.map +0 -1
  412. package/dist/recorder/screenRecorder.js +0 -1
  413. package/dist/recorder/screenRecorder.js.map +0 -1
  414. package/dist/services/api.service.js +0 -1
  415. package/dist/services/api.service.js.map +0 -1
  416. package/dist/services/network.service.js +0 -1
  417. package/dist/services/network.service.js.map +0 -1
  418. package/dist/services/screenMaskingService.js +0 -1
  419. package/dist/services/screenMaskingService.js.map +0 -1
  420. package/dist/services/storage.service.js +0 -1
  421. package/dist/services/storage.service.js.map +0 -1
  422. package/dist/session-recorder.js +0 -1
  423. package/dist/session-recorder.js.map +0 -1
  424. package/dist/types/configs.js +0 -1
  425. package/dist/types/configs.js.map +0 -1
  426. package/dist/types/index.js +0 -1
  427. package/dist/types/index.js.map +0 -1
  428. package/dist/types/session-recorder.js +0 -1
  429. package/dist/types/session-recorder.js.map +0 -1
  430. package/dist/types/session.js +0 -1
  431. package/dist/types/session.js.map +0 -1
  432. package/dist/utils/app-metadata.js +0 -1
  433. package/dist/utils/app-metadata.js.map +0 -1
  434. package/dist/utils/constants.optional.expo.js +0 -1
  435. package/dist/utils/constants.optional.expo.js.map +0 -1
  436. package/dist/utils/constants.optional.js +0 -1
  437. package/dist/utils/constants.optional.js.map +0 -1
  438. package/dist/utils/createStore.js +0 -1
  439. package/dist/utils/createStore.js.map +0 -1
  440. package/dist/utils/index.js +0 -1
  441. package/dist/utils/index.js.map +0 -1
  442. package/dist/utils/logger.js +0 -1
  443. package/dist/utils/logger.js.map +0 -1
  444. package/dist/utils/platform.js +0 -1
  445. package/dist/utils/platform.js.map +0 -1
  446. package/dist/utils/request-utils.js +0 -1
  447. package/dist/utils/request-utils.js.map +0 -1
  448. package/dist/utils/rrweb-events.js +0 -1
  449. package/dist/utils/rrweb-events.js.map +0 -1
  450. package/dist/utils/session.js +0 -1
  451. package/dist/utils/session.js.map +0 -1
  452. package/dist/utils/shallowEqual.js +0 -1
  453. package/dist/utils/shallowEqual.js.map +0 -1
  454. package/dist/utils/time.js +0 -1
  455. package/dist/utils/time.js.map +0 -1
  456. package/dist/utils/type-utils.js +0 -1
  457. package/dist/utils/type-utils.js.map +0 -1
  458. package/dist/version.js +0 -1
  459. package/dist/version.js.map +0 -1
  460. package/docs/AUTO_METADATA_DETECTION.md +0 -108
  461. package/react-native.config.js +0 -13
  462. /package/{dist/components/index.d.ts → src/components/index.ts} +0 -0
  463. /package/{dist/patch/index.d.ts → src/patch/index.ts} +0 -0
@@ -0,0 +1,647 @@
1
+ import { SessionType } from '@multiplayer-app/session-recorder-common';
2
+ import { Observable } from 'lib0/observable';
3
+ import { type eventWithTime } from '@rrweb/types';
4
+
5
+ import { TracerReactNativeSDK } from './otel';
6
+ import { RecorderReactNativeSDK } from './recorder';
7
+ import { logger } from './utils';
8
+
9
+ import {
10
+ SessionState,
11
+ type ISession,
12
+ type ISessionRecorder,
13
+ type SessionRecorderConfigs,
14
+ type SessionRecorderOptions,
15
+ type EventRecorder,
16
+ } from './types';
17
+ import { getFormattedDate, isSessionActive, getNavigatorInfo } from './utils';
18
+ import {
19
+ setMaxCapturingHttpPayloadSize,
20
+ setShouldRecordHttpData,
21
+ } from './patch/xhr';
22
+ import { BASE_CONFIG, getSessionRecorderConfig } from './config';
23
+
24
+ import { StorageService } from './services/storage.service';
25
+ import { NetworkService } from './services/network.service';
26
+ import {
27
+ ApiService,
28
+ type StartSessionRequest,
29
+ type StopSessionRequest,
30
+ } from './services/api.service';
31
+
32
+ type SessionRecorderEvents = 'state-change';
33
+
34
+ class SessionRecorder
35
+ extends Observable<SessionRecorderEvents>
36
+ implements ISessionRecorder, EventRecorder
37
+ {
38
+ private _configs: SessionRecorderConfigs;
39
+ private _apiService = new ApiService();
40
+ private _tracer = new TracerReactNativeSDK();
41
+ private _recorder = new RecorderReactNativeSDK();
42
+ private _storageService = StorageService.getInstance();
43
+ private _networkService = NetworkService.getInstance();
44
+ private _startRequestController: AbortController | null = null;
45
+
46
+ // Whether the session recorder is initialized
47
+ private _isInitialized = false;
48
+ get isInitialized(): boolean {
49
+ return this._isInitialized;
50
+ }
51
+ set isInitialized(isInitialized: boolean) {
52
+ this._isInitialized = isInitialized;
53
+ }
54
+
55
+ // Session ID and state are stored in AsyncStorage
56
+ private _sessionId: string | null = null;
57
+ get sessionId(): string | null {
58
+ return this._sessionId;
59
+ }
60
+ set sessionId(sessionId: string | null) {
61
+ this._sessionId = sessionId;
62
+ if (sessionId) {
63
+ this._storageService.saveSessionId(sessionId);
64
+ }
65
+ }
66
+
67
+ private _sessionType: SessionType = SessionType.PLAIN;
68
+ get sessionType(): SessionType {
69
+ return this._sessionType;
70
+ }
71
+ set sessionType(sessionType: SessionType) {
72
+ this._sessionType = sessionType;
73
+ this._storageService.saveSessionType(sessionType);
74
+ }
75
+
76
+ get continuousRecording(): boolean {
77
+ return this.sessionType === SessionType.CONTINUOUS;
78
+ }
79
+
80
+ private _sessionState: SessionState | null = null;
81
+ get sessionState(): SessionState | null {
82
+ return this._sessionState || SessionState.stopped;
83
+ }
84
+ set sessionState(state: SessionState | null) {
85
+ this._sessionState = state;
86
+ this.emit('state-change', [
87
+ state || SessionState.stopped,
88
+ this.sessionType,
89
+ ]);
90
+ if (state) {
91
+ this._storageService.saveSessionState(state);
92
+ }
93
+ }
94
+
95
+ private _session: ISession | null = null;
96
+ get session(): ISession | null {
97
+ return this._session;
98
+ }
99
+ set session(session: ISession | null) {
100
+ this._session = session;
101
+ if (session) {
102
+ this._storageService.saveSessionObject(session);
103
+ }
104
+ }
105
+
106
+ private _sessionAttributes: Record<string, any> | null = null;
107
+ get sessionAttributes(): Record<string, any> {
108
+ return this._sessionAttributes || {};
109
+ }
110
+ set sessionAttributes(attributes: Record<string, any> | null) {
111
+ this._sessionAttributes = attributes;
112
+ }
113
+
114
+ /**
115
+ * Error message getter and setter
116
+ */
117
+ public get error(): string {
118
+ return this._error || '';
119
+ }
120
+
121
+ public set error(v: string) {
122
+ this._error = v;
123
+ }
124
+ private _error: string = '';
125
+
126
+ /**
127
+ * React Native doesn't have HTML elements, so we return null
128
+ */
129
+ public get sessionWidgetButtonElement(): any {
130
+ return null;
131
+ }
132
+
133
+ public get config(): SessionRecorderConfigs {
134
+ return this._configs;
135
+ }
136
+ /**
137
+ * Initialize debugger with default or custom configurations
138
+ */
139
+ constructor() {
140
+ super();
141
+ this._configs = BASE_CONFIG;
142
+ // Initialize with stored session data if available
143
+ StorageService.initialize();
144
+ }
145
+
146
+ private async _loadStoredSessionData(): Promise<void> {
147
+ try {
148
+ await StorageService.initialize();
149
+ const storedData = await this._storageService.getAllSessionData();
150
+ if (isSessionActive(storedData.sessionObject, storedData.sessionType)) {
151
+ this.session = storedData.sessionObject;
152
+ this.sessionId = storedData.sessionId;
153
+ this.sessionType = storedData.sessionType || SessionType.PLAIN;
154
+ this.sessionState = storedData.sessionState;
155
+ } else {
156
+ this.session = null;
157
+ this.sessionId = null;
158
+ this.sessionState = null;
159
+ this.sessionType = SessionType.PLAIN;
160
+ }
161
+ } catch (error) {
162
+ logger.error(
163
+ 'SessionRecorder',
164
+ 'Failed to load stored session data',
165
+ error
166
+ );
167
+ this.session = null;
168
+ this.sessionId = null;
169
+ this.sessionState = null;
170
+ this.sessionType = SessionType.PLAIN;
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Initialize the session debugger
176
+ * @param configs - custom configurations for session debugger
177
+ */
178
+ public async init(configs: SessionRecorderOptions): Promise<void> {
179
+ if (this._isInitialized) return;
180
+ this._isInitialized = true;
181
+ this._configs = getSessionRecorderConfig({ ...this._configs, ...configs });
182
+ logger.configure(this._configs.logger);
183
+ await this._loadStoredSessionData();
184
+ setMaxCapturingHttpPayloadSize(this._configs.maxCapturingHttpPayloadSize);
185
+ setShouldRecordHttpData(
186
+ !this._configs.captureBody,
187
+ this._configs.captureHeaders
188
+ );
189
+
190
+ this._tracer.init(this._configs);
191
+ this._recorder.init(this._configs);
192
+ this._apiService.init(this._configs);
193
+ await this._networkService.init();
194
+ this._setupNetworkCallbacks();
195
+
196
+ if (
197
+ this.sessionId &&
198
+ (this.sessionState === SessionState.started ||
199
+ this.sessionState === SessionState.paused)
200
+ ) {
201
+ this._start();
202
+ }
203
+ }
204
+
205
+ /**
206
+ * Setup network state change callbacks
207
+ */
208
+ private _setupNetworkCallbacks(): void {
209
+ this._networkService.addCallback((state) => {
210
+ if (!state.isConnected && this.sessionState === SessionState.started) {
211
+ logger.info(
212
+ 'SessionRecorder',
213
+ 'Network went offline - pausing session recording'
214
+ );
215
+ this.pause();
216
+ } else if (
217
+ state.isConnected &&
218
+ this.sessionState === SessionState.paused
219
+ ) {
220
+ logger.info(
221
+ 'SessionRecorder',
222
+ 'Network came back online - resuming session recording'
223
+ );
224
+ this.resume();
225
+ }
226
+ });
227
+ }
228
+
229
+ /**
230
+ * Start a new session
231
+ * @param type - the type of session to start
232
+ * @param session - the session to start
233
+ */
234
+ public async start(
235
+ type: SessionType = SessionType.PLAIN,
236
+ session?: ISession
237
+ ): Promise<void> {
238
+ this._checkOperation('start');
239
+
240
+ // Check if offline - don't start recording if offline
241
+ if (!this._networkService.isOnline()) {
242
+ logger.warn(
243
+ 'SessionRecorder',
244
+ 'Cannot start session recording - device is offline'
245
+ );
246
+ throw new Error('Cannot start session recording while offline');
247
+ }
248
+
249
+ // If continuous recording is disabled, force plain mode
250
+ if (
251
+ type === SessionType.CONTINUOUS &&
252
+ !this._configs?.showContinuousRecording
253
+ ) {
254
+ type = SessionType.PLAIN;
255
+ }
256
+ logger.info('SessionRecorder', 'Starting session with type:', type);
257
+ this.sessionType = type;
258
+ this._startRequestController = new AbortController();
259
+ if (session) {
260
+ this._setupSessionAndStart(session, true);
261
+ } else {
262
+ await this._createSessionAndStart();
263
+ }
264
+ }
265
+
266
+ /**
267
+ * Stop the current session with an optional comment
268
+ * @param comment - user-provided comment to include in session session attributes
269
+ */
270
+ public async stop(comment?: string): Promise<void> {
271
+ try {
272
+ this._checkOperation('stop');
273
+ this._stop();
274
+ if (this.continuousRecording) {
275
+ await this._apiService.stopContinuousDebugSession(this.sessionId!);
276
+ this.sessionType = SessionType.PLAIN;
277
+ } else {
278
+ const request: StopSessionRequest = {
279
+ sessionAttributes: { comment },
280
+ stoppedAt: Date.now(),
281
+ };
282
+ await this._apiService.stopSession(this.sessionId!, request);
283
+ }
284
+ this._clearSession();
285
+ } catch (error: any) {
286
+ this.error = error.message;
287
+ }
288
+ }
289
+
290
+ /**
291
+ * Pause the current session
292
+ */
293
+ public async pause(): Promise<void> {
294
+ try {
295
+ this._checkOperation('pause');
296
+ this._pause();
297
+ } catch (error: any) {
298
+ this.error = error.message;
299
+ }
300
+ }
301
+
302
+ /**
303
+ * Resume the current session
304
+ */
305
+ public async resume(): Promise<void> {
306
+ try {
307
+ this._checkOperation('resume');
308
+ this._resume();
309
+ } catch (error: any) {
310
+ this.error = error.message;
311
+ }
312
+ }
313
+
314
+ /**
315
+ * Cancel the current session
316
+ */
317
+ public async cancel(): Promise<void> {
318
+ try {
319
+ this._checkOperation('cancel');
320
+ this._stop();
321
+ if (this.continuousRecording) {
322
+ await this._apiService.stopContinuousDebugSession(this.sessionId!);
323
+ this.sessionType = SessionType.PLAIN;
324
+ } else {
325
+ await this._apiService.cancelSession(this.sessionId!);
326
+ }
327
+ this._clearSession();
328
+ } catch (error: any) {
329
+ this.error = error.message;
330
+ }
331
+ }
332
+
333
+ /**
334
+ * Save the continuous recording session
335
+ */
336
+ public async save(): Promise<any> {
337
+ try {
338
+ this._checkOperation('save');
339
+ if (
340
+ !this.continuousRecording ||
341
+ !this._configs?.showContinuousRecording
342
+ ) {
343
+ return;
344
+ }
345
+
346
+ const res = await this._apiService.saveContinuousDebugSession(
347
+ this.sessionId!,
348
+ {
349
+ sessionAttributes: this.sessionAttributes,
350
+ resourceAttributes: getNavigatorInfo(),
351
+ stoppedAt: Date.now(),
352
+ name: this.sessionAttributes.userName
353
+ ? `${this.sessionAttributes.userName}'s session on ${getFormattedDate(
354
+ Date.now(),
355
+ { month: 'short', day: 'numeric' }
356
+ )}`
357
+ : `Session on ${getFormattedDate(Date.now())}`,
358
+ }
359
+ );
360
+
361
+ return res;
362
+ } catch (error: any) {
363
+ this.error = error.message;
364
+ }
365
+ }
366
+
367
+ /**
368
+ * Set the session attributes
369
+ * @param attributes - the attributes to set
370
+ */
371
+ public setSessionAttributes(attributes: Record<string, any>): void {
372
+ this._sessionAttributes = attributes;
373
+ }
374
+
375
+ /**
376
+ * @description Check if session should be started/stopped automatically
377
+ * @param {ISession} [sessionPayload]
378
+ * @returns {Promise<void>}
379
+ */
380
+ public async checkRemoteContinuousSession(
381
+ sessionPayload?: Omit<ISession, '_id' | 'shortId'>
382
+ ): Promise<void> {
383
+ this._checkOperation('autoStartRemoteContinuousSession');
384
+ if (!this._configs?.showContinuousRecording) {
385
+ return;
386
+ }
387
+ const payload = {
388
+ sessionAttributes: {
389
+ ...this.sessionAttributes,
390
+ ...(sessionPayload?.sessionAttributes || {}),
391
+ },
392
+ resourceAttributes: {
393
+ ...getNavigatorInfo(),
394
+ ...(sessionPayload?.resourceAttributes || {}),
395
+ },
396
+ };
397
+
398
+ const { state } = await this._apiService.checkRemoteSession(payload);
399
+
400
+ if (state == 'START') {
401
+ if (this.sessionState !== SessionState.started) {
402
+ await this.start(SessionType.CONTINUOUS);
403
+ }
404
+ } else if (state == 'STOP') {
405
+ if (this.sessionState !== SessionState.stopped) {
406
+ await this.stop();
407
+ }
408
+ }
409
+ }
410
+
411
+ /**
412
+ * Create a new session and start it
413
+ */
414
+ private async _createSessionAndStart(): Promise<void> {
415
+ const signal = this._startRequestController?.signal;
416
+ try {
417
+ const payload = {
418
+ sessionAttributes: this.sessionAttributes,
419
+ resourceAttributes: getNavigatorInfo(),
420
+ name: this.sessionAttributes.userName
421
+ ? `${this.sessionAttributes.userName}'s session on ${getFormattedDate(Date.now(), { month: 'short', day: 'numeric' })}`
422
+ : `Session on ${getFormattedDate(Date.now())}`,
423
+ };
424
+ const request: StartSessionRequest = !this.continuousRecording
425
+ ? payload
426
+ : { debugSessionData: payload };
427
+
428
+ const session = this.continuousRecording
429
+ ? await this._apiService.startContinuousDebugSession(request, signal)
430
+ : await this._apiService.startSession(request, signal);
431
+
432
+ if (session) {
433
+ session.sessionType = this.continuousRecording
434
+ ? SessionType.CONTINUOUS
435
+ : SessionType.PLAIN;
436
+ this._setupSessionAndStart(session, false);
437
+ }
438
+ } catch (error: any) {
439
+ this.error = error.message;
440
+ logger.error('SessionRecorder', 'Error creating session:', error.message);
441
+ if (this.continuousRecording) {
442
+ this.sessionType = SessionType.PLAIN;
443
+ }
444
+ }
445
+ }
446
+
447
+ /**
448
+ * Start tracing and recording for the session
449
+ */
450
+ private _start(): void {
451
+ this.sessionState = SessionState.started;
452
+ this.sessionType = this.sessionType;
453
+
454
+ if (this.sessionId) {
455
+ this._tracer.start(this.sessionId, this.sessionType);
456
+ this._recorder.start(this.sessionId, this.sessionType);
457
+ }
458
+ }
459
+
460
+ /**
461
+ * Stop tracing and recording for the session
462
+ */
463
+ private _stop(): void {
464
+ this.sessionState = SessionState.stopped;
465
+ this._tracer.shutdown();
466
+ this._recorder.stop();
467
+ }
468
+
469
+ /**
470
+ * Pause the session tracing and recording
471
+ */
472
+ private _pause(): void {
473
+ this._tracer.shutdown();
474
+ this._recorder.stop();
475
+ this.sessionState = SessionState.paused;
476
+ }
477
+
478
+ /**
479
+ * Resume the session tracing and recording
480
+ */
481
+ private _resume(): void {
482
+ if (this.sessionId) {
483
+ this._tracer.setSessionId(this.sessionId, this.sessionType);
484
+ this._recorder.start(this.sessionId, this.sessionType);
485
+ }
486
+ this.sessionState = SessionState.started;
487
+ }
488
+
489
+ private _setupSessionAndStart(
490
+ session: ISession,
491
+ configureExporters: boolean = true
492
+ ): void {
493
+ if (configureExporters && session.tempApiKey) {
494
+ this._configs.apiKey = session.tempApiKey;
495
+ this._tracer.setApiKey(session.tempApiKey);
496
+ this._recorder.setApiKey(session.tempApiKey);
497
+ this._apiService.setApiKey(session.tempApiKey);
498
+ }
499
+
500
+ this._setSession(session);
501
+ this._start();
502
+ }
503
+
504
+ /**
505
+ * Set the session ID in storage
506
+ * @param sessionId - the session ID to set or clear
507
+ */
508
+ private _setSession(session: ISession): void {
509
+ this.session = {
510
+ ...session,
511
+ createdAt: session.createdAt || new Date().toISOString(),
512
+ };
513
+ this.sessionId = session?.shortId || session?._id;
514
+ }
515
+
516
+ private _clearSession(): void {
517
+ this.session = null;
518
+ this.sessionId = null;
519
+ this.sessionState = SessionState.stopped;
520
+ this._storageService.clearSessionData();
521
+ }
522
+
523
+ /**
524
+ * Check the operation validity based on the session state and action
525
+ * @param action - action being checked ('init', 'start', 'stop', 'cancel', 'pause', 'resume')
526
+ */
527
+ private _checkOperation(
528
+ action:
529
+ | 'init'
530
+ | 'start'
531
+ | 'stop'
532
+ | 'cancel'
533
+ | 'pause'
534
+ | 'resume'
535
+ | 'save'
536
+ | 'autoStartRemoteContinuousSession',
537
+ _payload?: any
538
+ ): void {
539
+ if (!this._isInitialized) {
540
+ throw new Error(
541
+ 'Configuration not initialized. Call init() before performing any actions.'
542
+ );
543
+ }
544
+ switch (action) {
545
+ case 'start':
546
+ if (this.sessionState === SessionState.started) {
547
+ throw new Error('Session is already started.');
548
+ }
549
+ break;
550
+ case 'stop':
551
+ if (
552
+ this.sessionState !== SessionState.paused &&
553
+ this.sessionState !== SessionState.started
554
+ ) {
555
+ throw new Error('Cannot stop. Session is not currently started.');
556
+ }
557
+ break;
558
+ case 'cancel':
559
+ if (this.sessionState === SessionState.stopped) {
560
+ throw new Error('Cannot cancel. Session has already been stopped.');
561
+ }
562
+ break;
563
+ case 'pause':
564
+ if (this.sessionState !== SessionState.started) {
565
+ throw new Error('Cannot pause. Session is not running.');
566
+ }
567
+ break;
568
+ case 'resume':
569
+ if (this.sessionState !== SessionState.paused) {
570
+ throw new Error('Cannot resume. Session is not paused.');
571
+ }
572
+ break;
573
+ case 'save':
574
+ if (!this.continuousRecording) {
575
+ throw new Error(
576
+ 'Cannot save continuous recording session. Continuous recording is not enabled.'
577
+ );
578
+ }
579
+ if (this.sessionState !== SessionState.started) {
580
+ throw new Error(
581
+ 'Cannot save continuous recording session. Session is not started.'
582
+ );
583
+ }
584
+ break;
585
+ case 'autoStartRemoteContinuousSession':
586
+ if (this.sessionState !== SessionState.stopped) {
587
+ throw new Error(
588
+ 'Cannot start remote continuous session. Session is not stopped.'
589
+ );
590
+ }
591
+ break;
592
+ }
593
+ }
594
+ // Session attributes
595
+ setSessionAttribute(key: string, value: any): void {
596
+ if (this._session) {
597
+ if (!this._session.sessionAttributes) {
598
+ this._session.sessionAttributes = {};
599
+ }
600
+ this._session.sessionAttributes[key] = value;
601
+ this._session.updatedAt = new Date().toISOString();
602
+ }
603
+ }
604
+
605
+ /**
606
+ * Record a custom rrweb event
607
+ * Note: Screen capture and touch events are recorded automatically when session is started
608
+ * @param event - The rrweb event to record
609
+ */
610
+ recordEvent(event: eventWithTime): void {
611
+ if (!this._isInitialized || this.sessionState !== SessionState.started) {
612
+ return;
613
+ }
614
+
615
+ // Forward the event to the recorder SDK
616
+ this._recorder.recordEvent(event);
617
+ }
618
+
619
+ /**
620
+ * Set the viewshot ref for screen capture
621
+ * @param ref - React Native View ref for screen capture
622
+ */
623
+ setViewShotRef(ref: any): void {
624
+ if (this._recorder) {
625
+ this._recorder.setViewShotRef(ref);
626
+ }
627
+ }
628
+
629
+ /**
630
+ * Set the navigation ref for navigation tracking
631
+ * @param ref - React Native Navigation ref for navigation tracking
632
+ */
633
+ setNavigationRef(ref: any): void {
634
+ if (this._recorder) {
635
+ this._recorder.setNavigationRef(ref);
636
+ }
637
+ }
638
+
639
+ /**
640
+ * Cleanup resources and unsubscribe from network monitoring
641
+ */
642
+ cleanup(): void {
643
+ this._networkService.cleanup();
644
+ }
645
+ }
646
+
647
+ export default new SessionRecorder();