fix: prevent sentry from loading when telemetry is disabled (#10543)

Co-authored-by: forehalo <forehalo@gmail.com>
This commit is contained in:
hackerESQ
2025-03-05 06:09:38 -06:00
committed by GitHub
parent b247b8e26c
commit fed0e0add3
16 changed files with 122 additions and 200 deletions
@@ -0,0 +1,20 @@
import { enableAutoTrack, mixpanel, sentry } from '@affine/track';
import { appSettingAtom } from '@toeverything/infra';
import { useAtomValue } from 'jotai/react';
import { useLayoutEffect } from 'react';
export function Telemetry() {
const settings = useAtomValue(appSettingAtom);
useLayoutEffect(() => {
if (settings.enableTelemetry === false) {
sentry.disable();
mixpanel.opt_out_tracking();
return;
} else {
sentry.enable();
mixpanel.opt_in_tracking();
return enableAutoTrack(document.body, mixpanel.track);
}
}, [settings.enableTelemetry]);
return null;
}