From 16ee575ff8435d767344cd76112b2e62c657ad88 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Wed, 1 Jul 2026 11:24:03 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(all)=20support=20a=20dedicated=20doma?= =?UTF-8?q?in=20for=20the=20PostHog=20feature=20flag=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/frontend/src/api/useConfig.ts | 1 + .../src/features/analytics/hooks/useAnalytics.ts | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/api/useConfig.ts b/src/frontend/src/api/useConfig.ts index 943f2c38..7a3bf320 100644 --- a/src/frontend/src/api/useConfig.ts +++ b/src/frontend/src/api/useConfig.ts @@ -9,6 +9,7 @@ export interface ApiConfig { analytics?: { id: string host: string + flags_api_host?: string } support?: { id: string diff --git a/src/frontend/src/features/analytics/hooks/useAnalytics.ts b/src/frontend/src/features/analytics/hooks/useAnalytics.ts index 36ac5e6e..c0b241af 100644 --- a/src/frontend/src/features/analytics/hooks/useAnalytics.ts +++ b/src/frontend/src/features/analytics/hooks/useAnalytics.ts @@ -28,10 +28,16 @@ export const terminateAnalyticsSession = async () => { export type useAnalyticsProps = { id?: string host?: string + flags_api_host?: string isDisabled?: boolean } -export const useAnalytics = ({ id, host, isDisabled }: useAnalyticsProps) => { +export const useAnalytics = ({ + id, + host, + flags_api_host, + isDisabled, +}: useAnalyticsProps) => { const [location] = useLocation() const { user } = useUser() @@ -39,9 +45,13 @@ export const useAnalytics = ({ id, host, isDisabled }: useAnalyticsProps) => { if (!id || !host || isDisabled) return getPosthog().then((ph) => { 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(() => { if (!user) return