mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 04:48:53 +00:00
fix(core): opt out telemetry if it was set to false (#6335)
This commit is contained in:
@@ -111,7 +111,7 @@ export const AboutAffine = () => {
|
||||
desc={t['com.affine.telemetry.enable.desc']()}
|
||||
>
|
||||
<Switch
|
||||
checked={appSettings.enableTelemetry}
|
||||
checked={appSettings.enableTelemetry !== false}
|
||||
onChange={onSwitchTelemetry}
|
||||
/>
|
||||
</SettingRow>
|
||||
|
||||
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