@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.
- package/LICENSE +1 -2
- package/README.md +216 -155
- package/SessionRecorderNative.podspec +9 -14
- package/android/build.gradle +21 -44
- package/android/gradle.properties +4 -4
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/multiplayer/sessionrecordernative/SessionRecorderNativeConfig.kt +52 -0
- package/android/src/main/java/com/multiplayer/sessionrecordernative/SessionRecorderNativeModule.kt +860 -0
- package/android/src/main/java/com/multiplayer/sessionrecordernative/SessionRecorderNativePackage.kt +33 -0
- package/android/src/main/java/com/multiplayer/sessionrecordernative/model/TargetInfo.kt +9 -0
- package/android/src/main/java/com/multiplayer/sessionrecordernative/util/ViewUtils.kt +72 -0
- package/ios/SessionRecorderNative.podspec +4 -2
- package/ios/SessionRecorderNative.swift +1 -1
- package/ios/SessionRecorderNativeSpec.swift +3 -3
- package/lib/module/components/ScreenRecorderView/ScreenRecorderView.js +23 -0
- package/lib/module/components/ScreenRecorderView/ScreenRecorderView.js.map +1 -0
- package/lib/module/components/ScreenRecorderView/index.js +4 -0
- package/lib/module/components/ScreenRecorderView/index.js.map +1 -0
- package/lib/module/components/SessionRecorderWidget/ErrorBanner.js +64 -0
- package/lib/module/components/SessionRecorderWidget/ErrorBanner.js.map +1 -0
- package/lib/module/components/SessionRecorderWidget/FinalPopover.js +74 -0
- package/lib/module/components/SessionRecorderWidget/FinalPopover.js.map +1 -0
- package/lib/module/components/SessionRecorderWidget/FloatingButton.js +191 -0
- package/lib/module/components/SessionRecorderWidget/FloatingButton.js.map +1 -0
- package/lib/module/components/SessionRecorderWidget/InitialPopover.js +138 -0
- package/lib/module/components/SessionRecorderWidget/InitialPopover.js.map +1 -0
- package/lib/module/components/SessionRecorderWidget/ModalContainer.js +177 -0
- package/lib/module/components/SessionRecorderWidget/ModalContainer.js.map +1 -0
- package/lib/module/components/SessionRecorderWidget/ModalHeader.js +27 -0
- package/lib/module/components/SessionRecorderWidget/ModalHeader.js.map +1 -0
- package/lib/module/components/SessionRecorderWidget/SessionRecorderWidget.js +133 -0
- package/lib/module/components/SessionRecorderWidget/SessionRecorderWidget.js.map +1 -0
- package/lib/module/components/SessionRecorderWidget/icons.js +93 -0
- package/lib/module/components/SessionRecorderWidget/icons.js.map +1 -0
- package/lib/module/components/SessionRecorderWidget/index.js +5 -0
- package/lib/module/components/SessionRecorderWidget/index.js.map +1 -0
- package/lib/module/components/SessionRecorderWidget/styles.js +173 -0
- package/lib/module/components/SessionRecorderWidget/styles.js.map +1 -0
- package/lib/module/components/index.js +5 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/config/constants.js +42 -0
- package/lib/module/config/constants.js.map +1 -0
- package/lib/module/config/defaults.js +81 -0
- package/lib/module/config/defaults.js.map +1 -0
- package/lib/module/config/index.js +9 -0
- package/lib/module/config/index.js.map +1 -0
- package/lib/module/config/masking.js +35 -0
- package/lib/module/config/masking.js.map +1 -0
- package/lib/module/config/session-recorder.js +44 -0
- package/lib/module/config/session-recorder.js.map +1 -0
- package/lib/module/config/validators.js +28 -0
- package/lib/module/config/validators.js.map +1 -0
- package/lib/module/config/widget.js +35 -0
- package/lib/module/config/widget.js.map +1 -0
- package/lib/module/context/SessionRecorderContext.js +93 -0
- package/lib/module/context/SessionRecorderContext.js.map +1 -0
- package/lib/module/context/SessionRecorderStore.js +12 -0
- package/lib/module/context/SessionRecorderStore.js.map +1 -0
- package/lib/module/context/useSessionRecorderStore.js +20 -0
- package/lib/module/context/useSessionRecorderStore.js.map +1 -0
- package/lib/module/context/useStoreSelector.js +27 -0
- package/lib/module/context/useStoreSelector.js.map +1 -0
- package/lib/module/index.js +13 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/native/SessionRecorderNative.js +74 -0
- package/lib/module/native/SessionRecorderNative.js.map +1 -0
- package/lib/module/native/index.js +4 -0
- package/lib/module/native/index.js.map +1 -0
- package/lib/module/otel/helpers.js +218 -0
- package/lib/module/otel/helpers.js.map +1 -0
- package/lib/module/otel/index.js +95 -0
- package/lib/module/otel/index.js.map +1 -0
- package/lib/module/otel/instrumentations/index.js +102 -0
- package/lib/module/otel/instrumentations/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/patch/index.js +4 -0
- package/lib/module/patch/index.js.map +1 -0
- package/lib/module/patch/xhr.js +116 -0
- package/lib/module/patch/xhr.js.map +1 -0
- package/lib/module/recorder/eventExporter.js +130 -0
- package/lib/module/recorder/eventExporter.js.map +1 -0
- package/lib/module/recorder/gestureRecorder.js +641 -0
- package/lib/module/recorder/gestureRecorder.js.map +1 -0
- package/lib/module/recorder/index.js +168 -0
- package/lib/module/recorder/index.js.map +1 -0
- package/lib/module/recorder/navigationTracker.js +228 -0
- package/lib/module/recorder/navigationTracker.js.map +1 -0
- package/lib/module/recorder/screenRecorder.js +495 -0
- package/lib/module/recorder/screenRecorder.js.map +1 -0
- package/lib/module/services/api.service.js +149 -0
- package/lib/module/services/api.service.js.map +1 -0
- package/lib/module/services/network.service.js +178 -0
- package/lib/module/services/network.service.js.map +1 -0
- package/lib/module/services/screenMaskingService.js +107 -0
- package/lib/module/services/screenMaskingService.js.map +1 -0
- package/lib/module/services/storage.service.js +179 -0
- package/lib/module/services/storage.service.js.map +1 -0
- package/lib/module/session-recorder.js +541 -0
- package/lib/module/session-recorder.js.map +1 -0
- package/lib/module/types/configs.js +4 -0
- package/lib/module/types/configs.js.map +1 -0
- package/lib/module/types/expo-constants.d.js +2 -0
- package/lib/module/types/expo-constants.d.js.map +1 -0
- package/lib/module/types/index.js +11 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/session-recorder.js +68 -0
- package/lib/module/types/session-recorder.js.map +1 -0
- package/lib/module/types/session.js +9 -0
- package/lib/module/types/session.js.map +1 -0
- package/lib/module/utils/app-metadata.js +28 -0
- package/lib/module/utils/app-metadata.js.map +1 -0
- package/lib/module/utils/constants.optional.expo.js +6 -0
- package/lib/module/utils/constants.optional.expo.js.map +1 -0
- package/lib/module/utils/constants.optional.js +8 -0
- package/lib/module/utils/constants.optional.js.map +1 -0
- package/lib/module/utils/createStore.js +27 -0
- package/lib/module/utils/createStore.js.map +1 -0
- package/lib/module/utils/index.js +11 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/module/utils/logger.js +185 -0
- package/lib/module/utils/logger.js.map +1 -0
- package/lib/module/utils/platform.js +340 -0
- package/lib/module/utils/platform.js.map +1 -0
- package/lib/module/utils/request-utils.js +58 -0
- package/lib/module/utils/request-utils.js.map +1 -0
- package/lib/module/utils/rrweb-events.js +276 -0
- package/lib/module/utils/rrweb-events.js.map +1 -0
- package/lib/module/utils/session.js +21 -0
- package/lib/module/utils/session.js.map +1 -0
- package/lib/module/utils/shallowEqual.js +17 -0
- package/lib/module/utils/shallowEqual.js.map +1 -0
- package/lib/module/utils/time.js +17 -0
- package/lib/module/utils/time.js.map +1 -0
- package/lib/module/utils/type-utils.js +69 -0
- package/lib/module/utils/type-utils.js.map +1 -0
- package/lib/module/version.js +4 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/components/ScreenRecorderView/ScreenRecorderView.d.ts +6 -0
- package/lib/typescript/src/components/ScreenRecorderView/ScreenRecorderView.d.ts.map +1 -0
- package/lib/typescript/src/components/ScreenRecorderView/index.d.ts +2 -0
- package/lib/typescript/src/components/ScreenRecorderView/index.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/components/SessionRecorderWidget/ErrorBanner.d.ts +1 -0
- package/lib/typescript/src/components/SessionRecorderWidget/ErrorBanner.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/components/SessionRecorderWidget/FinalPopover.d.ts +2 -1
- package/lib/typescript/src/components/SessionRecorderWidget/FinalPopover.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/components/SessionRecorderWidget/FloatingButton.d.ts +1 -0
- package/lib/typescript/src/components/SessionRecorderWidget/FloatingButton.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/components/SessionRecorderWidget/InitialPopover.d.ts +2 -1
- package/lib/typescript/src/components/SessionRecorderWidget/InitialPopover.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/components/SessionRecorderWidget/ModalContainer.d.ts +1 -0
- package/lib/typescript/src/components/SessionRecorderWidget/ModalContainer.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/components/SessionRecorderWidget/ModalHeader.d.ts +1 -0
- package/lib/typescript/src/components/SessionRecorderWidget/ModalHeader.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/components/SessionRecorderWidget/SessionRecorderWidget.d.ts +1 -0
- package/lib/typescript/src/components/SessionRecorderWidget/SessionRecorderWidget.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/components/SessionRecorderWidget/icons.d.ts +1 -0
- package/lib/typescript/src/components/SessionRecorderWidget/icons.d.ts.map +1 -0
- package/lib/typescript/src/components/SessionRecorderWidget/index.d.ts +3 -0
- package/lib/typescript/src/components/SessionRecorderWidget/index.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/components/SessionRecorderWidget/styles.d.ts +4 -3
- package/lib/typescript/src/components/SessionRecorderWidget/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +3 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/config/constants.d.ts +1 -0
- package/lib/typescript/src/config/constants.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/config/defaults.d.ts +2 -1
- package/lib/typescript/src/config/defaults.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/config/index.d.ts +1 -0
- package/lib/typescript/src/config/index.d.ts.map +1 -0
- package/lib/typescript/src/config/masking.d.ts +3 -0
- package/lib/typescript/src/config/masking.d.ts.map +1 -0
- package/lib/typescript/src/config/session-recorder.d.ts +3 -0
- package/lib/typescript/src/config/session-recorder.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/config/validators.d.ts +1 -0
- package/lib/typescript/src/config/validators.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/config/widget.d.ts +2 -1
- package/lib/typescript/src/config/widget.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/context/SessionRecorderContext.d.ts +3 -2
- package/lib/typescript/src/context/SessionRecorderContext.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/context/SessionRecorderStore.d.ts +2 -1
- package/lib/typescript/src/context/SessionRecorderStore.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/context/useSessionRecorderStore.d.ts +4 -3
- package/lib/typescript/src/context/useSessionRecorderStore.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/context/useStoreSelector.d.ts +2 -1
- package/lib/typescript/src/context/useStoreSelector.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/native/SessionRecorderNative.d.ts +21 -3
- package/lib/typescript/src/native/SessionRecorderNative.d.ts.map +1 -0
- package/lib/typescript/src/native/index.d.ts +2 -0
- package/lib/typescript/src/native/index.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/otel/helpers.d.ts +3 -2
- package/lib/typescript/src/otel/helpers.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/otel/index.d.ts +2 -2
- package/lib/typescript/src/otel/index.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/otel/instrumentations/index.d.ts +2 -1
- package/lib/typescript/src/otel/instrumentations/index.d.ts.map +1 -0
- package/lib/typescript/src/patch/index.d.ts +2 -0
- package/lib/typescript/src/patch/index.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/patch/xhr.d.ts +1 -0
- package/lib/typescript/src/patch/xhr.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/recorder/eventExporter.d.ts +2 -1
- package/lib/typescript/src/recorder/eventExporter.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/recorder/gestureRecorder.d.ts +3 -2
- package/lib/typescript/src/recorder/gestureRecorder.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/recorder/index.d.ts +3 -2
- package/lib/typescript/src/recorder/index.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/recorder/navigationTracker.d.ts +2 -1
- package/lib/typescript/src/recorder/navigationTracker.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/recorder/screenRecorder.d.ts +4 -4
- package/lib/typescript/src/recorder/screenRecorder.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/services/api.service.d.ts +2 -1
- package/lib/typescript/src/services/api.service.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/services/network.service.d.ts +1 -0
- package/lib/typescript/src/services/network.service.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/services/screenMaskingService.d.ts +2 -1
- package/lib/typescript/src/services/screenMaskingService.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/services/storage.service.d.ts +2 -1
- package/lib/typescript/src/services/storage.service.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/session-recorder.d.ts +3 -2
- package/lib/typescript/src/session-recorder.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/types/configs.d.ts +3 -2
- package/lib/typescript/src/types/configs.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/types/index.d.ts +1 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/types/session-recorder.d.ts +7 -6
- package/lib/typescript/src/types/session-recorder.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/types/session.d.ts +1 -0
- package/lib/typescript/src/types/session.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/utils/app-metadata.d.ts +1 -0
- package/lib/typescript/src/utils/app-metadata.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/utils/constants.optional.d.ts +1 -0
- package/lib/typescript/src/utils/constants.optional.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/utils/constants.optional.expo.d.ts +1 -0
- package/lib/typescript/src/utils/constants.optional.expo.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/utils/createStore.d.ts +1 -0
- package/lib/typescript/src/utils/createStore.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +8 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/utils/logger.d.ts +2 -1
- package/lib/typescript/src/utils/logger.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/utils/platform.d.ts +2 -1
- package/lib/typescript/src/utils/platform.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/utils/request-utils.d.ts +1 -0
- package/lib/typescript/src/utils/request-utils.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/utils/rrweb-events.d.ts +2 -1
- package/lib/typescript/src/utils/rrweb-events.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/utils/session.d.ts +1 -0
- package/lib/typescript/src/utils/session.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/utils/shallowEqual.d.ts +1 -0
- package/lib/typescript/src/utils/shallowEqual.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/utils/time.d.ts +1 -0
- package/lib/typescript/src/utils/time.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/utils/type-utils.d.ts +1 -0
- package/lib/typescript/src/utils/type-utils.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/version.d.ts +1 -0
- package/lib/typescript/src/version.d.ts.map +1 -0
- package/package.json +133 -44
- package/src/components/ScreenRecorderView/ScreenRecorderView.tsx +20 -0
- package/src/components/ScreenRecorderView/index.ts +1 -0
- package/src/components/SessionRecorderWidget/ErrorBanner.tsx +58 -0
- package/src/components/SessionRecorderWidget/FinalPopover.tsx +96 -0
- package/src/components/SessionRecorderWidget/FloatingButton.tsx +176 -0
- package/src/components/SessionRecorderWidget/InitialPopover.tsx +167 -0
- package/src/components/SessionRecorderWidget/ModalContainer.tsx +189 -0
- package/src/components/SessionRecorderWidget/ModalHeader.tsx +26 -0
- package/src/components/SessionRecorderWidget/SessionRecorderWidget.tsx +150 -0
- package/src/components/SessionRecorderWidget/icons.tsx +80 -0
- package/src/components/SessionRecorderWidget/index.ts +3 -0
- package/src/components/SessionRecorderWidget/styles.ts +168 -0
- package/src/config/constants.ts +67 -0
- package/src/config/defaults.ts +105 -0
- package/src/config/index.ts +6 -0
- package/src/config/masking.ts +60 -0
- package/src/config/session-recorder.ts +87 -0
- package/src/config/validators.ts +54 -0
- package/src/config/widget.ts +47 -0
- package/src/context/SessionRecorderContext.tsx +138 -0
- package/src/context/SessionRecorderStore.ts +22 -0
- package/src/context/useSessionRecorderStore.ts +34 -0
- package/src/context/useStoreSelector.ts +36 -0
- package/src/index.ts +10 -0
- package/src/native/SessionRecorderNative.ts +180 -0
- package/src/native/index.ts +5 -0
- package/src/otel/helpers.ts +290 -0
- package/src/otel/index.ts +132 -0
- package/src/otel/instrumentations/index.ts +118 -0
- package/src/patch/xhr.ts +148 -0
- package/src/recorder/eventExporter.ts +150 -0
- package/src/recorder/gestureRecorder.ts +828 -0
- package/src/recorder/index.ts +203 -0
- package/src/recorder/navigationTracker.ts +268 -0
- package/src/recorder/screenRecorder.ts +600 -0
- package/src/services/api.service.ts +216 -0
- package/src/services/network.service.ts +191 -0
- package/src/services/screenMaskingService.ts +153 -0
- package/src/services/storage.service.ts +248 -0
- package/src/session-recorder.ts +647 -0
- package/src/types/configs.ts +118 -0
- package/src/types/expo-constants.d.ts +7 -0
- package/src/types/index.ts +27 -0
- package/src/types/session-recorder.ts +381 -0
- package/src/types/session.ts +65 -0
- package/src/utils/app-metadata.ts +31 -0
- package/src/utils/constants.optional.expo.ts +5 -0
- package/src/utils/constants.optional.ts +18 -0
- package/src/utils/createStore.ts +32 -0
- package/{dist/utils/index.d.ts → src/utils/index.ts} +1 -0
- package/src/utils/logger.ts +245 -0
- package/src/utils/platform.ts +401 -0
- package/src/utils/request-utils.ts +61 -0
- package/src/utils/rrweb-events.ts +329 -0
- package/src/utils/session.ts +22 -0
- package/src/utils/shallowEqual.ts +20 -0
- package/src/utils/time.ts +20 -0
- package/src/utils/type-utils.ts +75 -0
- package/src/version.ts +1 -0
- package/REACT_NATIVE_SETUP.md +0 -91
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -7
- package/android/gradlew +0 -249
- package/android/gradlew.bat +0 -92
- package/copy-react-native-dist.sh +0 -56
- package/dist/components/ScreenRecorderView/ScreenRecorderView.d.ts +0 -5
- package/dist/components/ScreenRecorderView/ScreenRecorderView.js +0 -1
- package/dist/components/ScreenRecorderView/ScreenRecorderView.js.map +0 -1
- package/dist/components/ScreenRecorderView/index.d.ts +0 -1
- package/dist/components/ScreenRecorderView/index.js +0 -1
- package/dist/components/ScreenRecorderView/index.js.map +0 -1
- package/dist/components/SessionRecorderWidget/ErrorBanner.js +0 -1
- package/dist/components/SessionRecorderWidget/ErrorBanner.js.map +0 -1
- package/dist/components/SessionRecorderWidget/FinalPopover.js +0 -1
- package/dist/components/SessionRecorderWidget/FinalPopover.js.map +0 -1
- package/dist/components/SessionRecorderWidget/FloatingButton.js +0 -1
- package/dist/components/SessionRecorderWidget/FloatingButton.js.map +0 -1
- package/dist/components/SessionRecorderWidget/InitialPopover.js +0 -1
- package/dist/components/SessionRecorderWidget/InitialPopover.js.map +0 -1
- package/dist/components/SessionRecorderWidget/ModalContainer.js +0 -1
- package/dist/components/SessionRecorderWidget/ModalContainer.js.map +0 -1
- package/dist/components/SessionRecorderWidget/ModalHeader.js +0 -1
- package/dist/components/SessionRecorderWidget/ModalHeader.js.map +0 -1
- package/dist/components/SessionRecorderWidget/SessionRecorderWidget.js +0 -1
- package/dist/components/SessionRecorderWidget/SessionRecorderWidget.js.map +0 -1
- package/dist/components/SessionRecorderWidget/icons.js +0 -1
- package/dist/components/SessionRecorderWidget/icons.js.map +0 -1
- package/dist/components/SessionRecorderWidget/index.d.ts +0 -2
- package/dist/components/SessionRecorderWidget/index.js +0 -1
- package/dist/components/SessionRecorderWidget/index.js.map +0 -1
- package/dist/components/SessionRecorderWidget/styles.js +0 -1
- package/dist/components/SessionRecorderWidget/styles.js.map +0 -1
- package/dist/components/index.js +0 -1
- package/dist/components/index.js.map +0 -1
- package/dist/config/constants.js +0 -1
- package/dist/config/constants.js.map +0 -1
- package/dist/config/defaults.js +0 -1
- package/dist/config/defaults.js.map +0 -1
- package/dist/config/index.js +0 -1
- package/dist/config/index.js.map +0 -1
- package/dist/config/masking.d.ts +0 -2
- package/dist/config/masking.js +0 -1
- package/dist/config/masking.js.map +0 -1
- package/dist/config/session-recorder.d.ts +0 -2
- package/dist/config/session-recorder.js +0 -1
- package/dist/config/session-recorder.js.map +0 -1
- package/dist/config/validators.js +0 -1
- package/dist/config/validators.js.map +0 -1
- package/dist/config/widget.js +0 -1
- package/dist/config/widget.js.map +0 -1
- package/dist/context/SessionRecorderContext.js +0 -1
- package/dist/context/SessionRecorderContext.js.map +0 -1
- package/dist/context/SessionRecorderStore.js +0 -1
- package/dist/context/SessionRecorderStore.js.map +0 -1
- package/dist/context/useSessionRecorderStore.js +0 -1
- package/dist/context/useSessionRecorderStore.js.map +0 -1
- package/dist/context/useStoreSelector.js +0 -1
- package/dist/context/useStoreSelector.js.map +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +0 -1
- package/dist/native/GestureRecorderNative.d.ts +0 -57
- package/dist/native/GestureRecorderNative.js +0 -1
- package/dist/native/GestureRecorderNative.js.map +0 -1
- package/dist/native/GestureRecorderNativeTurboSpec.d.ts +0 -31
- package/dist/native/GestureRecorderNativeTurboSpec.js +0 -1
- package/dist/native/GestureRecorderNativeTurboSpec.js.map +0 -1
- package/dist/native/SessionRecorderNative.js +0 -1
- package/dist/native/SessionRecorderNative.js.map +0 -1
- package/dist/native/SessionRecorderNativeTurboSpec.d.ts +0 -17
- package/dist/native/SessionRecorderNativeTurboSpec.js +0 -1
- package/dist/native/SessionRecorderNativeTurboSpec.js.map +0 -1
- package/dist/native/index.d.ts +0 -1
- package/dist/native/index.js +0 -1
- package/dist/native/index.js.map +0 -1
- package/dist/otel/helpers.js +0 -1
- package/dist/otel/helpers.js.map +0 -1
- package/dist/otel/index.js +0 -1
- package/dist/otel/index.js.map +0 -1
- package/dist/otel/instrumentations/index.js +0 -1
- package/dist/otel/instrumentations/index.js.map +0 -1
- package/dist/patch/index.js +0 -1
- package/dist/patch/index.js.map +0 -1
- package/dist/patch/xhr.js +0 -1
- package/dist/patch/xhr.js.map +0 -1
- package/dist/recorder/eventExporter.js +0 -1
- package/dist/recorder/eventExporter.js.map +0 -1
- package/dist/recorder/gestureRecorder.js +0 -1
- package/dist/recorder/gestureRecorder.js.map +0 -1
- package/dist/recorder/index.js +0 -1
- package/dist/recorder/index.js.map +0 -1
- package/dist/recorder/navigationTracker.js +0 -1
- package/dist/recorder/navigationTracker.js.map +0 -1
- package/dist/recorder/screenRecorder.js +0 -1
- package/dist/recorder/screenRecorder.js.map +0 -1
- package/dist/services/api.service.js +0 -1
- package/dist/services/api.service.js.map +0 -1
- package/dist/services/network.service.js +0 -1
- package/dist/services/network.service.js.map +0 -1
- package/dist/services/screenMaskingService.js +0 -1
- package/dist/services/screenMaskingService.js.map +0 -1
- package/dist/services/storage.service.js +0 -1
- package/dist/services/storage.service.js.map +0 -1
- package/dist/session-recorder.js +0 -1
- package/dist/session-recorder.js.map +0 -1
- package/dist/types/configs.js +0 -1
- package/dist/types/configs.js.map +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/session-recorder.js +0 -1
- package/dist/types/session-recorder.js.map +0 -1
- package/dist/types/session.js +0 -1
- package/dist/types/session.js.map +0 -1
- package/dist/utils/app-metadata.js +0 -1
- package/dist/utils/app-metadata.js.map +0 -1
- package/dist/utils/constants.optional.expo.js +0 -1
- package/dist/utils/constants.optional.expo.js.map +0 -1
- package/dist/utils/constants.optional.js +0 -1
- package/dist/utils/constants.optional.js.map +0 -1
- package/dist/utils/createStore.js +0 -1
- package/dist/utils/createStore.js.map +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/logger.js +0 -1
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/platform.js +0 -1
- package/dist/utils/platform.js.map +0 -1
- package/dist/utils/request-utils.js +0 -1
- package/dist/utils/request-utils.js.map +0 -1
- package/dist/utils/rrweb-events.js +0 -1
- package/dist/utils/rrweb-events.js.map +0 -1
- package/dist/utils/session.js +0 -1
- package/dist/utils/session.js.map +0 -1
- package/dist/utils/shallowEqual.js +0 -1
- package/dist/utils/shallowEqual.js.map +0 -1
- package/dist/utils/time.js +0 -1
- package/dist/utils/time.js.map +0 -1
- package/dist/utils/type-utils.js +0 -1
- package/dist/utils/type-utils.js.map +0 -1
- package/dist/version.js +0 -1
- package/dist/version.js.map +0 -1
- package/docs/AUTO_METADATA_DETECTION.md +0 -108
- package/react-native.config.js +0 -13
- /package/{dist/components/index.d.ts → src/components/index.ts} +0 -0
- /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();
|