@multiplayer-app/session-recorder-react-native 1.3.36 → 2.0.17-alpha.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/package.json +13 -8
- package/src/NativeSessionRecorderModule.ts +4 -2
- package/src/NativeSessionRecorderModuleSpec.ts +4 -2
- package/src/NativeSessionRecorderNative.ts +1 -1
- package/src/index.ts +0 -1
- package/src/native/SessionRecorderNative.ts +22 -13
- package/src/otel/helpers.ts +5 -1
- package/src/otel/index.ts +1 -1
- package/src/otel/instrumentations/index.ts +22 -22
- package/src/patch/configs.ts +15 -10
- package/src/patch/fetch.ts +98 -89
- package/src/patch/index.ts +1 -1
- package/src/patch/xhr.ts +3 -4
- package/src/services/screenRecordingService.ts +7 -2
- package/src/services/storage.service.ts +4 -1
- package/src/session-recorder.ts +4 -0
- package/src/types/configs.ts +1 -2
- package/lib/module/NativeSessionRecorderModule.js +0 -5
- package/lib/module/NativeSessionRecorderModule.js.map +0 -1
- package/lib/module/NativeSessionRecorderModuleSpec.js +0 -5
- package/lib/module/NativeSessionRecorderModuleSpec.js.map +0 -1
- package/lib/module/NativeSessionRecorderNative.js +0 -5
- package/lib/module/NativeSessionRecorderNative.js.map +0 -1
- package/lib/module/components/ErrorBoundary.js +0 -32
- package/lib/module/components/ErrorBoundary.js.map +0 -1
- package/lib/module/components/ScreenRecorderView/ScreenRecorderView.js +0 -23
- package/lib/module/components/ScreenRecorderView/ScreenRecorderView.js.map +0 -1
- package/lib/module/components/ScreenRecorderView/index.js +0 -4
- package/lib/module/components/ScreenRecorderView/index.js.map +0 -1
- package/lib/module/components/SessionRecorderWidget/ErrorBanner.js +0 -64
- package/lib/module/components/SessionRecorderWidget/ErrorBanner.js.map +0 -1
- package/lib/module/components/SessionRecorderWidget/FinalPopover.js +0 -74
- package/lib/module/components/SessionRecorderWidget/FinalPopover.js.map +0 -1
- package/lib/module/components/SessionRecorderWidget/FloatingButton.js +0 -191
- package/lib/module/components/SessionRecorderWidget/FloatingButton.js.map +0 -1
- package/lib/module/components/SessionRecorderWidget/InitialPopover.js +0 -138
- package/lib/module/components/SessionRecorderWidget/InitialPopover.js.map +0 -1
- package/lib/module/components/SessionRecorderWidget/ModalContainer.js +0 -177
- package/lib/module/components/SessionRecorderWidget/ModalContainer.js.map +0 -1
- package/lib/module/components/SessionRecorderWidget/ModalHeader.js +0 -27
- package/lib/module/components/SessionRecorderWidget/ModalHeader.js.map +0 -1
- package/lib/module/components/SessionRecorderWidget/SessionRecorderWidget.js +0 -133
- package/lib/module/components/SessionRecorderWidget/SessionRecorderWidget.js.map +0 -1
- package/lib/module/components/SessionRecorderWidget/icons.js +0 -93
- package/lib/module/components/SessionRecorderWidget/icons.js.map +0 -1
- package/lib/module/components/SessionRecorderWidget/index.js +0 -5
- package/lib/module/components/SessionRecorderWidget/index.js.map +0 -1
- package/lib/module/components/SessionRecorderWidget/styles.js +0 -173
- package/lib/module/components/SessionRecorderWidget/styles.js.map +0 -1
- package/lib/module/components/index.js +0 -6
- package/lib/module/components/index.js.map +0 -1
- package/lib/module/config/constants.js +0 -47
- package/lib/module/config/constants.js.map +0 -1
- package/lib/module/config/defaults.js +0 -87
- package/lib/module/config/defaults.js.map +0 -1
- package/lib/module/config/index.js +0 -9
- package/lib/module/config/index.js.map +0 -1
- package/lib/module/config/masking.js +0 -35
- package/lib/module/config/masking.js.map +0 -1
- package/lib/module/config/session-recorder.js +0 -50
- package/lib/module/config/session-recorder.js.map +0 -1
- package/lib/module/config/validators.js +0 -28
- package/lib/module/config/validators.js.map +0 -1
- package/lib/module/config/widget.js +0 -35
- package/lib/module/config/widget.js.map +0 -1
- package/lib/module/context/SessionRecorderContext.js +0 -100
- package/lib/module/context/SessionRecorderContext.js.map +0 -1
- package/lib/module/context/SessionRecorderStore.js +0 -12
- package/lib/module/context/SessionRecorderStore.js.map +0 -1
- package/lib/module/context/createStore.js +0 -27
- package/lib/module/context/createStore.js.map +0 -1
- package/lib/module/context/useSessionRecorderStore.js +0 -45
- package/lib/module/context/useSessionRecorderStore.js.map +0 -1
- package/lib/module/context/useStoreSelector.js +0 -27
- package/lib/module/context/useStoreSelector.js.map +0 -1
- package/lib/module/index.js +0 -14
- package/lib/module/index.js.map +0 -1
- package/lib/module/native/SessionRecorderNative.js +0 -76
- package/lib/module/native/SessionRecorderNative.js.map +0 -1
- package/lib/module/native/index.js +0 -4
- package/lib/module/native/index.js.map +0 -1
- package/lib/module/otel/CrashBufferSpanProcessor.js +0 -42
- package/lib/module/otel/CrashBufferSpanProcessor.js.map +0 -1
- package/lib/module/otel/helpers.js +0 -218
- package/lib/module/otel/helpers.js.map +0 -1
- package/lib/module/otel/index.js +0 -202
- package/lib/module/otel/index.js.map +0 -1
- package/lib/module/otel/instrumentations/index.js +0 -122
- package/lib/module/otel/instrumentations/index.js.map +0 -1
- package/lib/module/package.json +0 -1
- package/lib/module/patch/configs.js +0 -18
- package/lib/module/patch/configs.js.map +0 -1
- package/lib/module/patch/fetch.js +0 -224
- package/lib/module/patch/fetch.js.map +0 -1
- package/lib/module/patch/index.js +0 -6
- package/lib/module/patch/index.js.map +0 -1
- package/lib/module/patch/xhr.js +0 -100
- package/lib/module/patch/xhr.js.map +0 -1
- package/lib/module/recorder/gestureRecorder.js +0 -641
- package/lib/module/recorder/gestureRecorder.js.map +0 -1
- package/lib/module/recorder/index.js +0 -176
- package/lib/module/recorder/index.js.map +0 -1
- package/lib/module/recorder/navigationRecorder.js +0 -238
- package/lib/module/recorder/navigationRecorder.js.map +0 -1
- package/lib/module/recorder/screenRecorder.js +0 -527
- package/lib/module/recorder/screenRecorder.js.map +0 -1
- package/lib/module/services/api.service.js +0 -166
- package/lib/module/services/api.service.js.map +0 -1
- package/lib/module/services/crashBuffer.service.js +0 -280
- package/lib/module/services/crashBuffer.service.js.map +0 -1
- package/lib/module/services/network.service.js +0 -178
- package/lib/module/services/network.service.js.map +0 -1
- package/lib/module/services/screenRecordingService.js +0 -107
- package/lib/module/services/screenRecordingService.js.map +0 -1
- package/lib/module/services/socket.service.js +0 -186
- package/lib/module/services/socket.service.js.map +0 -1
- package/lib/module/services/storage.service.js +0 -178
- package/lib/module/services/storage.service.js.map +0 -1
- package/lib/module/session-recorder.js +0 -750
- package/lib/module/session-recorder.js.map +0 -1
- package/lib/module/types/configs.js +0 -4
- package/lib/module/types/configs.js.map +0 -1
- package/lib/module/types/expo-constants.d.js +0 -2
- package/lib/module/types/expo-constants.d.js.map +0 -1
- package/lib/module/types/index.js +0 -10
- package/lib/module/types/index.js.map +0 -1
- package/lib/module/types/session-recorder.js +0 -68
- package/lib/module/types/session-recorder.js.map +0 -1
- package/lib/module/utils/app-metadata.js +0 -28
- package/lib/module/utils/app-metadata.js.map +0 -1
- package/lib/module/utils/constants.optional.expo.js +0 -6
- package/lib/module/utils/constants.optional.expo.js.map +0 -1
- package/lib/module/utils/constants.optional.js +0 -8
- package/lib/module/utils/constants.optional.js.map +0 -1
- package/lib/module/utils/index.js +0 -11
- package/lib/module/utils/index.js.map +0 -1
- package/lib/module/utils/logger.js +0 -185
- package/lib/module/utils/logger.js.map +0 -1
- package/lib/module/utils/platform.js +0 -340
- package/lib/module/utils/platform.js.map +0 -1
- package/lib/module/utils/request-utils.js +0 -58
- package/lib/module/utils/request-utils.js.map +0 -1
- package/lib/module/utils/rrweb-events.js +0 -276
- package/lib/module/utils/rrweb-events.js.map +0 -1
- package/lib/module/utils/session.js +0 -21
- package/lib/module/utils/session.js.map +0 -1
- package/lib/module/utils/shallowEqual.js +0 -17
- package/lib/module/utils/shallowEqual.js.map +0 -1
- package/lib/module/utils/time.js +0 -17
- package/lib/module/utils/time.js.map +0 -1
- package/lib/module/utils/type-utils.js +0 -69
- package/lib/module/utils/type-utils.js.map +0 -1
- package/lib/module/version.js +0 -4
- package/lib/module/version.js.map +0 -1
- package/lib/typescript/package.json +0 -1
- package/lib/typescript/src/NativeSessionRecorderModule.d.ts +0 -25
- package/lib/typescript/src/NativeSessionRecorderModule.d.ts.map +0 -1
- package/lib/typescript/src/NativeSessionRecorderModuleSpec.d.ts +0 -25
- package/lib/typescript/src/NativeSessionRecorderModuleSpec.d.ts.map +0 -1
- package/lib/typescript/src/NativeSessionRecorderNative.d.ts +0 -25
- package/lib/typescript/src/NativeSessionRecorderNative.d.ts.map +0 -1
- package/lib/typescript/src/components/ErrorBoundary.d.ts +0 -16
- package/lib/typescript/src/components/ErrorBoundary.d.ts.map +0 -1
- package/lib/typescript/src/components/ScreenRecorderView/ScreenRecorderView.d.ts +0 -6
- package/lib/typescript/src/components/ScreenRecorderView/ScreenRecorderView.d.ts.map +0 -1
- package/lib/typescript/src/components/ScreenRecorderView/index.d.ts +0 -2
- package/lib/typescript/src/components/ScreenRecorderView/index.d.ts.map +0 -1
- package/lib/typescript/src/components/SessionRecorderWidget/ErrorBanner.d.ts +0 -8
- package/lib/typescript/src/components/SessionRecorderWidget/ErrorBanner.d.ts.map +0 -1
- package/lib/typescript/src/components/SessionRecorderWidget/FinalPopover.d.ts +0 -13
- package/lib/typescript/src/components/SessionRecorderWidget/FinalPopover.d.ts.map +0 -1
- package/lib/typescript/src/components/SessionRecorderWidget/FloatingButton.d.ts +0 -9
- package/lib/typescript/src/components/SessionRecorderWidget/FloatingButton.d.ts.map +0 -1
- package/lib/typescript/src/components/SessionRecorderWidget/InitialPopover.d.ts +0 -17
- package/lib/typescript/src/components/SessionRecorderWidget/InitialPopover.d.ts.map +0 -1
- package/lib/typescript/src/components/SessionRecorderWidget/ModalContainer.d.ts +0 -9
- package/lib/typescript/src/components/SessionRecorderWidget/ModalContainer.d.ts.map +0 -1
- package/lib/typescript/src/components/SessionRecorderWidget/ModalHeader.d.ts +0 -7
- package/lib/typescript/src/components/SessionRecorderWidget/ModalHeader.d.ts.map +0 -1
- package/lib/typescript/src/components/SessionRecorderWidget/SessionRecorderWidget.d.ts +0 -6
- package/lib/typescript/src/components/SessionRecorderWidget/SessionRecorderWidget.d.ts.map +0 -1
- package/lib/typescript/src/components/SessionRecorderWidget/icons.d.ts +0 -12
- package/lib/typescript/src/components/SessionRecorderWidget/icons.d.ts.map +0 -1
- package/lib/typescript/src/components/SessionRecorderWidget/index.d.ts +0 -3
- package/lib/typescript/src/components/SessionRecorderWidget/index.d.ts.map +0 -1
- package/lib/typescript/src/components/SessionRecorderWidget/styles.d.ts +0 -166
- package/lib/typescript/src/components/SessionRecorderWidget/styles.d.ts.map +0 -1
- package/lib/typescript/src/components/index.d.ts +0 -4
- package/lib/typescript/src/components/index.d.ts.map +0 -1
- package/lib/typescript/src/config/constants.d.ts +0 -22
- package/lib/typescript/src/config/constants.d.ts.map +0 -1
- package/lib/typescript/src/config/defaults.d.ts +0 -5
- package/lib/typescript/src/config/defaults.d.ts.map +0 -1
- package/lib/typescript/src/config/index.d.ts +0 -6
- package/lib/typescript/src/config/index.d.ts.map +0 -1
- package/lib/typescript/src/config/masking.d.ts +0 -3
- package/lib/typescript/src/config/masking.d.ts.map +0 -1
- package/lib/typescript/src/config/session-recorder.d.ts +0 -3
- package/lib/typescript/src/config/session-recorder.d.ts.map +0 -1
- package/lib/typescript/src/config/validators.d.ts +0 -11
- package/lib/typescript/src/config/validators.d.ts.map +0 -1
- package/lib/typescript/src/config/widget.d.ts +0 -10
- package/lib/typescript/src/config/widget.d.ts.map +0 -1
- package/lib/typescript/src/context/SessionRecorderContext.d.ts +0 -22
- package/lib/typescript/src/context/SessionRecorderContext.d.ts.map +0 -1
- package/lib/typescript/src/context/SessionRecorderStore.d.ts +0 -13
- package/lib/typescript/src/context/SessionRecorderStore.d.ts.map +0 -1
- package/lib/typescript/src/context/createStore.d.ts +0 -9
- package/lib/typescript/src/context/createStore.d.ts.map +0 -1
- package/lib/typescript/src/context/useSessionRecorderStore.d.ts +0 -29
- package/lib/typescript/src/context/useSessionRecorderStore.d.ts.map +0 -1
- package/lib/typescript/src/context/useStoreSelector.d.ts +0 -5
- package/lib/typescript/src/context/useStoreSelector.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts +0 -9
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/lib/typescript/src/native/SessionRecorderNative.d.ts +0 -29
- package/lib/typescript/src/native/SessionRecorderNative.d.ts.map +0 -1
- package/lib/typescript/src/native/index.d.ts +0 -2
- package/lib/typescript/src/native/index.d.ts.map +0 -1
- package/lib/typescript/src/otel/CrashBufferSpanProcessor.d.ts +0 -17
- package/lib/typescript/src/otel/CrashBufferSpanProcessor.d.ts.map +0 -1
- package/lib/typescript/src/otel/helpers.d.ts +0 -46
- package/lib/typescript/src/otel/helpers.d.ts.map +0 -1
- package/lib/typescript/src/otel/index.d.ts +0 -33
- package/lib/typescript/src/otel/index.d.ts.map +0 -1
- package/lib/typescript/src/otel/instrumentations/index.d.ts +0 -5
- package/lib/typescript/src/otel/instrumentations/index.d.ts.map +0 -1
- package/lib/typescript/src/patch/configs.d.ts +0 -9
- package/lib/typescript/src/patch/configs.d.ts.map +0 -1
- package/lib/typescript/src/patch/fetch.d.ts +0 -2
- package/lib/typescript/src/patch/fetch.d.ts.map +0 -1
- package/lib/typescript/src/patch/index.d.ts +0 -4
- package/lib/typescript/src/patch/index.d.ts.map +0 -1
- package/lib/typescript/src/patch/xhr.d.ts +0 -2
- package/lib/typescript/src/patch/xhr.d.ts.map +0 -1
- package/lib/typescript/src/recorder/gestureRecorder.d.ts +0 -66
- package/lib/typescript/src/recorder/gestureRecorder.d.ts.map +0 -1
- package/lib/typescript/src/recorder/index.d.ts +0 -79
- package/lib/typescript/src/recorder/index.d.ts.map +0 -1
- package/lib/typescript/src/recorder/navigationRecorder.d.ts +0 -29
- package/lib/typescript/src/recorder/navigationRecorder.d.ts.map +0 -1
- package/lib/typescript/src/recorder/screenRecorder.d.ts +0 -127
- package/lib/typescript/src/recorder/screenRecorder.d.ts.map +0 -1
- package/lib/typescript/src/services/api.service.d.ts +0 -116
- package/lib/typescript/src/services/api.service.d.ts.map +0 -1
- package/lib/typescript/src/services/crashBuffer.service.d.ts +0 -27
- package/lib/typescript/src/services/crashBuffer.service.d.ts.map +0 -1
- package/lib/typescript/src/services/network.service.d.ts +0 -47
- package/lib/typescript/src/services/network.service.d.ts.map +0 -1
- package/lib/typescript/src/services/screenRecordingService.d.ts +0 -48
- package/lib/typescript/src/services/screenRecordingService.d.ts.map +0 -1
- package/lib/typescript/src/services/socket.service.d.ts +0 -44
- package/lib/typescript/src/services/socket.service.d.ts.map +0 -1
- package/lib/typescript/src/services/storage.service.d.ts +0 -47
- package/lib/typescript/src/services/storage.service.d.ts.map +0 -1
- package/lib/typescript/src/session-recorder.d.ts +0 -191
- package/lib/typescript/src/session-recorder.d.ts.map +0 -1
- package/lib/typescript/src/types/configs.d.ts +0 -92
- package/lib/typescript/src/types/configs.d.ts.map +0 -1
- package/lib/typescript/src/types/index.d.ts +0 -21
- package/lib/typescript/src/types/index.d.ts.map +0 -1
- package/lib/typescript/src/types/session-recorder.d.ts +0 -367
- package/lib/typescript/src/types/session-recorder.d.ts.map +0 -1
- package/lib/typescript/src/utils/app-metadata.d.ts +0 -17
- package/lib/typescript/src/utils/app-metadata.d.ts.map +0 -1
- package/lib/typescript/src/utils/constants.optional.d.ts +0 -22
- package/lib/typescript/src/utils/constants.optional.d.ts.map +0 -1
- package/lib/typescript/src/utils/constants.optional.expo.d.ts +0 -4
- package/lib/typescript/src/utils/constants.optional.expo.d.ts.map +0 -1
- package/lib/typescript/src/utils/index.d.ts +0 -8
- package/lib/typescript/src/utils/index.d.ts.map +0 -1
- package/lib/typescript/src/utils/logger.d.ts +0 -108
- package/lib/typescript/src/utils/logger.d.ts.map +0 -1
- package/lib/typescript/src/utils/platform.d.ts +0 -58
- package/lib/typescript/src/utils/platform.d.ts.map +0 -1
- package/lib/typescript/src/utils/request-utils.d.ts +0 -22
- package/lib/typescript/src/utils/request-utils.d.ts.map +0 -1
- package/lib/typescript/src/utils/rrweb-events.d.ts +0 -67
- package/lib/typescript/src/utils/rrweb-events.d.ts.map +0 -1
- package/lib/typescript/src/utils/session.d.ts +0 -7
- package/lib/typescript/src/utils/session.d.ts.map +0 -1
- package/lib/typescript/src/utils/shallowEqual.d.ts +0 -2
- package/lib/typescript/src/utils/shallowEqual.d.ts.map +0 -1
- package/lib/typescript/src/utils/time.d.ts +0 -5
- package/lib/typescript/src/utils/time.d.ts.map +0 -1
- package/lib/typescript/src/utils/type-utils.d.ts +0 -17
- package/lib/typescript/src/utils/type-utils.d.ts.map +0 -1
- package/lib/typescript/src/version.d.ts +0 -2
- package/lib/typescript/src/version.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplayer-app/session-recorder-react-native",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.17-alpha.10",
|
|
4
4
|
"description": "Multiplayer Fullstack Session Recorder for React Native",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Multiplayer Software, Inc.",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"scripts": {
|
|
57
57
|
"test": "jest",
|
|
58
58
|
"typecheck": "tsc",
|
|
59
|
-
"lint": "eslint
|
|
59
|
+
"lint": "eslint 'src/**/*.{ts,tsx}' --config eslint.config.mjs",
|
|
60
60
|
"build": "bob build",
|
|
61
61
|
"prepublishOnly": "npm run build",
|
|
62
62
|
"release": "release-it --only-version"
|
|
@@ -78,6 +78,12 @@
|
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"registry": "https://registry.npmjs.org/"
|
|
80
80
|
},
|
|
81
|
+
"resolutions": {
|
|
82
|
+
"eslint-plugin-jest": "^28.0.0",
|
|
83
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
84
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
85
|
+
"@typescript-eslint/utils": "^8.0.0"
|
|
86
|
+
},
|
|
81
87
|
"devDependencies": {
|
|
82
88
|
"@commitlint/config-conventional": "^19.8.1",
|
|
83
89
|
"@eslint/compat": "^1.3.2",
|
|
@@ -90,25 +96,24 @@
|
|
|
90
96
|
"@react-native/eslint-config": "^0.81.1",
|
|
91
97
|
"@release-it/conventional-changelog": "^10.0.1",
|
|
92
98
|
"@types/jest": "^29.5.14",
|
|
93
|
-
"@types/react": "^19.
|
|
99
|
+
"@types/react": "^19.2.0",
|
|
94
100
|
"commitlint": "^19.8.1",
|
|
95
101
|
"del-cli": "^6.0.0",
|
|
96
|
-
"eslint": "
|
|
102
|
+
"eslint": "10.1.0",
|
|
97
103
|
"eslint-config-prettier": "^10.1.8",
|
|
98
104
|
"eslint-plugin-prettier": "^5.5.4",
|
|
99
105
|
"jest": "^29.7.0",
|
|
100
|
-
"prettier": "
|
|
101
|
-
"react": "19.
|
|
106
|
+
"prettier": "3.8.1",
|
|
107
|
+
"react": "19.2.4",
|
|
102
108
|
"react-native": "0.81.1",
|
|
103
109
|
"react-native-builder-bob": "^0.40.13",
|
|
104
110
|
"react-native-safe-area-context": "^5.6.1",
|
|
105
111
|
"react-native-svg": "^15.14.0",
|
|
106
112
|
"release-it": "^19.0.4",
|
|
107
|
-
"turbo": "^2.5.6",
|
|
108
113
|
"typescript": "^5.9.2"
|
|
109
114
|
},
|
|
110
115
|
"dependencies": {
|
|
111
|
-
"@multiplayer-app/session-recorder-common": "
|
|
116
|
+
"@multiplayer-app/session-recorder-common": "2.0.17-alpha.10",
|
|
112
117
|
"@opentelemetry/core": "2.0.1",
|
|
113
118
|
"@opentelemetry/exporter-trace-otlp-http": "0.203.0",
|
|
114
119
|
"@opentelemetry/instrumentation": "0.203.0",
|
|
@@ -24,10 +24,12 @@ export interface Spec extends TurboModule {
|
|
|
24
24
|
x: number,
|
|
25
25
|
y: number,
|
|
26
26
|
target?: string,
|
|
27
|
-
metadata?:
|
|
27
|
+
metadata?: object
|
|
28
28
|
): void;
|
|
29
29
|
addListener(eventName: string): void;
|
|
30
30
|
removeListeners(count: number): void;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export default TurboModuleRegistry.getEnforcing<Spec>(
|
|
33
|
+
export default TurboModuleRegistry.getEnforcing<Spec>(
|
|
34
|
+
'SessionRecorderNative'
|
|
35
|
+
) as Spec;
|
|
@@ -24,10 +24,12 @@ export interface Spec extends TurboModule {
|
|
|
24
24
|
x: number,
|
|
25
25
|
y: number,
|
|
26
26
|
target?: string,
|
|
27
|
-
metadata?:
|
|
27
|
+
metadata?: object
|
|
28
28
|
): void;
|
|
29
29
|
addListener(eventName: string): void;
|
|
30
30
|
removeListeners(count: number): void;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export default TurboModuleRegistry.getEnforcing<Spec>(
|
|
33
|
+
export default TurboModuleRegistry.getEnforcing<Spec>(
|
|
34
|
+
'SessionRecorderNative'
|
|
35
|
+
) as Spec;
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Platform, NativeEventEmitter } from 'react-native';
|
|
2
|
-
import SessionRecorderNative, {
|
|
3
|
-
|
|
2
|
+
import SessionRecorderNative, {
|
|
3
|
+
type MaskingOptions,
|
|
4
|
+
type Spec,
|
|
5
|
+
} from '../NativeSessionRecorderModule';
|
|
4
6
|
|
|
5
7
|
// Check if we're on web platform
|
|
6
8
|
const isWeb = Platform.OS === 'web';
|
|
@@ -8,7 +10,6 @@ const isWeb = Platform.OS === 'web';
|
|
|
8
10
|
// Get the Turbo Module
|
|
9
11
|
let eventEmitter = new NativeEventEmitter(SessionRecorderNative as any);
|
|
10
12
|
|
|
11
|
-
|
|
12
13
|
// Validate that the native module is available
|
|
13
14
|
if (!SessionRecorderNative && !isWeb) {
|
|
14
15
|
console.warn(
|
|
@@ -57,7 +58,13 @@ const SafeSessionRecorderNative: Spec = {
|
|
|
57
58
|
return SessionRecorderNative.isGestureRecordingActive();
|
|
58
59
|
},
|
|
59
60
|
|
|
60
|
-
recordGesture(
|
|
61
|
+
recordGesture(
|
|
62
|
+
gestureType: string,
|
|
63
|
+
x: number,
|
|
64
|
+
y: number,
|
|
65
|
+
target?: string,
|
|
66
|
+
metadata?: any
|
|
67
|
+
): void {
|
|
61
68
|
if (isWeb || !SessionRecorderNative) {
|
|
62
69
|
throw new Error('SessionRecorderNative is not available on web platform');
|
|
63
70
|
}
|
|
@@ -75,13 +82,13 @@ const SafeSessionRecorderNative: Spec = {
|
|
|
75
82
|
|
|
76
83
|
export interface NativeGestureEvent {
|
|
77
84
|
type:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
| 'tap'
|
|
86
|
+
| 'pan_start'
|
|
87
|
+
| 'pan_move'
|
|
88
|
+
| 'pan_end'
|
|
89
|
+
| 'long_press'
|
|
90
|
+
| 'pinch'
|
|
91
|
+
| 'swipe';
|
|
85
92
|
timestamp: number;
|
|
86
93
|
x: number;
|
|
87
94
|
y: number;
|
|
@@ -103,7 +110,9 @@ export interface NativeGestureEvent {
|
|
|
103
110
|
}
|
|
104
111
|
|
|
105
112
|
// Helper function to set gesture callback using event emitter pattern
|
|
106
|
-
export function setGestureCallback(
|
|
113
|
+
export function setGestureCallback(
|
|
114
|
+
callback: (event: NativeGestureEvent) => void
|
|
115
|
+
): void {
|
|
107
116
|
if (isWeb || !SessionRecorderNative) {
|
|
108
117
|
throw new Error('SessionRecorderNative is not available on web platform');
|
|
109
118
|
}
|
|
@@ -115,4 +124,4 @@ export default SafeSessionRecorderNative;
|
|
|
115
124
|
|
|
116
125
|
// Export event emitter for gesture events to maintain previous API
|
|
117
126
|
export const gestureEventEmitter = eventEmitter;
|
|
118
|
-
export type { MaskingOptions };
|
|
127
|
+
export type { MaskingOptions };
|
package/src/otel/helpers.ts
CHANGED
|
@@ -263,7 +263,11 @@ export async function extractResponseBody(
|
|
|
263
263
|
} catch (error) {
|
|
264
264
|
// If cloning fails (body already consumed), return null
|
|
265
265
|
|
|
266
|
-
logger.warn(
|
|
266
|
+
logger.warn(
|
|
267
|
+
'MULTIPLAYER_SESSION_RECORDER',
|
|
268
|
+
'Failed to extract response body',
|
|
269
|
+
error
|
|
270
|
+
);
|
|
267
271
|
return null;
|
|
268
272
|
}
|
|
269
273
|
}
|
package/src/otel/index.ts
CHANGED
|
@@ -202,7 +202,7 @@ export class TracerReactNativeSDK {
|
|
|
202
202
|
if (this.globalErrorHandlerRegistered) return;
|
|
203
203
|
|
|
204
204
|
// React Native global error handler
|
|
205
|
-
|
|
205
|
+
|
|
206
206
|
const ErrorUtilsRef: any = (global as any).ErrorUtils;
|
|
207
207
|
if (ErrorUtilsRef && typeof ErrorUtilsRef.setGlobalHandler === 'function') {
|
|
208
208
|
const previous = ErrorUtilsRef.getGlobalHandler?.();
|
|
@@ -32,29 +32,29 @@ export function getInstrumentations(config: TracerReactNativeConfig) {
|
|
|
32
32
|
|
|
33
33
|
// Try to get data from our fetch wrapper first
|
|
34
34
|
// @ts-ignore
|
|
35
|
-
const networkRequest = response?.networkRequest
|
|
35
|
+
const networkRequest = response?.networkRequest;
|
|
36
36
|
|
|
37
|
-
let requestBody: any = null
|
|
38
|
-
let responseBody: string | null = null
|
|
39
|
-
let requestHeaders: Record<string, string> = {}
|
|
40
|
-
let responseHeaders: Record<string, string> = {}
|
|
37
|
+
let requestBody: any = null;
|
|
38
|
+
let responseBody: string | null = null;
|
|
39
|
+
let requestHeaders: Record<string, string> = {};
|
|
40
|
+
let responseHeaders: Record<string, string> = {};
|
|
41
41
|
|
|
42
42
|
if (networkRequest) {
|
|
43
43
|
// Use data captured by our fetch wrapper
|
|
44
|
-
requestBody = networkRequest.requestBody
|
|
45
|
-
responseBody = networkRequest.responseBody
|
|
46
|
-
requestHeaders = networkRequest.requestHeaders || {}
|
|
47
|
-
responseHeaders = networkRequest.responseHeaders || {}
|
|
44
|
+
requestBody = networkRequest.requestBody;
|
|
45
|
+
responseBody = networkRequest.responseBody;
|
|
46
|
+
requestHeaders = networkRequest.requestHeaders || {};
|
|
47
|
+
responseHeaders = networkRequest.responseHeaders || {};
|
|
48
48
|
} else {
|
|
49
49
|
// Fallback to original OpenTelemetry approach
|
|
50
|
-
requestBody = request.body
|
|
51
|
-
requestHeaders = headersToObject(request.headers)
|
|
50
|
+
requestBody = request.body;
|
|
51
|
+
requestHeaders = headersToObject(request.headers);
|
|
52
52
|
responseHeaders = headersToObject(
|
|
53
53
|
response instanceof Response ? response.headers : undefined
|
|
54
|
-
)
|
|
54
|
+
);
|
|
55
55
|
|
|
56
56
|
if (response instanceof Response && response.body) {
|
|
57
|
-
responseBody = await extractResponseBody(response)
|
|
57
|
+
responseBody = await extractResponseBody(response);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -94,17 +94,17 @@ export function getInstrumentations(config: TracerReactNativeConfig) {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
// @ts-ignore
|
|
97
|
-
const networkRequest = xhr.networkRequest
|
|
98
|
-
let requestBody: any = null
|
|
99
|
-
let responseBody: string | null = null
|
|
100
|
-
let requestHeaders: Record<string, string> = {}
|
|
101
|
-
let responseHeaders: Record<string, string> = {}
|
|
97
|
+
const networkRequest = xhr.networkRequest;
|
|
98
|
+
let requestBody: any = null;
|
|
99
|
+
let responseBody: string | null = null;
|
|
100
|
+
let requestHeaders: Record<string, string> = {};
|
|
101
|
+
let responseHeaders: Record<string, string> = {};
|
|
102
102
|
|
|
103
103
|
if (networkRequest) {
|
|
104
|
-
requestBody = networkRequest.requestBody
|
|
105
|
-
responseBody = networkRequest.responseBody
|
|
106
|
-
requestHeaders = networkRequest.requestHeaders || {}
|
|
107
|
-
responseHeaders = networkRequest.responseHeaders || {}
|
|
104
|
+
requestBody = networkRequest.requestBody;
|
|
105
|
+
responseBody = networkRequest.responseBody;
|
|
106
|
+
requestHeaders = networkRequest.requestHeaders || {};
|
|
107
|
+
responseHeaders = networkRequest.responseHeaders || {};
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
const payload = {
|
package/src/patch/configs.ts
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import { DEFAULT_MAX_HTTP_CAPTURING_PAYLOAD_SIZE } from '../config'
|
|
1
|
+
import { DEFAULT_MAX_HTTP_CAPTURING_PAYLOAD_SIZE } from '../config';
|
|
2
2
|
|
|
3
3
|
export const configs = {
|
|
4
4
|
recordRequestHeaders: true,
|
|
5
5
|
recordResponseHeaders: true,
|
|
6
6
|
shouldRecordBody: true,
|
|
7
7
|
maxCapturingHttpPayloadSize: DEFAULT_MAX_HTTP_CAPTURING_PAYLOAD_SIZE,
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
|
|
10
|
-
export const setMaxCapturingHttpPayloadSize = (
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
export const setMaxCapturingHttpPayloadSize = (
|
|
11
|
+
_maxCapturingHttpPayloadSize: number
|
|
12
|
+
) => {
|
|
13
|
+
configs.maxCapturingHttpPayloadSize = _maxCapturingHttpPayloadSize;
|
|
14
|
+
};
|
|
13
15
|
|
|
14
|
-
export const setShouldRecordHttpData = (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
export const setShouldRecordHttpData = (
|
|
17
|
+
shouldRecordBody: boolean,
|
|
18
|
+
shouldRecordHeaders: boolean
|
|
19
|
+
) => {
|
|
20
|
+
configs.recordRequestHeaders = shouldRecordHeaders;
|
|
21
|
+
configs.recordResponseHeaders = shouldRecordHeaders;
|
|
22
|
+
configs.shouldRecordBody = shouldRecordBody;
|
|
23
|
+
};
|
package/src/patch/fetch.ts
CHANGED
|
@@ -1,38 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
isObject,
|
|
5
|
-
isString,
|
|
6
|
-
} from '../utils/type-utils'
|
|
7
|
-
import { formDataToQuery } from '../utils/request-utils'
|
|
8
|
-
import { configs } from './configs'
|
|
1
|
+
import { isFormData, isNullish, isObject, isString } from '../utils/type-utils';
|
|
2
|
+
import { formDataToQuery } from '../utils/request-utils';
|
|
3
|
+
import { configs } from './configs';
|
|
9
4
|
|
|
10
5
|
function _tryReadFetchBody({
|
|
11
6
|
body,
|
|
12
7
|
}: {
|
|
13
|
-
body: any | null | undefined
|
|
8
|
+
body: any | null | undefined;
|
|
14
9
|
}): string | null {
|
|
15
10
|
if (isNullish(body)) {
|
|
16
|
-
return null
|
|
11
|
+
return null;
|
|
17
12
|
}
|
|
18
13
|
|
|
19
14
|
if (isString(body)) {
|
|
20
|
-
return body
|
|
15
|
+
return body;
|
|
21
16
|
}
|
|
22
17
|
|
|
23
18
|
if (isFormData(body)) {
|
|
24
|
-
return formDataToQuery(body)
|
|
19
|
+
return formDataToQuery(body);
|
|
25
20
|
}
|
|
26
21
|
|
|
27
22
|
if (isObject(body)) {
|
|
28
23
|
try {
|
|
29
|
-
return JSON.stringify(body)
|
|
24
|
+
return JSON.stringify(body);
|
|
30
25
|
} catch {
|
|
31
|
-
return '[Fetch] Failed to stringify request object'
|
|
26
|
+
return '[Fetch] Failed to stringify request object';
|
|
32
27
|
}
|
|
33
28
|
}
|
|
34
29
|
|
|
35
|
-
return `[Fetch] Cannot read body of type ${Object.prototype.toString.call(body)}
|
|
30
|
+
return `[Fetch] Cannot read body of type ${Object.prototype.toString.call(body)}`;
|
|
36
31
|
}
|
|
37
32
|
|
|
38
33
|
/**
|
|
@@ -42,221 +37,235 @@ function _tryReadFetchBody({
|
|
|
42
37
|
* - Corrupt the stream for the actual consumer
|
|
43
38
|
*/
|
|
44
39
|
function _isStreamingResponse(response: Response): boolean {
|
|
45
|
-
const contentType = response.headers.get('content-type')?.toLowerCase() ?? ''
|
|
40
|
+
const contentType = response.headers.get('content-type')?.toLowerCase() ?? '';
|
|
46
41
|
|
|
47
42
|
// SSE - Server-Sent Events (infinite stream)
|
|
48
43
|
if (contentType.includes('text/event-stream')) {
|
|
49
|
-
return true
|
|
44
|
+
return true;
|
|
50
45
|
}
|
|
51
46
|
|
|
52
47
|
// Binary streams that are typically long-running
|
|
53
48
|
if (contentType.includes('application/octet-stream')) {
|
|
54
|
-
return true
|
|
49
|
+
return true;
|
|
55
50
|
}
|
|
56
51
|
|
|
57
52
|
// NDJSON streaming (newline-delimited JSON, common in streaming APIs)
|
|
58
|
-
if (
|
|
59
|
-
|
|
53
|
+
if (
|
|
54
|
+
contentType.includes('application/x-ndjson') ||
|
|
55
|
+
contentType.includes('application/ndjson')
|
|
56
|
+
) {
|
|
57
|
+
return true;
|
|
60
58
|
}
|
|
61
59
|
|
|
62
60
|
// gRPC-web streaming
|
|
63
61
|
if (contentType.includes('application/grpc')) {
|
|
64
|
-
return true
|
|
62
|
+
return true;
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
// Check for chunked transfer encoding (often indicates streaming)
|
|
68
|
-
const transferEncoding = response.headers
|
|
66
|
+
const transferEncoding = response.headers
|
|
67
|
+
.get('transfer-encoding')
|
|
68
|
+
?.toLowerCase();
|
|
69
69
|
if (transferEncoding?.includes('chunked')) {
|
|
70
70
|
// Chunked alone isn't definitive, but combined with no content-length = streaming
|
|
71
|
-
const contentLength = response.headers.get('content-length')
|
|
71
|
+
const contentLength = response.headers.get('content-length');
|
|
72
72
|
if (!contentLength) {
|
|
73
|
-
return true
|
|
73
|
+
return true;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
return false
|
|
77
|
+
return false;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* Safely reads response body for non-streaming responses.
|
|
82
82
|
* Returns null for streaming responses to avoid blocking/corruption.
|
|
83
83
|
*/
|
|
84
|
-
async function _tryReadResponseBody(
|
|
84
|
+
async function _tryReadResponseBody(
|
|
85
|
+
response: Response
|
|
86
|
+
): Promise<string | null> {
|
|
85
87
|
// CRITICAL: Never attempt to read streaming response bodies
|
|
86
88
|
if (_isStreamingResponse(response)) {
|
|
87
|
-
return null
|
|
89
|
+
return null;
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
try {
|
|
91
93
|
// Clone the response to avoid consuming the original stream.
|
|
92
|
-
const clonedResponse = response.clone()
|
|
93
|
-
const contentType =
|
|
94
|
+
const clonedResponse = response.clone();
|
|
95
|
+
const contentType =
|
|
96
|
+
response.headers.get('content-type')?.toLowerCase() ?? '';
|
|
94
97
|
|
|
95
98
|
// Check content-length to avoid reading massive responses
|
|
96
|
-
const contentLength = response.headers.get('content-length')
|
|
99
|
+
const contentLength = response.headers.get('content-length');
|
|
97
100
|
if (contentLength) {
|
|
98
|
-
const length = parseInt(contentLength, 10)
|
|
101
|
+
const length = parseInt(contentLength, 10);
|
|
99
102
|
if (!isNaN(length) && length > configs.maxCapturingHttpPayloadSize) {
|
|
100
|
-
return `[Fetch] Response too large (${length} bytes)
|
|
103
|
+
return `[Fetch] Response too large (${length} bytes)`;
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
if (contentType.includes('application/json')) {
|
|
105
|
-
const json = await clonedResponse.json()
|
|
106
|
-
return JSON.stringify(json)
|
|
108
|
+
const json = await clonedResponse.json();
|
|
109
|
+
return JSON.stringify(json);
|
|
107
110
|
}
|
|
108
111
|
|
|
109
112
|
if (contentType.includes('text/')) {
|
|
110
|
-
return await clonedResponse.text()
|
|
113
|
+
return await clonedResponse.text();
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
// For unknown types, attempt text read
|
|
114
117
|
try {
|
|
115
|
-
return await clonedResponse.text()
|
|
118
|
+
return await clonedResponse.text();
|
|
116
119
|
} catch {
|
|
117
120
|
try {
|
|
118
|
-
const arrayBuffer = await clonedResponse.arrayBuffer()
|
|
119
|
-
return `[Fetch] Binary data (${arrayBuffer.byteLength} bytes)
|
|
121
|
+
const arrayBuffer = await clonedResponse.arrayBuffer();
|
|
122
|
+
return `[Fetch] Binary data (${arrayBuffer.byteLength} bytes)`;
|
|
120
123
|
} catch {
|
|
121
|
-
return '[Fetch] Unable to read response body'
|
|
124
|
+
return '[Fetch] Unable to read response body';
|
|
122
125
|
}
|
|
123
126
|
}
|
|
124
127
|
} catch (error) {
|
|
125
|
-
return `[Fetch] Error reading response body: ${error instanceof Error ? error.message : 'Unknown error'}
|
|
128
|
+
return `[Fetch] Error reading response body: ${error instanceof Error ? error.message : 'Unknown error'}`;
|
|
126
129
|
}
|
|
127
130
|
}
|
|
128
131
|
|
|
129
132
|
function _headersToObject(headers: Headers): Record<string, string> {
|
|
130
|
-
const result: Record<string, string> = {}
|
|
133
|
+
const result: Record<string, string> = {};
|
|
131
134
|
headers.forEach((value, key) => {
|
|
132
|
-
result[key] = value
|
|
133
|
-
})
|
|
134
|
-
return result
|
|
135
|
+
result[key] = value;
|
|
136
|
+
});
|
|
137
|
+
return result;
|
|
135
138
|
}
|
|
136
139
|
|
|
137
140
|
// Convert HeadersInit to a plain object without needing to construct a Request
|
|
138
141
|
function _headersInitToObject(headersInit?: any): Record<string, string> {
|
|
139
|
-
if (!headersInit) return {}
|
|
142
|
+
if (!headersInit) return {};
|
|
140
143
|
|
|
141
144
|
// Headers instance
|
|
142
145
|
if (typeof Headers !== 'undefined' && headersInit instanceof Headers) {
|
|
143
|
-
return _headersToObject(headersInit)
|
|
146
|
+
return _headersToObject(headersInit);
|
|
144
147
|
}
|
|
145
148
|
|
|
146
|
-
const result: Record<string, string> = {}
|
|
149
|
+
const result: Record<string, string> = {};
|
|
147
150
|
|
|
148
151
|
// Array of tuples
|
|
149
152
|
if (Array.isArray(headersInit)) {
|
|
150
153
|
for (const [key, value] of headersInit) {
|
|
151
|
-
result[String(key).toLowerCase()] = String(value)
|
|
154
|
+
result[String(key).toLowerCase()] = String(value);
|
|
152
155
|
}
|
|
153
|
-
return result
|
|
156
|
+
return result;
|
|
154
157
|
}
|
|
155
158
|
|
|
156
159
|
// Record<string, string>
|
|
157
|
-
for (const [key, value] of Object.entries(
|
|
158
|
-
|
|
160
|
+
for (const [key, value] of Object.entries(
|
|
161
|
+
headersInit as Record<string, string>
|
|
162
|
+
)) {
|
|
163
|
+
result[String(key).toLowerCase()] = String(value);
|
|
159
164
|
}
|
|
160
165
|
|
|
161
|
-
return result
|
|
166
|
+
return result;
|
|
162
167
|
}
|
|
163
168
|
|
|
164
169
|
// Only patch fetch if available and safe to do so
|
|
165
170
|
if (typeof fetch !== 'undefined' && typeof global !== 'undefined') {
|
|
166
171
|
// Store original fetch
|
|
167
|
-
const originalFetch = global.fetch
|
|
172
|
+
const originalFetch = global.fetch;
|
|
168
173
|
|
|
169
174
|
// Override fetch with safer implementation
|
|
170
|
-
global.fetch = async function (
|
|
171
|
-
input: any,
|
|
172
|
-
init?: any
|
|
173
|
-
): Promise<Response> {
|
|
175
|
+
global.fetch = async function (input: any, init?: any): Promise<Response> {
|
|
174
176
|
const networkRequest: {
|
|
175
|
-
requestHeaders?: Record<string, string
|
|
176
|
-
requestBody?: string
|
|
177
|
-
responseHeaders?: Record<string, string
|
|
178
|
-
responseBody?: string
|
|
179
|
-
} = {}
|
|
177
|
+
requestHeaders?: Record<string, string>;
|
|
178
|
+
requestBody?: string;
|
|
179
|
+
responseHeaders?: Record<string, string>;
|
|
180
|
+
responseBody?: string;
|
|
181
|
+
} = {};
|
|
180
182
|
|
|
181
183
|
// Capture request data
|
|
182
|
-
const inputIsRequest =
|
|
184
|
+
const inputIsRequest =
|
|
185
|
+
typeof Request !== 'undefined' && input instanceof Request;
|
|
183
186
|
|
|
184
187
|
if (configs.recordRequestHeaders) {
|
|
185
188
|
if (inputIsRequest) {
|
|
186
|
-
networkRequest.requestHeaders = _headersToObject(
|
|
189
|
+
networkRequest.requestHeaders = _headersToObject(
|
|
190
|
+
(input as Request).headers
|
|
191
|
+
);
|
|
187
192
|
} else {
|
|
188
|
-
networkRequest.requestHeaders = _headersInitToObject(init?.headers)
|
|
193
|
+
networkRequest.requestHeaders = _headersInitToObject(init?.headers);
|
|
189
194
|
}
|
|
190
195
|
}
|
|
191
196
|
|
|
192
197
|
if (configs.shouldRecordBody) {
|
|
193
198
|
// Only attempt to read the body from init (safe); avoid constructing/cloning Requests
|
|
194
199
|
// If the caller passed a Request as input, we do not attempt to read its body here
|
|
195
|
-
const candidateBody: any | null | undefined = init?.body
|
|
200
|
+
const candidateBody: any | null | undefined = init?.body;
|
|
196
201
|
|
|
197
202
|
if (!isNullish(candidateBody)) {
|
|
198
203
|
const requestBody = _tryReadFetchBody({
|
|
199
204
|
body: candidateBody,
|
|
200
|
-
})
|
|
205
|
+
});
|
|
201
206
|
|
|
202
207
|
if (
|
|
203
208
|
requestBody?.length &&
|
|
204
209
|
(typeof Blob !== 'undefined'
|
|
205
|
-
? new Blob([requestBody]).size <=
|
|
210
|
+
? new Blob([requestBody]).size <=
|
|
211
|
+
configs.maxCapturingHttpPayloadSize
|
|
206
212
|
: requestBody.length <= configs.maxCapturingHttpPayloadSize)
|
|
207
213
|
) {
|
|
208
|
-
networkRequest.requestBody = requestBody
|
|
214
|
+
networkRequest.requestBody = requestBody;
|
|
209
215
|
}
|
|
210
216
|
}
|
|
211
217
|
}
|
|
212
218
|
|
|
213
219
|
try {
|
|
214
220
|
// Make the actual fetch request
|
|
215
|
-
const response = await originalFetch(input, init)
|
|
221
|
+
const response = await originalFetch(input, init);
|
|
216
222
|
|
|
217
223
|
// Capture response data
|
|
218
224
|
if (configs.recordResponseHeaders) {
|
|
219
|
-
networkRequest.responseHeaders = _headersToObject(response.headers)
|
|
225
|
+
networkRequest.responseHeaders = _headersToObject(response.headers);
|
|
220
226
|
}
|
|
221
227
|
|
|
222
228
|
if (configs.shouldRecordBody) {
|
|
223
|
-
const responseBody = await _tryReadResponseBody(response)
|
|
229
|
+
const responseBody = await _tryReadResponseBody(response);
|
|
224
230
|
|
|
225
231
|
if (
|
|
226
232
|
responseBody?.length &&
|
|
227
233
|
(typeof Blob !== 'undefined'
|
|
228
|
-
? new Blob([responseBody]).size <=
|
|
234
|
+
? new Blob([responseBody]).size <=
|
|
235
|
+
configs.maxCapturingHttpPayloadSize
|
|
229
236
|
: responseBody.length <= configs.maxCapturingHttpPayloadSize)
|
|
230
237
|
) {
|
|
231
|
-
networkRequest.responseBody = responseBody
|
|
238
|
+
networkRequest.responseBody = responseBody;
|
|
232
239
|
}
|
|
233
240
|
}
|
|
234
241
|
|
|
235
|
-
// Attach network request data to the response for later access
|
|
236
|
-
|
|
237
|
-
response.networkRequest = networkRequest
|
|
242
|
+
// @ts-expect-error Attach network request data to the response for later access
|
|
243
|
+
response.networkRequest = networkRequest;
|
|
238
244
|
|
|
239
|
-
return response
|
|
245
|
+
return response;
|
|
240
246
|
} catch (error) {
|
|
241
247
|
// Even if the fetch fails, we can still capture the request data
|
|
242
248
|
// Attach captured request data to the thrown error for downstream handling
|
|
243
|
-
// @ts-ignore
|
|
244
249
|
if (error && typeof error === 'object') {
|
|
245
|
-
// @ts-
|
|
246
|
-
error.networkRequest = networkRequest
|
|
250
|
+
// @ts-expect-error
|
|
251
|
+
error.networkRequest = networkRequest;
|
|
247
252
|
}
|
|
248
|
-
throw error
|
|
253
|
+
throw error;
|
|
249
254
|
}
|
|
250
|
-
}
|
|
255
|
+
};
|
|
251
256
|
|
|
252
257
|
// Preserve the original fetch function's properties
|
|
253
258
|
try {
|
|
254
|
-
Object.setPrototypeOf(global.fetch, originalFetch)
|
|
255
|
-
Object.defineProperty(global.fetch, 'name', { value: 'fetch' })
|
|
256
|
-
Object.defineProperty(global.fetch, 'length', {
|
|
259
|
+
Object.setPrototypeOf(global.fetch, originalFetch);
|
|
260
|
+
Object.defineProperty(global.fetch, 'name', { value: 'fetch' });
|
|
261
|
+
Object.defineProperty(global.fetch, 'length', {
|
|
262
|
+
value: originalFetch.length,
|
|
263
|
+
});
|
|
257
264
|
} catch (error) {
|
|
258
|
-
console.warn('[Fetch Patch] Failed to preserve fetch properties:', error)
|
|
265
|
+
console.warn('[Fetch Patch] Failed to preserve fetch properties:', error);
|
|
259
266
|
}
|
|
260
267
|
} else {
|
|
261
|
-
console.info(
|
|
262
|
-
|
|
268
|
+
console.info(
|
|
269
|
+
'Fetch patch: Skipping fetch patching - fetch not available or unsafe environment'
|
|
270
|
+
);
|
|
271
|
+
}
|