Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions website/analytics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ describe("ghostget.com analytics contract", () => {
expect(capture?.properties).toMatchObject({ analytics_schema_version: 2, site_id: "ghostget" });
});

test("selects the EU UI only for the exact validated ingestion origin", () => {
expect(createBrowserConfig("https://eu.i.posthog.com", home).ui_host).toBe("https://eu.posthog.com");
for (const host of [
"https://us.i.posthog.com",
"https://eu.i.posthog.com.attacker.example",
"https://attacker.example/eu.i.posthog.com",
"https://attacker.example/?host=eu.i.posthog.com",
]) {
expect(createBrowserConfig(host, home).ui_host).toBe("https://us.posthog.com");
}
});

test("keeps the cookieless, personless, bundled-SDK configuration", () => {
const config = createBrowserConfig("https://us.i.posthog.com", home);
expect(config).toMatchObject({
Expand Down
2 changes: 1 addition & 1 deletion website/source/analytics-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ export function createBrowserConfig(host: string, evidence: BrowserEvidence, isA
respect_dnt: true,
// Do not retain a batch that could outlive a visitor’s consent.
request_batching: false,
ui_host: host.includes("eu.i.posthog.com") ? "https://eu.posthog.com" : "https://us.posthog.com",
ui_host: host === "https://eu.i.posthog.com" ? "https://eu.posthog.com" : "https://us.posthog.com",
};
}

Expand Down
Loading