From bb02f7027dff8f023c3d0db80a0fc9e9bd6bd0d2 Mon Sep 17 00:00:00 2001 From: Athul Date: Tue, 28 Oct 2025 15:20:59 +0530 Subject: [PATCH] UN-2236 [FEAT] Add build-time PostHog control for on-prem deployments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added build argument to control PostHog analytics at build time, enabling cloud deployments while disabling for on-prem installations. Changes: - Added REACT_APP_ENABLE_POSTHOG build argument to frontend Dockerfile - Defaults to true to maintain cloud behavior - Updated sample.env with PostHog configuration documentation - Default set to false for local development (privacy-first) This provides clean separation between cloud (analytics enabled) and on-prem (analytics disabled) builds without runtime complexity. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- docker/dockerfiles/frontend.Dockerfile | 2 ++ frontend/sample.env | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/docker/dockerfiles/frontend.Dockerfile b/docker/dockerfiles/frontend.Dockerfile index 3c205ffcb6..1a69660fc2 100644 --- a/docker/dockerfiles/frontend.Dockerfile +++ b/docker/dockerfiles/frontend.Dockerfile @@ -23,7 +23,9 @@ CMD ["npm", "start"] ### FOR PRODUCTION ### # Builder stage for production build FROM base AS builder +ARG REACT_APP_ENABLE_POSTHOG=true ENV REACT_APP_BACKEND_URL="" +ENV REACT_APP_ENABLE_POSTHOG=${REACT_APP_ENABLE_POSTHOG} # Copy package files and install dependencies COPY ${BUILD_CONTEXT_PATH}/package.json ${BUILD_CONTEXT_PATH}/package-lock.json ./ diff --git a/frontend/sample.env b/frontend/sample.env index d7d8b7d677..8e09fca6c9 100644 --- a/frontend/sample.env +++ b/frontend/sample.env @@ -1,5 +1,9 @@ REACT_APP_BACKEND_URL=http://localhost:8000 +# Analytics - PostHog (set to false to disable tracking) +# Default: false for local development +REACT_APP_ENABLE_POSTHOG=false + # For development NODE_ENV=development # Enable file watching via polling instead of filesystem events