@snowplow/react-native-tracker 1.2.0 → 1.2.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.
- package/CHANGELOG +4 -0
- package/android/src/main/java/com/snowplowanalytics/react/util/TrackerVersion.java +1 -1
- package/ios/RNSnowplowTracker.m +68 -69
- package/ios/Util/NSDictionary+RNSP_TypeMethods.h +33 -0
- package/ios/Util/NSDictionary+RNSP_TypeMethods.m +40 -0
- package/ios/Util/RNConfigUtils.m +31 -31
- package/ios/Util/RNTrackerVersion.m +1 -1
- package/package.json +1 -1
package/CHANGELOG
CHANGED
package/ios/RNSnowplowTracker.m
CHANGED
|
@@ -21,10 +21,9 @@
|
|
|
21
21
|
#import "RNSnowplowTracker.h"
|
|
22
22
|
#import "RNConfigUtils.h"
|
|
23
23
|
#import "RNUtilities.h"
|
|
24
|
+
#import "NSDictionary+RNSP_TypeMethods.h"
|
|
24
25
|
|
|
25
26
|
#import <SnowplowTracker/SPSnowplow.h>
|
|
26
|
-
#import <SnowplowTracker/NSDictionary+SP_TypeMethods.h>
|
|
27
|
-
#import <SnowplowTracker/SPUtilities.h>
|
|
28
27
|
#import <SnowplowTracker/SPNetworkConfiguration.h>
|
|
29
28
|
#import <SnowplowTracker/SPNetworkConnection.h>
|
|
30
29
|
#import <SnowplowTracker/SPTrackerConfiguration.h>
|
|
@@ -61,7 +60,7 @@ RCT_EXPORT_METHOD(createTracker:
|
|
|
61
60
|
NSDictionary *networkConfig =[argmap objectForKey:@"networkConfig"];
|
|
62
61
|
|
|
63
62
|
// NetworkConfiguration
|
|
64
|
-
NSString *method = [networkConfig
|
|
63
|
+
NSString *method = [networkConfig rnsp_stringForKey:@"method" defaultValue:nil];
|
|
65
64
|
SPHttpMethod httpMethod = [@"get" isEqualToString:method] ? SPHttpMethodGet : SPHttpMethodPost;
|
|
66
65
|
SPNetworkConfiguration *networkConfiguration = [[SPNetworkConfiguration alloc] initWithEndpoint:networkConfig[@"endpoint"] method:httpMethod];
|
|
67
66
|
|
|
@@ -169,19 +168,19 @@ RCT_EXPORT_METHOD(trackStructuredEvent:
|
|
|
169
168
|
NSDictionary *argmap = [details objectForKey:@"eventData"];
|
|
170
169
|
NSArray<NSDictionary *> *contexts = [details objectForKey:@"contexts"];
|
|
171
170
|
|
|
172
|
-
NSString *category = [argmap
|
|
173
|
-
NSString *action = [argmap
|
|
171
|
+
NSString *category = [argmap rnsp_stringForKey:@"category" defaultValue:nil];
|
|
172
|
+
NSString *action = [argmap rnsp_stringForKey:@"action" defaultValue:nil];
|
|
174
173
|
SPStructured *event = [[SPStructured alloc] initWithCategory:category
|
|
175
174
|
action:action];
|
|
176
|
-
NSString *label = [argmap
|
|
175
|
+
NSString *label = [argmap rnsp_stringForKey:@"label" defaultValue:nil];
|
|
177
176
|
if (label) {
|
|
178
177
|
event.label = label;
|
|
179
178
|
}
|
|
180
|
-
NSString *property = [argmap
|
|
179
|
+
NSString *property = [argmap rnsp_stringForKey:@"property" defaultValue:nil];
|
|
181
180
|
if (property) {
|
|
182
181
|
event.property = property;
|
|
183
182
|
}
|
|
184
|
-
NSNumber *value = [argmap
|
|
183
|
+
NSNumber *value = [argmap rnsp_numberForKey:@"value" defaultValue:nil];
|
|
185
184
|
if (label) {
|
|
186
185
|
event.value = value;
|
|
187
186
|
}
|
|
@@ -206,8 +205,8 @@ RCT_EXPORT_METHOD(trackScreenViewEvent:
|
|
|
206
205
|
NSDictionary *argmap = [details objectForKey:@"eventData"];
|
|
207
206
|
NSArray<NSDictionary *> *contexts = [details objectForKey:@"contexts"];
|
|
208
207
|
|
|
209
|
-
NSString *screenName = [argmap
|
|
210
|
-
NSString *screenId = [argmap
|
|
208
|
+
NSString *screenName = [argmap rnsp_stringForKey:@"name" defaultValue:nil];
|
|
209
|
+
NSString *screenId = [argmap rnsp_stringForKey:@"id" defaultValue:nil];
|
|
211
210
|
NSUUID *screenUuid = [[NSUUID alloc] initWithUUIDString:screenId];
|
|
212
211
|
if (screenId != nil && screenUuid == nil) {
|
|
213
212
|
NSError* error = [NSError errorWithDomain:@"SnowplowTracker" code:200 userInfo:nil];
|
|
@@ -216,23 +215,23 @@ RCT_EXPORT_METHOD(trackScreenViewEvent:
|
|
|
216
215
|
SPScreenView *event = [[SPScreenView alloc] initWithName:screenName
|
|
217
216
|
screenId:screenUuid];
|
|
218
217
|
|
|
219
|
-
NSString *type = [argmap
|
|
218
|
+
NSString *type = [argmap rnsp_stringForKey:@"type" defaultValue:nil];
|
|
220
219
|
if (type) {
|
|
221
220
|
event.type = type;
|
|
222
221
|
}
|
|
223
|
-
NSString *previousName = [argmap
|
|
222
|
+
NSString *previousName = [argmap rnsp_stringForKey:@"previousName" defaultValue:nil];
|
|
224
223
|
if (previousName) {
|
|
225
224
|
event.previousName = previousName;
|
|
226
225
|
}
|
|
227
|
-
NSString *previousId = [argmap
|
|
226
|
+
NSString *previousId = [argmap rnsp_stringForKey:@"previousId" defaultValue:nil];
|
|
228
227
|
if (previousId) {
|
|
229
228
|
event.previousId = previousId;
|
|
230
229
|
}
|
|
231
|
-
NSString *previousType = [argmap
|
|
230
|
+
NSString *previousType = [argmap rnsp_stringForKey:@"previousType" defaultValue:nil];
|
|
232
231
|
if (previousType) {
|
|
233
232
|
event.previousType = previousType;
|
|
234
233
|
}
|
|
235
|
-
NSString *transitionType = [argmap
|
|
234
|
+
NSString *transitionType = [argmap rnsp_stringForKey:@"transitionType" defaultValue:nil];
|
|
236
235
|
if (transitionType) {
|
|
237
236
|
event.transitionType = transitionType;
|
|
238
237
|
}
|
|
@@ -257,14 +256,14 @@ RCT_EXPORT_METHOD(trackPageViewEvent:
|
|
|
257
256
|
NSDictionary *argmap = [details objectForKey:@"eventData"];
|
|
258
257
|
NSArray<NSDictionary *> *contexts = [details objectForKey:@"contexts"];
|
|
259
258
|
|
|
260
|
-
NSString *pageUrl = [argmap
|
|
259
|
+
NSString *pageUrl = [argmap rnsp_stringForKey:@"pageUrl" defaultValue:nil];
|
|
261
260
|
SPPageView *event = [[SPPageView alloc] initWithPageUrl:pageUrl];
|
|
262
261
|
|
|
263
|
-
NSString *pageTitle = [argmap
|
|
262
|
+
NSString *pageTitle = [argmap rnsp_stringForKey:@"pageTitle" defaultValue:nil];
|
|
264
263
|
if (pageTitle) {
|
|
265
264
|
event.pageTitle = pageTitle;
|
|
266
265
|
}
|
|
267
|
-
NSString *referrer = [argmap
|
|
266
|
+
NSString *referrer = [argmap rnsp_stringForKey:@"referrer" defaultValue:nil];
|
|
268
267
|
if (referrer) {
|
|
269
268
|
event.referrer = referrer;
|
|
270
269
|
}
|
|
@@ -289,13 +288,13 @@ RCT_EXPORT_METHOD(trackTimingEvent:
|
|
|
289
288
|
NSDictionary *argmap = [details objectForKey:@"eventData"];
|
|
290
289
|
NSArray<NSDictionary *> *contexts = [details objectForKey:@"contexts"];
|
|
291
290
|
|
|
292
|
-
NSString *category = [argmap
|
|
293
|
-
NSString *variable = [argmap
|
|
294
|
-
NSNumber *timing = [argmap
|
|
291
|
+
NSString *category = [argmap rnsp_stringForKey:@"category" defaultValue:nil];
|
|
292
|
+
NSString *variable = [argmap rnsp_stringForKey:@"variable" defaultValue:nil];
|
|
293
|
+
NSNumber *timing = [argmap rnsp_numberForKey:@"timing" defaultValue:nil];
|
|
295
294
|
SPTiming *event = [[SPTiming alloc] initWithCategory:category
|
|
296
295
|
variable:variable
|
|
297
296
|
timing:timing];
|
|
298
|
-
NSString *label = [argmap
|
|
297
|
+
NSString *label = [argmap rnsp_stringForKey:@"label" defaultValue:nil];
|
|
299
298
|
if (label) {
|
|
300
299
|
event.label = label;
|
|
301
300
|
}
|
|
@@ -320,18 +319,18 @@ RCT_EXPORT_METHOD(trackConsentGrantedEvent:
|
|
|
320
319
|
NSDictionary *argmap = [details objectForKey:@"eventData"];
|
|
321
320
|
NSArray<NSDictionary *> *contexts = [details objectForKey:@"contexts"];
|
|
322
321
|
|
|
323
|
-
NSString *expiry = [argmap
|
|
324
|
-
NSString *documentId = [argmap
|
|
325
|
-
NSString *version = [argmap
|
|
322
|
+
NSString *expiry = [argmap rnsp_stringForKey:@"expiry" defaultValue:nil];
|
|
323
|
+
NSString *documentId = [argmap rnsp_stringForKey:@"documentId" defaultValue:nil];
|
|
324
|
+
NSString *version = [argmap rnsp_stringForKey:@"version" defaultValue:nil];
|
|
326
325
|
SPConsentGranted *event = [[SPConsentGranted alloc] initWithExpiry:expiry
|
|
327
326
|
documentId:documentId
|
|
328
327
|
version:version];
|
|
329
328
|
|
|
330
|
-
NSString *name = [argmap
|
|
329
|
+
NSString *name = [argmap rnsp_stringForKey:@"name" defaultValue:nil];
|
|
331
330
|
if (name) {
|
|
332
331
|
event.name = name;
|
|
333
332
|
}
|
|
334
|
-
NSString *documentDescription = [argmap
|
|
333
|
+
NSString *documentDescription = [argmap rnsp_stringForKey:@"documentDescription" defaultValue:nil];
|
|
335
334
|
if (documentDescription) {
|
|
336
335
|
event.documentDescription = documentDescription;
|
|
337
336
|
}
|
|
@@ -358,17 +357,17 @@ RCT_EXPORT_METHOD(trackConsentWithdrawnEvent:
|
|
|
358
357
|
|
|
359
358
|
SPConsentWithdrawn *event = [SPConsentWithdrawn new];
|
|
360
359
|
|
|
361
|
-
BOOL all = [argmap
|
|
360
|
+
BOOL all = [argmap rnsp_boolForKey:@"all" defaultValue:nil];
|
|
362
361
|
event.all = all;
|
|
363
|
-
NSString *documentId = [argmap
|
|
362
|
+
NSString *documentId = [argmap rnsp_stringForKey:@"documentId" defaultValue:nil];
|
|
364
363
|
event.documentId = documentId;
|
|
365
|
-
NSString *version = [argmap
|
|
364
|
+
NSString *version = [argmap rnsp_stringForKey:@"version" defaultValue:nil];
|
|
366
365
|
event.version = version;
|
|
367
|
-
NSString *name = [argmap
|
|
366
|
+
NSString *name = [argmap rnsp_stringForKey:@"name" defaultValue:nil];
|
|
368
367
|
if (name) {
|
|
369
368
|
event.name = name;
|
|
370
369
|
}
|
|
371
|
-
NSString *documentDescription = [argmap
|
|
370
|
+
NSString *documentDescription = [argmap rnsp_stringForKey:@"documentDescription" defaultValue:nil];
|
|
372
371
|
if (documentDescription) {
|
|
373
372
|
event.documentDescription = documentDescription;
|
|
374
373
|
}
|
|
@@ -393,28 +392,28 @@ RCT_EXPORT_METHOD(trackEcommerceTransactionEvent:
|
|
|
393
392
|
NSDictionary *argmap = [details objectForKey:@"eventData"];
|
|
394
393
|
NSArray<NSDictionary *> *contexts = [details objectForKey:@"contexts"];
|
|
395
394
|
|
|
396
|
-
NSString *orderId = [argmap
|
|
397
|
-
NSNumber *totalValue = [argmap
|
|
395
|
+
NSString *orderId = [argmap rnsp_stringForKey:@"orderId" defaultValue:nil];
|
|
396
|
+
NSNumber *totalValue = [argmap rnsp_numberForKey:@"totalValue" defaultValue:nil];
|
|
398
397
|
NSArray *items = [argmap objectForKey:@"items"];
|
|
399
398
|
|
|
400
399
|
NSMutableArray *transItems = [NSMutableArray new];
|
|
401
400
|
for (NSDictionary* item in items) {
|
|
402
|
-
NSString *sku = [item
|
|
403
|
-
NSNumber *price = [item
|
|
404
|
-
NSNumber *quantity = [item
|
|
401
|
+
NSString *sku = [item rnsp_stringForKey:@"sku" defaultValue:nil];
|
|
402
|
+
NSNumber *price = [item rnsp_numberForKey:@"price" defaultValue:nil];
|
|
403
|
+
NSNumber *quantity = [item rnsp_numberForKey:@"quantity" defaultValue:nil];
|
|
405
404
|
SPEcommerceItem *ecomItem = [[SPEcommerceItem alloc] initWithSku:sku
|
|
406
405
|
price:price
|
|
407
406
|
quantity:quantity];
|
|
408
407
|
|
|
409
|
-
NSString *name = [argmap
|
|
408
|
+
NSString *name = [argmap rnsp_stringForKey:@"name" defaultValue:nil];
|
|
410
409
|
if (name) {
|
|
411
410
|
ecomItem.name = name;
|
|
412
411
|
}
|
|
413
|
-
NSString *category = [argmap
|
|
412
|
+
NSString *category = [argmap rnsp_stringForKey:@"category" defaultValue:nil];
|
|
414
413
|
if (category) {
|
|
415
414
|
ecomItem.category = category;
|
|
416
415
|
}
|
|
417
|
-
NSString *currency = [argmap
|
|
416
|
+
NSString *currency = [argmap rnsp_stringForKey:@"currency" defaultValue:nil];
|
|
418
417
|
if (currency) {
|
|
419
418
|
ecomItem.currency = currency;
|
|
420
419
|
}
|
|
@@ -446,10 +445,10 @@ RCT_EXPORT_METHOD(trackDeepLinkReceivedEvent:
|
|
|
446
445
|
NSDictionary *argmap = [details objectForKey:@"eventData"];
|
|
447
446
|
NSArray<NSDictionary *> *contexts = [details objectForKey:@"contexts"];
|
|
448
447
|
|
|
449
|
-
NSString *url = [argmap
|
|
448
|
+
NSString *url = [argmap rnsp_stringForKey:@"url" defaultValue:nil];
|
|
450
449
|
SPDeepLinkReceived *event = [[SPDeepLinkReceived alloc] initWithUrl:url];
|
|
451
450
|
|
|
452
|
-
NSString *referrer = [argmap
|
|
451
|
+
NSString *referrer = [argmap rnsp_stringForKey:@"referrer" defaultValue:nil];
|
|
453
452
|
if (referrer) {
|
|
454
453
|
event.referrer = referrer;
|
|
455
454
|
}
|
|
@@ -474,9 +473,9 @@ RCT_EXPORT_METHOD(trackMessageNotificationEvent:
|
|
|
474
473
|
NSDictionary *argmap = [details objectForKey:@"eventData"];
|
|
475
474
|
NSArray<NSDictionary *> *contexts = [details objectForKey:@"contexts"];
|
|
476
475
|
|
|
477
|
-
NSString *title = [argmap
|
|
478
|
-
NSString *body = [argmap
|
|
479
|
-
NSString *triggerStr = [argmap
|
|
476
|
+
NSString *title = [argmap rnsp_stringForKey:@"title" defaultValue:nil];
|
|
477
|
+
NSString *body = [argmap rnsp_stringForKey:@"body" defaultValue:nil];
|
|
478
|
+
NSString *triggerStr = [argmap rnsp_stringForKey:@"trigger" defaultValue:nil];
|
|
480
479
|
SPMessageNotificationTrigger trigger;
|
|
481
480
|
if ([triggerStr isEqualToString:@"push"]) {
|
|
482
481
|
trigger = SPMessageNotificationTriggerPush;
|
|
@@ -493,7 +492,7 @@ RCT_EXPORT_METHOD(trackMessageNotificationEvent:
|
|
|
493
492
|
body: body
|
|
494
493
|
trigger: trigger];
|
|
495
494
|
|
|
496
|
-
NSString *action = [argmap
|
|
495
|
+
NSString *action = [argmap rnsp_stringForKey:@"action" defaultValue:nil];
|
|
497
496
|
if (action) {
|
|
498
497
|
event.action = action;
|
|
499
498
|
}
|
|
@@ -501,9 +500,9 @@ RCT_EXPORT_METHOD(trackMessageNotificationEvent:
|
|
|
501
500
|
if (attachmentsMap) {
|
|
502
501
|
NSMutableArray *attachments = [NSMutableArray new];
|
|
503
502
|
for (NSDictionary* attachmentMap in attachmentsMap) {
|
|
504
|
-
NSString *identifier = [attachmentMap
|
|
505
|
-
NSString *type = [attachmentMap
|
|
506
|
-
NSString *url = [attachmentMap
|
|
503
|
+
NSString *identifier = [attachmentMap rnsp_stringForKey:@"identifier" defaultValue:nil];
|
|
504
|
+
NSString *type = [attachmentMap rnsp_stringForKey:@"type" defaultValue:nil];
|
|
505
|
+
NSString *url = [attachmentMap rnsp_stringForKey:@"url" defaultValue:nil];
|
|
507
506
|
SPMessageNotificationAttachment *attachment = [[SPMessageNotificationAttachment alloc] initWithIdentifier:identifier
|
|
508
507
|
type:type
|
|
509
508
|
url:url];
|
|
@@ -515,47 +514,47 @@ RCT_EXPORT_METHOD(trackMessageNotificationEvent:
|
|
|
515
514
|
if (bodyLocArgs) {
|
|
516
515
|
event.bodyLocArgs = bodyLocArgs;
|
|
517
516
|
}
|
|
518
|
-
NSString *bodyLocKey = [argmap
|
|
517
|
+
NSString *bodyLocKey = [argmap rnsp_stringForKey:@"bodyLocKey" defaultValue:nil];
|
|
519
518
|
if (bodyLocKey) {
|
|
520
519
|
event.bodyLocKey = bodyLocKey;
|
|
521
520
|
}
|
|
522
|
-
NSString *category = [argmap
|
|
521
|
+
NSString *category = [argmap rnsp_stringForKey:@"category" defaultValue:nil];
|
|
523
522
|
if (category) {
|
|
524
523
|
event.category = category;
|
|
525
524
|
}
|
|
526
|
-
NSNumber *contentAvailable = [argmap
|
|
525
|
+
NSNumber *contentAvailable = [argmap rnsp_numberForKey:@"contentAvailable" defaultValue:nil];
|
|
527
526
|
if (contentAvailable != nil) {
|
|
528
527
|
event.contentAvailable = contentAvailable;
|
|
529
528
|
}
|
|
530
|
-
NSString *group = [argmap
|
|
529
|
+
NSString *group = [argmap rnsp_stringForKey:@"group" defaultValue:nil];
|
|
531
530
|
if (group) {
|
|
532
531
|
event.group = group;
|
|
533
532
|
}
|
|
534
|
-
NSString *icon = [argmap
|
|
533
|
+
NSString *icon = [argmap rnsp_stringForKey:@"icon" defaultValue:nil];
|
|
535
534
|
if (icon) {
|
|
536
535
|
event.icon = icon;
|
|
537
536
|
}
|
|
538
|
-
NSNumber *notificationCount = [argmap
|
|
537
|
+
NSNumber *notificationCount = [argmap rnsp_numberForKey:@"notificationCount" defaultValue:nil];
|
|
539
538
|
if (notificationCount) {
|
|
540
539
|
event.notificationCount = notificationCount;
|
|
541
540
|
}
|
|
542
|
-
NSString *notificationTimestamp = [argmap
|
|
541
|
+
NSString *notificationTimestamp = [argmap rnsp_stringForKey:@"notificationTimestamp" defaultValue:nil];
|
|
543
542
|
if (notificationTimestamp) {
|
|
544
543
|
event.notificationTimestamp = notificationTimestamp;
|
|
545
544
|
}
|
|
546
|
-
NSString *sound = [argmap
|
|
545
|
+
NSString *sound = [argmap rnsp_stringForKey:@"sound" defaultValue:nil];
|
|
547
546
|
if (sound) {
|
|
548
547
|
event.sound = sound;
|
|
549
548
|
}
|
|
550
|
-
NSString *subtitle = [argmap
|
|
549
|
+
NSString *subtitle = [argmap rnsp_stringForKey:@"subtitle" defaultValue:nil];
|
|
551
550
|
if (subtitle) {
|
|
552
551
|
event.subtitle = subtitle;
|
|
553
552
|
}
|
|
554
|
-
NSString *tag = [argmap
|
|
553
|
+
NSString *tag = [argmap rnsp_stringForKey:@"tag" defaultValue:nil];
|
|
555
554
|
if (tag) {
|
|
556
555
|
event.tag = tag;
|
|
557
556
|
}
|
|
558
|
-
NSString *threadIdentifier = [argmap
|
|
557
|
+
NSString *threadIdentifier = [argmap rnsp_stringForKey:@"threadIdentifier" defaultValue:nil];
|
|
559
558
|
if (threadIdentifier) {
|
|
560
559
|
event.threadIdentifier = threadIdentifier;
|
|
561
560
|
}
|
|
@@ -563,7 +562,7 @@ RCT_EXPORT_METHOD(trackMessageNotificationEvent:
|
|
|
563
562
|
if (titleLocArgs) {
|
|
564
563
|
event.titleLocArgs = titleLocArgs;
|
|
565
564
|
}
|
|
566
|
-
NSString *titleLocKey = [argmap
|
|
565
|
+
NSString *titleLocKey = [argmap rnsp_stringForKey:@"titleLocKey" defaultValue:nil];
|
|
567
566
|
if (titleLocKey) {
|
|
568
567
|
event.titleLocKey = titleLocKey;
|
|
569
568
|
}
|
|
@@ -625,7 +624,7 @@ RCT_EXPORT_METHOD(setUserId:
|
|
|
625
624
|
id<SPTrackerController> trackerController = [SPSnowplow trackerByNamespace:namespace];
|
|
626
625
|
|
|
627
626
|
if (trackerController != nil) {
|
|
628
|
-
NSString *newUid = [details
|
|
627
|
+
NSString *newUid = [details rnsp_stringForKey:@"userId" defaultValue:nil];
|
|
629
628
|
[trackerController.subject setUserId:newUid];
|
|
630
629
|
resolve(@YES);
|
|
631
630
|
} else {
|
|
@@ -642,7 +641,7 @@ RCT_EXPORT_METHOD(setNetworkUserId:
|
|
|
642
641
|
id<SPTrackerController> trackerController = [SPSnowplow trackerByNamespace:namespace];
|
|
643
642
|
|
|
644
643
|
if (trackerController != nil) {
|
|
645
|
-
NSString *newNuid = [details
|
|
644
|
+
NSString *newNuid = [details rnsp_stringForKey:@"networkUserId" defaultValue:nil];
|
|
646
645
|
[trackerController.subject setNetworkUserId:newNuid];
|
|
647
646
|
resolve(@YES);
|
|
648
647
|
} else {
|
|
@@ -659,7 +658,7 @@ RCT_EXPORT_METHOD(setDomainUserId:
|
|
|
659
658
|
id<SPTrackerController> trackerController = [SPSnowplow trackerByNamespace:namespace];
|
|
660
659
|
|
|
661
660
|
if (trackerController != nil) {
|
|
662
|
-
NSString *newDuid = [details
|
|
661
|
+
NSString *newDuid = [details rnsp_stringForKey:@"domainUserId" defaultValue:nil];
|
|
663
662
|
[trackerController.subject setDomainUserId:newDuid];
|
|
664
663
|
resolve(@YES);
|
|
665
664
|
} else {
|
|
@@ -676,7 +675,7 @@ RCT_EXPORT_METHOD(setIpAddress:
|
|
|
676
675
|
id<SPTrackerController> trackerController = [SPSnowplow trackerByNamespace:namespace];
|
|
677
676
|
|
|
678
677
|
if (trackerController != nil) {
|
|
679
|
-
NSString *newIp = [details
|
|
678
|
+
NSString *newIp = [details rnsp_stringForKey:@"ipAddress" defaultValue:nil];
|
|
680
679
|
[trackerController.subject setIpAddress:newIp];
|
|
681
680
|
resolve(@YES);
|
|
682
681
|
} else {
|
|
@@ -693,7 +692,7 @@ RCT_EXPORT_METHOD(setUseragent:
|
|
|
693
692
|
id<SPTrackerController> trackerController = [SPSnowplow trackerByNamespace:namespace];
|
|
694
693
|
|
|
695
694
|
if (trackerController != nil) {
|
|
696
|
-
NSString *newUagent = [details
|
|
695
|
+
NSString *newUagent = [details rnsp_stringForKey:@"useragent" defaultValue:nil];
|
|
697
696
|
[trackerController.subject setUseragent:newUagent];
|
|
698
697
|
resolve(@YES);
|
|
699
698
|
} else {
|
|
@@ -710,7 +709,7 @@ RCT_EXPORT_METHOD(setTimezone:
|
|
|
710
709
|
id<SPTrackerController> trackerController = [SPSnowplow trackerByNamespace:namespace];
|
|
711
710
|
|
|
712
711
|
if (trackerController != nil) {
|
|
713
|
-
NSString *newTz = [details
|
|
712
|
+
NSString *newTz = [details rnsp_stringForKey:@"timezone" defaultValue:nil];
|
|
714
713
|
[trackerController.subject setTimezone:newTz];
|
|
715
714
|
resolve(@YES);
|
|
716
715
|
} else {
|
|
@@ -727,7 +726,7 @@ RCT_EXPORT_METHOD(setLanguage:
|
|
|
727
726
|
id<SPTrackerController> trackerController = [SPSnowplow trackerByNamespace:namespace];
|
|
728
727
|
|
|
729
728
|
if (trackerController != nil) {
|
|
730
|
-
NSString *newLang = [details
|
|
729
|
+
NSString *newLang = [details rnsp_stringForKey:@"language" defaultValue:nil];
|
|
731
730
|
[trackerController.subject setLanguage:newLang];
|
|
732
731
|
resolve(@YES);
|
|
733
732
|
} else {
|
|
@@ -792,7 +791,7 @@ RCT_EXPORT_METHOD(setColorDepth:
|
|
|
792
791
|
id<SPTrackerController> trackerController = [SPSnowplow trackerByNamespace:namespace];
|
|
793
792
|
|
|
794
793
|
if (trackerController != nil) {
|
|
795
|
-
NSNumber *newColorD = [details
|
|
794
|
+
NSNumber *newColorD = [details rnsp_numberForKey:@"colorDepth" defaultValue:nil];
|
|
796
795
|
[trackerController.subject setColorDepth:newColorD];
|
|
797
796
|
resolve(@YES);
|
|
798
797
|
} else {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// NSDictionary+RNSP_TypeMethods.h
|
|
3
|
+
//
|
|
4
|
+
// Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
// This program is licensed to you under the Apache License Version 2.0,
|
|
7
|
+
// and you may not use this file except in compliance with the Apache License
|
|
8
|
+
// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0.
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
|
12
|
+
// software distributed under the Apache License Version 2.0 is distributed on
|
|
13
|
+
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
14
|
+
// express or implied. See the Apache License Version 2.0 for the specific
|
|
15
|
+
// language governing permissions and limitations there under.
|
|
16
|
+
//
|
|
17
|
+
// Copyright: Copyright (c) 2022 Snowplow Analytics Ltd
|
|
18
|
+
// License: Apache License Version 2.0
|
|
19
|
+
//
|
|
20
|
+
|
|
21
|
+
#import <Foundation/Foundation.h>
|
|
22
|
+
|
|
23
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
24
|
+
|
|
25
|
+
@interface NSDictionary (RNSP_TypeMethods)
|
|
26
|
+
|
|
27
|
+
- (nullable NSString *)rnsp_stringForKey:(NSString *)key defaultValue:(nullable NSString *)defaultValue;
|
|
28
|
+
- (nullable NSNumber *)rnsp_numberForKey:(NSString *)key defaultValue:(nullable NSNumber *)defaultValue;
|
|
29
|
+
- (BOOL)rnsp_boolForKey:(NSString *)key defaultValue:(BOOL)defaultValue;
|
|
30
|
+
|
|
31
|
+
@end
|
|
32
|
+
|
|
33
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//
|
|
2
|
+
// NSDictionary+RNSP_TypeMethods.m
|
|
3
|
+
//
|
|
4
|
+
// Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved.
|
|
5
|
+
//
|
|
6
|
+
// This program is licensed to you under the Apache License Version 2.0,
|
|
7
|
+
// and you may not use this file except in compliance with the Apache License
|
|
8
|
+
// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0.
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
|
12
|
+
// software distributed under the Apache License Version 2.0 is distributed on
|
|
13
|
+
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
14
|
+
// express or implied. See the Apache License Version 2.0 for the specific
|
|
15
|
+
// language governing permissions and limitations there under.
|
|
16
|
+
//
|
|
17
|
+
// Copyright: Copyright (c) 2022 Snowplow Analytics Ltd
|
|
18
|
+
// License: Apache License Version 2.0
|
|
19
|
+
//
|
|
20
|
+
|
|
21
|
+
#import "NSDictionary+RNSP_TypeMethods.h"
|
|
22
|
+
|
|
23
|
+
@implementation NSDictionary (RNSP_TypeMethods)
|
|
24
|
+
|
|
25
|
+
- (nullable NSString *)rnsp_stringForKey:(NSString *)key defaultValue:(nullable NSString *)defaultValue {
|
|
26
|
+
NSObject *obj = [self objectForKey:key];
|
|
27
|
+
return [obj isKindOfClass:NSString.class] ? (NSString *)obj : defaultValue;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
- (nullable NSNumber *)rnsp_numberForKey:(NSString *)key defaultValue:(nullable NSNumber *)defaultValue {
|
|
31
|
+
NSObject *obj = [self objectForKey:key];
|
|
32
|
+
return [obj isKindOfClass:NSNumber.class] ? (NSNumber *)obj : defaultValue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
- (BOOL)rnsp_boolForKey:(NSString *)key defaultValue:(BOOL)defaultValue {
|
|
36
|
+
NSNumber *num = [self rnsp_numberForKey:key defaultValue:nil];
|
|
37
|
+
return num ? num.boolValue : defaultValue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@end
|
package/ios/Util/RNConfigUtils.m
CHANGED
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
#import "RNConfigUtils.h"
|
|
22
22
|
#import "RNTrackerVersion.h"
|
|
23
23
|
#import "RNUtilities.h"
|
|
24
|
+
#import "NSDictionary+RNSP_TypeMethods.h"
|
|
24
25
|
|
|
25
26
|
#import <Foundation/Foundation.h>
|
|
26
27
|
|
|
27
28
|
#import <SnowplowTracker/SPSnowplow.h>
|
|
28
|
-
#import <SnowplowTracker/NSDictionary+SP_TypeMethods.h>
|
|
29
29
|
#import <SnowplowTracker/SPTrackerConfiguration.h>
|
|
30
30
|
#import <SnowplowTracker/SPDevicePlatform.h>
|
|
31
31
|
#import <SnowplowTracker/SPLoggerDelegate.h>
|
|
@@ -41,43 +41,43 @@
|
|
|
41
41
|
SPTrackerConfiguration *trackerConfiguration = [SPTrackerConfiguration new];
|
|
42
42
|
trackerConfiguration.trackerVersionSuffix = kRNTrackerVersion;
|
|
43
43
|
|
|
44
|
-
NSString *appId = [trackerConfig
|
|
44
|
+
NSString *appId = [trackerConfig rnsp_stringForKey:@"appId" defaultValue:nil];
|
|
45
45
|
if (appId) {
|
|
46
46
|
trackerConfiguration.appId = appId;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
NSString *devicePlatform = [trackerConfig
|
|
49
|
+
NSString *devicePlatform = [trackerConfig rnsp_stringForKey:@"devicePlatform" defaultValue:nil];
|
|
50
50
|
if (devicePlatform) {
|
|
51
51
|
trackerConfiguration.devicePlatform = SPStringToDevicePlatform(devicePlatform);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
trackerConfiguration.base64Encoding = [trackerConfig
|
|
54
|
+
trackerConfiguration.base64Encoding = [trackerConfig rnsp_boolForKey:@"base64Encoding" defaultValue:YES];
|
|
55
55
|
|
|
56
|
-
NSString *logLevel = [trackerConfig
|
|
56
|
+
NSString *logLevel = [trackerConfig rnsp_stringForKey:@"logLevel" defaultValue:nil];
|
|
57
57
|
if (logLevel) {
|
|
58
58
|
NSUInteger index = [@[@"off", @"error", @"debug", @"verbose"] indexOfObject:logLevel];
|
|
59
59
|
trackerConfiguration.logLevel = index != NSNotFound ? index : SPLogLevelOff;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
trackerConfiguration.sessionContext = [trackerConfig
|
|
63
|
-
trackerConfiguration.applicationContext = [trackerConfig
|
|
64
|
-
trackerConfiguration.platformContext = [trackerConfig
|
|
65
|
-
trackerConfiguration.geoLocationContext = [trackerConfig
|
|
66
|
-
trackerConfiguration.screenContext = [trackerConfig
|
|
67
|
-
trackerConfiguration.deepLinkContext = [trackerConfig
|
|
68
|
-
trackerConfiguration.screenViewAutotracking = [trackerConfig
|
|
69
|
-
trackerConfiguration.lifecycleAutotracking = [trackerConfig
|
|
70
|
-
trackerConfiguration.installAutotracking = [trackerConfig
|
|
71
|
-
trackerConfiguration.exceptionAutotracking = [trackerConfig
|
|
72
|
-
trackerConfiguration.diagnosticAutotracking = [trackerConfig
|
|
62
|
+
trackerConfiguration.sessionContext = [trackerConfig rnsp_boolForKey:@"sessionContext" defaultValue:YES];
|
|
63
|
+
trackerConfiguration.applicationContext = [trackerConfig rnsp_boolForKey:@"applicationContext" defaultValue:YES];
|
|
64
|
+
trackerConfiguration.platformContext = [trackerConfig rnsp_boolForKey:@"platformContext" defaultValue:YES];
|
|
65
|
+
trackerConfiguration.geoLocationContext = [trackerConfig rnsp_boolForKey:@"geoLocationContext" defaultValue:NO];
|
|
66
|
+
trackerConfiguration.screenContext = [trackerConfig rnsp_boolForKey:@"screenContext" defaultValue:YES];
|
|
67
|
+
trackerConfiguration.deepLinkContext = [trackerConfig rnsp_boolForKey:@"deepLinkContext" defaultValue:YES];
|
|
68
|
+
trackerConfiguration.screenViewAutotracking = [trackerConfig rnsp_boolForKey:@"screenViewAutotracking" defaultValue:YES];
|
|
69
|
+
trackerConfiguration.lifecycleAutotracking = [trackerConfig rnsp_boolForKey:@"lifecycleAutotracking" defaultValue:NO];
|
|
70
|
+
trackerConfiguration.installAutotracking = [trackerConfig rnsp_boolForKey:@"installAutotracking" defaultValue:YES];
|
|
71
|
+
trackerConfiguration.exceptionAutotracking = [trackerConfig rnsp_boolForKey:@"exceptionAutotracking" defaultValue:YES];
|
|
72
|
+
trackerConfiguration.diagnosticAutotracking = [trackerConfig rnsp_boolForKey:@"diagnosticAutotracking" defaultValue:NO];
|
|
73
73
|
|
|
74
74
|
return trackerConfiguration;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
+ (SPSessionConfiguration *) mkSessionConfig:(NSDictionary *) sessionConfig {
|
|
78
78
|
|
|
79
|
-
NSInteger foreground = [[sessionConfig
|
|
80
|
-
NSInteger background = [[sessionConfig
|
|
79
|
+
NSInteger foreground = [[sessionConfig rnsp_numberForKey:@"foregroundTimeout" defaultValue:@1800] integerValue];
|
|
80
|
+
NSInteger background = [[sessionConfig rnsp_numberForKey:@"backgroundTimeout" defaultValue:@1800] integerValue];
|
|
81
81
|
SPSessionConfiguration *sessionConfiguration = [[SPSessionConfiguration alloc] initWithForegroundTimeoutInSeconds:foreground backgroundTimeoutInSeconds:background];
|
|
82
82
|
|
|
83
83
|
return sessionConfiguration;
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
|
|
86
86
|
+ (SPEmitterConfiguration *) mkEmitterConfig:(NSDictionary *) emitterConfig {
|
|
87
87
|
SPEmitterConfiguration *emitterConfiguration = [[SPEmitterConfiguration alloc] init];
|
|
88
|
-
NSString *bufferOption = [emitterConfig
|
|
88
|
+
NSString *bufferOption = [emitterConfig rnsp_stringForKey:@"bufferOption" defaultValue:@"single"];
|
|
89
89
|
if ([bufferOption isEqualToString:@"default"]) {
|
|
90
90
|
emitterConfiguration.bufferOption = SPBufferOptionDefaultGroup;
|
|
91
91
|
} else if ([bufferOption isEqualToString:@"large"]) {
|
|
@@ -94,10 +94,10 @@
|
|
|
94
94
|
emitterConfiguration.bufferOption = SPBufferOptionSingle;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
emitterConfiguration.emitRange = [[emitterConfig
|
|
98
|
-
emitterConfiguration.threadPoolSize = [[emitterConfig
|
|
99
|
-
emitterConfiguration.byteLimitGet = [[emitterConfig
|
|
100
|
-
emitterConfiguration.byteLimitPost = [[emitterConfig
|
|
97
|
+
emitterConfiguration.emitRange = [[emitterConfig rnsp_numberForKey:@"emitRange" defaultValue:@150] integerValue];
|
|
98
|
+
emitterConfiguration.threadPoolSize = [[emitterConfig rnsp_numberForKey:@"threadPoolSize" defaultValue:@15] integerValue];
|
|
99
|
+
emitterConfiguration.byteLimitGet = [[emitterConfig rnsp_numberForKey:@"byteLimitGet" defaultValue:@40000] integerValue];
|
|
100
|
+
emitterConfiguration.byteLimitPost = [[emitterConfig rnsp_numberForKey:@"byteLimitPost" defaultValue:@40000] integerValue];
|
|
101
101
|
|
|
102
102
|
return emitterConfiguration;
|
|
103
103
|
}
|
|
@@ -106,37 +106,37 @@
|
|
|
106
106
|
|
|
107
107
|
SPSubjectConfiguration *subjectConfiguration = [SPSubjectConfiguration new];
|
|
108
108
|
|
|
109
|
-
NSString *userId = [subjectConfig
|
|
109
|
+
NSString *userId = [subjectConfig rnsp_stringForKey:@"userId" defaultValue:nil];
|
|
110
110
|
if (userId) {
|
|
111
111
|
subjectConfiguration.userId = userId;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
NSString *networkUserId = [subjectConfig
|
|
114
|
+
NSString *networkUserId = [subjectConfig rnsp_stringForKey:@"networkUserId" defaultValue:nil];
|
|
115
115
|
if (networkUserId) {
|
|
116
116
|
subjectConfiguration.networkUserId = networkUserId;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
NSString *domainUserId = [subjectConfig
|
|
119
|
+
NSString *domainUserId = [subjectConfig rnsp_stringForKey:@"domainUserId" defaultValue:nil];
|
|
120
120
|
if (domainUserId) {
|
|
121
121
|
subjectConfiguration.domainUserId = domainUserId;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
NSString *useragent = [subjectConfig
|
|
124
|
+
NSString *useragent = [subjectConfig rnsp_stringForKey:@"useragent" defaultValue:nil];
|
|
125
125
|
if (useragent) {
|
|
126
126
|
subjectConfiguration.useragent = useragent;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
NSString *ipAddress = [subjectConfig
|
|
129
|
+
NSString *ipAddress = [subjectConfig rnsp_stringForKey:@"ipAddress" defaultValue:nil];
|
|
130
130
|
if (ipAddress) {
|
|
131
131
|
subjectConfiguration.ipAddress = ipAddress;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
NSString *timezone = [subjectConfig
|
|
134
|
+
NSString *timezone = [subjectConfig rnsp_stringForKey:@"timezone" defaultValue:nil];
|
|
135
135
|
if (timezone) {
|
|
136
136
|
subjectConfiguration.timezone = timezone;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
NSString *language = [subjectConfig
|
|
139
|
+
NSString *language = [subjectConfig rnsp_stringForKey:@"language" defaultValue:nil];
|
|
140
140
|
if (language) {
|
|
141
141
|
subjectConfiguration.language = language;
|
|
142
142
|
}
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
// colorDepth
|
|
163
|
-
NSNumber *colorDepth = [subjectConfig
|
|
163
|
+
NSNumber *colorDepth = [subjectConfig rnsp_numberForKey:@"colorDepth" defaultValue: nil];
|
|
164
164
|
if (colorDepth != nil) {
|
|
165
165
|
subjectConfiguration.colorDepth = colorDepth;
|
|
166
166
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snowplow/react-native-tracker",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "A library for tracking Snowplow events in React Native",
|
|
5
5
|
"homepage": "https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/react-native-tracker/",
|
|
6
6
|
"main": "dist/index.js",
|