chore(core): split sentry and setup into web/electron (#6357)

This commit is contained in:
Brooooooklyn
2024-03-28 10:24:25 +00:00
parent 88d04e23e9
commit c2847e2082
17 changed files with 463 additions and 198 deletions

View File

@@ -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
*/

View File

@@ -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();
},