Skip to content

Commit

Permalink
feat: read image proxy url from ab value
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Sep 20, 2024
1 parent 7f3b787 commit d81f57d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 7 additions & 2 deletions apps/renderer/src/hooks/biz/useAb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ export const useAb = (feature: FeatureKeys) => {
return isEnabled
}

export const getAbValue = (feature: FeatureKeys) => {
const enabled = PostHog.getFeatureFlag(feature)
export const isAbEnabled = (feature: FeatureKeys) => {
const featureFlag = PostHog.getFeatureFlag(feature)
const enabled = typeof featureFlag === "boolean" ? featureFlag : featureFlag === "enabled"
const debugOverride = jotaiStore.get(debugFeaturesAtom)

const isEnableOverride = jotaiStore.get(enableDebugOverrideAtom)
Expand All @@ -29,3 +30,7 @@ export const getAbValue = (feature: FeatureKeys) => {

return enabled
}

export const getAbValue = (feature: FeatureKeys) => {
return PostHog.getFeatureFlagPayload(feature)
}
9 changes: 4 additions & 5 deletions apps/renderer/src/lib/img-proxy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { env } from "@follow/shared/env"
import { imageRefererMatches } from "@follow/shared/image"

import { getAbValue } from "~/hooks/biz/useAb"
import { getAbValue, isAbEnabled } from "~/hooks/biz/useAb"

export const getImageProxyUrl = ({
url,
Expand All @@ -12,10 +11,10 @@ export const getImageProxyUrl = ({
width: number
height: number
}) => {
if (getAbValue("Image_Proxy_V2")) {
return `${env.VITE_IMGPROXY_URL}?url=${encodeURIComponent(url)}&width=${width}&height=${height}`
if (isAbEnabled("Image_Proxy_V2")) {
return `${getAbValue("Image_Proxy_V2")}?url=${encodeURIComponent(url)}&width=${width}&height=${height}`
} else {
return `${env.VITE_IMGPROXY_URL}/unsafe/fit-in/${width}x${height}/${encodeURIComponent(url)}`
return `${getAbValue("Image_Proxy_V2")}/unsafe/fit-in/${width}x${height}/${encodeURIComponent(url)}`
}
}

Expand Down

0 comments on commit d81f57d

Please sign in to comment.