feat: add posthog reverse proxy (#449)

This commit is contained in:
David Nguyen
2023-09-28 12:56:53 +10:00
committed by Mythie
parent cca1bb4639
commit 7ec8ce2a56
3 changed files with 19 additions and 1 deletions

View File

@ -56,6 +56,14 @@ const config = {
}, },
]; ];
}, },
async rewrites() {
return [
{
source: '/ingest/:path*',
destination: 'https://eu.posthog.com/:path*',
},
];
},
}; };
module.exports = withContentlayer(config); module.exports = withContentlayer(config);

View File

@ -29,6 +29,14 @@ const config = {
transform: 'lucide-react/dist/esm/icons/{{ kebabCase member }}', transform: 'lucide-react/dist/esm/icons/{{ kebabCase member }}',
}, },
}, },
async rewrites() {
return [
{
source: '/ingest/:path*',
destination: 'https://eu.posthog.com/:path*',
},
];
},
}; };
module.exports = config; module.exports = config;

View File

@ -1,3 +1,5 @@
import { APP_BASE_URL } from './app';
/** /**
* The flag name for global session recording feature flag. * The flag name for global session recording feature flag.
*/ */
@ -23,7 +25,7 @@ export const LOCAL_FEATURE_FLAGS: Record<string, boolean> = {
*/ */
export function extractPostHogConfig(): { key: string; host: string } | null { export function extractPostHogConfig(): { key: string; host: string } | null {
const postHogKey = process.env.NEXT_PUBLIC_POSTHOG_KEY; const postHogKey = process.env.NEXT_PUBLIC_POSTHOG_KEY;
const postHogHost = process.env.NEXT_PUBLIC_POSTHOG_HOST; const postHogHost = `${APP_BASE_URL}/ingest`;
if (!postHogKey || !postHogHost) { if (!postHogKey || !postHogHost) {
return null; return null;