@convivainc/conviva-react-native-appanalytics 0.2.7 → 0.2.8

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.md CHANGED
@@ -1,6 +1,10 @@
1
1
 
2
2
  # Changelog
3
3
 
4
+ ## 0.2.8 (06/Apr/2025)
5
+ - Added trackRevenueEvent API to track purchase and revenue events.
6
+ - Using latest android(v1.3.1) and ios(v1.10.1) native packages.
7
+
4
8
  ## 0.2.7 (31/Dec/2025)
5
9
  - Supports network request url query params tracking.
6
10
  - Enhanced the remote configuration feature to support instant updates.
@@ -20,5 +20,5 @@ Pod::Spec.new do |s|
20
20
  s.requires_arc = true
21
21
 
22
22
  s.dependency "React-Core"
23
- s.dependency "ConvivaAppAnalytics", "1.8.0"
23
+ s.dependency "ConvivaAppAnalytics", "1.10.1"
24
24
  end
@@ -16,6 +16,7 @@ buildscript {
16
16
  apply plugin: "com.android.library"
17
17
 
18
18
  android {
19
+ namespace "com.conviva.react.apptracker"
19
20
  compileSdkVersion safeExtGet('compileSdkVersion', 33)
20
21
  buildToolsVersion safeExtGet('buildToolsVersion', '30.0.2')
21
22
 
@@ -28,10 +29,6 @@ android {
28
29
  lintOptions {
29
30
  abortOnError false
30
31
  }
31
- buildFeatures {
32
- buildConfig true
33
- }
34
- namespace "com.conviva.react.apptracker"
35
32
  compileOptions {
36
33
  sourceCompatibility JavaVersion.VERSION_1_8
37
34
  targetCompatibility JavaVersion.VERSION_1_8
@@ -55,5 +52,5 @@ dependencies {
55
52
  implementation "com.squareup.okhttp3:okhttp:4.9.3"
56
53
  implementation "com.facebook.react:react-native:+"
57
54
  implementation 'com.googlecode.json-simple:json-simple:1.1'
58
- implementation 'com.conviva.sdk:conviva-android-tracker:1.2.6'
55
+ implementation 'com.conviva.sdk:conviva-android-tracker:1.3.1'
59
56
  }
@@ -13,6 +13,8 @@ import com.conviva.apptracker.configuration.TrackerConfiguration;
13
13
  import com.conviva.apptracker.controller.TrackerController;
14
14
  import com.conviva.apptracker.event.ButtonClick;
15
15
  import com.conviva.apptracker.event.ConsentGranted;
16
+ import com.conviva.apptracker.revenue.ConvivaRevenueEvent;
17
+ import com.conviva.apptracker.revenue.ConvivaRevenueEventItem;
16
18
  import com.conviva.apptracker.event.ConsentWithdrawn;
17
19
  import com.conviva.apptracker.event.DeepLinkReceived;
18
20
  import com.conviva.apptracker.event.EcommerceTransaction;
@@ -37,6 +39,7 @@ import com.facebook.react.bridge.ReadableArray;
37
39
  import com.facebook.react.bridge.ReadableMap;
38
40
  import com.facebook.react.bridge.ReadableMapKeySetIterator;
39
41
 
42
+ import org.json.JSONObject;
40
43
  import org.json.simple.JSONValue;
41
44
 
42
45
  import java.util.ArrayList;
@@ -543,6 +546,78 @@ public class RNConvivaTrackerModule extends ReactContextBaseJavaModule {
543
546
  }
544
547
  }
545
548
 
549
+ @ReactMethod
550
+ public void trackRevenueEvent(ReadableMap details, Promise promise) {
551
+ try {
552
+ String namespace = details.getString("tracker");
553
+ TrackerController trackerController = getTracker(namespace);
554
+ if (trackerController != null) {
555
+ ReadableMap argmap = details.getMap("eventData");
556
+
557
+ double totalOrderAmount = argmap.getDouble("totalOrderAmount");
558
+ String transactionId = argmap.getString("transactionId");
559
+ String currency = argmap.getString("currency");
560
+
561
+ ConvivaRevenueEvent.Builder builder =
562
+ ConvivaRevenueEvent.builder(totalOrderAmount, transactionId, currency);
563
+
564
+ if (argmap.hasKey("taxAmount") && !argmap.isNull("taxAmount"))
565
+ builder.taxAmount(argmap.getDouble("taxAmount"));
566
+ if (argmap.hasKey("shippingCost") && !argmap.isNull("shippingCost"))
567
+ builder.shippingCost(argmap.getDouble("shippingCost"));
568
+ if (argmap.hasKey("discount") && !argmap.isNull("discount"))
569
+ builder.discount(argmap.getDouble("discount"));
570
+ if (argmap.hasKey("cartSize") && !argmap.isNull("cartSize"))
571
+ builder.cartSize(argmap.getInt("cartSize"));
572
+ if (argmap.hasKey("paymentMethod") && !argmap.isNull("paymentMethod"))
573
+ builder.paymentMethod(argmap.getString("paymentMethod"));
574
+ if (argmap.hasKey("paymentProvider") && !argmap.isNull("paymentProvider"))
575
+ builder.paymentProvider(argmap.getString("paymentProvider"));
576
+ if (argmap.hasKey("extraMetadata") && !argmap.isNull("extraMetadata"))
577
+ builder.extraMetadata(new JSONObject(argmap.getMap("extraMetadata").toHashMap()));
578
+
579
+ if (argmap.hasKey("items") && !argmap.isNull("items")) {
580
+ ReadableArray itemsArray = argmap.getArray("items");
581
+ List<ConvivaRevenueEventItem> items = new ArrayList<>();
582
+ for (int i = 0; i < itemsArray.size(); i++) {
583
+ ReadableMap itemDict = itemsArray.getMap(i);
584
+ ConvivaRevenueEventItem.Builder itemBuilder = ConvivaRevenueEventItem.builder();
585
+ if (itemDict.hasKey("productId") && !itemDict.isNull("productId"))
586
+ itemBuilder.productId(itemDict.getString("productId"));
587
+ if (itemDict.hasKey("name") && !itemDict.isNull("name"))
588
+ itemBuilder.name(itemDict.getString("name"));
589
+ if (itemDict.hasKey("sku") && !itemDict.isNull("sku"))
590
+ itemBuilder.sku(itemDict.getString("sku"));
591
+ if (itemDict.hasKey("category") && !itemDict.isNull("category"))
592
+ itemBuilder.category(EventUtil.createStrings(itemDict.getArray("category")));
593
+ if (itemDict.hasKey("unitPrice") && !itemDict.isNull("unitPrice"))
594
+ itemBuilder.unitPrice(itemDict.getDouble("unitPrice"));
595
+ if (itemDict.hasKey("quantity") && !itemDict.isNull("quantity"))
596
+ itemBuilder.quantity(itemDict.getInt("quantity"));
597
+ if (itemDict.hasKey("discount") && !itemDict.isNull("discount"))
598
+ itemBuilder.discount(itemDict.getDouble("discount"));
599
+ if (itemDict.hasKey("brand") && !itemDict.isNull("brand"))
600
+ itemBuilder.brand(itemDict.getString("brand"));
601
+ if (itemDict.hasKey("variant") && !itemDict.isNull("variant"))
602
+ itemBuilder.variant(itemDict.getString("variant"));
603
+ if (itemDict.hasKey("extraMetadata") && !itemDict.isNull("extraMetadata"))
604
+ itemBuilder.extraMetadata(new JSONObject(itemDict.getMap("extraMetadata").toHashMap()));
605
+ items.add(itemBuilder.build());
606
+ }
607
+ builder.items(items);
608
+ }
609
+
610
+ trackerController.trackRevenueEvent(builder.build());
611
+ promise.resolve(true);
612
+ } else {
613
+ promise.reject("ERROR", "TrackerController is null");
614
+ }
615
+
616
+ } catch (Throwable t) {
617
+ promise.reject("ERROR", t.getMessage());
618
+ }
619
+ }
620
+
546
621
  @ReactMethod
547
622
  public void setCustomTags(ReadableMap details, Promise promise) {
548
623
  try {
@@ -4,6 +4,6 @@ import com.conviva.react.apptracker.BuildConfig;
4
4
 
5
5
  public class TrackerVersion {
6
6
 
7
- public final static String RN_CONVIVA_TRACKER_VERSION = "rn-0.2.7";
7
+ public final static String RN_CONVIVA_TRACKER_VERSION = "rn-0.2.8";
8
8
 
9
9
  }
@@ -578,6 +578,39 @@ type MessageNotificationProps = {
578
578
  */
579
579
  trigger: Trigger;
580
580
  };
581
+ /**
582
+ * RevenueEventItem properties.
583
+ * All fields are optional.
584
+ */
585
+ type RevenueEventItemProps = {
586
+ productId?: string;
587
+ name?: string;
588
+ sku?: string;
589
+ category?: string[];
590
+ unitPrice?: number;
591
+ quantity?: number;
592
+ discount?: number;
593
+ brand?: string;
594
+ variant?: string;
595
+ extraMetadata?: Record<string, unknown>;
596
+ };
597
+ /**
598
+ * RevenueEvent properties.
599
+ * Required: totalOrderAmount, transactionId, currency.
600
+ */
601
+ type RevenueEventProps = {
602
+ totalOrderAmount: number;
603
+ transactionId: string;
604
+ currency: string;
605
+ taxAmount?: number;
606
+ shippingCost?: number;
607
+ discount?: number;
608
+ cartSize?: number;
609
+ paymentMethod?: string;
610
+ paymentProvider?: string;
611
+ items?: RevenueEventItemProps[];
612
+ extraMetadata?: Record<string, unknown>;
613
+ };
581
614
  /**
582
615
  * The ReactNativeTracker type
583
616
  */
@@ -662,6 +695,13 @@ type ReactNativeTracker = {
662
695
  * @returns {Promise}
663
696
  */
664
697
  readonly trackCustomEvent: (eventName: string, eventData: any, contexts?: EventContext[]) => Promise<void>;
698
+ /**
699
+ * Tracks a revenue event
700
+ *
701
+ * @param argmap - The revenue event properties
702
+ * @param contexts - The array of event contexts
703
+ */
704
+ readonly trackRevenueEvent: (argmap: RevenueEventProps, contexts?: EventContext[]) => Promise<void>;
665
705
  /**
666
706
  * Sets custom tags
667
707
  *
@@ -880,4 +920,4 @@ declare const _default: {
880
920
  withReactNavigationAutotrack: (AppContainer: any) => react.ForwardRefExoticComponent<react.RefAttributes<any>>;
881
921
  };
882
922
 
883
- export { Basis, BufferOption, ConsentDocument, ConsentGrantedProps, ConsentWithdrawnProps, DeepLinkReceivedProps, DevicePlatform, EcommerceItem, EcommerceTransactionProps, EmitterConfiguration, EventContext, GCConfiguration, GdprConfiguration, GlobalContext, HttpMethod, LogLevel, MessageNotificationProps, NetworkConfiguration, PageViewProps, ReactNativeTracker, ScreenSize, ScreenViewProps, SelfDescribing, SessionConfiguration, StructuredProps, SubjectConfiguration, TimingProps, TrackerConfiguration, TrackerControllerConfiguration, Trigger, autocaptureNavigationTrack, createTracker, cleanup, _default as default, getWebViewCallback, removeAllTrackers, removeTracker, withReactNavigationAutotrack, getClientId, setClientId};
923
+ export { Basis, BufferOption, ConsentDocument, ConsentGrantedProps, ConsentWithdrawnProps, DeepLinkReceivedProps, DevicePlatform, EcommerceItem, EcommerceTransactionProps, EmitterConfiguration, EventContext, GCConfiguration, GdprConfiguration, GlobalContext, HttpMethod, LogLevel, MessageNotificationProps, NetworkConfiguration, PageViewProps, ReactNativeTracker, RevenueEventItemProps, RevenueEventProps, ScreenSize, ScreenViewProps, SelfDescribing, SessionConfiguration, StructuredProps, SubjectConfiguration, TimingProps, TrackerConfiguration, TrackerControllerConfiguration, Trigger, autocaptureNavigationTrack, cleanup, createTracker, _default as default, getClientId, getWebViewCallback, removeAllTrackers, removeTracker, setClientId, withReactNavigationAutotrack };
@@ -52,11 +52,14 @@ function safeWaitCallback(callPromise, errHandle) {
52
52
  * Handles an error.
53
53
  *
54
54
  * @param err - The error to be handled.
55
+ * @param alwaysLog - When true, the error is logged regardless of the __DEV__ flag.
55
56
  */
56
- function errorHandler(err) {
57
- if (__DEV__) {
57
+ function errorHandler(err, alwaysLog = false) {
58
+ // #region agent log
59
+ console.warn('[DEBUG-148efd] errorHandler called: __DEV__=' + __DEV__ + ' alwaysLog=' + alwaysLog + ' msg=' + err.message);
60
+ // #endregion
61
+ if (__DEV__ || alwaysLog) {
58
62
  console.warn('ConvivaTracker:' + err.message);
59
- return undefined;
60
63
  }
61
64
  return undefined;
62
65
  }
@@ -128,6 +131,10 @@ const logMessages = {
128
131
  deepLinkReq: 'deepLinkReceived event requires the url parameter to be set',
129
132
  messageNotificationReq: 'messageNotification event requires title, body, and trigger parameters to be set',
130
133
  trackCustomEvent: 'trackCustomEvent event requires name and data',
134
+ revenueEventNullEvent: 'event is null. Event not sent.',
135
+ revenueEventInvalidTotalOrderAmount: 'Must be a finite number. Event not sent.',
136
+ revenueEventInvalidTransactionId: 'Must be a non-empty string. Event not sent.',
137
+ revenueEventInvalidCurrency: 'Must be a non-empty string. Event not sent.',
131
138
  trackClickEvent: 'click event requires atleast one attribute',
132
139
  // custom tags contexts
133
140
  setCustomTags: 'setCustomTags requires tags',
@@ -152,6 +159,7 @@ const logMessages = {
152
159
  trackEcommerceTransaction: 'trackEcommerceTransaction:',
153
160
  trackDeepLinkReceived: 'trackDeepLinkReceivedEvent:',
154
161
  trackMessageNotification: 'trackMessageNotificationEvent:',
162
+ trackRevenueEvent: 'trackRevenueEvent:',
155
163
  removeGlobalContexts: 'removeGlobalContexts:',
156
164
  addGlobalContexts: 'addGlobalContexts:',
157
165
  // setters
@@ -413,11 +421,26 @@ function validateEcommerceTransaction(argmap) {
413
421
  return Promise.resolve(true);
414
422
  }
415
423
  /**
416
- * Validates a custom event
424
+ * Validates a revenue event
417
425
  *
418
426
  * @param argmap {Object} - the object to validate
419
427
  * @returns - boolean promise
420
428
  */
429
+ function validateRevenueEvent(argmap) {
430
+ if (!isObject(argmap)) {
431
+ return Promise.reject(new Error(logMessages.revenueEventNullEvent));
432
+ }
433
+ if (typeof argmap.totalOrderAmount !== 'number' || !Number.isFinite(argmap.totalOrderAmount)) {
434
+ return Promise.reject(new Error(`invalid totalOrderAmount "${argmap.totalOrderAmount}". ${logMessages.revenueEventInvalidTotalOrderAmount}`));
435
+ }
436
+ if (typeof argmap.transactionId !== 'string' || argmap.transactionId.trim() === '') {
437
+ return Promise.reject(new Error(`invalid transactionId "${argmap.transactionId}". ${logMessages.revenueEventInvalidTransactionId}`));
438
+ }
439
+ if (typeof argmap.currency !== 'string' || argmap.currency.trim() === '') {
440
+ return Promise.reject(new Error(`invalid currency "${argmap.currency}". ${logMessages.revenueEventInvalidCurrency}`));
441
+ }
442
+ return Promise.resolve(true);
443
+ }
421
444
  function validateCustomEvent(argmap) {
422
445
  // validate type
423
446
  if (!isObject(argmap)) {
@@ -954,6 +977,37 @@ function trackCustomEvent$1(namespace, name, arg, contexts = []) {
954
977
  throw new Error(`${logMessages.trackCustomEvent} ${error.message}`);
955
978
  });
956
979
  }
980
+ /**
981
+ * Tracks a revenue event
982
+ *
983
+ * @param namespace {string} - the tracker namespace
984
+ * @param argmap {Object} - the event data
985
+ * @param contexts {Array}- the event contexts
986
+ * @returns {Promise}
987
+ */
988
+ function trackRevenueEvent$1(namespace, argmap, contexts = []) {
989
+ // #region agent log
990
+ console.warn('[DEBUG-148efd] trackRevenueEvent ENTRY __DEV__=' + __DEV__ + ' argmap=' + JSON.stringify(argmap));
991
+ // #endregion
992
+ return validateRevenueEvent(argmap)
993
+ .then(() => validateContexts(contexts))
994
+ .then(() => {
995
+ // #region agent log
996
+ console.warn('[DEBUG-148efd] trackRevenueEvent VALIDATION PASSED - calling native bridge');
997
+ // #endregion
998
+ return RNConvivaTracker.trackRevenueEvent({
999
+ tracker: namespace,
1000
+ eventData: argmap,
1001
+ contexts: contexts
1002
+ });
1003
+ })
1004
+ .catch((error) => {
1005
+ // #region agent log
1006
+ console.warn('[DEBUG-148efd] trackRevenueEvent VALIDATION FAILED: ' + error.message);
1007
+ // #endregion
1008
+ throw new Error(`${logMessages.trackRevenueEvent} ${error.message}`);
1009
+ });
1010
+ }
957
1011
  /**
958
1012
  * Sets custom tags
959
1013
  *
@@ -1516,6 +1570,20 @@ function trackCustomEvent(namespace) {
1516
1570
  return trackCustomEvent$1(namespace, eventName, eventData, contexts);
1517
1571
  };
1518
1572
  }
1573
+ /**
1574
+ * Returns a function to track a RevenueEvent by a tracker
1575
+ *
1576
+ * @param namespace {string} - The tracker namespace
1577
+ * @returns - A function to track a RevenueEvent
1578
+ */
1579
+ function trackRevenueEvent(namespace) {
1580
+ return function (argmap, contexts = []) {
1581
+ if (!isTrackerInitialised) {
1582
+ return Promise.reject(new Error(logMessages.createTrackerNotSet));
1583
+ }
1584
+ return trackRevenueEvent$1(namespace, argmap, contexts);
1585
+ };
1586
+ }
1519
1587
  function setCustomTags(namespace) {
1520
1588
  return function (tags, contexts = []) {
1521
1589
  if (!isTrackerInitialised) {
@@ -2182,6 +2250,8 @@ controllerConfig = {}) {
2182
2250
  }));
2183
2251
  // mkMethod creates methods subscribed to the initTrackerPromise
2184
2252
  const mkMethod = safeWait(initTrackerPromise, errorHandler);
2253
+ // mkMethodAlwaysLog creates methods that always log errors, regardless of __DEV__
2254
+ const mkMethodAlwaysLog = safeWait(initTrackerPromise, (err) => errorHandler(err, true));
2185
2255
  // mkCallback creates callbacks subscribed to the initTrackerPromise
2186
2256
  const mkCallback = safeWaitCallback(initTrackerPromise, errorHandler);
2187
2257
  // track methods
@@ -2197,6 +2267,7 @@ controllerConfig = {}) {
2197
2267
  const trackDeepLinkReceivedEvent$1 = mkMethod(trackDeepLinkReceivedEvent(namespace));
2198
2268
  const trackMessageNotificationEvent$1 = mkMethod(trackMessageNotificationEvent(namespace));
2199
2269
  const trackCustomEvent$1 = mkMethod(trackCustomEvent(namespace));
2270
+ const trackRevenueEvent$1 = mkMethodAlwaysLog(trackRevenueEvent(namespace));
2200
2271
  const trackClickEvent$1 = mkMethod(trackClickEvent(namespace));
2201
2272
  // custom tags contexts
2202
2273
  const setCustomTags$1 = mkMethod(setCustomTags(namespace));
@@ -2237,6 +2308,7 @@ controllerConfig = {}) {
2237
2308
  trackDeepLinkReceivedEvent: trackDeepLinkReceivedEvent$1,
2238
2309
  trackMessageNotificationEvent: trackMessageNotificationEvent$1,
2239
2310
  trackCustomEvent: trackCustomEvent$1,
2311
+ trackRevenueEvent: trackRevenueEvent$1,
2240
2312
  setCustomTags: setCustomTags$1,
2241
2313
  setCustomTagsWithCategory: setCustomTagsWithCategory$1,
2242
2314
  clearCustomTags: clearCustomTags$1,
@@ -45,6 +45,8 @@
45
45
  #import <ConvivaAppAnalytics/CATEcommerce.h>
46
46
  #import <ConvivaAppAnalytics/CATDeepLinkReceived.h>
47
47
  #import <ConvivaAppAnalytics/CATMessageNotification.h>
48
+ #import <ConvivaAppAnalytics/CATRevenueEvent.h>
49
+ #import <ConvivaAppAnalytics/CATRevenueEventItem.h>
48
50
  #import <Foundation/NSObject.h>
49
51
 
50
52
  @implementation RNConvivaTracker
@@ -655,6 +657,115 @@ RCT_EXPORT_METHOD(trackCustomEvent:
655
657
  }
656
658
  }
657
659
 
660
+ RCT_EXPORT_METHOD(trackRevenueEvent:
661
+ (NSDictionary *)details
662
+ resolver:(RCTPromiseResolveBlock)resolve
663
+ rejecter:(RCTPromiseRejectBlock)reject) {
664
+ // #region agent log
665
+ NSLog(@"[DEBUG-148efd] iOS bridge trackRevenueEvent ENTERED with details: %@", details);
666
+ // #endregion
667
+ NSString *namespace = [details objectForKey:@"tracker"];
668
+
669
+ id<CATTrackerController> trackerController = [self trackerByNamespace:namespace];
670
+
671
+ if (trackerController != nil) {
672
+ NSDictionary *argmap = [details objectForKey:@"eventData"];
673
+
674
+ NSNumber *totalOrderAmount = [argmap objectForKey:@"totalOrderAmount"];
675
+ NSString *transactionId = [argmap objectForKey:@"transactionId"];
676
+ NSString *currency = [argmap objectForKey:@"currency"];
677
+ // #region agent log
678
+ NSLog(@"[DEBUG-148efd] iOS bridge trackRevenueEvent totalOrderAmount=%@ transactionId=%@ currency=%@", totalOrderAmount, transactionId, currency);
679
+ // #endregion
680
+
681
+ CATRevenueEvent *event = [[CATRevenueEvent alloc]
682
+ initWithTotalOrderAmount:totalOrderAmount
683
+ transactionId:transactionId
684
+ currency:currency];
685
+
686
+ if ([argmap objectForKey:@"taxAmount"] && ![[argmap objectForKey:@"taxAmount"] isEqual:[NSNull null]]) {
687
+ event.taxAmount = [argmap objectForKey:@"taxAmount"];
688
+ }
689
+ if ([argmap objectForKey:@"shippingCost"] && ![[argmap objectForKey:@"shippingCost"] isEqual:[NSNull null]]) {
690
+ event.shippingCost = [argmap objectForKey:@"shippingCost"];
691
+ }
692
+ if ([argmap objectForKey:@"discount"] && ![[argmap objectForKey:@"discount"] isEqual:[NSNull null]]) {
693
+ event.discount = [argmap objectForKey:@"discount"];
694
+ }
695
+ if ([argmap objectForKey:@"cartSize"] && ![[argmap objectForKey:@"cartSize"] isEqual:[NSNull null]]) {
696
+ event.cartSize = [argmap objectForKey:@"cartSize"];
697
+ }
698
+ if ([argmap objectForKey:@"paymentMethod"] && ![[argmap objectForKey:@"paymentMethod"] isEqual:[NSNull null]]) {
699
+ event.paymentMethod = [argmap objectForKey:@"paymentMethod"];
700
+ }
701
+ if ([argmap objectForKey:@"paymentProvider"] && ![[argmap objectForKey:@"paymentProvider"] isEqual:[NSNull null]]) {
702
+ event.paymentProvider = [argmap objectForKey:@"paymentProvider"];
703
+ }
704
+ if ([argmap objectForKey:@"extraMetadata"] && ![[argmap objectForKey:@"extraMetadata"] isEqual:[NSNull null]]) {
705
+ event.extraMetadata = [argmap objectForKey:@"extraMetadata"];
706
+ }
707
+
708
+ NSArray *itemsArray = [argmap objectForKey:@"items"];
709
+ if (itemsArray && ![itemsArray isEqual:[NSNull null]] && [itemsArray isKindOfClass:[NSArray class]]) {
710
+ NSMutableArray<CATRevenueEventItem *> *items = [NSMutableArray array];
711
+ for (NSDictionary *itemDict in itemsArray) {
712
+ if (![itemDict isKindOfClass:[NSDictionary class]]) continue;
713
+
714
+ CATRevenueEventItem *item = [[CATRevenueEventItem alloc] init];
715
+
716
+ if ([itemDict objectForKey:@"productId"] && ![[itemDict objectForKey:@"productId"] isEqual:[NSNull null]]) {
717
+ item.productId = [itemDict objectForKey:@"productId"];
718
+ }
719
+ if ([itemDict objectForKey:@"name"] && ![[itemDict objectForKey:@"name"] isEqual:[NSNull null]]) {
720
+ item.name = [itemDict objectForKey:@"name"];
721
+ }
722
+ if ([itemDict objectForKey:@"sku"] && ![[itemDict objectForKey:@"sku"] isEqual:[NSNull null]]) {
723
+ item.sku = [itemDict objectForKey:@"sku"];
724
+ }
725
+ if ([itemDict objectForKey:@"category"] && ![[itemDict objectForKey:@"category"] isEqual:[NSNull null]]) {
726
+ item.category = [itemDict objectForKey:@"category"];
727
+ }
728
+ if ([itemDict objectForKey:@"unitPrice"] && ![[itemDict objectForKey:@"unitPrice"] isEqual:[NSNull null]]) {
729
+ item.unitPrice = [itemDict objectForKey:@"unitPrice"];
730
+ }
731
+ if ([itemDict objectForKey:@"quantity"] && ![[itemDict objectForKey:@"quantity"] isEqual:[NSNull null]]) {
732
+ item.quantity = [itemDict objectForKey:@"quantity"];
733
+ }
734
+ if ([itemDict objectForKey:@"discount"] && ![[itemDict objectForKey:@"discount"] isEqual:[NSNull null]]) {
735
+ item.discount = [itemDict objectForKey:@"discount"];
736
+ }
737
+ if ([itemDict objectForKey:@"brand"] && ![[itemDict objectForKey:@"brand"] isEqual:[NSNull null]]) {
738
+ item.brand = [itemDict objectForKey:@"brand"];
739
+ }
740
+ if ([itemDict objectForKey:@"variant"] && ![[itemDict objectForKey:@"variant"] isEqual:[NSNull null]]) {
741
+ item.variant = [itemDict objectForKey:@"variant"];
742
+ }
743
+ if ([itemDict objectForKey:@"extraMetadata"] && ![[itemDict objectForKey:@"extraMetadata"] isEqual:[NSNull null]]) {
744
+ item.extraMetadata = [itemDict objectForKey:@"extraMetadata"];
745
+ }
746
+
747
+ [items addObject:item];
748
+ }
749
+ event.items = items;
750
+ }
751
+
752
+ // #region agent log
753
+ NSLog(@"[DEBUG-148efd] iOS bridge calling native trackRevenueEvent now");
754
+ // #endregion
755
+ [trackerController trackRevenueEvent:event];
756
+ // #region agent log
757
+ NSLog(@"[DEBUG-148efd] iOS bridge trackRevenueEvent completed successfully");
758
+ // #endregion
759
+ resolve(@YES);
760
+ } else {
761
+ // #region agent log
762
+ NSLog(@"[DEBUG-148efd] iOS bridge trackRevenueEvent FAILED - tracker not found for namespace: %@", namespace);
763
+ // #endregion
764
+ NSError* error = [NSError errorWithDomain:@"ConvivaAppAnalytics" code:200 userInfo:nil];
765
+ reject(@"ERROR", @"tracker with given namespace not found", error);
766
+ }
767
+ }
768
+
658
769
  RCT_EXPORT_METHOD(setCustomTags:
659
770
  (NSDictionary *)details
660
771
  resolver:(RCTPromiseResolveBlock)resolve
@@ -1026,7 +1137,7 @@ RCT_EXPORT_METHOD(getIsInBackground:
1026
1137
  // NSError* error = [NSError errorWithDomain:@"ConvivaAppAnalytics" code:200 userInfo:nil];
1027
1138
  // reject(@"ERROR", @"tracker with given namespace not found", error);
1028
1139
  // }
1029
-
1140
+
1030
1141
  @try {
1031
1142
  resolve(@(YES));
1032
1143
  } @catch (NSException *exception) {
@@ -22,6 +22,6 @@
22
22
 
23
23
  @implementation RNTrackerVersion
24
24
 
25
- NSString * const kRNTrackerVersion = @"rn-0.2.7";
25
+ NSString * const kRNTrackerVersion = @"rn-0.2.8";
26
26
 
27
27
  @end
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@convivainc/conviva-react-native-appanalytics",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "Conviva React Native Application Analytics Library",
5
5
  "main": "conviva-react-native-appanalytics.js",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+github.com:Conviva/conviva-react-native-appanalytics.git"
9
9
  },
10
+ "dependencies": {
11
+ "hoist-non-react-statics": "^3.3.2",
12
+ "lodash": "^4.17.21"
13
+ },
10
14
  "keywords": [
11
15
  "Conviva",
12
16
  "Application",