Skip to content

Conversation

@gazjones00
Copy link

@gazjones00 gazjones00 commented Jun 27, 2025

Add Legacy Client Support to React Bindings SDK

Problem:

Currently, it's not possible to use the legacy client with the React Bindings SDK because the bootstrap initialisation always calls dataAdapter.setData(). However, Cloudflare integration requires using dataAdapter.setDataLegacy() method from the legacy Node SDK.

Solution:

  • Added an optional useLegacyClient parameter to useClientBootstrapInit
  • Modified useStatsigInternalClientFactoryBootstrap to conditionally call setDataLegacy when the legacy client flag is enabled
  • When using legacy client, passes both initialValues and initialUser to setDataLegacy as required by the legacy API
  • Maintains backward compatibility by defaulting to the standard setData behavior

Context:

Per discussion with Statsig: "I chatted with our SDK PM and they're still figuring out what the long-term plan will be for a server SDK on cloudflare. If they can get the new SDK running there it might be that, but for now the 'Legacy' Node SDK will be fully supported for cases like that, until we have a new solution."

This change enables developers using Cloudflare deployments to leverage the React bindings with the legacy Node SDK until a permanent solution is available.

statsig-kong bot pushed a commit that referenced this pull request Jul 8, 2025
* feat(react-bindings): add legacy format support for server SDKs

- Add useLegacyFormat parameter to useClientBootstrapInit
- Conditionally call setDataLegacy when flag is enabled
- Support legacy server SDKs that require separate user parameter

Based on public PR #30 with naming feedback incorporated

Co-Authored-By: [email protected] <[email protected]>

* test(react-bindings): add comprehensive tests for useClientBootstrapInit

- Test both standard bootstrap (setData) and legacy format (setDataLegacy) code paths
- Verify correct parameter passing and method invocation
- Ensure backward compatibility with default behavior
- Follow existing test patterns from React bindings package

Co-Authored-By: [email protected] <[email protected]>

* fix: format test file with Prettier to resolve lint failure

Co-Authored-By: [email protected] <[email protected]>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: [email protected] <[email protected]>
@gazjones00
Copy link
Author

gazjones00 commented Jul 8, 2025

Thanks @kat-statsig - appreciate you getting this added! I noticed the release notes list you and devin as the authors. I’m guessing that’s automated? No worries either way, but if there’s a quick way to update it, it’d be great to have some creditfor this change. Thanks again!

@brock-statsig

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