@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.
- package/FTMobileReactNativeSDK.podspec +32 -2
- package/android/build.gradle +10 -4
- 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/main/java/com/ft/sdk/reactnative/FTTraceImpl.java +1 -1
- 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 -4
- package/android/src/rnpre74/java/com/ft/sdk/reactnative/FTMobilePackage.java +0 -2
- 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 -4
- package/ios/{FTReactNativeRUM.m → FTReactNativeRUM.mm} +143 -84
- package/ios/FTReactNativeTrace.h +7 -3
- package/ios/FTReactNativeTrace.mm +74 -0
- package/ios/FtMobileAgent.xcodeproj/project.pbxproj +22 -0
- 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 +30 -0
- 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 -3
- 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 -3
- 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 +71 -40
- package/src/ft_mobile_agent.tsx +374 -92
- package/src/ft_rum.tsx +227 -123
- package/src/ft_tracing.tsx +58 -38
- package/src/index.tsx +58 -16
- 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/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 -183
- package/ios/FTReactNativeLog.m +0 -60
- package/ios/FTReactNativeTrace.m +0 -58
- 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/src/ft_mobile_agent.tsx
CHANGED
|
@@ -1,13 +1,200 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
EmitterSubscription,
|
|
3
|
+
NativeEventEmitter,
|
|
4
|
+
NativeModules,
|
|
5
|
+
} from 'react-native';
|
|
6
|
+
import { version as sdkVersion } from './version';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Bridge context manager for managing shared properties across RUM and Logger modules
|
|
10
|
+
* This class provides a centralized way to store and retrieve global properties that will be
|
|
11
|
+
* automatically merged with local properties when making calls to RUM and Logger functions
|
|
12
|
+
*/
|
|
13
|
+
class BridgeContextManager {
|
|
14
|
+
private static instance: BridgeContextManager;
|
|
15
|
+
private properties: Map<string, any> = new Map();
|
|
16
|
+
|
|
17
|
+
private constructor() {
|
|
18
|
+
// Initialize with SDK version information
|
|
19
|
+
this.initializeSDKInfo();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Initialize SDK information properties
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
private initializeSDKInfo(): void {
|
|
27
|
+
// Create sdk_bridge_info with version information
|
|
28
|
+
const sdkBridgeInfo = {
|
|
29
|
+
react_native: sdkVersion,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Set the sdk_bridge_info property
|
|
33
|
+
this.properties.set('sdk_bridge_info', JSON.stringify(sdkBridgeInfo));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Get singleton instance of BridgeContextManager
|
|
38
|
+
* @returns BridgeContextManager instance
|
|
39
|
+
*/
|
|
40
|
+
public static getInstance(): BridgeContextManager {
|
|
41
|
+
if (!BridgeContextManager.instance) {
|
|
42
|
+
BridgeContextManager.instance = new BridgeContextManager();
|
|
43
|
+
}
|
|
44
|
+
return BridgeContextManager.instance;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Add bridge context properties that will be automatically merged with local properties
|
|
49
|
+
* @param properties Object containing key-value pairs
|
|
50
|
+
*/
|
|
51
|
+
public appendBridgeContext(properties: Record<string, any>): void {
|
|
52
|
+
// Store properties locally in JavaScript
|
|
53
|
+
try {
|
|
54
|
+
// Store properties locally in JavaScript
|
|
55
|
+
Object.entries(properties).forEach(([key, value]) => {
|
|
56
|
+
this.properties.set(key, value);
|
|
57
|
+
});
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.warn('Failed to append bridge context:', error);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Merge bridge context properties with local properties
|
|
65
|
+
* Bridge context properties take precedence over local properties
|
|
66
|
+
* @param localProperties Local properties to merge with bridge context properties
|
|
67
|
+
* @returns Merged properties object
|
|
68
|
+
*/
|
|
69
|
+
public mergeWithLocalPropertiesSync(
|
|
70
|
+
localProperties?: object
|
|
71
|
+
): Record<string, any> {
|
|
72
|
+
try {
|
|
73
|
+
const merged: Record<string, any> = {};
|
|
74
|
+
|
|
75
|
+
// First add local properties (if any)
|
|
76
|
+
if (localProperties) {
|
|
77
|
+
Object.assign(merged, localProperties);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Then add bridge context properties (these will override local properties with same keys)
|
|
81
|
+
this.properties.forEach((value, key) => {
|
|
82
|
+
merged[key] = value;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
return merged;
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.warn(
|
|
88
|
+
'Failed to merge bridge context with local properties:',
|
|
89
|
+
error
|
|
90
|
+
);
|
|
91
|
+
// Return empty object or only local properties on error
|
|
92
|
+
return localProperties ? { ...localProperties } : {};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Internal bridge context manager - not exported
|
|
98
|
+
export const bridgeContextManager = BridgeContextManager.getInstance();
|
|
3
99
|
|
|
4
100
|
/**
|
|
5
101
|
* Environment.
|
|
6
102
|
*/
|
|
7
103
|
export enum EnvType {
|
|
8
|
-
prod,
|
|
104
|
+
prod,
|
|
105
|
+
gray,
|
|
106
|
+
pre,
|
|
107
|
+
common,
|
|
108
|
+
local,
|
|
109
|
+
}
|
|
110
|
+
export enum FTDBCacheDiscard {
|
|
111
|
+
discard,
|
|
112
|
+
discardOldest,
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Remote config override rule matching condition for custom keys. Supports exact match and contains match.
|
|
117
|
+
* For exact match, set the value directly, for example: "userid": "test_user", which means the rule will be applied when the custom key "userid" is exactly "test_user".
|
|
118
|
+
* For contains match, set the value as an object with a "contains" field, for example: "userid": { "contains": "test_user" }, which means the rule will be applied when the custom key "userid" contains the object "test_user".
|
|
119
|
+
*/
|
|
120
|
+
export type FTRemoteConfigCustomKeyContainsMatch = {
|
|
121
|
+
contains: string | number | boolean;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Matching rules for remote config override
|
|
126
|
+
* Defines matching conditions using customKeys
|
|
127
|
+
*/
|
|
128
|
+
export type FTRemoteConfigOverrideMatch = {
|
|
129
|
+
customKeys?: Record<
|
|
130
|
+
string,
|
|
131
|
+
string | number | boolean | FTRemoteConfigCustomKeyContainsMatch
|
|
132
|
+
>;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Values that can be modified by remote config override rules.
|
|
137
|
+
* These values will adjust the fetched remote configuration before it is applied.
|
|
138
|
+
*/
|
|
139
|
+
export type FTRemoteConfigOverrideValues = {
|
|
140
|
+
env?: string;
|
|
141
|
+
serviceName?: string;
|
|
142
|
+
autoSync?: boolean;
|
|
143
|
+
compressIntakeRequests?: boolean;
|
|
144
|
+
syncPageSize?: number;
|
|
145
|
+
syncSleepTime?: number;
|
|
146
|
+
rumSampleRate?: number;
|
|
147
|
+
rumSessionOnErrorSampleRate?: number;
|
|
148
|
+
rumEnableTraceUserAction?: boolean;
|
|
149
|
+
rumEnableTraceUserView?: boolean;
|
|
150
|
+
rumEnableTraceUserResource?: boolean;
|
|
151
|
+
rumEnableResourceHostIP?: boolean;
|
|
152
|
+
rumEnableTrackAppUIBlock?: boolean;
|
|
153
|
+
rumBlockDurationMs?: number;
|
|
154
|
+
rumEnableTrackAppCrash?: boolean;
|
|
155
|
+
rumEnableTrackAppANR?: boolean;
|
|
156
|
+
rumEnableTraceWebView?: boolean;
|
|
157
|
+
rumAllowWebViewHost?: Array<string>;
|
|
158
|
+
traceSampleRate?: number;
|
|
159
|
+
traceEnableAutoTrace?: boolean;
|
|
160
|
+
traceType?: string;
|
|
161
|
+
logSampleRate?: number;
|
|
162
|
+
logLevelFilters?: Array<string>;
|
|
163
|
+
logEnableCustomLog?: boolean;
|
|
164
|
+
logEnableConsoleLog?: boolean;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Remote config override rules .
|
|
169
|
+
* Adjust the fetched remote configuration before application.
|
|
170
|
+
*/
|
|
171
|
+
export type FTRemoteConfigOverrideRule = {
|
|
172
|
+
id?: string;
|
|
173
|
+
enabled?: boolean;
|
|
174
|
+
match: FTRemoteConfigOverrideMatch;
|
|
175
|
+
override: FTRemoteConfigOverrideValues;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Final result of the remote config update
|
|
179
|
+
* @param triggerType the type of remote config update trigger, auto or manual
|
|
180
|
+
* @param success whether the remote config update was successful
|
|
181
|
+
* @param platform the platform of the device, ios or android
|
|
182
|
+
* @param timestamp the timestamp when the remote config update was triggered
|
|
183
|
+
* @param rawJson the final remote config update result, in JSON string format
|
|
184
|
+
* @param errorCode the error code if the remote config update failed, may be null if the update was successful
|
|
185
|
+
* @param errorMessage the error message if the remote config update failed, may be null if the update was successful
|
|
186
|
+
* @param appliedOverrideRuleIds the list of override rule IDs applied in this remote config update, may be null if no rules were applied
|
|
187
|
+
*/
|
|
188
|
+
export type FTRemoteConfigResult = {
|
|
189
|
+
triggerType: 'auto' | 'manual';
|
|
190
|
+
success: boolean;
|
|
191
|
+
platform: 'ios' | 'android';
|
|
192
|
+
timestamp: number;
|
|
193
|
+
rawJson?: string;
|
|
194
|
+
errorCode?: string | number;
|
|
195
|
+
errorMessage?: string;
|
|
196
|
+
appliedOverrideRuleIds?: string[];
|
|
9
197
|
};
|
|
10
|
-
export enum FTDBCacheDiscard { discard, discardOldest };
|
|
11
198
|
/**
|
|
12
199
|
* Configure SDK startup parameters.
|
|
13
200
|
* @param serverUrl data reporting address, deprecated, use [datakitUrl] instead
|
|
@@ -29,43 +216,59 @@ export enum FTDBCacheDiscard { discard, discardOldest };
|
|
|
29
216
|
* @param dbDiscardStrategy db data discard strategy
|
|
30
217
|
* @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
218
|
* @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
|
|
219
|
+
* @param remoteConfiguration Set whether to enable remote dynamic configuration
|
|
220
|
+
* @param remoteConfigMiniUpdateInterval Set remote dynamic configuration minimum update interval, unit seconds, default 12*60*60
|
|
221
|
+
* @param remoteConfigOverrideRules Remote config override rules .Adjust the fetched remote configuration before application.
|
|
32
222
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
223
|
+
export interface FTMobileConfig {
|
|
224
|
+
/**
|
|
225
|
+
* @deprecated "serverUrl" parameter renamed to "datakitUrl"
|
|
226
|
+
*/
|
|
227
|
+
serverUrl?: string;
|
|
228
|
+
datakitUrl?: string;
|
|
229
|
+
datawayUrl?: string;
|
|
230
|
+
clientToken?: string;
|
|
231
|
+
debug?: boolean;
|
|
232
|
+
envType?: EnvType;
|
|
233
|
+
env?: string;
|
|
234
|
+
service?: string;
|
|
235
|
+
autoSync?: boolean;
|
|
236
|
+
syncPageSize?: number;
|
|
237
|
+
syncSleepTime?: number;
|
|
238
|
+
enableDataIntegerCompatible?: boolean;
|
|
239
|
+
compressIntakeRequests?: boolean;
|
|
240
|
+
globalContext?: object;
|
|
241
|
+
groupIdentifiers?: Array<string>;
|
|
242
|
+
enableLimitWithDbSize?: boolean;
|
|
243
|
+
dbCacheLimit?: number;
|
|
244
|
+
dbDiscardStrategy?: FTDBCacheDiscard;
|
|
245
|
+
dataModifier?: object;
|
|
246
|
+
lineDataModifier?: object;
|
|
247
|
+
remoteConfiguration?: boolean;
|
|
248
|
+
remoteConfigMiniUpdateInterval?: number;
|
|
249
|
+
remoteConfigOverrideRules?: Array<FTRemoteConfigOverrideRule>;
|
|
250
|
+
}
|
|
60
251
|
|
|
61
252
|
type FTMobileReactNativeType = {
|
|
62
|
-
|
|
63
253
|
/**
|
|
64
254
|
* SDK initialization method.
|
|
65
255
|
* @param config SDK initialization configuration items.
|
|
66
256
|
* @returns a Promise.
|
|
67
257
|
*/
|
|
68
|
-
|
|
258
|
+
sdkConfig(config: FTMobileConfig): Promise<void>;
|
|
259
|
+
/**
|
|
260
|
+
* Dynamically set the Datakit upload URL after SDK initialization.
|
|
261
|
+
* @param datakitUrl Datakit upload URL.
|
|
262
|
+
* @returns a Promise.
|
|
263
|
+
*/
|
|
264
|
+
setDatakitURL(datakitUrl: string): Promise<void>;
|
|
265
|
+
/**
|
|
266
|
+
* Dynamically set the Dataway upload URL and client token after SDK initialization.
|
|
267
|
+
* @param datawayUrl Dataway upload URL.
|
|
268
|
+
* @param clientToken Dataway authentication token.
|
|
269
|
+
* @returns a Promise.
|
|
270
|
+
*/
|
|
271
|
+
setDatawayURL(datawayUrl: string, clientToken: string): Promise<void>;
|
|
69
272
|
/**
|
|
70
273
|
* Bind user.
|
|
71
274
|
* @param userId user ID.
|
|
@@ -74,89 +277,168 @@ type FTMobileReactNativeType = {
|
|
|
74
277
|
* @param extra additional user information
|
|
75
278
|
* @returns a Promise.
|
|
76
279
|
*/
|
|
77
|
-
|
|
280
|
+
bindRUMUserData(
|
|
281
|
+
userId: string,
|
|
282
|
+
userName?: string,
|
|
283
|
+
userEmail?: string,
|
|
284
|
+
extra?: object
|
|
285
|
+
): Promise<void>;
|
|
78
286
|
/**
|
|
79
287
|
* Unbind user.
|
|
80
288
|
* @returns a Promise.
|
|
81
289
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
290
|
+
unbindRUMUserData(): Promise<void>;
|
|
291
|
+
/**
|
|
84
292
|
* Add custom global parameters. Applies to RUM and Log data
|
|
85
293
|
* @param context custom global parameters.
|
|
86
294
|
* @returns a Promise.
|
|
87
295
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
296
|
+
appendGlobalContext(context: object): Promise<void>;
|
|
297
|
+
/**
|
|
90
298
|
* Add custom RUM global parameters. Applies to RUM data
|
|
91
299
|
* @param context custom RUM global parameters.
|
|
92
300
|
* @returns a Promise.
|
|
93
301
|
*/
|
|
94
|
-
|
|
302
|
+
appendRUMGlobalContext(context: object): Promise<void>;
|
|
95
303
|
/**
|
|
96
304
|
* Add custom RUM and Log global parameters. Applies to Log data
|
|
97
305
|
* @param context custom Log global parameters.
|
|
98
306
|
* @returns a Promise.
|
|
99
307
|
*/
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
308
|
+
appendLogGlobalContext(context: object): Promise<void>;
|
|
309
|
+
/**
|
|
310
|
+
* Actively synchronize data. When `FTMobileConfig.autoSync=false` is configured, you need to actively trigger this method to synchronize data.
|
|
311
|
+
* @returns a Promise.
|
|
104
312
|
*/
|
|
105
|
-
|
|
313
|
+
flushSyncData(): Promise<void>;
|
|
106
314
|
|
|
107
|
-
|
|
315
|
+
/**
|
|
108
316
|
* Synchronize events in iOS Widget Extension, iOS only
|
|
109
317
|
* @param groupIdentifier app groupId
|
|
110
318
|
* @returns {groupIdentifier:string,datas:Array<object>} can be used to view data collected in Extension.
|
|
111
319
|
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
320
|
+
trackEventFromExtension(identifier: string): Promise<object>;
|
|
321
|
+
/**
|
|
322
|
+
* Shut down objects currently running in the SDK
|
|
323
|
+
*/
|
|
324
|
+
shutDown(): Promise<void>;
|
|
325
|
+
/**
|
|
326
|
+
* Clear all data that has not yet been uploaded to the server.
|
|
327
|
+
*/
|
|
328
|
+
clearAllData(): Promise<void>;
|
|
329
|
+
/**
|
|
330
|
+
* Add bridge context properties that will be automatically merged with local properties
|
|
331
|
+
* @param properties Object containing key-value pairs
|
|
332
|
+
*/
|
|
333
|
+
appendBridgeContext(properties: Record<string, any>): void;
|
|
334
|
+
/**
|
|
335
|
+
* Update remote configuration, after enabling remote configuration, you can call this method to update the configuration in real time.
|
|
336
|
+
*/
|
|
337
|
+
updateRemoteConfig(): Promise<FTRemoteConfigResult>;
|
|
338
|
+
/**
|
|
339
|
+
* Update remote configuration with minimum update interval, after enabling remote configuration, you can call this method to update the configuration in real time.
|
|
340
|
+
* This method is used to set the minimum update interval for remote configuration updates. If the time since the last update is less than the specified interval, the update will not be performed.
|
|
341
|
+
* @param interval minimum update interval, unit seconds
|
|
342
|
+
* @param rules Remote config override rules .Adjust the fetched remote configuration before application.
|
|
343
|
+
* @returns the result of the remote config update
|
|
344
|
+
*/
|
|
345
|
+
updateRemoteConfigWithMiniUpdateInterval(
|
|
346
|
+
interval: number,
|
|
347
|
+
rules?: Array<FTRemoteConfigOverrideRule>
|
|
348
|
+
): Promise<FTRemoteConfigResult>;
|
|
349
|
+
/**
|
|
350
|
+
* Listen for auto remote configuration updates triggered by the native SDK.
|
|
351
|
+
* Manual updates are returned through the update Promise instead of this event.
|
|
352
|
+
*/
|
|
353
|
+
addRemoteConfigListener(
|
|
354
|
+
listener: (result: FTRemoteConfigResult) => void
|
|
355
|
+
): EmitterSubscription;
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
class FTMobileReactNativeWrapper implements FTMobileReactNativeType {
|
|
359
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
360
|
+
private sdk: FTMobileReactNativeType =
|
|
361
|
+
require('./specs/NativeFTMobileReactNative').default;
|
|
362
|
+
/* eslint-enable @typescript-eslint/no-var-requires */
|
|
363
|
+
|
|
364
|
+
private emitter: NativeEventEmitter | null = null;
|
|
365
|
+
|
|
366
|
+
private getEmitter(): NativeEventEmitter {
|
|
367
|
+
if (this.emitter) {
|
|
368
|
+
return this.emitter;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const nativeEventModule = NativeModules.FTMobileReactNative ?? this.sdk;
|
|
372
|
+
this.emitter = new NativeEventEmitter(nativeEventModule as never);
|
|
373
|
+
return this.emitter;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
sdkConfig(config: FTMobileConfig): Promise<void> {
|
|
377
|
+
if (
|
|
378
|
+
config.serverUrl != null &&
|
|
379
|
+
config.serverUrl.length > 0 &&
|
|
380
|
+
config.datakitUrl == null
|
|
381
|
+
) {
|
|
382
|
+
config.datakitUrl = config.serverUrl;
|
|
383
|
+
}
|
|
384
|
+
return this.sdk.sdkConfig(config);
|
|
385
|
+
}
|
|
386
|
+
setDatakitURL(datakitUrl: string): Promise<void> {
|
|
387
|
+
return this.sdk.setDatakitURL(datakitUrl);
|
|
388
|
+
}
|
|
389
|
+
setDatawayURL(datawayUrl: string, clientToken: string): Promise<void> {
|
|
390
|
+
return this.sdk.setDatawayURL(datawayUrl, clientToken);
|
|
391
|
+
}
|
|
392
|
+
bindRUMUserData(
|
|
393
|
+
userId: string,
|
|
394
|
+
userName?: string,
|
|
395
|
+
userEmail?: string,
|
|
396
|
+
extra?: object
|
|
397
|
+
): Promise<void> {
|
|
398
|
+
return this.sdk.bindRUMUserData(userId, userName, userEmail, extra);
|
|
399
|
+
}
|
|
400
|
+
unbindRUMUserData(): Promise<void> {
|
|
401
|
+
return this.sdk.unbindRUMUserData();
|
|
402
|
+
}
|
|
403
|
+
appendGlobalContext(context: object): Promise<void> {
|
|
140
404
|
return this.sdk.appendGlobalContext(context);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
405
|
+
}
|
|
406
|
+
appendLogGlobalContext(context: object): Promise<void> {
|
|
407
|
+
return this.sdk.appendLogGlobalContext(context);
|
|
408
|
+
}
|
|
409
|
+
appendRUMGlobalContext(context: object): Promise<void> {
|
|
410
|
+
return this.sdk.appendRUMGlobalContext(context);
|
|
411
|
+
}
|
|
412
|
+
trackEventFromExtension(identifier: string): Promise<object> {
|
|
413
|
+
return this.sdk.trackEventFromExtension(identifier);
|
|
414
|
+
}
|
|
415
|
+
flushSyncData(): Promise<void> {
|
|
152
416
|
return this.sdk.flushSyncData();
|
|
153
|
-
|
|
154
|
-
|
|
417
|
+
}
|
|
418
|
+
shutDown(): Promise<void> {
|
|
155
419
|
return this.sdk.shutDown();
|
|
156
|
-
|
|
157
|
-
|
|
420
|
+
}
|
|
421
|
+
clearAllData(): Promise<void> {
|
|
158
422
|
return this.sdk.clearAllData();
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
423
|
+
}
|
|
424
|
+
appendBridgeContext(properties: Record<string, any>): void {
|
|
425
|
+
// Use bridgeContextManager to store properties in JavaScript and send to native SDK
|
|
426
|
+
bridgeContextManager.appendBridgeContext(properties);
|
|
427
|
+
}
|
|
428
|
+
updateRemoteConfig(): Promise<FTRemoteConfigResult> {
|
|
429
|
+
return this.sdk.updateRemoteConfig();
|
|
430
|
+
}
|
|
431
|
+
updateRemoteConfigWithMiniUpdateInterval(
|
|
432
|
+
interval: number,
|
|
433
|
+
rules?: Array<FTRemoteConfigOverrideRule>
|
|
434
|
+
): Promise<FTRemoteConfigResult> {
|
|
435
|
+
return this.sdk.updateRemoteConfigWithMiniUpdateInterval(interval, rules);
|
|
436
|
+
}
|
|
437
|
+
addRemoteConfigListener(
|
|
438
|
+
listener: (result: FTRemoteConfigResult) => void
|
|
439
|
+
): EmitterSubscription {
|
|
440
|
+
return this.getEmitter().addListener('ft_remote_config_callback', listener);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
export const FTMobileReactNative: FTMobileReactNativeType =
|
|
444
|
+
new FTMobileReactNativeWrapper();
|