Skip to content

Commit 807f995

Browse files
author
farfromrefug
committed
fix(android): another fix for Sentry options init
1 parent b68c6a5 commit 807f995

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

src/sentry/wrapper.android.ts

+31-8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ import { SDK_NAME } from './version';
1111
import { CLog, CLogTypes } from '.';
1212
import { rewriteFrameIntegration } from './integrations/default';
1313

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+
1426
function capitalize(value) {
1527
return value.charAt(0).toUpperCase() + value.substr(1);
1628
}
@@ -80,10 +92,10 @@ export namespace NATIVE {
8092
const stackFrame = new io.sentry.protocol.SentryStackFrame();
8193
stackFrame.setFunction(methodName);
8294
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));
8597
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));
8799
frames.add(stackFrame);
88100
}
89101
nStackTrace.setFrames(frames);
@@ -96,7 +108,7 @@ export namespace NATIVE {
96108
const nException = new io.sentry.protocol.SentryException();
97109
nException.setType(type);
98110
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()));
100112

101113
nException.setStacktrace(convertToNativeJavascriptStacktrace(stack));
102114
actualExceptions.add(nException);
@@ -379,10 +391,21 @@ export namespace NATIVE {
379391
const methodName = `set${capitalize(k)}`;
380392
const value = otherOptions[k];
381393
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+
}
386409
} else {
387410
config[methodName](value);
388411
}

0 commit comments

Comments
 (0)