From 448bb2e64af8ebb8b2a28700d793b97fba75bf6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Falc=C3=B3n?= Date: Mon, 1 Jun 2026 09:29:30 +0200 Subject: [PATCH] feat(posthog): route analytics through reverse proxy (#463) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What Route PostHog through the managed reverse proxy at `t.whisper.money` to dodge ad blockers and keep analytics first-party. We use the **JS library method** (`posthog-js` in `resources/js/lib/posthog.ts`), so only that init needed changes — no snippet. ## Changes - `api_host` default → `https://t.whisper.money` (proxy domain) - Add `ui_host` (default `https://eu.posthog.com`) so dashboard links resolve back to PostHog correctly - Both stay env-overridable: `VITE_POSTHOG_HOST`, new `VITE_POSTHOG_UI_HOST` - Update `.env.example` ## Test - `posthog.test.ts` passes - format + lint clean (one pre-existing unrelated warning) --- .env.example | 3 ++- resources/js/lib/posthog.ts | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 63023bcb..598f16c7 100644 --- a/.env.example +++ b/.env.example @@ -82,7 +82,8 @@ VITE_APP_NAME="${APP_NAME}" # PostHog Analytics VITE_POSTHOG_ENABLED=false VITE_POSTHOG_API_KEY= -VITE_POSTHOG_HOST=https://eu.i.posthog.com +VITE_POSTHOG_HOST=https://t.whisper.money +VITE_POSTHOG_UI_HOST=https://eu.posthog.com # Stripe Configuration STRIPE_KEY= diff --git a/resources/js/lib/posthog.ts b/resources/js/lib/posthog.ts index f6751105..84b4907b 100644 --- a/resources/js/lib/posthog.ts +++ b/resources/js/lib/posthog.ts @@ -13,7 +13,11 @@ const getPostHogApiKey = (): string | undefined => { }; const getPostHogHost = (): string => { - return import.meta.env.VITE_POSTHOG_HOST || 'https://eu.i.posthog.com'; + return import.meta.env.VITE_POSTHOG_HOST || 'https://t.whisper.money'; +}; + +const getPostHogUiHost = (): string => { + return import.meta.env.VITE_POSTHOG_UI_HOST || 'https://eu.posthog.com'; }; export const isPostHogSessionRecordingEnabled = (): boolean => { @@ -42,6 +46,7 @@ export function initializePostHog(): void { posthog.init(apiKey, { api_host: host, + ui_host: getPostHogUiHost(), person_profiles: 'always', disable_session_recording: !isPostHogSessionRecordingEnabled(), loaded: () => {