Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

FEAT: Allow Disabling Posthog via ENV Variable (#453)

Tahier Hussain9693199c84f4
diff --git a/README.md b/README.md
index 900514fda..1408c983b 100644
--- a/README.md
+++ b/README.md
@@ -142,4 +142,4 @@ Contributions are welcome! Please read [CONTRIBUTE.md](CONTRIBUTE.md) for furthe
## 📊 A note on analytics
-In full disclosure, Unstract integrates Posthog to track usage analytics. As you can inspect the relevant code here, we collect the minimum possible metrics.
+In full disclosure, Unstract integrates Posthog to track usage analytics. As you can inspect the relevant code here, we collect the minimum possible metrics. Posthog can be disabled if desired by setting `REACT_APP_ENABLE_POSTHOG` to `false` in the frontend's .env file.
diff --git a/frontend/src/index.js b/frontend/src/index.js
index 832ec14b6..0d0585f73 100644
--- a/frontend/src/index.js
+++ b/frontend/src/index.js
@@ -8,13 +8,19 @@ import { LazyLoader } from "./components/widgets/lazy-loader/LazyLoader.jsx";
import { SocketProvider } from "./helpers/SocketContext.js";
import "./index.css";
-const API_KEY = "phc_PTafesyRuRB5hceRILaNPeyu2IDuzPshyjIPYGvgoBd"; // gitleaks:allow
-const API_HOST = "https://eu.i.posthog.com/";
-posthog.init(API_KEY, {
- api_host: API_HOST,
- capture_pageview: false,
- autocapture: false,
-});
+const enablePosthog = process.env.REACT_APP_ENABLE_POSTHOG;
+if (enablePosthog !== "false") {
+ // Define the PostHog API key and host URL
+ const API_KEY = "phc_PTafesyRuRB5hceRILaNPeyu2IDuzPshyjIPYGvgoBd"; // gitleaks:allow
+ const API_HOST = "https://eu.i.posthog.com/";
+
+ // Initialize PostHog with the specified API key and host
+ posthog.init(API_KEY, {
+ api_host: API_HOST,
+ capture_pageview: false,
+ autocapture: false,
+ });
+}
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(