Skip to content

fix: adds setNonce to TFormbricks type and jsdoc comments#29

Merged
pandeymangg merged 7 commits intomainfrom
fix/update-types
Dec 12, 2025
Merged

fix: adds setNonce to TFormbricks type and jsdoc comments#29
pandeymangg merged 7 commits intomainfrom
fix/update-types

Conversation

@pandeymangg
Copy link
Contributor

Adds the type for setNonce

  /**
   * Sets the CSP nonce for inline styles
   * @param nonce - The CSP nonce value (without 'nonce-' prefix), or undefined to clear
   */
  setNonce: (nonce: string | undefined) => void;

@coderabbitai
Copy link

coderabbitai bot commented Dec 12, 2025

Walkthrough

Adds multiple public async methods to the TFormbricks type: setup({ environmentId, appUrl }), setEmail, setAttribute, setAttributes, setLanguage, setUserId, setNonce, logout, and registerRouteChange (all returning Promise<void>). The existing track and init methods remain. Bumps packages/js version from 4.2.1 to 4.3.0 and updates dependency versions in the playground app (next, react, react-dom, lucide-react).

Pre-merge checks

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions adding setNonce and JSDoc comments, but the actual changeset includes 8 additional new methods beyond setNonce and updates to multiple package versions—making the title incomplete and not representative of the full scope. Update the title to reflect all major changes, such as 'feat: add multiple methods to TFormbricks type and update dependencies', or focus on the most significant change if keeping it concise.
Description check ⚠️ Warning The description only documents the setNonce method in detail, but the changeset actually adds 8 other methods (setup, setEmail, setAttribute, setAttributes, setLanguage, setUserId, logout, registerRouteChange) and updates package versions—the description is incomplete. Expand the description to document all added methods to the TFormbricks interface and mention the package version updates in apps/playground and packages/js.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a50155a and f719a48.

📒 Files selected for processing (1)
  • packages/js/src/types/formbricks.ts (1 hunks)
🔇 Additional comments (4)
packages/js/src/types/formbricks.ts (4)

10-17: LGTM!

The JSDoc documentation for the setup method is clear and properly formatted.


19-36: LGTM!

The JSDoc documentation for setEmail, setAttribute, and setAttributes methods is clear and follows a consistent pattern.


56-66: LGTM!

The JSDoc documentation and type signature for the track method are clear and properly defined.


68-77: LGTM!

The JSDoc documentation for logout and registerRouteChange is clear and functional. The documentation style is appropriate for these action-oriented methods.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f719a48 and f9cd5a9.

📒 Files selected for processing (1)
  • packages/js/src/types/formbricks.ts (1 hunks)
🔇 Additional comments (1)
packages/js/src/types/formbricks.ts (1)

50-55: setNonce return type as Promise<void> matches the proxy behavior (good)
This resolves the prior type mismatch risk (sync void vs async proxy). Only nit: align JSDoc style with the rest (@description, punctuation, and undefined formatting).

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f9cd5a9 and ea3da47.

📒 Files selected for processing (3)
  • apps/playground/package.json (1 hunks)
  • packages/js/package.json (1 hunks)
  • packages/js/src/types/formbricks.ts (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Build JS Package
apps/playground/package.json

[error] 1-1: Cannot install with 'frozen-lockfile' because pnpm-lock.yaml is not up to date with this package.json. Command failed: pnpm install --frozen-lockfile.

🪛 GitHub Actions: Run unit tests for js package
apps/playground/package.json

[error] 1-1: Dependency specifiers in lockfile do not match manifest. 4 mismatches: lucide-react (lockfile: 0.559.0, manifest: 0.561.0), next (16.0.8 vs 16.0.10), react (19.2.1 vs 19.2.3), react-dom (19.2.1 vs 19.2.3).

🪛 GitHub Actions: SonarQube
apps/playground/package.json

[error] 1-1: Command failed: pnpm install --frozen-lockfile. Lockfile is out of date and contains mismatched specifiers with the manifest: lucide-react (lockfile: 0.559.0, manifest: 0.561.0), next (lockfile: 16.0.8, manifest: 16.0.10), react (lockfile: 19.2.1, manifest: 19.2.3), react-dom (lockfile: 19.2.1, manifest: 19.2.3). Run 'pnpm install' or update the lockfile.

🔇 Additional comments (3)
packages/js/package.json (1)

4-4: LGTM! Version bump aligns with the new public API.

The minor version increment from 4.2.1 to 4.3.0 appropriately reflects the addition of new public methods to the TFormbricks interface.

packages/js/src/types/formbricks.ts (2)

10-48: LGTM! JSDoc documentation is clear and consistent.

The method signatures and documentation for setup, setEmail, setAttribute, setAttributes, setLanguage, and setUserId follow a consistent pattern with clear descriptions and parameter documentation.


56-76: LGTM! Event tracking and lifecycle methods are properly typed.

The track, logout, and registerRouteChange methods all correctly return Promise<void> and have appropriate JSDoc documentation.

@sonarqubecloud
Copy link

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

♻️ Duplicate comments (3)
packages/js/src/types/formbricks.ts (3)

10-17: Clarify what setupConfig.appUrl should be (origin vs path) and how it relates to initConfig.apiHost.
This remains easy to misconfigure when migrating from init. Add an explicit example (and whether it must include protocol/port).


19-42: Tighten repetitive JSDoc phrasing (“of the user”) for consistency/readability.
Pure doc polish, but it’s repeated across the new public surface.


56-66: track typing still forces properties.hiddenFields whenever properties is passed.
This prevents track("x", {}) and similar calls; consider making hiddenFields optional and/or allowing additional keys.

  track: (
    code: string,
    properties?: {
-     hiddenFields: Record<string | number, string | number | string[]>;
+     hiddenFields?: Record<string | number, string | number | string[]>;
    }
  ) => Promise<void>;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ea3da47 and 75b8b35.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • packages/js/src/types/formbricks.ts (1 hunks)
🔇 Additional comments (1)
packages/js/src/types/formbricks.ts (1)

44-48: setUserId JSDoc looks good now.
Concise and consistent with the rest of the interface.

@pandeymangg pandeymangg added this pull request to the merge queue Dec 12, 2025
Merged via the queue into main with commit 1dcd4fa Dec 12, 2025
9 checks passed
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