@@ -5,6 +5,7 @@ import { useFeatureFlagEnabled } from "posthog-js/react"
|
||||
import { jotaiStore } from "~/lib/jotai"
|
||||
import type { FeatureKeys } from "~/modules/ab/atoms"
|
||||
import { debugFeaturesAtom, enableDebugOverrideAtom, IS_DEBUG_ENV } from "~/modules/ab/atoms"
|
||||
import { abPayloadFallback } from "~/modules/ab/fallback"
|
||||
|
||||
export const useAb = (feature: FeatureKeys) => {
|
||||
const isEnableDebugOverrides = useAtomValue(enableDebugOverrideAtom)
|
||||
@@ -32,5 +33,5 @@ export const isAbEnabled = (feature: FeatureKeys) => {
|
||||
}
|
||||
|
||||
export const getAbValue = (feature: FeatureKeys) => {
|
||||
return PostHog.getFeatureFlagPayload(feature)
|
||||
return PostHog.getFeatureFlagPayload(feature) || abPayloadFallback[feature]
|
||||
}
|
||||
|
||||
@@ -11,10 +11,11 @@ export const getImageProxyUrl = ({
|
||||
width: number
|
||||
height: number
|
||||
}) => {
|
||||
const abValue = getAbValue("Image_Proxy_V2")
|
||||
if (isAbEnabled("Image_Proxy_V2")) {
|
||||
return `${getAbValue("Image_Proxy_V2")}?url=${encodeURIComponent(url)}&width=${width}&height=${height}`
|
||||
return `${abValue}?url=${encodeURIComponent(url)}&width=${width}&height=${height}`
|
||||
} else {
|
||||
return `${getAbValue("Image_Proxy_V2")}/unsafe/fit-in/${width}x${height}/${encodeURIComponent(url)}`
|
||||
return `${abValue}/unsafe/fit-in/${width}x${height}/${encodeURIComponent(url)}`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import type { FeatureKeys } from "./atoms"
|
||||
|
||||
export const abPayloadFallback: Record<FeatureKeys, string> = {
|
||||
Image_Proxy_V2: "https://thumbor.follow.is",
|
||||
}
|
||||
Reference in New Issue
Block a user