[PM-34134] [Innovation] Implement UserPreferences table and add to sync response#7329
Conversation
Introduces the UserPreferences domain entity, repository interface, and Dapper implementation for storing user synced preferences.
…user-preferences-PM-34134
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## innovation/sync-user-preferences #7329 +/- ##
===================================================================
Coverage ? 62.15%
===================================================================
Files ? 2059
Lines ? 90582
Branches ? 8053
===================================================================
Hits ? 56304
Misses ? 32322
Partials ? 1956 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
New Issues (140)Checkmarx found the following issues in this Pull Request
|
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
util/MySqlMigrations/Migrations/20260326201149_UserPreferencesInit.cs
Outdated
Show resolved
Hide resolved
| userAccountKeys = await _userAccountKeysQuery.Run(user); | ||
| } | ||
|
|
||
| var userPreferences = await _userPreferencesRepository.GetByUserIdAsync(user.Id); |
There was a problem hiding this comment.
Details and fix
The UserPreferencesController is gated behind [RequireFeature(FeatureFlagKeys.SyncUserPreferences)], but this sync endpoint unconditionally queries the UserPreferences table for every user on every sync call. This adds an extra DB round-trip to one of the most frequently called endpoints, even when the feature is disabled and no users have preferences.
This controller already establishes the pattern of gating behind feature flags before querying -- see webAuthnCredentials on line 131:
var webAuthnCredentials = _featureService.IsEnabled(FeatureFlagKeys.PM2035PasskeyUnlock)
? await _webAuthnCredentialRepository.GetManyByUserIdAsync(user.Id)
: [];Suggested fix:
| var userPreferences = await _userPreferencesRepository.GetByUserIdAsync(user.Id); | |
| var userPreferences = _featureService.IsEnabled(FeatureFlagKeys.SyncUserPreferences) | |
| ? await _userPreferencesRepository.GetByUserIdAsync(user.Id) | |
| : null; |
There was a problem hiding this comment.
@gbubemismith We should probably gate the query behind the flag in the sync controller as suggested.
There was a problem hiding this comment.
oh I missed this
shane-melton
left a comment
There was a problem hiding this comment.
Looks great! Only suggestion would be to feature flag the sync controller, but since this is going to a feature branch first anyways, doesn't need to hold it up.
|
1921a7e
into
innovation/sync-user-preferences







🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-34134
📔 Objective
📸 Screenshots