Skip to content

Commit a8b80cc

Browse files
committed
chore(webapp): drop billing alerts backfill machinery in favor of billing-side migration
1 parent 8862678 commit a8b80cc

4 files changed

Lines changed: 4 additions & 168 deletions

File tree

apps/webapp/app/routes/_app.orgs.$organizationSlug.settings.billing-limits/route.tsx

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ import {
2424
thresholdValuesAreUnique,
2525
} from "~/components/billing/billingAlertsFormat";
2626
import { getSuggestedRecoveryLimitDollars } from "~/components/billing/billingLimitFormat";
27-
import {
28-
billingAlertsLookUnconfigured,
29-
buildDefaultBillingAlerts,
30-
} from "~/services/billingAlertsDefaults.server";
3127
import {
3228
BillingLimitConfigSection,
3329
billingLimitFormSchema,
@@ -130,25 +126,15 @@ export const loader = dashboardLoader(
130126
});
131127
}
132128

133-
const planLimitCents = currentPlan?.v3Subscription?.plan?.limits.includedUsage ?? 500;
134-
135-
const [alertsError, fetchedAlerts] = await tryCatch(getBillingAlerts(organization.id));
136-
let alerts = alertsError ? undefined : fetchedAlerts;
137-
if (
138-
getBillingLimitMode(billingLimit) === "none" &&
139-
(!alerts || billingAlertsLookUnconfigured(alerts))
140-
) {
141-
// Lazily seed default alerts for orgs that have none configured.
142-
const defaults = buildDefaultBillingAlerts();
143-
const [seedError, seeded] = await tryCatch(setBillingAlert(organization.id, defaults));
144-
alerts = seedError || !seeded ? defaults : seeded;
145-
}
146-
if (!alerts) {
129+
const [alertsError, alerts] = await tryCatch(getBillingAlerts(organization.id));
130+
if (alertsError || !alerts) {
147131
throw new Response(null, {
148132
status: 404,
149133
statusText: `Billing alerts error: ${alertsError ?? "not found"}`,
150134
});
151135
}
136+
137+
const planLimitCents = currentPlan?.v3Subscription?.plan?.limits.includedUsage ?? 500;
152138
const alertsResetRequested = getAlertsResetRequested(request);
153139
const resolveSubmitted = getResolveSubmitted(request);
154140
const submittedResumeMode = getSubmittedResumeMode(request);

apps/webapp/app/routes/admin.api.v1.billing-alerts.backfill.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

apps/webapp/app/services/billingAlertsBackfiller.server.ts

Lines changed: 0 additions & 107 deletions
This file was deleted.

apps/webapp/app/services/billingAlertsDefaults.server.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,3 @@ export function buildDefaultBillingAlerts(): UpdateBillingAlertsRequest {
2121
alertLevels: [...DEFAULT_ALERT_THRESHOLD_DOLLARS],
2222
};
2323
}
24-
25-
/**
26-
* Whether alerts look never-configured. When no alert row exists the platform
27-
* returns a default of `{ amount: planIncludedUsage, emails: [], alertLevels: [] }`;
28-
* a deliberately cleared config stores the $1 absolute base amount and/or keeps
29-
* the configured emails.
30-
*/
31-
export function billingAlertsLookUnconfigured(alerts: {
32-
amount: number;
33-
emails: string[];
34-
alertLevels: number[];
35-
}): boolean {
36-
return (
37-
alerts.alertLevels.length === 0 &&
38-
alerts.emails.length === 0 &&
39-
alerts.amount !== ABSOLUTE_ALERT_BASE_CENTS
40-
);
41-
}

0 commit comments

Comments
 (0)