fix: custom events now handle null object within the event properties #2537
+385
−10
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.
Description
One Line Summary
Fix null value handling in JSON conversion for custom event properties to preserve null values in nested structures.
Details
Motivation
Custom event properties with null values were not preserved when converting to JSON. This prevented users from tracking events with null properties (e.g., someNull: null or nested nulls like someObject.ghi: null). The JSON conversion now preserves nulls by converting them to JSONObject.NULL, matching expected JSON behavior.
Scope
OPTIONAL - Other
The fix ensures that when convertToJson() encounters a null value, it returns JSONObject.NULL instead of null. This allows:
All null values are properly serialized to JSON and can be deserialized back, maintaining data integrity throughout the conversion process.
Testing
Unit testing
Updated JSONUtilsTests.kt.
Added CustomEventControllerTests.kt.
All tests verify that null values are correctly converted to JSONObject.NULL and preserved in the final JSON output.
Manual testing
Tested with emulator Pixel 9 api 35
Used some example codes in
MainApplicationKT.ktwhich tracks a custom event with the following structure:Verified that all null values are properly serialized and sent to the backend.

Affected code checklist
Checklist
Overview
Testing
Final pass
This change is