Skip to content

Commit 0df7517

Browse files
Add Additional Log throughout the sdk
1 parent 4b35a6d commit 0df7517

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

ios/RNMParticle/RNMPRokt.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ - (void)selectPlacements:(NSString *)identifer
184184
[strongSelf subscribeViewEvents:identifer];
185185
}
186186

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");
187190
_rokt_log(@"[mParticle-Rokt] calling mParticle Core selectPlacements for: %@", identifer);
188191
[[[MParticle sharedInstance] rokt] selectPlacements:identifer
189192
attributes:finalAttributes

ios/RNMParticle/RoktEventManager.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
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

Comments
 (0)