feat: Java enum for MPCommerceEventActionType was base 1#336
feat: Java enum for MPCommerceEventActionType was base 1#336BrandonStalnaker wants to merge 1 commit into
Conversation
PR SummaryMedium Risk Overview The dictionary-based Reviewed by Cursor Bugbot for commit 2a8ebda. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
|
||
| if (commerceEvent.productActionType().has_value()) { | ||
| mpCommerceEvent.action = (MPCommerceEventAction)commerceEvent.productActionType().value(); | ||
| mpCommerceEvent.action = [RCTConvert MPCommerceEventAction:@(commerceEvent.productActionType().value())]; |
There was a problem hiding this comment.
This solves for the product action but looks like we'll have the same issue with the promotion actions? Looks like view and click would get the wrong index too?
Could you cast a wider net to see if there's anything more widespread here please?
There was a problem hiding this comment.
We need to fix the PromotionActionType as well. On JS side 0 means View. But on the Objective-C side it is Click
|
Also wondering if there's any tests we can be adding here as a regression on this type of error can easily occur |
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