Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { ReactNode } from 'react'
import { useQueryStates } from 'nuqs'
import { getUpgradeCardCta, type PlanTier, type UpgradeCardId } from '@/lib/billing/client'
import { ANNUAL_DISCOUNT_RATE, CREDIT_TIERS } from '@/lib/billing/constants'
import { formatMonthlyPlanPrice } from '@/lib/billing/plan-helpers'
import { DEMO_HREF, SIGNUP_HREF } from '@/app/(landing)/constants'
import {
PricingCard,
Expand Down Expand Up @@ -54,11 +55,6 @@ function sectionsForColumn(col: number): PricingCardSection[] {
/** The four card columns (Free, Pro, Max, Enterprise) transposed once at module load - the source data is static, so this never needs to be redone per render. */
const SECTIONS_BY_COLUMN = [0, 1, 2, 3].map(sectionsForColumn)

/** Round a dollar amount down to the annual-billing discounted price. */
function annualPrice(dollars: number): number {
return Math.round(dollars * (1 - ANNUAL_DISCOUNT_RATE))
}

/**
* Resolve a card's canonical label and variant from the free-tier matrix. A
* `sales` intent ("Talk to sales") routes to the demo-request form, matching
Expand Down Expand Up @@ -99,8 +95,8 @@ export function PricingPlans({ heading }: PricingPlansProps) {
const setIsAnnual = (next: boolean) => setParams({ billing: next ? 'annual' : 'monthly' })

const discountPct = Math.round(ANNUAL_DISCOUNT_RATE * 100)
const proPrice = isAnnual ? annualPrice(CREDIT_TIERS[0].dollars) : CREDIT_TIERS[0].dollars
const maxPrice = isAnnual ? annualPrice(CREDIT_TIERS[1].dollars) : CREDIT_TIERS[1].dollars
const proPrice = formatMonthlyPlanPrice(CREDIT_TIERS[0].dollars, isAnnual)
const maxPrice = formatMonthlyPlanPrice(CREDIT_TIERS[1].dollars, isAnnual)
const priceSubtext = isAnnual
? 'per user/month, billed annually'
: 'per user/month, billed monthly'
Expand All @@ -127,15 +123,15 @@ export function PricingPlans({ heading }: PricingPlansProps) {
/>
<PricingCard
name='Pro'
price={`$${proPrice}`}
price={proPrice}
discountLabel={discountLabel}
priceSubtext={priceSubtext}
cta={proCta}
sections={SECTIONS_BY_COLUMN[1]}
/>
<PricingCard
name='Max'
price={`$${maxPrice}`}
price={maxPrice}
discountLabel={discountLabel}
priceSubtext={priceSubtext}
cta={maxCta}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const COMPARISON_SECTIONS: ComparisonSection[] = [
false,
`+${formatCredits(PRO_TIER.weeklyRefreshCredits)}/week`,
`+${formatCredits(MAX_TIER.weeklyRefreshCredits)}/week`,
'Custom',
false,
],
},
{
Expand All @@ -113,7 +113,7 @@ export const COMPARISON_SECTIONS: ComparisonSection[] = [
rows: [
{
label: 'Workspaces',
values: ['1', '3', 'Unlimited', 'Unlimited'],
values: ['1', '3 (unlimited on Teams)', '10 (unlimited on Teams)', 'Unlimited'],
},
{
label: 'Invite teammates',
Expand All @@ -140,15 +140,15 @@ export const COMPARISON_SECTIONS: ComparisonSection[] = [
rows: [
{
label: 'Sync executions',
values: ['50', '150', '300', 'Custom'],
values: ['50', '150', '300', '600'],
},
{
label: 'Async executions',
values: ['200', '1,000', '2,500', 'Custom'],
values: ['200', '1,000', '2,500', '5,000'],
},
{
label: 'API endpoint',
values: ['30', '100', '200', 'Custom'],
values: ['30', '100', '200', '500'],
},
],
},
Expand All @@ -157,7 +157,7 @@ export const COMPARISON_SECTIONS: ComparisonSection[] = [
rows: [
{
label: 'Sync timeout',
values: ['5 min', '50 min', '50 min', 'Custom'],
values: ['5 min', '50 min', '50 min', '50 min'],
},
{
label: 'Async timeout',
Expand All @@ -173,12 +173,12 @@ export const COMPARISON_SECTIONS: ComparisonSection[] = [
values: ['5 GB', '50 GB', '500 GB', 'Custom'],
},
{
label: 'Max tables',
values: ['5', '100', '1,000', 'Custom'],
label: 'Tables per workspace',
values: ['5', '100', '1,000', '10,000'],
},
{
label: 'Max rows per table',
values: ['50,000', '100,000', '500,000', 'Custom'],
values: ['50,000', '100,000', '500,000', '1,000,000'],
},
{
label: 'Log retention',
Expand Down
17 changes: 7 additions & 10 deletions apps/sim/app/workspace/[workspaceId]/upgrade/upgrade.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
type UpgradeCardId,
} from '@/lib/billing/client'
import { ANNUAL_DISCOUNT_RATE } from '@/lib/billing/constants'
import { formatMonthlyPlanPrice } from '@/lib/billing/plan-helpers'
import { DEFAULT_UPGRADE_HEADER, UPGRADE_REASON_COPY } from '@/lib/billing/upgrade-reasons'
import { canManageWorkspaceBilling } from '@/lib/billing/workspace-permissions'
import { useWorkspaceHostContext } from '@/app/workspace/[workspaceId]/providers/workspace-host-provider'
Expand Down Expand Up @@ -186,12 +187,8 @@ export function Upgrade({ workspaceId }: UpgradeProps) {
const maxBanner = state.isOnMax ? 'Your plan' : undefined

const discountPct = Math.round(ANNUAL_DISCOUNT_RATE * 100)
const proPrice = state.isAnnual
? Math.round(state.proTier.dollars * (1 - ANNUAL_DISCOUNT_RATE))
: state.proTier.dollars
const maxPrice = state.isAnnual
? Math.round(state.maxTier.dollars * (1 - ANNUAL_DISCOUNT_RATE))
: state.maxTier.dollars
const proPrice = formatMonthlyPlanPrice(state.proTier.dollars, state.isAnnual)
const maxPrice = formatMonthlyPlanPrice(state.maxTier.dollars, state.isAnnual)
const priceSubtext = state.isAnnual
? 'per user/month, billed annually'
: 'per user/month, billed monthly'
Expand Down Expand Up @@ -220,7 +217,7 @@ export function Upgrade({ workspaceId }: UpgradeProps) {
<div className='grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3'>
<UpgradePlanCard
name='Pro'
price={`$${proPrice}`}
price={proPrice}
discountLabel={state.isAnnual ? `${discountPct}% off` : undefined}
priceSubtext={priceSubtext}
segmentLabel='For growing teams'
Expand All @@ -236,7 +233,7 @@ export function Upgrade({ workspaceId }: UpgradeProps) {

<UpgradePlanCard
name='Max'
price={`$${maxPrice}`}
price={maxPrice}
discountLabel={state.isAnnual ? `${discountPct}% off` : undefined}
priceSubtext={priceSubtext}
segmentLabel='For scaling businesses'
Expand Down Expand Up @@ -275,8 +272,8 @@ export function Upgrade({ workspaceId }: UpgradeProps) {

{showAllFeatures && (
<ComparisonTable
proPrice={`$${proPrice}`}
maxPrice={`$${maxPrice}`}
proPrice={proPrice}
maxPrice={maxPrice}
isAnnual={state.isAnnual}
onIsAnnualChange={state.setIsAnnual}
ctas={comparisonCtas}
Expand Down
10 changes: 10 additions & 0 deletions apps/sim/lib/billing/plan-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import type { AnyColumn } from 'drizzle-orm'
import { eq, like, or, type SQL } from 'drizzle-orm'
import {
ANNUAL_DISCOUNT_RATE,
CREDIT_TIERS,
CREDITS_PER_DOLLAR,
DEFAULT_PRO_TIER_COST_LIMIT,
Expand Down Expand Up @@ -107,6 +108,15 @@ export function getPlanTierDollars(plan: string | null | undefined): number {
return 0
}

/**
* A plan's per-seat monthly price as shown to customers: the list price on monthly billing, or the
* annual price spread over twelve months, to the cent ($21.25, not $21).
*/
export function formatMonthlyPlanPrice(monthlyDollars: number, isAnnual: boolean): string {
const price = isAnnual ? monthlyDollars * (1 - ANNUAL_DISCOUNT_RATE) : monthlyDollars
return `$${Number.isInteger(price) ? price : price.toFixed(2)}`
}

/**
* Weekly refresh allowance for a plan, in dollars per seat per week.
*
Expand Down
Loading