@truewatchtech/react-native-mobile 0.4.0-alpha.4 → 0.4.1
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/FTMobileReactNativeSDK.podspec +32 -3
- package/android/build.gradle +7 -19
- package/android/src/main/java/com/ft/sdk/reactnative/FTMobileImpl.java +434 -5
- package/android/src/main/java/com/ft/sdk/reactnative/FTRUMImpl.java +12 -0
- package/android/src/newarch/java/com/ft/sdk/reactnative/FTLogModule.java +7 -14
- package/android/src/newarch/java/com/ft/sdk/reactnative/FTMobileModule.java +46 -12
- package/android/src/newarch/java/com/ft/sdk/reactnative/FTRUMModule.java +12 -13
- package/android/src/newarch/java/com/ft/sdk/reactnative/FTTraceModule.java +6 -8
- package/android/src/oldarch/java/com/ft/sdk/reactnative/FTMobileModule.java +34 -2
- package/android/src/rnpost74/java/com/ft/sdk/reactnative/FTMobilePackage.java +14 -3
- package/android/src/rnpre74/java/com/ft/sdk/reactnative/FTMobilePackage.java +0 -3
- package/ios/FTMobileReactNative.h +9 -5
- package/ios/FTMobileReactNative.mm +619 -0
- package/ios/FTReactNativeLog.h +8 -3
- package/ios/FTReactNativeLog.mm +79 -0
- package/ios/FTReactNativeRUM.h +8 -3
- package/ios/{FTReactNativeRUM.m → FTReactNativeRUM.mm} +143 -84
- package/ios/FTReactNativeTrace.h +8 -2
- package/ios/FTReactNativeTrace.mm +74 -0
- package/ios/FtMobileAgent.xcodeproj/project.pbxproj +17 -1
- package/lib/commonjs/ft_logger.js +14 -13
- package/lib/commonjs/ft_logger.js.map +1 -1
- package/lib/commonjs/ft_mobile_agent.js +153 -6
- package/lib/commonjs/ft_mobile_agent.js.map +1 -1
- package/lib/commonjs/ft_rum.js +55 -21
- package/lib/commonjs/ft_rum.js.map +1 -1
- package/lib/commonjs/ft_tracing.js +29 -10
- package/lib/commonjs/ft_tracing.js.map +1 -1
- package/lib/commonjs/index.js +24 -13
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/rum/FTRumActionTracking.js +10 -4
- package/lib/commonjs/rum/FTRumActionTracking.js.map +1 -1
- package/lib/commonjs/rum/FTRumErrorTracking.js +4 -4
- package/lib/commonjs/rum/FTRumErrorTracking.js.map +1 -1
- package/lib/commonjs/specs/NativeFTMobileReactNative.js +10 -0
- package/lib/commonjs/specs/NativeFTMobileReactNative.js.map +1 -0
- package/lib/commonjs/specs/NativeFTReactNativeLog.js +10 -0
- package/lib/commonjs/specs/NativeFTReactNativeLog.js.map +1 -0
- package/lib/commonjs/specs/NativeFTReactNativeRUM.js +10 -0
- package/lib/commonjs/specs/NativeFTReactNativeRUM.js.map +1 -0
- package/lib/commonjs/specs/NativeFTReactNativeTrace.js +10 -0
- package/lib/commonjs/specs/NativeFTReactNativeTrace.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/ft_logger.js +14 -12
- package/lib/module/ft_logger.js.map +1 -1
- package/lib/module/ft_mobile_agent.js +159 -5
- package/lib/module/ft_mobile_agent.js.map +1 -1
- package/lib/module/ft_rum.js +54 -16
- package/lib/module/ft_rum.js.map +1 -1
- package/lib/module/ft_tracing.js +29 -9
- package/lib/module/ft_tracing.js.map +1 -1
- package/lib/module/index.js +3 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/rum/FTRumActionTracking.js +10 -4
- package/lib/module/rum/FTRumActionTracking.js.map +1 -1
- package/lib/module/rum/FTRumErrorTracking.js +4 -4
- package/lib/module/rum/FTRumErrorTracking.js.map +1 -1
- package/lib/module/specs/NativeFTMobileReactNative.js +5 -0
- package/lib/module/specs/NativeFTMobileReactNative.js.map +1 -0
- package/lib/module/specs/NativeFTReactNativeLog.js +5 -0
- package/lib/module/specs/NativeFTReactNativeLog.js.map +1 -0
- package/lib/module/specs/NativeFTReactNativeRUM.js +5 -0
- package/lib/module/specs/NativeFTReactNativeRUM.js.map +1 -0
- package/lib/module/specs/NativeFTReactNativeTrace.js +5 -0
- package/lib/module/specs/NativeFTReactNativeTrace.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/ft_logger.d.ts +6 -6
- package/lib/typescript/ft_mobile_agent.d.ts +165 -14
- package/lib/typescript/ft_rum.d.ts +32 -8
- package/lib/typescript/ft_tracing.d.ts +6 -6
- package/lib/typescript/index.d.ts +3 -4
- package/lib/typescript/specs/NativeFTMobileReactNative.d.ts +75 -0
- package/lib/typescript/specs/NativeFTReactNativeLog.d.ts +23 -0
- package/lib/typescript/specs/NativeFTReactNativeRUM.d.ts +89 -0
- package/lib/typescript/specs/NativeFTReactNativeTrace.d.ts +24 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +29 -96
- package/scripts/replace-react-require.js +37 -38
- package/src/ft_logger.tsx +72 -40
- package/src/ft_mobile_agent.tsx +374 -91
- package/src/ft_rum.tsx +227 -121
- package/src/ft_tracing.tsx +58 -37
- package/src/index.tsx +58 -18
- package/src/rum/FTRumActionTracking.tsx +212 -204
- package/src/rum/FTRumErrorTracking.tsx +70 -71
- package/src/specs/NativeFTMobileReactNative.ts +83 -0
- package/src/specs/NativeFTReactNativeLog.ts +29 -0
- package/src/specs/NativeFTReactNativeRUM.ts +104 -0
- package/src/specs/NativeFTReactNativeTrace.ts +26 -0
- package/src/version.ts +1 -1
- package/LICENSE +0 -201
- package/android/.project +0 -17
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
- package/android/gradlew +0 -185
- package/android/local.properties +0 -8
- package/android/src/main/java/com/ft/sdk/InnerClassProxy.java +0 -8
- package/android/src/main/java/com/ft/sdk/reactnative/FTSessionReplayImpl.java +0 -60
- package/android/src/main/java/com/ft/sdk/reactnative/extensions/ReactDrawablesExt.java +0 -155
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/NoopTextPropertiesResolver.java +0 -23
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/ReactNativeSessionReplayExtensionSupport.java +0 -57
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/ShadowNodeWrapper.java +0 -84
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/TextPropertiesResolver.java +0 -20
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/DefaultMapper.java +0 -78
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/Pair.java +0 -11
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactEditTextMapper.java +0 -136
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactNativeImageViewMapper.java +0 -117
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactTextMapper.java +0 -57
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactViewGroupMapper.java +0 -22
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactViewModalMapper.java +0 -21
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/resources/ReactDrawableCopier.java +0 -35
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/DrawableUtils.java +0 -34
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/ReflectionUtils.java +0 -43
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/text/FabricTextViewUtils.java +0 -69
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/text/LegacyTextViewUtils.java +0 -97
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/text/TextViewUtils.java +0 -184
- package/android/src/main/java/com/ft/sdk/reactnative/utils/ColorUtils.java +0 -24
- package/android/src/newarch/java/com/ft/sdk/reactnative/FTSessionReplayModule.java +0 -30
- package/android/src/oldarch/java/com/ft/sdk/reactnative/FTSessionReplayModule.java +0 -25
- package/android/src/rn69/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -100
- package/android/src/rn75/java/com/ft/sdk/reactnative/sessionreplay/extensions/LengthPercentageExt.java +0 -27
- package/android/src/rn75/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -116
- package/android/src/rn76/java/com/ft/sdk/reactnative/sessionreplay/extensions/LengthPercentageExt.java +0 -38
- package/android/src/rn76/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -117
- package/android/src/rn79/java/com/ft/sdk/reactnative/sessionreplay/extensions/LengthPercentageExt.java +0 -38
- package/android/src/rn79/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -132
- package/android/src/rn80/java/com/ft/sdk/reactnative/sessionreplay/extensions/ComputedBorderRadiusExt.java +0 -58
- package/android/src/rn80/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -190
- package/android/src/rnlegacy/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -120
- package/ios/.idea/.name +0 -1
- package/ios/.idea/ios.iml +0 -2
- package/ios/.idea/modules.xml +0 -8
- package/ios/.idea/vcs.xml +0 -6
- package/ios/.idea/xcode.xml +0 -4
- package/ios/FTMobileReactNative.m +0 -184
- package/ios/FTRCTTextViewRecorder.h +0 -33
- package/ios/FTRCTTextViewRecorder.m +0 -120
- package/ios/FTReactNativeLog.m +0 -60
- package/ios/FTReactNativeSessionReplay.h +0 -6
- package/ios/FTReactNativeSessionReplay.mm +0 -44
- package/ios/FTReactNativeTrace.m +0 -56
- package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
- package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/xcuserdata/Brandon.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/xcuserdata/Brandon.xcuserdatad/xcschemes/xcschememanagement.plist +0 -5
- package/ios/FtMobileAgent.xcodeproj/xcuserdata/Brandon.xcuserdatad/xcschemes/FtMobileAgent.xcscheme +0 -56
- package/ios/FtMobileAgent.xcodeproj/xcuserdata/Brandon.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/ios/RCTVersion.h +0 -8
- package/lib/commonjs/ft_session_replay.js +0 -34
- package/lib/commonjs/ft_session_replay.js.map +0 -1
- package/lib/module/ft_session_replay.js +0 -29
- package/lib/module/ft_session_replay.js.map +0 -1
- package/lib/typescript/ft_session_replay.d.ts +0 -27
- package/src/ft_session_replay.tsx +0 -34
|
@@ -1,232 +1,240 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { FTReactNativeRUM } from '../ft_rum';
|
|
3
3
|
const FT_ENABLE_TRACK = 'ft-enable-track';
|
|
4
4
|
const FT_EXTRA_PROPERTY = 'ft-extra-property';
|
|
5
5
|
export class FTRumActionTracking {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
private static isTracking = false;
|
|
7
|
+
private static preActionTimestamp = Number.MIN_VALUE;
|
|
8
|
+
private static originalMemo = React.memo;
|
|
9
|
+
private static originalJsx = null;
|
|
10
|
+
private static originalCreateElement = React.createElement;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return originalOnPress(...args);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
(props as Record<
|
|
30
|
-
string,
|
|
31
|
-
unknown
|
|
32
|
-
>).__FT_INTERNAL_ORIGINAL_ON_PRESS__ = originalOnPress;
|
|
33
|
-
}
|
|
34
|
-
return originalFunction(element, props, ...rest);
|
|
35
|
-
};
|
|
36
|
-
static startTracking(): void {
|
|
37
|
-
if (FTRumActionTracking.isTracking) {
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
const original = React.createElement
|
|
41
|
-
React.createElement = (
|
|
42
|
-
...args: Parameters<typeof React.createElement>
|
|
43
|
-
): any => {
|
|
44
|
-
return this.patchCreateElementFunction(original, args);
|
|
45
|
-
};
|
|
46
|
-
try {
|
|
47
|
-
const jsxRuntime = getJsxRuntime();
|
|
48
|
-
const originaljsx = jsxRuntime.jsx;
|
|
49
|
-
this.originalJsx = originaljsx;
|
|
50
|
-
jsxRuntime.jsx = (
|
|
51
|
-
...args: Parameters<typeof React.createElement>
|
|
52
|
-
): ReturnType<typeof React.createElement> => {
|
|
53
|
-
return this.patchCreateElementFunction(originaljsx, args);
|
|
54
|
-
};
|
|
55
|
-
} catch (e) {
|
|
56
|
-
|
|
57
|
-
}
|
|
12
|
+
private static patchCreateElementFunction = (
|
|
13
|
+
originalFunction: typeof React.createElement,
|
|
14
|
+
[element, props, ...rest]: Parameters<typeof React.createElement>
|
|
15
|
+
): ReturnType<typeof React.createElement> => {
|
|
16
|
+
if (
|
|
17
|
+
props &&
|
|
18
|
+
typeof (props as Record<string, unknown>).onPress === 'function'
|
|
19
|
+
) {
|
|
20
|
+
const originalOnPress = (props as Record<string, unknown>) // eslint-disable-next-line @typescript-eslint/ban-types
|
|
21
|
+
.onPress as Function;
|
|
22
|
+
(props as Record<string, unknown>).onPress = (...args: any[]) => {
|
|
23
|
+
FTRumActionTracking.interceptOnPress(...args);
|
|
24
|
+
return originalOnPress(...args);
|
|
25
|
+
};
|
|
58
26
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
27
|
+
(props as Record<string, unknown>).__FT_INTERNAL_ORIGINAL_ON_PRESS__ =
|
|
28
|
+
originalOnPress;
|
|
29
|
+
}
|
|
30
|
+
return originalFunction(element, props, ...rest);
|
|
31
|
+
};
|
|
32
|
+
static startTracking(): void {
|
|
33
|
+
if (FTRumActionTracking.isTracking) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const original = React.createElement;
|
|
37
|
+
React.createElement = (
|
|
38
|
+
...args: Parameters<typeof React.createElement>
|
|
39
|
+
): any => {
|
|
40
|
+
return this.patchCreateElementFunction(original, args);
|
|
41
|
+
};
|
|
42
|
+
try {
|
|
43
|
+
const jsxRuntime = getJsxRuntime();
|
|
44
|
+
const originaljsx = jsxRuntime.jsx;
|
|
45
|
+
this.originalJsx = originaljsx;
|
|
46
|
+
jsxRuntime.jsx = (
|
|
47
|
+
...args: Parameters<typeof React.createElement>
|
|
48
|
+
): ReturnType<typeof React.createElement> => {
|
|
49
|
+
return this.patchCreateElementFunction(originaljsx, args);
|
|
50
|
+
};
|
|
51
|
+
} catch (e) {
|
|
52
|
+
// Ignore missing jsx runtime support on older React versions.
|
|
53
|
+
}
|
|
70
54
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
55
|
+
const originalMemo = React.memo;
|
|
56
|
+
React.memo = (
|
|
57
|
+
component: any,
|
|
58
|
+
propsAreEqual?: (prevProps: any, newProps: any) => boolean
|
|
59
|
+
) => {
|
|
60
|
+
return originalMemo(component, (prev, next) => {
|
|
61
|
+
if (!next.onPress || !prev.onPress) {
|
|
62
|
+
return propsAreEqual
|
|
63
|
+
? propsAreEqual(prev, next)
|
|
64
|
+
: areObjectShallowEqual(prev, next);
|
|
65
|
+
}
|
|
76
66
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
68
|
+
const { onPress: _prevOnPress, ...partialPrevProps } = prev;
|
|
69
|
+
const prevProps = {
|
|
70
|
+
...partialPrevProps,
|
|
71
|
+
onPress: prev.__FT_INTERNAL_ORIGINAL_ON_PRESS__,
|
|
72
|
+
};
|
|
82
73
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
75
|
+
const { onPress: _nextOnPress, ...partialNextProps } = next;
|
|
76
|
+
const nextProps = {
|
|
77
|
+
...partialNextProps,
|
|
78
|
+
onPress: next.__FT_INTERNAL_ORIGINAL_ON_PRESS__,
|
|
87
79
|
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
80
|
+
|
|
81
|
+
return propsAreEqual
|
|
82
|
+
? propsAreEqual(prevProps, nextProps)
|
|
83
|
+
: areObjectShallowEqual(nextProps, prevProps);
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
FTRumActionTracking.isTracking = true;
|
|
87
|
+
}
|
|
88
|
+
static stopTracking() {
|
|
89
|
+
React.createElement = this.originalCreateElement;
|
|
90
|
+
React.memo = this.originalMemo;
|
|
91
|
+
FTRumActionTracking.isTracking = false;
|
|
92
|
+
if (this.originalJsx) {
|
|
93
|
+
const jsxRuntime = getJsxRuntime();
|
|
94
|
+
jsxRuntime.jsx = this.originalJsx;
|
|
95
|
+
this.originalJsx = null;
|
|
99
96
|
}
|
|
97
|
+
}
|
|
100
98
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
99
|
+
private static interceptOnPress(...args: any[]): void {
|
|
100
|
+
if (args.length > 0 && args[0] && args[0]._targetInst) {
|
|
101
|
+
const currentTime = Date.now();
|
|
102
|
+
const timestampDifference = Math.abs(
|
|
103
|
+
Date.now() - FTRumActionTracking.preActionTimestamp
|
|
104
|
+
);
|
|
105
|
+
if (timestampDifference > 10) {
|
|
106
|
+
const targetNode = args[0]._targetInst;
|
|
107
|
+
this.handleTargetEvent(targetNode);
|
|
108
|
+
FTRumActionTracking.preActionTimestamp = currentTime;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
FTReactNativeRUM.startAction(elementTypeName, 'click');
|
|
132
|
-
}
|
|
133
|
-
}
|
|
113
|
+
private static handleTargetEvent(targetNode: any | null) {
|
|
114
|
+
if (targetNode) {
|
|
115
|
+
const enable = FTRumActionTracking.findActionEnableTrack(targetNode);
|
|
116
|
+
if (enable) {
|
|
117
|
+
const extraProperty =
|
|
118
|
+
FTRumActionTracking.findActionProperty(targetNode);
|
|
119
|
+
const elementTypeName =
|
|
120
|
+
FTRumActionTracking.resolveActionName(targetNode);
|
|
121
|
+
if (elementTypeName) {
|
|
122
|
+
let jsonObject = null;
|
|
123
|
+
if (extraProperty) {
|
|
124
|
+
try {
|
|
125
|
+
jsonObject = JSON.parse(extraProperty);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.warn(
|
|
128
|
+
`Error parsing JSON string ${extraProperty}:`,
|
|
129
|
+
error
|
|
130
|
+
);
|
|
134
131
|
}
|
|
132
|
+
}
|
|
133
|
+
if (jsonObject) {
|
|
134
|
+
FTReactNativeRUM.startAction(elementTypeName, 'click', jsonObject);
|
|
135
|
+
} else {
|
|
136
|
+
FTReactNativeRUM.startAction(elementTypeName, 'click');
|
|
137
|
+
}
|
|
135
138
|
}
|
|
139
|
+
}
|
|
136
140
|
}
|
|
141
|
+
}
|
|
137
142
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
const accessibilityRole = targetNode.memoizedProps?.accessibilityRole;
|
|
144
|
-
let subTitle = '';
|
|
145
|
-
let children = targetNode.memoizedProps?.children;
|
|
146
|
-
while (children){
|
|
147
|
-
if(Array.isArray(children) && children.length>0 && children[0]){
|
|
148
|
-
children = children[0];
|
|
149
|
-
}else if(typeof children === 'object' && children.props && children.props.children){
|
|
150
|
-
children = children.props.children;
|
|
151
|
-
}else if(typeof children === 'string'){
|
|
152
|
-
subTitle = children;
|
|
153
|
-
children = null;
|
|
154
|
-
}else{
|
|
155
|
-
children = null;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
let elementTypeName = accessibilityRole;
|
|
159
|
-
if(!accessibilityRole){
|
|
160
|
-
let elementType = targetNode.elementType;
|
|
161
|
-
if (typeof elementType === "string") {
|
|
162
|
-
elementTypeName = elementType
|
|
163
|
-
} else if (elementType && typeof elementType.name === "string") {
|
|
164
|
-
elementTypeName = elementType.name
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
if(elementTypeName){
|
|
168
|
-
return '['+elementTypeName+']'+subTitle;
|
|
169
|
-
}
|
|
170
|
-
return null;
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
private static findActionProperty(targetNode: any): string | null {
|
|
174
|
-
let currentNode = targetNode;
|
|
175
|
-
while (currentNode) {
|
|
176
|
-
const props = currentNode.memoizedProps;
|
|
177
|
-
if (props && props[FT_EXTRA_PROPERTY]) {
|
|
178
|
-
return props[FT_EXTRA_PROPERTY];
|
|
179
|
-
}
|
|
180
|
-
currentNode = currentNode.return;
|
|
181
|
-
}
|
|
182
|
-
return null;
|
|
143
|
+
private static resolveActionName(targetNode: any): string | null {
|
|
144
|
+
const accessibilityLabel = targetNode.memoizedProps?.accessibilityLabel;
|
|
145
|
+
if (accessibilityLabel != null) {
|
|
146
|
+
return accessibilityLabel;
|
|
183
147
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
148
|
+
const accessibilityRole = targetNode.memoizedProps?.accessibilityRole;
|
|
149
|
+
let subTitle = '';
|
|
150
|
+
let children = targetNode.memoizedProps?.children;
|
|
151
|
+
while (children) {
|
|
152
|
+
if (Array.isArray(children) && children.length > 0 && children[0]) {
|
|
153
|
+
children = children[0];
|
|
154
|
+
} else if (
|
|
155
|
+
typeof children === 'object' &&
|
|
156
|
+
children.props &&
|
|
157
|
+
children.props.children
|
|
158
|
+
) {
|
|
159
|
+
children = children.props.children;
|
|
160
|
+
} else if (typeof children === 'string') {
|
|
161
|
+
subTitle = children;
|
|
162
|
+
children = null;
|
|
163
|
+
} else {
|
|
164
|
+
children = null;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
let elementTypeName = accessibilityRole;
|
|
168
|
+
if (!accessibilityRole) {
|
|
169
|
+
let elementType = targetNode.elementType;
|
|
170
|
+
if (typeof elementType === 'string') {
|
|
171
|
+
elementTypeName = elementType;
|
|
172
|
+
} else if (elementType && typeof elementType.name === 'string') {
|
|
173
|
+
elementTypeName = elementType.name;
|
|
174
|
+
}
|
|
196
175
|
}
|
|
176
|
+
if (elementTypeName) {
|
|
177
|
+
return '[' + elementTypeName + ']' + subTitle;
|
|
178
|
+
}
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
private static findActionProperty(targetNode: any): string | null {
|
|
182
|
+
let currentNode = targetNode;
|
|
183
|
+
while (currentNode) {
|
|
184
|
+
const props = currentNode.memoizedProps;
|
|
185
|
+
if (props && props[FT_EXTRA_PROPERTY]) {
|
|
186
|
+
return props[FT_EXTRA_PROPERTY];
|
|
187
|
+
}
|
|
188
|
+
currentNode = currentNode.return;
|
|
189
|
+
}
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
private static findActionEnableTrack(targetNode: any): boolean {
|
|
193
|
+
let currentNode = targetNode;
|
|
194
|
+
let enable = true;
|
|
195
|
+
while (currentNode) {
|
|
196
|
+
const props = currentNode.memoizedProps;
|
|
197
|
+
if (props && props[FT_ENABLE_TRACK]) {
|
|
198
|
+
enable = props[FT_ENABLE_TRACK] === 'true';
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
currentNode = currentNode.return;
|
|
202
|
+
}
|
|
203
|
+
return enable;
|
|
204
|
+
}
|
|
197
205
|
}
|
|
198
206
|
|
|
199
207
|
const areObjectShallowEqual = (
|
|
200
|
-
|
|
201
|
-
|
|
208
|
+
objectA: Record<string, unknown> | undefined | null,
|
|
209
|
+
objectB: Record<string, unknown> | undefined | null
|
|
202
210
|
): boolean => {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
211
|
+
if (!objectA || !objectB) {
|
|
212
|
+
return objectA === objectB;
|
|
213
|
+
}
|
|
206
214
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
const keys = Object.keys(objectA);
|
|
216
|
+
if (keys.length !== Object.keys(objectB).length) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
for (const key of keys) {
|
|
220
|
+
if (objectA[key] !== objectB[key]) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return true;
|
|
217
225
|
};
|
|
218
226
|
const getJsxRuntime = () => {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
227
|
+
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
228
|
+
const [major, minor] = require('react/package.json').version.split('.');
|
|
229
|
+
// JSX Transform applies to > 16.14.0
|
|
230
|
+
if (Number(major) <= 16 && Number(minor) < 14) {
|
|
231
|
+
throw new Error('React version does not support new jsx transform');
|
|
232
|
+
}
|
|
225
233
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
234
|
+
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
235
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
236
|
+
if (!jsxRuntime.jsx) {
|
|
237
|
+
throw new Error('React jsx runtime does not export new jsx transform');
|
|
238
|
+
}
|
|
239
|
+
return jsxRuntime;
|
|
232
240
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ErrorHandlerCallback } from 'react-native';
|
|
2
2
|
import { FTReactNativeRUM } from '../ft_rum';
|
|
3
3
|
const EMPTY_MESSAGE = 'Unknown Error';
|
|
4
|
-
const CONSOLE_ERROR =
|
|
4
|
+
const CONSOLE_ERROR = 'console_error';
|
|
5
5
|
|
|
6
6
|
export class FTRumErrorTracking {
|
|
7
7
|
private static isTracking = false;
|
|
@@ -9,13 +9,16 @@ export class FTRumErrorTracking {
|
|
|
9
9
|
private static isInDefaultErrorHandler = false;
|
|
10
10
|
|
|
11
11
|
// Original error handler method
|
|
12
|
-
private static defaultErrorHandler: ErrorHandlerCallback = (
|
|
12
|
+
private static defaultErrorHandler: ErrorHandlerCallback = (
|
|
13
|
+
_error: any,
|
|
14
|
+
_isFatal?: boolean
|
|
15
|
+
) => {};
|
|
13
16
|
|
|
14
17
|
// Original console error handler method
|
|
15
|
-
private static defaultConsoleError = (..._params: unknown[]) => {
|
|
18
|
+
private static defaultConsoleError = (..._params: unknown[]) => {};
|
|
16
19
|
|
|
17
20
|
static startTracking(): void {
|
|
18
|
-
if(FTRumErrorTracking.isTracking){
|
|
21
|
+
if (FTRumErrorTracking.isTracking) {
|
|
19
22
|
return;
|
|
20
23
|
}
|
|
21
24
|
if (ErrorUtils) {
|
|
@@ -29,82 +32,78 @@ export class FTRumErrorTracking {
|
|
|
29
32
|
static onGlobalError(error: any, isFatal?: boolean): void {
|
|
30
33
|
const message = FTRumErrorTracking.getErrorMessage(error);
|
|
31
34
|
const stacktrace = FTRumErrorTracking.getErrorStackTrace(error);
|
|
32
|
-
FTReactNativeRUM.addError(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
FTRumErrorTracking.defaultErrorHandler(error, isFatal);
|
|
40
|
-
} finally {
|
|
41
|
-
FTRumErrorTracking.isInDefaultErrorHandler = false;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static onConsoleError(...params: unknown[]): void {
|
|
47
|
-
if ( FTRumErrorTracking.isInDefaultErrorHandler) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
let stack: string = '';
|
|
52
|
-
for (let i = 0; i < params.length; i += 1) {
|
|
53
|
-
const param = params[i];
|
|
54
|
-
const paramStack = FTRumErrorTracking.getErrorStackTrace(param);
|
|
55
|
-
if (paramStack != undefined && paramStack != '') {
|
|
56
|
-
stack = paramStack;
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
35
|
+
FTReactNativeRUM.addError(stacktrace, message).then(() => {
|
|
36
|
+
try {
|
|
37
|
+
FTRumErrorTracking.isInDefaultErrorHandler = true;
|
|
38
|
+
//Call the original error handler method
|
|
39
|
+
FTRumErrorTracking.defaultErrorHandler(error, isFatal);
|
|
40
|
+
} finally {
|
|
41
|
+
FTRumErrorTracking.isInDefaultErrorHandler = false;
|
|
59
42
|
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
60
45
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
FTReactNativeRUM.addErrorWithType(
|
|
68
|
-
CONSOLE_ERROR,
|
|
69
|
-
stack,
|
|
70
|
-
message,
|
|
71
|
-
).then(() => {
|
|
72
|
-
FTRumErrorTracking.defaultConsoleError.apply(console, params);
|
|
73
|
-
});
|
|
46
|
+
static onConsoleError(...params: unknown[]): void {
|
|
47
|
+
if (FTRumErrorTracking.isInDefaultErrorHandler) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
74
50
|
|
|
51
|
+
let stack: string = '';
|
|
52
|
+
for (let i = 0; i < params.length; i += 1) {
|
|
53
|
+
const param = params[i];
|
|
54
|
+
const paramStack = FTRumErrorTracking.getErrorStackTrace(param);
|
|
55
|
+
if (paramStack !== '') {
|
|
56
|
+
stack = paramStack;
|
|
57
|
+
break;
|
|
75
58
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const message = params
|
|
62
|
+
.map((param) => {
|
|
63
|
+
if (typeof param === 'string') {
|
|
64
|
+
return param;
|
|
82
65
|
} else {
|
|
83
|
-
|
|
66
|
+
return FTRumErrorTracking.getErrorMessage(param);
|
|
84
67
|
}
|
|
68
|
+
})
|
|
69
|
+
.join(' ');
|
|
85
70
|
|
|
86
|
-
|
|
71
|
+
FTReactNativeRUM.addErrorWithType(CONSOLE_ERROR, stack, message).then(
|
|
72
|
+
() => {
|
|
73
|
+
FTRumErrorTracking.defaultConsoleError.apply(console, params);
|
|
87
74
|
}
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
private static getErrorMessage(error: any | undefined): string {
|
|
78
|
+
let message = EMPTY_MESSAGE;
|
|
79
|
+
if (error == null) {
|
|
80
|
+
message = EMPTY_MESSAGE;
|
|
81
|
+
} else if (typeof error === 'object' && 'message' in error) {
|
|
82
|
+
message = String(error.message);
|
|
83
|
+
} else {
|
|
84
|
+
message = String(error);
|
|
85
|
+
}
|
|
88
86
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (error == undefined) {
|
|
93
|
-
stack = '';
|
|
94
|
-
} else if (typeof error === 'string') {
|
|
95
|
-
stack = '';
|
|
96
|
-
} else if ('componentStack' in error) {
|
|
97
|
-
stack = String(error.componentStack);
|
|
98
|
-
} else if ('stacktrace' in error) {
|
|
99
|
-
stack = String(error.stacktrace);
|
|
100
|
-
} else if ('stack' in error) {
|
|
101
|
-
stack = String(error.stack);
|
|
102
|
-
} else if (('sourceURL' in error) && ('line' in error) && ('column' in error)) {
|
|
103
|
-
stack = `at ${error.sourceURL}:${error.line}:${error.column}`;
|
|
104
|
-
}
|
|
87
|
+
return message;
|
|
88
|
+
}
|
|
105
89
|
|
|
106
|
-
|
|
107
|
-
|
|
90
|
+
private static getErrorStackTrace(error: any | undefined): string {
|
|
91
|
+
let stack = '';
|
|
92
|
+
|
|
93
|
+
if (error == null) {
|
|
94
|
+
stack = '';
|
|
95
|
+
} else if (typeof error === 'string') {
|
|
96
|
+
stack = '';
|
|
97
|
+
} else if ('componentStack' in error) {
|
|
98
|
+
stack = String(error.componentStack);
|
|
99
|
+
} else if ('stacktrace' in error) {
|
|
100
|
+
stack = String(error.stacktrace);
|
|
101
|
+
} else if ('stack' in error) {
|
|
102
|
+
stack = String(error.stack);
|
|
103
|
+
} else if ('sourceURL' in error && 'line' in error && 'column' in error) {
|
|
104
|
+
stack = `at ${error.sourceURL}:${error.line}:${error.column}`;
|
|
108
105
|
}
|
|
109
106
|
|
|
110
|
-
|
|
107
|
+
return stack;
|
|
108
|
+
}
|
|
109
|
+
}
|