forked from github/plane
fix: posthog proxy config using rewrites
This commit is contained in:
parent
e47ab573a7
commit
a04ce5abfc
@ -8,7 +8,6 @@
|
|||||||
"NEXT_PUBLIC_SPACE_BASE_URL",
|
"NEXT_PUBLIC_SPACE_BASE_URL",
|
||||||
"NEXT_PUBLIC_SPACE_BASE_PATH",
|
"NEXT_PUBLIC_SPACE_BASE_PATH",
|
||||||
"NEXT_PUBLIC_WEB_BASE_URL",
|
"NEXT_PUBLIC_WEB_BASE_URL",
|
||||||
"NEXT_PUBLIC_TRACK_EVENTS",
|
|
||||||
"NEXT_PUBLIC_PLAUSIBLE_DOMAIN",
|
"NEXT_PUBLIC_PLAUSIBLE_DOMAIN",
|
||||||
"NEXT_PUBLIC_CRISP_ID",
|
"NEXT_PUBLIC_CRISP_ID",
|
||||||
"NEXT_PUBLIC_ENABLE_SESSION_RECORDER",
|
"NEXT_PUBLIC_ENABLE_SESSION_RECORDER",
|
||||||
|
@ -20,7 +20,7 @@ export interface IPosthogWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const PostHogProvider: FC<IPosthogWrapper> = (props) => {
|
const PostHogProvider: FC<IPosthogWrapper> = (props) => {
|
||||||
const { children, user, workspaceRole, currentWorkspaceId, projectRole, posthogAPIKey, posthogHost } = props;
|
const { children, user, workspaceRole, currentWorkspaceId, projectRole } = props;
|
||||||
// states
|
// states
|
||||||
const [lastWorkspaceId, setLastWorkspaceId] = useState(currentWorkspaceId);
|
const [lastWorkspaceId, setLastWorkspaceId] = useState(currentWorkspaceId);
|
||||||
// router
|
// router
|
||||||
@ -42,15 +42,16 @@ const PostHogProvider: FC<IPosthogWrapper> = (props) => {
|
|||||||
}, [user, workspaceRole, projectRole]);
|
}, [user, workspaceRole, projectRole]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (posthogAPIKey && (process.env.NEXT_PUBLIC_POSTHOG_HOST || posthogHost)) {
|
if (process.env.NEXT_PUBLIC_POSTHOG_KEY && process.env.NEXT_PUBLIC_POSTHOG_HOST) {
|
||||||
posthog.init(posthogAPIKey, {
|
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
|
||||||
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST || posthogHost || "https://app.posthog.com",
|
api_host: "/ingest",
|
||||||
|
ui_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
|
||||||
debug: process.env.NEXT_PUBLIC_POSTHOG_DEBUG === "1", // Debug mode based on the environment variable
|
debug: process.env.NEXT_PUBLIC_POSTHOG_DEBUG === "1", // Debug mode based on the environment variable
|
||||||
autocapture: false,
|
autocapture: false,
|
||||||
capture_pageview: false, // Disable automatic pageview capture, as we capture manually
|
capture_pageview: false, // Disable automatic pageview capture, as we capture manually
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [posthogAPIKey, posthogHost]);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Join workspace group on workspace change
|
// Join workspace group on workspace change
|
||||||
|
@ -55,14 +55,15 @@ const nextConfig = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
async rewrites() {
|
async rewrites() {
|
||||||
|
const posthogHost = process.env.NEXT_PUBLIC_POSTHOG_HOST || "https://app.posthog.com"
|
||||||
const rewrites = [
|
const rewrites = [
|
||||||
{
|
{
|
||||||
source: "/ingest/static/:path*",
|
source: "/ingest/static/:path*",
|
||||||
destination: "https://us-assets.i.posthog.com/static/:path*",
|
destination: `${posthogHost}/static/:path*`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
source: "/ingest/:path*",
|
source: "/ingest/:path*",
|
||||||
destination: "https://us.i.posthog.com/:path*",
|
destination: `${posthogHost}/:path*`,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
if (process.env.NEXT_PUBLIC_ADMIN_BASE_URL || process.env.NEXT_PUBLIC_ADMIN_BASE_PATH) {
|
if (process.env.NEXT_PUBLIC_ADMIN_BASE_URL || process.env.NEXT_PUBLIC_ADMIN_BASE_PATH) {
|
||||||
|
Loading…
Reference in New Issue
Block a user