-
Notifications
You must be signed in to change notification settings - Fork 31
chore: add an example app for browser sdk #1019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@launchdarkly/browser size report |
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/js-client-sdk-common size report |
cd49047 to
1048727
Compare
|
@launchdarkly/js-client-sdk size report |
126daf7 to
d701b99
Compare
10632da to
580a21a
Compare
|
|
||
| ldclient.identify(context).catch(() => { | ||
| div.replaceChild(document.createTextNode('Error identifying client'), div.firstChild as Node); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: UI remains stuck when identify succeeds without flags
The identify call only has a .catch() handler without a .then() for the success case. The UI update relies entirely on the change event firing. However, the SDK only emits a change event when flag values differ from previous values. If no flags are configured in the LaunchDarkly project (or the server returns empty flags), identify succeeds but no change event fires, leaving the UI permanently stuck on "Initializing...". Adding a .then() handler that calls render() would ensure the UI updates after successful identification regardless of whether flags exist.
This PR will add a new browser SDK example that works with the new 4.x implementation.
Note
Adds a new browser example app demonstrating the JS client SDK, with build config and workspace inclusion.
packages/sdk/browser/example):src/app.tsinitializes@launchdarkly/js-client-sdk, identifies a user context, evaluatesflagKey, updates UI onchange/error.package.jsonwithtsdownbuild,tsconfig.json,tsdown.config.ts(browser bundling),index.html,index.css.README.mdwith setup and run instructions.packages/sdk/browser/exampleto rootpackage.jsonworkspaces.Written by Cursor Bugbot for commit 580a21a. This will update automatically on new commits. Configure here.