11#import " RoktEventManager.h"
22#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+ }
321
422@implementation RoktEventManager
523{
@@ -13,17 +31,20 @@ + (id)allocWithZone:(NSZone *)zone {
1331 static dispatch_once_t onceToken;
1432 dispatch_once (&onceToken, ^{
1533 sharedInstance = [super allocWithZone: zone];
34+ _rokt_events_log (@" [mParticle-Rokt] RoktEventManager module alloc" );
1635 });
1736 return sharedInstance;
1837}
1938
2039// Will be called when this module's first listener is added.
2140-(void )startObserving {
41+ _rokt_events_log (@" [mParticle-Rokt] RoktEventManager startObserving (JS listener added)" );
2242 hasListeners = YES ;
2343}
2444
2545// Will be called when this module's last listener is removed, or on dealloc.
2646-(void )stopObserving {
47+ _rokt_events_log (@" [mParticle-Rokt] RoktEventManager stopObserving (no JS listeners)" );
2748 hasListeners = NO ;
2849}
2950
@@ -51,13 +72,16 @@ - (void)onFirstPositiveResponse
5172
5273- (void )onRoktCallbackReceived : (NSString *)eventValue
5374{
75+ _rokt_events_log (@" [mParticle-Rokt] RoktEventManager onRoktCallbackReceived: %@ " , eventValue ?: @" (nil)" );
5476 if (hasListeners) {
5577 [self sendEventWithName: @" RoktCallback" body: @{@" callbackValue" : eventValue}];
5678 }
5779}
5880
5981- (void )onRoktEvents : (MPRoktEvent * _Nonnull)event viewName : (NSString * _Nullable)viewName
6082{
83+ NSString *eventClass = event ? NSStringFromClass ([event class ]) : @" nil" ;
84+ _rokt_events_log (@" [mParticle-Rokt] RoktEventManager onRoktEvents: %@ viewName: %@ " , eventClass, viewName ?: @" (nil)" );
6185 if (hasListeners) {
6286 NSString *placementId;
6387 NSString *eventName = @" " ;
0 commit comments