Skip to content

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

chore(studio): allow project creation region flags to resolve independently (#51787)

kemal.earth991653aa36a7
diff --git a/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.utils.test.ts b/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.utils.test.ts
index fc95460cda0..1e545af9412 100644
--- a/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.utils.test.ts
+++ b/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.utils.test.ts
@@ -14,7 +14,6 @@ import {
getFreeTierGeneralRegionExperimentVariant,
getHighAvailabilityRegionCode,
getRegionSelectionType,
- getSpecificRegionsLinkVariant,
resolveDefaultDbRegion,
resolvePostgresVersion,
} from './ProjectCreation.utils'
@@ -141,12 +140,6 @@ describe('getFreeTierGeneralRegionExperimentVariant', () => {
)
})
- it('returns undefined when overridden, even if otherwise enrolled', () => {
- expect(
- getFreeTierGeneralRegionExperimentVariant({ ...base, isOverridden: true })
- ).toBeUndefined()
- })
-
it('returns undefined for a paid plan', () => {
expect(
getFreeTierGeneralRegionExperimentVariant({ ...base, isFreePlan: false })
@@ -235,30 +228,6 @@ describe('getRegionSelectionType', () => {
})
})
-describe('getSpecificRegionsLinkVariant', () => {
- const base = {
- isFreePlan: true,
- smartRegionEnabled: true,
- linkFlag: true,
- }
-
- it('returns test when eligible and the flag is on', () => {
- expect(getSpecificRegionsLinkVariant(base)).toBe('test')
- })
-
- it('returns control when eligible and the flag is off', () => {
- expect(getSpecificRegionsLinkVariant({ ...base, linkFlag: false })).toBe('control')
- })
-
- it('returns undefined for a paid plan', () => {
- expect(getSpecificRegionsLinkVariant({ ...base, isFreePlan: false })).toBeUndefined()
- })
-
- it('returns undefined when smart regions are disabled (AWS_NIMBUS)', () => {
- expect(getSpecificRegionsLinkVariant({ ...base, smartRegionEnabled: false })).toBeUndefined()
- })
-})
-
describe('extractPostgresVersionDetails', () => {
it('splits engine and release channel', () => {
expect(extractPostgresVersionDetails('17|ga')).toEqual({
diff --git a/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.utils.ts b/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.utils.ts
index 0973f51eebf..dbb556aacbf 100644
--- a/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.utils.ts
+++ b/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.utils.ts
@@ -117,25 +117,21 @@ type GetFreeTierGeneralRegionExperimentVariantArgs = {
smartRegionEnabled: boolean
enrollmentFlag: boolean
selectionFlag: boolean
- /** When true, another feature owns the region selector and the experiment is inactive */
- isOverridden?: boolean
}
/**
* Org's arm in the freeTierGeneralRegionExperiment. The test arm only sees general regions.
- * Returns undefined when the org isn't enrolled, or when the experiment is overridden.
+ * Returns undefined when the org isn't enrolled.
*/
export function getFreeTierGeneralRegionExperimentVariant({
isFreePlan,
smartRegionEnabled,
enrollmentFlag,
selectionFlag,
- isOverridden = false,
}: GetFreeTierGeneralRegionExperimentVariantArgs):
| FreeTierGeneralRegionExperimentVariant
| undefined {
- const isInExperiment =
- !isOverridden && isFreePlan && smartRegionEnabled && enrollmentFlag === true
+ const isInExperiment = isFreePlan && smartRegionEnabled && enrollmentFlag === true
if (!isInExperiment) return undefined
return selectionFlag === true ? 'test' : 'control'
}
@@ -168,28 +164,6 @@ export function getRegionSelectionType({
return isGeneral ? 'general' : 'specific'
}
-export type SpecificRegionsLinkVariant = 'test' | 'control'
-
-type GetSpecificRegionsLinkVariantArgs = {
- isFreePlan: boolean
- smartRegionEnabled: boolean
- linkFlag: boolean
-}
-
-/**
- * Org's arm in the projectCreationSpecificRegionsLink experiment. Returns undefined when the
- * org isn't in the eligible population (paid plan, or smart regions disabled for the selected
- * cloud provider) — the link can never show for them regardless of the flag.
- */
-export function getSpecificRegionsLinkVariant({
- isFreePlan,
- smartRegionEnabled,
- linkFlag,
-}: GetSpecificRegionsLinkVariantArgs): SpecificRegionsLinkVariant | undefined {
- if (!isFreePlan || !smartRegionEnabled) return undefined
- return linkFlag === true ? 'test' : 'control'
-}
-
export interface PostgresVersionDetails {
postgresEngine?: Exclude<PostgresEngine, '13' | '14'>
releaseChannel?: ReleaseChannel
diff --git a/apps/studio/components/interfaces/ProjectCreation/ProjectCreationForm.tsx b/apps/studio/components/interfaces/ProjectCreation/ProjectCreationForm.tsx
index a9b5cff24bc..d4fce5a095e 100644
--- a/apps/studio/components/interfaces/ProjectCreation/ProjectCreationForm.tsx
+++ b/apps/studio/components/interfaces/ProjectCreation/ProjectCreationForm.tsx
@@ -33,7 +33,6 @@ import {
getFreeTierGeneralRegionExperimentVariant,
getHighAvailabilityRegionCode,
getRegionSelectionType,
- getSpecificRegionsLinkVariant,
instanceLabel,
monthlyInstancePrice,
resolveDefaultDbRegion,
@@ -208,17 +207,7 @@ export const ProjectCreationForm = ({
const highAvailabilityRegionCode = getHighAvailabilityRegionCode()
const { isPending: isPendingOrganizationCreatedAt } = useSelectedOrganizationCreatedAtQuery()
- // Only free-plan orgs get the specific-regions link collapse behavior. When active for an
- // org, it owns the region selector, so the free tier experiment stays inactive for that org.
- const specificRegionsLinkFlag = useFlag('projectCreationSpecificRegionsLink') === true
- const isSpecificRegionsLinkEnabled = specificRegionsLinkFlag && isFreePlan
- const specificRegionsLinkVariant = getSpecificRegionsLinkVariant({
- isFreePlan,
- smartRegionEnabled,
- linkFlag: specificRegionsLinkFlag,
- })
const isResolvingFreeTierGeneralRegionExperiment =
- !isSpecificRegionsLinkEnabled &&
isFreePlan &&
smartRegionEnabled &&
(!flagsLoaded || isPendingOrganizationCreatedAt || isConfigCatStale === true)
@@ -229,7 +218,6 @@ export const ProjectCreationForm = ({
smartRegionEnabled,
enrollmentFlag: freeTierGeneralRegionEnrollment,
selectionFlag: freeTierGeneralRegionSelection,
- isOverridden: isSpecificRegionsLinkEnabled,
})
// Read dirty state during render rather than depending on form.formState in the
@@ -400,9 +388,6 @@ export const ProjectCreationForm = ({
...(freeTierGeneralRegionExperimentVariant !== undefined && {
freeTierGeneralRegionExperiment: freeTierGeneralRegionExperimentVariant,
}),
- ...(specificRegionsLinkVariant !== undefined && {
- specificRegionsLinkExperiment: specificRegionsLinkVariant,
- }),
...(regionSelectionType !== undefined && { regionSelectionType }),
regionCode: res.region,
},
@@ -653,9 +638,15 @@ export const ProjectCreationForm = ({
if (freeTierGeneralRegionExperimentVariant === undefined) return
if (!canCreateProject || projectCreationDisabled || isLoadingFreeProjectLimit) return
freeTierGeneralRegionExposedSlug.current = slug
- track('free_tier_general_region_experiment_exposed', {
- variant: freeTierGeneralRegionExperimentVariant,
- })
+ track(
+ 'free_tier_general_region_experiment_exposed',
+ {
+ variant: freeTierGeneralRegionExperimentVariant,
+ },
+ {
+ organization: slug,
+ }
+ )
}, [
slug,
isResolvingFreeTierGeneralRegionExperiment,
diff --git a/apps/studio/components/interfaces/ProjectCreation/RegionSelector.tsx b/apps/studio/components/interfaces/ProjectCreation/RegionSelector.tsx
index 1cd19240ebf..ad5e46314c2 100644
--- a/apps/studio/components/interfaces/ProjectCreation/RegionSelector.tsx
+++ b/apps/studio/components/interfaces/ProjectCreation/RegionSelector.tsx
@@ -94,8 +94,7 @@ export const RegionSelector = ({
const { hasLoaded: flagsLoaded } = useFeatureFlags()
const smartRegionEnabled = cloudProvider !== 'AWS_NIMBUS'
const isStatusPageEnabled = useFlag('incidentIoStatusPage') === true
- const isSpecificRegionsLinkEnabled =
- useFlag('projectCreationSpecificRegionsLink') === true && isFreePlan
+ const isSpecificRegionsLinkEnabled = isFreePlan && !hideSpecificRegions
const { getRegionRestriction } = useRegionRestriction()
@@ -187,8 +186,6 @@ export const RegionSelector = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [dbRegion, form])
- // Behind projectCreationSpecificRegionsLink the dropdown opens on the general regions alone, with
- // a link that reveals the full list — the same list that ships today, general selection intact.
const hasGeneralRegions = smartRegionEnabled && !highAvailability
const isSpecificRegionSelected = regionOptions.some((region) => region.name === dbRegion)
const [isOpen, setIsOpen] = useState(false)
diff --git a/apps/studio/tests/pages/new/[slug].test.tsx b/apps/studio/tests/pages/new/[slug].test.tsx
index ff66a680715..76f096b0c21 100644
--- a/apps/studio/tests/pages/new/[slug].test.tsx
+++ b/apps/studio/tests/pages/new/[slug].test.tsx
@@ -285,7 +285,6 @@ const DEFAULT_FLAGS = {
disableOrioleProjectCreation: false,
defaultRegionRestrictedPool: false,
projectCreationRestrictedRegions: false,
- projectCreationSpecificRegionsLink: false,
freeTierGeneralRegionEnrollment: false,
freeTierGeneralRegionSelection: false,
}
@@ -556,13 +555,12 @@ describe('project creation wizard', () => {
})
describe('specific regions behind a link', () => {
- const SPECIFIC_REGIONS_LINK_FLAG = { projectCreationSpecificRegionsLink: true }
const FREE_PLAN_ORG = [mockOrg({ plan: { id: 'free', name: 'Free' } })]
test('opens on the general regions alone for a free-plan org', async () => {
mockWizardEndpoints({ organizations: FREE_PLAN_ORG })
- await renderWizard({ flags: SPECIFIC_REGIONS_LINK_FLAG })
+ await renderWizard()
await screen.findByPlaceholderText('Project name')
await user.click(getSelectTriggerByLabel('Region'))
@@ -576,7 +574,7 @@ describe('project creation wizard', () => {
const onRequest = vi.fn()
mockCreateProject(onRequest)
- await renderWizard({ flags: SPECIFIC_REGIONS_LINK_FLAG })
+ await renderWizard()
await fillProjectName('Specific Region Link Project')
await generateAndWaitForStrongPassword()
@@ -596,10 +594,10 @@ describe('project creation wizard', () => {
expect(await submitAndReadRegionSelection(onRequest)).toMatchObject({ code: 'us-east-1' })
})
- test('has no effect for a paid-plan org: the full region list shows directly with no link', async () => {
+ test('does not apply to a paid-plan org: the full region list shows directly with no link', async () => {
mockWizardEndpoints()
- await renderWizard({ flags: SPECIFIC_REGIONS_LINK_FLAG })
+ await renderWizard()
await screen.findByPlaceholderText('Project name')
await user.click(getSelectTriggerByLabel('Region'))
@@ -713,7 +711,7 @@ describe('project creation wizard', () => {
)
})
- test('shows the full region picker with no upgrade footer for a free-plan org in the control arm', async () => {
+ test('the upgrade footer replaces the specific-regions link for a free-plan org in the test arm', async () => {
mockWizardEndpoints({
organizations: [mockOrg({ plan: { id: 'free', name: 'Free' } })],
})
@@ -721,28 +719,28 @@ describe('project creation wizard', () => {
await renderWizard({
flags: {
freeTierGeneralRegionEnrollment: true,
- freeTierGeneralRegionSelection: false,
+ freeTierGeneralRegionSelection: true,
},
})
await screen.findByPlaceholderText('Project name')
await user.click(getSelectTriggerByLabel('Region'))
- expect(await screen.findByText('Specific regions')).toBeInTheDocument()
- expect(screen.getByRole('option', { name: /North Virginia/ })).toBeInTheDocument()
- expect(screen.queryByRole('link', { name: 'Upgrade to Pro' })).not.toBeInTheDocument()
+ expect(await screen.findByText('General regions')).toBeInTheDocument()
+ expect(screen.queryByText('Specific regions')).not.toBeInTheDocument()
+ expect(screen.getByRole('link', { name: 'Upgrade to Pro' })).toBeInTheDocument()
+ expect(screen.queryByText('Need a specific region?')).not.toBeInTheDocument()
})
- test('the specific-regions link takes precedence when both flags are on', async () => {
+ test('collapses specific regions behind the link for a free-plan org in the control arm', async () => {
mockWizardEndpoints({
organizations: [mockOrg({ plan: { id: 'free', name: 'Free' } })],
})
await renderWizard({
flags: {
- projectCreationSpecificRegionsLink: true,
freeTierGeneralRegionEnrollment: true,
- freeTierGeneralRegionSelection: true,
+ freeTierGeneralRegionSelection: false,
},
})
diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.ts
index f563ac23ad9..09e97e22bae 100644
--- a/packages/common/telemetry-constants.ts
+++ b/packages/common/telemetry-constants.ts
@@ -455,13 +455,6 @@ export interface ProjectCreationSimpleVersionSubmittedEvent {
* or not enrolled via the freeTierGeneralRegionEnrollment ConfigCat flag).
*/
freeTierGeneralRegionExperiment?: 'control' | 'test'
- /**
- * Org's arm in the projectCreationSpecificRegionsLink experiment at submission time.
- * Omitted when the org isn't in the eligible population (paid plan, or smart regions
- * disabled for the selected cloud provider) — the link can never show for them regardless
- * of the ConfigCat flag.
- */
- specificRegionsLinkExperiment?: 'control' | 'test'
/**
* How the submitted region was arrived at. 'auto' = the user never touched the region field
* and kept the auto-assigned default. 'general' = the user picked a smart region group (e.g.