Skip to content

Commit e26d47a

Browse files
authored
feat: add devMode configuration to app settings endpoint (#99)
- 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.
1 parent 365d7ee commit e26d47a

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/backend/routers/app_router.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ async def get_app_config():
3232
return {
3333
"coderUrl": os.getenv("CODER_URL", ""),
3434
"posthogKey": os.getenv("VITE_PUBLIC_POSTHOG_KEY", ""),
35-
"posthogHost": os.getenv("VITE_PUBLIC_POSTHOG_HOST", "")
35+
"posthogHost": os.getenv("VITE_PUBLIC_POSTHOG_HOST", ""),
36+
"devMode": os.getenv("PAD_DEV_MODE", "false") == "true",
3637
}

src/frontend/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function App() {
5252
};
5353

5454
useEffect(() => {
55-
if (config?.posthogKey && config?.posthogHost) {
55+
if (!config?.devMode && config?.posthogKey && config?.posthogHost) {
5656
initializePostHog({
5757
posthogKey: config.posthogKey,
5858
posthogHost: config.posthogHost,

src/frontend/src/hooks/useAppConfig.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ interface AppConfig {
44
coderUrl: string;
55
posthogKey: string;
66
posthogHost: string;
7+
devMode: boolean;
78
}
89

910
const fetchAppConfig = async (): Promise<AppConfig> => {
@@ -31,6 +32,7 @@ export const useAppConfig = () => {
3132
gcTime: Infinity, // Renamed from cacheTime in v5
3233
});
3334

35+
console.log('data', data);
3436
return {
3537
config: data,
3638
isLoadingConfig: isLoading,

0 commit comments

Comments
 (0)