mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 05:14:54 +00:00
fix(core): opt out telemetry if it was set to false (#6335)
This commit is contained in:
20
packages/frontend/core/src/telemetry.tsx
Normal file
20
packages/frontend/core/src/telemetry.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user