Skip to content

fix: never create guest IDs when generateGuestId is false; resolve useFlow loading state - #514

Merged
christianmat merged 1 commit into
mainfrom
fix/anonymous-guest-id-disabled-state
Jul 29, 2026
Merged

fix: never create guest IDs when generateGuestId is false; resolve useFlow loading state#514
christianmat merged 1 commit into
mainfrom
fix/anonymous-guest-id-disabled-state

Conversation

@christianmat

Copy link
Copy Markdown
Contributor

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 default userId and persisted it to localStorage regardless 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 no userId, the config's userId stays undefined and nothing is written to localStorage. Note: customers on @frigade/react 2.10.5 or older lockfiles may still be pinned to @frigade/js 0.9.8, which sent guest flowStates/sessions requests — upgrading picks up both fixes.

2. useFlow never resolved for anonymous users. With the flag off and no user logged in, isLoading stayed true forever since no Flow would ever arrive. init() now still sets up local state (without any API calls) so isReady() and getGlobalState() work, isAnonymousWithGuestIdDisabled() is exposed publicly, and useFlow returns flow: undefined with isLoading: false in this state.

Also consolidated the scattered generateGuestId === false checks in getFlow/getFlows/getCollections onto the shared helper (which now also covers the undefined-userId case).

Providing a userId (at render time or later via identify()) restores full behavior, covered by the extended integration test.

Test plan

  • Full js-api integration suite passes (23/23)
  • Extended can disable guest id generation test: asserts userId is undefined, no frigade-guest-key in localStorage, zero fetch calls while anonymous, and flows load after identify()
  • Typecheck and build pass for both @frigade/js and @frigade/react

Made with Cursor

… useFlow loading state

Co-authored-by: Cursor <cursoragent@cursor.com>
@christianmat
christianmat merged commit c21e076 into main Jul 29, 2026
1 of 2 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