@attentive-mobile/attentive-react-native-sdk 2.0.0-beta.1 → 2.0.0-beta.2

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.
@@ -558,7 +558,35 @@ public extension ATTNNativeSDK {
558
558
  ATTNEventTracker.sharedInstance()?.record(event: event)
559
559
 
560
560
  if debuggingEnabled {
561
- showDebugInfo(event: "Add To Cart Event", data: ["items_count": "\(items.count)", "deeplink": deeplink, "payload": attributes])
561
+ // Enhanced debug data to show parsed item details
562
+ var debugData: [String: Any] = [
563
+ "items_count": "\(items.count)",
564
+ "deeplink": deeplink,
565
+ "payload": attributes
566
+ ]
567
+
568
+ // Add item details to debug output
569
+ if let firstItem = items.first {
570
+ var itemDetails: [String: Any] = [
571
+ "productId": firstItem.productId,
572
+ "productVariantId": firstItem.productVariantId
573
+ ]
574
+ if let name = firstItem.name {
575
+ itemDetails["name"] = name
576
+ }
577
+ if let productImage = firstItem.productImage {
578
+ itemDetails["productImage"] = productImage
579
+ }
580
+ if let category = firstItem.category {
581
+ itemDetails["category"] = category
582
+ }
583
+ if let quantity = firstItem.quantity {
584
+ itemDetails["quantity"] = quantity
585
+ }
586
+ debugData["first_item"] = itemDetails
587
+ }
588
+
589
+ showDebugInfo(event: "Add To Cart Event", data: debugData)
562
590
  }
563
591
  }
564
592
 
@@ -570,7 +598,35 @@ public extension ATTNNativeSDK {
570
598
  ATTNEventTracker.sharedInstance()?.record(event: event)
571
599
 
572
600
  if debuggingEnabled {
573
- showDebugInfo(event: "Product View Event", data: ["items_count": "\(items.count)", "deeplink": deeplink, "payload": attributes])
601
+ // Enhanced debug data to show parsed item details
602
+ var debugData: [String: Any] = [
603
+ "items_count": "\(items.count)",
604
+ "deeplink": deeplink,
605
+ "payload": attributes
606
+ ]
607
+
608
+ // Add item details to debug output
609
+ if let firstItem = items.first {
610
+ var itemDetails: [String: Any] = [
611
+ "productId": firstItem.productId,
612
+ "productVariantId": firstItem.productVariantId
613
+ ]
614
+ if let name = firstItem.name {
615
+ itemDetails["name"] = name
616
+ }
617
+ if let productImage = firstItem.productImage {
618
+ itemDetails["productImage"] = productImage
619
+ }
620
+ if let category = firstItem.category {
621
+ itemDetails["category"] = category
622
+ }
623
+ if let quantity = firstItem.quantity {
624
+ itemDetails["quantity"] = quantity
625
+ }
626
+ debugData["first_item"] = itemDetails
627
+ }
628
+
629
+ showDebugInfo(event: "Product View Event", data: debugData)
574
630
  }
575
631
  }
576
632
 
@@ -584,7 +640,35 @@ public extension ATTNNativeSDK {
584
640
  ATTNEventTracker.sharedInstance()?.record(event: event)
585
641
 
586
642
  if debuggingEnabled {
587
- showDebugInfo(event: "Purchase Event", data: ["items_count": "\(items.count)", "order_id": orderId, "payload": attributes])
643
+ // Enhanced debug data to show parsed item details
644
+ var debugData: [String: Any] = [
645
+ "items_count": "\(items.count)",
646
+ "order_id": orderId,
647
+ "payload": attributes
648
+ ]
649
+
650
+ // Add item details to debug output
651
+ if let firstItem = items.first {
652
+ var itemDetails: [String: Any] = [
653
+ "productId": firstItem.productId,
654
+ "productVariantId": firstItem.productVariantId
655
+ ]
656
+ if let name = firstItem.name {
657
+ itemDetails["name"] = name
658
+ }
659
+ if let productImage = firstItem.productImage {
660
+ itemDetails["productImage"] = productImage
661
+ }
662
+ if let category = firstItem.category {
663
+ itemDetails["category"] = category
664
+ }
665
+ if let quantity = firstItem.quantity {
666
+ itemDetails["quantity"] = quantity
667
+ }
668
+ debugData["first_item"] = itemDetails
669
+ }
670
+
671
+ showDebugInfo(event: "Purchase Event", data: debugData)
588
672
  }
589
673
  }
590
674
 
@@ -606,21 +690,38 @@ private extension ATTNNativeSDK {
606
690
  var itemsToReturn: [ATTNItem] = []
607
691
 
608
692
  for rawItem in rawItems {
609
- if let rawPrice = rawItem["price"] as? [String: Any],
610
- let priceString = rawPrice["price"] as? String,
611
- let currency = rawPrice["currency"] as? String {
693
+ // Parse price - flattened structure (not nested)
694
+ guard let priceString = rawItem["price"] as? String,
695
+ let currency = rawItem["currency"] as? String,
696
+ let productId = rawItem["productId"] as? String,
697
+ let productVariantId = rawItem["productVariantId"] as? String else {
698
+ continue
699
+ }
612
700
 
613
- let price = NSDecimalNumber(string: priceString)
701
+ let price = NSDecimalNumber(string: priceString)
702
+ let attnPrice = ATTNPrice(price: price, currency: currency)
614
703
 
615
- let attnPrice = ATTNPrice(price: price, currency: currency)
704
+ let item = ATTNItem(productId: productId, productVariantId: productVariantId, price: attnPrice)
616
705
 
617
- if let productId = rawItem["productId"] as? String,
618
- let productVariantId = rawItem["productVariantId"] as? String {
706
+ // Parse optional fields to match Android implementation
707
+ if let productImage = rawItem["productImage"] as? String {
708
+ item.productImage = productImage
709
+ }
619
710
 
620
- let item = ATTNItem(productId: productId, productVariantId: productVariantId, price: attnPrice)
621
- itemsToReturn.append(item)
622
- }
711
+ if let name = rawItem["name"] as? String {
712
+ item.name = name
713
+ }
714
+
715
+ // React Native bridges JS numbers as NSNumber, so accept NSNumber directly
716
+ if let quantity = rawItem["quantity"] as? NSNumber {
717
+ item.quantity = quantity
623
718
  }
719
+
720
+ if let category = rawItem["category"] as? String {
721
+ item.category = category
722
+ }
723
+
724
+ itemsToReturn.append(item)
624
725
  }
625
726
 
626
727
  return itemsToReturn
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@attentive-mobile/attentive-react-native-sdk",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "React Native Module for the Attentive SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",