Skip to content

[WPB-25136] Do not count apps as paying users.#5213

Draft
fisx wants to merge 6 commits intodevelopfrom
WPB-25136-do-not-count-apps-as-paying-users
Draft

[WPB-25136] Do not count apps as paying users.#5213
fisx wants to merge 6 commits intodevelopfrom
WPB-25136-do-not-count-apps-as-paying-users

Conversation

@fisx
Copy link
Copy Markdown
Contributor

@fisx fisx commented May 4, 2026

https://wearezeta.atlassian.net/browse/WPB-25136

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label May 4, 2026
@fisx fisx force-pushed the WPB-25136-do-not-count-apps-as-paying-users branch 2 times, most recently from d86787b to 6979bd7 Compare May 6, 2026 07:39
@fisx fisx requested a review from Copilot May 6, 2026 07:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates how team size is represented and reported across the Wire backend to distinguish between regular users and apps, enabling billing/journaling logic to avoid counting apps as “paying users”.

Changes:

  • Extend TeamSize to track (regulars, apps) and expose a teamSizeTotal helper.
  • Update Galley/Brig code paths (member add/remove, legalhold checks, invitations, team-size endpoints) to use the new TeamSize shape.
  • Update journaling protobuf schema and API/golden/integration tests to include the new breakdown fields.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
services/galley/src/Galley/API/Teams.hs Updates activation/member add/delete flows to use the new TeamSize and app-vs-regular adjustments.
services/galley/src/Galley/API/LegalHold/Team.hs Switches LegalHold size-limit checks to use TeamSize (via teamSizeTotal).
services/brig/test/integration/API/Team.hs Updates integration expectations for the new TeamSize JSON shape.
libs/wire-subsystems/test/unit/Wire/MockInterpreters/IndexedUserStore.hs Adjusts mock indexed store team-size calculation to split regulars/apps.
libs/wire-subsystems/src/Wire/UserSubsystem/Interpreter.hs Updates max-team-size enforcement to use teamSizeTotal.
libs/wire-subsystems/src/Wire/TeamJournal.hs Changes journal API to accept TeamSize and attempts to emit new member-count fields.
libs/wire-subsystems/src/Wire/IndexedUserStore/ElasticSearch.hs Updates ES counting logic to compute regular/app counts separately.
libs/wire-api/test/golden/testObject_TeamSize_1.json Golden update for new JSON fields.
libs/wire-api/test/golden/testObject_TeamSize_2.json Golden update for new JSON fields.
libs/wire-api/test/golden/testObject_TeamSize_3.json Golden update for new JSON fields.
libs/wire-api/test/golden/Test/Wire/API/Golden/Manual/TeamSize.hs Updates golden test objects to construct TeamSize regulars apps.
libs/wire-api/src/Wire/API/User/Search.hs Introduces UserTypeFilter used where bots are not relevant.
libs/wire-api/src/Wire/API/Team/Size.hs Redefines TeamSize as a record with helpers and updated JSON schema.
libs/types-common-journal/proto/TeamEvents.proto Adds separate journal fields for regular/app member counts.
integration/test/Test/Apps.hs Adds integration test validating team size breakdown when apps exist.
integration/test/API/BrigInternal.hs Adds an internal API helper for GET /i/teams/:tid/size.
integration/test/API/Brig.hs Adds a public API helper for GET /teams/:tid/size.
changelog.d/3-bug-fixes/WPB-25136-do-not-count-apps-as-paying-users Adds changelog entry for the fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libs/wire-subsystems/src/Wire/TeamJournal.hs Outdated
Comment thread libs/wire-api/src/Wire/API/Team/Size.hs
Comment thread services/galley/src/Galley/API/Teams.hs
Comment thread libs/wire-api/src/Wire/API/User/Search.hs Outdated
Comment on lines +83 to +86
getTeamSizeImpl cfg tid = do
let indexName = cfg.conn.indexName
countResEither <- embed $ ES.runBH cfg.conn.env $ ES.countByIndex indexName (ES.CountQuery query)
countRes <- either (liftIO . throwIO . IndexLookupError) pure countResEither
pure . TeamSize $ ES.crCount countRes
regulars <- countWith regularQuery
apps <- countWith appQuery
pure $ TeamSize regulars apps -- {regulars, apps}
Comment on lines -557 to -558
(TeamSize sizeBeforeJoin) <- E.getSize tid
ensureNotTooLargeForLegalHold tid (fromIntegral sizeBeforeJoin + 1)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has been moved to addTeamMemberInternal, which is always called right after.

Comment on lines -584 to -586
(TeamSize sizeBeforeJoin) <- E.getSize tid
ensureNotTooLargeForLegalHold tid (fromIntegral sizeBeforeJoin + 1)
(TeamSize sizeBeforeAdd) <- addTeamMemberInternal tid Nothing Nothing nmem
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to addTeamMemberInternal.

newTeamSize <- addTeamMemberInternal tid Nothing Nothing nmem
owners <- E.getBillingTeamMembers tid
Journal.teamUpdate tid (sizeBeforeAdd + 1) owners
Journal.teamUpdate tid newTeamSize owners
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addTeamMemberInternal used to return the old size, but that was only ever used to compute the new size, so now it returns the latter instead.

@fisx fisx force-pushed the WPB-25136-do-not-count-apps-as-paying-users branch from 6979bd7 to a8e3bb9 Compare May 6, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants