Conversation
* task(SDK-5520) - Release v3.9.0 Inaction and NestedObject support * task(SDK-5520) - Fixes a minor bump in nested object date ingestion * task(SDK-5520) - Fixes changelog date
📝 WalkthroughWalkthroughThis PR releases version 3.9.0 with support for nested objects in event and profile properties. It updates CleverTap Android SDK to 7.8.0 and iOS SDK to 7.5.0, adds native layer handling for nested Map and Array types, enhances recursive date conversion for nested structures, and introduces example app demonstrations of the nested properties feature. Changes
Sequence Diagram(s)sequenceDiagram
participant App as Example App
participant Bridge as React Native Bridge
participant Native as Native Layer<br/>(CleverTapModuleImpl)
participant SDK as CleverTap SDK
App->>App: Build nested payload<br/>(set_userProfileWithNestedProperties)
App->>Bridge: recordEvent('Product Purchased',<br/>eventProps with nested objs)
Bridge->>Bridge: convertDateToEpochInProperties<br/>(recursive traversal)
Bridge->>Native: Read ReadableMap<br/>(including nested Maps/Arrays)
Native->>Native: Handle nested Map type<br/>via MapUtil.toMap()
Native->>Native: Handle nested Array type<br/>via ArrayUtil.toArray()
Native->>SDK: profileSet() / recordEvent()<br/>with nested objects
SDK->>SDK: Process nested structure
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/index.js (1)
1244-1268: Recursive date conversion looks correct but has inconsistent indentation.The nested object and array handling properly recurses to convert
Datevalues at any depth. However, the array branch (lines 257-264) uses extra indentation compared to the rest of the function body, which hurts readability.One edge-case note: arrays nested inside arrays are handled implicitly — an inner array item passes the
typeof item === 'object'check on line 260 and entersconvertDateToEpochInProperties, which works becauseObject.entrieson an array yields index-value pairs. Consider adding an explicitArray.isArray(item)branch for clarity and to avoid relying on this implicit behavior.♻️ Suggested improvement for explicit nested array handling
} else if (Array.isArray(value)) { - value.forEach((item, index) => { - if (Object.prototype.toString.call(item) === '[object Date]') { - value[index] = "$D_" + Math.floor(item.getTime() / 1000); - } else if (item !== null && typeof item === 'object') { - convertDateToEpochInProperties(item); - } - }); - } + value.forEach((item, index) => { + if (Object.prototype.toString.call(item) === '[object Date]') { + value[index] = "$D_" + Math.floor(item.getTime() / 1000); + } else if (Array.isArray(item)) { + // Recursively handle nested arrays + item.forEach((nestedItem, nestedIndex) => { + if (Object.prototype.toString.call(nestedItem) === '[object Date]') { + item[nestedIndex] = "$D_" + Math.floor(nestedItem.getTime() / 1000); + } else if (nestedItem !== null && typeof nestedItem === 'object') { + convertDateToEpochInProperties(nestedItem); + } + }); + } else if (item !== null && typeof item === 'object') { + convertDateToEpochInProperties(item); + } + }); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/index.js` around lines 1244 - 1268, The convertDateToEpochInProperties function works but its array branch has inconsistent indentation and should explicitly handle arrays nested inside arrays; reformat the Array.isArray(value) branch to match the function's indentation style and add an explicit Array.isArray(item) check inside the value.forEach loop (in function convertDateToEpochInProperties) so that when item is an array you call convertDateToEpochInProperties(item) directly instead of relying on Object.entries on arrays; ensure the rest of the recursive branches remain unchanged and preserve Date-to-"$D_" epoch conversion logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/index.js`:
- Around line 1244-1268: The convertDateToEpochInProperties function works but
its array branch has inconsistent indentation and should explicitly handle
arrays nested inside arrays; reformat the Array.isArray(value) branch to match
the function's indentation style and add an explicit Array.isArray(item) check
inside the value.forEach loop (in function convertDateToEpochInProperties) so
that when item is an array you call convertDateToEpochInProperties(item)
directly instead of relying on Object.entries on arrays; ensure the rest of the
recursive branches remain unchanged and preserve Date-to-"$D_" epoch conversion
logic.
Inaction and NestedObject support
task(SDK-5520) - Fixes a minor bump in nested object date ingestion
task(SDK-5520) - Fixes changelog date
https://wizrocket.atlassian.net/browse/SDK-5520
Summary by CodeRabbit
Release 3.9.0