Skip to content

Commit

Permalink
feat(frontend): Move posthog key to config and upgrade posthog-js (#4940
Browse files Browse the repository at this point in the history
)
  • Loading branch information
amanape authored Nov 13, 2024
1 parent 87c0217 commit b3fbbba
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
8 changes: 4 additions & 4 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -120,4 +120,4 @@
"public"
]
}
}
}
5 changes: 3 additions & 2 deletions frontend/public/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"APP_MODE": "oss",
"GITHUB_CLIENT_ID": ""
}
"GITHUB_CLIENT_ID": "",
"POSTHOG_CLIENT_KEY": "phc_3ESMmY9SgqEAGBB6sMGK5ayYHkeUuknH2vP6FmWH9RA"
}
3 changes: 2 additions & 1 deletion frontend/src/api/open-hands.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
17 changes: 14 additions & 3 deletions frontend/src/entry.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit b3fbbba

Please sign in to comment.