Skip to content

feat: adds workspace support#47

Merged
pandeymangg merged 2 commits intoepic/v5from
feat/workspace-support
Apr 30, 2026
Merged

feat: adds workspace support#47
pandeymangg merged 2 commits intoepic/v5from
feat/workspace-support

Conversation

@pandeymangg
Copy link
Copy Markdown
Contributor

Adds support for workspaceId and keeps support for environmentId as well for backwards compatibility by marking it as deprecated. Similar to the js-core changes for this

@pandeymangg pandeymangg changed the base branch from main to epic/v5 April 24, 2026 06:22
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

Walkthrough

This pull request updates the Formbricks JavaScript SDK's setup configuration to support workspaceId as an alternative identifier alongside the existing environmentId. The changes introduce a new TSetupConfig type that accepts appUrl with either workspaceId or environmentId (or both). Validation logic is updated to require at least one identifier and emit a deprecation warning when only environmentId is used. Documentation and test coverage are expanded to reflect the new configuration option while maintaining backward compatibility with existing deployments using environmentId.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: adds workspace support' clearly describes the main change—introducing workspace ID support—which aligns with the core modifications across all changed files.
Description check ✅ Passed The description is directly related to the changeset, explaining that workspaceId support is added while environmentId remains for backward compatibility and is marked deprecated.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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
Copy Markdown

@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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/js/src/lib/load-formbricks.test.ts`:
- Around line 4-8: Replace the inline config shape with the canonical
TSetupConfig type: add a static import of TSetupConfig from the types module at
the top of the test file and change the setup declaration to use TSetupConfig
(i.e. let setup: (config: TSetupConfig) => Promise<void>), keeping the dynamic
import("./load-formbricks") behavior for runtime module reset unchanged so only
the type is resolved statically.

In `@packages/js/src/lib/load-formbricks.ts`:
- Around line 79-80: The parameter to validateSetupArgs should be typed as
TSetupConfig instead of unknown; change the signature from
validateSetupArgs(config: unknown) to validateSetupArgs(config: TSetupConfig),
remove the runtime cast (config as TSetupConfig) and destructure directly (const
{ appUrl, environmentId, workspaceId } = config), and ensure any callers (e.g.,
setup) already passing a TSetupConfig keep their types so the compiler surfaces
typos like enviromentId.

In `@packages/js/src/types/formbricks.ts`:
- Around line 6-13: Replace the inline setupConfig object in the
TFormbricks.setup signature with the existing TSetupConfig type to avoid
duplication; update the setup signature to accept (setupConfig: TSetupConfig) =>
Promise<void>, ensuring TSetupConfig (the type that includes environmentId,
workspaceId, appUrl and the `@deprecated` JSDoc) is referenced instead of
redefining the shape, and keep TSetupConfig declared in the same module (no
reordering required).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0eb613f6-4063-4367-8ebf-7fb00e8c2ae9

📥 Commits

Reviewing files that changed from the base of the PR and between ca8bd8c and c6e0f02.

📒 Files selected for processing (5)
  • packages/js/README.md
  • packages/js/src/index.test.ts
  • packages/js/src/lib/load-formbricks.test.ts
  • packages/js/src/lib/load-formbricks.ts
  • packages/js/src/types/formbricks.ts

Comment thread packages/js/src/lib/load-formbricks.test.ts Outdated
Comment thread packages/js/src/lib/load-formbricks.ts Outdated
Comment thread packages/js/src/types/formbricks.ts Outdated
@sonarqubecloud
Copy link
Copy Markdown

@pandeymangg pandeymangg merged commit 6cbfec1 into epic/v5 Apr 30, 2026
7 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.

1 participant