11import "source-map-support/register" ;
2+ import * as Sentry from "@sentry/electron" ;
23
3- import { app , dialog } from "electron" ;
4+ import { app , dialog , shell } from "electron" ;
45import { init as initSocket , socket } from "./managers/socketManager" ;
56import { update as initAutoLaunch } from "./managers/launchManager" ;
6- import { checkForUpdate } from "./util/updateChecker" ;
77import { TrayManager } from "./managers/trayManager" ;
8+ import { settings } from "./managers/settingsManager" ;
9+ import { checkForUpdate } from "./util/updateChecker" ;
810
911export let trayManager : TrayManager ;
1012
@@ -13,6 +15,32 @@ export let trayManager: TrayManager;
1315//* When app is ready
1416export let updateCheckerInterval = null ;
1517app . whenReady ( ) . then ( async ( ) => {
18+ if ( settings . get ( "firstLaunch" ) ) {
19+ settings . set ( "firstLaunch" , false ) ;
20+ dialog
21+ . showMessageBox ( {
22+ message : "Welcome to PreMiD!" ,
23+ detail :
24+ "In order to work, the browser extension is also required, would you like to install it now?" ,
25+ buttons : [ "I already have it" , "Show me" ] ,
26+ type : "question" ,
27+ cancelId : 0 ,
28+ defaultId : 0 ,
29+ checkboxLabel : "Also enable automatic crash reporting" ,
30+ checkboxChecked : true
31+ } )
32+ . then ( async value => {
33+ if ( value . checkboxChecked ) await initReporter ( true ) ;
34+ switch ( value . response ) {
35+ case 1 :
36+ shell . openExternal ( "https://premid.app/downloads#ext-downloads" ) ;
37+ break ;
38+ }
39+ } ) ;
40+ } else {
41+ await initReporter ( ) ;
42+ }
43+
1644 trayManager = new TrayManager ( ) ;
1745 await initAutoLaunch ( ) ;
1846 await initSocket ( ) ;
@@ -25,6 +53,16 @@ app.whenReady().then(async () => {
2553 }
2654} ) ;
2755
56+ async function initReporter ( firstLaunch : boolean = false ) {
57+ if ( firstLaunch ) settings . set ( "improvementProgramme" , true ) ;
58+ if ( settings . get ( "improvementProgramme" ) ) {
59+ console . log ( "Initializing Sentry..." ) ;
60+ Sentry . init ( {
61+ dsn : process . env . DSN
62+ } ) ;
63+ }
64+ }
65+
2866//* If second instance started, close old one
2967app . on ( "second-instance" , ( ) => app . exit ( 0 ) ) ;
3068
0 commit comments