chore(electron): re-enable sentry for electron (#7898)

related
https://github.com/toeverything/AFFiNE/pull/7001
This commit is contained in:
pengx17
2024-08-17 04:32:49 +00:00
parent f324fa4719
commit 23c73243ab
5 changed files with 482 additions and 17 deletions
@@ -2,6 +2,8 @@ import './security-restrictions';
import path from 'node:path';
import * as Sentry from '@sentry/electron/main';
import { IPCMode } from '@sentry/electron/main';
import { app } from 'electron';
import { createApplicationMenu } from './application-menu/create';
@@ -12,6 +14,7 @@ import { registerEvents } from './events';
import { registerHandlers } from './handlers';
import { logger } from './logger';
import { registerProtocol } from './protocol';
import { isOnline } from './ui';
import { registerUpdater } from './updater';
import { launch } from './windows-manager/launcher';
import { launchStage } from './windows-manager/stage';
@@ -75,3 +78,18 @@ app
.then(createApplicationMenu)
.then(registerUpdater)
.catch(e => console.error('Failed create window:', e));
if (process.env.SENTRY_RELEASE) {
// https://docs.sentry.io/platforms/javascript/guides/electron/
Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: process.env.BUILD_TYPE ?? 'development',
ipcMode: IPCMode.Protocol,
transportOptions: {
maxAgeDays: 30,
maxQueueSize: 100,
shouldStore: () => !isOnline,
shouldSend: () => isOnline,
},
});
}
@@ -1,3 +1,5 @@
import '@sentry/electron/preload';
import { contextBridge } from 'electron';
import { appInfo, getElectronAPIs } from './electron-api';