:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
export type Region = 'us' | 'eu'
export const POSTHOG_US_BASE_URL = 'https://us.posthog.com'
export const POSTHOG_EU_BASE_URL = 'https://eu.posthog.com'
export const REGION_BASE_URLS: Record<Region, string> = {
us: POSTHOG_US_BASE_URL,
eu: POSTHOG_EU_BASE_URL,
}
export function toRegion(value: string | undefined | null): Region {
return value?.toLowerCase() === 'eu' ? 'eu' : 'us'
}
export function baseUrlForRegion(region: Region): string {
return REGION_BASE_URLS[region]
}
export function regionForBaseUrl(baseUrl: string): Region | null {
const match = Object.entries(REGION_BASE_URLS).find(([, url]) => url === baseUrl)
return match ? (match[0] as Region) : null
}
export function proxyOrigin(request: Request): string {
return new URL(request.url).origin
}