Compare commits

...
Author SHA1 Message Date
Brandon Thomas 1d67a29b41 fix production build - remove posthog, minification 2025-05-27 15:30:51 -04:00
5 changed files with 8 additions and 39 deletions
@@ -1,14 +1,5 @@
import { useFeatureFlagEnabled } from "posthog-js/react";
import { FeatureFlags } from "~/enums/FeatureFlags";
import environmentVariables from "~/Classes/EnvironmentVariables";
export const usePosthogFeatureFlag = (flag: FeatureFlags): boolean => {
const enabled = useFeatureFlagEnabled(flag) ?? false;
if (
environmentVariables.values.DEPLOY_CONTEXT &&
environmentVariables.values.DEPLOY_CONTEXT === "DEVELOPMENT"
) {
return true;
}
return enabled;
return true; // TODO(bt,2025-05-27): Find a replacement for Posthog feature flags.
};
-12
View File
@@ -11,8 +11,6 @@ import { config } from "@fortawesome/fontawesome-svg-core";
import EnvironmentVariables from "~/Classes/EnvironmentVariables";
import { pageHeight, pageWidth, persistLogin } from "~/signals";
import { posthog } from "posthog-js";
config.autoAddCss = false; /* eslint-disable import/first */
// TODO(bt,2025-04-19): Make these configurable
@@ -31,21 +29,11 @@ const GlobalSettingsManager = ({ env }: { env: Record<string, string> }) => {
persistLogin();
});
/// Initizations that depends on ENV vars ///
function PostHogInit() {
const apiKey = import.meta.env.VITE_POSTHOG_API_KEY;
posthog.init(apiKey, {
api_host: "https://us.i.posthog.com/",
ui_host: "https://us.i.posthog.com/",
});
}
useEffect(() => {
EnvironmentVariables.initialize(env);
if (import.meta.env.DEV) {
return;
}
PostHogInit();
}, [env]);
/// Initizations that run only once on 1ST mount ///
@@ -12,20 +12,8 @@ export const GlobalSettingsManager = ({ env }: { env: Record<string, string> })
persistLogin();
});
/// Initizations that depends on ENV vars ///
function PostHogInit() {
const data = EnvironmentVariables.values;
const apiKey = data.REACT_APP_PUBLIC_POSTHOG_KEY as string;
//posthog.init(apiKey, {
// //HACK: This is the default host from Netlify, but need to figure out why it isn't working on prod.
// // api_host: data.DEPLOY_PRIME_URL + "/ingest" as string,
// api_host: "https://studio.storyteller.ai/ingest" as string,
// ui_host: data.REACT_APP_PUBLIC_POSTHOG_UI as string,
//});
}
useEffect(() => {
EnvironmentVariables.initialize(env);
PostHogInit();
}, [env]);
/// Initizations that run only once on 1ST mount ///
+1 -5
View File
@@ -1,6 +1,4 @@
import { LinksFunction } from "@remix-run/deno";
import { posthog } from "posthog-js";
import { PostHogProvider } from "posthog-js/react";
import {
Links,
Meta,
@@ -61,9 +59,7 @@ export default function App() {
</head>
<body className="overflow-hidden bg-ui-background">
<div className="topbar-spacer" />
<PostHogProvider client={posthog}>
<Outlet />
</PostHogProvider>
<Outlet />
<ScrollRestoration />
<Scripts />
</body>
+6
View File
@@ -19,6 +19,12 @@ export default defineConfig({
signup: resolve(__dirname, 'app/signup.html'),
},
},
// NB(bt): Set minify to false for debugging purposes in production builds.
minify: false,
terserOptions: {
compress: false,
mangle: false,
},
},
plugins: [
netlifyPlugin(),