@@ -11,6 +11,18 @@ import { SDK_NAME } from './version';
11
11
import { CLog , CLogTypes } from '.' ;
12
12
import { rewriteFrameIntegration } from './integrations/default' ;
13
13
14
+ enum JavaType {
15
+ Long ,
16
+ Boolean ,
17
+ Double
18
+ }
19
+
20
+ const OPTIONS_SPECIAL_TYPES = {
21
+ sampleRate : JavaType . Double ,
22
+ tracesSampleRate : JavaType . Double ,
23
+ enableTracing : JavaType . Boolean ,
24
+ } ;
25
+
14
26
function capitalize ( value ) {
15
27
return value . charAt ( 0 ) . toUpperCase ( ) + value . substr ( 1 ) ;
16
28
}
@@ -80,10 +92,10 @@ export namespace NATIVE {
80
92
const stackFrame = new io . sentry . protocol . SentryStackFrame ( ) ;
81
93
stackFrame . setFunction ( methodName ) ;
82
94
stackFrame . setFilename ( fileName ) ;
83
- stackFrame . setLineno ( new java . lang . Integer ( lineNumber ) ) ;
84
- stackFrame . setColno ( new java . lang . Integer ( column ) ) ;
95
+ stackFrame . setLineno ( java . lang . Integer . valueOf ( lineNumber ) ) ;
96
+ stackFrame . setColno ( java . lang . Integer . valueOf ( column ) ) ;
85
97
stackFrame . setPlatform ( 'javascript' ) ;
86
- stackFrame . setInApp ( new java . lang . Boolean ( frame . in_app || false ) ) ;
98
+ stackFrame . setInApp ( java . lang . Boolean . valueOf ( frame . in_app || false ) ) ;
87
99
frames . add ( stackFrame ) ;
88
100
}
89
101
nStackTrace . setFrames ( frames ) ;
@@ -96,7 +108,7 @@ export namespace NATIVE {
96
108
const nException = new io . sentry . protocol . SentryException ( ) ;
97
109
nException . setType ( type ) ;
98
110
nException . setValue ( value ) ;
99
- nException . setThreadId ( new java . lang . Long ( java . lang . Thread . currentThread ( ) . getId ( ) ) ) ;
111
+ nException . setThreadId ( java . lang . Long . valueOf ( java . lang . Thread . currentThread ( ) . getId ( ) ) ) ;
100
112
101
113
nException . setStacktrace ( convertToNativeJavascriptStacktrace ( stack ) ) ;
102
114
actualExceptions . add ( nException ) ;
@@ -379,10 +391,21 @@ export namespace NATIVE {
379
391
const methodName = `set${ capitalize ( k ) } ` ;
380
392
const value = otherOptions [ k ] ;
381
393
if ( value && typeof config [ methodName ] === 'function' ) {
382
- if ( typeof value === 'number' ) {
383
- config [ methodName ] ( java . lang . Double . valueOf ( value ) ) ;
384
- } else if ( typeof value === 'boolean' ) {
385
- config [ methodName ] ( java . lang . Boolean . valueOf ( value ) ) ;
394
+ if ( OPTIONS_SPECIAL_TYPES [ k ] ) {
395
+ switch ( OPTIONS_SPECIAL_TYPES [ k ] ) {
396
+ case JavaType . Double :
397
+ config [ methodName ] ( java . lang . Double . valueOf ( value ) ) ;
398
+ break ;
399
+ case JavaType . Boolean :
400
+ config [ methodName ] ( java . lang . Boolean . valueOf ( value ) ) ;
401
+ break ;
402
+ case JavaType . Long :
403
+ config [ methodName ] ( java . lang . Long . valueOf ( value ) ) ;
404
+ break ;
405
+ default :
406
+ config [ methodName ] ( value ) ;
407
+ break ;
408
+ }
386
409
} else {
387
410
config [ methodName ] ( value ) ;
388
411
}
0 commit comments