@multiplayer-app/session-recorder-react-native 1.0.1-beta.2 → 1.0.1-beta.4
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 -41
- 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/SessionRecorderNativeModuleSpec.kt +51 -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/android/src/main/java/com/xxx/XxxModule.kt +23 -0
- package/ios/GestureTargetFinder.swift +50 -0
- package/ios/SessionRecorderNative.podspec +4 -2
- package/ios/SessionRecorderNative.swift +10 -1
- package/ios/SessionRecorderNativeSpec.swift +55 -0
- package/ios/Xxx.h +5 -0
- package/ios/Xxx.mm +21 -0
- 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 +193 -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/{dist → lib/typescript/src}/components/index.d.ts +1 -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 +2 -1
- 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/{dist → lib/typescript/src}/native/index.d.ts +1 -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 +3 -2
- 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/{dist → lib/typescript/src}/utils/index.d.ts +1 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -0
- package/{dist → lib/typescript/src}/utils/logger.d.ts +1 -0
- 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/lib/typescript/src/version.d.ts +2 -0
- package/lib/typescript/src/version.d.ts.map +1 -0
- package/package.json +140 -39
- package/src/components/ScreenRecorderView/ScreenRecorderView.tsx +20 -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 +24 -0
- package/src/components/SessionRecorderWidget/SessionRecorderWidget.tsx +136 -0
- package/src/components/SessionRecorderWidget/icons.tsx +52 -0
- package/{dist/components/SessionRecorderWidget/index.d.ts → src/components/SessionRecorderWidget/index.ts} +1 -0
- package/src/components/SessionRecorderWidget/styles.ts +169 -0
- package/src/components/index.ts +2 -0
- package/src/config/constants.ts +68 -0
- package/src/config/defaults.ts +101 -0
- package/src/config/index.ts +6 -0
- package/src/config/masking.ts +34 -0
- package/src/config/session-recorder.ts +59 -0
- package/src/config/validators.ts +31 -0
- package/src/config/widget.ts +38 -0
- package/src/context/SessionRecorderContext.tsx +138 -0
- package/src/context/SessionRecorderStore.ts +21 -0
- package/src/context/useSessionRecorderStore.ts +27 -0
- package/src/context/useStoreSelector.ts +34 -0
- package/src/index.ts +10 -0
- package/src/native/SessionRecorderNative.ts +164 -0
- package/src/native/index.ts +1 -0
- package/src/otel/helpers.ts +274 -0
- package/src/otel/index.ts +135 -0
- package/src/otel/instrumentations/index.ts +115 -0
- package/src/patch/index.ts +1 -0
- package/src/patch/xhr.ts +149 -0
- package/src/recorder/eventExporter.ts +155 -0
- package/src/recorder/gestureRecorder.ts +681 -0
- package/src/recorder/index.ts +190 -0
- package/src/recorder/navigationTracker.ts +245 -0
- package/src/recorder/screenRecorder.ts +549 -0
- package/src/services/api.service.ts +215 -0
- package/src/services/network.service.ts +182 -0
- package/src/services/screenMaskingService.ts +122 -0
- package/src/services/storage.service.ts +219 -0
- package/src/session-recorder.ts +591 -0
- package/src/types/configs.ts +96 -0
- package/src/types/expo-constants.d.ts +7 -0
- package/src/types/index.ts +29 -0
- package/src/types/session-recorder.ts +386 -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 +16 -0
- package/src/utils/createStore.ts +29 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/logger.ts +216 -0
- package/src/utils/platform.ts +370 -0
- package/src/utils/request-utils.ts +61 -0
- package/src/utils/rrweb-events.ts +316 -0
- package/src/utils/session.ts +19 -0
- package/src/utils/shallowEqual.ts +14 -0
- package/src/utils/time.ts +17 -0
- package/src/utils/type-utils.ts +75 -0
- package/src/version.ts +1 -0
- 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.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.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.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.d.ts +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.d.ts +0 -1
- package/dist/version.js +0 -1
- package/dist/version.js.map +0 -1
- package/docs/AUTO_METADATA_DETECTION.md +0 -108
- /package/{dist/components/ScreenRecorderView/index.d.ts → src/components/ScreenRecorderView/index.ts} +0 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { resourceFromAttributes } from '@opentelemetry/resources'
|
|
2
|
+
import { W3CTraceContextPropagator } from '@opentelemetry/core'
|
|
3
|
+
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base'
|
|
4
|
+
import * as SemanticAttributes from '@opentelemetry/semantic-conventions'
|
|
5
|
+
import { registerInstrumentations } from '@opentelemetry/instrumentation'
|
|
6
|
+
import {
|
|
7
|
+
SessionType,
|
|
8
|
+
ATTR_MULTIPLAYER_SESSION_ID,
|
|
9
|
+
SessionRecorderIdGenerator,
|
|
10
|
+
SessionRecorderTraceIdRatioBasedSampler,
|
|
11
|
+
SessionRecorderBrowserTraceExporter,
|
|
12
|
+
} from '@multiplayer-app/session-recorder-common'
|
|
13
|
+
import { type TracerReactNativeConfig } from '../types'
|
|
14
|
+
import { getInstrumentations } from './instrumentations'
|
|
15
|
+
import { getExporterEndpoint } from './helpers'
|
|
16
|
+
|
|
17
|
+
import { getPlatformAttributes } from '../utils/platform'
|
|
18
|
+
import { WebTracerProvider } from '@opentelemetry/sdk-trace-web'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
export class TracerReactNativeSDK {
|
|
24
|
+
private tracerProvider?: WebTracerProvider
|
|
25
|
+
private config?: TracerReactNativeConfig
|
|
26
|
+
|
|
27
|
+
private sessionId = ''
|
|
28
|
+
private idGenerator?: SessionRecorderIdGenerator
|
|
29
|
+
private exporter?: any
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
constructor() { }
|
|
33
|
+
|
|
34
|
+
private _setSessionId(
|
|
35
|
+
sessionId: string,
|
|
36
|
+
sessionType: SessionType = SessionType.PLAIN,
|
|
37
|
+
) {
|
|
38
|
+
this.sessionId = sessionId
|
|
39
|
+
this.idGenerator?.setSessionId(sessionId, sessionType)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
init(options: TracerReactNativeConfig): void {
|
|
43
|
+
this.config = options
|
|
44
|
+
|
|
45
|
+
const { application, version, environment } = this.config
|
|
46
|
+
|
|
47
|
+
this.idGenerator = new SessionRecorderIdGenerator()
|
|
48
|
+
|
|
49
|
+
this.exporter = new SessionRecorderBrowserTraceExporter({
|
|
50
|
+
apiKey: options.apiKey,
|
|
51
|
+
url: getExporterEndpoint(options.exporterEndpoint),
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
this.tracerProvider = new WebTracerProvider({
|
|
55
|
+
resource: resourceFromAttributes({
|
|
56
|
+
[SemanticAttributes.SEMRESATTRS_SERVICE_NAME]: application,
|
|
57
|
+
[SemanticAttributes.SEMRESATTRS_SERVICE_VERSION]: version,
|
|
58
|
+
[SemanticAttributes.SEMRESATTRS_DEPLOYMENT_ENVIRONMENT]: environment,
|
|
59
|
+
...getPlatformAttributes(),
|
|
60
|
+
}),
|
|
61
|
+
idGenerator: this.idGenerator,
|
|
62
|
+
sampler: new SessionRecorderTraceIdRatioBasedSampler(this.config.sampleTraceRatio || 0.15),
|
|
63
|
+
spanProcessors: [
|
|
64
|
+
this._getSpanSessionIdProcessor(),
|
|
65
|
+
new BatchSpanProcessor(this.exporter),
|
|
66
|
+
],
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
this.tracerProvider.register({
|
|
70
|
+
propagator: new W3CTraceContextPropagator(),
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
// Register instrumentations
|
|
74
|
+
registerInstrumentations({
|
|
75
|
+
tracerProvider: this.tracerProvider,
|
|
76
|
+
instrumentations: getInstrumentations(this.config),
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private _getSpanSessionIdProcessor() {
|
|
82
|
+
return {
|
|
83
|
+
onStart: (span: any) => {
|
|
84
|
+
if (this.sessionId) {
|
|
85
|
+
span.setAttribute(ATTR_MULTIPLAYER_SESSION_ID, this.sessionId)
|
|
86
|
+
}
|
|
87
|
+
// Add React Native specific attributes
|
|
88
|
+
span.setAttribute('platform', 'react-native')
|
|
89
|
+
span.setAttribute('timestamp', Date.now())
|
|
90
|
+
},
|
|
91
|
+
onEnd: () => { },
|
|
92
|
+
shutdown: () => Promise.resolve(),
|
|
93
|
+
forceFlush: () => Promise.resolve(),
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
start(sessionId: string, sessionType: SessionType): void {
|
|
98
|
+
if (!this.tracerProvider) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
'Configuration not initialized. Call init() before start().',
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this._setSessionId(sessionId, sessionType)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
stop(): void {
|
|
108
|
+
if (!this.tracerProvider) {
|
|
109
|
+
throw new Error(
|
|
110
|
+
'Configuration not initialized. Call init() before start().',
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
this._setSessionId('')
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
setApiKey(apiKey: string): void {
|
|
118
|
+
if (!this.exporter) {
|
|
119
|
+
throw new Error(
|
|
120
|
+
'Configuration not initialized. Call init() before setApiKey().',
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
this.exporter.setApiKey?.(apiKey)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
setSessionId(sessionId: string, sessionType: SessionType): void {
|
|
128
|
+
this._setSessionId(sessionId, sessionType)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Shutdown (React Native specific)
|
|
132
|
+
shutdown(): Promise<void> {
|
|
133
|
+
return Promise.resolve()
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { FetchInstrumentation } from '@opentelemetry/instrumentation-fetch'
|
|
2
|
+
import { XMLHttpRequestInstrumentation } from '@opentelemetry/instrumentation-xml-http-request'
|
|
3
|
+
|
|
4
|
+
import { logger } from '../../utils'
|
|
5
|
+
import { OTEL_IGNORE_URLS } from '../../config'
|
|
6
|
+
import { type TracerReactNativeConfig } from '../../types'
|
|
7
|
+
import { extractResponseBody, headersToObject, processHttpPayload } from '../helpers'
|
|
8
|
+
|
|
9
|
+
export function getInstrumentations(config: TracerReactNativeConfig) {
|
|
10
|
+
|
|
11
|
+
const instrumentations = []
|
|
12
|
+
|
|
13
|
+
// Fetch instrumentation
|
|
14
|
+
try {
|
|
15
|
+
instrumentations.push(
|
|
16
|
+
new FetchInstrumentation({
|
|
17
|
+
clearTimingResources: false,
|
|
18
|
+
ignoreUrls: [
|
|
19
|
+
...OTEL_IGNORE_URLS,
|
|
20
|
+
...(config.ignoreUrls || []),
|
|
21
|
+
],
|
|
22
|
+
propagateTraceHeaderCorsUrls: config.propagateTraceHeaderCorsUrls,
|
|
23
|
+
applyCustomAttributesOnSpan: async (span, request, response) => {
|
|
24
|
+
if (!config) return
|
|
25
|
+
|
|
26
|
+
const { captureBody, captureHeaders } = config
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
if (!captureBody && !captureHeaders) {
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const requestBody = request.body
|
|
34
|
+
const requestHeaders = headersToObject(request.headers)
|
|
35
|
+
const responseHeaders = headersToObject(response instanceof Response ? response.headers : undefined)
|
|
36
|
+
|
|
37
|
+
let responseBody: string | null = null
|
|
38
|
+
if (response instanceof Response && response.body) {
|
|
39
|
+
responseBody = await extractResponseBody(response)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const payload = {
|
|
43
|
+
requestBody,
|
|
44
|
+
responseBody,
|
|
45
|
+
requestHeaders,
|
|
46
|
+
responseHeaders,
|
|
47
|
+
}
|
|
48
|
+
processHttpPayload(payload, config, span)
|
|
49
|
+
} catch (error) {
|
|
50
|
+
// eslint-disable-next-line
|
|
51
|
+
logger.error('DEBUGGER_LIB', 'Failed to capture fetch payload', error)
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
)
|
|
56
|
+
} catch (error) {
|
|
57
|
+
logger.warn('DEBUGGER_LIB', 'Fetch instrumentation not available', error)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// XMLHttpRequest instrumentation
|
|
61
|
+
try {
|
|
62
|
+
instrumentations.push(
|
|
63
|
+
new XMLHttpRequestInstrumentation({
|
|
64
|
+
clearTimingResources: false,
|
|
65
|
+
ignoreUrls: [
|
|
66
|
+
...OTEL_IGNORE_URLS,
|
|
67
|
+
...(config.ignoreUrls || []),
|
|
68
|
+
],
|
|
69
|
+
propagateTraceHeaderCorsUrls: config.propagateTraceHeaderCorsUrls,
|
|
70
|
+
applyCustomAttributesOnSpan: (span, xhr) => {
|
|
71
|
+
if (!config) return
|
|
72
|
+
|
|
73
|
+
const { captureBody, captureHeaders } = config
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
if (!captureBody && !captureHeaders) {
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
const requestBody = xhr.networkRequest.requestBody
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
const responseBody = xhr.networkRequest.responseBody
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
const requestHeaders = xhr.networkRequest.requestHeaders || {}
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
const responseHeaders = xhr.networkRequest.responseHeaders || {}
|
|
88
|
+
|
|
89
|
+
const payload = {
|
|
90
|
+
requestBody,
|
|
91
|
+
responseBody,
|
|
92
|
+
requestHeaders,
|
|
93
|
+
responseHeaders,
|
|
94
|
+
}
|
|
95
|
+
processHttpPayload(payload, config, span)
|
|
96
|
+
} catch (error) {
|
|
97
|
+
// eslint-disable-next-line
|
|
98
|
+
logger.error('DEBUGGER_LIB', 'Failed to capture xml-http payload', error)
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
})
|
|
102
|
+
)
|
|
103
|
+
} catch (error) {
|
|
104
|
+
logger.warn('DEBUGGER_LIB', 'XMLHttpRequest instrumentation not available', error)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Custom React Native instrumentations
|
|
108
|
+
// try {
|
|
109
|
+
// instrumentations.push(new ReactNativeInstrumentation())
|
|
110
|
+
// } catch (error) {
|
|
111
|
+
// console.warn('React Native instrumentation not available:', error)
|
|
112
|
+
// }
|
|
113
|
+
|
|
114
|
+
return instrumentations
|
|
115
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './xhr'
|
package/src/patch/xhr.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { Platform } from 'react-native'
|
|
2
|
+
import {
|
|
3
|
+
|
|
4
|
+
isFormData,
|
|
5
|
+
isNullish,
|
|
6
|
+
isObject,
|
|
7
|
+
isString,
|
|
8
|
+
} from '../utils/type-utils'
|
|
9
|
+
import { formDataToQuery } from '../utils/request-utils'
|
|
10
|
+
import { DEFAULT_MAX_HTTP_CAPTURING_PAYLOAD_SIZE } from '../config'
|
|
11
|
+
|
|
12
|
+
// Check if we're on web platform
|
|
13
|
+
const isWeb = Platform.OS === 'web'
|
|
14
|
+
|
|
15
|
+
let recordRequestHeaders = true
|
|
16
|
+
let recordResponseHeaders = true
|
|
17
|
+
let shouldRecordBody = true
|
|
18
|
+
let maxCapturingHttpPayloadSize = DEFAULT_MAX_HTTP_CAPTURING_PAYLOAD_SIZE
|
|
19
|
+
|
|
20
|
+
export const setMaxCapturingHttpPayloadSize = (_maxCapturingHttpPayloadSize: number) => {
|
|
21
|
+
maxCapturingHttpPayloadSize = _maxCapturingHttpPayloadSize
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const setShouldRecordHttpData = (shouldRecordBody: boolean, shouldRecordHeaders: boolean) => {
|
|
25
|
+
recordRequestHeaders = shouldRecordHeaders
|
|
26
|
+
recordResponseHeaders = shouldRecordHeaders
|
|
27
|
+
shouldRecordBody = shouldRecordBody
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function _tryReadXHRBody({
|
|
31
|
+
body,
|
|
32
|
+
}: {
|
|
33
|
+
body: any | null | undefined
|
|
34
|
+
url: string | URL | RequestInfo
|
|
35
|
+
}): string | null {
|
|
36
|
+
|
|
37
|
+
if (isNullish(body)) {
|
|
38
|
+
return null
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (isString(body)) {
|
|
42
|
+
return body
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (isFormData(body)) {
|
|
46
|
+
return formDataToQuery(body)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (isObject(body)) {
|
|
50
|
+
try {
|
|
51
|
+
return JSON.stringify({ ...body })
|
|
52
|
+
} catch {
|
|
53
|
+
return '[XHR] Failed to stringify response object'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return `[XHR] Cannot read body of type ${Object.prototype.toString.call(body)}`
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Only patch XMLHttpRequest if not on web platform or if XMLHttpRequest is available
|
|
61
|
+
if (!isWeb && typeof XMLHttpRequest !== 'undefined') {
|
|
62
|
+
(function (xhr) {
|
|
63
|
+
const originalOpen = XMLHttpRequest.prototype.open
|
|
64
|
+
|
|
65
|
+
xhr.open = function (
|
|
66
|
+
method: string,
|
|
67
|
+
url: string | URL,
|
|
68
|
+
async = true,
|
|
69
|
+
username?: string | null,
|
|
70
|
+
password?: string | null,
|
|
71
|
+
) {
|
|
72
|
+
const xhr = this as XMLHttpRequest
|
|
73
|
+
const networkRequest: {
|
|
74
|
+
requestHeaders?: any,
|
|
75
|
+
requestBody?: any,
|
|
76
|
+
responseHeaders?: any,
|
|
77
|
+
responseBody?: any,
|
|
78
|
+
} = {}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
const requestHeaders: Record<string, string> = {}
|
|
83
|
+
const originalSetRequestHeader = xhr.setRequestHeader.bind(xhr)
|
|
84
|
+
xhr.setRequestHeader = (header: string, value: string) => {
|
|
85
|
+
requestHeaders[header] = value
|
|
86
|
+
return originalSetRequestHeader(header, value)
|
|
87
|
+
}
|
|
88
|
+
if (recordRequestHeaders) {
|
|
89
|
+
networkRequest.requestHeaders = requestHeaders
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const originalSend = xhr.send.bind(xhr)
|
|
93
|
+
xhr.send = (body) => {
|
|
94
|
+
if (shouldRecordBody) {
|
|
95
|
+
const requestBody = _tryReadXHRBody({ body, url })
|
|
96
|
+
|
|
97
|
+
if (
|
|
98
|
+
requestBody?.length
|
|
99
|
+
&& requestBody.length <= maxCapturingHttpPayloadSize
|
|
100
|
+
) {
|
|
101
|
+
networkRequest.requestBody = requestBody
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return originalSend(body)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
xhr.addEventListener('readystatechange', () => {
|
|
108
|
+
if (xhr.readyState !== xhr.DONE) {
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// @ts-ignore
|
|
113
|
+
const responseHeaders: Record<string, string> = {}
|
|
114
|
+
const rawHeaders = xhr.getAllResponseHeaders() || ''
|
|
115
|
+
const headers = rawHeaders.trim().split(/[\r\n]+/).filter(Boolean)
|
|
116
|
+
|
|
117
|
+
headers.forEach((line) => {
|
|
118
|
+
const parts = line.split(': ')
|
|
119
|
+
const header = parts.shift()
|
|
120
|
+
const value = parts.join(': ')
|
|
121
|
+
if (header) {
|
|
122
|
+
responseHeaders[header] = value
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
if (recordResponseHeaders) {
|
|
126
|
+
networkRequest.responseHeaders = responseHeaders
|
|
127
|
+
}
|
|
128
|
+
if (shouldRecordBody) {
|
|
129
|
+
const responseBody = _tryReadXHRBody({ body: xhr.response, url })
|
|
130
|
+
|
|
131
|
+
if (
|
|
132
|
+
responseBody?.length
|
|
133
|
+
&& responseBody.length <= maxCapturingHttpPayloadSize
|
|
134
|
+
) {
|
|
135
|
+
networkRequest.responseBody = responseBody
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
// @ts-ignore
|
|
142
|
+
xhr.networkRequest = networkRequest
|
|
143
|
+
|
|
144
|
+
originalOpen.call(xhr, method, url as string, async, username, password)
|
|
145
|
+
}
|
|
146
|
+
})(XMLHttpRequest.prototype)
|
|
147
|
+
} else if (isWeb) {
|
|
148
|
+
console.info('XHR patch: Skipping XMLHttpRequest patching on web platform')
|
|
149
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import io, { Socket } from 'socket.io-client'
|
|
2
|
+
|
|
3
|
+
import { type ISession } from '../types'
|
|
4
|
+
import { logger } from '../utils'
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
SESSION_ADD_EVENT,
|
|
8
|
+
SESSION_AUTO_CREATED,
|
|
9
|
+
SESSION_STOPPED_EVENT,
|
|
10
|
+
SESSION_SUBSCRIBE_EVENT,
|
|
11
|
+
SESSION_UNSUBSCRIBE_EVENT,
|
|
12
|
+
} from '../config'
|
|
13
|
+
|
|
14
|
+
const MAX_RECONNECTION_ATTEMPTS = 2
|
|
15
|
+
|
|
16
|
+
export class EventExporter {
|
|
17
|
+
private socket: Socket | null = null
|
|
18
|
+
private queue: any[] = []
|
|
19
|
+
private isConnecting: boolean = false
|
|
20
|
+
private isConnected: boolean = false
|
|
21
|
+
private attempts: number = 0
|
|
22
|
+
private sessionId: string | null = null
|
|
23
|
+
|
|
24
|
+
private socketUrl: string
|
|
25
|
+
private apiKey: string
|
|
26
|
+
|
|
27
|
+
constructor(options: { socketUrl: string, apiKey: string }) {
|
|
28
|
+
this.socketUrl = options.socketUrl
|
|
29
|
+
this.apiKey = options.apiKey
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private init(): void {
|
|
33
|
+
if (this.isConnecting || this.isConnected) return
|
|
34
|
+
this.attempts++
|
|
35
|
+
this.isConnecting = true
|
|
36
|
+
this.socket = io(this.socketUrl, {
|
|
37
|
+
path: '/v0/radar/ws',
|
|
38
|
+
auth: {
|
|
39
|
+
'x-api-key': this.apiKey,
|
|
40
|
+
},
|
|
41
|
+
reconnectionAttempts: 2,
|
|
42
|
+
transports: ['websocket'],
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
// this.socket.on('connect', () => {
|
|
46
|
+
// this.isConnecting = false
|
|
47
|
+
// this.isConnected = true
|
|
48
|
+
// this.usePostMessage = false
|
|
49
|
+
// this.flushQueue()
|
|
50
|
+
// })
|
|
51
|
+
|
|
52
|
+
this.socket.on('ready', () => {
|
|
53
|
+
this.isConnecting = false
|
|
54
|
+
this.isConnected = true
|
|
55
|
+
logger.info('EventExporter', 'Connected to server')
|
|
56
|
+
this.flushQueue()
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
this.socket.on('disconnect', (_err: any) => {
|
|
60
|
+
this.isConnecting = false
|
|
61
|
+
this.isConnected = false
|
|
62
|
+
logger.info('EventExporter', 'Disconnected from server')
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
this.socket.on('connect_error', (err: any) => {
|
|
66
|
+
this.isConnecting = false
|
|
67
|
+
this.isConnected = false
|
|
68
|
+
this.checkReconnectionAttempts()
|
|
69
|
+
logger.error('EventExporter', 'Error connecting to server', err)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
this.socket.on(SESSION_STOPPED_EVENT, (_: any) => {
|
|
73
|
+
|
|
74
|
+
this.unsubscribeFromSession()
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
this.socket.on(SESSION_AUTO_CREATED, (_: any) => {
|
|
78
|
+
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
setApiKey(apiKey: string): void {
|
|
83
|
+
this.apiKey = apiKey
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
setSocketUrl(socketUrl: string): void {
|
|
87
|
+
this.socketUrl = socketUrl
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private checkReconnectionAttempts(): void {
|
|
91
|
+
if (this.attempts >= MAX_RECONNECTION_ATTEMPTS) {
|
|
92
|
+
|
|
93
|
+
this.flushQueue()
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
private flushQueue(): void {
|
|
99
|
+
while (this.queue.length > 0 && (this.socket?.connected)) {
|
|
100
|
+
const event = this.queue.shift()
|
|
101
|
+
if (!event) continue
|
|
102
|
+
|
|
103
|
+
if (this.socket?.connected) {
|
|
104
|
+
this.socket.emit(event.name, event.data)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private unsubscribeFromSession() {
|
|
110
|
+
const payload = {
|
|
111
|
+
debugSessionId: this.sessionId,
|
|
112
|
+
}
|
|
113
|
+
if (this.socket?.connected) {
|
|
114
|
+
this.socket.emit(SESSION_UNSUBSCRIBE_EVENT, payload)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public send(event: any): void {
|
|
119
|
+
if (this.socket?.connected) {
|
|
120
|
+
this.socket.emit(SESSION_ADD_EVENT, event)
|
|
121
|
+
} else {
|
|
122
|
+
this.queue.push({ data: event, name: SESSION_ADD_EVENT })
|
|
123
|
+
this.init()
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
public subscribeToSession(session: ISession): void {
|
|
128
|
+
this.sessionId = session.shortId || session._id
|
|
129
|
+
const payload = {
|
|
130
|
+
projectId: session.project,
|
|
131
|
+
workspaceId: session.workspace,
|
|
132
|
+
debugSessionId: this.sessionId,
|
|
133
|
+
sessionType: session.creationType,
|
|
134
|
+
}
|
|
135
|
+
if (this.socket?.connected) {
|
|
136
|
+
this.socket.emit(SESSION_SUBSCRIBE_EVENT, payload)
|
|
137
|
+
} else {
|
|
138
|
+
this.queue.push({ data: payload, name: SESSION_SUBSCRIBE_EVENT })
|
|
139
|
+
this.init()
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public close(): void {
|
|
144
|
+
if (this.socket?.connected) {
|
|
145
|
+
setTimeout(() => {
|
|
146
|
+
this.unsubscribeFromSession()
|
|
147
|
+
this.attempts = 0
|
|
148
|
+
this.isConnected = false
|
|
149
|
+
this.isConnecting = false
|
|
150
|
+
this.socket?.disconnect()
|
|
151
|
+
this.socket = null
|
|
152
|
+
}, 500)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|