Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
abdullah-kasim opened this issue Mar 3, 2021 · 5 comments

Comments

@abdullah-kasim
Copy link

abdullah-kasim commented Mar 3, 2021

Copied from segmentio/analytics-react-native#277

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": [
    {
      "id": "27", // if I remove this field, purchases don't logged, but the v2 spec said the field is called product_id, not id
      "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"
    },
    {
      "id": "2621", // if I remove this field, purchases don't logged, but the v2 spec said the field is called product_id, not id
      "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", // if I add id: "2621" as well in the products array, the purchases would get logged.
      "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 created the above payload based on this document: https://segment.com/docs/connections/spec/ecommerce/v2/

Platform: react-native, Android

Android Appboy SDK version: +--- com.appboy:android-sdk-base:{strictly 12.0.0} -> 12.0.0 (c)
Android Segment Analytics version: +--- com.segment.analytics.android:analytics:{strictly 4.9.1-beta} -> 4.9.1-beta (c)
React Native react-native-appboy-sdk: 1.26.0
React Native @segment/analytics-react-native-appboy: 1.4.1

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

Extra note: Niall Brennan from segment dropped a note from Segment support that the issue may be related to this line. https://github.com/Appboy/appboy-segment-android/blob/master/appboy-segment-integration/src/main/java/com/segment/analytics/android/integrations/appboy/AppboyIntegration.java#L263

EDIT: Worth noting that it's completely ignoring the quantity field, too - if quantity is 3, it shows up in the dashboard as 1, but I guess that means a ticket rename or a new ticket is needed? Leaving it here so that I remember.

EDIT2: We've decided to integrate directly for this event. See #25 (comment) for further info.

@Bucimis
Copy link
Collaborator

Bucimis commented Mar 10, 2021

@abdullah-kasim thanks for reaching out.

I think this is possibly a bug on Segment's end, and I'll follow up in the ticket you linked & file a new on on https://github.com/segmentio/analytics-android

The issue is that Braze is parsing fields from Segment-provided Product objects (a field of Properties which itself is a field of TrackPayload) to pass into into its own logPurchase() event, and the field used to deserialize Product objects inside the Segment Android SDK is id and not product_id (https://github.com/segmentio/analytics-android/blob/006bd94aa4ed14ae3eaf9da508f2d0653d0be8c7/analytics/src/main/java/com/segment/analytics/Properties.java#L391)

Similarly, it looks like quantity is not supported in the Segment Android Product object

@Bucimis
Copy link
Collaborator

Bucimis commented Mar 10, 2021

@abdullah-kasim for now, I would continue to pass in id as well as product_id.

See also segmentio/analytics-android#746

@Bucimis
Copy link
Collaborator

Bucimis commented Mar 10, 2021

@abdullah-kasim Segment confirmed the bug and the workaround here segmentio/analytics-android#746 (comment)

@abdullah-kasim
Copy link
Author

abdullah-kasim commented Mar 11, 2021

@Bucimis

Unfortunately, we won't be able to use the workaround as that doesn't fix the issue where the quantity would be 1, which would give us the wrong revenue in the end.

But, just to give everyone reading a closure - we've decided to integrate the purchases directly rather than going through Segment - so Appboy integration set to false for the Order Completed event.

This has been the best solution for us so far, as I'm experiencing issues with the IOS's device mode integration too, where purchases aren't being logged at all. I'm just mentioning this in passing, as I didn't investigate it as deep as I did for Android. Plus, Segment's device mode integration is even harder to debug for React Native - it's frequently falling back to cloud-mode if I'm on a debug build of my app on iOS, possibly due to a conflict with CodePush. The times when it did manage to use device-mode, I didn't investigate deep enough. Production builds work perfectly though. But, I digressed.

@Bucimis
Copy link
Collaborator

Bucimis commented Mar 11, 2021

@abdullah-kasim thanks for the followup and feedback. I filed another issue with Segment re quantity, but agree that going the native route seems like the best path forward for now. Let us know if there's anything else we can do to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants