feat: adds support for attribute data types#49
Conversation
WalkthroughThis pull request expands the attribute system to support multiple data types and enhances error handling across the React Native SDK. Attribute types are widened from 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/react-native/src/lib/user/update.ts (1)
32-32:⚠️ Potential issue | 🟡 MinorURL version mismatch between error metadata and actual API endpoint.
sendUpdatesToBackend(Line 32) andsendUpdates(Line 78) both construct the URL as/api/v1/client/..., butApiClient.createOrUpdateUserinapi.ts(Line 85) actually posts to/api/v2/client/${environmentId}/user. This means theurlfield in error responses will reference the wrong endpoint, making debugging harder.Suggested fix
- const url = `${appUrl}/api/v1/client/${environmentId}/user`; + const url = `${appUrl}/api/v2/client/${environmentId}/user`;Apply in both
sendUpdatesToBackend(Line 32) andsendUpdates(Line 78).Also applies to: 78-78
🤖 Fix all issues with AI agents
In `@packages/react-native/src/lib/user/attribute.ts`:
- Around line 4-16: The docstring in attribute.ts incorrectly claims ISO 8601
strings are treated as date attributes while the normalization loop in the
module (the string pass-through logic in the attribute normalization code) does
not implement date-string detection; update the docstring in the top of the file
to accurately reflect reality by replacing "ISO 8601 date strings -> date
attribute" with a note that ISO 8601 strings are not parsed client-side and that
the backend will detect/convert ISO 8601 date strings to date attributes (or
alternatively implement client-side detection/conversion in the normalization
loop if you prefer that behavior).
🧹 Nitpick comments (2)
packages/react-native/src/lib/user/update.ts (1)
52-65:sendUpdatesToBackendcatch block re-throws instead of returning — verify this is intentional.The catch block constructs an
err(...)object but then throwserror.errorinstead of returning it. This means callers ofsendUpdatesToBackendmust handle both a rejected promise and a returned errorResult. The callersendUpdatesdoes handle both paths (Lines 87-89 for returned errors, Lines 120-130 for thrown exceptions), so this works, but the asymmetry is worth noting — the "throw on network failure, return on API error" contract is implicit and not documented.packages/react-native/src/lib/user/update-queue.ts (1)
83-83:as stringcast onlanguageattribute — consider a runtime guard.With
TAttributesnow beingRecord<string, string | number>,languagecould theoretically be anumber. The cast silently coerces the type. This is practically safe since language values are always strings, but aString(...)call would be more defensive than a type-only assertion.
|



Adds support for attributes data types. All the js-core equivalent changes for the PR on formbricks formbricks/formbricks#7246 are here