The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(studio): add plan-change panel presentation experiment (#49534)
Mert YEREKAPANd11705ded016
diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCard.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCard.tsxnew file mode 100644index 00000000000..406e58cbd54--- /dev/null+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCard.tsx@@ -0,0 +1,377 @@+import { isArray } from 'lodash'+import { Check, X } from 'lucide-react'+import type { PricingInformation } from 'shared-data'+import { Button, cn } from 'ui'+import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'++import type { GapFeature, PlanPresentationVariant } from './plan-presentation'+import { FREE_PLAN_GAPS, PRO_PLAN_GAPS } from './plan-presentation'+import { ButtonTooltip } from '@/components/ui/ButtonTooltip'+import { RequestUpgradeToBillingOwners } from '@/components/ui/RequestUpgradeToBillingOwners'+import { MANAGED_BY } from '@/lib/constants/infrastructure'+import { formatCurrency } from '@/lib/helpers'++const GAPS_BY_PLAN_ID: Record<string, GapFeature[]> = {+ tier_free: FREE_PLAN_GAPS,+ tier_pro: PRO_PLAN_GAPS,+}++export interface PlanCardProps {+ plan: PricingInformation+ price: number+ isCurrentPlan: boolean+ isDowngradeOption: boolean+ isLoadingPlans: boolean+ canUpdateSubscription: boolean+ isPartnerBilledOrganization: boolean+ hasOrioleProjects: boolean+ currentSubscriptionPlanId: string | undefined+ managedBy: string | undefined+ shouldHighlight: boolean+ variant: PlanPresentationVariant+ onSelectTier: () => void+ onTrackCtaClick: () => void+}++export function PlanCard({+ plan,+ price,+ isCurrentPlan,+ isDowngradeOption,+ isLoadingPlans,+ canUpdateSubscription,+ isPartnerBilledOrganization,+ hasOrioleProjects,+ currentSubscriptionPlanId,+ managedBy,+ shouldHighlight,+ variant,+ onSelectTier,+ onTrackCtaClick,+}: PlanCardProps) {+ const isParity = variant === 'parity' || variant === 'gaps'+ const features = plan.features+ const footer = plan.footer++ const gaps: GapFeature[] = variant === 'gaps' ? (GAPS_BY_PLAN_ID[plan.id] ?? []) : []++ const ctaButton = isCurrentPlan ? (+ <Button block disabled variant="default">+ Current plan+ </Button>+ ) : !canUpdateSubscription &&+ !isDowngradeOption &&+ (plan.name === 'Pro' || plan.name === 'Team') ? (+ <RequestUpgradeToBillingOwners block plan={plan.name} />+ ) : (+ <ButtonTooltip+ block+ variant={isDowngradeOption ? 'default' : 'primary'}+ disabled={+ (!canUpdateSubscription && isDowngradeOption) ||+ currentSubscriptionPlanId === 'enterprise' ||+ currentSubscriptionPlanId === 'platform' ||+ (isPartnerBilledOrganization && plan.id !== 'tier_free') ||+ managedBy === MANAGED_BY.AWS_MARKETPLACE ||+ hasOrioleProjects+ }+ onClick={() => {+ onSelectTier()+ onTrackCtaClick()+ }}+ tooltip={{+ content: {+ side: 'bottom' as const,+ className: hasOrioleProjects ? 'w-96 text-center' : '',+ text:+ !canUpdateSubscription && isDowngradeOption+ ? "You need additional permissions to change your organization's plan"+ : currentSubscriptionPlanId === 'enterprise' ||+ currentSubscriptionPlanId === 'platform'+ ? 'Reach out to us via support to update your plan'+ : hasOrioleProjects+ ? 'Your organization has projects that are using the OrioleDB extension which is only available on the Free plan. Remove all OrioleDB projects before changing your plan.'+ : managedBy === MANAGED_BY.AWS_MARKETPLACE+ ? 'You cannot change the plan for an organization managed by AWS Marketplace'+ : undefined,+ },+ }}+ >+ {isDowngradeOption ? 'Downgrade' : 'Upgrade'} to {plan.name}+ </ButtonTooltip>+ )++ if (!isParity) {+ return (+ <ControlCard+ plan={plan}+ price={price}+ isCurrentPlan={isCurrentPlan}+ isLoadingPlans={isLoadingPlans}+ shouldHighlight={shouldHighlight}+ features={features}+ footer={footer}+ ctaButton={ctaButton}+ />+ )+ }++ return (+ <ParityCard+ plan={plan}+ price={price}+ isCurrentPlan={isCurrentPlan}+ isLoadingPlans={isLoadingPlans}+ shouldHighlight={shouldHighlight}+ features={features}+ footer={footer}+ gaps={gaps}+ ctaButton={ctaButton}+ />+ )+}++function ControlCard({+ plan,+ price,+ isCurrentPlan,+ isLoadingPlans,+ shouldHighlight,+ features,+ footer,+ ctaButton,+}: {+ plan: PricingInformation+ price: number+ isCurrentPlan: boolean+ isLoadingPlans: boolean+ shouldHighlight: boolean+ features: (string | string[])[]+ footer: string | undefined+ ctaButton: React.ReactNode+}) {+ return (+ <div+ className={cn(+ 'px-4 py-4 flex flex-col items-start justify-between',+ 'border rounded-md col-span-12 md:col-span-4 bg-surface-200',+ shouldHighlight &&+ 'ring-4 ring-brand animate-[pulse_1.5s_ease-in-out_1] motion-reduce:animate-none shadow-md shadow-brand/40'+ )}+ >+ <div className="w-full">+ <div className="flex items-center space-x-2">+ <p className="text-brand-link text-sm uppercase">{plan.name}</p>+ {isCurrentPlan ? (+ <div className="text-xs bg-surface-300 text-foreground-light rounded-sm px-2 py-0.5">+ Current plan+ </div>+ ) : plan.nameBadge ? (+ <div className="text-xs bg-brand-300 dark:bg-brand-400 text-brand-600 rounded-sm px-2 py-0.5">+ {plan.nameBadge}+ </div>+ ) : null}+ </div>+ <div className="mt-4 flex items-center space-x-1 mb-4">+ {(price ?? 0) > 0 && <p className="text-foreground-light text-sm">From</p>}+ {isLoadingPlans ? (+ <div className="h-[28px] flex items-center justify-center">+ <ShimmeringLoader className="w-[30px] h-[24px]" />+ </div>+ ) : (+ <p className="text-foreground text-lg" translate="no">+ {formatCurrency(price)}+ </p>+ )}+ <p className="text-foreground-light text-sm">{plan.costUnit}</p>+ </div>+ {ctaButton}++ <div className="border-t my-4" />++ <ul role="list">+ {features.map((feature) => (+ <li key={typeof feature === 'string' ? feature : feature[0]} className="flex py-2">+ <div className="w-[12px]">+ <Check+ className="h-3 w-3 text-brand translate-y-[2.5px]"+ aria-hidden="true"+ strokeWidth={3}+ />+ </div>+ <div>+ <p className="ml-3 text-xs text-foreground-light">+ {typeof feature === 'string' ? feature : feature[0]}+ </p>+ {isArray(feature) && (+ <p className="ml-3 text-xs text-foreground-lighter">{feature[1]}</p>+ )}+ </div>+ </li>+ ))}+ </ul>+ </div>++ {footer && (+ <div className="border-t pt-4 mt-4">+ <p className="text-foreground-light text-xs">{footer}</p>+ </div>+ )}+ </div>+ )+}++function ParityCard({+ plan,+ price,+ isCurrentPlan,+ isLoadingPlans,+ shouldHighlight,+ features,+ footer,+ gaps,+ ctaButton,+}: {+ plan: PricingInformation+ price: number+ isCurrentPlan: boolean+ isLoadingPlans: boolean+ shouldHighlight: boolean+ features: (string | string[])[]+ footer: string | undefined+ gaps: GapFeature[]+ ctaButton: React.ReactNode+}) {+ return (+ <div+ className={cn(+ 'flex flex-col items-start justify-between',+ 'border rounded-md col-span-12 md:col-span-4 bg-surface-200',+ shouldHighlight &&+ 'ring-4 ring-brand animate-[pulse_1.5s_ease-in-out_1] motion-reduce:animate-none shadow-md shadow-brand/40'+ )}+ >+ <div className="w-full px-4 pt-4">+ <div className="flex items-center gap-2">+ <div className="flex items-center gap-2 pb-2">+ <h3 className="text-foreground text-xl font-normal uppercase font-mono">{plan.name}</h3>+ {isCurrentPlan ? (+ <span className="text-xs bg-surface-300 text-foreground-light rounded-sm px-2 py-0.5">+ Current plan+ </span>+ ) : plan.nameBadge ? (+ <span className="bg-foreground-light text-background rounded-md py-0.5 px-2 text-[13px] leading-4">+ {plan.nameBadge}+ </span>+ ) : null}+ </div>+ </div>++ <p className="text-foreground-light text-[13px] leading-4 mb-4 min-h-12 line-clamp-3">+ {plan.description}+ </p>++ {ctaButton}++ <div className="border-t my-4" />++ <div className="flex items-end gap-1 pb-4">+ <div>+ <p+ className={cn(+ 'text-foreground-lighter text-[13px] leading-4',+ (price ?? 0) <= 0 && 'invisible'+ )}+ >+ From+ </p>+ <div className="flex items-end">+ {isLoadingPlans ? (+ <div className="h-[40px] flex items-center justify-center">+ <ShimmeringLoader className="w-[60px] h-[32px]" />+ </div>+ ) : (+ <p className="text-foreground text-3xl font-mono" translate="no">+ {formatCurrency(price)}+ </p>+ )}+ <p className="text-foreground-lighter mb-0.5 ml-1 text-[13px] leading-4">+ {plan.costUnit}+ </p>+ </div>+ </div>+ </div>+ </div>++ <div className="w-full flex-1 flex flex-col px-4 pb-4">+ {plan.preface && (+ <p className="text-foreground-lighter text-[13px] mt-2 mb-4">{plan.preface}</p>+ )}+ <ul className="text-[13px] flex-1">+ {features.map((feature) => (+ <li+ key={typeof feature === 'string' ? feature : feature[0]}+ className="flex flex-col py-2 first:mt-0"+ >+ <div className="flex items-center">+ <div className="flex w-5">+ <Check className="h-4 w-4 text-brand" aria-hidden="true" strokeWidth={3} />+ </div>+ <span className="text-foreground">+ {typeof feature === 'string' ? feature : feature[0]}+ </span>+ </div>+ {typeof feature !== 'string' && isArray(feature) && (+ <p className="ml-5 text-foreground-lighter">{feature[1]}</p>+ )}+ </li>+ ))}+ </ul>++ {gaps.length > 0 && (+ <>+ <div className="border-t my-3" />+ <p className="text-foreground-muted text-[13px] mb-3">+ {gaps.some((g) => g.type === 'lesser') ? 'Plan limits' : 'Not included'}+ </p>+ <ul className="text-[13px]">+ {gaps.map((gap) => (+ <li key={gap.label} className="flex items-center py-1.5">+ {gap.type === 'missing' ? (+ <>+ <div className="flex w-5">+ <X+ className="h-4 w-4 text-foreground-muted"+ aria-hidden="true"+ strokeWidth={2}+ />+ </div>+ <span className="text-foreground-muted">{gap.label}</span>+ </>+ ) : (+ <>+ <div className="flex w-5">+ <Check+ className="h-4 w-4 text-foreground-muted"+ aria-hidden="true"+ strokeWidth={2}+ />+ </div>+ <span className="text-foreground-muted">{gap.label}</span>+ </>+ )}+ </li>+ ))}+ </ul>+ </>+ )}++ {footer && (+ <div className="border-t pt-4 mt-auto">+ <p className="text-foreground-lighter text-[13px] whitespace-pre-wrap">{footer}</p>+ </div>+ )}+ </div>+ </div>+ )+}diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCards.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCards.tsxnew file mode 100644index 00000000000..2ff1fa49304--- /dev/null+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCards.tsx@@ -0,0 +1,92 @@+import { useRouter } from 'next/router'+import { plans as subscriptionsPlans } from 'shared-data/plans'++import { EnterpriseCard } from './EnterpriseCard'+import { isPlanChangeEligible, usePlanPresentationExperiment } from './plan-presentation'+import { PlanCard } from './PlanCard'+import { getPlanChangeType } from '@/components/interfaces/Billing/Subscription/Subscription.utils'+import type { OrgPlan, PlanId } from '@/data/subscriptions/types'+import { useTrack } from '@/lib/telemetry/track'+import type { Organization } from '@/types/base'++export interface PlanCardsProps {+ availablePlans: OrgPlan[]+ isLoadingPlans: boolean+ currentSubscriptionPlanId: PlanId | undefined+ currentSubscriptionPlanName: string | undefined+ canUpdateSubscription: boolean+ isPartnerBilledOrganization: boolean+ hasOrioleProjects: boolean+ selectedOrganization: Organization | undefined+ onSelectTier: (tier: 'tier_free' | 'tier_pro' | 'tier_team') => void+}++export function PlanCards({+ availablePlans,+ isLoadingPlans,+ currentSubscriptionPlanId,+ currentSubscriptionPlanName,+ canUpdateSubscription,+ isPartnerBilledOrganization,+ hasOrioleProjects,+ selectedOrganization,+ onSelectTier,+}: PlanCardsProps) {+ const router = useRouter()+ const track = useTrack()++ const eligible = isPlanChangeEligible({+ managedBy: selectedOrganization?.managed_by,+ billingPartner: selectedOrganization?.billing_partner,+ currentPlanId: currentSubscriptionPlanId,+ canUpdateSubscription,+ })++ const variant = usePlanPresentationExperiment({ eligible })++ return (+ <div className="py-6 grid grid-cols-12 gap-3">+ {subscriptionsPlans.map((plan) => {+ const planMeta = availablePlans.find((p) => p.id === plan.id.split('tier_')[1])+ const price = planMeta?.price ?? 0+ const isDowngradeOption =+ getPlanChangeType(currentSubscriptionPlanId, plan?.planId) === 'downgrade'+ const isCurrentPlan = planMeta?.id === currentSubscriptionPlanId++ const source = Array.isArray(router.query.source)+ ? router.query.source[0]+ : router.query.source+ const shouldHighlight = source === 'log-drains-empty-state' && plan.id === 'tier_pro'++ if (plan.id === 'tier_enterprise') {+ return <EnterpriseCard key={plan.id} plan={plan} isCurrentPlan={isCurrentPlan} />+ }++ return (+ <PlanCard+ key={plan.id}+ plan={plan}+ price={price}+ isCurrentPlan={isCurrentPlan}+ isDowngradeOption={isDowngradeOption}+ isLoadingPlans={isLoadingPlans}+ canUpdateSubscription={canUpdateSubscription}+ isPartnerBilledOrganization={isPartnerBilledOrganization}+ hasOrioleProjects={hasOrioleProjects}+ currentSubscriptionPlanId={currentSubscriptionPlanId}+ managedBy={selectedOrganization?.managed_by}+ shouldHighlight={shouldHighlight}+ variant={variant}+ onSelectTier={() => onSelectTier(plan.id as 'tier_free' | 'tier_pro' | 'tier_team')}+ onTrackCtaClick={() =>+ track('studio_pricing_plan_cta_clicked', {+ selectedPlan: plan.name,+ currentPlan: currentSubscriptionPlanName,+ })+ }+ />+ )+ })}+ </div>+ )+}diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.test.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.test.tsxindex 7cb5fb3fd3a..30334872ecd 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.test.tsx+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.test.tsx@@ -8,6 +8,7 @@ import { createMockOrganization, render } from '@/tests/helpers'const mockSelectedOrganization = vi.hoisted(() => vi.fn())const mockPush = vi.hoisted(() => vi.fn())const mockPartnerManagedResource = vi.hoisted(() => vi.fn())+const mockUsePHFlag = vi.hoisted(() => vi.fn())vi.mock('common', async (importOriginal) => {const original = (await importOriginal()) as typeof import('common')@@ -27,8 +28,26 @@ vi.mock('next/router', () => ({vi.mock('shared-data/plans', () => ({plans: [- { id: 'tier_free', planId: 'free', name: 'Free', costUnit: '/ month', features: [] },- { id: 'tier_pro', planId: 'pro', name: 'Pro', costUnit: '/ month', features: [] },+ {+ id: 'tier_free',+ planId: 'free',+ name: 'Free',+ costUnit: '/ month',+ features: ['Unlimited API requests'],+ description: 'Perfect for passion projects & simple websites.',+ preface: 'Get started with:',+ footer: 'Free projects are paused after 1 week of inactivity. Limit of 2 active projects.',+ },+ {+ id: 'tier_pro',+ planId: 'pro',+ name: 'Pro',+ nameBadge: 'Most Popular',+ costUnit: '/ month',+ features: ['Email support'],+ description: 'For production applications with the power to scale.',+ preface: 'Everything in the Free Plan, plus:',+ },],}))@@ -117,9 +136,18 @@ vi.mock('./SubscriptionPlanUpdateDialog', () => ({SubscriptionPlanUpdateDialog: () => null,}))+vi.mock('@/hooks/ui/useFlag', () => ({+ usePHFlag: mockUsePHFlag,+}))++vi.mock('@/hooks/misc/useTrackExperimentExposure', () => ({+ useTrackExperimentExposure: vi.fn(),+}))+describe('PlanUpdateSidePanel', () => {beforeEach(() => {vi.clearAllMocks()+ mockUsePHFlag.mockReturnValue('control')mockSelectedOrganization.mockReturnValue(createMockOrganization({slug: 'stripe-org',@@ -183,4 +211,76 @@ describe('PlanUpdateSidePanel', () => {expect(screen.getByTestId('partner-managed-resource')).toBeInTheDocument()})++ describe('parity variant', () => {+ beforeEach(() => {+ mockUsePHFlag.mockReturnValue('parity')+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({ slug: 'test-org', billing_partner: null })+ )+ })++ it('renders plan description', () => {+ render(<PlanUpdateSidePanel />)+ expect(+ screen.getByText('Perfect for passion projects & simple websites.')+ ).toBeInTheDocument()+ })++ it('renders preface line', () => {+ render(<PlanUpdateSidePanel />)+ expect(screen.getByText('Everything in the Free Plan, plus:')).toBeInTheDocument()+ })+ })++ describe('gaps variant', () => {+ beforeEach(() => {+ mockUsePHFlag.mockReturnValue('gaps')+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({ slug: 'test-org', billing_partner: null })+ )+ })++ it('renders gap rows on the Free plan', () => {+ render(<PlanUpdateSidePanel />)+ expect(screen.getByText('Daily backups')).toBeInTheDocument()+ // "Email support" appears twice: once as a Pro plan feature (✓), once as a Free plan gap (✗)+ expect(screen.getAllByText('Email support')).toHaveLength(2)+ })++ it('shows log retention as a lesser value, not a missing feature', () => {+ render(<PlanUpdateSidePanel />)+ expect(screen.getByText('1-day log retention')).toBeInTheDocument()+ })++ it('renders the gap section heading on Free and Pro cards', () => {+ render(<PlanUpdateSidePanel />)+ // Free has a `lesser` item, so its heading is "Plan limits"; Pro has only `missing` items → "Not included"+ expect(screen.getByText('Plan limits')).toBeInTheDocument()+ expect(screen.getByText('Not included')).toBeInTheDocument()+ })+ })++ describe('control variant', () => {+ beforeEach(() => {+ mockUsePHFlag.mockReturnValue('control')+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({ slug: 'test-org', billing_partner: null })+ )+ })++ it('does not render preface or description', () => {+ render(<PlanUpdateSidePanel />)+ expect(screen.queryByText('Everything in the Free Plan, plus:')).not.toBeInTheDocument()+ expect(+ screen.queryByText('Perfect for passion projects & simple websites.')+ ).not.toBeInTheDocument()+ })++ it('does not render gap rows', () => {+ render(<PlanUpdateSidePanel />)+ expect(screen.queryByText('Not included')).not.toBeInTheDocument()+ expect(screen.queryByText('Plan limits')).not.toBeInTheDocument()+ })+ })})diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsxindex d3bd6f55b24..677c59cdd60 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx@@ -2,23 +2,18 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'import { useDebounce } from '@uidotdev/usehooks'import { useParams } from 'common'import { StudioPricingSidePanelOpenedEvent } from 'common/telemetry-constants'-import { isArray } from 'lodash'-import { Check, ExternalLink } from 'lucide-react'+import { ExternalLink } from 'lucide-react'import { useRouter } from 'next/router'import { useCallback, useEffect, useEffectEvent, useMemo, useRef, useState } from 'react'import { plans as subscriptionsPlans } from 'shared-data/plans'-import { Button, cn, SidePanel } from 'ui'-import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'+import { Button, SidePanel } from 'ui'import { CancellationFlow } from './CancellationFlow'-import { EnterpriseCard } from './EnterpriseCard'+import { PlanCards } from './PlanCards'import { SubscriptionPlanUpdateDialog } from './SubscriptionPlanUpdateDialog'import UpgradeSurveyModal from './UpgradeModal'import { STRIPE_PROJECTS_DOCS_URL } from '@/components/interfaces/Billing/Payment/PaymentMethods/StripePaymentConnection'-import { getPlanChangeType } from '@/components/interfaces/Billing/Subscription/Subscription.utils'-import { ButtonTooltip } from '@/components/ui/ButtonTooltip'import PartnerManagedResource from '@/components/ui/PartnerManagedResource'-import { RequestUpgradeToBillingOwners } from '@/components/ui/RequestUpgradeToBillingOwners'import { isPartnerBillingOrganization } from '@/data/organizations/managed-by-utils'import { useOrganizationBillingSubscriptionPreview } from '@/data/organizations/organization-billing-subscription-preview'import { useOrganizationQuery } from '@/data/organizations/organization-query'@@ -30,7 +25,6 @@ import type { OrgPlan } from '@/data/subscriptions/types'import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'import { MANAGED_BY } from '@/lib/constants/infrastructure'-import { formatCurrency } from '@/lib/helpers'import { useTrack } from '@/lib/telemetry/track'import { useOrgSettingsPageStateSnapshot } from '@/state/organization-settings'import { Organization } from '@/types/base'@@ -225,149 +219,17 @@ export const PlanUpdateSidePanel = () => {/>) : null)}<SidePanel.Content>- <div className="py-6 grid grid-cols-12 gap-3">- {subscriptionsPlans.map((plan) => {- const planMeta = availablePlans.find((p) => p.id === plan.id.split('tier_')[1])- const price = planMeta?.price ?? 0- const isDowngradeOption =- getPlanChangeType(subscription?.plan.id, plan?.planId) === 'downgrade'- const isCurrentPlan = planMeta?.id === subscription?.plan?.id- const features = plan.features- const footer = plan.footer-- const source = Array.isArray(router.query.source)- ? router.query.source[0]- : router.query.source- // TODO this panel should allow direct configuration of the highlighting rather than indirectly via the source param- const shouldHighlight = source === 'log-drains-empty-state' && plan.id === 'tier_pro'-- if (plan.id === 'tier_enterprise') {- return <EnterpriseCard key={plan.id} plan={plan} isCurrentPlan={isCurrentPlan} />- }-- return (- <div- key={plan.id}- className={cn(- 'px-4 py-4 flex flex-col items-start justify-between',- 'border rounded-md col-span-12 md:col-span-4 bg-surface-200',- shouldHighlight &&- 'ring-4 ring-brand animate-[pulse_1.5s_ease-in-out_1] shadow-md shadow-brand/40'- )}- >- <div className="w-full">- <div className="flex items-center space-x-2">- <p className="text-brand-link text-sm uppercase">{plan.name}</p>- {isCurrentPlan ? (- <div className="text-xs bg-surface-300 text-foreground-light rounded-sm px-2 py-0.5">- Current plan- </div>- ) : plan.nameBadge ? (- <div className="text-xs bg-brand-300 dark:bg-brand-400 text-brand-600 rounded-sm px-2 py-0.5">- {plan.nameBadge}- </div>- ) : null}- </div>- <div className="mt-4 flex items-center space-x-1 mb-4">- {(price ?? 0) > 0 && <p className="text-foreground-light text-sm">From</p>}- {isLoadingPlans ? (- <div className="h-[28px] flex items-center justify-center">- <ShimmeringLoader className="w-[30px] h-[24px]" />- </div>- ) : (- <p className="text-foreground text-lg" translate="no">- {formatCurrency(price)}- </p>- )}- <p className="text-foreground-light text-sm">{plan.costUnit}</p>- </div>- {isCurrentPlan ? (- <Button block disabled variant="default">- Current plan- </Button>- ) : !canUpdateSubscription && !isDowngradeOption ? (- <RequestUpgradeToBillingOwners block plan={plan.name as 'Pro' | 'Team'} />- ) : (- <ButtonTooltip- block- variant={isDowngradeOption ? 'default' : 'primary'}- disabled={- (!canUpdateSubscription && isDowngradeOption) ||- subscription?.plan?.id === 'enterprise' ||- subscription?.plan?.id === 'platform' ||- // Downgrades to free are still allowed through the dashboard given we have much better control about showing customers the impact + any possible issues with downgrading to free- (isPartnerBilledOrganization && plan.id !== 'tier_free') ||- // Orgs managed by AWS marketplace are not allowed to change the plan- selectedOrganization?.managed_by === MANAGED_BY.AWS_MARKETPLACE ||- hasOrioleProjects- }- onClick={() => {- setSelectedTier(plan.id as 'tier_free' | 'tier_pro' | 'tier_team')- track('studio_pricing_plan_cta_clicked', {- selectedPlan: plan.name,- currentPlan: subscription?.plan?.name,- })- }}- tooltip={{- content: {- side: 'bottom',- className: hasOrioleProjects ? 'w-96 text-center' : '',- text:- !canUpdateSubscription && isDowngradeOption- ? "You need additional permissions to change your organization's plan"- : subscription?.plan?.id === 'enterprise' ||- subscription?.plan?.id === 'platform'- ? 'Reach out to us via support to update your plan'- : hasOrioleProjects- ? 'Your organization has projects that are using the OrioleDB extension which is only available on the Free plan. Remove all OrioleDB projects before changing your plan.'- : selectedOrganization?.managed_by ===- MANAGED_BY.AWS_MARKETPLACE- ? 'You cannot change the plan for an organization managed by AWS Marketplace'- : undefined,- },- }}- >- {isDowngradeOption ? 'Downgrade' : 'Upgrade'} to {plan.name}- </ButtonTooltip>- )}-- <div className="border-t my-4" />-- <ul role="list">- {features.map((feature) => (- <li- key={typeof feature === 'string' ? feature : feature[0]}- className="flex py-2"- >- <div className="w-[12px]">- <Check- className="h-3 w-3 text-brand translate-y-[2.5px]"- aria-hidden="true"- strokeWidth={3}- />- </div>- <div>- <p className="ml-3 text-xs text-foreground-light">- {typeof feature === 'string' ? feature : feature[0]}- </p>- {isArray(feature) && (- <p className="ml-3 text-xs text-foreground-lighter">{feature[1]}</p>- )}- </div>- </li>- ))}- </ul>- </div>-- {footer && (- <div className="border-t pt-4 mt-4">- <p className="text-foreground-light text-xs">{footer}</p>- </div>- )}- </div>- )- })}- </div>+ <PlanCards+ availablePlans={availablePlans}+ isLoadingPlans={isLoadingPlans}+ currentSubscriptionPlanId={subscription?.plan?.id}+ currentSubscriptionPlanName={subscription?.plan?.name}+ canUpdateSubscription={canUpdateSubscription}+ isPartnerBilledOrganization={isPartnerBilledOrganization}+ hasOrioleProjects={hasOrioleProjects}+ selectedOrganization={selectedOrganization}+ onSelectTier={setSelectedTier}+ /></SidePanel.Content></SidePanel>diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/plan-presentation.test.ts b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/plan-presentation.test.tsnew file mode 100644index 00000000000..55140e9c581--- /dev/null+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/plan-presentation.test.ts@@ -0,0 +1,65 @@+import { describe, expect, it } from 'vitest'++import { FREE_PLAN_GAPS, isPlanChangeEligible, PRO_PLAN_GAPS } from './plan-presentation'+import { MANAGED_BY } from '@/lib/constants/infrastructure'++describe('isPlanChangeEligible', () => {+ const baseArgs = {+ managedBy: 'supabase' as const,+ billingPartner: null as string | null | undefined,+ currentPlanId: 'free',+ canUpdateSubscription: true,+ }++ it('returns true for a standard free-plan org with billing permissions', () => {+ expect(isPlanChangeEligible(baseArgs)).toBe(true)+ })++ it('returns false for Stripe-managed orgs', () => {+ expect(isPlanChangeEligible({ ...baseArgs, managedBy: MANAGED_BY.STRIPE_PROJECTS })).toBe(false)+ })++ it('returns false for AWS Marketplace orgs', () => {+ expect(isPlanChangeEligible({ ...baseArgs, managedBy: MANAGED_BY.AWS_MARKETPLACE })).toBe(false)+ })++ it('returns false for partner-billed orgs', () => {+ expect(isPlanChangeEligible({ ...baseArgs, billingPartner: 'aws_marketplace' })).toBe(false)+ })++ it('returns false for enterprise plan', () => {+ expect(isPlanChangeEligible({ ...baseArgs, currentPlanId: 'enterprise' })).toBe(false)+ })++ it('returns false for platform plan', () => {+ expect(isPlanChangeEligible({ ...baseArgs, currentPlanId: 'platform' })).toBe(false)+ })++ it('returns false when user cannot update subscription', () => {+ expect(isPlanChangeEligible({ ...baseArgs, canUpdateSubscription: false })).toBe(false)+ })++ it('returns true for pro-plan org with billing permissions', () => {+ expect(isPlanChangeEligible({ ...baseArgs, currentPlanId: 'pro' })).toBe(true)+ })+})++describe('gap lists', () => {+ it('FREE_PLAN_GAPS includes backups and email support as missing', () => {+ const missing = FREE_PLAN_GAPS.filter((g) => g.type === 'missing')+ expect(missing.map((g) => g.label)).toContain('Daily backups')+ expect(missing.map((g) => g.label)).toContain('Email support')+ })++ it('FREE_PLAN_GAPS shows log retention as lesser, not missing', () => {+ const logRetention = FREE_PLAN_GAPS.find((g) => g.label.includes('log retention'))+ expect(logRetention).toBeDefined()+ expect(logRetention!.type).toBe('lesser')+ })++ it('PRO_PLAN_GAPS includes SOC2 and SSO as missing', () => {+ const missing = PRO_PLAN_GAPS.filter((g) => g.type === 'missing')+ expect(missing.map((g) => g.label)).toContain('SOC2 & ISO 27001')+ expect(missing.map((g) => g.label)).toContain('SSO for Supabase Dashboard')+ })+})diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/plan-presentation.ts b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/plan-presentation.tsnew file mode 100644index 00000000000..e17fb7bc77b--- /dev/null+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/plan-presentation.ts@@ -0,0 +1,68 @@+import { useMemo } from 'react'++import { isPartnerBillingOrganization } from '@/data/organizations/managed-by-utils'+import { useTrackExperimentExposure } from '@/hooks/misc/useTrackExperimentExposure'+import { usePHFlag } from '@/hooks/ui/useFlag'+import { MANAGED_BY } from '@/lib/constants/infrastructure'+import type { ManagedBy } from '@/lib/constants/infrastructure'++export type PlanPresentationVariant = 'control' | 'parity' | 'gaps'++const FLAG_KEY = 'pricingPanelPlanPresentation'+const EXPERIMENT_ID = 'pricing_panel_plan_presentation'++export function isPlanChangeEligible({+ managedBy,+ billingPartner,+ currentPlanId,+ canUpdateSubscription,+}: {+ managedBy: ManagedBy | undefined+ billingPartner: string | null | undefined+ currentPlanId: string | undefined+ canUpdateSubscription: boolean+}): boolean {+ if (managedBy === MANAGED_BY.STRIPE_PROJECTS) return false+ if (managedBy === MANAGED_BY.AWS_MARKETPLACE) return false+ if (isPartnerBillingOrganization(billingPartner)) return false+ if (currentPlanId === 'enterprise' || currentPlanId === 'platform') return false+ if (!canUpdateSubscription) return false+ return true+}++export function usePlanPresentationExperiment({+ eligible,+}: {+ eligible: boolean+}): PlanPresentationVariant {+ const flag = usePHFlag<'control' | 'parity' | 'gaps'>(FLAG_KEY)++ const isInExperiment = flag === 'control' || flag === 'parity' || flag === 'gaps'++ const variant: PlanPresentationVariant = useMemo(() => {+ if (!eligible || !isInExperiment) return 'control'+ return flag as PlanPresentationVariant+ }, [eligible, isInExperiment, flag])++ const liveVariant = eligible && isInExperiment ? variant : undefined+ useTrackExperimentExposure(EXPERIMENT_ID, liveVariant)++ return variant+}++export interface GapFeature {+ label: string+ type: 'missing' | 'lesser'+}++export const FREE_PLAN_GAPS: GapFeature[] = [+ { label: 'Daily backups', type: 'missing' },+ { label: 'Email support', type: 'missing' },+ { label: '1-day log retention', type: 'lesser' },+]++export const PRO_PLAN_GAPS: GapFeature[] = [+ { label: 'SOC2 & ISO 27001', type: 'missing' },+ { label: 'SSO for Supabase Dashboard', type: 'missing' },+ { label: 'Priority email support & SLAs', type: 'missing' },+]diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.tsindex d0e5db8d925..12dad4e2243 100644--- a/packages/common/telemetry-constants.ts+++ b/packages/common/telemetry-constants.ts@@ -3516,6 +3516,25 @@ export interface UpgradeCtaClickedEvent {groups: Omit<TelemetryGroups, 'project'>}+/**+ * User was exposed to the plan-change panel presentation experiment.+ * Fires once per session per enrolled user in any variant (including control), so the+ * conversion analysis has a baseline cohort. Conversion itself is tracked server-side.+ * GROWTH experiment: `pricingPanelPlanPresentation`.+ *+ * @group Events+ * @page /org/[slug]/billing (plan-change side panel)+ * @source studio+ */+export interface PricingPanelPlanPresentationExperimentExposedEvent {+ action: 'pricing_panel_plan_presentation_experiment_exposed'+ properties: {+ /** The experiment variant the user is enrolled in */+ variant: 'control' | 'parity' | 'gaps'+ }+ groups: Omit<TelemetryGroups, 'project'>+}+/*** User clicked the primary CTA on a resource exhaustion warning banner.*@@ -3937,6 +3956,7 @@ export type TelemetryEvent =| FreeMicroUpgradeBannerDismissedEvent| FreeMicroUpgradeBannerCtaClickedEvent| UpgradeCtaClickedEvent+ | PricingPanelPlanPresentationExperimentExposedEvent| AccessTokenCreatedEvent| AccessTokenRemovedEvent| ResourceExhaustionBannerUpgradeClickedEvent