Skip to content

feat: adds support for attribute data types#49

Merged
pandeymangg merged 4 commits intomainfrom
feat/attribute-data-type-updates
Feb 17, 2026
Merged

feat: adds support for attribute data types#49
pandeymangg merged 4 commits intomainfrom
feat/attribute-data-type-updates

Conversation

@pandeymangg
Copy link
Contributor

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

@pandeymangg pandeymangg requested a review from Dhruwang February 13, 2026 10:48
@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

Walkthrough

This 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 Record<string, string> to Record<string, string | number | Date> throughout the codebase. Date values are normalized to ISO strings during processing while strings and numbers are preserved. Error handling is refined to log errors separately from warnings and return a hasWarnings boolean in response payloads. Public API signatures for sendUpdates, sendUpdatesToBackend, and setAttributes are updated accordingly. Error messages for unknown action codes are improved for clarity.

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (14 files):

⚔️ packages/react-native/src/components/survey-web-view.tsx (content)
⚔️ packages/react-native/src/index.ts (content)
⚔️ packages/react-native/src/lib/common/api.ts (content)
⚔️ packages/react-native/src/lib/survey/action.ts (content)
⚔️ packages/react-native/src/lib/survey/tests/action.test.ts (content)
⚔️ packages/react-native/src/lib/user/attribute.ts (content)
⚔️ packages/react-native/src/lib/user/tests/attribute.test.ts (content)
⚔️ packages/react-native/src/lib/user/tests/update-queue.test.ts (content)
⚔️ packages/react-native/src/lib/user/tests/update.test.ts (content)
⚔️ packages/react-native/src/lib/user/update-queue.ts (content)
⚔️ packages/react-native/src/lib/user/update.ts (content)
⚔️ packages/react-native/src/types/api.ts (content)
⚔️ packages/react-native/src/types/config.ts (content)
⚔️ pnpm-lock.yaml (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: expanding attribute support to include multiple data types (string, number, and Date) across the codebase.
Description check ✅ Passed The description relates to the changeset by explaining that it adds support for attribute data types and references the equivalent changes in the related repository.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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 | 🟡 Minor

URL version mismatch between error metadata and actual API endpoint.

sendUpdatesToBackend (Line 32) and sendUpdates (Line 78) both construct the URL as /api/v1/client/..., but ApiClient.createOrUpdateUser in api.ts (Line 85) actually posts to /api/v2/client/${environmentId}/user. This means the url field 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) and sendUpdates (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: sendUpdatesToBackend catch block re-throws instead of returning — verify this is intentional.

The catch block constructs an err(...) object but then throws error.error instead of returning it. This means callers of sendUpdatesToBackend must handle both a rejected promise and a returned error Result. The caller sendUpdates does 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 string cast on language attribute — consider a runtime guard.

With TAttributes now being Record<string, string | number>, language could theoretically be a number. The cast silently coerces the type. This is practically safe since language values are always strings, but a String(...) call would be more defensive than a type-only assertion.

@sonarqubecloud
Copy link

@pandeymangg pandeymangg added this pull request to the merge queue Feb 17, 2026
Merged via the queue into main with commit 1649f3f Feb 17, 2026
9 checks passed
@pandeymangg pandeymangg deleted the feat/attribute-data-type-updates branch February 17, 2026 11:14
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