clients icon indicating copy to clipboard operation
clients copied to clipboard

[SM-1743] feature flag implementation for disableSmAdsForUsers

Open cd-bitwarden opened this issue 1 month ago â€ĸ 3 comments

đŸŽŸī¸ Tracking

https://bitwarden.atlassian.net/jira/software/c/projects/SM/boards/74?assignee=625cb516fd06270069beaf5d&selectedIssue=SM-1743

📔 Objective

Add feature flag for disableSmAdsForUsers

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

đŸĻŽ Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or â„šī¸ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or âš ī¸ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or â™ģī¸ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

cd-bitwarden avatar Nov 20 '25 21:11 cd-bitwarden

Logo Checkmarx One – Scan Summary & Details – 66f586c9-485f-4cce-8cb7-a784f668ccae

Great job! No new security vulnerabilities introduced in this pull request

github-actions[bot] avatar Nov 20 '25 22:11 github-actions[bot]

Claude finished @cd-bitwarden's task in 6m 37s —— View job


Code Review Complete ✅

I've completed a comprehensive review of this PR. The feature flag implementation follows Bitwarden's patterns correctly and properly propagates through all layers (API → Data → Domain → Service). However, there are some important items to address:

🔴 Must Fix Before Merge

  1. Missing Test Coverage - The new shouldDisableSMAds logic in product-switcher.service.ts has no unit tests. This is critical functionality that needs test coverage for:

    • User with no organizations with the flag
    • Regular User in org with flag enabled (should hide ad)
    • Admin/Owner in org with flag enabled (should show ad)
    • Edge cases with multiple organizations
  2. Revert Tools Formatting Changes - As @harr1424 noted, please revert the formatting-only changes to the 11 files in libs/tools/generator/. These are unrelated to your feature and make the PR harder to review.

âš ī¸ Logic Clarification Needed

The current implementation uses orgs.some() which means the SM ad will be hidden if the user is a regular User type in ANY organization with the flag enabled.

Question: Is this the intended behavior, or should it only hide the ad if:

  • ALL organizations have the flag enabled?
  • The user is a regular User in their primary/current organization?

Please verify this with product/business requirements and add a code comment documenting the decision.

✅ What's Working Well

  • Feature flag properly propagated through all layers
  • Consistent naming convention with existing flags
  • Clean, readable implementation
  • Test data properly updated

claude[bot] avatar Dec 12 '25 04:12 claude[bot]

Codecov Report

:x: Patch coverage is 82.92683% with 7 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 41.85%. Comparing base (27d82aa) to head (82ef39b). :warning: Report is 3 commits behind head on main. :white_check_mark: All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...s/extension-device-management-component.service.ts 0.00% 1 Missing :warning:
...roduct-switcher/shared/product-switcher.service.ts 75.00% 0 Missing and 1 partial :warning:
...ent/default-device-management-component.service.ts 0.00% 1 Missing :warning:
...ault-two-factor-auth-webauthn-component.service.ts 0.00% 1 Missing :warning:
...n-console/models/response/organization.response.ts 0.00% 1 Missing :warning:
...ganization/organization-sponsorship-api.service.ts 0.00% 1 Missing :warning:
...lt-user-asymmetric-key-regeneration-api.service.ts 0.00% 1 Missing :warning:
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #17525   +/-   ##
=======================================
  Coverage   41.84%   41.85%           
=======================================
  Files        3589     3589           
  Lines      104193   104199    +6     
  Branches    15719    15720    +1     
=======================================
+ Hits        43603    43610    +7     
+ Misses      58734    58731    -3     
- Partials     1856     1858    +2     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Dec 12 '25 04:12 codecov[bot]

Should there be so many formatting changes here? Looks like a bunch of teams are pinged due to formatting changes?

Yeah, if the formatting is intentional, it should be a separate concern, but my guess is an outdated branch basis with a different version of prettier (which has a commit hook to run in our default setups and version-bumped recently-ish).

@cd-bitwarden try running nvm install && npm ci on your local branch, then npm run lint:fix && npm run prettier

jprusik avatar Dec 18 '25 16:12 jprusik