(all) support a dedicated domain for the PostHog feature flag API

Ad blockers recently started blocking requests to our PostHog
feature flag API, leading to undesired behavior in the app.

Following PostHog's documentation, allow configuring a dedicated
domain for feature flags, isolated from the main PostHog domain.
This commit is contained in:
lebaudantoine
2026-07-01 11:24:03 +02:00
committed by aleb_the_flash
parent e42b083f20
commit 16ee575ff8
2 changed files with 14 additions and 3 deletions
+1
View File
@@ -9,6 +9,7 @@ export interface ApiConfig {
analytics?: { analytics?: {
id: string id: string
host: string host: string
flags_api_host?: string
} }
support?: { support?: {
id: string id: string
@@ -28,10 +28,16 @@ export const terminateAnalyticsSession = async () => {
export type useAnalyticsProps = { export type useAnalyticsProps = {
id?: string id?: string
host?: string host?: string
flags_api_host?: string
isDisabled?: boolean isDisabled?: boolean
} }
export const useAnalytics = ({ id, host, isDisabled }: useAnalyticsProps) => { export const useAnalytics = ({
id,
host,
flags_api_host,
isDisabled,
}: useAnalyticsProps) => {
const [location] = useLocation() const [location] = useLocation()
const { user } = useUser() const { user } = useUser()
@@ -39,9 +45,13 @@ export const useAnalytics = ({ id, host, isDisabled }: useAnalyticsProps) => {
if (!id || !host || isDisabled) return if (!id || !host || isDisabled) return
getPosthog().then((ph) => { getPosthog().then((ph) => {
if (ph.__loaded) return if (ph.__loaded) return
ph.init(id, { api_host: host, person_profiles: 'always' }) ph.init(id, {
api_host: host,
flags_api_host: flags_api_host,
person_profiles: 'always',
})
}) })
}, [id, host, isDisabled]) }, [id, host, flags_api_host, isDisabled])
useEffect(() => { useEffect(() => {
if (!user) return if (!user) return