clients icon indicating copy to clipboard operation
clients copied to clipboard

[SM-1570] Adding DisableSMAdsForUsers - Front end changes to disable SM ads for users

Open cd-bitwarden opened this issue 2 months ago â€ĸ 3 comments

đŸŽŸī¸ Tracking

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

📔 Objective

Removing ads when the organization has useDisableSMAdsForUsers set to true, if the orgUser is of type User.

📸 Screenshots

For a user when the useDisableSMAdsForUsers is set to True: image

⏰ 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 Oct 23 '25 15:10 cd-bitwarden

Logo Checkmarx One – Scan Summary & Details – 74f94a80-a930-430c-b23a-e35fce91bd26

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

github-actions[bot] avatar Oct 23 '25 15:10 github-actions[bot]

Codecov Report

:x: Patch coverage is 62.50000% with 3 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 41.84%. Comparing base (be9d0c0) to head (2a78d7c). :warning: Report is 1 commits behind head on main. :white_check_mark: All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...roduct-switcher/shared/product-switcher.service.ts 75.00% 0 Missing and 1 partial :warning:
...n-console/models/response/organization.response.ts 0.00% 1 Missing :warning:
...e/models/response/profile-organization.response.ts 0.00% 0 Missing and 1 partial :warning:
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #17000   +/-   ##
=======================================
  Coverage   41.84%   41.84%           
=======================================
  Files        3589     3589           
  Lines      104191   104200    +9     
  Branches    15719    15724    +5     
=======================================
+ Hits        43597    43602    +5     
- Misses      58738    58739    +1     
- Partials     1856     1859    +3     

: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 Oct 28 '25 18:10 codecov[bot]

Claude finished @cd-bitwarden's task —— View job


Code Review Complete ✅

I've reviewed the PR changes for adding DisableSMAdsForUsers functionality. The implementation follows good patterns but has some critical issues that need addressing.

Tasks

  • [x] Analyze PR context and changes
  • [x] Perform comprehensive code review
  • [x] Post review feedback

Summary

The bitwarden-code-reviewer agent has posted 7 inline comments with detailed feedback on specific lines. Here are the key findings:

🔴 Critical Issues

  1. Multi-Organization Logic Flaw (product-switcher.service.ts:279-283)

    • Current logic uses .some() which will incorrectly hide SM ads for users who are Admins/Owners in some orgs but regular Users in others
    • Example: User is Admin in Org A, but User in Org B with flag=true → ads incorrectly hidden
    • Fix needed: Logic should prioritize Admin/Owner status across all orgs
  2. Missing Test Coverage (product-switcher.service.ts:279-283)

    • Core conditional logic has zero test coverage (Codecov reports 62.5% patch coverage)
    • Critical functionality must have comprehensive tests for:
      • Flag enabled + User type → ads hidden
      • Flag enabled + Admin/Owner type → ads shown
      • Flag disabled → ads shown
      • Multi-org scenarios
  3. Custom User Type Not Addressed (product-switcher.service.ts:279-283)

    • Code only checks for OrganizationUserType.User but doesn't handle OrganizationUserType.Custom
    • Need clarification: Should Custom users also have ads disabled?

✅ Positive Aspects

  • Good null safety with consistent use of ?? false for backward compatibility
  • Clean data flow through all model layers (response → data → domain)
  • Follows existing codebase patterns for boolean properties
  • Test fixtures properly updated

📋 Recommendations

  1. Fix the multi-org logic to check if user has Admin/Owner access in ANY org before hiding ads
  2. Add comprehensive unit tests to product-switcher.service.spec.ts
  3. Clarify and document behavior for Custom user types
  4. Consider adding JSDoc comments explaining the business logic

Please review the inline comments for specific implementation suggestions and code examples.


claude[bot] avatar Oct 28 '25 19:10 claude[bot]