@truewatchtech/react-native-mobile 0.4.0-alpha.4 → 0.4.2
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 +31 -2
- package/android/build.gradle +7 -19
- package/android/src/main/java/com/ft/sdk/reactnative/FTMobileImpl.java +472 -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/oldarch/java/com/ft/sdk/reactnative/FTRUMModule.java +5 -0
- 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 +625 -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 +155 -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 +161 -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 +169 -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 +26 -93
- package/scripts/replace-react-require.js +37 -38
- package/src/ft_logger.tsx +72 -40
- package/src/ft_mobile_agent.tsx +378 -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
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
//
|
|
2
|
+
// FTMobileReactNative.m
|
|
3
|
+
// FtMobileAgent
|
|
4
|
+
//
|
|
5
|
+
// Created by Hu Leilei on 2021/12/14.
|
|
6
|
+
// Copyright © 2021 Facebook. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "FTMobileReactNative.h"
|
|
10
|
+
#import <React/RCTConvert.h>
|
|
11
|
+
#import <FTMobileSDK/FTMobileAgent.h>
|
|
12
|
+
#import <FTMobileSDK/FTMobileConfig+Private.h>
|
|
13
|
+
#import <FTMobileSDK/FTThreadDispatchManager.h>
|
|
14
|
+
#import <FTMobileSDK/FTConstants.h>
|
|
15
|
+
#import <FTMobileSDK/FTJSONUtil.h>
|
|
16
|
+
#import <FTMobileSDK/FTRemoteConfigModel+Private.h>
|
|
17
|
+
|
|
18
|
+
static NSString *const FTRemoteConfigCallbackEvent = @"ft_remote_config_callback";
|
|
19
|
+
|
|
20
|
+
@implementation FTMobileReactNative
|
|
21
|
+
{
|
|
22
|
+
BOOL _hasListeners;
|
|
23
|
+
BOOL _remoteConfigurationEnabled;
|
|
24
|
+
int _remoteConfigMiniUpdateInterval;
|
|
25
|
+
NSArray<NSDictionary *> *_remoteConfigOverrideRules;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
RCT_EXPORT_MODULE()
|
|
29
|
+
|
|
30
|
+
- (NSArray<NSString *> *)supportedEvents
|
|
31
|
+
{
|
|
32
|
+
return @[FTRemoteConfigCallbackEvent];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
- (void)startObserving
|
|
36
|
+
{
|
|
37
|
+
_hasListeners = YES;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
- (void)stopObserving
|
|
41
|
+
{
|
|
42
|
+
_hasListeners = NO;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
- (NSDictionary *)remoteConfigResultWithSuccess:(BOOL)success
|
|
46
|
+
content:(NSDictionary<NSString *, id> *_Nullable)content
|
|
47
|
+
error:(NSError *_Nullable)error
|
|
48
|
+
triggerType:(NSString *)triggerType
|
|
49
|
+
model:(FTRemoteConfigModel *_Nullable)model
|
|
50
|
+
rules:(NSArray<NSDictionary *> *_Nullable)rules
|
|
51
|
+
{
|
|
52
|
+
// Use local rules if provided, otherwise use global rules
|
|
53
|
+
NSArray<NSDictionary *> *rulesToApply = rules ?: _remoteConfigOverrideRules;
|
|
54
|
+
NSArray<NSString *> *appliedRuleIds = @[];
|
|
55
|
+
|
|
56
|
+
if (model && content && rulesToApply.count > 0) {
|
|
57
|
+
appliedRuleIds = [self applyRemoteConfigOverrideRulesWithModel:model content:content rules:rulesToApply];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
NSMutableDictionary *payload = [NSMutableDictionary dictionary];
|
|
61
|
+
payload[@"triggerType"] = triggerType;
|
|
62
|
+
payload[@"success"] = @(success);
|
|
63
|
+
payload[@"platform"] = @"ios";
|
|
64
|
+
payload[@"timestamp"] = @((long long)([[NSDate date] timeIntervalSince1970] * 1000));
|
|
65
|
+
|
|
66
|
+
// Overridden content after applying rules
|
|
67
|
+
if (model && appliedRuleIds.count > 0) {
|
|
68
|
+
NSDictionary *overriddenContent = [model toDictionary];
|
|
69
|
+
payload[@"rawJson"] = [FTJSONUtil convertToJsonData:overriddenContent];
|
|
70
|
+
payload[@"appliedOverrideRuleIds"] = appliedRuleIds;
|
|
71
|
+
} else if (content) {
|
|
72
|
+
payload[@"rawJson"] = [FTJSONUtil convertToJsonData:content];
|
|
73
|
+
}
|
|
74
|
+
if (error) {
|
|
75
|
+
payload[@"errorCode"] = @(error.code);
|
|
76
|
+
payload[@"errorMessage"] = error.localizedDescription ?: @"";
|
|
77
|
+
}
|
|
78
|
+
return payload;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
- (void)emitAutoRemoteConfigEventWithSuccess:(BOOL)success
|
|
82
|
+
content:(NSDictionary<NSString *, id> *_Nullable)content
|
|
83
|
+
error:(NSError *_Nullable)error
|
|
84
|
+
model:(FTRemoteConfigModel *_Nullable)model
|
|
85
|
+
{
|
|
86
|
+
if (!_hasListeners) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
[self sendEventWithName:FTRemoteConfigCallbackEvent
|
|
90
|
+
body:[self remoteConfigResultWithSuccess:success
|
|
91
|
+
content:content
|
|
92
|
+
error:error
|
|
93
|
+
triggerType:@"auto"
|
|
94
|
+
model:model
|
|
95
|
+
rules:nil]];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
- (BOOL)isEqualValue:(id)value1 toValue:(id)value2 {
|
|
99
|
+
if (value1 == nil && value2 == nil) {
|
|
100
|
+
return YES;
|
|
101
|
+
}
|
|
102
|
+
if (value1 == nil || value2 == nil) {
|
|
103
|
+
return NO;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if ([value1 isKindOfClass:[NSString class]]) {
|
|
107
|
+
id normalizedValue1 = [self parsedJSONArrayIfNeeded:value1];
|
|
108
|
+
if (normalizedValue1 != value1) {
|
|
109
|
+
return [self isEqualValue:normalizedValue1 toValue:value2];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Handle NSNumber comparison
|
|
114
|
+
if ([value1 isKindOfClass:[NSNumber class]] && [value2 isKindOfClass:[NSNumber class]]) {
|
|
115
|
+
return [value1 isEqualToNumber:value2];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Handle NSString comparison
|
|
119
|
+
if ([value1 isKindOfClass:[NSString class]] && [value2 isKindOfClass:[NSString class]]) {
|
|
120
|
+
return [value1 isEqualToString:value2];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Handle NSArray comparison
|
|
124
|
+
if ([value1 isKindOfClass:[NSArray class]] && [value2 isKindOfClass:[NSArray class]]) {
|
|
125
|
+
return [value1 isEqualToArray:value2];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Handle NSDictionary comparison
|
|
129
|
+
if ([value1 isKindOfClass:[NSDictionary class]] && [value2 isKindOfClass:[NSDictionary class]]) {
|
|
130
|
+
return [value1 isEqualToDictionary:value2];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// For other types, use description comparison as fallback
|
|
134
|
+
return [[value1 description] isEqualToString:[value2 description]];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
- (BOOL)matchesCustomKeyActual:(id)actualValue expected:(id)expectedValue {
|
|
138
|
+
if ([expectedValue isKindOfClass:[NSDictionary class]]) {
|
|
139
|
+
NSDictionary *rule = (NSDictionary *)expectedValue;
|
|
140
|
+
id containsValue = rule[@"contains"];
|
|
141
|
+
if (containsValue != nil) {
|
|
142
|
+
return [self containsValueInActual:actualValue expected:containsValue];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return [self isEqualValue:actualValue toValue:expectedValue];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
- (BOOL)containsValueInActual:(id)actualValue expected:(id)expectedValue {
|
|
149
|
+
id normalizedActual = [actualValue isKindOfClass:[NSString class]]
|
|
150
|
+
? [self parsedJSONArrayIfNeeded:actualValue]
|
|
151
|
+
: actualValue;
|
|
152
|
+
if (![normalizedActual isKindOfClass:[NSArray class]]) {
|
|
153
|
+
return [self isEqualValue:normalizedActual toValue:expectedValue];
|
|
154
|
+
}
|
|
155
|
+
NSArray *array = (NSArray *)normalizedActual;
|
|
156
|
+
return [array containsObject:expectedValue];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
- (id)parsedJSONArrayIfNeeded:(NSString *)value {
|
|
160
|
+
if (!value) return nil;
|
|
161
|
+
|
|
162
|
+
NSData *data = [value dataUsingEncoding:NSUTF8StringEncoding];
|
|
163
|
+
NSError *error = nil;
|
|
164
|
+
id object = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
|
|
165
|
+
|
|
166
|
+
if (!error && [object isKindOfClass:[NSArray class]]) {
|
|
167
|
+
return object;
|
|
168
|
+
}
|
|
169
|
+
return value;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
- (NSArray<NSString *> *)applyRemoteConfigOverrideRulesWithModel:(FTRemoteConfigModel *_Nullable)model
|
|
173
|
+
content:(NSDictionary<NSString *, id> *_Nullable)content
|
|
174
|
+
rules:(NSArray<NSDictionary *> *)rules
|
|
175
|
+
{
|
|
176
|
+
if (!model || !content || rules.count == 0) {
|
|
177
|
+
return @[];
|
|
178
|
+
}
|
|
179
|
+
NSMutableArray<NSString *> *appliedRuleIds = [NSMutableArray array];
|
|
180
|
+
[rules enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull rule, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
181
|
+
BOOL enabled = ![rule.allKeys containsObject:@"enabled"] || [RCTConvert BOOL:rule[@"enabled"]];
|
|
182
|
+
if (!enabled) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
NSDictionary *match = [RCTConvert NSDictionary:rule[@"match"]];
|
|
186
|
+
NSDictionary *customKeys = [RCTConvert NSDictionary:match[@"customKeys"]];
|
|
187
|
+
NSDictionary *override = [RCTConvert NSDictionary:rule[@"override"]];
|
|
188
|
+
|
|
189
|
+
if (customKeys.count == 0 || override.count == 0) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
__block BOOL matches = YES;
|
|
193
|
+
[customKeys enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stopKeys) {
|
|
194
|
+
id actualValue = [content valueForKey:[key description]];
|
|
195
|
+
if (![self matchesCustomKeyActual:actualValue expected:obj]) {
|
|
196
|
+
matches = NO;
|
|
197
|
+
*stopKeys = YES;
|
|
198
|
+
}
|
|
199
|
+
}];
|
|
200
|
+
if (!matches) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Basic configuration properties
|
|
205
|
+
if ([override.allKeys containsObject:@"env"]) {
|
|
206
|
+
model.env = [RCTConvert NSString:override[@"env"]];
|
|
207
|
+
}
|
|
208
|
+
if ([override.allKeys containsObject:@"serviceName"]) {
|
|
209
|
+
model.serviceName = [RCTConvert NSString:override[@"serviceName"]];
|
|
210
|
+
}
|
|
211
|
+
if ([override.allKeys containsObject:@"autoSync"]) {
|
|
212
|
+
model.autoSync = @([RCTConvert double:override[@"autoSync"]]);
|
|
213
|
+
}
|
|
214
|
+
if ([override.allKeys containsObject:@"compressIntakeRequests"]) {
|
|
215
|
+
model.compressIntakeRequests = @([RCTConvert double:override[@"compressIntakeRequests"]]);
|
|
216
|
+
}
|
|
217
|
+
if ([override.allKeys containsObject:@"syncPageSize"]) {
|
|
218
|
+
model.syncPageSize = @([RCTConvert double:override[@"syncPageSize"]]);
|
|
219
|
+
}
|
|
220
|
+
if ([override.allKeys containsObject:@"syncSleepTime"]) {
|
|
221
|
+
model.syncSleepTime = @([RCTConvert double:override[@"syncSleepTime"]]);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// RUM configuration properties
|
|
225
|
+
if ([override.allKeys containsObject:@"rumSampleRate"]) {
|
|
226
|
+
model.rumSampleRate = @([RCTConvert double:override[@"rumSampleRate"]]);
|
|
227
|
+
}
|
|
228
|
+
if ([override.allKeys containsObject:@"rumSessionOnErrorSampleRate"]) {
|
|
229
|
+
model.rumSessionOnErrorSampleRate = @([RCTConvert double:override[@"rumSessionOnErrorSampleRate"]]);
|
|
230
|
+
}
|
|
231
|
+
if ([override.allKeys containsObject:@"rumEnableTraceUserAction"]) {
|
|
232
|
+
model.rumEnableTraceUserAction = @([RCTConvert double:override[@"rumEnableTraceUserAction"]]);
|
|
233
|
+
}
|
|
234
|
+
if ([override.allKeys containsObject:@"rumEnableTraceUserView"]) {
|
|
235
|
+
model.rumEnableTraceUserView = @([RCTConvert double:override[@"rumEnableTraceUserView"]]);
|
|
236
|
+
}
|
|
237
|
+
if ([override.allKeys containsObject:@"rumEnableTraceUserResource"]) {
|
|
238
|
+
model.rumEnableTraceUserResource = @([RCTConvert double:override[@"rumEnableTraceUserResource"]]);
|
|
239
|
+
}
|
|
240
|
+
if ([override.allKeys containsObject:@"rumEnableResourceHostIP"]) {
|
|
241
|
+
model.rumEnableResourceHostIP = @([RCTConvert double:override[@"rumEnableResourceHostIP"]]);
|
|
242
|
+
}
|
|
243
|
+
if ([override.allKeys containsObject:@"rumEnableTrackAppUIBlock"]) {
|
|
244
|
+
model.rumEnableTrackAppUIBlock = @([RCTConvert double:override[@"rumEnableTrackAppUIBlock"]]);
|
|
245
|
+
}
|
|
246
|
+
if ([override.allKeys containsObject:@"rumBlockDurationMs"]) {
|
|
247
|
+
model.rumBlockDurationMs = @([RCTConvert double:override[@"rumBlockDurationMs"]]);
|
|
248
|
+
}
|
|
249
|
+
if ([override.allKeys containsObject:@"rumEnableTrackAppCrash"]) {
|
|
250
|
+
model.rumEnableTrackAppCrash = @([RCTConvert double:override[@"rumEnableTrackAppCrash"]]);
|
|
251
|
+
}
|
|
252
|
+
if ([override.allKeys containsObject:@"rumEnableTrackAppANR"]) {
|
|
253
|
+
model.rumEnableTrackAppANR = @([RCTConvert double:override[@"rumEnableTrackAppANR"]]);
|
|
254
|
+
}
|
|
255
|
+
if ([override.allKeys containsObject:@"rumEnableTraceWebView"]) {
|
|
256
|
+
model.rumEnableTraceWebView = @([RCTConvert double:override[@"rumEnableTraceWebView"]]);
|
|
257
|
+
}
|
|
258
|
+
if ([override.allKeys containsObject:@"rumAllowWebViewHost"]) {
|
|
259
|
+
model.rumAllowWebViewHost = [RCTConvert NSArray:override[@"rumAllowWebViewHost"]];
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Trace configuration properties
|
|
263
|
+
if ([override.allKeys containsObject:@"traceSampleRate"]) {
|
|
264
|
+
model.traceSampleRate = @([RCTConvert double:override[@"traceSampleRate"]]);
|
|
265
|
+
}
|
|
266
|
+
if ([override.allKeys containsObject:@"traceEnableAutoTrace"]) {
|
|
267
|
+
model.traceEnableAutoTrace = @([RCTConvert double:override[@"traceEnableAutoTrace"]]);
|
|
268
|
+
}
|
|
269
|
+
if ([override.allKeys containsObject:@"traceType"]) {
|
|
270
|
+
model.traceType = [RCTConvert NSString:override[@"traceType"]];
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Log configuration properties
|
|
274
|
+
if ([override.allKeys containsObject:@"logSampleRate"]) {
|
|
275
|
+
model.logSampleRate = @([RCTConvert double:override[@"logSampleRate"]]);
|
|
276
|
+
}
|
|
277
|
+
if ([override.allKeys containsObject:@"logLevelFilters"]) {
|
|
278
|
+
model.logLevelFilters = [RCTConvert NSArray:override[@"logLevelFilters"]];
|
|
279
|
+
}
|
|
280
|
+
if ([override.allKeys containsObject:@"logEnableCustomLog"]) {
|
|
281
|
+
model.logEnableCustomLog = @([RCTConvert double:override[@"logEnableCustomLog"]]);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
NSString *ruleId = [RCTConvert NSString:rule[@"id"]];
|
|
285
|
+
[appliedRuleIds addObject:ruleId.length > 0 ? ruleId : [NSString stringWithFormat:@"rule_%lu", (unsigned long)idx]];
|
|
286
|
+
}];
|
|
287
|
+
return appliedRuleIds;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
RCT_REMAP_METHOD(sdkConfig,
|
|
291
|
+
context:(NSDictionary *)context
|
|
292
|
+
findEventsWithResolver:(RCTPromiseResolveBlock)resolve
|
|
293
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
294
|
+
{
|
|
295
|
+
[self sdkConfig:context resolve:resolve reject:reject];
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
RCT_REMAP_METHOD(setDatakitURL,
|
|
299
|
+
datakitUrl:(NSString *)datakitUrl
|
|
300
|
+
setDatakitURLWithResolver:(RCTPromiseResolveBlock)resolve
|
|
301
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
302
|
+
{
|
|
303
|
+
[self setDatakitURL:datakitUrl resolve:resolve reject:reject];
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
RCT_REMAP_METHOD(setDatawayURL,
|
|
307
|
+
datawayUrl:(NSString *)datawayUrl
|
|
308
|
+
clientToken:(NSString *)clientToken
|
|
309
|
+
setDatawayURLWithResolver:(RCTPromiseResolveBlock)resolve
|
|
310
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
311
|
+
{
|
|
312
|
+
[self setDatawayURL:datawayUrl clientToken:clientToken resolve:resolve reject:reject];
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
RCT_REMAP_METHOD(bindRUMUserData,
|
|
316
|
+
userId:(NSString*)userId userName:(NSString*)userName userEmail:(NSString*)userEmail extra:(NSDictionary *)extra
|
|
317
|
+
findEventsWithResolver:(RCTPromiseResolveBlock)resolve
|
|
318
|
+
rejecter:(RCTPromiseRejectBlock)reject){
|
|
319
|
+
[self bindRUMUserData:userId userName:userName userEmail:userName extra:extra resolve:resolve reject:reject];
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
RCT_REMAP_METHOD(unbindRUMUserData,
|
|
323
|
+
unbindRUMUserData_Resolver:(RCTPromiseResolveBlock)resolve
|
|
324
|
+
rejecter:(RCTPromiseRejectBlock)reject
|
|
325
|
+
){
|
|
326
|
+
[self unbindRUMUserData:resolve reject:reject];
|
|
327
|
+
}
|
|
328
|
+
RCT_REMAP_METHOD(appendGlobalContext,
|
|
329
|
+
appendGlobalContext:(NSDictionary *)context
|
|
330
|
+
findEventsWithResolver:(RCTPromiseResolveBlock)resolve
|
|
331
|
+
rejecter:(RCTPromiseRejectBlock)reject){
|
|
332
|
+
[self appendGlobalContext:context resolve:resolve reject:reject];
|
|
333
|
+
}
|
|
334
|
+
RCT_REMAP_METHOD(appendRUMGlobalContext,
|
|
335
|
+
appendRUMGlobalContext:(NSDictionary *)context
|
|
336
|
+
findEventsWithResolver:(RCTPromiseResolveBlock)resolve
|
|
337
|
+
rejecter:(RCTPromiseRejectBlock)reject){
|
|
338
|
+
[self appendRUMGlobalContext:context resolve:resolve reject:reject];
|
|
339
|
+
}
|
|
340
|
+
RCT_REMAP_METHOD(appendLogGlobalContext,
|
|
341
|
+
appendLogGlobalContext:(NSDictionary *)context
|
|
342
|
+
findEventsWithResolver:(RCTPromiseResolveBlock)resolve
|
|
343
|
+
rejecter:(RCTPromiseRejectBlock)reject){
|
|
344
|
+
[self appendLogGlobalContext:context resolve:resolve reject:reject];
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
RCT_REMAP_METHOD(flushSyncData,
|
|
348
|
+
flushSyncData_Resolver:(RCTPromiseResolveBlock)resolve
|
|
349
|
+
rejecter:(RCTPromiseRejectBlock)reject
|
|
350
|
+
){
|
|
351
|
+
[self flushSyncData:resolve reject:reject];
|
|
352
|
+
}
|
|
353
|
+
RCT_REMAP_METHOD(trackEventFromExtension,
|
|
354
|
+
identifier:(NSString*)identifier
|
|
355
|
+
findEventsWithResolver:(RCTPromiseResolveBlock)resolve
|
|
356
|
+
rejecter:(RCTPromiseRejectBlock)reject){
|
|
357
|
+
[self trackEventFromExtension:identifier resolve:resolve reject:reject];
|
|
358
|
+
}
|
|
359
|
+
RCT_REMAP_METHOD(shutDown,
|
|
360
|
+
shutDown_findEventsWithResolver:(RCTPromiseResolveBlock)resolve
|
|
361
|
+
rejecter:(RCTPromiseRejectBlock)reject){
|
|
362
|
+
[self shutDown:resolve reject:reject];
|
|
363
|
+
}
|
|
364
|
+
RCT_REMAP_METHOD(clearAllData,
|
|
365
|
+
clearAllData_findEventsWithResolver:(RCTPromiseResolveBlock)resolve
|
|
366
|
+
rejecter:(RCTPromiseRejectBlock)reject){
|
|
367
|
+
[self clearAllData:resolve reject:reject];
|
|
368
|
+
}
|
|
369
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
370
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
371
|
+
return std::make_shared<facebook::react::NativeFTMobileReactNativeSpecJSI>(params);
|
|
372
|
+
}
|
|
373
|
+
#endif
|
|
374
|
+
- (void)sdkConfig:(NSDictionary *)context resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
375
|
+
[FTThreadDispatchManager performBlockDispatchMainSyncSafe:^{
|
|
376
|
+
FTMobileConfig *config;
|
|
377
|
+
NSString *datakitUrl = [RCTConvert NSString:context[@"datakitUrl"]];
|
|
378
|
+
NSString *dataWayUrl = [RCTConvert NSString:context[@"datawayUrl"]];
|
|
379
|
+
NSString *clientToken = [RCTConvert NSString:context[@"clientToken"]];
|
|
380
|
+
if(dataWayUrl && dataWayUrl.length>0 && clientToken && clientToken.length>0){
|
|
381
|
+
config = [[FTMobileConfig alloc]initWithDatawayUrl:dataWayUrl clientToken:clientToken];
|
|
382
|
+
}else if(datakitUrl && datakitUrl.length>0){
|
|
383
|
+
config = [[FTMobileConfig alloc]initWithDatakitUrl:datakitUrl];
|
|
384
|
+
}else{
|
|
385
|
+
resolve(nil);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
if ([context.allKeys containsObject:@"debug"]) {
|
|
389
|
+
config.enableSDKDebugLog = [RCTConvert BOOL:context[@"debug"]];
|
|
390
|
+
}
|
|
391
|
+
if ([context.allKeys containsObject:@"service"]) {
|
|
392
|
+
config.service = [RCTConvert NSString:context[@"service"]];
|
|
393
|
+
}
|
|
394
|
+
if([context.allKeys containsObject:@"env"]){
|
|
395
|
+
id env = context[@"env"];
|
|
396
|
+
if([env isKindOfClass:NSString.class]){
|
|
397
|
+
config.env = env;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if([context.allKeys containsObject:@"envType"]){
|
|
401
|
+
id env = context[@"envType"];
|
|
402
|
+
if([env isKindOfClass:NSNumber.class]){
|
|
403
|
+
int envType = [env intValue];
|
|
404
|
+
if(envType>=0 && envType<5){
|
|
405
|
+
[config setEnvWithType:(FTEnv)envType];
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if ([context.allKeys containsObject:@"autoSync"]) {
|
|
410
|
+
config.autoSync = [RCTConvert BOOL:context[@"autoSync"]];
|
|
411
|
+
}
|
|
412
|
+
if ([context.allKeys containsObject:@"syncPageSize"]) {
|
|
413
|
+
config.syncPageSize = [RCTConvert int:context[@"syncPageSize"]];
|
|
414
|
+
}
|
|
415
|
+
if ([context.allKeys containsObject:@"syncSleepTime"]) {
|
|
416
|
+
config.syncSleepTime = [RCTConvert int:context[@"syncSleepTime"]];
|
|
417
|
+
}
|
|
418
|
+
if ([context.allKeys containsObject:@"enableDataIntegerCompatible"]) {
|
|
419
|
+
config.enableDataIntegerCompatible = [RCTConvert BOOL:context[@"enableDataIntegerCompatible"]];
|
|
420
|
+
}
|
|
421
|
+
if ([context.allKeys containsObject:@"compressIntakeRequests"]) {
|
|
422
|
+
config.compressIntakeRequests = [RCTConvert BOOL:context[@"compressIntakeRequests"]];
|
|
423
|
+
}
|
|
424
|
+
if ([context.allKeys containsObject:@"enableDataFilter"]) {
|
|
425
|
+
config.enableDataFilter = [RCTConvert BOOL:context[@"enableDataFilter"]];
|
|
426
|
+
}
|
|
427
|
+
if ([context.allKeys containsObject:@"dataFilters"]) {
|
|
428
|
+
config.dataFilters = [RCTConvert NSDictionary:context[@"dataFilters"]];
|
|
429
|
+
}
|
|
430
|
+
if ([context.allKeys containsObject:@"globalContext"]) {
|
|
431
|
+
config.globalContext = [RCTConvert NSDictionary:context[@"globalContext"]];
|
|
432
|
+
}
|
|
433
|
+
if ([context.allKeys containsObject:@"groupIdentifiers"]){
|
|
434
|
+
config.groupIdentifiers = [RCTConvert NSArray:context[@"groupIdentifiers"]];
|
|
435
|
+
}
|
|
436
|
+
if ([context.allKeys containsObject:@"dbDiscardStrategy"]){
|
|
437
|
+
config.dbDiscardType = (FTDBCacheDiscard)[RCTConvert int:context[@"dbDiscardStrategy"]];
|
|
438
|
+
}
|
|
439
|
+
if ([context.allKeys containsObject:@"enableLimitWithDbSize"]){
|
|
440
|
+
config.enableLimitWithDbSize = [RCTConvert BOOL:context[@"enableLimitWithDbSize"]];
|
|
441
|
+
}
|
|
442
|
+
if ([context.allKeys containsObject:@"dbCacheLimit"]){
|
|
443
|
+
config.dbCacheLimit = (long)[RCTConvert double:context[@"dbCacheLimit"]];
|
|
444
|
+
}
|
|
445
|
+
if ([context.allKeys containsObject:@"dataModifier"]){
|
|
446
|
+
NSDictionary *dataModifierDict = [[RCTConvert NSDictionary:context[@"dataModifier"]] copy];
|
|
447
|
+
config.dataModifier = ^id _Nullable(NSString * _Nonnull key, id _Nonnull value) {
|
|
448
|
+
if ([dataModifierDict.allKeys containsObject:key]) {
|
|
449
|
+
return dataModifierDict[key];
|
|
450
|
+
}
|
|
451
|
+
return value;
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
if ([context.allKeys containsObject:@"lineDataModifier"]){
|
|
455
|
+
NSDictionary *dataModifierDict = [[RCTConvert NSDictionary:context[@"lineDataModifier"]] copy];
|
|
456
|
+
config.lineDataModifier = ^NSDictionary<NSString *,id> * _Nullable(NSString * _Nonnull measurement, NSDictionary<NSString *,id> * _Nonnull data) {
|
|
457
|
+
if ([measurement isEqualToString:FT_LOGGER_SOURCE] || [measurement isEqualToString:FT_LOGGER_TVOS_SOURCE]) {
|
|
458
|
+
return [dataModifierDict valueForKey:@"log"];
|
|
459
|
+
}else{
|
|
460
|
+
return [dataModifierDict valueForKey:measurement];
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
if ([context.allKeys containsObject:@"remoteConfiguration"]){
|
|
465
|
+
config.remoteConfiguration = [RCTConvert BOOL:context[@"remoteConfiguration"]];
|
|
466
|
+
}
|
|
467
|
+
if ([context.allKeys containsObject:@"remoteConfigMiniUpdateInterval"]){
|
|
468
|
+
config.remoteConfigMiniUpdateInterval = [RCTConvert int:context[@"remoteConfigMiniUpdateInterval"]];
|
|
469
|
+
}
|
|
470
|
+
_remoteConfigOverrideRules = [RCTConvert NSArray:context[@"remoteConfigOverrideRules"]];
|
|
471
|
+
_remoteConfigurationEnabled = config.remoteConfiguration;
|
|
472
|
+
_remoteConfigMiniUpdateInterval = config.remoteConfigMiniUpdateInterval;
|
|
473
|
+
if (config.remoteConfiguration) {
|
|
474
|
+
__weak __typeof(self) weakSelf = self;
|
|
475
|
+
config.remoteConfigFetchCompletionBlock = ^FTRemoteConfigModel * _Nullable(BOOL success, NSError * _Nullable error, FTRemoteConfigModel * _Nullable model, NSDictionary<NSString *,id> * _Nullable content) {
|
|
476
|
+
__typeof(self) strongSelf = weakSelf;
|
|
477
|
+
if (!strongSelf) {
|
|
478
|
+
return nil;
|
|
479
|
+
}
|
|
480
|
+
@try {
|
|
481
|
+
NSArray<NSString *> *appliedRuleIds = [strongSelf applyRemoteConfigOverrideRulesWithModel:model content:content rules:strongSelf->_remoteConfigOverrideRules];
|
|
482
|
+
[strongSelf emitAutoRemoteConfigEventWithSuccess:success content:content error:error model:model];
|
|
483
|
+
if (appliedRuleIds.count > 0) {
|
|
484
|
+
return model;
|
|
485
|
+
}
|
|
486
|
+
} @catch (NSException *exception) {
|
|
487
|
+
[strongSelf emitAutoRemoteConfigEventWithSuccess:NO content:nil error:nil model:nil];
|
|
488
|
+
}
|
|
489
|
+
return nil;
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
[FTMobileAgent startWithConfigOptions:config];
|
|
493
|
+
resolve(nil);
|
|
494
|
+
}];
|
|
495
|
+
}
|
|
496
|
+
- (void)setDatakitURL:(NSString *)datakitUrl resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
497
|
+
[FTMobileAgent setDatakitURL:datakitUrl];
|
|
498
|
+
resolve(nil);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
- (void)setDatawayURL:(NSString *)datawayUrl clientToken:(NSString *)clientToken resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
502
|
+
[FTMobileAgent setDatawayURL:datawayUrl clientToken:clientToken];
|
|
503
|
+
resolve(nil);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
- (void)appendGlobalContext:(NSDictionary *)context resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
507
|
+
[FTMobileAgent appendGlobalContext:context];
|
|
508
|
+
resolve(nil);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
- (void)appendLogGlobalContext:(NSDictionary *)context resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
512
|
+
[FTMobileAgent appendLogGlobalContext:context];
|
|
513
|
+
resolve(nil);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
- (void)appendRUMGlobalContext:(NSDictionary *)context resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
517
|
+
[FTMobileAgent appendRUMGlobalContext:context];
|
|
518
|
+
resolve(nil);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
- (void)bindRUMUserData:(NSString *)userId userName:(NSString *)userName userEmail:(NSString *)userEmail extra:(NSDictionary *)extra resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
522
|
+
[[FTMobileAgent sharedInstance] bindUserWithUserID:userId userName:userName userEmail:userEmail extra:extra];
|
|
523
|
+
resolve(nil);
|
|
524
|
+
}
|
|
525
|
+
- (void)unbindRUMUserData:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
526
|
+
[[FTMobileAgent sharedInstance] unbindUser];
|
|
527
|
+
resolve(nil);
|
|
528
|
+
}
|
|
529
|
+
- (void)clearAllData:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
530
|
+
[FTMobileAgent clearAllData];
|
|
531
|
+
resolve(nil);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
- (void)flushSyncData:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
535
|
+
[[FTMobileAgent sharedInstance] flushSyncData];
|
|
536
|
+
resolve(nil);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
- (void)shutDown:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
540
|
+
[FTMobileAgent shutDown];
|
|
541
|
+
resolve(nil);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
- (void)trackEventFromExtension:(NSString *)identifier resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
545
|
+
[[FTMobileAgent sharedInstance] trackEventFromExtensionWithGroupIdentifier:identifier completion:^(NSString * _Nonnull groupIdentifier, NSArray * _Nonnull events) {
|
|
546
|
+
if(events.count>0){
|
|
547
|
+
resolve(@{@"groupIdentifier":identifier,
|
|
548
|
+
@"datas":events
|
|
549
|
+
});
|
|
550
|
+
}else{
|
|
551
|
+
resolve(nil);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
}];
|
|
555
|
+
}
|
|
556
|
+
RCT_REMAP_METHOD(updateRemoteConfig,
|
|
557
|
+
updateRemoteConfig_findEventsWithResolver:(RCTPromiseResolveBlock)resolve
|
|
558
|
+
rejecter:(RCTPromiseRejectBlock)reject){
|
|
559
|
+
if (!_remoteConfigurationEnabled) {
|
|
560
|
+
reject(@"E_REMOTE_CONFIG_DISABLED", @"Remote configuration is not enabled.", nil);
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
[FTMobileAgent updateRemoteConfigWithMiniUpdateInterval:_remoteConfigMiniUpdateInterval completion:^FTRemoteConfigModel * _Nullable(BOOL success, NSError * _Nullable error, FTRemoteConfigModel * _Nullable model, NSDictionary<NSString *,id> * _Nullable content) {
|
|
564
|
+
@try {
|
|
565
|
+
NSDictionary *result = [self remoteConfigResultWithSuccess:success content:content error:error triggerType:@"manual" model:model rules:nil];
|
|
566
|
+
if (success) {
|
|
567
|
+
resolve(result);
|
|
568
|
+
} else {
|
|
569
|
+
NSString *message = error.localizedDescription ?: @"Remote config update failed.";
|
|
570
|
+
reject(@"E_REMOTE_CONFIG_UPDATE_FAILED", message, error);
|
|
571
|
+
}
|
|
572
|
+
NSArray<NSString *> *appliedRuleIds = result[@"appliedOverrideRuleIds"];
|
|
573
|
+
if (appliedRuleIds.count > 0) {
|
|
574
|
+
return model;
|
|
575
|
+
}
|
|
576
|
+
} @catch (NSException *exception) {
|
|
577
|
+
NSString *message = [NSString stringWithFormat:@"Exception occurred: %@", exception];
|
|
578
|
+
reject(@"E_REMOTE_CONFIG_EXCEPTION", message, nil);
|
|
579
|
+
}
|
|
580
|
+
return nil;
|
|
581
|
+
}];
|
|
582
|
+
}
|
|
583
|
+
RCT_REMAP_METHOD(updateRemoteConfigWithMiniUpdateInterval,
|
|
584
|
+
interval:(int)interval
|
|
585
|
+
rules:(NSArray *)rules
|
|
586
|
+
findEventsWithResolver:(RCTPromiseResolveBlock)resolve
|
|
587
|
+
rejecter:(RCTPromiseRejectBlock)reject){
|
|
588
|
+
if (!_remoteConfigurationEnabled) {
|
|
589
|
+
reject(@"E_REMOTE_CONFIG_DISABLED", @"Remote configuration is not enabled.", nil);
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
__weak __typeof(self) weakSelf = self;
|
|
593
|
+
[FTMobileAgent updateRemoteConfigWithMiniUpdateInterval:(NSInteger)interval completion:^FTRemoteConfigModel * _Nullable(BOOL success, NSError * _Nullable error, FTRemoteConfigModel * _Nullable model, NSDictionary<NSString *,id> * _Nullable content) {
|
|
594
|
+
__typeof(self) strongSelf = weakSelf;
|
|
595
|
+
if (!strongSelf) {
|
|
596
|
+
return nil;
|
|
597
|
+
}
|
|
598
|
+
@try {
|
|
599
|
+
NSArray<NSDictionary *> *rulesToApply = nil;
|
|
600
|
+
if (rules != nil && ![rules isKindOfClass:[NSNull class]]) {
|
|
601
|
+
rulesToApply = [RCTConvert NSArray:rules];
|
|
602
|
+
}
|
|
603
|
+
if (rulesToApply == nil || rulesToApply.count == 0) {
|
|
604
|
+
rulesToApply = strongSelf->_remoteConfigOverrideRules;
|
|
605
|
+
}
|
|
606
|
+
NSDictionary *result = [strongSelf remoteConfigResultWithSuccess:success content:content error:error triggerType:@"manual" model:model rules:rulesToApply];
|
|
607
|
+
if (success) {
|
|
608
|
+
resolve(result);
|
|
609
|
+
} else {
|
|
610
|
+
NSString *message = error.localizedDescription ?: @"Remote config update failed.";
|
|
611
|
+
reject(@"E_REMOTE_CONFIG_UPDATE_FAILED", message, error);
|
|
612
|
+
}
|
|
613
|
+
NSArray<NSString *> *appliedRuleIds = result[@"appliedOverrideRuleIds"];
|
|
614
|
+
if (appliedRuleIds.count > 0) {
|
|
615
|
+
return model;
|
|
616
|
+
}
|
|
617
|
+
} @catch (NSException *exception) {
|
|
618
|
+
NSString *message = [NSString stringWithFormat:@"Exception occurred: %@", exception];
|
|
619
|
+
reject(@"E_REMOTE_CONFIG_EXCEPTION", message, nil);
|
|
620
|
+
}
|
|
621
|
+
return nil;
|
|
622
|
+
}];
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
@end
|
package/ios/FTReactNativeLog.h
CHANGED
|
@@ -9,10 +9,15 @@
|
|
|
9
9
|
#import <Foundation/Foundation.h>
|
|
10
10
|
#import <React/RCTBridgeModule.h>
|
|
11
11
|
|
|
12
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
14
|
+
#import <FTSdkReactNative/FTSdkReactNative.h>
|
|
15
|
+
@interface FTReactNativeLog: NSObject <NativeFTReactNativeLogSpec>
|
|
16
|
+
#else
|
|
17
|
+
|
|
18
|
+
#import <React/RCTBridgeModule.h>
|
|
19
|
+
@interface FTReactNativeLog : NSObject <RCTBridgeModule>
|
|
20
|
+
#endif
|
|
15
21
|
|
|
16
22
|
@end
|
|
17
23
|
|
|
18
|
-
NS_ASSUME_NONNULL_END
|