@@ -14,7 +14,7 @@ export namespace NSSentry {
1414 return {
1515 id : packageInfo . packageName ,
1616 version : packageInfo . versionName ,
17- build : packageInfo . versionCode
17+ build : packageInfo . versionCode ,
1818 } ;
1919 }
2020 function eventLevel ( event ) {
@@ -37,7 +37,7 @@ export namespace NSSentry {
3737 return null ;
3838 }
3939 const map = new java . util . HashMap < string , string > ( ) ;
40- Object . keys ( obj ) . forEach ( k => {
40+ Object . keys ( obj ) . forEach ( ( k ) => {
4141 map . put ( k , obj [ k ] ) ;
4242 } ) ;
4343 return map ;
@@ -150,7 +150,7 @@ export namespace NSSentry {
150150 nEvent . setExceptions ( exceptions ) ;
151151 }
152152 export function sendEvent ( event : Event ) : Promise < Response > {
153- return new Promise ( resolve => {
153+ return new Promise ( ( resolve ) => {
154154 const nEvent = new io . sentry . core . SentryEvent ( ) ;
155155 if ( event . event_id ) {
156156 nEvent . setEventId ( new io . sentry . core . protocol . SentryId ( event . event_id ) ) ;
@@ -181,7 +181,7 @@ export namespace NSSentry {
181181
182182 try {
183183 if ( breadcrumb . data ) {
184- Object . keys ( breadcrumb . data ) . forEach ( k => {
184+ Object . keys ( breadcrumb . data ) . forEach ( ( k ) => {
185185 const value = breadcrumb . data [ k ] ;
186186 // in case a `status_code` entry got accidentally stringified as a float
187187 if ( k === 'status_code' ) {
@@ -222,7 +222,7 @@ export namespace NSSentry {
222222 }
223223
224224 if ( event . extra ) {
225- Object . keys ( event . extra ) . forEach ( k => {
225+ Object . keys ( event . extra ) . forEach ( ( k ) => {
226226 const value = event . extra [ k ] ;
227227 nEvent . setExtra ( k , typeof value === 'string' ? value : JSON . stringify ( value ) ) ;
228228 } ) ;
@@ -238,7 +238,7 @@ export namespace NSSentry {
238238 }
239239
240240 if ( event . tags ) {
241- Object . keys ( event . tags ) . forEach ( k => {
241+ Object . keys ( event . tags ) . forEach ( ( k ) => {
242242 const value = event . tags [ k ] ;
243243 nEvent . setTag ( k , value || 'INVALID_TAG' ) ;
244244 } ) ;
@@ -278,7 +278,7 @@ export namespace NSSentry {
278278 nEvent . setLevel ( eventLevel ( event . level ) ) ;
279279 }
280280 if ( event . contexts ) {
281- Object . keys ( event . contexts ) . forEach ( k => {
281+ Object . keys ( event . contexts ) . forEach ( ( k ) => {
282282 // const value = event.contexts[k];
283283 // const context = new io.sentry.core.protocol.Contexts();
284284 // nEvent.setTag(k, value || 'INVALID_TAG');
@@ -300,7 +300,7 @@ export namespace NSSentry {
300300 const id = io . sentry . core . Sentry . captureEvent ( nEvent ) ;
301301 // io.sentry.core.Sentry.flush(0);
302302 resolve ( { status : Status . Success , id } ) ;
303- } ) . catch ( err => {
303+ } ) . catch ( ( err ) => {
304304 console . error ( 'error sending sentry event' , err , err . stack ) ;
305305 return Promise . reject ( err ) ;
306306 } ) as any ;
@@ -324,18 +324,15 @@ export namespace NSSentry {
324324 appAndroid . context ,
325325 new io . sentry . core . Sentry . OptionsConfiguration ( {
326326 configure ( config ) {
327+ config . setLogger ( new io . sentry . core . SystemOutLogger ( ) ) ;
328+
329+ // config.setDiagnosticLevel(io.sentry.core.SentryLevel.DEBUG);
330+ // io.sentry.core.Sentry.setLevel(io.sentry.core.SentryLevel.DEBUG);
327331 config . setDsn ( dsnString ) ;
328332 config . setEnvironment ( 'javascript' ) ;
329333 if ( ! ! options . environment ) {
330334 config . setEnvironment ( options . environment ) ;
331335 }
332- config . setLogger (
333- new io . sentry . core . ILogger ( {
334- log ( param0 : io . sentry . core . SentryLevel , param1 : any , param2 : any , param3 ?: native . Array < any > ) {
335- console . log ( 'sentry' , param0 , param1 , param2 , param3 ) ;
336- }
337- } )
338- ) ;
339336 if ( ! ! options . debug ) {
340337 config . setDebug ( options . debug ) ;
341338 }
@@ -345,26 +342,35 @@ export namespace NSSentry {
345342 if ( ! ! options . dist ) {
346343 config . setDist ( options . dist ) ;
347344 }
345+ if ( options . enableAutoSessionTracking !== undefined ) {
346+ config . setEnableSessionTracking ( options . enableAutoSessionTracking ) ;
347+ }
348348
349349 config . setEnableNdk ( true ) ;
350-
351350 const integrations = config . getIntegrations ( ) ;
352351 const size = integrations . size ( ) ;
353352 if ( options . enableNativeCrashHandling === false ) {
354- let indexToRemove = - 1 ;
355- for ( let index = 0 ; index < size ; index ++ ) {
353+ for ( let index = size - 1 ; index >= 0 ; index -- ) {
356354 const inte = integrations . get ( index ) ;
357- if ( inte instanceof io . sentry . core . UncaughtExceptionHandlerIntegration ) {
358- indexToRemove = index ;
355+ if (
356+ inte instanceof io . sentry . core . UncaughtExceptionHandlerIntegration ||
357+ inte instanceof io . sentry . android . core . AnrIntegration ||
358+ inte instanceof io . sentry . android . core . NdkIntegration
359+ ) {
360+ integrations . remove ( index ) ;
359361 }
360362 }
361- if ( indexToRemove > - 1 ) {
362- integrations . remove ( indexToRemove ) ;
363- }
364363 }
365364 config . setBeforeSend (
366365 new io . sentry . core . SentryOptions . BeforeSendCallback ( {
367366 execute ( event , hint ) {
367+ if ( options . beforeSend ) {
368+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
369+ options . beforeSend ( event as any , hint ) ;
370+ }
371+ const map = new java . util . HashMap ( ) ;
372+ map . put ( 'X-Forwarded-Protocol' , 'https' ) ;
373+ event . getRequest ( ) . setHeaders ( map ) ;
368374 // we use this callback to actually try and get the JS stack when a native error is catched
369375 try {
370376 const ex : io . sentry . core . protocol . SentryException = event . getExceptions ( ) . get ( 0 ) ;
@@ -380,18 +386,18 @@ export namespace NSSentry {
380386 const stack = parseErrorStack ( { stack : jsStackTrace } as any ) ;
381387
382388 const convertedFrames = convertNativescriptFramesToSentryFrames ( stack as any ) ;
383- convertedFrames . forEach ( frame => rewriteFrameIntegration . _iteratee ( frame ) ) ;
389+ convertedFrames . forEach ( ( frame ) => rewriteFrameIntegration . _iteratee ( frame ) ) ;
384390 addExceptionInterface ( event , 'Error' , throwable . getMessage ( ) , convertedFrames . reverse ( ) ) ;
385391 }
386392 }
387393 }
388394 }
389395 } catch ( e ) { }
390396 return event ;
391- }
397+ } ,
392398 } )
393399 ) ;
394- }
400+ } ,
395401 } )
396402 ) ;
397403 initialized = true ;
@@ -426,14 +432,11 @@ export namespace NSSentry {
426432 throw new java . lang . RuntimeException ( 'TEST - Sentry Client Crash' ) ;
427433 }
428434 export function deviceContexts ( ) : Promise < any > {
429- return new Promise ( resolve => {
435+ return new Promise ( ( resolve ) => {
430436 const nEvent = new io . sentry . core . SentryEvent ( ) ;
431437
432438 const params = { } ;
433- const it = nEvent
434- . getContexts ( )
435- . entrySet ( )
436- . iterator ( ) ;
439+ const it = nEvent . getContexts ( ) . entrySet ( ) . iterator ( ) ;
437440 let value , pair , key ;
438441 while ( it . hasNext ( ) ) {
439442 pair = it . next ( ) ;
0 commit comments