Skip to content

[server] remove unused isBillingModeEnabled #13089

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

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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