@multiplayer-app/session-recorder-react-native 0.0.1-alpha.9 → 0.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/SessionRecorderNative.podspec +29 -0
- package/android/build.gradle +32 -0
- package/app.plugin.js +42 -0
- package/copy-react-native-dist.sh +4 -10
- package/dist/components/GestureCaptureWrapper/GestureCaptureWrapper.js +1 -0
- package/dist/components/GestureCaptureWrapper/GestureCaptureWrapper.js.map +1 -0
- package/dist/components/GestureCaptureWrapper/index.d.ts +1 -0
- package/dist/components/GestureCaptureWrapper/index.js +1 -0
- package/dist/components/GestureCaptureWrapper/index.js.map +1 -0
- package/dist/components/MaskableComponent.d.ts +22 -0
- package/dist/components/MaskableComponent.js +1 -0
- package/dist/components/MaskableComponent.js.map +1 -0
- package/dist/components/MaskableTextInput.d.ts +14 -0
- package/dist/components/MaskableTextInput.js +1 -0
- package/dist/components/MaskableTextInput.js.map +1 -0
- package/dist/components/ScreenRecorderView/ScreenRecorderView.d.ts +5 -0
- package/dist/components/ScreenRecorderView/ScreenRecorderView.js +1 -0
- package/dist/components/ScreenRecorderView/ScreenRecorderView.js.map +1 -0
- package/dist/components/ScreenRecorderView/index.d.ts +1 -0
- package/dist/components/ScreenRecorderView/index.js +1 -0
- package/dist/components/ScreenRecorderView/index.js.map +1 -0
- package/dist/components/SessionRecorderWidget/FinalPopover.d.ts +11 -0
- package/dist/components/SessionRecorderWidget/FinalPopover.js +1 -0
- package/dist/components/SessionRecorderWidget/FinalPopover.js.map +1 -0
- package/dist/components/SessionRecorderWidget/FloatingButton.d.ts +8 -0
- package/dist/components/SessionRecorderWidget/FloatingButton.js +1 -0
- package/dist/components/SessionRecorderWidget/FloatingButton.js.map +1 -0
- package/dist/components/SessionRecorderWidget/InitialPopover.d.ts +13 -0
- package/dist/components/SessionRecorderWidget/InitialPopover.js +1 -0
- package/dist/components/SessionRecorderWidget/InitialPopover.js.map +1 -0
- package/dist/components/SessionRecorderWidget/ModalContainer.d.ts +8 -0
- package/dist/components/SessionRecorderWidget/ModalContainer.js +1 -0
- package/dist/components/SessionRecorderWidget/ModalContainer.js.map +1 -0
- package/dist/components/SessionRecorderWidget/ModalHeader.d.ts +6 -0
- package/dist/components/SessionRecorderWidget/ModalHeader.js +1 -0
- package/dist/components/SessionRecorderWidget/ModalHeader.js.map +1 -0
- package/dist/components/SessionRecorderWidget/SessionRecorderWidget.d.ts +5 -0
- package/dist/components/SessionRecorderWidget/SessionRecorderWidget.js +1 -0
- package/dist/components/SessionRecorderWidget/SessionRecorderWidget.js.map +1 -0
- package/dist/components/SessionRecorderWidget/icons.d.ts +11 -0
- package/dist/components/SessionRecorderWidget/icons.js +1 -0
- package/dist/components/SessionRecorderWidget/icons.js.map +1 -0
- package/dist/components/SessionRecorderWidget/index.d.ts +2 -0
- package/dist/components/SessionRecorderWidget/index.js +1 -0
- package/dist/components/SessionRecorderWidget/index.js.map +1 -0
- package/dist/components/SessionRecorderWidget/styles.d.ts +145 -0
- package/dist/components/SessionRecorderWidget/styles.js +1 -0
- package/dist/components/SessionRecorderWidget/styles.js.map +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -0
- package/dist/config/defaults.js +1 -1
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/masking.js +1 -1
- package/dist/config/masking.js.map +1 -1
- package/dist/context/SessionRecorderContext.d.ts +5 -3
- package/dist/context/SessionRecorderContext.js +1 -1
- package/dist/context/SessionRecorderContext.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/native/ScreenMasking.d.ts +21 -0
- package/dist/native/ScreenMasking.js +1 -0
- package/dist/native/ScreenMasking.js.map +1 -0
- package/dist/native/SessionRecorderNative.d.ts +21 -0
- package/dist/native/SessionRecorderNative.js +1 -0
- package/dist/native/SessionRecorderNative.js.map +1 -0
- package/dist/otel/index.d.ts +0 -2
- package/dist/otel/index.js.map +1 -1
- package/dist/otel/instrumentations/index.d.ts +0 -3
- package/dist/otel/instrumentations/index.js +1 -1
- package/dist/otel/instrumentations/index.js.map +1 -1
- package/dist/patch/xhr.js +1 -1
- package/dist/patch/xhr.js.map +1 -1
- package/dist/recorder/gestureRecorder.d.ts +0 -9
- package/dist/recorder/gestureRecorder.js +1 -1
- package/dist/recorder/gestureRecorder.js.map +1 -1
- package/dist/recorder/index.d.ts +4 -3
- package/dist/recorder/index.js.map +1 -1
- package/dist/recorder/screenRecorder.d.ts +2 -6
- package/dist/recorder/screenRecorder.js +1 -1
- package/dist/recorder/screenRecorder.js.map +1 -1
- package/dist/recorder/screenshotManager.d.ts +10 -0
- package/dist/recorder/screenshotManager.js +1 -0
- package/dist/recorder/screenshotManager.js.map +1 -0
- package/dist/services/screenMaskingService.d.ts +39 -0
- package/dist/services/screenMaskingService.js +1 -0
- package/dist/services/screenMaskingService.js.map +1 -0
- package/dist/services/storage.service.d.ts +18 -2
- package/dist/services/storage.service.js +1 -1
- package/dist/services/storage.service.js.map +1 -1
- package/dist/session-recorder.d.ts +4 -2
- package/dist/session-recorder.js +1 -1
- package/dist/session-recorder.js.map +1 -1
- package/dist/types/index.d.ts +2 -16
- package/dist/types/index.js +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/session-recorder.d.ts +6 -0
- package/dist/types/session-recorder.js.map +1 -1
- package/dist/utils/app-metadata.d.ts +16 -0
- package/dist/utils/app-metadata.js +1 -0
- package/dist/utils/app-metadata.js.map +1 -0
- package/dist/utils/componentRegistry.d.ts +64 -0
- package/dist/utils/componentRegistry.js +1 -0
- package/dist/utils/componentRegistry.js.map +1 -0
- package/dist/utils/nativeModuleTest.d.ts +8 -0
- package/dist/utils/nativeModuleTest.js +1 -0
- package/dist/utils/nativeModuleTest.js.map +1 -0
- package/dist/utils/platform.d.ts +35 -0
- package/dist/utils/platform.js +1 -1
- package/dist/utils/platform.js.map +1 -1
- package/dist/utils/reactNativeHierarchyExtractor.d.ts +38 -0
- package/dist/utils/reactNativeHierarchyExtractor.js +1 -0
- package/dist/utils/reactNativeHierarchyExtractor.js.map +1 -0
- package/dist/utils/rrweb-events.d.ts +1 -1
- package/dist/utils/rrweb-events.js +1 -1
- package/dist/utils/rrweb-events.js.map +1 -1
- package/dist/utils/screenshotMasker.d.ts +96 -0
- package/dist/utils/screenshotMasker.js +1 -0
- package/dist/utils/screenshotMasker.js.map +1 -0
- package/dist/utils/viewHierarchyTracker.d.ts +89 -0
- package/dist/utils/viewHierarchyTracker.js +1 -0
- package/dist/utils/viewHierarchyTracker.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/docs/NATIVE_MODULE_SETUP.md +177 -0
- package/ios/SessionRecorderNative.m +17 -0
- package/ios/SessionRecorderNative.podspec +26 -0
- package/ios/SessionRecorderNative.swift +205 -0
- package/package.json +25 -14
- package/plugin/package.json +20 -0
- package/plugin/src/index.js +42 -0
- package/react-native.config.js +15 -0
- package/RRWEB_INTEGRATION.md +0 -336
- package/VIEWSHOT_INTEGRATION_TEST.md +0 -123
- package/babel.config.js +0 -13
- package/dist/components/GestureCaptureWrapper.js +0 -1
- package/dist/components/GestureCaptureWrapper.js.map +0 -1
- package/dist/expo.d.ts +0 -7
- package/dist/expo.js +0 -1
- package/dist/expo.js.map +0 -1
- package/dist/otel/instrumentations/gestureInstrumentation.d.ts +0 -15
- package/dist/otel/instrumentations/gestureInstrumentation.js +0 -1
- package/dist/otel/instrumentations/gestureInstrumentation.js.map +0 -1
- package/dist/otel/instrumentations/reactNativeInstrumentation.d.ts +0 -8
- package/dist/otel/instrumentations/reactNativeInstrumentation.js +0 -1
- package/dist/otel/instrumentations/reactNativeInstrumentation.js.map +0 -1
- package/dist/otel/instrumentations/reactNavigationInstrumentation.d.ts +0 -13
- package/dist/otel/instrumentations/reactNavigationInstrumentation.js +0 -1
- package/dist/otel/instrumentations/reactNavigationInstrumentation.js.map +0 -1
- package/dist/recorder/gestureHandlerRecorder.d.ts +0 -19
- package/dist/recorder/gestureHandlerRecorder.js +0 -1
- package/dist/recorder/gestureHandlerRecorder.js.map +0 -1
- package/dist/types/rrweb.d.ts +0 -118
- package/dist/types/rrweb.js +0 -1
- package/dist/types/rrweb.js.map +0 -1
- package/src/components/GestureCaptureWrapper.tsx +0 -110
- package/src/config/constants.ts +0 -60
- package/src/config/defaults.ts +0 -82
- package/src/config/index.ts +0 -6
- package/src/config/masking.ts +0 -27
- package/src/config/session-recorder.ts +0 -55
- package/src/config/validators.ts +0 -31
- package/src/context/SessionRecorderContext.tsx +0 -143
- package/src/expo.ts +0 -11
- package/src/index.ts +0 -9
- package/src/otel/helpers.ts +0 -275
- package/src/otel/index.ts +0 -149
- package/src/otel/instrumentations/gestureInstrumentation.ts +0 -141
- package/src/otel/instrumentations/index.ts +0 -120
- package/src/otel/instrumentations/reactNativeInstrumentation.ts +0 -77
- package/src/otel/instrumentations/reactNavigationInstrumentation.ts +0 -119
- package/src/patch/index.ts +0 -1
- package/src/patch/xhr.ts +0 -142
- package/src/recorder/eventExporter.ts +0 -141
- package/src/recorder/gestureHandlerRecorder.ts +0 -157
- package/src/recorder/gestureRecorder.ts +0 -622
- package/src/recorder/index.ts +0 -178
- package/src/recorder/navigationTracker.ts +0 -449
- package/src/recorder/screenRecorder.ts +0 -506
- package/src/services/api.service.ts +0 -203
- package/src/services/storage.service.ts +0 -158
- package/src/session-recorder.ts +0 -601
- package/src/types/expo.d.ts +0 -23
- package/src/types/index.ts +0 -46
- package/src/types/session-recorder.ts +0 -423
- package/src/types/session.ts +0 -65
- package/src/utils/index.ts +0 -8
- package/src/utils/logger.ts +0 -225
- package/src/utils/platform.ts +0 -87
- package/src/utils/request-utils.ts +0 -61
- package/src/utils/rrweb-events.ts +0 -311
- package/src/utils/session.ts +0 -18
- package/src/utils/time.ts +0 -17
- package/src/utils/type-utils.ts +0 -75
- package/src/version.ts +0 -1
- package/tsconfig.json +0 -24
- /package/dist/components/{GestureCaptureWrapper.d.ts → GestureCaptureWrapper/GestureCaptureWrapper.d.ts} +0 -0
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { InstrumentationBase } from '@opentelemetry/instrumentation'
|
|
2
|
-
import { trace, SpanStatusCode } from '@opentelemetry/api'
|
|
3
|
-
|
|
4
|
-
export class GestureInstrumentation extends InstrumentationBase {
|
|
5
|
-
private _isEnabled = false
|
|
6
|
-
|
|
7
|
-
constructor() {
|
|
8
|
-
super('react-native-gesture', '1.0.0', {})
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
init(): void {
|
|
12
|
-
// Initialize the instrumentation
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
enable(): void {
|
|
16
|
-
this._isEnabled = true
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
disable(): void {
|
|
20
|
-
this._isEnabled = false
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
isEnabled(): boolean {
|
|
24
|
-
return this._isEnabled
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Manual gesture tracking methods
|
|
28
|
-
recordTap(x: number, y: number, target?: string) {
|
|
29
|
-
if (!this._isEnabled) return
|
|
30
|
-
|
|
31
|
-
const span = trace.getTracer('gesture').startSpan('Gesture.tap', {
|
|
32
|
-
attributes: {
|
|
33
|
-
'gesture.type': 'tap',
|
|
34
|
-
'gesture.coordinates.x': x,
|
|
35
|
-
'gesture.coordinates.y': y,
|
|
36
|
-
'gesture.timestamp': Date.now(),
|
|
37
|
-
},
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
if (target) {
|
|
41
|
-
span.setAttribute('gesture.target', target)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
span.setStatus({ code: SpanStatusCode.OK })
|
|
45
|
-
span.end()
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
recordSwipe(direction: string, target?: string) {
|
|
49
|
-
if (!this._isEnabled) return
|
|
50
|
-
|
|
51
|
-
const span = trace.getTracer('gesture').startSpan('Gesture.swipe', {
|
|
52
|
-
attributes: {
|
|
53
|
-
'gesture.type': 'swipe',
|
|
54
|
-
'gesture.direction': direction,
|
|
55
|
-
'gesture.timestamp': Date.now(),
|
|
56
|
-
},
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
if (target) {
|
|
60
|
-
span.setAttribute('gesture.target', target)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
span.setStatus({ code: SpanStatusCode.OK })
|
|
64
|
-
span.end()
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
recordPinch(scale: number, target?: string) {
|
|
68
|
-
if (!this._isEnabled) return
|
|
69
|
-
|
|
70
|
-
const span = trace.getTracer('gesture').startSpan('Gesture.pinch', {
|
|
71
|
-
attributes: {
|
|
72
|
-
'gesture.type': 'pinch',
|
|
73
|
-
'gesture.scale': scale,
|
|
74
|
-
'gesture.timestamp': Date.now(),
|
|
75
|
-
},
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
if (target) {
|
|
79
|
-
span.setAttribute('gesture.target', target)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
span.setStatus({ code: SpanStatusCode.OK })
|
|
83
|
-
span.end()
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
recordPan(deltaX: number, deltaY: number, target?: string) {
|
|
87
|
-
if (!this._isEnabled) return
|
|
88
|
-
|
|
89
|
-
const span = trace.getTracer('gesture').startSpan('Gesture.pan', {
|
|
90
|
-
attributes: {
|
|
91
|
-
'gesture.type': 'pan',
|
|
92
|
-
'gesture.delta_x': deltaX,
|
|
93
|
-
'gesture.delta_y': deltaY,
|
|
94
|
-
'gesture.timestamp': Date.now(),
|
|
95
|
-
},
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
if (target) {
|
|
99
|
-
span.setAttribute('gesture.target', target)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
span.setStatus({ code: SpanStatusCode.OK })
|
|
103
|
-
span.end()
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
recordLongPress(duration: number, target?: string) {
|
|
107
|
-
if (!this._isEnabled) return
|
|
108
|
-
|
|
109
|
-
const span = trace.getTracer('gesture').startSpan('Gesture.longPress', {
|
|
110
|
-
attributes: {
|
|
111
|
-
'gesture.type': 'longPress',
|
|
112
|
-
'gesture.duration': duration,
|
|
113
|
-
'gesture.timestamp': Date.now(),
|
|
114
|
-
},
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
if (target) {
|
|
118
|
-
span.setAttribute('gesture.target', target)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
span.setStatus({ code: SpanStatusCode.OK })
|
|
122
|
-
span.end()
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Error tracking for gesture failures
|
|
126
|
-
recordGestureError(error: Error, gestureType: string) {
|
|
127
|
-
if (!this._isEnabled) return
|
|
128
|
-
|
|
129
|
-
const span = trace.getTracer('gesture').startSpan(`Gesture.${gestureType}.error`, {
|
|
130
|
-
attributes: {
|
|
131
|
-
'gesture.type': gestureType,
|
|
132
|
-
'gesture.error': true,
|
|
133
|
-
'gesture.timestamp': Date.now(),
|
|
134
|
-
},
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
span.setStatus({ code: SpanStatusCode.ERROR, message: error.message })
|
|
138
|
-
span.recordException(error)
|
|
139
|
-
span.end()
|
|
140
|
-
}
|
|
141
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { FetchInstrumentation } from '@opentelemetry/instrumentation-fetch'
|
|
2
|
-
import { XMLHttpRequestInstrumentation } from '@opentelemetry/instrumentation-xml-http-request'
|
|
3
|
-
|
|
4
|
-
import { OTEL_IGNORE_URLS } from '../../config'
|
|
5
|
-
import { TracerReactNativeConfig } from '../../types'
|
|
6
|
-
import { extractResponseBody, headersToObject, processHttpPayload } from '../helpers'
|
|
7
|
-
import { logger } from '../../utils'
|
|
8
|
-
|
|
9
|
-
export function getInstrumentations(config: TracerReactNativeConfig) {
|
|
10
|
-
|
|
11
|
-
const instrumentations = []
|
|
12
|
-
|
|
13
|
-
// Fetch instrumentation
|
|
14
|
-
try {
|
|
15
|
-
instrumentations.push(
|
|
16
|
-
new FetchInstrumentation({
|
|
17
|
-
clearTimingResources: false,
|
|
18
|
-
ignoreUrls: [
|
|
19
|
-
...OTEL_IGNORE_URLS,
|
|
20
|
-
...(config.ignoreUrls || []),
|
|
21
|
-
],
|
|
22
|
-
propagateTraceHeaderCorsUrls: config.propagateTraceHeaderCorsUrls,
|
|
23
|
-
applyCustomAttributesOnSpan: async (span, request, response) => {
|
|
24
|
-
if (!config) return
|
|
25
|
-
|
|
26
|
-
const { captureBody, captureHeaders } = config
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
if (!captureBody && !captureHeaders) {
|
|
30
|
-
return
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const requestBody = request.body
|
|
34
|
-
const requestHeaders = headersToObject(request.headers)
|
|
35
|
-
const responseHeaders = headersToObject(response instanceof Response ? response.headers : undefined)
|
|
36
|
-
|
|
37
|
-
let responseBody: string | null = null
|
|
38
|
-
if (response instanceof Response && response.body) {
|
|
39
|
-
responseBody = await extractResponseBody(response)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const payload = {
|
|
43
|
-
requestBody,
|
|
44
|
-
responseBody,
|
|
45
|
-
requestHeaders,
|
|
46
|
-
responseHeaders,
|
|
47
|
-
}
|
|
48
|
-
processHttpPayload(payload, config, span)
|
|
49
|
-
} catch (error) {
|
|
50
|
-
// eslint-disable-next-line
|
|
51
|
-
logger.error('DEBUGGER_LIB', 'Failed to capture fetch payload', error)
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
})
|
|
55
|
-
)
|
|
56
|
-
} catch (error) {
|
|
57
|
-
logger.warn('DEBUGGER_LIB', 'Fetch instrumentation not available', error)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// XMLHttpRequest instrumentation
|
|
61
|
-
try {
|
|
62
|
-
instrumentations.push(
|
|
63
|
-
new XMLHttpRequestInstrumentation({
|
|
64
|
-
clearTimingResources: false,
|
|
65
|
-
ignoreUrls: [
|
|
66
|
-
...OTEL_IGNORE_URLS,
|
|
67
|
-
...(config.ignoreUrls || []),
|
|
68
|
-
],
|
|
69
|
-
propagateTraceHeaderCorsUrls: config.propagateTraceHeaderCorsUrls,
|
|
70
|
-
applyCustomAttributesOnSpan: (span, xhr) => {
|
|
71
|
-
if (!config) return
|
|
72
|
-
|
|
73
|
-
const { captureBody, captureHeaders } = config
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
if (!captureBody && !captureHeaders) {
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// @ts-ignore
|
|
81
|
-
const requestBody = xhr.networkRequest.requestBody
|
|
82
|
-
// @ts-ignore
|
|
83
|
-
const responseBody = xhr.networkRequest.responseBody
|
|
84
|
-
// @ts-ignore
|
|
85
|
-
const requestHeaders = xhr.networkRequest.requestHeaders || {}
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
const responseHeaders = xhr.networkRequest.responseHeaders || {}
|
|
88
|
-
|
|
89
|
-
const payload = {
|
|
90
|
-
requestBody,
|
|
91
|
-
responseBody,
|
|
92
|
-
requestHeaders,
|
|
93
|
-
responseHeaders,
|
|
94
|
-
}
|
|
95
|
-
processHttpPayload(payload, config, span)
|
|
96
|
-
} catch (error) {
|
|
97
|
-
// eslint-disable-next-line
|
|
98
|
-
logger.error('DEBUGGER_LIB', 'Failed to capture xml-http payload', error)
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
})
|
|
102
|
-
)
|
|
103
|
-
} catch (error) {
|
|
104
|
-
logger.warn('DEBUGGER_LIB', 'XMLHttpRequest instrumentation not available', error)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Custom React Native instrumentations
|
|
108
|
-
// try {
|
|
109
|
-
// instrumentations.push(new ReactNativeInstrumentation())
|
|
110
|
-
// } catch (error) {
|
|
111
|
-
// console.warn('React Native instrumentation not available:', error)
|
|
112
|
-
// }
|
|
113
|
-
|
|
114
|
-
return instrumentations
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Export custom instrumentations for manual use
|
|
118
|
-
export { ReactNativeInstrumentation } from './reactNativeInstrumentation'
|
|
119
|
-
export { ReactNavigationInstrumentation } from './reactNavigationInstrumentation'
|
|
120
|
-
export { GestureInstrumentation } from './gestureInstrumentation'
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { InstrumentationBase } from '@opentelemetry/instrumentation'
|
|
2
|
-
import { logger } from '../../utils'
|
|
3
|
-
import { trace, SpanStatusCode } from '@opentelemetry/api'
|
|
4
|
-
import AsyncStorage from '@react-native-async-storage/async-storage'
|
|
5
|
-
|
|
6
|
-
export class ReactNativeInstrumentation extends InstrumentationBase {
|
|
7
|
-
constructor() {
|
|
8
|
-
super('react-native', '1.0.0', {})
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
init(): void {
|
|
12
|
-
// Initialize the instrumentation
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
enable(): void {
|
|
16
|
-
// Try to wrap AsyncStorage if it's available
|
|
17
|
-
try {
|
|
18
|
-
if (AsyncStorage) {
|
|
19
|
-
this._wrap(AsyncStorage, 'setItem', this._wrapAsyncStorage)
|
|
20
|
-
}
|
|
21
|
-
} catch (error) {
|
|
22
|
-
logger.warn('DEBUGGER_LIB', '@react-native-async-storage/async-storage is not available. AsyncStorage instrumentation will be disabled.')
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
disable(): void {
|
|
27
|
-
// Try to unwrap AsyncStorage if it was wrapped
|
|
28
|
-
try {
|
|
29
|
-
if (AsyncStorage) {
|
|
30
|
-
this._unwrap(AsyncStorage, 'setItem')
|
|
31
|
-
}
|
|
32
|
-
} catch (error) {
|
|
33
|
-
// AsyncStorage was not available, nothing to unwrap
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
private _wrapAsyncStorage(originalMethod: any) {
|
|
38
|
-
return async function (this: any, key: string, value: string) {
|
|
39
|
-
const startTime = Date.now()
|
|
40
|
-
try {
|
|
41
|
-
const result = await originalMethod.call(this, key, value)
|
|
42
|
-
|
|
43
|
-
const span = trace.getTracer('react-native').startSpan('AsyncStorage.setItem', {
|
|
44
|
-
attributes: {
|
|
45
|
-
'storage.operation': 'setItem',
|
|
46
|
-
'storage.key': key,
|
|
47
|
-
'storage.value_length': value.length,
|
|
48
|
-
'storage.duration': Date.now() - startTime,
|
|
49
|
-
},
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
span.setStatus({ code: SpanStatusCode.OK })
|
|
53
|
-
span.end()
|
|
54
|
-
|
|
55
|
-
return result
|
|
56
|
-
} catch (error) {
|
|
57
|
-
const span = trace.getTracer('react-native').startSpan('AsyncStorage.setItem', {
|
|
58
|
-
attributes: {
|
|
59
|
-
'storage.operation': 'setItem',
|
|
60
|
-
'storage.key': key,
|
|
61
|
-
'storage.error': true,
|
|
62
|
-
'storage.duration': Date.now() - startTime,
|
|
63
|
-
},
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
const errorMessage = error instanceof Error ? error.message : String(error)
|
|
67
|
-
span.setStatus({ code: SpanStatusCode.ERROR, message: errorMessage })
|
|
68
|
-
if (error instanceof Error) {
|
|
69
|
-
span.recordException(error)
|
|
70
|
-
}
|
|
71
|
-
span.end()
|
|
72
|
-
|
|
73
|
-
throw error
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { InstrumentationBase } from '@opentelemetry/instrumentation'
|
|
2
|
-
import { trace, SpanStatusCode } from '@opentelemetry/api'
|
|
3
|
-
|
|
4
|
-
export class ReactNavigationInstrumentation extends InstrumentationBase {
|
|
5
|
-
private navigationRef: any = null
|
|
6
|
-
|
|
7
|
-
constructor() {
|
|
8
|
-
super('react-navigation', '1.0.0', {})
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
init(): void {
|
|
12
|
-
// Initialize the instrumentation
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
enable(): void {
|
|
16
|
-
// Enable the instrumentation
|
|
17
|
-
super.enable()
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
setNavigationRef(ref: any) {
|
|
21
|
-
this.navigationRef = ref
|
|
22
|
-
this._setupNavigationListener()
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private _setupNavigationListener() {
|
|
26
|
-
if (!this.navigationRef) return
|
|
27
|
-
|
|
28
|
-
// Listen to navigation state changes
|
|
29
|
-
this.navigationRef.addListener('state', (e: any) => {
|
|
30
|
-
this._recordNavigationEvent('state_change', e.data)
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
// Listen to focus events
|
|
34
|
-
this.navigationRef.addListener('focus', (e: any) => {
|
|
35
|
-
this._recordNavigationEvent('focus', e.data)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
// Listen to blur events
|
|
39
|
-
this.navigationRef.addListener('blur', (e: any) => {
|
|
40
|
-
this._recordNavigationEvent('blur', e.data)
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
private _recordNavigationEvent(eventType: string, data: any) {
|
|
45
|
-
const span = trace.getTracer('navigation').startSpan(`Navigation.${eventType}`, {
|
|
46
|
-
attributes: {
|
|
47
|
-
'navigation.system': 'ReactNavigation',
|
|
48
|
-
'navigation.operation': eventType,
|
|
49
|
-
'navigation.type': eventType,
|
|
50
|
-
'navigation.timestamp': Date.now(),
|
|
51
|
-
},
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
if (data) {
|
|
55
|
-
if (data.routeName) {
|
|
56
|
-
span.setAttribute('navigation.route_name', data.routeName)
|
|
57
|
-
}
|
|
58
|
-
if (data.params) {
|
|
59
|
-
span.setAttribute('navigation.params', JSON.stringify(data.params))
|
|
60
|
-
}
|
|
61
|
-
if (data.key) {
|
|
62
|
-
span.setAttribute('navigation.key', data.key)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
span.setStatus({ code: SpanStatusCode.OK })
|
|
67
|
-
span.end()
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Manual navigation tracking methods
|
|
71
|
-
recordNavigate(routeName: string, params?: Record<string, any>) {
|
|
72
|
-
const span = trace.getTracer('navigation').startSpan('Navigation.navigate', {
|
|
73
|
-
attributes: {
|
|
74
|
-
'navigation.system': 'ReactNavigation',
|
|
75
|
-
'navigation.operation': 'navigate',
|
|
76
|
-
'navigation.route_name': routeName,
|
|
77
|
-
'navigation.timestamp': Date.now(),
|
|
78
|
-
},
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
if (params) {
|
|
82
|
-
span.setAttribute('navigation.params', JSON.stringify(params))
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
span.setStatus({ code: SpanStatusCode.OK })
|
|
86
|
-
span.end()
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
recordGoBack() {
|
|
90
|
-
const span = trace.getTracer('navigation').startSpan('Navigation.goBack', {
|
|
91
|
-
attributes: {
|
|
92
|
-
'navigation.system': 'ReactNavigation',
|
|
93
|
-
'navigation.operation': 'goBack',
|
|
94
|
-
'navigation.timestamp': Date.now(),
|
|
95
|
-
},
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
span.setStatus({ code: SpanStatusCode.OK })
|
|
99
|
-
span.end()
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
recordReset(routes: any[]) {
|
|
103
|
-
const span = trace.getTracer('navigation').startSpan('Navigation.reset', {
|
|
104
|
-
attributes: {
|
|
105
|
-
'navigation.system': 'ReactNavigation',
|
|
106
|
-
'navigation.operation': 'reset',
|
|
107
|
-
'navigation.routes_count': routes.length,
|
|
108
|
-
'navigation.timestamp': Date.now(),
|
|
109
|
-
},
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
if (routes.length > 0) {
|
|
113
|
-
span.setAttribute('navigation.initial_route', routes[0].name)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
span.setStatus({ code: SpanStatusCode.OK })
|
|
117
|
-
span.end()
|
|
118
|
-
}
|
|
119
|
-
}
|
package/src/patch/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import './xhr'
|
package/src/patch/xhr.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
isFormData,
|
|
4
|
-
isNullish,
|
|
5
|
-
isObject,
|
|
6
|
-
isString,
|
|
7
|
-
} from '../utils/type-utils'
|
|
8
|
-
import { formDataToQuery } from '../utils/request-utils'
|
|
9
|
-
import { DEFAULT_MAX_HTTP_CAPTURING_PAYLOAD_SIZE } from '../config'
|
|
10
|
-
|
|
11
|
-
let recordRequestHeaders = true
|
|
12
|
-
let recordResponseHeaders = true
|
|
13
|
-
const shouldRecordBody = true
|
|
14
|
-
let maxCapturingHttpPayloadSize = DEFAULT_MAX_HTTP_CAPTURING_PAYLOAD_SIZE
|
|
15
|
-
|
|
16
|
-
export const setMaxCapturingHttpPayloadSize = (_maxCapturingHttpPayloadSize: number) => {
|
|
17
|
-
maxCapturingHttpPayloadSize = _maxCapturingHttpPayloadSize
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const setShouldRecordHttpData = (shouldRecordBody: boolean, shouldRecordHeaders: boolean) => {
|
|
21
|
-
recordRequestHeaders = shouldRecordHeaders
|
|
22
|
-
recordResponseHeaders = shouldRecordHeaders
|
|
23
|
-
// eslint-disable-next-line
|
|
24
|
-
shouldRecordBody = shouldRecordBody
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function _tryReadXHRBody({
|
|
28
|
-
body,
|
|
29
|
-
url,
|
|
30
|
-
}: {
|
|
31
|
-
body: any | null | undefined
|
|
32
|
-
url: string | URL | RequestInfo
|
|
33
|
-
}): string | null {
|
|
34
|
-
if (isNullish(body)) {
|
|
35
|
-
return null
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (isString(body)) {
|
|
39
|
-
return body
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (isFormData(body)) {
|
|
44
|
-
return formDataToQuery(body)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (isObject(body)) {
|
|
48
|
-
try {
|
|
49
|
-
return JSON.stringify(body)
|
|
50
|
-
} catch {
|
|
51
|
-
return '[XHR] Failed to stringify response object'
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return `[XHR] Cannot read body of type ${Object.prototype.toString.call(body)}`
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
(function (xhr) {
|
|
59
|
-
const originalOpen = XMLHttpRequest.prototype.open
|
|
60
|
-
|
|
61
|
-
xhr.open = function (
|
|
62
|
-
method: string,
|
|
63
|
-
url: string | URL,
|
|
64
|
-
async = true,
|
|
65
|
-
username?: string | null,
|
|
66
|
-
password?: string | null,
|
|
67
|
-
) {
|
|
68
|
-
const xhr = this as XMLHttpRequest
|
|
69
|
-
const networkRequest: {
|
|
70
|
-
requestHeaders?: any,
|
|
71
|
-
requestBody?: any,
|
|
72
|
-
responseHeaders?: any,
|
|
73
|
-
responseBody?: any,
|
|
74
|
-
} = {}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// @ts-ignore
|
|
78
|
-
const requestHeaders: Record<string, string> = {}
|
|
79
|
-
const originalSetRequestHeader = xhr.setRequestHeader.bind(xhr)
|
|
80
|
-
xhr.setRequestHeader = (header: string, value: string) => {
|
|
81
|
-
requestHeaders[header] = value
|
|
82
|
-
return originalSetRequestHeader(header, value)
|
|
83
|
-
}
|
|
84
|
-
if (recordRequestHeaders) {
|
|
85
|
-
networkRequest.requestHeaders = requestHeaders
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const originalSend = xhr.send.bind(xhr)
|
|
89
|
-
xhr.send = (body) => {
|
|
90
|
-
if (shouldRecordBody) {
|
|
91
|
-
const requestBody = _tryReadXHRBody({ body, url })
|
|
92
|
-
|
|
93
|
-
if (
|
|
94
|
-
requestBody?.length
|
|
95
|
-
&& requestBody.length <= maxCapturingHttpPayloadSize
|
|
96
|
-
) {
|
|
97
|
-
networkRequest.requestBody = requestBody
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return originalSend(body)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
xhr.addEventListener('readystatechange', () => {
|
|
104
|
-
if (xhr.readyState !== xhr.DONE) {
|
|
105
|
-
return
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
// @ts-ignore
|
|
110
|
-
const responseHeaders: Record<string, string> = {}
|
|
111
|
-
const rawHeaders = xhr.getAllResponseHeaders()
|
|
112
|
-
const headers = rawHeaders.trim().split(/[\r\n]+/)
|
|
113
|
-
headers.forEach((line) => {
|
|
114
|
-
const parts = line.split(': ')
|
|
115
|
-
const header = parts.shift()
|
|
116
|
-
const value = parts.join(': ')
|
|
117
|
-
if (header) {
|
|
118
|
-
responseHeaders[header] = value
|
|
119
|
-
}
|
|
120
|
-
})
|
|
121
|
-
if (recordResponseHeaders) {
|
|
122
|
-
networkRequest.responseHeaders = responseHeaders
|
|
123
|
-
}
|
|
124
|
-
if (shouldRecordBody) {
|
|
125
|
-
const responseBody = _tryReadXHRBody({ body: xhr.response, url })
|
|
126
|
-
|
|
127
|
-
if (
|
|
128
|
-
responseBody?.length
|
|
129
|
-
&& responseBody.length <= maxCapturingHttpPayloadSize
|
|
130
|
-
) {
|
|
131
|
-
networkRequest.responseBody = responseBody
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
// @ts-ignore
|
|
138
|
-
xhr.networkRequest = networkRequest
|
|
139
|
-
|
|
140
|
-
originalOpen.call(xhr, method, url as string, async, username, password)
|
|
141
|
-
}
|
|
142
|
-
})(XMLHttpRequest.prototype)
|