Skip to content

Commit e8676d3

Browse files
author
shehabeldeenibrahim
committed
Fixed parseErrorStack params based on RN Version in reportJSException
1 parent d39165f commit e8676d3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

modules/CrashReporting.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,17 @@ export default {
2424
* @param errorObject Error object to be sent to Instabug's servers
2525
*/
2626
reportJSException: function(errorObject) {
27-
let jsStackTrace = InstabugUtils.parseErrorStack(errorObject);
27+
let jsStackTrace;
28+
if (Platform.hasOwnProperty("constants")) {
29+
// RN version >= 0.63
30+
if (Platform.constants.reactNativeVersion.minor >= 64)
31+
// RN version >= 0.64 -> Stacktrace as string
32+
jsStackTrace = InstabugUtils.parseErrorStack(errorObject.stack);
33+
// RN version == 0.63 -> Stacktrace as string
34+
else jsStackTrace = InstabugUtils.parseErrorStack(errorObject);
35+
}
36+
// RN version < 0.63 -> Stacktrace as string
37+
else jsStackTrace = InstabugUtils.parseErrorStack(errorObject);
2838
var jsonObject = {
2939
message: errorObject.name + ' - ' + errorObject.message,
3040
os: Platform.OS,

0 commit comments

Comments
 (0)