Skip to content

Introduce BillingModes #11601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed

Introduce BillingModes #11601

wants to merge 4 commits into from

Conversation

geropl
Copy link
Member

@geropl geropl commented Jul 25, 2022

Description

ToDo

  1. Use getBillingModeUser/Team to show/hide controls/UI (Ideally replace getShowPaymentUI!)
    • block all Chargebee-based UI once switched! (except: old invoices: GitpodService.isChargebeeCustomer should help here)
  2. Block Chargebee API
    • block all Chargebee-based API once switched! (except: old invoices. GitpodService.isChargebeeCustomer should help here)
  3. Implement (and decide details of) EntitlementServiceUBB

Related Issue(s)

Fixes #

How to test

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

): Promise<MayStartWorkspaceResult> {
const billingMode = await this.billingModes.getBillingModeForUser(user);
switch (billingMode.mode) {
case "none":
Copy link
Member

Choose a reason for hiding this comment

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

For my own (and future reviewers) sanity, The mode of none only gets set for Self-hosted, bacause it depends on the paymentEnabled config to be false.

Comment on lines 33 to 70
const isUsageBasedBillingEnabled = await getExperimentsClientForBackend().getValueAsync(
"isUsageBasedBillingEnabled",
false,
{
user,
},
);
Copy link
Contributor

@jankeromnes jankeromnes Jul 28, 2022

Choose a reason for hiding this comment

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

Wait, isn't UBB flag currently controlled by whether you're part of the Gitpod team or not? In this case I believe you may need to also pass along the teams of the user.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's up to discussion. See comment below.


// UBB enabled?
if (!isUsageBasedBillingEnabled) {
// No Chargebee subscription, and UBB is not enabled: CB free tier?
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the question mark? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it make sense for the two of us to discuss the decision tree/scope of the decision made here. 👍

Comment on lines 83 to 128
const isUsageBasedBillingEnabled = await getExperimentsClientForBackend().getValueAsync(
"isUsageBasedBillingEnabled",
false,
{
teamId: team.id,
teamName: team.name,
},
);
Copy link
Contributor

@jankeromnes jankeromnes Jul 28, 2022

Choose a reason for hiding this comment

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

If I'm not mistaken, we don't yet have anything like this in ConfigCat -- we only enable UBB for users who happen to be part of the Gitpod team, and then everywhere in the UI for them (i.e. for all their teams).

But maybe it could be a good idea to selectively enable UBB for a specific team, and only in that team's UI 👍 we'd just need to code this into ConfigCat.

Copy link
Member Author

Choose a reason for hiding this comment

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

But maybe it could be a good idea to selectively enable UBB for a specific team, and only in that team's UI +1 we'd just need to code this into ConfigCat.

That was the intend. teamId and team_name are already available in ConfigCat. 👍


protected async ensureBillingMode(
sub: { user?: User; team?: Team },
pred: (m: BillingMode) => boolean,
Copy link
Contributor

Choose a reason for hiding this comment

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

What does pred mean? 👀

Copy link
Member Author

Choose a reason for hiding this comment

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

Predicate. Sorry, was a tad late when I wrote this 😛 Will improve.

@jankeromnes
Copy link
Contributor

jankeromnes commented Jul 28, 2022

Many thanks for implementing this!

This change makes me very nervous, because we're introducing so much complexity:

  • Complicated billing modes with both a "mode" and a "tier" (would ideally prefer just one parameter / moving part)
  • Feature flags, which get queried in multiple different ways throughout the code (with/without teams, with/without teamId and teamName, different APIs in client and server, etc) -- I'm keenly looking forward to deleting all the inconsistent and risky feature-flag logic once UBB is shipped and everyone uses it (</wishful-thinking>) -- meanwhile, I'm almost certain we'll see bugs where some users or teams get feature flag behaviors we don't expect 😬

However, we are in a complicated situation (with the transition from Chargebee to UBB with many moving parts), and your solution looks like it can work. So, many thanks for powering through this. 💯

I would love to test this somehow. Could you please get this into a testable state (and complete the "TODOs"), and then provide "How to test" instructions?

@geropl
Copy link
Member Author

geropl commented Aug 1, 2022

However, we are in a complicated situation (with the transition from Chargebee to UBB with many moving parts), and your solution looks like it can work. So, many thanks for powering through this. 100

💯

I would love to test this somehow. Could you please get this into a testable state (and complete the "TODOs"), and then provide "How to test" instructions?

It might also make sense to introduce this in steps. Especially the parts that affect current behaviors should be rolled out selectively so we do not break current users! Happy to brainstorm on this.

@geropl geropl changed the title BillingModes and EntitlementService Introduce BillingModes Aug 2, 2022
@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-gpl-entitlement-svc.3 because the annotations in the pull request description changed
(with .werft/ from main)

@geropl geropl force-pushed the gpl/entitlement-svc branch from 080d381 to 9b1097f Compare August 2, 2022 15:51
@geropl
Copy link
Member Author

geropl commented Aug 2, 2022

Closing this one as it's replaced by #11812 and it's successors.

@geropl geropl closed this Aug 2, 2022
@geropl geropl deleted the gpl/entitlement-svc branch August 4, 2022 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants