fix: never create guest IDs when generateGuestId is false; resolve useFlow loading state - #514
Merged
Merged
Conversation
… useFlow loading state Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two customer-reported issues with
generateGuestId={false}:1. A guest ID was still being created client-side. The SDK generated a
guest_<uuid>as the defaultuserIdand persisted it tolocalStorageregardless of the flag (and on SDK versions before@frigade/js@0.9.9, that guest ID was also sent to the API). The guest ID is now only generated when guest IDs are enabled; with the flag off and nouserId, the config'suserIdstaysundefinedand nothing is written tolocalStorage. Note: customers on@frigade/react2.10.5 or older lockfiles may still be pinned to@frigade/js0.9.8, which sent guestflowStates/sessionsrequests — upgrading picks up both fixes.2.
useFlownever resolved for anonymous users. With the flag off and no user logged in,isLoadingstayedtrueforever since no Flow would ever arrive.init()now still sets up local state (without any API calls) soisReady()andgetGlobalState()work,isAnonymousWithGuestIdDisabled()is exposed publicly, anduseFlowreturnsflow: undefinedwithisLoading: falsein this state.Also consolidated the scattered
generateGuestId === falsechecks ingetFlow/getFlows/getCollectionsonto the shared helper (which now also covers the undefined-userId case).Providing a
userId(at render time or later viaidentify()) restores full behavior, covered by the extended integration test.Test plan
can disable guest id generationtest: assertsuserIdisundefined, nofrigade-guest-keyin localStorage, zerofetchcalls while anonymous, and flows load afteridentify()@frigade/jsand@frigade/reactMade with Cursor