Skip to content

Conversation

@nikita-ushakov
Copy link

Summary

  • After an app reinstall, calling restore() could result in the SDK operating under a newly created user instead of returning to the original user. This change adds user switching logic to the restore flow so that when the backend returns a different uid, the SDK updates its local state accordingly.
  • The implementation follows the same pattern already used in the identify() flow: persist the new user ID, update internal config, notify remote config manager, and clear the permissions cache.

Changes

  • QProductCenterManager.kt: Added handleUserSwitchingOnRestore() method, called in the restore() success callback before caching the launch result. If the returned uid differs from the current local user, the SDK switches to the returned user.
  • QProductCenterManagerTest.kt: Added 4 unit tests covering:
    • Restore with same uid → no user switch
    • Restore with different uid → user switch occurs (all side effects verified in order)
    • Restore with error → no user switch
    • Restore with empty uid in response → no user switch

Test plan

  • Existing unit tests pass
  • New unit tests pass
  • Manual test: reinstall app → restore → SDK returns to original user
  • Manual test: restore without reinstall → no user switch occurs

When restore returns a different uid than the current local user
(e.g. after app reinstall), the SDK now detects this and updates
the local user state accordingly: persists the new user ID, updates
internal config, resets remote config cache, and clears the
permissions cache.

This ensures the SDK correctly returns to the original user after
a restore instead of creating a duplicate user with copied
entitlements.

Co-authored-by: Cursor <cursoragent@cursor.com>
return
}

logger.release(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we need the release log here. I think debug is enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants