@truewatchtech/react-native-mobile 0.3.15 → 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.
Files changed (113) hide show
  1. package/FTMobileReactNativeSDK.podspec +32 -2
  2. package/android/build.gradle +10 -4
  3. package/android/src/main/java/com/ft/sdk/reactnative/FTMobileImpl.java +434 -5
  4. package/android/src/main/java/com/ft/sdk/reactnative/FTRUMImpl.java +12 -0
  5. package/android/src/main/java/com/ft/sdk/reactnative/FTTraceImpl.java +1 -1
  6. package/android/src/newarch/java/com/ft/sdk/reactnative/FTLogModule.java +7 -14
  7. package/android/src/newarch/java/com/ft/sdk/reactnative/FTMobileModule.java +46 -12
  8. package/android/src/newarch/java/com/ft/sdk/reactnative/FTRUMModule.java +12 -13
  9. package/android/src/newarch/java/com/ft/sdk/reactnative/FTTraceModule.java +6 -8
  10. package/android/src/oldarch/java/com/ft/sdk/reactnative/FTMobileModule.java +34 -2
  11. package/android/src/rnpost74/java/com/ft/sdk/reactnative/FTMobilePackage.java +14 -4
  12. package/android/src/rnpre74/java/com/ft/sdk/reactnative/FTMobilePackage.java +0 -2
  13. package/ios/FTMobileReactNative.h +9 -5
  14. package/ios/FTMobileReactNative.mm +619 -0
  15. package/ios/FTReactNativeLog.h +8 -3
  16. package/ios/FTReactNativeLog.mm +79 -0
  17. package/ios/FTReactNativeRUM.h +8 -4
  18. package/ios/{FTReactNativeRUM.m → FTReactNativeRUM.mm} +143 -84
  19. package/ios/FTReactNativeTrace.h +7 -3
  20. package/ios/FTReactNativeTrace.mm +74 -0
  21. package/ios/FtMobileAgent.xcodeproj/project.pbxproj +22 -0
  22. package/lib/commonjs/ft_logger.js +14 -13
  23. package/lib/commonjs/ft_logger.js.map +1 -1
  24. package/lib/commonjs/ft_mobile_agent.js +153 -6
  25. package/lib/commonjs/ft_mobile_agent.js.map +1 -1
  26. package/lib/commonjs/ft_rum.js +55 -21
  27. package/lib/commonjs/ft_rum.js.map +1 -1
  28. package/lib/commonjs/ft_tracing.js +29 -10
  29. package/lib/commonjs/ft_tracing.js.map +1 -1
  30. package/lib/commonjs/index.js +30 -0
  31. package/lib/commonjs/index.js.map +1 -1
  32. package/lib/commonjs/rum/FTRumActionTracking.js +10 -4
  33. package/lib/commonjs/rum/FTRumActionTracking.js.map +1 -1
  34. package/lib/commonjs/rum/FTRumErrorTracking.js +4 -4
  35. package/lib/commonjs/rum/FTRumErrorTracking.js.map +1 -1
  36. package/lib/commonjs/specs/NativeFTMobileReactNative.js +10 -0
  37. package/lib/commonjs/specs/NativeFTMobileReactNative.js.map +1 -0
  38. package/lib/commonjs/specs/NativeFTReactNativeLog.js +10 -0
  39. package/lib/commonjs/specs/NativeFTReactNativeLog.js.map +1 -0
  40. package/lib/commonjs/specs/NativeFTReactNativeRUM.js +10 -0
  41. package/lib/commonjs/specs/NativeFTReactNativeRUM.js.map +1 -0
  42. package/lib/commonjs/specs/NativeFTReactNativeTrace.js +10 -0
  43. package/lib/commonjs/specs/NativeFTReactNativeTrace.js.map +1 -0
  44. package/lib/commonjs/version.js +1 -1
  45. package/lib/commonjs/version.js.map +1 -1
  46. package/lib/module/ft_logger.js +14 -12
  47. package/lib/module/ft_logger.js.map +1 -1
  48. package/lib/module/ft_mobile_agent.js +159 -5
  49. package/lib/module/ft_mobile_agent.js.map +1 -1
  50. package/lib/module/ft_rum.js +54 -16
  51. package/lib/module/ft_rum.js.map +1 -1
  52. package/lib/module/ft_tracing.js +29 -9
  53. package/lib/module/ft_tracing.js.map +1 -1
  54. package/lib/module/index.js +3 -3
  55. package/lib/module/index.js.map +1 -1
  56. package/lib/module/rum/FTRumActionTracking.js +10 -4
  57. package/lib/module/rum/FTRumActionTracking.js.map +1 -1
  58. package/lib/module/rum/FTRumErrorTracking.js +4 -4
  59. package/lib/module/rum/FTRumErrorTracking.js.map +1 -1
  60. package/lib/module/specs/NativeFTMobileReactNative.js +5 -0
  61. package/lib/module/specs/NativeFTMobileReactNative.js.map +1 -0
  62. package/lib/module/specs/NativeFTReactNativeLog.js +5 -0
  63. package/lib/module/specs/NativeFTReactNativeLog.js.map +1 -0
  64. package/lib/module/specs/NativeFTReactNativeRUM.js +5 -0
  65. package/lib/module/specs/NativeFTReactNativeRUM.js.map +1 -0
  66. package/lib/module/specs/NativeFTReactNativeTrace.js +5 -0
  67. package/lib/module/specs/NativeFTReactNativeTrace.js.map +1 -0
  68. package/lib/module/version.js +1 -1
  69. package/lib/module/version.js.map +1 -1
  70. package/lib/typescript/ft_logger.d.ts +6 -6
  71. package/lib/typescript/ft_mobile_agent.d.ts +165 -14
  72. package/lib/typescript/ft_rum.d.ts +32 -8
  73. package/lib/typescript/ft_tracing.d.ts +6 -6
  74. package/lib/typescript/index.d.ts +3 -3
  75. package/lib/typescript/specs/NativeFTMobileReactNative.d.ts +75 -0
  76. package/lib/typescript/specs/NativeFTReactNativeLog.d.ts +23 -0
  77. package/lib/typescript/specs/NativeFTReactNativeRUM.d.ts +89 -0
  78. package/lib/typescript/specs/NativeFTReactNativeTrace.d.ts +24 -0
  79. package/lib/typescript/version.d.ts +1 -1
  80. package/package.json +29 -96
  81. package/scripts/replace-react-require.js +37 -38
  82. package/src/ft_logger.tsx +71 -40
  83. package/src/ft_mobile_agent.tsx +374 -92
  84. package/src/ft_rum.tsx +227 -123
  85. package/src/ft_tracing.tsx +58 -38
  86. package/src/index.tsx +58 -16
  87. package/src/rum/FTRumActionTracking.tsx +212 -204
  88. package/src/rum/FTRumErrorTracking.tsx +70 -71
  89. package/src/specs/NativeFTMobileReactNative.ts +83 -0
  90. package/src/specs/NativeFTReactNativeLog.ts +29 -0
  91. package/src/specs/NativeFTReactNativeRUM.ts +104 -0
  92. package/src/specs/NativeFTReactNativeTrace.ts +26 -0
  93. package/src/version.ts +1 -1
  94. package/LICENSE +0 -201
  95. package/android/.project +0 -17
  96. package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
  97. package/android/gradlew +0 -185
  98. package/android/local.properties +0 -8
  99. package/android/src/main/java/com/ft/sdk/InnerClassProxy.java +0 -8
  100. package/ios/.idea/.name +0 -1
  101. package/ios/.idea/ios.iml +0 -2
  102. package/ios/.idea/modules.xml +0 -8
  103. package/ios/.idea/vcs.xml +0 -6
  104. package/ios/.idea/xcode.xml +0 -4
  105. package/ios/FTMobileReactNative.m +0 -183
  106. package/ios/FTReactNativeLog.m +0 -60
  107. package/ios/FTReactNativeTrace.m +0 -58
  108. package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
  109. package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/xcuserdata/Brandon.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  110. package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/xcuserdata/Brandon.xcuserdatad/xcschemes/xcschememanagement.plist +0 -5
  111. package/ios/FtMobileAgent.xcodeproj/xcuserdata/Brandon.xcuserdatad/xcschemes/FtMobileAgent.xcscheme +0 -56
  112. package/ios/FtMobileAgent.xcodeproj/xcuserdata/Brandon.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  113. package/ios/RCTVersion.h +0 -8
package/src/ft_rum.tsx CHANGED
@@ -1,33 +1,73 @@
1
- import { NativeModules } from 'react-native';
2
- import { FTRumErrorTracking} from './rum/FTRumErrorTracking';
3
- import { FTRumActionTracking} from './rum/FTRumActionTracking';
1
+ // import { NativeModules } from 'react-native';
2
+ import { FTRumErrorTracking } from './rum/FTRumErrorTracking';
3
+ import { FTRumActionTracking } from './rum/FTRumActionTracking';
4
+ import { bridgeContextManager } from './ft_mobile_agent';
4
5
 
5
6
  /**
6
7
  * Error monitoring type.
7
8
  */
8
- export enum ErrorMonitorType {
9
- all=0xFFFFFFFF,
10
- battery=1 << 1,
11
- memory=1 << 2,
12
- cpu=1 << 3,
13
- }
14
- /**
15
- * Page monitoring supplement type
16
- */
17
- export enum DeviceMetricsMonitorType {
18
- all=0xFFFFFFFF,
19
- battery=1 << 1,
20
- memory=1 << 2,
21
- cpu=1 << 3,
22
- fps=1 << 4
23
- }
24
- /**
25
- * Device information monitoring cycle.
26
- */
27
- export enum DetectFrequency { normal, frequent, rare }
9
+ /* eslint-disable no-bitwise */
10
+ export enum ErrorMonitorType {
11
+ all = 0xffffffff,
12
+ battery = 1 << 1,
13
+ memory = 1 << 2,
14
+ cpu = 1 << 3,
15
+ }
16
+ /**
17
+ * Page monitoring supplement type
18
+ */
19
+ export enum DeviceMetricsMonitorType {
20
+ all = 0xffffffff,
21
+ battery = 1 << 1,
22
+ memory = 1 << 2,
23
+ cpu = 1 << 3,
24
+ fps = 1 << 4,
25
+ }
26
+ /**
27
+ * Device information monitoring cycle.
28
+ */
29
+ export enum DetectFrequency {
30
+ normal,
31
+ frequent,
32
+ rare,
33
+ }
34
+
35
+ export enum FTRUMCacheDiscard {
36
+ discard,
37
+ discardOldest,
38
+ }
39
+
40
+ export enum IOSCrashMonitoringType {
41
+ /** Monitor Mach kernel exceptions. */
42
+ machException = 0x01,
28
43
 
29
- export enum FTRUMCacheDiscard { discard, discardOldest };
44
+ /** Monitor fatal signals. */
45
+ signal = 0x02,
30
46
 
47
+ /** Monitor uncaught C++ exceptions. */
48
+ cppException = 0x04,
49
+
50
+ /** Monitor uncaught Objective-C NSExceptions. */
51
+ nsException = 0x08,
52
+
53
+ /** Track and inject system information. */
54
+ system = 0x40,
55
+
56
+ /** Track and inject application state information. */
57
+ applicationState = 0x80,
58
+
59
+ /** All crash monitor types. */
60
+ all = machException |
61
+ signal |
62
+ cppException |
63
+ nsException |
64
+ applicationState |
65
+ system,
66
+
67
+ /** High compatibility crash monitor types (excludes Mach exceptions). */
68
+ highCompatibility = all & ~machException,
69
+ }
70
+ /* eslint-enable no-bitwise */
31
71
  /**
32
72
  * Set RUM tracking conditions.
33
73
  * @param androidAppId appId, apply during monitoring
@@ -50,29 +90,35 @@ import { FTRumActionTracking} from './rum/FTRumActionTracking';
50
90
  * @param globalContext custom global parameters
51
91
  * @param rumCacheLimitCount RUM max cache size, default 100_000
52
92
  * @param rumDiscardStrategy RUM data discard strategy
93
+ * @param enableTraceWebView Set whether to enable WebView data collection, default true
94
+ * @param allowWebViewHost Set specific hosts or domains allowed to collect WebView data, nil means collect all
95
+ * @param iosCrashMonitoringType iOS crash monitoring type , default is highCompatibility, which does not include Mach exceptions for better compatibility. you must enable system crash monitoring to get crash stack traces and crash information.
53
96
  */
54
- export interface FTRUMConfig{
55
- androidAppId:string,
56
- iOSAppId:string,
57
- sampleRate?:number,
58
- sessionOnErrorSampleRate?:number,
59
- enableAutoTrackUserAction?:boolean,
60
- enableAutoTrackError?:boolean,
61
- enableTrackNativeCrash?:boolean,
62
- enableTrackNativeAppANR?:boolean,
63
- enableTrackNativeFreeze?:boolean,
64
- nativeFreezeDurationMs?:number,
65
- enableNativeUserAction?:boolean,
66
- enableNativeUserView?:boolean,
67
- enableNativeUserResource?:boolean,
68
- enableResourceHostIP?:boolean,
69
- errorMonitorType?:ErrorMonitorType,
70
- deviceMonitorType?:DeviceMetricsMonitorType,
71
- detectFrequency?:DetectFrequency
72
- globalContext?:object,
73
- rumCacheLimitCount?:number,
74
- rumDiscardStrategy?:FTRUMCacheDiscard,
75
- }
97
+ export interface FTRUMConfig {
98
+ androidAppId: string;
99
+ iOSAppId: string;
100
+ sampleRate?: number;
101
+ sessionOnErrorSampleRate?: number;
102
+ enableAutoTrackUserAction?: boolean;
103
+ enableAutoTrackError?: boolean;
104
+ enableTrackNativeCrash?: boolean;
105
+ enableTrackNativeAppANR?: boolean;
106
+ enableTrackNativeFreeze?: boolean;
107
+ nativeFreezeDurationMs?: number;
108
+ enableNativeUserAction?: boolean;
109
+ enableNativeUserView?: boolean;
110
+ enableNativeUserResource?: boolean;
111
+ enableResourceHostIP?: boolean;
112
+ errorMonitorType?: ErrorMonitorType;
113
+ deviceMonitorType?: DeviceMetricsMonitorType;
114
+ detectFrequency?: DetectFrequency;
115
+ globalContext?: object;
116
+ rumCacheLimitCount?: number;
117
+ rumDiscardStrategy?: FTRUMCacheDiscard;
118
+ enableTraceWebView?: boolean;
119
+ allowWebViewHost?: Array<string>;
120
+ iosCrashMonitoringType?: IOSCrashMonitoringType;
121
+ }
76
122
  /**
77
123
  * RUM Resource data.
78
124
  * @param url request URL
@@ -82,14 +128,14 @@ import { FTRumActionTracking} from './rum/FTRumActionTracking';
82
128
  * @param responseBody response content
83
129
  * @param resourceStatus response status code
84
130
  */
85
- export interface FTRUMResource{
86
- url:string,
87
- httpMethod:string,
88
- requestHeader:object,
89
- responseHeader?:object,
90
- responseBody?:string,
91
- resourceStatus?:number
92
- };
131
+ export interface FTRUMResource {
132
+ url: string;
133
+ httpMethod: string;
134
+ requestHeader: object;
135
+ responseHeader?: object;
136
+ responseBody?: string;
137
+ resourceStatus?: number;
138
+ }
93
139
  /**
94
140
  * RUM Resource performance metrics.
95
141
  * @param duration resource load time
@@ -100,23 +146,22 @@ import { FTRumActionTracking} from './rum/FTRumActionTracking';
100
146
  * @param resource_trans resource content transfer time
101
147
  * @param resource_first_byte resource first byte time
102
148
  */
103
- export interface FTRUMResourceMetrics{
104
-
105
- duration?:number,
106
- resource_dns?:number,
107
- resource_tcp?:number,
108
- resource_ssl?:number,
109
- resource_ttfb?:number,
110
- resource_trans?:number,
111
- resource_first_byte?:number,
112
- };
113
- type FTReactNativeRUMType = {
149
+ export interface FTRUMResourceMetrics {
150
+ duration?: number;
151
+ resource_dns?: number;
152
+ resource_tcp?: number;
153
+ resource_ssl?: number;
154
+ resource_ttfb?: number;
155
+ resource_trans?: number;
156
+ resource_first_byte?: number;
157
+ }
158
+ type FTReactNativeRUMType = {
114
159
  /**
115
160
  * Set RUM tracking conditions and enable RUM collection.
116
161
  * @param config rum configuration parameters.
117
162
  * @returns a Promise.
118
163
  */
119
- setConfig(config:FTRUMConfig): Promise<void>;
164
+ setConfig(config: FTRUMConfig): Promise<void>;
120
165
  /**
121
166
  * Start RUM Action.
122
167
  * RUM will bind Resource, Error, LongTask events that may be triggered by this Action.
@@ -127,35 +172,43 @@ import { FTRumActionTracking} from './rum/FTRumActionTracking';
127
172
  * @param property event context (optional)
128
173
  * @returns a Promise.
129
174
  */
130
- startAction(actionName:string,actionType:string,property?:object): Promise<void>;
131
- /**
175
+ startAction(
176
+ actionName: string,
177
+ actionType: string,
178
+ property?: object
179
+ ): Promise<void>;
180
+ /**
132
181
  * Add Action event. This type of data cannot be associated with Error, Resource, LongTask data, and has no discard logic.
133
182
  * @param actionName action name
134
183
  * @param actionType action type
135
184
  * @param property event context (optional)
136
185
  * @returns a Promise.
137
186
  */
138
- addAction(actionName:string,actionType:string,property?:object): Promise<void>;
187
+ addAction(
188
+ actionName: string,
189
+ actionType: string,
190
+ property?: object
191
+ ): Promise<void>;
139
192
  /**
140
193
  * view load duration.
141
194
  * @param viewName view name
142
195
  * @param loadTime view load duration
143
196
  * @returns a Promise.
144
197
  */
145
- onCreateView(viewName:string,loadTime:number): Promise<void>;
198
+ onCreateView(viewName: string, loadTime: number): Promise<void>;
146
199
  /**
147
200
  * view start.
148
201
  * @param viewName page name
149
202
  * @param property event context (optional)
150
203
  * @returns a Promise.
151
204
  */
152
- startView(viewName: string, property?: object): Promise<void>;
205
+ startView(viewName: string, property?: object): Promise<void>;
153
206
  /**
154
207
  * view end.
155
208
  * @param property event context (optional)
156
209
  * @returns a Promise.
157
210
  */
158
- stopView(property?:object): Promise<void>;
211
+ stopView(property?: object): Promise<void>;
159
212
  /**
160
213
  * Exception capture and log collection.
161
214
  * @param stack stack log
@@ -163,7 +216,7 @@ import { FTRumActionTracking} from './rum/FTRumActionTracking';
163
216
  * @param property event context (optional)
164
217
  * @returns a Promise.
165
218
  */
166
- addError(stack: string, message: string,property?:object): Promise<void>;
219
+ addError(stack: string, message: string, property?: object): Promise<void>;
167
220
  /**
168
221
  * Exception capture and log collection.
169
222
  * @param type error type
@@ -172,21 +225,26 @@ import { FTRumActionTracking} from './rum/FTRumActionTracking';
172
225
  * @param property event context (optional)
173
226
  * @returns a Promise.
174
227
  */
175
- addErrorWithType(type:string,stack: string, message: string,property?:object): Promise<void>;
228
+ addErrorWithType(
229
+ type: string,
230
+ stack: string,
231
+ message: string,
232
+ property?: object
233
+ ): Promise<void>;
176
234
  /**
177
235
  * Start resource request.
178
236
  * @param key unique id
179
237
  * @param property event context (optional)
180
238
  * @returns a Promise.
181
239
  */
182
- startResource(key: string,property?:object): Promise<void>;
240
+ startResource(key: string, property?: object): Promise<void>;
183
241
  /**
184
242
  * End resource request.
185
243
  * @param key unique id
186
244
  * @param property event context (optional)
187
245
  * @returns a Promise.
188
246
  */
189
- stopResource(key: string,property?:object): Promise<void>;
247
+ stopResource(key: string, property?: object): Promise<void>;
190
248
  /**
191
249
  * Send resource data metrics.
192
250
  * @param key unique id
@@ -194,54 +252,100 @@ import { FTRumActionTracking} from './rum/FTRumActionTracking';
194
252
  * @param metrics resource performance data
195
253
  * @returns a Promise.
196
254
  */
197
- addResource(key:string, resource:FTRUMResource,metrics?:FTRUMResourceMetrics):Promise<void>;
198
- }
199
-
200
- class FTReactNativeRUMWrapper implements FTReactNativeRUMType {
201
- private rum: FTReactNativeRUMType = NativeModules.FTReactNativeRUM;
255
+ addResource(
256
+ key: string,
257
+ resource: FTRUMResource,
258
+ metrics?: FTRUMResourceMetrics
259
+ ): Promise<void>;
260
+ };
202
261
 
262
+ class FTReactNativeRUMWrapper implements FTReactNativeRUMType {
263
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
264
+ private rum: FTReactNativeRUMType = require('./specs/NativeFTReactNativeRUM')
265
+ .default;
203
266
 
204
- setConfig(config:FTRUMConfig): Promise<void>{
205
- console.log('FTRUMConfig');
206
- if(config.enableAutoTrackError){
207
- FTRumErrorTracking.startTracking();
208
- }
209
- if(config.enableAutoTrackUserAction){
210
- FTRumActionTracking.startTracking();
211
- }
212
- return this.rum.setConfig(config);
213
- }
214
- startAction(actionName:string,actionType:string,property?:object): Promise<void>{
215
- return this.rum.startAction(actionName,actionType,property);
216
- }
217
- addAction(actionName: string, actionType: string, property?: object): Promise<void> {
218
- return this.rum.addAction(actionName,actionType,property);
219
- }
220
- onCreateView(viewName:string,loadTime:number): Promise<void>{
221
- return this.rum.onCreateView(viewName,loadTime);
222
- }
223
- startView(viewName: string, property?:object): Promise<void>{
224
- return this.rum.startView(viewName,property);
225
- }
226
- stopView(property?:object): Promise<void>{
227
- return this.rum.stopView(property);
228
- }
229
- addError(stack: string, message: string,property?:object): Promise<void>{
230
- return this.rum.addError(stack,message,property);
231
- }
232
- addErrorWithType(type:string,stack: string, message: string,property?:object): Promise<void>{
233
- return this.rum.addErrorWithType(type,stack,message,property);
267
+ setConfig(config: FTRUMConfig): Promise<void> {
268
+ console.log('FTRUMConfig');
269
+ if (config.enableAutoTrackError) {
270
+ FTRumErrorTracking.startTracking();
271
+ }
272
+ if (config.enableAutoTrackUserAction) {
273
+ FTRumActionTracking.startTracking();
274
+ }
275
+ return this.rum.setConfig(config);
234
276
  }
235
- startResource(key: string,property?:object): Promise<void>{
236
- return this.rum.startResource(key,property);
237
- }
238
- stopResource(key: string,property?:object): Promise<void>{
239
- return this.rum.stopResource(key,property);
240
- }
241
- addResource(key:string, resource:FTRUMResource,metrics:FTRUMResourceMetrics={}):Promise<void>{
242
- return this.rum.addResource(key,resource,metrics);
243
- }
244
- }
245
-
246
- export const FTReactNativeRUM: FTReactNativeRUMType = new FTReactNativeRUMWrapper();
277
+ startAction(
278
+ actionName: string,
279
+ actionType: string,
280
+ property?: object
281
+ ): Promise<void> {
282
+ // Automatically merge bridge context properties with local properties
283
+ const mergedProperties =
284
+ bridgeContextManager.mergeWithLocalPropertiesSync(property);
285
+ return this.rum.startAction(actionName, actionType, mergedProperties);
286
+ }
287
+ addAction(
288
+ actionName: string,
289
+ actionType: string,
290
+ property?: object
291
+ ): Promise<void> {
292
+ // Automatically merge bridge context properties with local properties
293
+ const mergedProperties =
294
+ bridgeContextManager.mergeWithLocalPropertiesSync(property);
295
+ return this.rum.addAction(actionName, actionType, mergedProperties);
296
+ }
297
+ onCreateView(viewName: string, loadTime: number): Promise<void> {
298
+ return this.rum.onCreateView(viewName, loadTime);
299
+ }
300
+ startView(viewName: string, property?: object): Promise<void> {
301
+ // Automatically merge bridge context properties with local properties
302
+ const mergedProperties =
303
+ bridgeContextManager.mergeWithLocalPropertiesSync(property);
304
+ return this.rum.startView(viewName, mergedProperties);
305
+ }
306
+ stopView(property?: object): Promise<void> {
307
+ // Automatically merge bridge context properties with local properties
308
+ const mergedProperties =
309
+ bridgeContextManager.mergeWithLocalPropertiesSync(property);
310
+ return this.rum.stopView(mergedProperties);
311
+ }
312
+ addError(stack: string, message: string, property?: object): Promise<void> {
313
+ // Automatically merge bridge context properties with local properties
314
+ const mergedProperties =
315
+ bridgeContextManager.mergeWithLocalPropertiesSync(property);
316
+ return this.rum.addError(stack, message, mergedProperties);
317
+ }
318
+ addErrorWithType(
319
+ type: string,
320
+ stack: string,
321
+ message: string,
322
+ property?: object
323
+ ): Promise<void> {
324
+ // Automatically merge bridge context properties with local properties
325
+ const mergedProperties =
326
+ bridgeContextManager.mergeWithLocalPropertiesSync(property);
327
+ return this.rum.addErrorWithType(type, stack, message, mergedProperties);
328
+ }
329
+ startResource(key: string, property?: object): Promise<void> {
330
+ // Automatically merge bridge context properties with local properties
331
+ const mergedProperties =
332
+ bridgeContextManager.mergeWithLocalPropertiesSync(property);
333
+ return this.rum.startResource(key, mergedProperties);
334
+ }
335
+ stopResource(key: string, property?: object): Promise<void> {
336
+ // Automatically merge bridge context properties with local properties
337
+ const mergedProperties =
338
+ bridgeContextManager.mergeWithLocalPropertiesSync(property);
339
+ return this.rum.stopResource(key, mergedProperties);
340
+ }
341
+ addResource(
342
+ key: string,
343
+ resource: FTRUMResource,
344
+ metrics: FTRUMResourceMetrics = {}
345
+ ): Promise<void> {
346
+ return this.rum.addResource(key, resource, metrics);
347
+ }
348
+ }
247
349
 
350
+ export const FTReactNativeRUM: FTReactNativeRUMType =
351
+ new FTReactNativeRUMWrapper();
@@ -1,17 +1,36 @@
1
- import { NativeModules } from 'react-native';
1
+ // import { NativeModules } from 'react-native';
2
2
  //FTReactNativeTrace
3
3
 
4
4
  /**
5
5
  * Trace types for use.
6
6
  */
7
- export enum TraceType {
8
- ddTrace,
9
- zipkinMulti,
10
- zipkinSingle,
11
- traceparent,
12
- skywalking,
13
- jaeger,
14
- };
7
+ export enum TraceType {
8
+ //
9
+ // datadog trace
10
+ //
11
+ // x-datadog-trace-id
12
+ // x-datadog-parent-id
13
+ // x-datadog-sampling-priority
14
+ // x-datadog-origin
15
+ //
16
+ ddTrace,
17
+ //
18
+ // zipkin multi header
19
+ //
20
+ // X-B3-TraceId
21
+ // X-B3-SpanId
22
+ // X-B3-Sampled
23
+ //
24
+ zipkinMulti,
25
+ /// zipkin single header,b3
26
+ zipkinSingle,
27
+ // w3c, traceparent
28
+ traceparent,
29
+ // skywalking 8.0+, sw-8
30
+ skywalking,
31
+ // jaeger, header uber-trace-id
32
+ jaeger,
33
+ }
15
34
  /**
16
35
  * Configure trace.
17
36
  * @param sampleRate sampling rate
@@ -19,61 +38,62 @@ import { NativeModules } from 'react-native';
19
38
  * @param enableLinkRUMData whether to link with RUM data
20
39
  * @param enableNativeAutoTrace whether to enable automatic tracing
21
40
  */
22
- export interface FTTraceConfig{
23
- sampleRate?:number,
24
- traceType?:TraceType,
25
- enableLinkRUMData?:boolean,
26
- enableNativeAutoTrace?:boolean,
27
- };
41
+ export interface FTTraceConfig {
42
+ sampleRate?: number;
43
+ traceType?: TraceType;
44
+ enableLinkRUMData?: boolean;
45
+ enableNativeAutoTrace?: boolean;
46
+ }
28
47
 
29
- type FTReactNativeTraceType = {
48
+ type FTReactNativeTraceType = {
30
49
  /**
31
50
  * Configure trace to enable distributed tracing.
32
51
  * @param config trace configuration parameters.
33
52
  * @returns a Promise.
34
53
  */
35
- setConfig(config: FTTraceConfig): Promise<void>;
54
+ setConfig(config: FTTraceConfig): Promise<void>;
36
55
  /**
37
56
  * Get trace HTTP request header data.
38
57
  * @param url request URL
39
58
  * @returns trace request header parameters
40
59
  * @deprecated use getTraceHeaderFields() replace.
41
60
  */
42
- getTraceHeader(key:String, url: String): Promise<object>;
43
- /**
61
+ getTraceHeader(key: string, url: string): Promise<object>;
62
+ /**
44
63
  * Get trace HTTP request header data.
45
64
  * @param url request URL
46
65
  * @returns trace request header parameters
47
66
  */
48
- getTraceHeaderFields(url: String,key?:String): Promise<object>;
49
- };
50
-
51
- class FTReactNativeTraceWrapper implements FTReactNativeTraceType {
52
- private trace: FTReactNativeTraceType = NativeModules.FTReactNativeTrace;
67
+ getTraceHeaderFields(url: string, key?: string): Promise<object>;
68
+ };
53
69
 
70
+ class FTReactNativeTraceWrapper implements FTReactNativeTraceType {
71
+ /* eslint-disable @typescript-eslint/no-var-requires */
72
+ private trace: FTReactNativeTraceType =
73
+ require('./specs/NativeFTReactNativeTrace').default;
74
+ /* eslint-enable @typescript-eslint/no-var-requires */
54
75
 
55
- setConfig(config:FTTraceConfig): Promise<void>{
56
- return this.trace.setConfig(config);
57
- }
76
+ setConfig(config: FTTraceConfig): Promise<void> {
77
+ return this.trace.setConfig(config);
78
+ }
58
79
  /**
59
80
  * Get trace HTTP request header data.
60
81
  * @param key unique id
61
82
  * @param url request URL
62
83
  * @returns a Promise.
63
84
  */
64
- getTraceHeader(key:String, url: String): Promise<object>{
65
- return this.trace.getTraceHeaderFields(url,key);
66
- }
67
- /**
85
+ getTraceHeader(key: string, url: string): Promise<object> {
86
+ return this.trace.getTraceHeaderFields(url, key);
87
+ }
88
+ /**
68
89
  * Get trace HTTP request header data.
69
90
  * @param url request URL
70
91
  * @param key unique id
71
92
  * @returns a Promise.
72
93
  */
73
- getTraceHeaderFields(url: String,key?:String): Promise<object>{
74
- return this.trace.getTraceHeaderFields(url,key);
75
- }
76
-
77
- }
78
- export const FTReactNativeTrace:FTReactNativeTraceType = new FTReactNativeTraceWrapper();
79
-
94
+ getTraceHeaderFields(url: string, key?: string): Promise<object> {
95
+ return this.trace.getTraceHeaderFields(url, key);
96
+ }
97
+ }
98
+ export const FTReactNativeTrace: FTReactNativeTraceType =
99
+ new FTReactNativeTraceWrapper();
package/src/index.tsx CHANGED
@@ -1,17 +1,59 @@
1
- import {FTMobileConfig,FTMobileReactNative,EnvType,FTDBCacheDiscard} from './ft_mobile_agent'
2
- import {FTLogConfig,FTReactNativeLog,FTLogStatus,FTLogCacheDiscard} from './ft_logger'
3
- import {FTRUMConfig,FTRUMResource,FTReactNativeRUM,ErrorMonitorType,DeviceMetricsMonitorType,DetectFrequency,FTRUMResourceMetrics,FTRUMCacheDiscard} from './ft_rum'
4
- import {FTTraceConfig,FTReactNativeTrace,TraceType} from './ft_tracing'
5
- import {FTRumActionTracking} from './rum/FTRumActionTracking'
6
- import {FTRumErrorTracking} from './rum/FTRumErrorTracking'
7
-
8
-
9
- export {
10
- FTMobileReactNative,FTMobileConfig,EnvType,FTDBCacheDiscard,
11
- FTLogConfig, FTReactNativeLog,FTLogStatus,FTLogCacheDiscard,
12
- FTRUMConfig,FTReactNativeRUM,FTRUMResource,ErrorMonitorType,DeviceMetricsMonitorType,DetectFrequency,FTRUMResourceMetrics,FTRUMCacheDiscard,
13
- FTTraceConfig,FTReactNativeTrace,TraceType,
14
- FTRumActionTracking,
15
- FTRumErrorTracking
16
- };
1
+ import {
2
+ FTMobileConfig,
3
+ FTMobileReactNative,
4
+ EnvType,
5
+ FTDBCacheDiscard,
6
+ FTRemoteConfigResult,
7
+ FTRemoteConfigOverrideRule,
8
+ FTRemoteConfigOverrideMatch,
9
+ FTRemoteConfigOverrideValues,
10
+ } from './ft_mobile_agent';
11
+ import {
12
+ FTLogConfig,
13
+ FTReactNativeLog,
14
+ FTLogStatus,
15
+ FTLogCacheDiscard,
16
+ } from './ft_logger';
17
+ import {
18
+ FTRUMConfig,
19
+ FTRUMResource,
20
+ FTReactNativeRUM,
21
+ ErrorMonitorType,
22
+ DeviceMetricsMonitorType,
23
+ DetectFrequency,
24
+ FTRUMResourceMetrics,
25
+ FTRUMCacheDiscard,
26
+ IOSCrashMonitoringType,
27
+ } from './ft_rum';
28
+ import { FTTraceConfig, FTReactNativeTrace, TraceType } from './ft_tracing';
29
+ import { FTRumActionTracking } from './rum/FTRumActionTracking';
30
+ import { FTRumErrorTracking } from './rum/FTRumErrorTracking';
17
31
 
32
+ export {
33
+ FTMobileReactNative,
34
+ FTMobileConfig,
35
+ EnvType,
36
+ FTDBCacheDiscard,
37
+ FTRemoteConfigResult,
38
+ FTRemoteConfigOverrideRule,
39
+ FTRemoteConfigOverrideMatch,
40
+ FTRemoteConfigOverrideValues,
41
+ FTLogConfig,
42
+ FTReactNativeLog,
43
+ FTLogStatus,
44
+ FTLogCacheDiscard,
45
+ FTRUMConfig,
46
+ FTReactNativeRUM,
47
+ FTRUMResource,
48
+ ErrorMonitorType,
49
+ DeviceMetricsMonitorType,
50
+ DetectFrequency,
51
+ FTRUMResourceMetrics,
52
+ FTRUMCacheDiscard,
53
+ IOSCrashMonitoringType,
54
+ FTTraceConfig,
55
+ FTReactNativeTrace,
56
+ TraceType,
57
+ FTRumActionTracking,
58
+ FTRumErrorTracking,
59
+ };