Skip to content

fix: Attribute Handling of non-strings and colorMode for roktConfig#354

Open
BrandonStalnaker wants to merge 1 commit into
mainfrom
fix/Attribute-Handling-and-colorMode-for-roktConfig
Open

fix: Attribute Handling of non-strings and colorMode for roktConfig#354
BrandonStalnaker wants to merge 1 commit into
mainfrom
fix/Attribute-Handling-and-colorMode-for-roktConfig

Conversation

@BrandonStalnaker

Copy link
Copy Markdown
Contributor

Summary

Fixes two gaps in the React Native Rokt bridge that caused placement attributes and config to be lost before reaching the native mParticle/Rokt SDK.

Problem

  1. Non-string placement attributes were silently removed — e.g. amount: 23.47 was passed from JS but never reached Rokt because iOS stripped any value that wasn’t an NSString, and Android filtered to value is String only.
  2. roktConfig.colorMode was dropped on New Architecture (iOS) — safeExtractRoktConfigDict only extracted cacheConfig, so { colorMode: 'light' } arrived at native as config: (null) even though Old Architecture and the native kit support it.

Changes
iOS (RNMPRokt.mm)

  • Reworked convertToMutableDictionaryOfStrings to coerce values to strings (aligned with MPKitRokt.m): strings as-is, numbers via stringValue, booleans as "true"/"false", dictionaries/arrays via description, nulls skipped.
    Extended safeExtractRoktConfigDict to extract colorMode from the TurboModule RoktConfigType on New Architecture.

Android (MPRoktModuleImpl.kt)

  • Reworked readableMapToMapOfStrings to coerce ReadableType.String, Number, Boolean, Map, and Array instead of accepting strings only.

TypeScript

  • Added RoktAttributeValue = string | number | boolean to the codegen spec and public Rokt API so callers can pass numeric/boolean attributes without manual stringification.

Testing Plan

Added MPRoktModuleImplTest covering number/boolean coercion and null skipping on Android.

Master Issue

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

@BrandonStalnaker BrandonStalnaker self-assigned this Jun 29, 2026
@BrandonStalnaker BrandonStalnaker requested a review from a team as a code owner June 29, 2026 16:51
@cursor

cursor Bot commented Jun 29, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes data passed into Rokt placement APIs on both platforms; behavior fix but affects production attribute/config payloads and TurboModule typing.

Overview
Fixes the React Native Rokt bridge dropping non-string placement attributes and roktConfig.colorMode on iOS New Architecture before data reaches the native SDK.

Placement attributes are now coerced to Map<String, String> / NSString dictionaries instead of stripping non-strings: numbers (with iOS-aligned formatting on Android), booleans as "true"/"false", and nested maps/arrays via string representation; nulls are skipped. The public TypeScript API and codegen spec accept RoktAttributeValue (string | number | boolean) on selectPlacements and selectShoppableAds.

On iOS New Architecture, safeExtractRoktConfigDict now includes colorMode from the TurboModule config type (previously only cacheConfig was extracted, so color mode never reached buildRoktConfigFromDict).

Android adds unit tests for attribute coercion; test MockMap handles Long/Boolean numeric reads.

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1cc7bf4. Configure here.

Comment thread android/src/main/java/com/mparticle/react/rokt/MPRoktModuleImpl.kt Outdated
@BrandonStalnaker BrandonStalnaker force-pushed the fix/Attribute-Handling-and-colorMode-for-roktConfig branch from 1cc7bf4 to f6dac5d Compare June 29, 2026 17:19
@BrandonStalnaker BrandonStalnaker force-pushed the fix/Attribute-Handling-and-colorMode-for-roktConfig branch from f6dac5d to 2530d53 Compare June 29, 2026 17:20
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.

1 participant