@snowplow/react-native-tracker 1.0.0 → 1.1.0

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.
@@ -1,7 +1,7 @@
1
1
  //
2
2
  // RNSnowplowTracker.m
3
3
  //
4
- // Copyright (c) 2020-2021 Snowplow Analytics Ltd. All rights reserved.
4
+ // Copyright (c) 2020-2022 Snowplow Analytics Ltd. All rights reserved.
5
5
  //
6
6
  // This program is licensed to you under the Apache License Version 2.0,
7
7
  // and you may not use this file except in compliance with the Apache License
@@ -14,7 +14,7 @@
14
14
  // express or implied. See the Apache License Version 2.0 for the specific
15
15
  // language governing permissions and limitations there under.
16
16
  //
17
- // Copyright: Copyright (c) 2021 Snowplow Analytics Ltd
17
+ // Copyright: Copyright (c) 2022 Snowplow Analytics Ltd
18
18
  // License: Apache License Version 2.0
19
19
  //
20
20
 
@@ -44,6 +44,8 @@
44
44
  #import <SnowplowTracker/SPStructured.h>
45
45
  #import <SnowplowTracker/SPEcommerceItem.h>
46
46
  #import <SnowplowTracker/SPEcommerce.h>
47
+ #import <SnowplowTracker/SPDeepLinkReceived.h>
48
+ #import <SnowplowTracker/SPMessageNotification.h>
47
49
 
48
50
 
49
51
  @implementation RNSnowplowTracker
@@ -433,6 +435,148 @@ RCT_EXPORT_METHOD(trackEcommerceTransactionEvent:
433
435
  }
434
436
  }
435
437
 
438
+ RCT_EXPORT_METHOD(trackDeepLinkReceivedEvent:
439
+ (NSDictionary *)details
440
+ resolver:(RCTPromiseResolveBlock)resolve
441
+ rejecter:(RCTPromiseRejectBlock)reject) {
442
+ NSString *namespace = [details objectForKey:@"tracker"];
443
+ id<SPTrackerController> trackerController = [SPSnowplow trackerByNamespace:namespace];
444
+
445
+ if (trackerController != nil) {
446
+ NSDictionary *argmap = [details objectForKey:@"eventData"];
447
+ NSArray<NSDictionary *> *contexts = [details objectForKey:@"contexts"];
448
+
449
+ NSString *url = [argmap sp_stringForKey:@"url" defaultValue:nil];
450
+ SPDeepLinkReceived *event = [[SPDeepLinkReceived alloc] initWithUrl:url];
451
+
452
+ NSString *referrer = [argmap sp_stringForKey:@"referrer" defaultValue:nil];
453
+ if (referrer) {
454
+ event.referrer = referrer;
455
+ }
456
+
457
+ [event contexts:[RNUtilities mkSDJArray:contexts]];
458
+ [trackerController track:event];
459
+ resolve(@YES);
460
+ } else {
461
+ NSError* error = [NSError errorWithDomain:@"SnowplowTracker" code:200 userInfo:nil];
462
+ reject(@"ERROR", @"tracker with given namespace not found", error);
463
+ }
464
+ }
465
+
466
+ RCT_EXPORT_METHOD(trackMessageNotificationEvent:
467
+ (NSDictionary *)details
468
+ resolver:(RCTPromiseResolveBlock)resolve
469
+ rejecter:(RCTPromiseRejectBlock)reject) {
470
+ NSString *namespace = [details objectForKey:@"tracker"];
471
+ id<SPTrackerController> trackerController = [SPSnowplow trackerByNamespace:namespace];
472
+
473
+ if (trackerController != nil) {
474
+ NSDictionary *argmap = [details objectForKey:@"eventData"];
475
+ NSArray<NSDictionary *> *contexts = [details objectForKey:@"contexts"];
476
+
477
+ NSString *title = [argmap sp_stringForKey:@"title" defaultValue:nil];
478
+ NSString *body = [argmap sp_stringForKey:@"body" defaultValue:nil];
479
+ NSString *triggerStr = [argmap sp_stringForKey:@"trigger" defaultValue:nil];
480
+ SPMessageNotificationTrigger trigger;
481
+ if ([triggerStr isEqualToString:@"push"]) {
482
+ trigger = SPMessageNotificationTriggerPush;
483
+ } else if ([triggerStr isEqualToString:@"location"]) {
484
+ trigger = SPMessageNotificationTriggerLocation;
485
+ } else if ([triggerStr isEqualToString:@"calendar"]) {
486
+ trigger = SPMessageNotificationTriggerCalendar;
487
+ } else if ([triggerStr isEqualToString:@"timeInterval"]) {
488
+ trigger = SPMessageNotificationTriggerTimeInterval;
489
+ } else {
490
+ trigger = SPMessageNotificationTriggerOther;
491
+ }
492
+ SPMessageNotification *event = [[SPMessageNotification alloc] initWithTitle: title
493
+ body: body
494
+ trigger: trigger];
495
+
496
+ NSString *action = [argmap sp_stringForKey:@"action" defaultValue:nil];
497
+ if (action) {
498
+ event.action = action;
499
+ }
500
+ NSArray *attachmentsMap = [argmap objectForKey:@"attachments"];
501
+ if (attachmentsMap) {
502
+ NSMutableArray *attachments = [NSMutableArray new];
503
+ for (NSDictionary* attachmentMap in attachmentsMap) {
504
+ NSString *identifier = [attachmentMap sp_stringForKey:@"identifier" defaultValue:nil];
505
+ NSString *type = [attachmentMap sp_stringForKey:@"type" defaultValue:nil];
506
+ NSString *url = [attachmentMap sp_stringForKey:@"url" defaultValue:nil];
507
+ SPMessageNotificationAttachment *attachment = [[SPMessageNotificationAttachment alloc] initWithIdentifier:identifier
508
+ type:type
509
+ url:url];
510
+ [attachments addObject:attachment];
511
+ }
512
+ event.attachments = attachments;
513
+ }
514
+ NSArray<NSString *> *bodyLocArgs = [argmap objectForKey:@"bodyLocArgs"];
515
+ if (bodyLocArgs) {
516
+ event.bodyLocArgs = bodyLocArgs;
517
+ }
518
+ NSString *bodyLocKey = [argmap sp_stringForKey:@"bodyLocKey" defaultValue:nil];
519
+ if (bodyLocKey) {
520
+ event.bodyLocKey = bodyLocKey;
521
+ }
522
+ NSString *category = [argmap sp_stringForKey:@"category" defaultValue:nil];
523
+ if (category) {
524
+ event.category = category;
525
+ }
526
+ NSNumber *contentAvailable = [argmap sp_numberForKey:@"contentAvailable" defaultValue:nil];
527
+ if (contentAvailable != nil) {
528
+ event.contentAvailable = contentAvailable;
529
+ }
530
+ NSString *group = [argmap sp_stringForKey:@"group" defaultValue:nil];
531
+ if (group) {
532
+ event.group = group;
533
+ }
534
+ NSString *icon = [argmap sp_stringForKey:@"icon" defaultValue:nil];
535
+ if (icon) {
536
+ event.icon = icon;
537
+ }
538
+ NSNumber *notificationCount = [argmap sp_numberForKey:@"notificationCount" defaultValue:nil];
539
+ if (notificationCount) {
540
+ event.notificationCount = notificationCount;
541
+ }
542
+ NSString *notificationTimestamp = [argmap sp_stringForKey:@"notificationTimestamp" defaultValue:nil];
543
+ if (notificationTimestamp) {
544
+ event.notificationTimestamp = notificationTimestamp;
545
+ }
546
+ NSString *sound = [argmap sp_stringForKey:@"sound" defaultValue:nil];
547
+ if (sound) {
548
+ event.sound = sound;
549
+ }
550
+ NSString *subtitle = [argmap sp_stringForKey:@"subtitle" defaultValue:nil];
551
+ if (subtitle) {
552
+ event.subtitle = subtitle;
553
+ }
554
+ NSString *tag = [argmap sp_stringForKey:@"tag" defaultValue:nil];
555
+ if (tag) {
556
+ event.tag = tag;
557
+ }
558
+ NSString *threadIdentifier = [argmap sp_stringForKey:@"threadIdentifier" defaultValue:nil];
559
+ if (threadIdentifier) {
560
+ event.threadIdentifier = threadIdentifier;
561
+ }
562
+ NSArray<NSString *> *titleLocArgs = [argmap objectForKey:@"titleLocArgs"];
563
+ if (titleLocArgs) {
564
+ event.titleLocArgs = titleLocArgs;
565
+ }
566
+ NSString *titleLocKey = [argmap sp_stringForKey:@"titleLocKey" defaultValue:nil];
567
+ if (titleLocKey) {
568
+ event.titleLocKey = titleLocKey;
569
+ }
570
+
571
+ [event contexts:[RNUtilities mkSDJArray:contexts]];
572
+ [trackerController track:event];
573
+ resolve(@YES);
574
+ } else {
575
+ NSError* error = [NSError errorWithDomain:@"SnowplowTracker" code:200 userInfo:nil];
576
+ reject(@"ERROR", @"tracker with given namespace not found", error);
577
+ }
578
+ }
579
+
436
580
  RCT_EXPORT_METHOD(removeGlobalContexts:
437
581
  (NSDictionary *)details
438
582
  resolver:(RCTPromiseResolveBlock)resolve
@@ -1,7 +1,7 @@
1
1
  //
2
2
  // RNConfigUtils.h
3
3
  //
4
- // Copyright (c) 2021 Snowplow Analytics Ltd. All rights reserved.
4
+ // Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved.
5
5
  //
6
6
  // This program is licensed to you under the Apache License Version 2.0,
7
7
  // and you may not use this file except in compliance with the Apache License
@@ -14,7 +14,7 @@
14
14
  // express or implied. See the Apache License Version 2.0 for the specific
15
15
  // language governing permissions and limitations there under.
16
16
  //
17
- // Copyright: Copyright (c) 2021 Snowplow Analytics Ltd
17
+ // Copyright: Copyright (c) 2022 Snowplow Analytics Ltd
18
18
  // License: Apache License Version 2.0
19
19
  //
20
20
 
@@ -1,7 +1,7 @@
1
1
  //
2
2
  // RNConfigUtils.m
3
3
  //
4
- // Copyright (c) 2021 Snowplow Analytics Ltd. All rights reserved.
4
+ // Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved.
5
5
  //
6
6
  // This program is licensed to you under the Apache License Version 2.0,
7
7
  // and you may not use this file except in compliance with the Apache License
@@ -14,7 +14,7 @@
14
14
  // express or implied. See the Apache License Version 2.0 for the specific
15
15
  // language governing permissions and limitations there under.
16
16
  //
17
- // Copyright: Copyright (c) 2021 Snowplow Analytics Ltd
17
+ // Copyright: Copyright (c) 2022 Snowplow Analytics Ltd
18
18
  // License: Apache License Version 2.0
19
19
  //
20
20
 
@@ -64,6 +64,7 @@
64
64
  trackerConfiguration.platformContext = [trackerConfig sp_boolForKey:@"platformContext" defaultValue:YES];
65
65
  trackerConfiguration.geoLocationContext = [trackerConfig sp_boolForKey:@"geoLocationContext" defaultValue:NO];
66
66
  trackerConfiguration.screenContext = [trackerConfig sp_boolForKey:@"screenContext" defaultValue:YES];
67
+ trackerConfiguration.deepLinkContext = [trackerConfig sp_boolForKey:@"deepLinkContext" defaultValue:YES];
67
68
  trackerConfiguration.screenViewAutotracking = [trackerConfig sp_boolForKey:@"screenViewAutotracking" defaultValue:YES];
68
69
  trackerConfiguration.lifecycleAutotracking = [trackerConfig sp_boolForKey:@"lifecycleAutotracking" defaultValue:NO];
69
70
  trackerConfiguration.installAutotracking = [trackerConfig sp_boolForKey:@"installAutotracking" defaultValue:YES];
@@ -1,7 +1,7 @@
1
1
  //
2
2
  // RNTrackerVersion.h
3
3
  //
4
- // Copyright (c) 2021 Snowplow Analytics Ltd. All rights reserved.
4
+ // Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved.
5
5
  //
6
6
  // This program is licensed to you under the Apache License Version 2.0,
7
7
  // and you may not use this file except in compliance with the Apache License
@@ -14,7 +14,7 @@
14
14
  // express or implied. See the Apache License Version 2.0 for the specific
15
15
  // language governing permissions and limitations there under.
16
16
  //
17
- // Copyright: Copyright (c) 2021 Snowplow Analytics Ltd
17
+ // Copyright: Copyright (c) 2022 Snowplow Analytics Ltd
18
18
  // License: Apache License Version 2.0
19
19
  //
20
20
 
@@ -1,7 +1,7 @@
1
1
  //
2
2
  // RNTrackerVersion.m
3
3
  //
4
- // Copyright (c) 2021 Snowplow Analytics Ltd. All rights reserved.
4
+ // Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved.
5
5
  //
6
6
  // This program is licensed to you under the Apache License Version 2.0,
7
7
  // and you may not use this file except in compliance with the Apache License
@@ -14,7 +14,7 @@
14
14
  // express or implied. See the Apache License Version 2.0 for the specific
15
15
  // language governing permissions and limitations there under.
16
16
  //
17
- // Copyright: Copyright (c) 2021 Snowplow Analytics Ltd
17
+ // Copyright: Copyright (c) 2022 Snowplow Analytics Ltd
18
18
  // License: Apache License Version 2.0
19
19
  //
20
20
 
@@ -22,6 +22,6 @@
22
22
 
23
23
  @implementation RNTrackerVersion
24
24
 
25
- NSString * const kRNTrackerVersion = @"rn-1.0.0";
25
+ NSString * const kRNTrackerVersion = @"rn-1.1.0";
26
26
 
27
27
  @end
@@ -1,7 +1,7 @@
1
1
  //
2
2
  // RNUtilities.h
3
3
  //
4
- // Copyright (c) 2021 Snowplow Analytics Ltd. All rights reserved.
4
+ // Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved.
5
5
  //
6
6
  // This program is licensed to you under the Apache License Version 2.0,
7
7
  // and you may not use this file except in compliance with the Apache License
@@ -14,7 +14,7 @@
14
14
  // express or implied. See the Apache License Version 2.0 for the specific
15
15
  // language governing permissions and limitations there under.
16
16
  //
17
- // Copyright: Copyright (c) 2021 Snowplow Analytics Ltd
17
+ // Copyright: Copyright (c) 2022 Snowplow Analytics Ltd
18
18
  // License: Apache License Version 2.0
19
19
  //
20
20
 
@@ -1,7 +1,7 @@
1
1
  //
2
2
  // RNUtilities.m
3
3
  //
4
- // Copyright (c) 2021 Snowplow Analytics Ltd. All rights reserved.
4
+ // Copyright (c) 2021-2022 Snowplow Analytics Ltd. All rights reserved.
5
5
  //
6
6
  // This program is licensed to you under the Apache License Version 2.0,
7
7
  // and you may not use this file except in compliance with the Apache License
@@ -14,7 +14,7 @@
14
14
  // express or implied. See the Apache License Version 2.0 for the specific
15
15
  // language governing permissions and limitations there under.
16
16
  //
17
- // Copyright: Copyright (c) 2021 Snowplow Analytics Ltd
17
+ // Copyright: Copyright (c) 2022 Snowplow Analytics Ltd
18
18
  // License: Apache License Version 2.0
19
19
  //
20
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowplow/react-native-tracker",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
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",
@@ -30,7 +30,8 @@
30
30
  "James Munro",
31
31
  "Max Bondarenko",
32
32
  "Paul Boocock",
33
- "Ada Tzereme"
33
+ "Ada Tzereme",
34
+ "Matus Tomlein"
34
35
  ],
35
36
  "license": "Apache-2.0",
36
37
  "repository": {
@@ -42,21 +43,21 @@
42
43
  "react-native": ">=0.59.8"
43
44
  },
44
45
  "devDependencies": {
45
- "@types/jest": "^26.0.24",
46
- "@types/react": "^17.0.15",
47
- "@types/react-native": "^0.64.12",
48
- "@typescript-eslint/eslint-plugin": "^4.29.0",
49
- "@typescript-eslint/parser": "^4.29.0",
50
- "eslint": "^7.32.0",
51
- "eslint-plugin-jest": "^24.4.0",
52
- "eslint-plugin-promise": "^5.1.0",
53
- "jest": "^27.0.6",
46
+ "@types/jest": "^27.4.0",
47
+ "@types/react": "^17.0.39",
48
+ "@types/react-native": "^0.66.15",
49
+ "@typescript-eslint/eslint-plugin": "^5.10.2",
50
+ "@typescript-eslint/parser": "^5.10.2",
51
+ "eslint": "^8.8.0",
52
+ "eslint-plugin-jest": "^26.1.0",
53
+ "eslint-plugin-promise": "^6.0.0",
54
+ "jest": "^27.5.0",
54
55
  "rimraf": "^3.0.2",
55
- "rollup": "^2.56.0",
56
- "rollup-plugin-dts": "^3.0.2",
56
+ "rollup": "^2.67.1",
57
+ "rollup-plugin-dts": "^4.1.0",
57
58
  "rollup-plugin-sourcemaps": "^0.6.3",
58
- "ts-jest": "^27.0.4",
59
- "typescript": "^4.3.5"
59
+ "ts-jest": "^27.1.3",
60
+ "typescript": "^4.5.5"
60
61
  },
61
62
  "jest": {
62
63
  "testEnvironment": "node",