Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat(studio): ship both upgrade CTA placements, remove A/B experiment (#47881)

Mert YEREKAPAN320604d0e75a
diff --git a/apps/studio/components/interfaces/Home/ProjectList/EmptyStates.tsx b/apps/studio/components/interfaces/Home/ProjectList/EmptyStates.tsx
index e8be56338ff..7290e60e85e 100644
--- a/apps/studio/components/interfaces/Home/ProjectList/EmptyStates.tsx
+++ b/apps/studio/components/interfaces/Home/ProjectList/EmptyStates.tsx
@@ -1,7 +1,6 @@
import { BoxPlus } from 'icons'
import { Plus } from 'lucide-react'
import Link from 'next/link'
-import { ReactNode } from 'react'
import {
Button,
Card,
@@ -66,10 +65,9 @@ export const LoadingTableView = () => {
)
}
-export const LoadingCardView = ({ prependCard }: { prependCard?: ReactNode }) => {
+export const LoadingCardView = () => {
return (
<ul className="w-full mx-auto grid grid-cols-1 gap-4 sm:grid-cols-1 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3">
- {prependCard}
<ShimmeringCard />
<ShimmeringCard />
</ul>
diff --git a/apps/studio/components/interfaces/Home/ProjectList/ProjectList.tsx b/apps/studio/components/interfaces/Home/ProjectList/ProjectList.tsx
index 9fd6fdf81a2..0a364a45b53 100644
--- a/apps/studio/components/interfaces/Home/ProjectList/ProjectList.tsx
+++ b/apps/studio/components/interfaces/Home/ProjectList/ProjectList.tsx
@@ -2,7 +2,7 @@ import { keepPreviousData } from '@tanstack/react-query'
import { useDebounce } from '@uidotdev/usehooks'
import { LOCAL_STORAGE_KEYS, useParams } from 'common'
import { parseAsArrayOf, parseAsString, parseAsStringLiteral, useQueryState } from 'nuqs'
-import { ReactNode, useMemo } from 'react'
+import { useMemo } from 'react'
import {
Card,
cn,
@@ -40,19 +40,9 @@ import type { Organization } from '@/types'
export interface ProjectListProps {
organization?: Organization
rewriteHref?: (projectRef: string) => string
- /**
- * Optional content rendered as the first `<li>` inside the grid view, before the
- * project cards. Used by the upgrade CTA placement experiment to slot a card-shaped
- * usage tile in the project list. Ignored in table view.
- */
- prependCard?: ReactNode
}
-export const ProjectList = ({
- organization: organization_,
- rewriteHref,
- prependCard,
-}: ProjectListProps) => {
+export const ProjectList = ({ organization: organization_, rewriteHref }: ProjectListProps) => {
const { slug: urlSlug } = useParams()
const { data: selectedOrganization } = useSelectedOrganizationQuery()
@@ -160,11 +150,7 @@ export const ProjectList = ({
}
if (isLoadingPermissions || isLoadingProjects || !organization) {
- return viewMode === 'table' ? (
- <LoadingTableView />
- ) : (
- <LoadingCardView prependCard={prependCard} />
- )
+ return viewMode === 'table' ? <LoadingTableView /> : <LoadingCardView />
}
if (isEmpty) {
@@ -299,7 +285,6 @@ export const ProjectList = ({
'sm:grid-cols-1 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3'
)}
>
- {prependCard}
{orgProjects?.map((project) => (
<ProjectCard
key={project.ref}
diff --git a/apps/studio/components/interfaces/ProjectHome/PlanUsageCard.tsx b/apps/studio/components/interfaces/ProjectHome/PlanUsageCard.tsx
index dff70bbf0ef..740ff099c64 100644
--- a/apps/studio/components/interfaces/ProjectHome/PlanUsageCard.tsx
+++ b/apps/studio/components/interfaces/ProjectHome/PlanUsageCard.tsx
@@ -113,8 +113,8 @@ const ProgressRing = ({
)
}
-// The upgrade CTA placement experiment variant this card represents. Used as the telemetry
-// `source` + `placement` value. Kept as a constant so the tracking stays explicit.
+// The upgrade CTA surface this card represents. Used as the telemetry `source` +
+// `placement` value. Kept as a constant so the tracking stays explicit.
const PLACEMENT = 'org_projects_list'
const CompactMetricRow = ({
@@ -179,10 +179,10 @@ const SkeletonMetricRow = ({ label }: { label: string }) => (
)
/**
- * Renders the upgrade CTA's plan-usage card as the first tile in the org project list
- * (the `org_projects_list` experiment variant). The parent is responsible for gating on
- * the experiment variant + free plan — this component only renders the visual sections
- * once usage data is available. Shaped like a `ProjectCard` so it reads as another tile.
+ * Renders the upgrade CTA's plan-usage card in the org project list (the
+ * `org_projects_list` CTA placement). The parent is responsible for gating on free plan —
+ * this component only renders the visual sections once usage data is available. Shaped
+ * like a `ProjectCard` so it reads as another tile.
*/
export const PlanUsageCard = () => {
const track = useTrack()
diff --git a/apps/studio/components/interfaces/UserDropdown.tsx b/apps/studio/components/interfaces/UserDropdown.tsx
index ae004c1a9c1..f9cb865fcd8 100644
--- a/apps/studio/components/interfaces/UserDropdown.tsx
+++ b/apps/studio/components/interfaces/UserDropdown.tsx
@@ -23,7 +23,7 @@ import { TimezoneDropdown } from './UserDropdown/TimezoneDropdown'
import { ProfileImage } from '@/components/ui/ProfileImage'
import { UpgradePlanButton } from '@/components/ui/UpgradePlanButton'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
-import { useUpgradeCtaExperiment } from '@/hooks/misc/useUpgradeCtaExperiment'
+import { useShowUpgradeCta } from '@/hooks/misc/useShowUpgradeCta'
import { IS_PLATFORM } from '@/lib/constants'
import { useProfileNameAndPicture } from '@/lib/profile'
import { useTrack } from '@/lib/telemetry/track'
@@ -45,12 +45,12 @@ export function UserDropdown({
const { toggleFeaturePreviewModal } = useFeaturePreviewModal()
const track = useTrack()
- const { variant: upgradeCtaVariant } = useUpgradeCtaExperiment()
- // Per Slack feedback (Jonny): the upgrade CTA is org-scoped, so only show it on routes
- // where an org is in scope. Excludes /account/*, /organizations, /new, marketing routes, etc.
+ // The upgrade CTA is org-scoped, so only enable it on routes where an org is in scope.
+ // Excludes /account/*, /organizations, /new, marketing routes, etc. Gating the hook here
+ // also skips fetching organization data on routes where the CTA can't render.
const isOrgScopedRoute =
router.pathname.startsWith('/project/') || router.pathname.startsWith('/org/')
- const showUpgradeCta = upgradeCtaVariant === 'user_dropdown' && isOrgScopedRoute
+ const { showUpgradeCta } = useShowUpgradeCta({ enabled: isOrgScopedRoute })
const [isOpen, setIsOpen] = useState(false)
diff --git a/apps/studio/hooks/misc/__tests__/useShowUpgradeCta.test.ts b/apps/studio/hooks/misc/__tests__/useShowUpgradeCta.test.ts
new file mode 100644
index 00000000000..d616c3b7eca
--- /dev/null
+++ b/apps/studio/hooks/misc/__tests__/useShowUpgradeCta.test.ts
@@ -0,0 +1,91 @@
+import { renderHook } from '@testing-library/react'
+import { beforeEach, describe, expect, test, vi } from 'vitest'
+
+import { useShowUpgradeCta } from '../useShowUpgradeCta'
+
+const { mockIsPlatform, mockUseSelectedOrganizationQuery } = vi.hoisted(() => ({
+ mockIsPlatform: { value: true },
+ mockUseSelectedOrganizationQuery: vi.fn(),
+}))
+
+vi.mock('@/lib/constants', async () => {
+ const actual = await vi.importActual<Record<string, unknown>>('@/lib/constants')
+ return {
+ ...actual,
+ get IS_PLATFORM() {
+ return mockIsPlatform.value
+ },
+ }
+})
+
+vi.mock('@/hooks/misc/useSelectedOrganization', () => ({
+ useSelectedOrganizationQuery: mockUseSelectedOrganizationQuery,
+}))
+
+const freePlanOrg = { plan: { id: 'free' } }
+const paidPlanOrg = { plan: { id: 'pro' } }
+
+describe('useShowUpgradeCta', () => {
+ beforeEach(() => {
+ mockIsPlatform.value = true
+ mockUseSelectedOrganizationQuery.mockReset()
+ })
+
+ test('hosted free plan: shows the CTA', () => {
+ mockUseSelectedOrganizationQuery.mockReturnValue({ data: freePlanOrg, isPending: false })
+
+ const { result } = renderHook(() => useShowUpgradeCta())
+
+ expect(result.current).toEqual({ isFreePlan: true, showUpgradeCta: true })
+ })
+
+ test('hosted paid plan: hides the CTA', () => {
+ mockUseSelectedOrganizationQuery.mockReturnValue({ data: paidPlanOrg, isPending: false })
+
+ const { result } = renderHook(() => useShowUpgradeCta())
+
+ expect(result.current).toEqual({ isFreePlan: false, showUpgradeCta: false })
+ })
+
+ test('self-hosted: never shows the CTA, even on a free plan', () => {
+ mockIsPlatform.value = false
+ mockUseSelectedOrganizationQuery.mockReturnValue({ data: freePlanOrg, isPending: false })
+
+ const { result } = renderHook(() => useShowUpgradeCta())
+
+ expect(result.current.showUpgradeCta).toBe(false)
+ })
+
+ test('plan still loading: hides the CTA until the org resolves', () => {
+ mockUseSelectedOrganizationQuery.mockReturnValue({ data: undefined, isPending: true })
+
+ const { result } = renderHook(() => useShowUpgradeCta())
+
+ expect(result.current).toEqual({ isFreePlan: false, showUpgradeCta: false })
+ })
+
+ test('missing / errored organization: hides the CTA', () => {
+ mockUseSelectedOrganizationQuery.mockReturnValue({ data: undefined, isPending: false })
+
+ const { result } = renderHook(() => useShowUpgradeCta())
+
+ expect(result.current).toEqual({ isFreePlan: false, showUpgradeCta: false })
+ })
+
+ test('enabled: false — hides the CTA and does not fetch organization data', () => {
+ mockUseSelectedOrganizationQuery.mockReturnValue({ data: undefined, isPending: true })
+
+ const { result } = renderHook(() => useShowUpgradeCta({ enabled: false }))
+
+ expect(result.current.showUpgradeCta).toBe(false)
+ expect(mockUseSelectedOrganizationQuery).toHaveBeenCalledWith({ enabled: false })
+ })
+
+ test('enabled + hosted: fetches organization data', () => {
+ mockUseSelectedOrganizationQuery.mockReturnValue({ data: freePlanOrg, isPending: false })
+
+ renderHook(() => useShowUpgradeCta({ enabled: true }))
+
+ expect(mockUseSelectedOrganizationQuery).toHaveBeenCalledWith({ enabled: true })
+ })
+})
diff --git a/apps/studio/hooks/misc/useShowUpgradeCta.ts b/apps/studio/hooks/misc/useShowUpgradeCta.ts
new file mode 100644
index 00000000000..c20834b3b6b
--- /dev/null
+++ b/apps/studio/hooks/misc/useShowUpgradeCta.ts
@@ -0,0 +1,18 @@
+import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
+import { IS_PLATFORM } from '@/lib/constants'
+
+/**
+ * Whether to show the "Upgrade to Pro" CTA (free-plan orgs on the hosted platform only).
+ * Pass `enabled: false` where the CTA can't render to skip fetching organization data.
+ */
+export const useShowUpgradeCta = ({ enabled = true }: { enabled?: boolean } = {}) => {
+ const shouldEvaluate = IS_PLATFORM && enabled
+ const { data: organization, isPending } = useSelectedOrganizationQuery({
+ enabled: shouldEvaluate,
+ })
+
+ const isFreePlan = organization?.plan?.id === 'free'
+ const showUpgradeCta = shouldEvaluate && !isPending && isFreePlan
+
+ return { isFreePlan, showUpgradeCta }
+}
diff --git a/apps/studio/hooks/misc/useUpgradeCtaExperiment.ts b/apps/studio/hooks/misc/useUpgradeCtaExperiment.ts
deleted file mode 100644
index 23ba7f53d9d..00000000000
--- a/apps/studio/hooks/misc/useUpgradeCtaExperiment.ts
+++ /dev/null
@@ -1,97 +0,0 @@
-import { IS_PLATFORM, safeLocalStorage, useFeatureFlags, useParams } from 'common'
-import { useEffect, useMemo } from 'react'
-
-import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
-import { useTrackExperimentExposure } from '@/hooks/misc/useTrackExperimentExposure'
-import { usePHFlag } from '@/hooks/ui/useFlag'
-
-// PostHog flag key (camelCase, matches other flag naming in the codebase).
-export const UPGRADE_CTA_FLAG_NAME = 'upgradeCtaPlacement'
-
-// snake_case experiment ID so the auto-fired exposure event name matches the
-// `[experiment_id]_experiment_exposed` typed event registered in telemetry-constants.ts.
-const UPGRADE_CTA_EXPERIMENT_ID = 'upgrade_cta_placement'
-
-// localStorage key prefix for the seeded variant (see hook docs). Keyed per org slug
-// because eligibility folds in that org's plan.
-const UPGRADE_CTA_SEED_PREFIX = 'supabase-upgrade-cta-variant-'
-
-export type UpgradeCtaPlacement = 'control' | 'user_dropdown' | 'org_projects_list'
-
-const VALID_VARIANTS: UpgradeCtaPlacement[] = ['control', 'user_dropdown', 'org_projects_list']
-
-/**
- * Shared experiment state for the upgrade CTA placement test.
- *
- * `variant` is the placement to render, and is gated on a confirmed free plan + the
- * experiment flag — paid users never receive a variant, so the CTA never renders for them.
- *
- * First-paint correctness: PostHog flags are fetched async on every load, so the flag
- * (and therefore the variant) is unknown at first paint. To avoid the CTA popping in
- * (layout shift) or flashing, we persist the last resolved variant per org and seed from
- * it synchronously. The seed is used only until the live flag + plan resolve, then the
- * live value takes over and is re-persisted — so it self-heals if anything changed. A
- * confirmed paid plan always wins over a stale seed, so the CTA can't flash for paid users.
- *
- * Net effect: correct at first paint with no shift/flash on every visit after the first
- * (the first-ever visit to a given org still resolves async).
- *
- * Exposure tracking fires only once confirmed (free-plan + in experiment), so the
- * experiment cohort stays accurate.
- */
-export const useUpgradeCtaExperiment = () => {
- const { slug } = useParams()
- const { data: organization, isPending: isOrgPending } = useSelectedOrganizationQuery()
- const flagStore = useFeatureFlags()
- const flagValue = usePHFlag<UpgradeCtaPlacement | false>(UPGRADE_CTA_FLAG_NAME)
-
- const flagsLoaded = flagStore.hasLoaded === true
- const planKnown = !isOrgPending
- const isFreePlan = organization?.plan?.id === 'free'
- const isInExperiment =
- typeof flagValue === 'string' && VALID_VARIANTS.includes(flagValue as UpgradeCtaPlacement)
-
- // The definitive variant for a confirmed free-plan user in the experiment.
- const liveVariant = isFreePlan && isInExperiment ? (flagValue as UpgradeCtaPlacement) : undefined
-
- // Synchronous seed from the last resolved variant for this org. Read via useMemo so it
- // re-reads when the org slug changes (e.g. navigating between orgs without a remount).
- const seedKey = `${UPGRADE_CTA_SEED_PREFIX}${slug ?? 'none'}`
- const seededVariant = useMemo<UpgradeCtaPlacement | null>(() => {
- const item = safeLocalStorage.getItem(seedKey)
- if (!item) return null
- try {
- const parsed = JSON.parse(item)
- return VALID_VARIANTS.includes(parsed) ? (parsed as UpgradeCtaPlacement) : null
- } catch {
- return null
- }
- }, [seedKey])
-
- let variant: UpgradeCtaPlacement | undefined
- if (!IS_PLATFORM) {
- // No billing/plans on self-hosted, so there is nothing to upgrade to — never show.
- variant = undefined
- } else if (flagsLoaded && planKnown) {
- // Fully resolved — source of truth.
- variant = liveVariant
- } else if (planKnown && !isFreePlan) {
- // Confirmed paid — never show, even if a stale seed says otherwise.
- variant = undefined
- } else {
- // Free, or still loading — trust the last known value to avoid a first-paint shift.
- variant = seededVariant ?? undefined
- }
-
- // Persist the last resolved variant once we have a definitive answer, so the next visit
- // to this org can seed from it. Only matters before the live value resolves, so we don't
- // need it in component state.
- useEffect(() => {
- if (!IS_PLATFORM || !flagsLoaded || !planKnown) return
- safeLocalStorage.setItem(seedKey, JSON.stringify(liveVariant ?? null))
- }, [flagsLoaded, planKnown, liveVariant, seedKey])
-
- useTrackExperimentExposure(UPGRADE_CTA_EXPERIMENT_ID, liveVariant)
-
- return { isFreePlan, variant }
-}
diff --git a/apps/studio/pages/org/[slug]/index.tsx b/apps/studio/pages/org/[slug]/index.tsx
index 47bb7aacf6c..4673219bb6c 100644
--- a/apps/studio/pages/org/[slug]/index.tsx
+++ b/apps/studio/pages/org/[slug]/index.tsx
@@ -11,16 +11,15 @@ import OrganizationLayout from '@/components/layouts/OrganizationLayout'
import { PageLayout } from '@/components/layouts/PageLayout/PageLayout'
import { ScaffoldContainer, ScaffoldSection } from '@/components/layouts/Scaffold'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
-import { useUpgradeCtaExperiment } from '@/hooks/misc/useUpgradeCtaExperiment'
+import { useShowUpgradeCta } from '@/hooks/misc/useShowUpgradeCta'
import type { NextPageWithLayout } from '@/types'
const ProjectsPage: NextPageWithLayout = () => {
const isUserMFAEnabled = useIsMFAEnabled()
const { data: org } = useSelectedOrganizationQuery()
- const { variant: upgradeCtaVariant } = useUpgradeCtaExperiment()
+ const { showUpgradeCta: showOrgProjectsListUsageCard } = useShowUpgradeCta()
const disableAccessMfa = org?.organization_requires_mfa && !isUserMFAEnabled
- const showOrgProjectsListUsageCard = upgradeCtaVariant === 'org_projects_list'
return (
<ScaffoldContainer className="grow flex">
diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.ts
index 2a7b3a8f20b..cb8ba616486 100644
--- a/packages/common/telemetry-constants.ts
+++ b/packages/common/telemetry-constants.ts
@@ -3283,8 +3283,8 @@ export interface AccessTokenRemovedEvent {
}
/**
- * User clicked the "Upgrade to Pro" CTA in one of the experiment placement surfaces.
- * GROWTH experiment: `upgradeCtaPlacement` (user_dropdown / org_projects_list).
+ * User clicked the "Upgrade to Pro" CTA. Fired from each CTA placement surface, with
+ * `placement` identifying which one (the user dropdown or the org project-list usage card).
*
* @group Events
* @source studio
@@ -3297,25 +3297,6 @@ export interface UpgradeCtaClickedEvent {
groups: Omit<TelemetryGroups, 'project'>
}
-/**
- * User was exposed to the upgrade CTA placement experiment.
- * Fires once per session per free-plan user enrolled in any variant (including control),
- * so the conversion analysis has a baseline cohort.
- *
- * @group Events
- * @source studio
- */
-export interface UpgradeCtaPlacementExperimentExposedEvent {
- action: 'upgrade_cta_placement_experiment_exposed'
- properties: {
- /**
- * The experiment variant shown to the user
- */
- variant: 'control' | 'user_dropdown' | 'org_projects_list'
- }
- groups: Omit<TelemetryGroups, 'project'>
-}
-
/**
* User clicked the primary CTA on a resource exhaustion warning banner.
*
@@ -3725,7 +3706,6 @@ export type TelemetryEvent =
| FreeMicroUpgradeBannerDismissedEvent
| FreeMicroUpgradeBannerCtaClickedEvent
| UpgradeCtaClickedEvent
- | UpgradeCtaPlacementExperimentExposedEvent
| AccessTokenCreatedEvent
| AccessTokenRemovedEvent
| ResourceExhaustionBannerUpgradeClickedEvent