Elffuss BraidHub

kikocis/continue public

99fe51849b68 · 1.0 KiBRawPermalink
1import posthog from "posthog-js";
2import { PostHogProvider } from "posthog-js/react";
3import { PropsWithChildren, useEffect } from "react";
4import { useAppSelector } from "../redux/hooks";
5
6const CustomPostHogProvider = ({ children }: PropsWithChildren) => {
7 const allowAnonymousTelemetry = useAppSelector(
8 (store) => store?.config?.config?.allowAnonymousTelemetry,
9 );
10
11 useEffect(() => {
12 if (allowAnonymousTelemetry) {
13 posthog.init("phc_JS6XFROuNbhJtVCEdTSYk6gl5ArRrTNMpCcguAXlSPs", {
14 api_host: "https://app.posthog.com",
15 disable_session_recording: true,
16 autocapture: false,
17 // // We need to manually track pageviews since we're a SPA
18 capture_pageleave: false,
19 capture_pageview: false,
20 });
21 posthog.identify(window.vscMachineId);
22 posthog.opt_in_capturing();
23 } else {
24 posthog.opt_out_capturing();
25 }
26 }, [allowAnonymousTelemetry]);
27
28 return <PostHogProvider client={posthog}>{children}</PostHogProvider>;
29};
30
31export default CustomPostHogProvider;