Skip to content

πŸ™Œ OpenHands: AI-Driven Development

feat(frontend): Move posthog key to config and upgrade posthog-js (#4940)

sp.wackb3fbbbaa9d35
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index bb18dc8b46..7a19eb1d65 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -26,7 +26,7 @@
"isbot": "^5.1.17",
"jose": "^5.9.4",
"monaco-editor": "^0.52.0",
- "posthog-js": "^1.176.0",
+ "posthog-js": "^1.184.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-highlight": "^0.15.0",
@@ -19749,9 +19749,9 @@
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ=="
},
"node_modules/posthog-js": {
- "version": "1.176.0",
- "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.176.0.tgz",
- "integrity": "sha512-T5XKNtRzp7q6CGb7Vc7wAI76rWap9fiuDUPxPsyPBPDkreKya91x9RIsSapAVFafwD1AEin1QMczCmt9Le9BWw==",
+ "version": "1.184.1",
+ "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.184.1.tgz",
+ "integrity": "sha512-q/1Kdard5SZnL2smrzeKcD+RuUi2PnbidiN4D3ThK20bNrhy5Z2heIy9SnRMvEiARY5lcQ7zxmDCAKPBKGSOtQ==",
"dependencies": {
"core-js": "^3.38.1",
"fflate": "^0.4.8",
diff --git a/frontend/package.json b/frontend/package.json
index 9d09d967fb..635daf05bd 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -25,7 +25,7 @@
"isbot": "^5.1.17",
"jose": "^5.9.4",
"monaco-editor": "^0.52.0",
- "posthog-js": "^1.176.0",
+ "posthog-js": "^1.184.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-highlight": "^0.15.0",
@@ -120,4 +120,4 @@
"public"
]
}
-}
+}
\ No newline at end of file
diff --git a/frontend/public/config.json b/frontend/public/config.json
index 49dd5e4362..94900dcbaf 100644
--- a/frontend/public/config.json
+++ b/frontend/public/config.json
@@ -1,4 +1,5 @@
{
"APP_MODE": "oss",
- "GITHUB_CLIENT_ID": ""
-}
+ "GITHUB_CLIENT_ID": "",
+ "POSTHOG_CLIENT_KEY": "phc_3ESMmY9SgqEAGBB6sMGK5ayYHkeUuknH2vP6FmWH9RA"
+}
\ No newline at end of file
diff --git a/frontend/src/api/open-hands.types.ts b/frontend/src/api/open-hands.types.ts
index a562267363..46b59db579 100644
--- a/frontend/src/api/open-hands.types.ts
+++ b/frontend/src/api/open-hands.types.ts
@@ -43,5 +43,6 @@ export interface Feedback {
export interface GetConfigResponse {
APP_MODE: "saas" | "oss";
- GITHUB_CLIENT_ID: string | null;
+ GITHUB_CLIENT_ID: string;
+ POSTHOG_CLIENT_KEY: string;
}
diff --git a/frontend/src/entry.client.tsx b/frontend/src/entry.client.tsx
index 4fe347f703..cb8f3d16f0 100644
--- a/frontend/src/entry.client.tsx
+++ b/frontend/src/entry.client.tsx
@@ -12,15 +12,26 @@ import { Provider } from "react-redux";
import posthog from "posthog-js";
import "./i18n";
import store from "./store";
+import OpenHands from "./api/open-hands";
function PosthogInit() {
+ const [key, setKey] = React.useState<string | null>(null);
+
React.useEffect(() => {
- posthog.init("phc_3ESMmY9SgqEAGBB6sMGK5ayYHkeUuknH2vP6FmWH9RA", {
- api_host: "https://us.i.posthog.com",
- person_profiles: "identified_only",
+ OpenHands.getConfig().then((config) => {
+ setKey(config.POSTHOG_CLIENT_KEY);
});
}, []);
+ React.useEffect(() => {
+ if (key) {
+ posthog.init(key, {
+ api_host: "https://us.i.posthog.com",
+ person_profiles: "identified_only",
+ });
+ }
+ }, [key]);
+
return null;
}