@multiplayer-app/session-recorder-react-native 1.0.1-beta.1 → 1.0.1-beta.10
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 +35 -14
- package/android/build.gradle +50 -54
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/sessionrecordernative/SessionRecorderNativeConfig.kt +52 -0
- package/android/src/main/java/com/sessionrecordernative/SessionRecorderNativeModule.kt +861 -0
- package/android/src/main/java/com/sessionrecordernative/SessionRecorderNativePackage.kt +33 -0
- package/android/src/main/java/com/sessionrecordernative/SessionRecorderNativeSpec.kt +79 -0
- package/android/src/main/java/com/sessionrecordernative/model/TargetInfo.kt +9 -0
- package/android/src/main/java/com/sessionrecordernative/util/ViewUtils.kt +72 -0
- package/ios/GestureTargetFinder.swift +50 -0
- package/ios/SessionRecorderNative-Bridging-Header.h +2 -0
- package/ios/{GestureRecorderNative.m → SessionRecorderNative.mm} +17 -6
- package/ios/SessionRecorderNative.swift +256 -4
- package/lib/module/SessionRecorderNativeSpec.js +5 -0
- package/lib/module/SessionRecorderNativeSpec.js.map +1 -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 +16 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/native/SessionRecorderNative.js +79 -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/{dist/native/SessionRecorderNative.d.ts → lib/typescript/src/SessionRecorderNativeSpec.d.ts} +23 -15
- package/lib/typescript/src/SessionRecorderNativeSpec.d.ts.map +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 +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/native/SessionRecorderNative.d.ts +27 -0
- 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/lib/typescript/src/version.d.ts +2 -0
- package/lib/typescript/src/version.d.ts.map +1 -0
- package/package.json +154 -37
- package/react-native.config.js +14 -0
- package/src/SessionRecorderNativeSpec.ts +52 -0
- 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 +13 -0
- package/src/native/SessionRecorderNative.ts +120 -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/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 -2
- 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.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/ios/GestureRecorderNative.swift +0 -316
- package/ios/SessionRecorderNative.m +0 -17
- package/ios/SessionRecorderNative.podspec +0 -26
- package/turbo.json +0 -41
- /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,828 @@
|
|
|
1
|
+
import { Dimensions, Platform } from 'react-native';
|
|
2
|
+
import { trace, SpanStatusCode, type Span } from '@opentelemetry/api';
|
|
3
|
+
import { logger } from '../utils';
|
|
4
|
+
import {
|
|
5
|
+
type GestureEvent,
|
|
6
|
+
type RecorderConfig,
|
|
7
|
+
type EventRecorder,
|
|
8
|
+
} from '../types';
|
|
9
|
+
import {
|
|
10
|
+
MouseInteractions,
|
|
11
|
+
type eventWithTime,
|
|
12
|
+
EventType,
|
|
13
|
+
IncrementalSource,
|
|
14
|
+
} from '@rrweb/types';
|
|
15
|
+
import {
|
|
16
|
+
type NativeGestureEvent,
|
|
17
|
+
SessionRecorderNative,
|
|
18
|
+
gestureEventEmitter,
|
|
19
|
+
} from '../native';
|
|
20
|
+
// Force TypeScript recompilation
|
|
21
|
+
|
|
22
|
+
export class GestureRecorder implements EventRecorder {
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
private config?: RecorderConfig;
|
|
25
|
+
private isRecording = false;
|
|
26
|
+
private events: GestureEvent[] = [];
|
|
27
|
+
private screenDimensions: { width: number; height: number } | null = null;
|
|
28
|
+
private lastGestureTime: number = 0;
|
|
29
|
+
private gestureThrottleMs: number = 50; // Throttle gestures to avoid spam
|
|
30
|
+
private lastTouchTime: number = 0;
|
|
31
|
+
private touchThrottleMs: number = 100; // Throttle touch events to max 10 per second
|
|
32
|
+
private eventRecorder?: EventRecorder;
|
|
33
|
+
private imageNodeId: number = 1; // ID of the image node for touch interactions
|
|
34
|
+
private screenRecorder?: any; // Reference to screen recorder for force capture
|
|
35
|
+
private gestureEventListener?: any; // Native event listener
|
|
36
|
+
private currentPanSpan?: Span; // Aggregated span for pan gesture
|
|
37
|
+
private panMoveCount: number = 0;
|
|
38
|
+
|
|
39
|
+
init(
|
|
40
|
+
config: RecorderConfig,
|
|
41
|
+
eventRecorder?: EventRecorder,
|
|
42
|
+
screenRecorder?: any
|
|
43
|
+
): void {
|
|
44
|
+
this.config = config;
|
|
45
|
+
this.eventRecorder = eventRecorder;
|
|
46
|
+
this.screenRecorder = screenRecorder;
|
|
47
|
+
this._getScreenDimensions();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
start(): void {
|
|
51
|
+
logger.info('GestureRecorder', 'Native gesture recording started');
|
|
52
|
+
this.isRecording = true;
|
|
53
|
+
this.events = [];
|
|
54
|
+
|
|
55
|
+
// Check if we're on web platform
|
|
56
|
+
if (Platform.OS === 'web') {
|
|
57
|
+
logger.warn(
|
|
58
|
+
'GestureRecorder',
|
|
59
|
+
'Native gesture recording not available on web platform'
|
|
60
|
+
);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Start native gesture recording
|
|
65
|
+
SessionRecorderNative.startGestureRecording()
|
|
66
|
+
.then(() => {
|
|
67
|
+
logger.info(
|
|
68
|
+
'GestureRecorder',
|
|
69
|
+
'Native gesture recording started successfully'
|
|
70
|
+
);
|
|
71
|
+
this._setupGestureEventListener();
|
|
72
|
+
})
|
|
73
|
+
.catch((error) => {
|
|
74
|
+
logger.error(
|
|
75
|
+
'GestureRecorder',
|
|
76
|
+
'Failed to start native gesture recording',
|
|
77
|
+
error
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
stop(): void {
|
|
83
|
+
this.isRecording = false;
|
|
84
|
+
this._removeGestureEventListener();
|
|
85
|
+
|
|
86
|
+
// Check if we're on web platform
|
|
87
|
+
if (Platform.OS === 'web') {
|
|
88
|
+
logger.warn(
|
|
89
|
+
'GestureRecorder',
|
|
90
|
+
'Native gesture recording not available on web platform'
|
|
91
|
+
);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Stop native gesture recording
|
|
96
|
+
SessionRecorderNative.stopGestureRecording()
|
|
97
|
+
.then(() => {
|
|
98
|
+
logger.info(
|
|
99
|
+
'GestureRecorder',
|
|
100
|
+
'Native gesture recording stopped successfully'
|
|
101
|
+
);
|
|
102
|
+
})
|
|
103
|
+
.catch((error) => {
|
|
104
|
+
logger.error(
|
|
105
|
+
'GestureRecorder',
|
|
106
|
+
'Failed to stop native gesture recording',
|
|
107
|
+
error
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private _getScreenDimensions(): void {
|
|
113
|
+
try {
|
|
114
|
+
this.screenDimensions = Dimensions.get('window');
|
|
115
|
+
} catch (error) {
|
|
116
|
+
// Failed to get screen dimensions - silently continue
|
|
117
|
+
this.screenDimensions = { width: 375, height: 667 }; // Default fallback
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private _setupGestureEventListener(): void {
|
|
122
|
+
if (!gestureEventEmitter) {
|
|
123
|
+
logger.warn('GestureRecorder', 'Gesture event emitter not available');
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
this.gestureEventListener = gestureEventEmitter.addListener(
|
|
128
|
+
'onGestureDetected',
|
|
129
|
+
(nativeGesture: any) => {
|
|
130
|
+
this._handleNativeGesture(nativeGesture as NativeGestureEvent);
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private _removeGestureEventListener(): void {
|
|
136
|
+
if (this.gestureEventListener) {
|
|
137
|
+
this.gestureEventListener.remove();
|
|
138
|
+
this.gestureEventListener = undefined;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private _handleNativeGesture(nativeGesture: NativeGestureEvent): void {
|
|
143
|
+
if (!this.isRecording) return;
|
|
144
|
+
|
|
145
|
+
// Throttle gestures to avoid spam
|
|
146
|
+
const now = Date.now();
|
|
147
|
+
if (now - this.lastGestureTime < this.gestureThrottleMs) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
this.lastGestureTime = now;
|
|
151
|
+
|
|
152
|
+
// Convert native gesture to our format
|
|
153
|
+
const gesture: GestureEvent = {
|
|
154
|
+
type: nativeGesture.type as any,
|
|
155
|
+
timestamp: nativeGesture.timestamp,
|
|
156
|
+
coordinates: { x: nativeGesture.x, y: nativeGesture.y },
|
|
157
|
+
target: nativeGesture.target,
|
|
158
|
+
targetInfo: nativeGesture.targetInfo, // Pass through targetInfo from native
|
|
159
|
+
metadata: {
|
|
160
|
+
...nativeGesture.metadata,
|
|
161
|
+
screenWidth: this.screenDimensions?.width,
|
|
162
|
+
screenHeight: this.screenDimensions?.height,
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
this.events.push(gesture);
|
|
167
|
+
this._sendEvent(gesture);
|
|
168
|
+
this._recordOpenTelemetrySpan(gesture);
|
|
169
|
+
|
|
170
|
+
// Handle specific gesture types
|
|
171
|
+
switch (nativeGesture.type) {
|
|
172
|
+
case 'tap':
|
|
173
|
+
this._handleTapGesture(nativeGesture);
|
|
174
|
+
break;
|
|
175
|
+
case 'pan_start':
|
|
176
|
+
this._handlePanStartGesture(nativeGesture);
|
|
177
|
+
break;
|
|
178
|
+
case 'pan_move':
|
|
179
|
+
this._handlePanMoveGesture(nativeGesture);
|
|
180
|
+
break;
|
|
181
|
+
case 'pan_end':
|
|
182
|
+
this._handlePanEndGesture(nativeGesture);
|
|
183
|
+
break;
|
|
184
|
+
case 'long_press':
|
|
185
|
+
this._handleLongPressGesture(nativeGesture);
|
|
186
|
+
break;
|
|
187
|
+
case 'pinch':
|
|
188
|
+
this._handlePinchGesture(nativeGesture);
|
|
189
|
+
break;
|
|
190
|
+
case 'swipe':
|
|
191
|
+
this._handleSwipeGesture(nativeGesture);
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private _handleTapGesture(nativeGesture: NativeGestureEvent): void {
|
|
197
|
+
this.recordTouchStart(
|
|
198
|
+
nativeGesture.x,
|
|
199
|
+
nativeGesture.y,
|
|
200
|
+
nativeGesture.target
|
|
201
|
+
);
|
|
202
|
+
this.recordTouchEnd(nativeGesture.x, nativeGesture.y, nativeGesture.target);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
private _handlePanStartGesture(nativeGesture: NativeGestureEvent): void {
|
|
206
|
+
this.recordTouchStart(
|
|
207
|
+
nativeGesture.x,
|
|
208
|
+
nativeGesture.y,
|
|
209
|
+
nativeGesture.target
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
private _handlePanMoveGesture(nativeGesture: NativeGestureEvent): void {
|
|
214
|
+
this.recordTouchMove(
|
|
215
|
+
nativeGesture.x,
|
|
216
|
+
nativeGesture.y,
|
|
217
|
+
nativeGesture.target
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private _handlePanEndGesture(nativeGesture: NativeGestureEvent): void {
|
|
222
|
+
this.recordTouchEnd(nativeGesture.x, nativeGesture.y, nativeGesture.target);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private _handleLongPressGesture(nativeGesture: NativeGestureEvent): void {
|
|
226
|
+
this.recordTouchStart(
|
|
227
|
+
nativeGesture.x,
|
|
228
|
+
nativeGesture.y,
|
|
229
|
+
nativeGesture.target
|
|
230
|
+
);
|
|
231
|
+
this.recordTouchEnd(nativeGesture.x, nativeGesture.y, nativeGesture.target);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private _handlePinchGesture(nativeGesture: NativeGestureEvent): void {
|
|
235
|
+
this.recordPinch(
|
|
236
|
+
nativeGesture.metadata?.scale || 1.0,
|
|
237
|
+
nativeGesture.target,
|
|
238
|
+
nativeGesture.metadata?.velocity || 0
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
private _handleSwipeGesture(nativeGesture: NativeGestureEvent): void {
|
|
243
|
+
this.recordSwipe(
|
|
244
|
+
nativeGesture.metadata?.direction || 'unknown',
|
|
245
|
+
nativeGesture.target,
|
|
246
|
+
nativeGesture.metadata?.velocity || 0
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
private _sendEvent(event: GestureEvent): void {
|
|
251
|
+
// Send event to backend or store locally
|
|
252
|
+
logger.debug('GestureRecorder', 'Gesture event recorded', {
|
|
253
|
+
type: event.type,
|
|
254
|
+
target: event.target,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
private _recordOpenTelemetrySpan(event: GestureEvent): void {
|
|
259
|
+
try {
|
|
260
|
+
logger.debug('GestureRecorder', 'Creating OTEL span for native gesture', {
|
|
261
|
+
type: event.type,
|
|
262
|
+
target: event.target,
|
|
263
|
+
targetInfo: event.targetInfo,
|
|
264
|
+
hasTargetInfo: !!event.targetInfo,
|
|
265
|
+
});
|
|
266
|
+
// Special handling to aggregate pan gestures into a single span
|
|
267
|
+
if (event.type === 'pan_start') {
|
|
268
|
+
// End any previously dangling pan span defensively
|
|
269
|
+
if (this.currentPanSpan) {
|
|
270
|
+
this.currentPanSpan.setStatus({ code: SpanStatusCode.OK });
|
|
271
|
+
this.currentPanSpan.end();
|
|
272
|
+
}
|
|
273
|
+
this.panMoveCount = 0;
|
|
274
|
+
const panSpan = trace
|
|
275
|
+
.getTracer('@opentelemetry/instrumentation-user-interaction')
|
|
276
|
+
.startSpan('NativeGesture.pan', {
|
|
277
|
+
startTime: event.timestamp,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
panSpan.setAttribute('gesture.type', 'pan');
|
|
281
|
+
panSpan.setAttribute('gesture.timestamp', event.timestamp);
|
|
282
|
+
panSpan.setAttribute('gesture.platform', 'react-native');
|
|
283
|
+
panSpan.setAttribute('gesture.source', 'native-module');
|
|
284
|
+
|
|
285
|
+
if (event.coordinates) {
|
|
286
|
+
panSpan.setAttribute('gesture.start.x', event.coordinates.x);
|
|
287
|
+
panSpan.setAttribute('gesture.start.y', event.coordinates.y);
|
|
288
|
+
}
|
|
289
|
+
if (event.target) {
|
|
290
|
+
panSpan.setAttribute(
|
|
291
|
+
'gesture.target',
|
|
292
|
+
this._truncateText(event.target, 50)
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
// Enrich with target info if provided
|
|
296
|
+
const info = event.targetInfo;
|
|
297
|
+
if (info) {
|
|
298
|
+
if (info.label) {
|
|
299
|
+
const truncatedLabel = this._truncateText(String(info.label), 50);
|
|
300
|
+
panSpan.setAttribute('gesture.target.label', truncatedLabel);
|
|
301
|
+
}
|
|
302
|
+
if (info.role) {
|
|
303
|
+
panSpan.setAttribute('gesture.target.role', String(info.role));
|
|
304
|
+
}
|
|
305
|
+
if (info.testId) {
|
|
306
|
+
panSpan.setAttribute('gesture.target.test_id', String(info.testId));
|
|
307
|
+
}
|
|
308
|
+
if (info.text) {
|
|
309
|
+
const truncatedText = this._truncateText(String(info.text), 50);
|
|
310
|
+
panSpan.setAttribute('gesture.target.text', truncatedText);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
// Save the span for subsequent move/end events
|
|
314
|
+
this.currentPanSpan = panSpan;
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (event.type === 'pan_move') {
|
|
319
|
+
if (this.currentPanSpan) {
|
|
320
|
+
this.panMoveCount += 1;
|
|
321
|
+
this.currentPanSpan.setAttribute(
|
|
322
|
+
'gesture.pan.move_count',
|
|
323
|
+
this.panMoveCount
|
|
324
|
+
);
|
|
325
|
+
if (event.coordinates) {
|
|
326
|
+
this.currentPanSpan.setAttribute(
|
|
327
|
+
'gesture.last.x',
|
|
328
|
+
event.coordinates.x
|
|
329
|
+
);
|
|
330
|
+
this.currentPanSpan.setAttribute(
|
|
331
|
+
'gesture.last.y',
|
|
332
|
+
event.coordinates.y
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
// Don't end the span here; just update it
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
// If we received a move without a start, fall through to single-shot span below
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (event.type === 'pan_end') {
|
|
342
|
+
if (this.currentPanSpan) {
|
|
343
|
+
if (event.coordinates) {
|
|
344
|
+
this.currentPanSpan.setAttribute(
|
|
345
|
+
'gesture.end.x',
|
|
346
|
+
event.coordinates.x
|
|
347
|
+
);
|
|
348
|
+
this.currentPanSpan.setAttribute(
|
|
349
|
+
'gesture.end.y',
|
|
350
|
+
event.coordinates.y
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
this.currentPanSpan.setStatus({ code: SpanStatusCode.OK });
|
|
354
|
+
this.currentPanSpan.end();
|
|
355
|
+
this.currentPanSpan = undefined;
|
|
356
|
+
this.panMoveCount = 0;
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
// If no current span, fall through and create a single-shot span for the end event
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// Default behavior: create a short-lived span per non-pan event
|
|
363
|
+
const span = trace
|
|
364
|
+
.getTracer('@opentelemetry/instrumentation-user-interaction')
|
|
365
|
+
.startSpan(`NativeGesture.${event.type}`, {
|
|
366
|
+
startTime: event.timestamp,
|
|
367
|
+
attributes: {
|
|
368
|
+
'gesture.type': event.type,
|
|
369
|
+
'gesture.timestamp': event.timestamp,
|
|
370
|
+
'gesture.platform': 'react-native',
|
|
371
|
+
'gesture.source': 'native-module',
|
|
372
|
+
},
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
if (event.coordinates) {
|
|
376
|
+
span.setAttribute('gesture.coordinates.x', event.coordinates.x);
|
|
377
|
+
span.setAttribute('gesture.coordinates.y', event.coordinates.y);
|
|
378
|
+
|
|
379
|
+
// Calculate relative position
|
|
380
|
+
if (this.screenDimensions) {
|
|
381
|
+
const relativeX = event.coordinates.x / this.screenDimensions.width;
|
|
382
|
+
const relativeY = event.coordinates.y / this.screenDimensions.height;
|
|
383
|
+
span.setAttribute('gesture.coordinates.relative_x', relativeX);
|
|
384
|
+
span.setAttribute('gesture.coordinates.relative_y', relativeY);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (event.target) {
|
|
389
|
+
span.setAttribute(
|
|
390
|
+
'gesture.target',
|
|
391
|
+
this._truncateText(event.target, 100)
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// Enrich with target info if provided
|
|
396
|
+
const info = event.targetInfo;
|
|
397
|
+
if (info) {
|
|
398
|
+
if (info.label) {
|
|
399
|
+
const truncatedLabel = this._truncateText(String(info.label), 100);
|
|
400
|
+
span.setAttribute('gesture.target.label', truncatedLabel);
|
|
401
|
+
}
|
|
402
|
+
if (info.role) {
|
|
403
|
+
span.setAttribute('gesture.target.role', String(info.role));
|
|
404
|
+
}
|
|
405
|
+
if (info.testId) {
|
|
406
|
+
span.setAttribute('gesture.target.test_id', String(info.testId));
|
|
407
|
+
}
|
|
408
|
+
if (info.text) {
|
|
409
|
+
const truncatedText = this._truncateText(String(info.text), 200);
|
|
410
|
+
span.setAttribute('gesture.target.text', truncatedText);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if (event.metadata) {
|
|
415
|
+
Object.entries(event.metadata).forEach(([key, value]) => {
|
|
416
|
+
span.setAttribute(`gesture.metadata.${key}`, String(value));
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
421
|
+
span.end();
|
|
422
|
+
logger.debug(
|
|
423
|
+
'GestureRecorder',
|
|
424
|
+
'OTEL span created and ended successfully'
|
|
425
|
+
);
|
|
426
|
+
} catch (error) {
|
|
427
|
+
logger.error(
|
|
428
|
+
'GestureRecorder',
|
|
429
|
+
'Failed to record OpenTelemetry span for native gesture',
|
|
430
|
+
error
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// Public methods for manual event recording (same as before)
|
|
436
|
+
recordTap(
|
|
437
|
+
x: number,
|
|
438
|
+
y: number,
|
|
439
|
+
target?: string,
|
|
440
|
+
pressure?: number,
|
|
441
|
+
timestamp?: number
|
|
442
|
+
): void {
|
|
443
|
+
const event: GestureEvent = {
|
|
444
|
+
type: 'tap',
|
|
445
|
+
timestamp: timestamp || Date.now(),
|
|
446
|
+
coordinates: { x, y },
|
|
447
|
+
target,
|
|
448
|
+
metadata: {
|
|
449
|
+
pressure: pressure || 1.0,
|
|
450
|
+
screenWidth: this.screenDimensions?.width,
|
|
451
|
+
screenHeight: this.screenDimensions?.height,
|
|
452
|
+
},
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
this._recordEvent(event);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
recordSwipe(
|
|
459
|
+
direction: string,
|
|
460
|
+
target?: string,
|
|
461
|
+
velocity?: number,
|
|
462
|
+
distance?: number
|
|
463
|
+
): void {
|
|
464
|
+
const event: GestureEvent = {
|
|
465
|
+
type: 'swipe',
|
|
466
|
+
timestamp: Date.now(),
|
|
467
|
+
target,
|
|
468
|
+
metadata: {
|
|
469
|
+
direction,
|
|
470
|
+
velocity: velocity || 0,
|
|
471
|
+
distance: distance || 0,
|
|
472
|
+
screenWidth: this.screenDimensions?.width,
|
|
473
|
+
screenHeight: this.screenDimensions?.height,
|
|
474
|
+
},
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
this._recordEvent(event);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
recordPinch(scale: number, target?: string, velocity?: number): void {
|
|
481
|
+
const event: GestureEvent = {
|
|
482
|
+
type: 'pinch',
|
|
483
|
+
timestamp: Date.now(),
|
|
484
|
+
target,
|
|
485
|
+
metadata: {
|
|
486
|
+
scale,
|
|
487
|
+
velocity: velocity || 0,
|
|
488
|
+
screenWidth: this.screenDimensions?.width,
|
|
489
|
+
screenHeight: this.screenDimensions?.height,
|
|
490
|
+
},
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
this._recordEvent(event);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
recordPan(
|
|
497
|
+
deltaX: number,
|
|
498
|
+
deltaY: number,
|
|
499
|
+
target?: string,
|
|
500
|
+
velocity?: number
|
|
501
|
+
): void {
|
|
502
|
+
const event: GestureEvent = {
|
|
503
|
+
type: 'pan',
|
|
504
|
+
timestamp: Date.now(),
|
|
505
|
+
target,
|
|
506
|
+
metadata: {
|
|
507
|
+
deltaX,
|
|
508
|
+
deltaY,
|
|
509
|
+
velocity: velocity || 0,
|
|
510
|
+
screenWidth: this.screenDimensions?.width,
|
|
511
|
+
screenHeight: this.screenDimensions?.height,
|
|
512
|
+
},
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
this._recordEvent(event);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
recordLongPress(duration: number, target?: string, pressure?: number): void {
|
|
519
|
+
const event: GestureEvent = {
|
|
520
|
+
type: 'longPress',
|
|
521
|
+
timestamp: Date.now(),
|
|
522
|
+
target,
|
|
523
|
+
metadata: {
|
|
524
|
+
duration,
|
|
525
|
+
pressure: pressure || 1.0,
|
|
526
|
+
screenWidth: this.screenDimensions?.width,
|
|
527
|
+
screenHeight: this.screenDimensions?.height,
|
|
528
|
+
},
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
this._recordEvent(event);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
recordDoubleTap(x: number, y: number, target?: string): void {
|
|
535
|
+
const event: GestureEvent = {
|
|
536
|
+
type: 'doubleTap',
|
|
537
|
+
timestamp: Date.now(),
|
|
538
|
+
coordinates: { x, y },
|
|
539
|
+
target,
|
|
540
|
+
metadata: {
|
|
541
|
+
screenWidth: this.screenDimensions?.width,
|
|
542
|
+
screenHeight: this.screenDimensions?.height,
|
|
543
|
+
},
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
this._recordEvent(event);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
recordRotate(rotation: number, target?: string, velocity?: number): void {
|
|
550
|
+
const event: GestureEvent = {
|
|
551
|
+
type: 'rotate',
|
|
552
|
+
timestamp: Date.now(),
|
|
553
|
+
target,
|
|
554
|
+
metadata: {
|
|
555
|
+
rotation,
|
|
556
|
+
velocity: velocity || 0,
|
|
557
|
+
screenWidth: this.screenDimensions?.width,
|
|
558
|
+
screenHeight: this.screenDimensions?.height,
|
|
559
|
+
},
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
this._recordEvent(event);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
recordFling(direction: string, velocity: number, target?: string): void {
|
|
566
|
+
const event: GestureEvent = {
|
|
567
|
+
type: 'fling',
|
|
568
|
+
timestamp: Date.now(),
|
|
569
|
+
target,
|
|
570
|
+
metadata: {
|
|
571
|
+
direction,
|
|
572
|
+
velocity,
|
|
573
|
+
screenWidth: this.screenDimensions?.width,
|
|
574
|
+
screenHeight: this.screenDimensions?.height,
|
|
575
|
+
},
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
this._recordEvent(event);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
recordMultiTouch(touchCount: number, target?: string): void {
|
|
582
|
+
const event: GestureEvent = {
|
|
583
|
+
type: 'multiTouch',
|
|
584
|
+
timestamp: Date.now(),
|
|
585
|
+
target,
|
|
586
|
+
metadata: {
|
|
587
|
+
touchCount,
|
|
588
|
+
screenWidth: this.screenDimensions?.width,
|
|
589
|
+
screenHeight: this.screenDimensions?.height,
|
|
590
|
+
},
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
this._recordEvent(event);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
recordScroll(
|
|
597
|
+
direction: string,
|
|
598
|
+
distance: number,
|
|
599
|
+
velocity: number,
|
|
600
|
+
target?: string
|
|
601
|
+
): void {
|
|
602
|
+
const event: GestureEvent = {
|
|
603
|
+
type: 'scroll',
|
|
604
|
+
timestamp: Date.now(),
|
|
605
|
+
target,
|
|
606
|
+
metadata: {
|
|
607
|
+
direction,
|
|
608
|
+
distance,
|
|
609
|
+
velocity,
|
|
610
|
+
screenWidth: this.screenDimensions?.width,
|
|
611
|
+
screenHeight: this.screenDimensions?.height,
|
|
612
|
+
},
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
this._recordEvent(event);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
recordZoom(scale: number, target?: string, velocity?: number): void {
|
|
619
|
+
const event: GestureEvent = {
|
|
620
|
+
type: 'zoom',
|
|
621
|
+
timestamp: Date.now(),
|
|
622
|
+
target,
|
|
623
|
+
metadata: {
|
|
624
|
+
scale,
|
|
625
|
+
velocity: velocity || 0,
|
|
626
|
+
screenWidth: this.screenDimensions?.width,
|
|
627
|
+
screenHeight: this.screenDimensions?.height,
|
|
628
|
+
},
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
this._recordEvent(event);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// Touch event methods (same as before)
|
|
635
|
+
recordTouchStart(
|
|
636
|
+
x: number,
|
|
637
|
+
y: number,
|
|
638
|
+
target?: string,
|
|
639
|
+
pressure?: number
|
|
640
|
+
): void {
|
|
641
|
+
// Throttle touch events to prevent spam
|
|
642
|
+
const now = Date.now();
|
|
643
|
+
if (now - this.lastTouchTime < this.touchThrottleMs) {
|
|
644
|
+
logger.debug(
|
|
645
|
+
'GestureRecorder',
|
|
646
|
+
`Touch start throttled (${now - this.lastTouchTime}ms < ${this.touchThrottleMs}ms)`
|
|
647
|
+
);
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
this.lastTouchTime = now;
|
|
651
|
+
|
|
652
|
+
logger.debug('GestureRecorder', 'Touch start recorded', {
|
|
653
|
+
x,
|
|
654
|
+
y,
|
|
655
|
+
target,
|
|
656
|
+
pressure,
|
|
657
|
+
});
|
|
658
|
+
this._createMouseInteractionEvent(x, y, MouseInteractions.TouchStart, now);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
recordTouchMove(
|
|
662
|
+
x: number,
|
|
663
|
+
y: number,
|
|
664
|
+
target?: string,
|
|
665
|
+
pressure?: number
|
|
666
|
+
): void {
|
|
667
|
+
// Throttle touch move events more aggressively
|
|
668
|
+
const now = Date.now();
|
|
669
|
+
if (now - this.lastTouchTime < this.touchThrottleMs * 2) {
|
|
670
|
+
// 200ms throttle for move events
|
|
671
|
+
logger.debug(
|
|
672
|
+
'GestureRecorder',
|
|
673
|
+
`Touch move throttled (${now - this.lastTouchTime}ms < ${this.touchThrottleMs * 2}ms)`
|
|
674
|
+
);
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
this.lastTouchTime = now;
|
|
678
|
+
|
|
679
|
+
logger.debug('GestureRecorder', 'Touch move recorded', {
|
|
680
|
+
x,
|
|
681
|
+
y,
|
|
682
|
+
target,
|
|
683
|
+
pressure,
|
|
684
|
+
});
|
|
685
|
+
this._createMouseMoveEvent(x, y, target);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
recordTouchEnd(
|
|
689
|
+
x: number,
|
|
690
|
+
y: number,
|
|
691
|
+
target?: string,
|
|
692
|
+
pressure?: number
|
|
693
|
+
): void {
|
|
694
|
+
const timestamp = Date.now();
|
|
695
|
+
|
|
696
|
+
logger.debug('GestureRecorder', 'Touch end recorded', {
|
|
697
|
+
x,
|
|
698
|
+
y,
|
|
699
|
+
target,
|
|
700
|
+
pressure,
|
|
701
|
+
timestamp,
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
this.recordTap(x, y, target, pressure, timestamp);
|
|
705
|
+
this._createMouseInteractionEvent(
|
|
706
|
+
x,
|
|
707
|
+
y,
|
|
708
|
+
MouseInteractions.TouchEnd,
|
|
709
|
+
timestamp
|
|
710
|
+
);
|
|
711
|
+
|
|
712
|
+
// Only force screen capture on touch end (not on every touch event)
|
|
713
|
+
this.screenRecorder?.forceCapture(timestamp);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
recordTouchCancel(x: number, y: number, _target?: string): void {
|
|
717
|
+
this._createMouseInteractionEvent(x, y, MouseInteractions.TouchCancel);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
setImageNodeId(nodeId: number): void {
|
|
721
|
+
this.imageNodeId = nodeId;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
private _recordEvent(event: GestureEvent): void {
|
|
725
|
+
if (!this.isRecording) return;
|
|
726
|
+
|
|
727
|
+
// Throttle gestures to avoid spam
|
|
728
|
+
const now = Date.now();
|
|
729
|
+
if (now - this.lastGestureTime < this.gestureThrottleMs) {
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
this.lastGestureTime = now;
|
|
733
|
+
|
|
734
|
+
this.events.push(event);
|
|
735
|
+
this._sendEvent(event);
|
|
736
|
+
this._recordOpenTelemetrySpan(event);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
private _createMouseInteractionEvent(
|
|
740
|
+
x: number,
|
|
741
|
+
y: number,
|
|
742
|
+
interactionType: MouseInteractions,
|
|
743
|
+
timestamp?: number
|
|
744
|
+
): void {
|
|
745
|
+
const incrementalSnapshotEvent: eventWithTime = {
|
|
746
|
+
type: EventType.IncrementalSnapshot,
|
|
747
|
+
data: {
|
|
748
|
+
source: IncrementalSource.MouseInteraction,
|
|
749
|
+
type: interactionType,
|
|
750
|
+
id: this.imageNodeId, // Reference to the image node
|
|
751
|
+
x: x, // Preserve decimal precision like web rrweb
|
|
752
|
+
y: y, // Preserve decimal precision like web rrweb
|
|
753
|
+
pointerType: 2, // 2 = Touch for React Native (0=Mouse, 1=Pen, 2=Touch)
|
|
754
|
+
},
|
|
755
|
+
timestamp: timestamp || Date.now(),
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
this.recordEvent(incrementalSnapshotEvent);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
private _createMouseMoveEvent(x: number, y: number, _target?: string): void {
|
|
762
|
+
const incrementalSnapshotEvent: eventWithTime = {
|
|
763
|
+
type: EventType.IncrementalSnapshot,
|
|
764
|
+
data: {
|
|
765
|
+
source: IncrementalSource.TouchMove, // Use MouseMove instead of MouseInteraction
|
|
766
|
+
positions: [
|
|
767
|
+
{
|
|
768
|
+
x: x, // Preserve decimal precision like web rrweb
|
|
769
|
+
y: y, // Preserve decimal precision like web rrweb
|
|
770
|
+
id: this.imageNodeId, // Reference to the image node
|
|
771
|
+
timeOffset: 0, // No time offset for single position
|
|
772
|
+
},
|
|
773
|
+
],
|
|
774
|
+
},
|
|
775
|
+
timestamp: Date.now(),
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
this.recordEvent(incrementalSnapshotEvent);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
recordEvent(event: any): void {
|
|
782
|
+
if (this.eventRecorder) {
|
|
783
|
+
this.eventRecorder.recordEvent(event);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// Get recorded events
|
|
788
|
+
getEvents(): GestureEvent[] {
|
|
789
|
+
return [...this.events];
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
// Clear events
|
|
793
|
+
clearEvents(): void {
|
|
794
|
+
this.events = [];
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// Get event statistics
|
|
798
|
+
getEventStats(): Record<string, number> {
|
|
799
|
+
const stats: Record<string, number> = {};
|
|
800
|
+
this.events.forEach((event) => {
|
|
801
|
+
stats[event.type] = (stats[event.type] || 0) + 1;
|
|
802
|
+
});
|
|
803
|
+
return stats;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
// Set gesture throttle
|
|
807
|
+
setGestureThrottle(throttleMs: number): void {
|
|
808
|
+
this.gestureThrottleMs = throttleMs;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
// Get recording status
|
|
812
|
+
isRecordingEnabled(): boolean {
|
|
813
|
+
return this.isRecording;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* Truncate text to prevent large span attributes
|
|
818
|
+
* @param text - Text to truncate
|
|
819
|
+
* @param maxLength - Maximum length (default: 100)
|
|
820
|
+
* @returns Truncated text with ellipsis if needed
|
|
821
|
+
*/
|
|
822
|
+
private _truncateText(text: string, maxLength: number = 100): string {
|
|
823
|
+
if (!text || text.length <= maxLength) {
|
|
824
|
+
return text;
|
|
825
|
+
}
|
|
826
|
+
return text.substring(0, maxLength - 3) + '...';
|
|
827
|
+
}
|
|
828
|
+
}
|