[SM-1570] Adding DisableSMAdsForUsers - Front end changes to disable SM ads for users
đī¸ 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:
â° 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
Checkmarx One â Scan Summary & Details â 74f94a80-a930-430c-b23a-e35fce91bd26
Great job! No new security vulnerabilities introduced in this pull request
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.
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.
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
-
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
- Current logic uses
-
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
-
Custom User Type Not Addressed (product-switcher.service.ts:279-283)
- Code only checks for
OrganizationUserType.Userbut doesn't handleOrganizationUserType.Custom - Need clarification: Should Custom users also have ads disabled?
- Code only checks for
â Positive Aspects
- Good null safety with consistent use of
?? falsefor backward compatibility - Clean data flow through all model layers (response â data â domain)
- Follows existing codebase patterns for boolean properties
- Test fixtures properly updated
đ Recommendations
- Fix the multi-org logic to check if user has Admin/Owner access in ANY org before hiding ads
- Add comprehensive unit tests to product-switcher.service.spec.ts
- Clarify and document behavior for Custom user types
- Consider adding JSDoc comments explaining the business logic
Please review the inline comments for specific implementation suggestions and code examples.