mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-13 16:16:46 +08:00
21 lines
601 B
TypeScript
21 lines
601 B
TypeScript
import { appSettingAtom } from '@toeverything/infra';
|
|
import { useAtomValue } from 'jotai/react';
|
|
import mixpanel from 'mixpanel-browser';
|
|
import { useLayoutEffect } from 'react';
|
|
|
|
export function Telemetry() {
|
|
const settings = useAtomValue(appSettingAtom);
|
|
useLayoutEffect(() => {
|
|
if (process.env.MIXPANEL_TOKEN) {
|
|
mixpanel.init(process.env.MIXPANEL_TOKEN || '', {
|
|
track_pageview: true,
|
|
persistence: 'localStorage',
|
|
});
|
|
}
|
|
if (settings.enableTelemetry === false) {
|
|
mixpanel.opt_out_tracking();
|
|
}
|
|
}, [settings.enableTelemetry]);
|
|
return null;
|
|
}
|