11import { Application } from '@nativescript/core' ;
2- import { Event , Response , Status } from '@sentry/types' ;
2+ import { android as androidApp } from '@nativescript/core/application' ;
3+ import { Breadcrumb , Event , Response , Status , User } from '@sentry/types' ;
34import { NativescriptOptions , _processLevel } from './backend' ;
4- import { rewriteFrameIntegration } from './sdk' ;
55import { convertNativescriptFramesToSentryFrames , parseErrorStack } from './integrations/debugsymbolicator' ;
66import { UserFeedback } from './nssentry' ;
7- import { android as androidApp } from '@nativescript/core/application' ;
8- import { Breadcrumb , User } from '@sentry/types' ;
7+ import { rewriteFrameIntegration } from './sdk' ;
98
109export namespace NSSentry {
1110 export const nativeClientAvailable = true ;
@@ -82,10 +81,10 @@ export namespace NSSentry {
8281 }
8382 return nUser ;
8483 }
85- const mJsModuleIdPattern = new RegExp ( '(?:^|[/\\\\])(\\d+\\.js)$' ) . compile ( ) ;
84+ const mJsModuleIdPattern = new RegExp ( '(?:^|[/\\\\])(\\d+\\.js)$' ) ;
8685 function stackFrameToModuleId ( frame : { file ?: string } ) {
8786 if ( ! ! frame . file ) {
88- const matcher = frame . file . match ( mJsModuleIdPattern ) ;
87+ const matcher = mJsModuleIdPattern . exec ( frame . file ) ;
8988 if ( matcher ) {
9089 return matcher [ 1 ] + ':' ;
9190 }
@@ -209,20 +208,20 @@ export namespace NSSentry {
209208
210209 function addPackages ( event : io . sentry . SentryEvent , sdk : io . sentry . protocol . SdkVersion ) {
211210 const eventSdk = event . getSdk ( ) ;
212- if ( eventSdk != null && eventSdk . getName ( ) === " sentry.javascript.react-native" && sdk != null ) {
211+ if ( eventSdk != null && eventSdk . getName ( ) === ' sentry.javascript.react-native' && sdk != null ) {
213212 const sentryPackages = sdk . getPackages ( ) ;
214213 if ( sentryPackages != null ) {
215214 for ( let index = 0 ; index < sentryPackages . size ( ) ; index ++ ) {
216215 const sentryPackage = sentryPackages . get ( index ) ;
217216 eventSdk . addPackage ( sentryPackage . getName ( ) , sentryPackage . getVersion ( ) ) ;
218-
217+
219218 }
220219 }
221220 const integrations = sdk . getIntegrations ( ) ;
222221 if ( integrations != null ) {
223222 for ( let index = 0 ; index < integrations . size ( ) ; index ++ ) {
224223 eventSdk . addIntegration ( integrations . get ( index ) ) ;
225-
224+
226225 }
227226 }
228227 event . setSdk ( eventSdk ) ;
@@ -326,7 +325,7 @@ export namespace NSSentry {
326325 throwable = mechanism ;
327326 }
328327 if ( throwable ) {
329- const jsStackTrace : string = ( throwable as any ) . getIncomingStackTrace ( ) ;
328+ const jsStackTrace : string = ( throwable ) . getIncomingStackTrace ( ) ;
330329 if ( jsStackTrace ) {
331330 const stack = parseErrorStack ( { stack : jsStackTrace } as any ) ;
332331
@@ -337,8 +336,8 @@ export namespace NSSentry {
337336 }
338337 }
339338 } catch ( e ) { }
340- event . setTag ( " event.origin" , " android" ) ;
341- event . setTag ( " event.environment" , " nativescript" ) ;
339+ event . setTag ( ' event.origin' , ' android' ) ;
340+ event . setTag ( ' event.environment' , ' nativescript' ) ;
342341 addPackages ( event , config . getSdkVersion ( ) ) ;
343342 return event ;
344343 } ,
@@ -378,17 +377,17 @@ export namespace NSSentry {
378377 // }
379378
380379 export function fetchNativeSdkInfo ( ) {
381- return { }
380+ return { } ;
382381 }
383382
384383 export function fetchNativeRelease ( ) {
385384 const context = androidApp . context ;
386385 const packageInfo = context . getPackageManager ( ) . getPackageInfo ( context . getPackageName ( ) , 0 ) ;
387386 return {
388- "id" : packageInfo . packageName ,
389- " version" : packageInfo . versionName ,
390- " build" : packageInfo . versionCode + ''
391- }
387+ 'id' : packageInfo . packageName ,
388+ ' version' : packageInfo . versionName ,
389+ ' build' : packageInfo . versionCode + ''
390+ } ;
392391 }
393392
394393 export function closeNativeSdk ( ) {
@@ -437,33 +436,33 @@ export namespace NSSentry {
437436 scope . setUser ( null ) ;
438437 } else {
439438 const userInstance = new io . sentry . protocol . User ( ) ;
440-
439+
441440 if ( user ) {
442441 if ( user . email ) {
443442 userInstance . setEmail ( user . email ) ;
444443 }
445-
444+
446445 if ( user . id ) {
447446 userInstance . setId ( user . id ) ;
448447 }
449-
448+
450449 if ( user . username ) {
451450 userInstance . setUsername ( user . username ) ;
452451 }
453-
452+
454453 if ( user . ip_address ) {
455454 userInstance . setIpAddress ( user . ip_address ) ;
456455 }
457456 }
458-
457+
459458 if ( otherUserKeys ) {
460459 userInstance . setOthers ( getNativeHashMap ( otherUserKeys ) ) ;
461460 }
462461 scope . setUser ( userInstance ) ;
463462 }
464463 }
465464 } ) ) ;
466-
465+
467466 }
468467 export function setTag ( key : string , value : string ) {
469468 io . sentry . Sentry . configureScope ( new io . sentry . ScopeCallback ( {
@@ -486,29 +485,29 @@ export namespace NSSentry {
486485 run ( scope ) {
487486 const breadcrumbInstance = new io . sentry . Breadcrumb ( ) ;
488487
489- if ( breadcrumb . message ) {
490- breadcrumbInstance . setMessage ( breadcrumb . message ) ;
491- }
488+ if ( breadcrumb . message ) {
489+ breadcrumbInstance . setMessage ( breadcrumb . message ) ;
490+ }
492491
493- if ( breadcrumb . type ) {
494- breadcrumbInstance . setType ( breadcrumb . type ) ;
495- }
492+ if ( breadcrumb . type ) {
493+ breadcrumbInstance . setType ( breadcrumb . type ) ;
494+ }
496495
497- if ( breadcrumb . category ) {
498- breadcrumbInstance . setCategory ( breadcrumb . category ) ;
499- }
496+ if ( breadcrumb . category ) {
497+ breadcrumbInstance . setCategory ( breadcrumb . category ) ;
498+ }
500499
501- if ( breadcrumb . level ) {
502- breadcrumbInstance . setLevel ( eventLevel ( breadcrumb . level ) ) ;
503- }
500+ if ( breadcrumb . level ) {
501+ breadcrumbInstance . setLevel ( eventLevel ( breadcrumb . level ) ) ;
502+ }
504503
505- if ( breadcrumb . data ) {
506- Object . keys ( breadcrumb . data ) . forEach ( key => {
507- breadcrumbInstance . setData ( key , breadcrumb . data [ key ] ) ;
508- } )
509- }
504+ if ( breadcrumb . data ) {
505+ Object . keys ( breadcrumb . data ) . forEach ( key => {
506+ breadcrumbInstance . setData ( key , breadcrumb . data [ key ] ) ;
507+ } ) ;
508+ }
510509
511- scope . addBreadcrumb ( breadcrumbInstance ) ;
510+ scope . addBreadcrumb ( breadcrumbInstance ) ;
512511 }
513512 } ) ) ;
514513 }
0 commit comments