feat(W-23159740): per-user persistent feature flags (iOS)#4086
Open
wmathurin wants to merge 22 commits into
Open
feat(W-23159740): per-user persistent feature flags (iOS)#4086wmathurin wants to merge 22 commits into
wmathurin wants to merge 22 commits into
Conversation
Implements per-user feature flag storage and hydration so each user account's active features are accurately reflected in the User-Agent string across app restarts. - SFSDKAppFeatureMarkers: +registerAppFeature:forUser:, +unregisterAppFeature:forUser:, +appFeaturesForUser: (union of global + per-user), +loadPersistedFeatures:forUser: - SFUserAccount: persistedFeatureFlags property (NSSet<NSString*>), serialized via NSKeyedArchiver into UserAccount.plist - SalesforceSDKManager: userAgentString:qualifier:forUser: unions global + per-user flags; hydratePerUserFeatureFlags called from sharedManager dispatch_once - SFUserAccountManager: finalizeAuthCompletion promotes BW/WD/QR transient global flags to per-user after login completes - SFSmartStore: SU flag now registered per-user - SFMobileSyncSyncManager: MS flag now registered per-user - SFSDKAppFeatureMarkersTests: 6 new tests covering isolation, union, nil-user fallback, per-user unregister, hydration, and persistence
Clang Static Analysis Issues
Generated by 🚫 Danger |
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (77.88%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## dev #4086 +/- ##
==========================================
+ Coverage 66.71% 68.51% +1.79%
==========================================
Files 246 246
Lines 21541 21620 +79
==========================================
+ Hits 14372 14813 +441
+ Misses 7169 6807 -362
🚀 New features to boost your workflow:
|
|
||||||||||||||
|
||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||
bbirman
reviewed
Jun 25, 2026
bbirman
reviewed
Jun 25, 2026
- Replace custom SFSDKUserKey() with SFKeyForUserAndScope(user, SFUserAccountScopeUser) to reuse the existing codebase convention for user-scoped keys - Capture per-user flag snapshot inside dispatch_sync block before assigning to user.persistedFeatureFlags, eliminating the map read outside the queue's protection
|
||||||||||||||||||||||||||||||||||||||||||
bbirman
approved these changes
Jun 25, 2026
…tion to UI tests - UserCredentialsView: add "SDK" section with User Agent row and JSON export - AuthFlowTesterMainPageObject: add getUserAgent() via JSON export - BaseAuthFlowTester: add validateUserAgent(), loginOtherUser(), isMultiUser param - MultiUserLoginTests: add testAdvancedAuthUser_HasBWFlag_RegularAuthUser_DoesNot - SFUserAccountManager: fix BW/WD global flag bleed by clearing global flags after promoting to per-user in finalizeAuthCompletion (matches existing QR pattern)
|
||||||||||||||
…Agent into public/private overloads validateUserAgent(loginHost:...) now fetches the UA once and delegates to a private overload that takes ua: String. validate() calls the private overload using credentials already loaded, eliminating a second export-button round-trip.
…ode paths - SFSDKAppFeatureMarkersTests: appFeaturesForUser:nil equivalence, unregister updates persistedFeatureFlags - SFUserAccountManagerTests: persistedFeatureFlags NSKeyedArchiver encode/decode roundtrip - SalesforceSDKManagerTests: userAgentString:forUser: with per-user flag, nil-user fallback, hydratePerUserFeatureFlags - Expose hydratePerUserFeatureFlags in SalesforceSDKManager+Internal.h for testability
…e-deriving from credentials.domain By auth completion, handleCustomDomainUpdateWithLoginHint:myDomain: has replaced credentials.domain with the resolved org domain, which no longer contains '/discovery'. Re-evaluating isDiscoveryDomain at that point always returns false, so the WD flag was never promoted to per-user. Use the transient global flag (already set by SFOAuthCoordinator at auth start) as the source of truth, matching the QR flag pattern.
…r BW, WD, QR Covers the six promotion call patterns from SFUserAccountManager auth-completion block (lines 2082-2107): BW promoted/cleared on advancedBrowser vs non-advanced authType, WD promoted/cleared based on global flag presence, QR promoted/cleared based on global flag presence.
…inForAdmin LoginForAdminTests use a regular login host but browser-based auth, which sets the BW flag. validateUserAgent was deciding BW solely from loginHost, causing LoginForAdminTests to fail. Now callers pass expectAdvancedAuth (true when loginForAdmin || loginHost == .advancedAuth) and the UA check uses that instead of re-deriving from the host.
Server returns invalid_grant for RTR + JWT tokens in hybrid flow. Tests will be re-enabled once the server fix lands.
…into W-21167151-feature-flags-per-user
…e UA before revoke/refresh - Add userAgent to UserCredentialsData and parse it from the sdk section in getUserCredentials(), eliminating the separate getUserAgent() UI round trip - Remove standalone getUserAgent() from page object and BaseAuthFlowTester - validateUserAgent() now takes userCredentials instead of calling getUserAgent() - In validate(), move validateUserAgent before assertRevokeAndRefreshWorks so the UA is checked on the just-authenticated state, not after token rotation
…nsistency with Android validateUser() now validates feature flags inline (matching Android's validateUser()), so callers never need a separate validateUserAgent step. The expectAdvancedAuth, usesWelcomeDiscovery, and isMultiUser flags are forwarded through validate(), restartAndValidateUser, and switchToUserAndValidateUser.
…/switchToUserAndValidateUser expectAdvancedAuth was derived from loginHost == .advancedAuth alone, missing the loginForAdmin case where browser-based auth is used regardless of loginHost.
…estart Adds two tests to LoginWithRestartTests: - testAdvancedAuth_WithRestart: login via advanced auth (BW flag), restart, assert BW still set - testWelcomeDiscovery_WithRestart: login via welcome discovery (WD flag), restart, assert WD still set Also adds usesWelcomeDiscovery param to restartAndValidateUser so the WD flag can be asserted post-restart.
…tAndValidateUser call loginHost: .advancedAuth already implies expectAdvancedAuth = true internally.
…ature flag tests to overview
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
SFUserAccountviapersistedFeatureFlags(NSSet, serialized with NSKeyedArchiver into UserAccount.plist)SFSDKAppFeatureMarkersgains per-user register/unregister/query methods;+appFeaturesForUser:returns global ∪ per-user union;+loadPersistedFeatures:forUser:hydrates in-memory state without writebackSalesforceSDKManager.userAgentString:qualifier:forUser:resolves per-user flags for UA construction;hydratePerUserFeatureFlagspopulates in-memory state at SDK initSFUserAccountManager.finalizeAuthCompletion:promotes BW/WD/QR transient global flags to per-user after authentication completesSFSDKAppFeatureMarkersTestsGUS Stories
Test plan
SFSDKAppFeatureMarkersTests— 9 tests, 0 failuresSalesforceSDKManagerTests— all existing tests passxcodebuild build -scheme SalesforceSDKCore -sdk iphonesimulator