useIsETLPrivateAlpha.ts44 lines · main
| 1 | import { useFlag } from 'common' |
| 2 | |
| 3 | import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization' |
| 4 | |
| 5 | /** |
| 6 | * Organization level opt in for ETL private alpha, there's 2 flags we're using which controls |
| 7 | * the individual destination types. Access to the ETL UI (`useIsETLPrivateAlpha`) will just |
| 8 | * check if the org has access to at least one of the destination types |
| 9 | */ |
| 10 | const useIsCurrentOrgInFlagList = (flag: string) => { |
| 11 | const flagValue = useFlag(flag) |
| 12 | const { data: organization } = useSelectedOrganizationQuery() |
| 13 | |
| 14 | const allowedOrgSlugs = |
| 15 | typeof flagValue === 'string' |
| 16 | ? (flagValue as string).split(',').map((x: string) => x.trim()) |
| 17 | : [] |
| 18 | |
| 19 | // [Joshen] Override for to enable for all organizations by setting the flag value as `all` |
| 20 | if (allowedOrgSlugs.includes('all')) return true |
| 21 | |
| 22 | // [Joshen] Otherwise fallback to checking against org slug |
| 23 | return allowedOrgSlugs.includes(organization?.slug ?? '') |
| 24 | } |
| 25 | |
| 26 | export const useIsETLBigQueryPrivateAlpha = () => { |
| 27 | return useIsCurrentOrgInFlagList('etlEnableBigQueryPrivateAlpha') |
| 28 | } |
| 29 | |
| 30 | export const useIsETLIcebergPrivateAlpha = () => { |
| 31 | return useIsCurrentOrgInFlagList('etlEnableIcebergPrivateAlpha') |
| 32 | } |
| 33 | |
| 34 | export const useIsETLDucklakePrivateAlpha = () => { |
| 35 | return useIsCurrentOrgInFlagList('etlEnableDucklakePrivateAlpha') |
| 36 | } |
| 37 | |
| 38 | export const useIsETLPrivateAlpha = () => { |
| 39 | const hasAccessToETLBigQuery = useIsCurrentOrgInFlagList('etlEnableBigQueryPrivateAlpha') |
| 40 | const hasAccessToETLIceberg = useIsCurrentOrgInFlagList('etlEnableIcebergPrivateAlpha') |
| 41 | const hasAccessToETLDucklake = useIsCurrentOrgInFlagList('etlEnableDucklakePrivateAlpha') |
| 42 | |
| 43 | return hasAccessToETLBigQuery || hasAccessToETLIceberg || hasAccessToETLDucklake |
| 44 | } |