Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

Commit

Permalink
fix: test mode and sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSim committed Apr 20, 2023
1 parent 40d21cb commit 1ba5946
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
19 changes: 12 additions & 7 deletions src/fsolauncher/library/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ function strFormat( str, ...args ) {
function initSentry() {
const { init } = require( '@sentry/electron' );
const { dsn } = require( '../../sentry.config' );
init( {
dsn,
beforeSend( event ) {
// Remove all possible PII from the event
return sanitizeEvent( event );
},
} );
if ( ! dsn.startsWith( 'SENTRY' ) ) {
init( {
dsn,
beforeSend( event ) {
if ( global.isTestMode ) {
return null;
}
// Remove all possible PII from the event
return sanitizeEvent( event );
},
} );
}
}

function sanitizeEvent( event ) {
Expand Down
11 changes: 6 additions & 5 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
require( 'fix-path' )(); // Fix $PATH on darwin
require( 'v8-compile-cache' );

global.isTestMode = process.argv.includes( '--test-mode' );
if ( global.isTestMode ) {
console.log( 'CI: Test mode enabled' );
}

// Init Sentry error logging
const { initSentry } = require( './fsolauncher/library/utils' );
initSentry();

const {
app, BrowserWindow, shell, Tray, Menu, nativeImage
} = require( 'electron' );
const isTestMode = process.argv.includes( '--test-mode' );
if ( isTestMode ) {
console.log( 'CI: Test mode enabled' );
}
// Switches for https://github.com/ItsSim/fsolauncher/issues/47
//app.commandLine.appendSwitch( 'no-sandbox' );
//app.commandLine.appendSwitch( 'disable-gpu' );
Expand Down Expand Up @@ -226,7 +227,7 @@ function CreateWindow() {
return { action: 'deny' };
} );

if ( isTestMode ) {
if ( global.isTestMode ) {
global.willQuit = true;
Window.webContents.on( 'did-finish-load', () => {
app.quit();
Expand Down

0 comments on commit 1ba5946

Please sign in to comment.