mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-11 09:58:28 +00:00
feat: proxy analytics requests
This commit is contained in:
parent
386580b0ee
commit
ba53605572
@ -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,
|
||||||
|
|||||||
@ -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);
|
||||||
Loading…
x
Reference in New Issue
Block a user