From 4d826b54d69c2abb5f9de7f355294285e96dd1a7 Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Sat, 20 Sep 2025 17:12:25 +0200 Subject: [PATCH] feat: support self hosted ph instances for ui_host --- app/routes/app.js-web-posthog-settings/route.tsx | 16 +--------------- common/dto/js-web-settings.dto.ts | 9 +++++---- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/app/routes/app.js-web-posthog-settings/route.tsx b/app/routes/app.js-web-posthog-settings/route.tsx index 92ce8dc..86fc8ab 100644 --- a/app/routes/app.js-web-posthog-settings/route.tsx +++ b/app/routes/app.js-web-posthog-settings/route.tsx @@ -94,20 +94,6 @@ export default function JsWebEvents() { const jsWebPosthogSettingsInitialState = defaultJsWebPosthogSettings.map((entry) => { return { ...entry, - ...(entry.key == 'ui_host' && entry.type == SettingType.Select && { - selectOptions: entry.selectOptions.map((v) => { - const label = (() => { - if (v == 'https://eu.posthog.com') { - return 'Posthog EU' - } - return 'Posthog US' - })(); - return { - label: label, - value: v, - } - }) - }), value: jsWebPosthogSettingsMetafieldValue?.[entry.key], } as JsWebPosthogSettingChoice; @@ -219,7 +205,7 @@ export default function JsWebEvents() { }; const dirty = useMemo(() => { - + const diff = detailedDiff(jsWebPosthogSettingsInitialState || {}, jsWebPosthogSettings); if (Object.values(diff).some((changeType: object) => Object.keys(changeType).length != 0)) { diff --git a/common/dto/js-web-settings.dto.ts b/common/dto/js-web-settings.dto.ts index 2ec89bb..b33e30d 100644 --- a/common/dto/js-web-settings.dto.ts +++ b/common/dto/js-web-settings.dto.ts @@ -3,9 +3,10 @@ export const JsWebPosthogConfigSchema = z.object({ /* api_host: z.string().describe('URL of your PostHog instance.').trim().url().nullish().default(''), */ ui_host: z - .enum(['https://us.posthog.com', 'https://eu.posthog.com']) + .string() + .url() .describe( - `If using a reverse proxy for 'api_host' then this should be the actual PostHog app URL (e.g. https://us.posthog.com). This ensures that links to PostHog point to the correct host.` + `If using a reverse proxy for 'api_host' then this should be the actual PostHog app URL (e.g. https://us.posthog.com, https://eu.posthog.com). This ensures that links to PostHog point to the correct host. If using a self-hosted PostHog instance, provide your custom URL here.` ) .nullable() .default("https://us.posthog.com"), @@ -134,14 +135,14 @@ export const JsWebPosthogConfigSchema = z.object({ // the following will not be implemented /** - * + * sanitize_properties: z.unknown().transform(() => null), loaded: z.unknown().transform(() => null), bootstrap: z.unknown().transform(() => null), session_recording: z.unknown().transform(() => null), xhr_headers: z.unknown().transform(() => null), autocapture: z.unknown().transform(() => null), - + 'autocapture.url_allowlist': z .array(z.string().trim()) .describe(