feat: Support Braze 42 and recommended eCommerce events#192
Open
nickolas-dimitrakas wants to merge 2 commits into
Open
feat: Support Braze 42 and recommended eCommerce events#192nickolas-dimitrakas wants to merge 2 commits into
nickolas-dimitrakas wants to merge 2 commits into
Conversation
Bump the kit to Braze Android SDK 42.x (com.braze:android-sdk-ui:[42.3.0,43.0.0), Kotlin 2.2.20) and add an opt-in `useEcommerceRecommendedEvents` setting that forwards the six supported mParticle commerce actions using Braze's recommended eCommerce event schema (cart_updated, checkout_started, product_viewed, order_placed, and order_refunded via logCustomEvent). Legacy commerce forwarding remains the default; unsupported actions and events without products fall back to it. Attributes without a direct Braze field are nested in event/product metadata per Braze's strict schema; source is "android". Adds unit tests for each mapped event and the legacy fallback paths (extends the Braze test mock with logEcommerceEvent and the recommended eCommerce event types). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
buildEventMetadataMap copied every commerce custom attribute into the event metadata object, including cart_id, checkout_id, and total_discounts, which are also promoted to typed recommended-event fields — so they appeared twice on the outbound event. Exclude the promoted keys from metadata; genuinely custom attributes are unaffected. Adds assertions covering the dedup. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Braze Android SDK 42.3.0+ introduces recommended eCommerce events (
ecommerce.cart_updated,ecommerce.checkout_started,ecommerce.product_viewed,ecommerce.order_placed,ecommerce.order_refunded) as typed SDK APIs that unlock calculated profile fields, eCommerce reporting, and out-of-the-box Canvas templates. This mirrors the iOS work in mparticle-apple-sdk#793.What changed
Bumped the kit to Braze Android SDK 42.x (
com.braze:android-sdk-ui:[42.3.0,43.0.0)) and Kotlin 2.2.20 (required by Braze 42).New opt-in
useEcommerceRecommendedEventssetting. When enabled, the six supported mParticle commerce actions map to Braze's recommended events vialogEcommerceEvent(andlogCustomEventforecommerce.order_refunded, which has no typed API):ecommerce.cart_updated(action add/remove)ecommerce.checkout_startedecommerce.product_viewed(one per product)ecommerce.order_placedecommerce.order_refundedWhen the setting is off (default), commerce forwarding is unchanged. Unsupported actions and events without products fall back to legacy forwarding.
Attributes without a direct Braze field (
cart_id,checkout_id,source,tax,shipping, productbrand/category/coupon_code/position, etc.) are nested in event/productmetadataper Braze's strict schema.sourceis"android".Testing
./gradlew testReleaseUnitTest— all unit tests pass (new recommended-eCommerce tests covering each mapped event + fallback paths, plus the existing suite).ktlintCheckclean. Compiles against the real Braze 42.3.x AAR.🤖 Generated with Claude Code