@@ -43,11 +43,15 @@ + (NSString *)moduleName {
4343}
4444
4545+ (void )load {
46+ RCTLogWarn (@" [mParticle-Rokt] RNMPRokt module load" );
4647 RCTRegisterModule (self);
4748}
4849
4950- (dispatch_queue_t )methodQueue
5051{
52+ BOOL bridgeNil = (self.bridge == nil );
53+ BOOL uiManagerNil = (self.bridge .uiManager == nil );
54+ RCTLogWarn (@" [mParticle-Rokt] methodQueue called, bridge %@ , uiManager %@ " , bridgeNil ? @" nil" : @" non-nil" , uiManagerNil ? @" nil" : @" non-nil" );
5155 return self.bridge .uiManager .methodQueue ;
5256}
5357
@@ -65,8 +69,10 @@ - (void)setMethodQueue:(dispatch_queue_t)methodQueue
6569static NSDictionary * __attribute__ ((optnone)) safeExtractRoktConfigDict(
6670 JS::NativeMPRokt::RoktConfigType &roktConfig) {
6771 if (&roktConfig == nullptr ) {
72+ RCTLogWarn (@" [mParticle-Rokt] safeExtractRoktConfigDict: roktConfig ref is nullptr, returning nil" );
6873 return nil ;
6974 }
75+ RCTLogWarn (@" [mParticle-Rokt] safeExtractRoktConfigDict: extracting config" );
7076 NSMutableDictionary *roktConfigDict = [[NSMutableDictionary alloc ] init ];
7177 if (roktConfig.cacheConfig ().has_value ()) {
7278 NSMutableDictionary *cacheConfigDict = [[NSMutableDictionary alloc ] init ];
@@ -78,7 +84,11 @@ - (void)setMethodQueue:(dispatch_queue_t)methodQueue
7884 cacheConfigDict[@" cacheAttributes" ] = cacheConfig.cacheAttributes ();
7985 }
8086 roktConfigDict[@" cacheConfig" ] = cacheConfigDict;
87+ RCTLogWarn (@" [mParticle-Rokt] safeExtractRoktConfigDict: cacheConfig present, keys: %lu " , (unsigned long )roktConfigDict.count );
88+ } else {
89+ RCTLogWarn (@" [mParticle-Rokt] safeExtractRoktConfigDict: cacheConfig has no value" );
8190 }
91+ RCTLogWarn (@" [mParticle-Rokt] safeExtractRoktConfigDict: returning dict with %lu keys" , (unsigned long )roktConfigDict.count );
8292 return roktConfigDict;
8393}
8494
@@ -89,6 +99,7 @@ - (void)selectPlacements:(NSString *)identifer
8999 roktConfig : (JS::NativeMPRokt::RoktConfigType &)roktConfig
90100 fontFilesMap : (NSDictionary *)fontFilesMap
91101{
102+ RCTLogWarn (@" [mParticle-Rokt] New Architecture Implementation" );
92103 NSMutableDictionary *finalAttributes = [self convertToMutableDictionaryOfStrings: attributes];
93104
94105 NSDictionary *roktConfigDict = safeExtractRoktConfigDict (roktConfig);
@@ -97,51 +108,70 @@ - (void)selectPlacements:(NSString *)identifer
97108// Old Architecture Implementation
98109RCT_EXPORT_METHOD (selectPlacements:(NSString *) identifer attributes:(NSDictionary *)attributes placeholders:(NSDictionary * _Nullable)placeholders roktConfig:(NSDictionary * _Nullable)roktConfig fontFilesMap:(NSDictionary * _Nullable)fontFilesMap)
99110{
111+ RCTLogWarn (@" [mParticle-Rokt] Old Architecture Implementation" );
100112 NSMutableDictionary *finalAttributes = [self convertToMutableDictionaryOfStrings: attributes];
101113 MPRoktConfig *config = [self buildRoktConfigFromDict: roktConfig];
102114#endif
103115
116+ RCTLogWarn (@" [mParticle-Rokt] selectPlacements called with identifier: %@ , attributes count: %lu " , identifer, (unsigned long )finalAttributes.count );
117+
104118 [MParticle _setWrapperSdk_internal: MPWrapperSdkReactNative version: @" " ];
105119 // Create callback implementation
106120 MPRoktEventCallback *callbacks = [[MPRoktEventCallback alloc ] init ];
107-
108121 __weak __typeof__ (self) weakSelf = self;
109122
110123 callbacks.onLoad = ^{
111- [self .eventManager onRoktCallbackReceived: @" onLoad" ];
124+ RCTLogWarn (@" [mParticle-Rokt] onLoad" );
125+ [weakSelf.eventManager onRoktCallbackReceived: @" onLoad" ];
112126 };
113127
114128 callbacks.onUnLoad = ^{
115- [ self .eventManager onRoktCallbackReceived: @" onUnLoad" ] ;
116- RCTLogInfo ( @" unloaded " ) ;
129+ RCTLogWarn ( @" [mParticle-Rokt] onUnLoad" ) ;
130+ [weakSelf.eventManager onRoktCallbackReceived: @" onUnLoad " ] ;
117131 };
118132
119133 callbacks.onShouldShowLoadingIndicator = ^{
120- [self .eventManager onRoktCallbackReceived: @" onShouldShowLoadingIndicator" ];
134+ RCTLogWarn (@" [mParticle-Rokt] onShouldShowLoadingIndicator" );
135+ [weakSelf.eventManager onRoktCallbackReceived: @" onShouldShowLoadingIndicator" ];
121136 };
122137
123138 callbacks.onShouldHideLoadingIndicator = ^{
124- [self .eventManager onRoktCallbackReceived: @" onShouldHideLoadingIndicator" ];
139+ RCTLogWarn (@" [mParticle-Rokt] onShouldHideLoadingIndicator" );
140+ [weakSelf.eventManager onRoktCallbackReceived: @" onShouldHideLoadingIndicator" ];
125141 };
126142
127143 callbacks.onEmbeddedSizeChange = ^(NSString *placementId, CGFloat height) {
128- [self .eventManager onWidgetHeightChanges: height placement: placementId];
144+ RCTLogWarn (@" [mParticle-Rokt] onEmbeddedSizeChange" );
145+ [weakSelf.eventManager onWidgetHeightChanges: height placement: placementId];
129146 };
130147
131- if (self.bridge == nil || self.bridge .uiManager == nil ) {
132- NSLog (@" [mParticle-Rokt] addUIBlock skipped: self.bridge%@ is nil. selectPlacements will not be called. This can occur in New Architecture bridgeless production builds." , self.bridge == nil ? @" " : @" .uiManager" );
148+ BOOL bridgeNil = (self.bridge == nil );
149+ BOOL uiManagerNil = (self.bridge .uiManager == nil );
150+ RCTLogWarn (@" [mParticle-Rokt] bridge %@ , uiManager %@ " , bridgeNil ? @" nil" : @" non-nil" , uiManagerNil ? @" nil" : @" non-nil" );
151+
152+ if (bridgeNil || uiManagerNil) {
153+ RCTLogWarn (@" [mParticle-Rokt] addUIBlock skipped: self.bridge%@ is nil. selectPlacements will not be called. This can occur in New Architecture bridgeless production builds." , bridgeNil ? @" " : @" .uiManager" );
154+ } else {
155+ RCTLogWarn (@" [mParticle-Rokt] queuing addUIBlock for identifier: %@ " , identifer);
133156 }
134157 [self .bridge.uiManager addUIBlock: ^(RCTUIManager *uiManager, NSDictionary <NSNumber *,UIView *> *viewRegistry) {
135- NSMutableDictionary *nativePlaceholders = [self getNativePlaceholders: placeholders viewRegistry: viewRegistry];
158+ __strong __typeof__ (weakSelf) strongSelf = weakSelf;
159+ RCTLogWarn (@" [mParticle-Rokt] addUIBlock executing for identifier: %@ , viewRegistry count: %lu " , identifer, (unsigned long )viewRegistry.count );
136160
137- [self subscribeViewEvents: identifer];
161+ NSMutableDictionary *nativePlaceholders = strongSelf ? [strongSelf getNativePlaceholders: placeholders viewRegistry: viewRegistry] : [NSMutableDictionary dictionary ];
162+
163+ if (strongSelf) {
164+ [strongSelf subscribeViewEvents: identifer];
165+ }
138166
167+ RCTLogWarn (@" [mParticle-Rokt] calling mParticle Core selectPlacements for: %@ " , identifer);
139168 [[[MParticle sharedInstance ] rokt ] selectPlacements: identifer
140169 attributes: finalAttributes
141170 embeddedViews: nativePlaceholders
142171 config: config
143172 callbacks: callbacks];
144173 }];
174+ RCTLogWarn (@" [mParticle-Rokt] addUIBlock enqueued for identifier: %@ " , identifer);
145175}
146176
147177RCT_EXPORT_METHOD (purchaseFinalized : (NSString *)placementId catalogItemId : (
@@ -180,6 +210,7 @@ - (MPColorMode)stringToColorMode:(NSString*)colorString
180210}
181211
182212- (MPRoktConfig *)buildRoktConfigFromDict:(NSDictionary <NSString *, id > *)configMap {
213+ RCTLogWarn (@" [mParticle-Rokt] buildRoktConfigFromDict: configMap %@ " , configMap == nil ? @" nil" : [NSString stringWithFormat: @" non-nil (%lu keys)" , (unsigned long )configMap.count]);
183214 MPRoktConfig *config = [[MPRoktConfig alloc ] init ];
184215 BOOL isConfigEmpty = YES ;
185216
@@ -212,11 +243,13 @@ - (MPRoktConfig *)buildRoktConfigFromDict:(NSDictionary<NSString *, id> *)config
212243 config.cacheDuration = cacheDuration;
213244 }
214245
246+ RCTLogWarn (@" [mParticle-Rokt] buildRoktConfigFromDict: returning %@ " , isConfigEmpty ? @" nil" : @" config" );
215247 return isConfigEmpty ? nil : config;
216248}
217249
218250- (void )subscribeViewEvents:(NSString * _Nonnull) viewName
219251{
252+ RCTLogWarn (@" [mParticle-Rokt] subscribeViewEvents for viewName: %@ " , viewName);
220253 if (self.eventManager == nil ) {
221254 self.eventManager = [RoktEventManager allocWithZone: nil ];
222255 }
@@ -227,6 +260,7 @@ - (void)subscribeViewEvents:(NSString* _Nonnull) viewName
227260
228261- (NSMutableDictionary *)getNativePlaceholders:(NSDictionary *)placeholders viewRegistry:(NSDictionary <NSNumber *, UIView *> *)viewRegistry
229262{
263+ RCTLogWarn (@" [mParticle-Rokt] getNativePlaceholders: placeholders %lu , viewRegistry %lu " , (unsigned long )placeholders.count , (unsigned long )viewRegistry.count );
230264 NSMutableDictionary *nativePlaceholders = [[NSMutableDictionary alloc ]initWithCapacity:placeholders.count];
231265
232266 for (id key in placeholders){
@@ -248,12 +282,14 @@ - (NSMutableDictionary *)getNativePlaceholders:(NSDictionary *)placeholders view
248282#endif // RCT_NEW_ARCH_ENABLED
249283 }
250284
285+ RCTLogWarn (@" [mParticle-Rokt] getNativePlaceholders: resolved %lu native placeholder(s)" , (unsigned long )nativePlaceholders.count );
251286 return nativePlaceholders;
252287}
253288
254289#ifdef RCT_NEW_ARCH_ENABLED
255290- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
256291 self.bridge = params.instance .bridge ;
292+ RCTLogWarn (@" [mParticle-Rokt] getTurboModule: bridge set to %@ " , self.bridge == nil ? @" nil" : @" non-nil" );
257293 return std::make_shared<facebook::react::NativeMPRoktSpecJSI>(params);
258294}
259295#endif // RCT_NEW_ARCH_ENABLED
0 commit comments