Skip to content

fix: React Native Codegen issue with version 0.84#284

Open
thomson-t wants to merge 1 commit intomainfrom
fix/rn-084-support
Open

fix: React Native Codegen issue with version 0.84#284
thomson-t wants to merge 1 commit intomainfrom
fix/rn-084-support

Conversation

@thomson-t
Copy link
Contributor

Summary

The app compilation failed when integrated into an app that uses React Native 0.84.

NativeMParticle.ts (line 6) uses TSArrayType shorthand (string[]) which is unsupported by the React Native codegen Removed the null type in the map

  • In RNMParticle.mm, added sanitization for user attributes to exclude null values before returning them in the callback.
  • Updated TypeScript definitions to reflect the changes in callback result types.

Testing Plan

Tested locally with 0.76.9 and 0.84

Master Issue

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

Copilot AI review requested due to automatic review settings March 5, 2026 04:18
@thomson-t thomson-t requested a review from a team as a code owner March 5, 2026 04:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes React Native 0.84 integration issues around the getUserAttributes TurboModule/codegen contract by ensuring native callbacks return a consistent (non-null) attributes object and by aligning the TypeScript spec with that behavior.

Changes:

  • iOS: sanitize user attributes to exclude null/NSNull values before returning them via callback.
  • Android: always invoke getUserAttributes callback with (null, emptyMap) when no user is found (instead of invoking with no args).
  • TypeScript codegen spec: remove null from UserAttributes value union and make getUserAttributes callback result non-nullable.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
js/codegenSpecs/NativeMParticle.ts Tightens UserAttributes and getUserAttributes callback typing for codegen.
ios/RNMParticle/RNMParticle.mm Filters null values out of user attributes before returning to JS.
android/src/main/java/com/mparticle/react/MParticleModule.kt Ensures callback is invoked with consistent (error, result) args even when user is missing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 5 to 7
export type UserAttributes = {
[key: string]: string | string[] | number | boolean | null;
[key: string]: string | string[] | number | boolean;
};
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

UserAttributes still uses the string[] shorthand. The PR description indicates this shorthand is unsupported by RN 0.84 codegen, so this change likely doesn’t resolve the reported build failure. Prefer Array<string> here (matching setUserAttributeArray) to avoid TSArrayType shorthand in the codegen spec.

Copilot uses AI. Check for mistakes.
Comment on lines 181 to 183
} else {
callback.invoke()
callback.invoke(null, WritableNativeMap())
}
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

There are Android unit tests for other user methods, but this updated getUserAttributes behavior (always invoking the callback with (null, emptyMap) when the user is missing) isn’t covered. Add a test to assert the callback is invoked with two arguments and that the second argument is an empty map when selectedUser is null.

Copilot uses AI. Check for mistakes.
`NativeMParticle.ts (line 6) uses TSArrayType shorthand (string[]) which is unsupported by the React Native codegen`
Made the types more flexible to support the new React Native 0.84.0 version.
- In RNMParticle.mm, added sanitization for user attributes to exclude null values before returning them in the callback.
- Updated TypeScript definitions to reflect the changes in callback result types.
@thomson-t thomson-t force-pushed the fix/rn-084-support branch from 7def449 to 7507daf Compare March 5, 2026 04:38
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