feat: proxy analytics requests

This commit is contained in:
Harshith Mullapudi 2025-09-03 13:44:53 +05:30
parent 386580b0ee
commit ba53605572
2 changed files with 3 additions and 3 deletions

View File

@ -19,7 +19,7 @@ export const usePostHog = (
if (postHogInitialized.current === true) return; if (postHogInitialized.current === true) return;
if (logging) console.log("Initializing PostHog"); if (logging) console.log("Initializing PostHog");
posthog.init(apiKey, { posthog.init(apiKey, {
api_host: "/relay-Xm1a", api_host: "/ph-relay-core20",
ui_host: "https://us.posthog.com", ui_host: "https://us.posthog.com",
opt_in_site_apps: true, opt_in_site_apps: true,
debug, debug,

View File

@ -5,7 +5,7 @@ const ASSET_HOST = "us-assets.i.posthog.com";
const posthogProxy = async (request: Request) => { const posthogProxy = async (request: Request) => {
const url = new URL(request.url); const url = new URL(request.url);
const hostname = url.pathname.startsWith("/relay-Xm1a/static/") const hostname = url.pathname.startsWith("/ph-relay-core20/static/")
? ASSET_HOST ? ASSET_HOST
: API_HOST; : API_HOST;
@ -13,7 +13,7 @@ const posthogProxy = async (request: Request) => {
newUrl.protocol = "https"; newUrl.protocol = "https";
newUrl.hostname = hostname; newUrl.hostname = hostname;
newUrl.port = "443"; newUrl.port = "443";
newUrl.pathname = newUrl.pathname.replace(/^\/relay-Xm1a/, ""); newUrl.pathname = newUrl.pathname.replace(/^\/ph-relay-core20/, "");
const headers = new Headers(request.headers); const headers = new Headers(request.headers);
headers.set("host", hostname); headers.set("host", hostname);