feat: Java enum for MPCommerceEventActionType was base 1#336
Conversation
PR SummaryMedium Risk Overview Product actions now go through existing Promotion actions get a new Reviewed by Cursor Bugbot for commit de1a016. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
Also wondering if there's any tests we can be adding here as a regression on this type of error can easily occur |
I agree we should add some but currently there's no existing tests in that vein. I figured with the priority it made sense to focus on the fix and then follow up adding tests later. Here's the breakdown of existing tests. Package root (react-native-mparticle)
Sample app (sample/)
Android library (android/src/test/)
Not automated tests
|
de1a016
Summary
On iOS with the New Architecture (RCT_NEW_ARCH_ENABLED), logCommerceEvent set MPCommerceEvent.action by casting the TurboModule / codegen number straight to MPCommerceEventAction. That number is the JavaScript ProductActionType (1-based MPReactCommerceEventAction: AddToCart = 1, …), which does not match the Apple SDK’s native enum raw values or ordering. The result was wrong commerce actions (e.g. AddToCart → remove_from_cart, and generally scrambled types including wishlist vs checkout).
The legacy bridge path already fixed this by routing productActionType through [RCTConvert MPCommerceEventAction:], which maps each JS constant to the correct MPCommerceEventAction.
This PR aligns the New Architecture path with that behavior by:
Android is unchanged (already maps JS ints explicitly in Kotlin). Promotion action types were not part of this issue (JS 0/1 matches existing native usage).
Master Issue
Closes https://go.mparticle.com/work/TRIAGE-719