console . log ( '####### ------ APP MODULES START ' ) ; import { Trace , Application , UnhandledErrorEventData , LaunchEventData , ApplicationEventData , DiscardedErrorEventData } from '@nativescript/core' ; Trace . addCategories ( Trace . categories . NativeLifecycle ) ; Trace . addCategories ( Trace . categories . Navigation ) ; Trace . addCategories ( Trace . categories . Transition ) ; Trace . enable ( ) ; var countResume = 0 ; var countSuspend = 0 ; Application . on ( 'displayed' , ( args ) => { const uptime = global . android ? ( < any > org ) . nativescript . Process . getUpTime : ( < any > global ) . __tns_uptime ; console . log ( 'Startup time: ' + uptime ( ) + 'ms.' ) ; } ) ; Application . on ( 'uncaughtError' , ( args ) => { const error = args . error ; console . warn ( error . message ) ; if ( error . nativeError ) { console . warn ( 'native error: ' + error . nativeError ) ; } } ) ; Application . on ( Application . launchEvent , function ( args ) { if ( args . android ) { console . log ( '### Launched application with: ' + args . android + '.' ) ; } else if ( args . ios !== undefined ) { console . log ( '### Launched application with: ' + args . ios ) ; } } ) ; Application . on ( Application . suspendEvent , function ( args ) { if ( args . android ) { console . log ( '#' + ++ countSuspend + '# SuspendEvent Activity: ' + args . android ) ; } else if ( args . ios ) { console . log ( '#' + ++ countSuspend + '# SuspendEvent UIApplication: ' + args . ios ) ; } } ) ; Application . on ( Application . resumeEvent , function ( args ) { if ( args . android ) { console . log ( '#' + ++ countResume + '# ResumeEvent Activity: ' + args . android ) ; } else if ( args . ios ) { console . log ( '#' + ++ countResume + '# ResumeEvent UIApplication: ' + args . ios ) ; } } ) ; Application . on ( Application . exitEvent , function ( args ) { if ( args . android ) { console . log ( '### ExitEvent Activity: ' + args . android ) ; } else if ( args . ios ) { console . log ( '### ExitEvent UIApplication: ' + args . ios ) ; } } ) ; Application . on ( Application . lowMemoryEvent , function ( args ) { if ( args . android ) { console . log ( '### LowMemoryEvent Activity: ' + args . android ) ; } else if ( args . ios ) { console . log ( '### LowMemoryEvent UIApplication: ' + args . ios ) ; } } ) ; Application . on ( Application . uncaughtErrorEvent , function ( args ) { console . log ( '### NativeScriptError: ' + args . error ) ; console . log ( '### nativeException: ' + ( < any > args . error ) . nativeException ) ; console . log ( '### stackTrace: ' + ( < any > args . error ) . stackTrace ) ; console . log ( '### stack: ' + args . error . stack ) ; } ) ; Application . on ( Application . discardedErrorEvent , function ( args ) { console . log ( '### [Discarded] NativeScriptError: ' + args . error ) ; console . log ( '### [Discarded] nativeException: ' + ( < any > args . error ) . nativeException ) ; console . log ( '### [Discarded] stackTrace: ' + ( < any > args . error ) . stackTrace ) ; console . log ( '### [Discarded] stack: ' + args . error . stack ) ; } ) ; Application . run ( { moduleName : 'app-root' } ) ;