Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/js/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@formbricks/js",
"license": "MIT",
"version": "4.2.1",
"version": "4.3.1",
Copy link
Member

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 ;-) )

"description": "Formbricks-js allows you to connect your index to Formbricks, display surveys and trigger events.",
"homepage": "https://formbricks.com",
"repository": {
Expand Down Expand Up @@ -57,4 +57,4 @@
"vite-plugin-dts": "4.5.4",
"vitest": "3.2.4"
}
}
}
3 changes: 2 additions & 1 deletion packages/js/src/types/formbricks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ export interface TFormbricks {
code: string,
properties?: {
hiddenFields: Record<string | number, string | number | string[]>;
},
}
) => Promise<void>;

logout: () => Promise<void>;

registerRouteChange: () => Promise<void>;
setNonce: (nonce: string) => Promise<void>;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 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:

  1. The implementation exists in the main Formbricks class
  2. Unit tests cover the new method
  3. 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:

  1. Implementation that proxies the nonce parameter through loadFormbricksToProxy (consistent with other setter methods)
  2. Test case in packages/js/src/index.test.ts following 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).

}