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

View File

@@ -8,7 +8,6 @@ import { useAppUpdater } from '@affine/core/components/hooks/use-app-updater';
import { UrlService } from '@affine/core/modules/url';
import { appIconMap, appNames } from '@affine/core/utils/channel';
import { useI18n } from '@affine/i18n';
import { mixpanel } from '@affine/track';
import { ArrowRightSmallIcon, OpenInNewIcon } from '@blocksuite/icons/rc';
import { useServices } from '@toeverything/infra';
import { useCallback } from 'react';
@@ -47,11 +46,6 @@ export const AboutAffine = () => {
const onSwitchTelemetry = useCallback(
(checked: boolean) => {
if (!checked) {
mixpanel.opt_out_tracking();
} else {
mixpanel.opt_in_tracking();
}
updateSettings('enableTelemetry', checked);
},
[updateSettings]

View File

@@ -1,17 +0,0 @@
import { enableAutoTrack, mixpanel } 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) {
mixpanel.opt_out_tracking();
return;
} else {
return enableAutoTrack(document.body, mixpanel.track);
}
}, [settings.enableTelemetry]);
return null;
}