mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
Check region selection for project creation (#51012)
## Context Previously added telemetry for `selectedRegionOption` and `selectedRegionOptionType` [here](https://github.com/supabase/supabase/issues/50851) if the best available region option is available for users Opting to extend this telemetry (still just for Free plan orgs) irregardless if best available region was selected and include `initialRecommendedRegion` Main thing to understand is what regions users are spinning projects up in outside of the recommended option ## To test - [ ] Verify the telemetry network request after creating projects - [ ] Non-free plan: Telemetry request doesn't have `initialRecommendedRegion` in the payload - [ ] Free plan: Telemetry request has `initialRecommendedRegion` in the payload - Sends correctly if best available region option is available (default behaviour for staging) - Sends correctly if best available region option is NOT available (override with dev tools the configcat flag)
This commit is contained in:
1 parent
8f6a6f7032
commit
93a262d185
2 files changed
+36
-4
No files matched your search
@@ -152,6 +152,9 @@ export const ProjectCreationForm = ({
|
||||
showBestAvailableRegionFeature && showBestAvailableRegionFlag && isFreePlan
|
||||
const [isBestAvailableSelected, setIsBestAvailableSelected] = useState(false)
|
||||
|
||||
const shouldTrackRegionRecommendation = isFreePlan && showBestAvailableRegionFeature
|
||||
const initialRecommendedRegionRef = useRef<string | undefined>(undefined)
|
||||
|
||||
// Read the raw flag for telemetry — coerce-undefined-to-false would record false for
|
||||
// users whose flags haven't loaded yet. The raw value preserves undefined (omitted from
|
||||
// PostHog) so we only record an actual value (boolean true/false, or a variant string
|
||||
@@ -302,6 +305,16 @@ export const ProjectCreationForm = ({
|
||||
? availableRegionsData?.recommendations.smartGroup.name
|
||||
: ''
|
||||
|
||||
if (
|
||||
initialRecommendedRegionRef.current === undefined &&
|
||||
flagsLoaded &&
|
||||
shouldTrackRegionRecommendation
|
||||
) {
|
||||
initialRecommendedRegionRef.current = showBestAvailableRegionOption
|
||||
? 'best_available'
|
||||
: recommendedSmartRegion || undefined
|
||||
}
|
||||
|
||||
const fixedDefaultRegion = PROVIDERS[selectedCloudProvider].default_region.displayName
|
||||
const regionError = smartRegionEnabled ? availableRegionsError : defaultRegionError
|
||||
const defaultRegion = resolveDefaultDbRegion({
|
||||
@@ -374,7 +387,11 @@ export const ProjectCreationForm = ({
|
||||
...(dataApiRevokeOnCreateDefaultFlag !== undefined && {
|
||||
dataApiRevokeOnCreateDefaultEnabled: dataApiRevokeOnCreateDefaultFlag,
|
||||
}),
|
||||
...(showBestAvailableRegionOption && { selectedRegionOption, selectedRegionOptionType }),
|
||||
...(shouldTrackRegionRecommendation && {
|
||||
selectedRegionOption,
|
||||
selectedRegionOptionType,
|
||||
initialRecommendedRegion: initialRecommendedRegionRef.current,
|
||||
}),
|
||||
},
|
||||
{
|
||||
project: res.ref,
|
||||
|
||||
Reference in new issue
Block a user