From 9401060f37b84b8e041df76b4c95f388e1a84c2a Mon Sep 17 00:00:00 2001 From: Alex TYRODE Date: Wed, 28 May 2025 13:17:42 +0000 Subject: [PATCH] feat: add devMode configuration to app settings endpoint - Introduced a new `devMode` property in the app configuration, allowing for conditional initialization of PostHog analytics based on the development environment. - Updated the App component to check for `devMode` before initializing PostHog, enhancing control over analytics in development settings. - Modified the AppConfig interface to include the new `devMode` boolean property for type safety. --- src/backend/routers/app_router.py | 3 ++- src/frontend/src/App.tsx | 2 +- src/frontend/src/hooks/useAppConfig.ts | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/backend/routers/app_router.py b/src/backend/routers/app_router.py index f053808..5c240fc 100644 --- a/src/backend/routers/app_router.py +++ b/src/backend/routers/app_router.py @@ -32,5 +32,6 @@ async def get_app_config(): return { "coderUrl": os.getenv("CODER_URL", ""), "posthogKey": os.getenv("VITE_PUBLIC_POSTHOG_KEY", ""), - "posthogHost": os.getenv("VITE_PUBLIC_POSTHOG_HOST", "") + "posthogHost": os.getenv("VITE_PUBLIC_POSTHOG_HOST", ""), + "devMode": os.getenv("PAD_DEV_MODE", "false") == "true", } diff --git a/src/frontend/src/App.tsx b/src/frontend/src/App.tsx index a61fa25..977cdc9 100644 --- a/src/frontend/src/App.tsx +++ b/src/frontend/src/App.tsx @@ -52,7 +52,7 @@ export default function App() { }; useEffect(() => { - if (config?.posthogKey && config?.posthogHost) { + if (!config?.devMode && config?.posthogKey && config?.posthogHost) { initializePostHog({ posthogKey: config.posthogKey, posthogHost: config.posthogHost, diff --git a/src/frontend/src/hooks/useAppConfig.ts b/src/frontend/src/hooks/useAppConfig.ts index 5a52f95..db18e0f 100644 --- a/src/frontend/src/hooks/useAppConfig.ts +++ b/src/frontend/src/hooks/useAppConfig.ts @@ -4,6 +4,7 @@ interface AppConfig { coderUrl: string; posthogKey: string; posthogHost: string; + devMode: boolean; } const fetchAppConfig = async (): Promise => { @@ -31,6 +32,7 @@ export const useAppConfig = () => { gcTime: Infinity, // Renamed from cacheTime in v5 }); + console.log('data', data); return { config: data, isLoadingConfig: isLoading,