@truewatchtech/react-native-mobile 0.3.15-alpha.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 (102) hide show
  1. package/FTMobileReactNativeSDK.podspec +22 -0
  2. package/LICENSE +201 -0
  3. package/README.md +37 -0
  4. package/android/.project +17 -0
  5. package/android/.settings/org.eclipse.buildship.core.prefs +13 -0
  6. package/android/build.gradle +183 -0
  7. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  8. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  9. package/android/gradle.properties +5 -0
  10. package/android/gradlew +185 -0
  11. package/android/gradlew.bat +89 -0
  12. package/android/local.properties +8 -0
  13. package/android/src/main/AndroidManifest.xml +4 -0
  14. package/android/src/main/AndroidManifestNew.xml +4 -0
  15. package/android/src/main/java/com/ft/sdk/InnerClassProxy.java +8 -0
  16. package/android/src/main/java/com/ft/sdk/reactnative/FTLogImpl.java +133 -0
  17. package/android/src/main/java/com/ft/sdk/reactnative/FTMobileImpl.java +198 -0
  18. package/android/src/main/java/com/ft/sdk/reactnative/FTRUMImpl.java +267 -0
  19. package/android/src/main/java/com/ft/sdk/reactnative/FTTraceImpl.java +89 -0
  20. package/android/src/main/java/com/ft/sdk/reactnative/utils/ReactNativeUtils.java +59 -0
  21. package/android/src/newarch/java/com/ft/sdk/reactnative/FTLogModule.java +39 -0
  22. package/android/src/newarch/java/com/ft/sdk/reactnative/FTMobileModule.java +69 -0
  23. package/android/src/newarch/java/com/ft/sdk/reactnative/FTRUMModule.java +84 -0
  24. package/android/src/newarch/java/com/ft/sdk/reactnative/FTTraceModule.java +34 -0
  25. package/android/src/oldarch/java/com/ft/sdk/reactnative/FTLogModule.java +36 -0
  26. package/android/src/oldarch/java/com/ft/sdk/reactnative/FTMobileModule.java +69 -0
  27. package/android/src/oldarch/java/com/ft/sdk/reactnative/FTRUMModule.java +70 -0
  28. package/android/src/oldarch/java/com/ft/sdk/reactnative/FTTraceModule.java +30 -0
  29. package/android/src/rnpost74/java/com/ft/sdk/reactnative/FTMobilePackage.java +71 -0
  30. package/android/src/rnpre74/java/com/ft/sdk/reactnative/FTMobilePackage.java +33 -0
  31. package/ios/.idea/.name +1 -0
  32. package/ios/.idea/ios.iml +2 -0
  33. package/ios/.idea/modules.xml +8 -0
  34. package/ios/.idea/vcs.xml +6 -0
  35. package/ios/.idea/xcode.xml +4 -0
  36. package/ios/FTMobileReactNative.h +18 -0
  37. package/ios/FTMobileReactNative.m +183 -0
  38. package/ios/FTReactNativeLog.h +18 -0
  39. package/ios/FTReactNativeLog.m +60 -0
  40. package/ios/FTReactNativeRUM.h +19 -0
  41. package/ios/FTReactNativeRUM.m +173 -0
  42. package/ios/FTReactNativeTrace.h +20 -0
  43. package/ios/FTReactNativeTrace.m +58 -0
  44. package/ios/FTReactNativeUtils.h +16 -0
  45. package/ios/FTReactNativeUtils.m +32 -0
  46. package/ios/FtMobileAgent.xcodeproj/project.pbxproj +293 -0
  47. package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  48. package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/xcuserdata/Brandon.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  49. package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/xcuserdata/Brandon.xcuserdatad/xcschemes/xcschememanagement.plist +5 -0
  50. package/ios/FtMobileAgent.xcodeproj/xcuserdata/Brandon.xcuserdatad/xcschemes/FtMobileAgent.xcscheme +56 -0
  51. package/ios/FtMobileAgent.xcodeproj/xcuserdata/Brandon.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  52. package/ios/RCTVersion.h +8 -0
  53. package/lib/commonjs/ft_logger.js +70 -0
  54. package/lib/commonjs/ft_logger.js.map +1 -0
  55. package/lib/commonjs/ft_mobile_agent.js +93 -0
  56. package/lib/commonjs/ft_mobile_agent.js.map +1 -0
  57. package/lib/commonjs/ft_rum.js +143 -0
  58. package/lib/commonjs/ft_rum.js.map +1 -0
  59. package/lib/commonjs/ft_tracing.js +61 -0
  60. package/lib/commonjs/ft_tracing.js.map +1 -0
  61. package/lib/commonjs/index.js +138 -0
  62. package/lib/commonjs/index.js.map +1 -0
  63. package/lib/commonjs/rum/FTRumActionTracking.js +214 -0
  64. package/lib/commonjs/rum/FTRumActionTracking.js.map +1 -0
  65. package/lib/commonjs/rum/FTRumErrorTracking.js +99 -0
  66. package/lib/commonjs/rum/FTRumErrorTracking.js.map +1 -0
  67. package/lib/commonjs/version.js +9 -0
  68. package/lib/commonjs/version.js.map +1 -0
  69. package/lib/module/ft_logger.js +64 -0
  70. package/lib/module/ft_logger.js.map +1 -0
  71. package/lib/module/ft_mobile_agent.js +88 -0
  72. package/lib/module/ft_mobile_agent.js.map +1 -0
  73. package/lib/module/ft_rum.js +138 -0
  74. package/lib/module/ft_rum.js.map +1 -0
  75. package/lib/module/ft_tracing.js +56 -0
  76. package/lib/module/ft_tracing.js.map +1 -0
  77. package/lib/module/index.js +8 -0
  78. package/lib/module/index.js.map +1 -0
  79. package/lib/module/rum/FTRumActionTracking.js +206 -0
  80. package/lib/module/rum/FTRumActionTracking.js.map +1 -0
  81. package/lib/module/rum/FTRumErrorTracking.js +92 -0
  82. package/lib/module/rum/FTRumErrorTracking.js.map +1 -0
  83. package/lib/module/version.js +3 -0
  84. package/lib/module/version.js.map +1 -0
  85. package/lib/typescript/ft_logger.d.ts +52 -0
  86. package/lib/typescript/ft_mobile_agent.d.ts +123 -0
  87. package/lib/typescript/ft_rum.d.ts +200 -0
  88. package/lib/typescript/ft_tracing.d.ts +47 -0
  89. package/lib/typescript/index.d.ts +7 -0
  90. package/lib/typescript/rum/FTRumActionTracking.d.ts +15 -0
  91. package/lib/typescript/rum/FTRumErrorTracking.d.ts +11 -0
  92. package/lib/typescript/version.d.ts +1 -0
  93. package/package.json +167 -0
  94. package/scripts/replace-react-require.js +52 -0
  95. package/src/ft_logger.tsx +77 -0
  96. package/src/ft_mobile_agent.tsx +162 -0
  97. package/src/ft_rum.tsx +247 -0
  98. package/src/ft_tracing.tsx +79 -0
  99. package/src/index.tsx +17 -0
  100. package/src/rum/FTRumActionTracking.tsx +232 -0
  101. package/src/rum/FTRumErrorTracking.tsx +110 -0
  102. package/src/version.ts +2 -0
@@ -0,0 +1,77 @@
1
+ import { NativeModules } from 'react-native';
2
+ /**
3
+ * Set log level.
4
+ */
5
+ export enum FTLogStatus {
6
+ info, warning, error, critical, ok,
7
+ };
8
+ /**
9
+ * Log discard method.
10
+ */
11
+ export enum FTLogCacheDiscard { discard, discardOldest };
12
+ /**
13
+ * Configure log output configuration.
14
+ * @param sampleRate sampling rate
15
+ * @param enableLinkRumData whether to link with RUM
16
+ * @param enableCustomLog whether to enable custom logs
17
+ * @param discardStrategy log discard strategy
18
+ * @param logLevelFilters log level filter
19
+ * @param globalContext custom global parameters
20
+ * @param logCacheLimitCount get maximum log entry count limit [1000,), default 5000
21
+ */
22
+ export interface FTLogConfig{
23
+ sampleRate?: number,
24
+ enableLinkRumData?: boolean,
25
+ enableCustomLog?: boolean,
26
+ discardStrategy?: FTLogCacheDiscard,
27
+ logLevelFilters?: Array<FTLogStatus>,
28
+ globalContext?:object,
29
+ logCacheLimitCount?: number
30
+ };
31
+
32
+ type FTReactNativeLogType = {
33
+ /**
34
+ *Configure log output configuration to enable log collection.
35
+ */
36
+ logConfig(config: FTLogConfig): Promise<void>;
37
+ /**
38
+ * Output log.
39
+ * @param content log content
40
+ * @param status log status
41
+ * @param property log context (optional)
42
+ */
43
+ logging(content:String,logStatus:FTLogStatus,property?:object): Promise<void>;
44
+ /**
45
+ * Output log.
46
+ * @param content log content
47
+ * @param status log status
48
+ * @param property log context (optional)
49
+ */
50
+ logWithStatusString(content:String,logStatus:String,property?:object): Promise<void>;
51
+ };
52
+
53
+ class FTReactNativeLogWrapper {
54
+ private logger: FTReactNativeLogType = NativeModules.FTReactNativeLog;
55
+
56
+ /**
57
+ *Configure log output configuration to enable log collection.
58
+ */
59
+ logConfig(config:FTLogConfig): Promise<void>{
60
+ return this.logger.logConfig(config);
61
+ }
62
+
63
+ /**
64
+ * Output log.
65
+ * @param content log content
66
+ * @param status log status
67
+ * @param property log context (optional)
68
+ */
69
+ logging(content:String,logStatus:FTLogStatus|String,property?:object): Promise<void>{
70
+ if((typeof logStatus)==='string'){
71
+ return this.logger.logWithStatusString(content,logStatus.toString(),property)
72
+ }
73
+ let enumLogStatus: FTLogStatus = logStatus as FTLogStatus;
74
+ return this.logger.logging(content,enumLogStatus,property);
75
+ }
76
+ }
77
+ export const FTReactNativeLog: FTReactNativeLogWrapper = new FTReactNativeLogWrapper();
@@ -0,0 +1,162 @@
1
+ import { NativeModules } from 'react-native';
2
+ import { version as sdkVersion } from './version'
3
+
4
+ /**
5
+ * Environment.
6
+ */
7
+ export enum EnvType {
8
+ prod, gray, pre, common, local
9
+ };
10
+ export enum FTDBCacheDiscard { discard, discardOldest };
11
+ /**
12
+ * Configure SDK startup parameters.
13
+ * @param serverUrl data reporting address, deprecated, use [datakitUrl] instead
14
+ * @param datakitUrl datakit access URL address, example: http://10.0.0.1:9529, default port 9529. Choose one between datakit and dataway configuration
15
+ * @param datawayUrl dataway access URL address, example: http://10.0.0.1:9528, default port 9528, note: the device installing the SDK needs to be able to access this address. Note: choose one between datakit and dataway configuration
16
+ * @param clientToken dataway authentication token, needs to be configured together with [datawayUrl]
17
+ * @param debug set whether to allow log printing, default false
18
+ * @param env environment, default prod
19
+ * @param service set the name of the business or service it belongs to, default: `df_rum_ios`, `df_rum_android`
20
+ * @param autoSync whether data is automatically synchronized and uploaded, default: true
21
+ * @param syncPageSize number of synchronized items per request during data synchronization, minimum value 5, default: 10
22
+ * @param syncSleepTime interval time between each request during data synchronization, unit milliseconds, 0 < syncSleepTime < 100
23
+ * @param enableDataIntegerCompatible whether to enable data integer compatibility during data synchronization, enabled by default
24
+ * @param compressIntakeRequests whether to compress synchronized data
25
+ * @param globalContext custom global parameters
26
+ * @param groupIdentifiers iOS side sets the AppGroups Identifier array corresponding to the collected Widget Extension
27
+ * @param enableLimitWithDbSize set whether to enable using db to limit data size, after enabling, `FTLogConfig.logCacheLimitCount` and `FTRUMConfig.rumCacheLimitCount` will no longer take effect
28
+ * @param dbCacheLimit db cache limit size, minimum value 30MB, default 100MB, unit byte
29
+ * @param dbDiscardStrategy db data discard strategy
30
+ * @param dataModifier data modifier, modify individual fields {key:value}, after setting, the SDK will replace the original value with the set value according to the key
31
+ * @param lineDataModifier data modifier, modify single data {"measurement":measurement,"data":{key:value}}, after setting, the SDK will replace the original value with the set value according to the key
32
+ */
33
+ export interface FTMobileConfig {
34
+ /**
35
+ * @deprecated "serverUrl" parameter renamed to "datakitUrl"
36
+ */
37
+ serverUrl?: string,
38
+ datakitUrl?: string,
39
+ datawayUrl?: string,
40
+ clientToken?: string,
41
+ debug?:boolean,
42
+ envType?:EnvType,
43
+ env?:string,
44
+ service?:string,
45
+ autoSync?:boolean,
46
+ syncPageSize?:number,
47
+ syncSleepTime?:number,
48
+ enableDataIntegerCompatible?:boolean,
49
+ compressIntakeRequests?:boolean,
50
+ globalContext?:object,
51
+ groupIdentifiers?:Array<string>,
52
+ enableLimitWithDbSize?:boolean,
53
+ dbCacheLimit?:number,
54
+ dbDiscardStrategy?:FTDBCacheDiscard,
55
+ pkgInfo?: string,
56
+ dataModifier?:object,
57
+ lineDataModifier?:object
58
+ }
59
+
60
+
61
+ type FTMobileReactNativeType = {
62
+
63
+ /**
64
+ * SDK initialization method.
65
+ * @param config SDK initialization configuration items.
66
+ * @returns a Promise.
67
+ */
68
+ sdkConfig(config:FTMobileConfig): Promise<void>;
69
+ /**
70
+ * Bind user.
71
+ * @param userId user ID.
72
+ * @param userName user name.
73
+ * @param userEmail user email
74
+ * @param extra additional user information
75
+ * @returns a Promise.
76
+ */
77
+ bindRUMUserData(userId: string,userName?:string,userEmail?:string,extra?:object): Promise<void>;
78
+ /**
79
+ * Unbind user.
80
+ * @returns a Promise.
81
+ */
82
+ unbindRUMUserData(): Promise<void>;
83
+ /**
84
+ * Add custom global parameters. Applies to RUM and Log data
85
+ * @param context custom global parameters.
86
+ * @returns a Promise.
87
+ */
88
+ appendGlobalContext(context:object):Promise<void>;
89
+ /**
90
+ * Add custom RUM global parameters. Applies to RUM data
91
+ * @param context custom RUM global parameters.
92
+ * @returns a Promise.
93
+ */
94
+ appendRUMGlobalContext(context:object):Promise<void>;
95
+ /**
96
+ * Add custom RUM and Log global parameters. Applies to Log data
97
+ * @param context custom Log global parameters.
98
+ * @returns a Promise.
99
+ */
100
+ appendLogGlobalContext(context:object):Promise<void>;
101
+ /**
102
+ * Actively synchronize data. When `FTMobileConfig.autoSync=false` is configured, you need to actively trigger this method to synchronize data.
103
+ * @returns a Promise.
104
+ */
105
+ flushSyncData():Promise<void>;
106
+
107
+ /**
108
+ * Synchronize events in iOS Widget Extension, iOS only
109
+ * @param groupIdentifier app groupId
110
+ * @returns {groupIdentifier:string,datas:Array<object>} can be used to view data collected in Extension.
111
+ */
112
+ trackEventFromExtension(identifier:string): Promise<object>
113
+ /**
114
+ * Shut down objects currently running in the SDK
115
+ */
116
+ shutDown():Promise<void>
117
+ /**
118
+ * Clear all data that has not yet been uploaded to the server.
119
+ */
120
+ clearAllData():Promise<void>
121
+ };
122
+
123
+ class FTMobileReactNativeWrapper implements FTMobileReactNativeType {
124
+ private sdk:FTMobileReactNativeType = NativeModules.FTMobileReactNative;
125
+
126
+ sdkConfig(config:FTMobileConfig): Promise<void> {
127
+ if(config.serverUrl != null && config.serverUrl.length>0 && config.datakitUrl == null){
128
+ config.datakitUrl = config.serverUrl;
129
+ }
130
+ config.pkgInfo = sdkVersion;
131
+ return this.sdk.sdkConfig(config);
132
+ }
133
+ bindRUMUserData(userId: string,userName?:string,userEmail?:string,extra?:object): Promise<void> {
134
+ return this.sdk.bindRUMUserData(userId,userName,userEmail,extra);
135
+ }
136
+ unbindRUMUserData(): Promise<void> {
137
+ return this.sdk.unbindRUMUserData();
138
+ }
139
+ appendGlobalContext(context: object): Promise<void> {
140
+ return this.sdk.appendGlobalContext(context);
141
+ }
142
+ appendLogGlobalContext(context: object): Promise<void> {
143
+ return this.sdk.appendLogGlobalContext(context);
144
+ }
145
+ appendRUMGlobalContext(context: object): Promise<void> {
146
+ return this.sdk.appendRUMGlobalContext(context);
147
+ }
148
+ trackEventFromExtension(identifier:string) :Promise<object>{
149
+ return this.sdk.trackEventFromExtension(identifier);
150
+ }
151
+ flushSyncData():Promise<void>{
152
+ return this.sdk.flushSyncData();
153
+ }
154
+ shutDown():Promise<void>{
155
+ return this.sdk.shutDown();
156
+ }
157
+ clearAllData():Promise<void>{
158
+ return this.sdk.clearAllData();
159
+ }
160
+ }
161
+ export const FTMobileReactNative: FTMobileReactNativeType = new FTMobileReactNativeWrapper();
162
+
package/src/ft_rum.tsx ADDED
@@ -0,0 +1,247 @@
1
+ import { NativeModules } from 'react-native';
2
+ import { FTRumErrorTracking} from './rum/FTRumErrorTracking';
3
+ import { FTRumActionTracking} from './rum/FTRumActionTracking';
4
+
5
+ /**
6
+ * Error monitoring type.
7
+ */
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 }
28
+
29
+ export enum FTRUMCacheDiscard { discard, discardOldest };
30
+
31
+ /**
32
+ * Set RUM tracking conditions.
33
+ * @param androidAppId appId, apply during monitoring
34
+ * @param iOSAppId appId, apply during monitoring
35
+ * @param sampleRate sampling rate
36
+ * @param sessionOnErrorSampleRate error session sampling rate. For sessions not sampled, if ERROR is hit, collect data 1 minute before the error occurs
37
+ * @param enableAutoTrackUserAction whether to automatically collect react-native control click events, can set actionName with accessibilityLabel when enabled
38
+ * @param enableTrackError whether to automatically collect react-native Error
39
+ * @param enableTrackNativeCrash whether to collect Native Error
40
+ * @param enableTrackNativeAppANR whether to collect Native ANR
41
+ * @param enableTrackNativeFreeze whether to collect Native Freeze
42
+ * @param nativeFreezeDurationMs set the threshold for collecting Native Freeze, value range [100,), unit ms. iOS default 250ms, Android default 1000ms
43
+ * @param enableNativeUserAction whether to start Native Action tracking, Button click events, recommended to disable for pure react-native apps
44
+ * @param enableNativeUserView whether to start Native View auto tracking, recommended to disable for pure react-native apps
45
+ * @param enableNativeUserResource whether to automatically collect react-native Resource
46
+ * @param enableResourceHostIP whether to collect network request Host IP (only for native http, iOS 13 and above)
47
+ * @param errorMonitorType error monitoring supplement type
48
+ * @param deviceMonitorType page monitoring supplement type
49
+ * @param detectFrequency monitoring frequency
50
+ * @param globalContext custom global parameters
51
+ * @param rumCacheLimitCount RUM max cache size, default 100_000
52
+ * @param rumDiscardStrategy RUM data discard strategy
53
+ */
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
+ }
76
+ /**
77
+ * RUM Resource data.
78
+ * @param url request URL
79
+ * @param httpMethod request method
80
+ * @param requestHeader request header parameters
81
+ * @param responseHeader response header parameters
82
+ * @param responseBody response content
83
+ * @param resourceStatus response status code
84
+ */
85
+ export interface FTRUMResource{
86
+ url:string,
87
+ httpMethod:string,
88
+ requestHeader:object,
89
+ responseHeader?:object,
90
+ responseBody?:string,
91
+ resourceStatus?:number
92
+ };
93
+ /**
94
+ * RUM Resource performance metrics.
95
+ * @param duration resource load time
96
+ * @param resource_dns resource DNS resolution time
97
+ * @param resource_tcp resource TCP connection time
98
+ * @param resource_ssl resource SSL connection time
99
+ * @param resource_ttfb resource request response time
100
+ * @param resource_trans resource content transfer time
101
+ * @param resource_first_byte resource first byte time
102
+ */
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 = {
114
+ /**
115
+ * Set RUM tracking conditions and enable RUM collection.
116
+ * @param config rum configuration parameters.
117
+ * @returns a Promise.
118
+ */
119
+ setConfig(config:FTRUMConfig): Promise<void>;
120
+ /**
121
+ * Start RUM Action.
122
+ * RUM will bind Resource, Error, LongTask events that may be triggered by this Action.
123
+ * Avoid adding multiple times within 0.1s, only one Action will be associated with the same View at the same time, and new Actions will be discarded if the previous one has not ended.
124
+ * Adding Action with `addAction` method does not affect each other.
125
+ * @param actionName action name
126
+ * @param actionType action type
127
+ * @param property event context (optional)
128
+ * @returns a Promise.
129
+ */
130
+ startAction(actionName:string,actionType:string,property?:object): Promise<void>;
131
+ /**
132
+ * Add Action event. This type of data cannot be associated with Error, Resource, LongTask data, and has no discard logic.
133
+ * @param actionName action name
134
+ * @param actionType action type
135
+ * @param property event context (optional)
136
+ * @returns a Promise.
137
+ */
138
+ addAction(actionName:string,actionType:string,property?:object): Promise<void>;
139
+ /**
140
+ * view load duration.
141
+ * @param viewName view name
142
+ * @param loadTime view load duration
143
+ * @returns a Promise.
144
+ */
145
+ onCreateView(viewName:string,loadTime:number): Promise<void>;
146
+ /**
147
+ * view start.
148
+ * @param viewName page name
149
+ * @param property event context (optional)
150
+ * @returns a Promise.
151
+ */
152
+ startView(viewName: string, property?: object): Promise<void>;
153
+ /**
154
+ * view end.
155
+ * @param property event context (optional)
156
+ * @returns a Promise.
157
+ */
158
+ stopView(property?:object): Promise<void>;
159
+ /**
160
+ * Exception capture and log collection.
161
+ * @param stack stack log
162
+ * @param message error message
163
+ * @param property event context (optional)
164
+ * @returns a Promise.
165
+ */
166
+ addError(stack: string, message: string,property?:object): Promise<void>;
167
+ /**
168
+ * Exception capture and log collection.
169
+ * @param type error type
170
+ * @param stack stack log
171
+ * @param message error message
172
+ * @param property event context (optional)
173
+ * @returns a Promise.
174
+ */
175
+ addErrorWithType(type:string,stack: string, message: string,property?:object): Promise<void>;
176
+ /**
177
+ * Start resource request.
178
+ * @param key unique id
179
+ * @param property event context (optional)
180
+ * @returns a Promise.
181
+ */
182
+ startResource(key: string,property?:object): Promise<void>;
183
+ /**
184
+ * End resource request.
185
+ * @param key unique id
186
+ * @param property event context (optional)
187
+ * @returns a Promise.
188
+ */
189
+ stopResource(key: string,property?:object): Promise<void>;
190
+ /**
191
+ * Send resource data metrics.
192
+ * @param key unique id
193
+ * @param resource resource data
194
+ * @param metrics resource performance data
195
+ * @returns a Promise.
196
+ */
197
+ addResource(key:string, resource:FTRUMResource,metrics?:FTRUMResourceMetrics):Promise<void>;
198
+ }
199
+
200
+ class FTReactNativeRUMWrapper implements FTReactNativeRUMType {
201
+ private rum: FTReactNativeRUMType = NativeModules.FTReactNativeRUM;
202
+
203
+
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);
234
+ }
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();
247
+
@@ -0,0 +1,79 @@
1
+ import { NativeModules } from 'react-native';
2
+ //FTReactNativeTrace
3
+
4
+ /**
5
+ * Trace types for use.
6
+ */
7
+ export enum TraceType {
8
+ ddTrace,
9
+ zipkinMulti,
10
+ zipkinSingle,
11
+ traceparent,
12
+ skywalking,
13
+ jaeger,
14
+ };
15
+ /**
16
+ * Configure trace.
17
+ * @param sampleRate sampling rate
18
+ * @param traceType trace type
19
+ * @param enableLinkRUMData whether to link with RUM data
20
+ * @param enableNativeAutoTrace whether to enable automatic tracing
21
+ */
22
+ export interface FTTraceConfig{
23
+ sampleRate?:number,
24
+ traceType?:TraceType,
25
+ enableLinkRUMData?:boolean,
26
+ enableNativeAutoTrace?:boolean,
27
+ };
28
+
29
+ type FTReactNativeTraceType = {
30
+ /**
31
+ * Configure trace to enable distributed tracing.
32
+ * @param config trace configuration parameters.
33
+ * @returns a Promise.
34
+ */
35
+ setConfig(config: FTTraceConfig): Promise<void>;
36
+ /**
37
+ * Get trace HTTP request header data.
38
+ * @param url request URL
39
+ * @returns trace request header parameters
40
+ * @deprecated use getTraceHeaderFields() replace.
41
+ */
42
+ getTraceHeader(key:String, url: String): Promise<object>;
43
+ /**
44
+ * Get trace HTTP request header data.
45
+ * @param url request URL
46
+ * @returns trace request header parameters
47
+ */
48
+ getTraceHeaderFields(url: String,key?:String): Promise<object>;
49
+ };
50
+
51
+ class FTReactNativeTraceWrapper implements FTReactNativeTraceType {
52
+ private trace: FTReactNativeTraceType = NativeModules.FTReactNativeTrace;
53
+
54
+
55
+ setConfig(config:FTTraceConfig): Promise<void>{
56
+ return this.trace.setConfig(config);
57
+ }
58
+ /**
59
+ * Get trace HTTP request header data.
60
+ * @param key unique id
61
+ * @param url request URL
62
+ * @returns a Promise.
63
+ */
64
+ getTraceHeader(key:String, url: String): Promise<object>{
65
+ return this.trace.getTraceHeaderFields(url,key);
66
+ }
67
+ /**
68
+ * Get trace HTTP request header data.
69
+ * @param url request URL
70
+ * @param key unique id
71
+ * @returns a Promise.
72
+ */
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
+
package/src/index.tsx ADDED
@@ -0,0 +1,17 @@
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
+ };
17
+