Skip to content

Commit

Permalink
[server] remove use of isBillingModeEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
svenefftinge committed Sep 20, 2022
1 parent 85ab504 commit fca1f1a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 28 deletions.
1 change: 0 additions & 1 deletion components/server/ee/src/billing/billing-mode.spec.db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@ class BillingModeSpec {
() =>
new ConfigCatClientMock({
isUsageBasedBillingEnabled: test.config.usageBasedPricingEnabled,
isBillingModeEnabled: true,
}),
);
}),
Expand Down
18 changes: 0 additions & 18 deletions components/server/ee/src/billing/billing-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,11 @@ export class BillingModesImpl implements BillingModes {
}
}

protected async isBillingModeEnabled(subject: { user?: User; team?: Team }): Promise<boolean> {
// This is a double safety-net to smoothen and de-risk the rollout of BillingMode, because it not only affects
// new behavior which is in focus and subject to test anyway (usage-based), but also old behavior (chargebee).
const teams = subject.user ? await this.teamDB.findTeamsByUser(subject.user.id) : undefined;
return await this.configCatClientFactory().getValueAsync("isBillingModeEnabled", false, {
user: subject.user,
teams,
teamId: subject.team?.id,
teamName: subject.team?.name,
});
}

async getBillingModeForUser(user: User, now: Date): Promise<BillingMode> {
if (!this.config.enablePayment) {
// Payment is not enabled. E.g. Self-Hosted.
return { mode: "none" };
}
if (!(await this.isBillingModeEnabled({ user }))) {
return { mode: "chargebee" };
}

// Is Usage Based Billing enabled for this user or not?
const teams = await this.teamDB.findTeamsByUser(user.id);
Expand Down Expand Up @@ -167,9 +152,6 @@ export class BillingModesImpl implements BillingModes {
// Payment is not enabled. E.g. Self-Hosted.
return { mode: "none" };
}
if (!(await this.isBillingModeEnabled({ team }))) {
return { mode: "chargebee" };
}
const now = _now.toISOString();

// Is Usage Based Billing enabled for this team?
Expand Down
9 changes: 0 additions & 9 deletions components/server/ee/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ import { AttributionId } from "@gitpod/gitpod-protocol/lib/attribution";
import { EntitlementService, MayStartWorkspaceResult } from "../../../src/billing/entitlement-service";
import { BillingMode } from "@gitpod/gitpod-protocol/lib/billing-mode";
import { BillingModes } from "../billing/billing-mode";
import { getExperimentsClientForBackend } from "@gitpod/gitpod-protocol/lib/experiments/configcat-server";
import { BillingService } from "../billing/billing-service";
import Stripe from "stripe";
import { UsageServiceDefinition } from "@gitpod/usage-api/lib/usage/v1/usage.pb";
Expand Down Expand Up @@ -2012,14 +2011,6 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
return subscription;
}

protected async isUsageBasedFeatureFlagEnabled(user: User): Promise<boolean> {
const teams = await this.teamDB.findTeamsByUser(user.id);
return await getExperimentsClientForBackend().getValueAsync("isUsageBasedBillingEnabled", false, {
user,
teams: teams,
});
}

protected async ensureChargebeeApiIsAllowed(sub: { user?: User; team?: Team }): Promise<void> {
await this.ensureBillingMode(sub, (m) => m.mode === "chargebee");
}
Expand Down

0 comments on commit fca1f1a

Please sign in to comment.