File tree 2 files changed +9
-19
lines changed
2 files changed +9
-19
lines changed Original file line number Diff line number Diff line change @@ -2008,20 +2008,6 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
2008
2008
id : attributionId ,
2009
2009
spendingLimit : this . defaultSpendingLimit ,
2010
2010
} ) ;
2011
-
2012
- // For all team members that didn't explicitly choose yet where their usage should be attributed to,
2013
- // we simplify the UX by automatically attributing their usage to this recently-upgraded team.
2014
- // Note: This default choice can be changed at any time by members in their personal billing settings.
2015
- const members = await this . teamDB . findMembersByTeam ( teamId ) ;
2016
- await Promise . all (
2017
- members . map ( async ( m ) => {
2018
- const u = await this . userDB . findUserById ( m . userId ) ;
2019
- if ( u && ! u . usageAttributionId ) {
2020
- u . usageAttributionId = attributionId ;
2021
- await this . userDB . storeUser ( u ) ;
2022
- }
2023
- } ) ,
2024
- ) ;
2025
2011
} catch ( error ) {
2026
2012
log . error ( `Failed to subscribe team '${ teamId } ' to Stripe` , error ) ;
2027
2013
throw new ResponseError ( ErrorCodes . INTERNAL_SERVER_ERROR , `Failed to subscribe team '${ teamId } ' to Stripe` ) ;
Original file line number Diff line number Diff line change @@ -229,12 +229,16 @@ export class UserService {
229
229
async getWorkspaceUsageAttributionId ( user : User , projectId ?: string ) : Promise < string | undefined > {
230
230
// A. Billing-based attribution
231
231
if ( this . config . enablePayment ) {
232
- if ( ! user . usageAttributionId ) {
233
- // No explicit user attribution ID yet -- attribute all usage to the user by default (regardless of project/team).
234
- return AttributionId . render ( { kind : "user" , userId : user . id } ) ;
232
+ if ( user . usageAttributionId ) {
233
+ // Return the user's explicit attribution ID.
234
+ // TODO(janx): Throw error if selected attribution ID is no longer valid (e.g. user left team, team deleted, team cancelled)
235
+ return user . usageAttributionId ;
235
236
}
236
- // Return the user's explicit attribution ID.
237
- return user . usageAttributionId ;
237
+ // TODO(janx):
238
+ // - If single team with Usage-Based billing enabled, auto-attribute to that team
239
+ // - If multiple teams with Usage-Based, throw error to prompt for explicit user choice
240
+ // No explicit user attribution ID yet -- attribute all usage to the user by default (regardless of project/team).
241
+ return AttributionId . render ( { kind : "user" , userId : user . id } ) ;
238
242
}
239
243
240
244
// B. Project-based attribution
You can’t perform that action at this time.
0 commit comments