feat: adds workspace support#47
Conversation
WalkthroughThis pull request updates the Formbricks JavaScript SDK's setup configuration to support 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (5)
packages/js/README.mdpackages/js/src/index.test.tspackages/js/src/lib/load-formbricks.test.tspackages/js/src/lib/load-formbricks.tspackages/js/src/types/formbricks.ts
|



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