refactor(core): adjust sentry config (#10631)

This commit is contained in:
EYHN
2025-03-05 11:18:06 +00:00
parent bb4240f6ef
commit 0015bfbaf2
9 changed files with 46 additions and 61 deletions

View File

@@ -1,19 +1,7 @@
import { notify } from '@affine/component';
import { I18n } from '@affine/i18n';
import {
init,
reactRouterV6BrowserTracingIntegration,
setTags,
} from '@sentry/react';
import { OnEvent, Service } from '@toeverything/infra';
import { debounce } from 'lodash-es';
import { useEffect } from 'react';
import {
createRoutesFromChildren,
matchRoutes,
useLocation,
useNavigationType,
} from 'react-router-dom';
import { AuthService, DefaultServerService, ServersService } from '../../cloud';
import { ApplicationStarted } from '../../lifecycle';
@@ -45,48 +33,10 @@ export class DesktopApiService extends Service {
}
private setupStartListener() {
this.setupSentry();
this.setupCommonUIEvents();
this.setupAuthRequestEvent();
}
private setupSentry() {
if (
BUILD_CONFIG.debug ||
window.SENTRY_RELEASE ||
this.api.appInfo.windowName !== 'main'
) {
// https://docs.sentry.io/platforms/javascript/guides/electron/
init({
dsn: process.env.SENTRY_DSN,
environment: process.env.BUILD_TYPE ?? 'development',
integrations: [
reactRouterV6BrowserTracingIntegration({
useEffect,
useLocation,
useNavigationType,
createRoutesFromChildren,
matchRoutes,
}),
],
});
setTags({
appVersion: BUILD_CONFIG.appVersion,
editorVersion: BUILD_CONFIG.editorVersion,
});
this.api.handler.ui
.handleNetworkChange(navigator.onLine)
.catch(console.error);
window.addEventListener('offline', () => {
this.api.handler.ui.handleNetworkChange(false).catch(console.error);
});
window.addEventListener('online', () => {
this.api.handler.ui.handleNetworkChange(true).catch(console.error);
});
}
}
private setupCommonUIEvents() {
if (this.api.appInfo.windowName !== 'main') {
return;