mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-16 05:47:09 +08:00
chore(core): split sentry and setup into web/electron (#6357)
This commit is contained in:
@@ -2,6 +2,7 @@ import './security-restrictions';
|
||||
|
||||
import path from 'node:path';
|
||||
|
||||
import { init, IPCMode } from '@sentry/electron/main';
|
||||
import { app } from 'electron';
|
||||
|
||||
import { createApplicationMenu } from './application-menu/create';
|
||||
@@ -12,6 +13,7 @@ import { registerEvents } from './events';
|
||||
import { registerHandlers } from './handlers';
|
||||
import { logger } from './logger';
|
||||
import { registerProtocol } from './protocol';
|
||||
import { isOnline } from './ui/handlers';
|
||||
import { registerUpdater } from './updater';
|
||||
import { launch } from './windows-manager/launcher';
|
||||
import { launchStage } from './windows-manager/stage';
|
||||
@@ -64,6 +66,19 @@ app.on('activate', () => {
|
||||
|
||||
setupDeepLink(app);
|
||||
|
||||
// https://docs.sentry.io/platforms/javascript/guides/electron/
|
||||
if (process.env.SENTRY_DSN) {
|
||||
init({
|
||||
dsn: process.env.SENTRY_DSN,
|
||||
ipcMode: IPCMode.Protocol,
|
||||
transportOptions: {
|
||||
maxQueueAgeDays: 30,
|
||||
maxQueueCount: 100,
|
||||
beforeSend: () => (isOnline ? 'send' : 'queue'),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create app window when background process will be ready
|
||||
*/
|
||||
|
||||
@@ -15,6 +15,8 @@ import { launchStage } from '../windows-manager/stage';
|
||||
import { getChallengeResponse } from './challenge';
|
||||
import { getGoogleOauthCode } from './google-auth';
|
||||
|
||||
export let isOnline = true;
|
||||
|
||||
export const uiHandlers = {
|
||||
isMaximized: async () => {
|
||||
const window = await getMainWindow();
|
||||
@@ -58,6 +60,9 @@ export const uiHandlers = {
|
||||
handleCloseApp: async () => {
|
||||
app.quit();
|
||||
},
|
||||
handleNetworkChange: async (_, _isOnline: boolean) => {
|
||||
isOnline = _isOnline;
|
||||
},
|
||||
getGoogleOauthCode: async () => {
|
||||
return getGoogleOauthCode();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user