react-native-mparticle 2.9.0 → 2.9.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.
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
#import <React/RCTViewManager.h>
|
|
20
20
|
#import <React/RCTUIManager.h>
|
|
21
21
|
#import <React/RCTBridge.h>
|
|
22
|
+
#import <os/log.h>
|
|
22
23
|
#import "RoktEventManager.h"
|
|
23
24
|
|
|
24
25
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
@@ -26,6 +27,25 @@
|
|
|
26
27
|
#import <RNMParticle/RNMParticle.h>
|
|
27
28
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
28
29
|
|
|
30
|
+
// os_log for [mParticle-Rokt] diagnostics: visible in production (Console.app, device logs)
|
|
31
|
+
// and does not trigger RCT LogBox/warning UI in debug.
|
|
32
|
+
static os_log_t _rokt_os_log(void) {
|
|
33
|
+
static os_log_t log;
|
|
34
|
+
static dispatch_once_t once;
|
|
35
|
+
dispatch_once(&once, ^{
|
|
36
|
+
log = os_log_create("com.mparticle.react-native", "rokt");
|
|
37
|
+
});
|
|
38
|
+
return log;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static void _rokt_log(NSString *format, ...) {
|
|
42
|
+
va_list args;
|
|
43
|
+
va_start(args, format);
|
|
44
|
+
NSString *msg = [[NSString alloc] initWithFormat:format arguments:args];
|
|
45
|
+
va_end(args);
|
|
46
|
+
os_log_with_type(_rokt_os_log(), OS_LOG_TYPE_INFO, "%{public}s", [msg UTF8String]);
|
|
47
|
+
}
|
|
48
|
+
|
|
29
49
|
@interface RNMPRokt ()
|
|
30
50
|
|
|
31
51
|
@property (nonatomic, nullable) RoktEventManager *eventManager;
|
|
@@ -43,11 +63,15 @@ RCT_EXTERN void RCTRegisterModule(Class);
|
|
|
43
63
|
}
|
|
44
64
|
|
|
45
65
|
+ (void)load {
|
|
66
|
+
_rokt_log(@"[mParticle-Rokt] RNMPRokt module load");
|
|
46
67
|
RCTRegisterModule(self);
|
|
47
68
|
}
|
|
48
69
|
|
|
49
70
|
- (dispatch_queue_t)methodQueue
|
|
50
71
|
{
|
|
72
|
+
BOOL bridgeNil = (self.bridge == nil);
|
|
73
|
+
BOOL uiManagerNil = (self.bridge.uiManager == nil);
|
|
74
|
+
_rokt_log(@"[mParticle-Rokt] methodQueue called, bridge %@, uiManager %@", bridgeNil ? @"nil" : @"non-nil", uiManagerNil ? @"nil" : @"non-nil");
|
|
51
75
|
return self.bridge.uiManager.methodQueue;
|
|
52
76
|
}
|
|
53
77
|
|
|
@@ -65,8 +89,10 @@ RCT_EXTERN void RCTRegisterModule(Class);
|
|
|
65
89
|
static NSDictionary * __attribute__((optnone)) safeExtractRoktConfigDict(
|
|
66
90
|
JS::NativeMPRokt::RoktConfigType &roktConfig) {
|
|
67
91
|
if (&roktConfig == nullptr) {
|
|
92
|
+
_rokt_log(@"[mParticle-Rokt] safeExtractRoktConfigDict: roktConfig ref is nullptr, returning nil");
|
|
68
93
|
return nil;
|
|
69
94
|
}
|
|
95
|
+
_rokt_log(@"[mParticle-Rokt] safeExtractRoktConfigDict: extracting config");
|
|
70
96
|
NSMutableDictionary *roktConfigDict = [[NSMutableDictionary alloc] init];
|
|
71
97
|
if (roktConfig.cacheConfig().has_value()) {
|
|
72
98
|
NSMutableDictionary *cacheConfigDict = [[NSMutableDictionary alloc] init];
|
|
@@ -78,7 +104,11 @@ static NSDictionary * __attribute__((optnone)) safeExtractRoktConfigDict(
|
|
|
78
104
|
cacheConfigDict[@"cacheAttributes"] = cacheConfig.cacheAttributes();
|
|
79
105
|
}
|
|
80
106
|
roktConfigDict[@"cacheConfig"] = cacheConfigDict;
|
|
107
|
+
_rokt_log(@"[mParticle-Rokt] safeExtractRoktConfigDict: cacheConfig present, keys: %lu", (unsigned long)roktConfigDict.count);
|
|
108
|
+
} else {
|
|
109
|
+
_rokt_log(@"[mParticle-Rokt] safeExtractRoktConfigDict: cacheConfig has no value");
|
|
81
110
|
}
|
|
111
|
+
_rokt_log(@"[mParticle-Rokt] safeExtractRoktConfigDict: returning dict with %lu keys", (unsigned long)roktConfigDict.count);
|
|
82
112
|
return roktConfigDict;
|
|
83
113
|
}
|
|
84
114
|
|
|
@@ -89,6 +119,7 @@ static NSDictionary * __attribute__((optnone)) safeExtractRoktConfigDict(
|
|
|
89
119
|
roktConfig:(JS::NativeMPRokt::RoktConfigType &)roktConfig
|
|
90
120
|
fontFilesMap:(NSDictionary *)fontFilesMap
|
|
91
121
|
{
|
|
122
|
+
_rokt_log(@"[mParticle-Rokt] New Architecture Implementation");
|
|
92
123
|
NSMutableDictionary *finalAttributes = [self convertToMutableDictionaryOfStrings:attributes];
|
|
93
124
|
|
|
94
125
|
NSDictionary *roktConfigDict = safeExtractRoktConfigDict(roktConfig);
|
|
@@ -97,51 +128,73 @@ static NSDictionary * __attribute__((optnone)) safeExtractRoktConfigDict(
|
|
|
97
128
|
// Old Architecture Implementation
|
|
98
129
|
RCT_EXPORT_METHOD(selectPlacements:(NSString *) identifer attributes:(NSDictionary *)attributes placeholders:(NSDictionary * _Nullable)placeholders roktConfig:(NSDictionary * _Nullable)roktConfig fontFilesMap:(NSDictionary * _Nullable)fontFilesMap)
|
|
99
130
|
{
|
|
131
|
+
_rokt_log(@"[mParticle-Rokt] Old Architecture Implementation");
|
|
100
132
|
NSMutableDictionary *finalAttributes = [self convertToMutableDictionaryOfStrings:attributes];
|
|
101
133
|
MPRoktConfig *config = [self buildRoktConfigFromDict:roktConfig];
|
|
102
134
|
#endif
|
|
103
135
|
|
|
136
|
+
_rokt_log(@"[mParticle-Rokt] selectPlacements called with identifier: %@, attributes count: %lu", identifer, (unsigned long)finalAttributes.count);
|
|
137
|
+
|
|
104
138
|
[MParticle _setWrapperSdk_internal:MPWrapperSdkReactNative version:@""];
|
|
105
139
|
// Create callback implementation
|
|
106
140
|
MPRoktEventCallback *callbacks = [[MPRoktEventCallback alloc] init];
|
|
107
|
-
|
|
108
141
|
__weak __typeof__(self) weakSelf = self;
|
|
109
142
|
|
|
110
143
|
callbacks.onLoad = ^{
|
|
111
|
-
[
|
|
144
|
+
_rokt_log(@"[mParticle-Rokt] onLoad");
|
|
145
|
+
[weakSelf.eventManager onRoktCallbackReceived:@"onLoad"];
|
|
112
146
|
};
|
|
113
147
|
|
|
114
148
|
callbacks.onUnLoad = ^{
|
|
115
|
-
[
|
|
116
|
-
|
|
149
|
+
_rokt_log(@"[mParticle-Rokt] onUnLoad");
|
|
150
|
+
[weakSelf.eventManager onRoktCallbackReceived:@"onUnLoad"];
|
|
117
151
|
};
|
|
118
152
|
|
|
119
153
|
callbacks.onShouldShowLoadingIndicator = ^{
|
|
120
|
-
[
|
|
154
|
+
_rokt_log(@"[mParticle-Rokt] onShouldShowLoadingIndicator");
|
|
155
|
+
[weakSelf.eventManager onRoktCallbackReceived:@"onShouldShowLoadingIndicator"];
|
|
121
156
|
};
|
|
122
157
|
|
|
123
158
|
callbacks.onShouldHideLoadingIndicator = ^{
|
|
124
|
-
[
|
|
159
|
+
_rokt_log(@"[mParticle-Rokt] onShouldHideLoadingIndicator");
|
|
160
|
+
[weakSelf.eventManager onRoktCallbackReceived:@"onShouldHideLoadingIndicator"];
|
|
125
161
|
};
|
|
126
162
|
|
|
127
163
|
callbacks.onEmbeddedSizeChange = ^(NSString *placementId, CGFloat height) {
|
|
128
|
-
[
|
|
164
|
+
_rokt_log(@"[mParticle-Rokt] onEmbeddedSizeChange");
|
|
165
|
+
[weakSelf.eventManager onWidgetHeightChanges:height placement:placementId];
|
|
129
166
|
};
|
|
130
167
|
|
|
131
|
-
|
|
132
|
-
|
|
168
|
+
BOOL bridgeNil = (self.bridge == nil);
|
|
169
|
+
BOOL uiManagerNil = (self.bridge.uiManager == nil);
|
|
170
|
+
_rokt_log(@"[mParticle-Rokt] bridge %@, uiManager %@", bridgeNil ? @"nil" : @"non-nil", uiManagerNil ? @"nil" : @"non-nil");
|
|
171
|
+
|
|
172
|
+
if (bridgeNil || uiManagerNil) {
|
|
173
|
+
_rokt_log(@"[mParticle-Rokt] addUIBlock skipped: self.bridge%@ is nil. selectPlacements will not be called. This can occur in New Architecture bridgeless production builds.", bridgeNil ? @"" : @".uiManager");
|
|
174
|
+
} else {
|
|
175
|
+
_rokt_log(@"[mParticle-Rokt] queuing addUIBlock for identifier: %@", identifer);
|
|
133
176
|
}
|
|
134
177
|
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
|
|
135
|
-
|
|
178
|
+
__strong __typeof__(weakSelf) strongSelf = weakSelf;
|
|
179
|
+
_rokt_log(@"[mParticle-Rokt] addUIBlock executing for identifier: %@, viewRegistry count: %lu", identifer, (unsigned long)viewRegistry.count);
|
|
136
180
|
|
|
137
|
-
[
|
|
181
|
+
NSMutableDictionary *nativePlaceholders = strongSelf ? [strongSelf getNativePlaceholders:placeholders viewRegistry:viewRegistry] : [NSMutableDictionary dictionary];
|
|
182
|
+
|
|
183
|
+
if (strongSelf) {
|
|
184
|
+
[strongSelf subscribeViewEvents:identifer];
|
|
185
|
+
}
|
|
138
186
|
|
|
187
|
+
id mpInstance = [MParticle sharedInstance];
|
|
188
|
+
id roktKit = mpInstance ? [mpInstance rokt] : nil;
|
|
189
|
+
_rokt_log(@"[mParticle-Rokt] MParticle sharedInstance %@, rokt kit %@", mpInstance ? @"non-nil" : @"nil", roktKit ? @"non-nil" : @"nil");
|
|
190
|
+
_rokt_log(@"[mParticle-Rokt] calling mParticle Core selectPlacements for: %@", identifer);
|
|
139
191
|
[[[MParticle sharedInstance] rokt] selectPlacements:identifer
|
|
140
192
|
attributes:finalAttributes
|
|
141
193
|
embeddedViews:nativePlaceholders
|
|
142
194
|
config:config
|
|
143
195
|
callbacks:callbacks];
|
|
144
196
|
}];
|
|
197
|
+
_rokt_log(@"[mParticle-Rokt] addUIBlock enqueued for identifier: %@", identifer);
|
|
145
198
|
}
|
|
146
199
|
|
|
147
200
|
RCT_EXPORT_METHOD(purchaseFinalized : (NSString *)placementId catalogItemId : (
|
|
@@ -180,6 +233,7 @@ RCT_EXPORT_METHOD(purchaseFinalized : (NSString *)placementId catalogItemId : (
|
|
|
180
233
|
}
|
|
181
234
|
|
|
182
235
|
- (MPRoktConfig *)buildRoktConfigFromDict:(NSDictionary<NSString *, id> *)configMap {
|
|
236
|
+
_rokt_log(@"[mParticle-Rokt] buildRoktConfigFromDict: configMap %@", configMap == nil ? @"nil" : [NSString stringWithFormat:@"non-nil (%lu keys)", (unsigned long)configMap.count]);
|
|
183
237
|
MPRoktConfig *config = [[MPRoktConfig alloc] init];
|
|
184
238
|
BOOL isConfigEmpty = YES;
|
|
185
239
|
|
|
@@ -212,11 +266,13 @@ RCT_EXPORT_METHOD(purchaseFinalized : (NSString *)placementId catalogItemId : (
|
|
|
212
266
|
config.cacheDuration = cacheDuration;
|
|
213
267
|
}
|
|
214
268
|
|
|
269
|
+
_rokt_log(@"[mParticle-Rokt] buildRoktConfigFromDict: returning %@", isConfigEmpty ? @"nil" : @"config");
|
|
215
270
|
return isConfigEmpty ? nil : config;
|
|
216
271
|
}
|
|
217
272
|
|
|
218
273
|
- (void)subscribeViewEvents:(NSString* _Nonnull) viewName
|
|
219
274
|
{
|
|
275
|
+
_rokt_log(@"[mParticle-Rokt] subscribeViewEvents for viewName: %@", viewName);
|
|
220
276
|
if (self.eventManager == nil) {
|
|
221
277
|
self.eventManager = [RoktEventManager allocWithZone: nil];
|
|
222
278
|
}
|
|
@@ -227,6 +283,7 @@ RCT_EXPORT_METHOD(purchaseFinalized : (NSString *)placementId catalogItemId : (
|
|
|
227
283
|
|
|
228
284
|
- (NSMutableDictionary *)getNativePlaceholders:(NSDictionary *)placeholders viewRegistry:(NSDictionary<NSNumber *, UIView *> *)viewRegistry
|
|
229
285
|
{
|
|
286
|
+
_rokt_log(@"[mParticle-Rokt] getNativePlaceholders: placeholders %lu, viewRegistry %lu", (unsigned long)placeholders.count, (unsigned long)viewRegistry.count);
|
|
230
287
|
NSMutableDictionary *nativePlaceholders = [[NSMutableDictionary alloc]initWithCapacity:placeholders.count];
|
|
231
288
|
|
|
232
289
|
for(id key in placeholders){
|
|
@@ -248,12 +305,14 @@ RCT_EXPORT_METHOD(purchaseFinalized : (NSString *)placementId catalogItemId : (
|
|
|
248
305
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
249
306
|
}
|
|
250
307
|
|
|
308
|
+
_rokt_log(@"[mParticle-Rokt] getNativePlaceholders: resolved %lu native placeholder(s)", (unsigned long)nativePlaceholders.count);
|
|
251
309
|
return nativePlaceholders;
|
|
252
310
|
}
|
|
253
311
|
|
|
254
312
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
255
313
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
256
314
|
self.bridge = params.instance.bridge;
|
|
315
|
+
_rokt_log(@"[mParticle-Rokt] getTurboModule: bridge set to %@", self.bridge == nil ? @"nil" : @"non-nil");
|
|
257
316
|
return std::make_shared<facebook::react::NativeMPRoktSpecJSI>(params);
|
|
258
317
|
}
|
|
259
318
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
#import "RoktEventManager.h"
|
|
2
2
|
#import <mParticle_Apple_SDK/mParticle_Apple_SDK-Swift.h>
|
|
3
|
+
#import <os/log.h>
|
|
4
|
+
|
|
5
|
+
static os_log_t _rokt_events_os_log(void) {
|
|
6
|
+
static os_log_t log;
|
|
7
|
+
static dispatch_once_t once;
|
|
8
|
+
dispatch_once(&once, ^{
|
|
9
|
+
log = os_log_create("com.mparticle.react-native", "rokt-events");
|
|
10
|
+
});
|
|
11
|
+
return log;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static void _rokt_events_log(NSString *format, ...) {
|
|
15
|
+
va_list args;
|
|
16
|
+
va_start(args, format);
|
|
17
|
+
NSString *msg = [[NSString alloc] initWithFormat:format arguments:args];
|
|
18
|
+
va_end(args);
|
|
19
|
+
os_log_with_type(_rokt_events_os_log(), OS_LOG_TYPE_INFO, "%{public}s", [msg UTF8String]);
|
|
20
|
+
}
|
|
3
21
|
|
|
4
22
|
@implementation RoktEventManager
|
|
5
23
|
{
|
|
@@ -13,17 +31,20 @@ RCT_EXPORT_MODULE(RoktEventManager);
|
|
|
13
31
|
static dispatch_once_t onceToken;
|
|
14
32
|
dispatch_once(&onceToken, ^{
|
|
15
33
|
sharedInstance = [super allocWithZone:zone];
|
|
34
|
+
_rokt_events_log(@"[mParticle-Rokt] RoktEventManager module alloc");
|
|
16
35
|
});
|
|
17
36
|
return sharedInstance;
|
|
18
37
|
}
|
|
19
38
|
|
|
20
39
|
// Will be called when this module's first listener is added.
|
|
21
40
|
-(void)startObserving {
|
|
41
|
+
_rokt_events_log(@"[mParticle-Rokt] RoktEventManager startObserving (JS listener added)");
|
|
22
42
|
hasListeners = YES;
|
|
23
43
|
}
|
|
24
44
|
|
|
25
45
|
// Will be called when this module's last listener is removed, or on dealloc.
|
|
26
46
|
-(void)stopObserving {
|
|
47
|
+
_rokt_events_log(@"[mParticle-Rokt] RoktEventManager stopObserving (no JS listeners)");
|
|
27
48
|
hasListeners = NO;
|
|
28
49
|
}
|
|
29
50
|
|
|
@@ -51,6 +72,7 @@ RCT_EXPORT_MODULE(RoktEventManager);
|
|
|
51
72
|
|
|
52
73
|
- (void)onRoktCallbackReceived:(NSString*)eventValue
|
|
53
74
|
{
|
|
75
|
+
_rokt_events_log(@"[mParticle-Rokt] RoktEventManager onRoktCallbackReceived: %@", eventValue ?: @"(nil)");
|
|
54
76
|
if (hasListeners) {
|
|
55
77
|
[self sendEventWithName:@"RoktCallback" body:@{@"callbackValue": eventValue}];
|
|
56
78
|
}
|
|
@@ -58,6 +80,8 @@ RCT_EXPORT_MODULE(RoktEventManager);
|
|
|
58
80
|
|
|
59
81
|
- (void)onRoktEvents:(MPRoktEvent * _Nonnull)event viewName:(NSString * _Nullable)viewName
|
|
60
82
|
{
|
|
83
|
+
NSString *eventClass = event ? NSStringFromClass([event class]) : @"nil";
|
|
84
|
+
_rokt_events_log(@"[mParticle-Rokt] RoktEventManager onRoktEvents: %@ viewName: %@", eventClass, viewName ?: @"(nil)");
|
|
61
85
|
if (hasListeners) {
|
|
62
86
|
NSString *placementId;
|
|
63
87
|
NSString *eventName = @"";
|
package/package.json
CHANGED