segmentio / analytics-react-native

The hassle-free way to add analytics to your React-Native app.
https://segment.com/docs/sources/mobile/react-native/
MIT License
362 stars 187 forks source link

Braze/Appboy device-mode destination is ignoring the product_id field on the 'Order Completed' event. #277

Closed abdullah-kasim closed 3 years ago

abdullah-kasim commented 3 years ago

Hello,

Upon sending the payload below, for the event 'Order Completed', I am getting the error The productId is empty, not logging in-app purchase to Appboy. in android's logcat. This is with verbose logging enabled on Appboy. It's not showing up on Braze's dashboard either.

Interestingly, if I added id alongside the product_id inside the products array, it will log the purchases properly, without the above error

Analytics.track('Order Completed', {
  "app_mode": "Regular",
  "categories": [
    null,
    null
  ],
  "discount": 18.75,
  "first_order": false,
  "line_item_count": 2,
  "order_number": "R270573084",
  "payment_method": "cash on delivery",
  "products": [
    {
      "brand": null,
      "category": null,
      "image_url": "https://d34e5984yv831d.cloudfront.net/spree/images/attachments/000/000/007/product/open-uri20170530-4-16z7kba?1496181795",
      "locale": "en",
      "name": "Neutrogena  Visibly Clear 2In1 Wash 150ml",
      "price": 35.5,
      "product_id": "27", // if I add id: "27" as well in the products array, the purchases would get logged.
      "product_name": null,
      "quantity": 1,
      "url": "https://sandbox.danube.sa/en/products/27"
    },
    {
      "brand": null,
      "category": null,
      "image_url": "https://d34e5984yv831d.cloudfront.net/spree/images/attachments/000/002/563/product/open-uri20170530-4-s76690?1496183783",
      "locale": "en",
      "name": "Nova Drinking Water 0.6 Ltr",
      "price": 152,
      "product_id": "2621",
      "product_name": null,
      "quantity": 1,
      "url": "https://sandbox.danube.sa/en/products/2621"
    }
  ],
  "shipping": 19,
  "shipping_method": "Home Delivery",
  "status": "order placed",
  "subtotal": 187.5,
  "total": 187.75
})

I'm using react-native-appboy-sdk version 1.26.0, and @segment/analytics-react-native-appboy version 1.4.1

The Appboy SDK version on android is version 12.0.0

I created the above payload based on this document: https://segment.com/docs/connections/spec/ecommerce/v2/

I've only tested this on Android. I'll update this issue once I've tested this on iOS.

EDIT2: We've decided to integrate directly for this event. See https://github.com/Appboy/appboy-segment-android/issues/25#issuecomment-796325856 for further info.

bsneed commented 3 years ago

The AppBoy integration is maintained by braze. Analytics-react-native simply uses it. If you see your product_id showing up in the segment debugger as expected, it's something with the integration. Please see here for support: https://github.com/Appboy/appboy-segment-ios

Bucimis commented 3 years ago

@bsneed just following up here (from Braze), I think there's a possibility that this is due to an issue in analytics-android, where the field used when deserializing Product objects is id when it should be product_id. I'll also inquire at analytics-android https://github.com/segmentio/analytics-android/blob/006bd94aa4ed14ae3eaf9da508f2d0653d0be8c7/analytics/src/main/java/com/segment/analytics/Properties.java#L391

prayansh commented 3 years ago

Yea this feels like a bug in our analytics-android library. As discussed https://github.com/segmentio/analytics-android/issues/746#issuecomment-795974071 we have filed an internal ticket and will update back once its fixed. Until then, I would recommend supplying both product_id and id in the properties payloads

abdullah-kasim commented 3 years ago

We've decided to integrate directly for this event. See https://github.com/Appboy/appboy-segment-android/issues/25#issuecomment-796325856 for further info.