-
Notifications
You must be signed in to change notification settings - Fork 0
added setNonce to types #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
WalkthroughThe pull request updates the JavaScript package with a version bump from 4.2.1 to 4.3.1. In the TypeScript type definitions for Formbricks, a new public method Pre-merge checks✅ Passed checks (3 passed)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
packages/js/package.json(2 hunks)packages/js/src/types/formbricks.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-09-24T17:04:00.743Z
Learnt from: pandeymangg
Repo: formbricks/js PR: 6
File: packages/js/src/lib/load-formbricks.test.ts:96-114
Timestamp: 2025-09-24T17:04:00.743Z
Learning: The formbricks/js project uses happy-dom as the test environment in Vitest configuration (packages/js/vite.config.ts), not jsdom. This configuration works well for DOM-dependent tests and is faster than jsdom.
Applied to files:
packages/js/package.json
📚 Learning: 2025-09-24T17:04:00.743Z
Learnt from: pandeymangg
Repo: formbricks/js PR: 6
File: packages/js/src/lib/load-formbricks.test.ts:96-114
Timestamp: 2025-09-24T17:04:00.743Z
Learning: The formbricks/js project uses happy-dom as the test environment in Vitest configuration, not jsdom. This is configured in packages/js/vite.config.ts and works well for DOM-dependent tests.
Applied to files:
packages/js/package.json
🔇 Additional comments (2)
packages/js/package.json (1)
4-4: LGTM! Appropriate version bump for the new feature.The minor version bump from 4.2.1 to 4.3.1 is appropriate for adding the new
setNoncepublic method, following semantic versioning conventions for backward-compatible functionality.packages/js/src/types/formbricks.ts (1)
25-30: Minor formatting improvement.The trailing comma was removed after the
hiddenFieldsproperty. This is a formatting-only change with no functional impact on the type definition.
| logout: () => Promise<void>; | ||
|
|
||
| registerRouteChange: () => Promise<void>; | ||
| setNonce: (nonce: string) => Promise<void>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
New setNonce method added - verify implementation and tests.
The type signature looks correct and follows the pattern of other setter methods in the interface. However, please ensure:
- The implementation exists in the main Formbricks class
- Unit tests cover the new method
- The method correctly handles the nonce value for CSP compliance
Run the following script to verify the implementation and tests exist:
🏁 Script executed:
#!/bin/bash
# Description: Verify setNonce implementation and tests exist
echo "=== Searching for setNonce implementation ==="
ast-grep --pattern 'setNonce($$$) {
$$$
}'
echo -e "\n=== Searching for setNonce in class/object definitions ==="
rg -nP --type=ts -C3 'setNonce\s*[:=]\s*(\(|async)'
echo -e "\n=== Searching for setNonce tests ==="
rg -nP --type=ts -C3 'describe|it|test.*setNonce|setNonce.*describe|it|test'Length of output: 60395
setNonce method requires implementation and tests - type-only addition is incomplete.
The type definition was added but the actual implementation and tests are missing. Other methods (setEmail, setAttribute, setUserId, etc.) in the codebase follow a consistent pattern where each has both an implementation that proxies through loadFormbricksToProxy and corresponding test coverage in packages/js/src/index.test.ts.
Add:
- Implementation that proxies the nonce parameter through
loadFormbricksToProxy(consistent with other setter methods) - Test case in
packages/js/src/index.test.tsfollowing the existing pattern for other setter methods
🤖 Prompt for AI Agents
In packages/js/src/types/formbricks.ts around line 35, the setNonce type was
added but not implemented; add a setNonce implementation in the corresponding
module (same file or the module that defines the other setters) that mirrors the
pattern of setEmail/setAttribute/setUserId by calling loadFormbricksToProxy()
and invoking the proxy method with the nonce parameter, returning the
Promise<void> result; also add a unit test in packages/js/src/index.test.ts
following the existing setter tests (mock loadFormbricksToProxy, call setNonce
with a test value, and assert the proxy was called with the correct method name
and nonce argument and that the returned promise resolves).
|
Hello 👋 Wanted to check in on the status of this PR. |
mattinannt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dhruwang Thank you for the PR :-)
I only have one concern regarding the version. We should do a new release for the js package next week when Anshuman has also merged his new changes.
| "name": "@formbricks/js", | ||
| "license": "MIT", | ||
| "version": "4.2.1", | ||
| "version": "4.3.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't change the version here at this moment, we should do this when we do a new release.
(and then we will likely go from 4.2.1 to 4.3.0 instead of 4.3.1 ;-) )



Add setNonce to types so that
formbricks.setNonce()does not throw a type error