Skip to content

fix: skip all API calls when generateGuestId is false and no userId is provided - #508

Merged
christianmat merged 1 commit into
mainfrom
fix/skip-api-calls-when-guest-id-disabled
Jul 27, 2026
Merged

fix: skip all API calls when generateGuestId is false and no userId is provided#508
christianmat merged 1 commit into
mainfrom
fix/skip-api-calls-when-guest-id-disabled

Conversation

@christianmat

Copy link
Copy Markdown
Contributor

Summary

When generateGuestId is set to false and no userId is provided, the SDK previously still sent a POST /v1/public/flowStates request with an auto-generated guest ID on initialization, page navigation, and tab focus. This contradicted the prop's documented behavior ("Frigade will not initialize or render any Flows until a userId is provided") and generated API traffic for anonymous visitors.

  • Added a guard in Fetchable.fetch() that skips all API requests when generateGuestId === false and the effective userId is missing or a guest_ ID. Since every request (flowStates, sessions, flow responses, tracking) goes through this method, this covers the full surface.
  • The flowStates refresh closure also returns early in this mode so the skipped request isn't misreported by hasFailedToLoad().
  • Global state is still initialized, so isReady() remains true and calling identify() with a real userId resumes normal behavior.

Test plan

  • Existing integration test can disable guest id generation passes (no flows anonymously → identify() → flows load)
  • Verified with a mocked fetch that zero requests occur with generateGuestId: false and no userId, and that requests resume after identify()
  • Typecheck passes

Made with Cursor

…s provided

Co-authored-by: Cursor <cursoragent@cursor.com>
@christianmat
christianmat merged commit fa0a863 into main Jul 27, 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