mirror of
https://github.com/upscayl/upscayl.git
synced 2025-02-15 10:22:37 +01:00
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
|
import { enableContributionAtom } from "@/atoms/user-settings-atom";
|
||
|
import { useAtomValue } from "jotai";
|
||
|
import posthog from "posthog-js";
|
||
|
import { PostHogProvider } from "posthog-js/react";
|
||
|
import { useEffect } from "react";
|
||
|
|
||
|
const PostHogProviderWrapper = ({
|
||
|
children,
|
||
|
}: {
|
||
|
children: React.ReactNode;
|
||
|
}) => {
|
||
|
const enableContribution = useAtomValue(enableContributionAtom);
|
||
|
|
||
|
useEffect(() => {
|
||
|
posthog.init("phc_QMcmlmComdofjfaRPzoN4KV9ziV2KgOwAOVyu4J3dIc", {
|
||
|
api_host: "https://us.i.posthog.com",
|
||
|
person_profiles: "identified_only",
|
||
|
autocapture: false,
|
||
|
capture_pageview: false,
|
||
|
capture_pageleave: false,
|
||
|
disable_session_recording: true,
|
||
|
loaded: async (posthog) => {
|
||
|
if (process.env.NODE_ENV === "development") posthog.debug();
|
||
|
const systemInfo = await window.electron.getSystemInfo();
|
||
|
const appVersion = await window.electron.getAppVersion();
|
||
|
// Set super properties that will be included with all events
|
||
|
posthog.register({
|
||
|
...systemInfo,
|
||
|
appVersion,
|
||
|
$ip: "0.0.0.0",
|
||
|
$geoip_disable: true,
|
||
|
});
|
||
|
// Capture initial session start
|
||
|
posthog.capture("app_launched", {
|
||
|
...systemInfo,
|
||
|
appVersion,
|
||
|
$ip: "0.0.0.0",
|
||
|
$geoip_disable: true,
|
||
|
});
|
||
|
},
|
||
|
});
|
||
|
}, []);
|
||
|
|
||
|
if (!enableContribution) return <>{children}</>;
|
||
|
|
||
|
return <PostHogProvider client={posthog}>{children}</PostHogProvider>;
|
||
|
};
|
||
|
|
||
|
export default PostHogProviderWrapper;
|