Files
AFFiNE/packages/frontend/core/src/bootstrap/telemetry.ts
2025-04-03 11:55:56 +00:00

21 lines
476 B
TypeScript

import { mixpanel, sentry } from '@affine/track';
import { APP_SETTINGS_STORAGE_KEY } from '@toeverything/infra/atom';
mixpanel.init();
sentry.init();
if (typeof localStorage !== 'undefined') {
let enabled = true;
const settingsStr = localStorage.getItem(APP_SETTINGS_STORAGE_KEY);
if (settingsStr) {
const parsed = JSON.parse(settingsStr);
enabled = parsed.enableTelemetry;
}
if (!enabled) {
mixpanel.opt_out_tracking();
sentry.disable();
}
}