mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-09 05:05:52 +08:00
fix: prevent sentry from loading when telemetry is disabled (#10543)
Co-authored-by: forehalo <forehalo@gmail.com>
This commit is contained in:
@@ -2,3 +2,4 @@
|
||||
import './env';
|
||||
import './public-path';
|
||||
import './polyfill/browser';
|
||||
import './telemetry';
|
||||
|
||||
@@ -2,3 +2,4 @@
|
||||
import './env';
|
||||
import './public-path';
|
||||
import './polyfill/electron';
|
||||
import './telemetry';
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import { mixpanel, sentry } from '@affine/track';
|
||||
|
||||
mixpanel.init();
|
||||
sentry.init();
|
||||
+4
-1
@@ -1,4 +1,4 @@
|
||||
import { enableAutoTrack, mixpanel } from '@affine/track';
|
||||
import { enableAutoTrack, mixpanel, sentry } from '@affine/track';
|
||||
import { appSettingAtom } from '@toeverything/infra';
|
||||
import { useAtomValue } from 'jotai/react';
|
||||
import { useLayoutEffect } from 'react';
|
||||
@@ -7,9 +7,12 @@ 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]);
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user