Skip to content

fix: Map All Commerce Fields on iOS New Architecture - #378

Merged
BrandonStalnaker merged 1 commit into
mainfrom
fix/Map-Commerce-Fields-on-ios-New-Arch
Aug 25, 2026
Merged

fix: Map All Commerce Fields on iOS New Architecture#378
BrandonStalnaker merged 1 commit into
mainfrom
fix/Map-Commerce-Fields-on-ios-New-Arch

Conversation

@BrandonStalnaker

Copy link
Copy Markdown
Contributor

Summary

On iOS with the New Architecture, commerce fields set in JS were dropped before they reached the native mParticle SDK. setCurrency("USD") produced currency_code: null, and setCheckoutStep(1) produced checkout_step: 0. The same JS worked on Android and on iOS Old Architecture.

The JS layer already stored and forwarded these fields. Android convertCommerceEvent and iOS +[RCTConvert MPCommerceEvent:] (legacy bridge) already mapped them. The TurboModule logCommerceEvent: in ios/RNMParticle/RNMParticle.mm built an MPCommerceEvent from the codegen struct but never copied currency, checkout step, or several related native fields, so the SDK kept defaults.

This change brings the New Architecture path to parity with RCTConvert without routing the whole event through RCTConvert (product/impression conversion still uses createMPProductFromDict).

  • Copies optional metadata onto MPCommerceEvent when present: currency, checkoutStep, checkoutOptions, productActionListName / productActionListSource, screenName, nonInteractive, shouldUploadEvent.
  • Fills promotionContainer with promotions from the JS struct (it was previously created with promotion: nil and never populated).
  • Extracts testable helpers applyCommerceEventMetadata:fromDictionary: and addPromotionsFromDicts:toCommerceEvent:.
  • No JS or Android changes. Affected on 3.3.1 / 3.3.2 with New Architecture enabled; there is no JS-only workaround for native currency_code / checkout_step.

Testing Plan

Sample iOS XCTests in RCTConvertCommerceMappingTests.m:

  • Legacy JSON → RCTConvert keeps currency, checkout step, checkout options, list name/source, screen name, nonInteractive, and shouldUploadEvent.
  • applyCommerceEventMetadata:fromDictionary: copies the same fields onto an MPCommerceEvent without generated C++ TurboModule types.
  • addPromotionsFromDicts:toCommerceEvent: adds a promotion (id, name, creative, position) onto promotionContainer.

Run the MParticleSampleTests target (including RCTConvertCommerceMappingTests) on an iOS simulator.

Master Issue

Closes https://go.mparticle.com/work/REPLACEME

@BrandonStalnaker BrandonStalnaker self-assigned this Aug 25, 2026
@BrandonStalnaker
BrandonStalnaker requested a review from a team as a code owner August 25, 2026 15:30
@cursor

cursor Bot commented Aug 25, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes only the iOS New Architecture commerce event path; behavior should match existing RCTConvert mapping but incorrect field mapping could skew analytics until caught in tests.

Overview
Fixes iOS New Architecture commerce logging so JS fields reach the mParticle SDK instead of being dropped on the TurboModule path. Legacy bridge and Android already mapped these; logCommerceEvent built MPCommerceEvent from the codegen struct but skipped optional metadata and left promotionContainer empty.

The New Arch handler now copies currency, checkout step/options, product list name/source, screen name, nonInteractive, and shouldUploadEvent via applyCommerceEventMetadata:fromDictionary:, and fills promotions on the container via addPromotionsFromDicts:toCommerceEvent: (using existing RCTConvert MPPromotion:). No JS or Android changes.

RCTConvertCommerceMappingTests adds coverage for legacy JSON → MPCommerceEvent metadata and for the two New Arch helpers without codegen C++ types.

Reviewed by Cursor Bugbot for commit 860c109. Bugbot is set up for automated code reviews on this repo. Configure here.

@BrandonStalnaker
BrandonStalnaker merged commit 3c549ef into main Aug 25, 2026
11 checks passed
@BrandonStalnaker
BrandonStalnaker deleted the fix/Map-Commerce-Fields-on-ios-New-Arch branch August 25, 2026 17:34
@rokt-releases rokt-releases Bot mentioned this pull request Aug 25, 2026
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

Successfully merging this pull request may close these issues.

2 participants