@@ -10,6 +10,10 @@ import { utf8ToBytes } from './vendor';
1010import { SDK_NAME } from './version' ;
1111import { CLog , CLogTypes } from '.' ;
1212
13+
14+ function capitalize ( value ) {
15+ return value . charAt ( 0 ) . toUpperCase ( ) + value . substr ( 1 ) ;
16+ }
1317let encoder ;
1418function strToTypedArray ( str : string ) {
1519 if ( ! encoder ) {
@@ -374,72 +378,80 @@ export namespace NATIVE {
374378 configure ( config : io . sentry . android . core . SentryAndroidOptions ) {
375379 // config.setLogger(new io.sentry.SystemOutLogger());
376380 try {
377- if ( options . dsn ) {
378- config . setDsn ( options . dsn ) ;
379- } else {
380- config . setDsn ( '' ) ;
381- }
382381
383- if ( options . sendClientReports ) {
384- config . setSendClientReports ( options . sendClientReports ) ;
385- }
382+ const { dsn, debug, enableNativeCrashHandling, beforeSend, beforeBreadcrumb, headers, ...otherOptions } = options ;
386383
387- if ( options . maxBreadcrumbs ) {
388- config . setMaxBreadcrumbs ( options . maxBreadcrumbs ) ;
384+ config . setDsn ( dsn || '' ) ;
385+ if ( ! ! debug ) {
386+ io . sentry . Sentry . setLevel ( io . sentry . SentryLevel . DEBUG ) ;
387+ config . setDebug ( debug ) ;
389388 }
389+ Object . keys ( otherOptions ) . forEach ( k => {
390+ const methodName = `set${ capitalize ( k ) } ` ;
391+ if ( typeof config [ methodName ] === 'function' ) {
392+ config [ methodName ] ( otherOptions [ k ] ) ;
393+ }
394+ } ) ;
395+ // if (options.sendClientReports) {
396+ // config.setSendClientReports(options.sendClientReports);
397+ // }
390398
391- if ( options . maxCacheItems ) {
392- config . setMaxCacheItems ( options . maxCacheItems ) ;
393- }
399+ // if (options.maxBreadcrumbs ) {
400+ // config.setMaxBreadcrumbs (options.maxBreadcrumbs );
401+ // }
394402
395- if ( ! ! options . environment ) {
396- config . setEnvironment ( options . environment ) ;
397- } else {
398- config . setEnvironment ( 'javascript' ) ;
399- }
400- if ( ! ! options . debug ) {
401- io . sentry . Sentry . setLevel ( io . sentry . SentryLevel . DEBUG ) ;
402- config . setDebug ( options . debug ) ;
403- }
404- if ( ! ! options . release ) {
405- config . setRelease ( options . release ) ;
406- }
407- if ( ! ! options . dist ) {
408- config . setDist ( options . dist ) ;
409- }
410- if ( options . enableAutoSessionTracking !== undefined ) {
411- config . setEnableAutoSessionTracking ( options . enableAutoSessionTracking ) ;
412- }
413- if ( options . sessionTrackingIntervalMillis !== undefined ) {
414- config . setSessionTrackingIntervalMillis ( options . sessionTrackingIntervalMillis ) ;
415- }
416- if ( options . shutdownTimeout !== undefined ) {
417- config . setShutdownTimeoutMillis ( options . shutdownTimeout ) ;
418- }
419- if ( options . enableNdkScopeSync !== undefined ) {
420- config . setEnableScopeSync ( options . enableNdkScopeSync ) ;
421- }
422- if ( options . attachStacktrace !== undefined ) {
423- config . setAttachStacktrace ( options . attachStacktrace ) ;
424- }
425- if ( options . attachThreads !== undefined ) {
426- // JS use top level stacktraces and android attaches Threads which hides them so
427- // by default we hide.
428- config . setAttachThreads ( options . attachThreads ) ;
429- }
430- if ( options . attachScreenshot !== undefined ) {
431- config . setAttachScreenshot ( options . attachScreenshot ) ;
432- }
433- if ( options . sendDefaultPii !== undefined ) {
434- config . setSendDefaultPii ( options . sendDefaultPii ) ;
435- }
436- if ( options . enableNdk !== undefined ) {
437- config . setEnableNdk ( options . enableNdk ) ;
438- }
403+ // if (options.maxCacheItems) {
404+ // config.setMaxCacheItems(options.maxCacheItems);
405+ // }
439406
440- if ( options . maxQueueSize !== undefined ) {
441- config . setMaxQueueSize ( options . maxQueueSize ) ;
442- }
407+ // if (!!options.environment) {
408+ // config.setEnvironment(options.environment);
409+ // } else {
410+ // config.setEnvironment('javascript');
411+ // }
412+ // if (!!options.debug) {
413+ // io.sentry.Sentry.setLevel(io.sentry.SentryLevel.DEBUG);
414+ // config.setDebug(options.debug);
415+ // }
416+ // if (!!options.release) {
417+ // config.setRelease(options.release);
418+ // }
419+ // if (!!options.dist) {
420+ // config.setDist(options.dist);
421+ // }
422+ // if (options.enableAutoSessionTracking !== undefined) {
423+ // config.setEnableAutoSessionTracking(options.enableAutoSessionTracking);
424+ // }
425+ // if (options.sessionTrackingIntervalMillis !== undefined) {
426+ // config.setSessionTrackingIntervalMillis(options.sessionTrackingIntervalMillis);
427+ // }
428+ // if (options.shutdownTimeout !== undefined) {
429+ // config.setShutdownTimeoutMillis(options.shutdownTimeout);
430+ // }
431+ // if (options.enableNdkScopeSync !== undefined) {
432+ // config.setEnableScopeSync(options.enableNdkScopeSync);
433+ // }
434+ // if (options.attachStacktrace !== undefined) {
435+ // config.setAttachStacktrace(options.attachStacktrace);
436+ // }
437+ // if (options.attachThreads !== undefined) {
438+ // // JS use top level stacktraces and android attaches Threads which hides them so
439+ // // by default we hide.
440+ // config.setAttachThreads(options.attachThreads);
441+ // }
442+ // if (options.attachScreenshot !== undefined) {
443+ // config.setAttachScreenshot(options.attachScreenshot);
444+ // }
445+ // if (options.sendDefaultPii !== undefined) {
446+ // config.setSendDefaultPii(options.sendDefaultPii);
447+ // }
448+ // if (options.enableNdk !== undefined) {
449+ // config.setEnableNdk(options.enableNdk);
450+ // }
451+
452+ // if (options.maxQueueSize !== undefined) {
453+ // config.setMaxQueueSize(options.maxQueueSize);
454+ // }
443455
444456 // if (options.enableAutoPerformanceTracking === true) {
445457
@@ -460,7 +472,7 @@ export namespace NATIVE {
460472 // }
461473
462474 // config.setEnableNdk(true);
463- if ( options . enableNativeCrashHandling === false ) {
475+ if ( enableNativeCrashHandling === false ) {
464476 const integrations = config . getIntegrations ( ) ;
465477 const size = integrations . size ( ) ;
466478 for ( let index = size - 1 ; index >= 0 ; index -- ) {
@@ -484,9 +496,9 @@ export namespace NATIVE {
484496 create ( sopt : io . sentry . SentryOptions , requestDetails : io . sentry . RequestDetails ) {
485497 const map = requestDetails . getHeaders ( ) ;
486498 map . put ( 'X-Forwarded-Protocol' , 'https' ) ;
487- if ( options . headers ) {
488- Object . keys ( options . headers ) . forEach ( k => {
489- map . put ( k , options . headers [ k ] ) ;
499+ if ( headers ) {
500+ Object . keys ( headers ) . forEach ( k => {
501+ map . put ( k , headers [ k ] ) ;
490502 } ) ;
491503 }
492504 return new io . sentry . transport . AsyncHttpTransport (
@@ -496,9 +508,9 @@ export namespace NATIVE {
496508 config . setBeforeSend (
497509 new io . sentry . SentryOptions . BeforeSendCallback ( {
498510 execute ( event , hint ) {
499- if ( options . beforeSend ) {
511+ if ( beforeSend ) {
500512 // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
501- options . beforeSend ( event as any , hint as any ) ;
513+ beforeSend ( event as any , hint as any ) ;
502514 }
503515
504516 // we use this callback to actually try and get the JS stack when a native error is catched
@@ -537,8 +549,8 @@ export namespace NATIVE {
537549 config . setBeforeBreadcrumb (
538550 new io . sentry . SentryOptions . BeforeBreadcrumbCallback ( {
539551 execute ( breadcrumb : io . sentry . Breadcrumb , hint : io . sentry . Hint ) {
540- if ( options . beforeBreadcrumb ) {
541- return options . beforeBreadcrumb ( breadcrumb as any , hint ) as any ;
552+ if ( beforeBreadcrumb ) {
553+ return beforeBreadcrumb ( breadcrumb as any , hint ) as any ;
542554 } else {
543555 return breadcrumb ;
544556 }
0 commit comments