feat(posthog): route analytics through reverse proxy (#463)

## 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)
This commit is contained in:
Víctor Falcón 2026-06-01 09:29:30 +02:00 committed by GitHub
parent 96ee311299
commit 448bb2e64a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -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=

View File

@ -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: () => {