mirror of
https://github.com/status-im/instabug-reactnative.git
synced 2025-03-03 14:40:54 +00:00
Remove capture errors
This commit is contained in:
parent
f4edf879a2
commit
cabacb6222
29
index.js
29
index.js
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
import {NativeModules, NativeAppEventEmitter, Platform} from 'react-native';
|
import {NativeModules, NativeAppEventEmitter, Platform} from 'react-native';
|
||||||
let {Instabug} = NativeModules;
|
let {Instabug} = NativeModules;
|
||||||
import instabugUtils from './utils/instabugUtils.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instabug
|
* Instabug
|
||||||
@ -475,34 +474,6 @@ module.exports = {
|
|||||||
Instabug.isInstabugNotification(dict, isInstabugNotificationCallback);
|
Instabug.isInstabugNotification(dict, isInstabugNotificationCallback);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Report a caught exception to Instabug dashboard
|
|
||||||
*
|
|
||||||
* @param error the error to be reported
|
|
||||||
* @param errorIdentifier used to group issues manually reported
|
|
||||||
* @throws Error if error param type wasn't Error
|
|
||||||
*/
|
|
||||||
reportJsException: function (error, errorIdentifier) {
|
|
||||||
if (!error || !error instanceof Error)
|
|
||||||
throw new TypeError("Invalid param type at param1, Expected Error");
|
|
||||||
|
|
||||||
let jsStackTrace = instabugUtils.parseErrorStack(error);
|
|
||||||
if (!errorIdentifier)
|
|
||||||
Instabug.reportJsException(jsStackTrace, error.message, null);
|
|
||||||
else if (errorIdentifier) {
|
|
||||||
Instabug.reportJsException(jsStackTrace, error.message, errorIdentifier);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Report un-caught exceptions to Instabug dashboard
|
|
||||||
* We don't send exceptions from __DEV__, since it's way too noisy!
|
|
||||||
*/
|
|
||||||
captureJsErrors(){
|
|
||||||
if (Platform.OS === 'android')
|
|
||||||
instabugUtils.captureJsErrors();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add file to attached files with each report being sent.
|
* Add file to attached files with each report being sent.
|
||||||
* A new copy of the file at fileURL will be attached with each bug report being sent. The file is only copied
|
* A new copy of the file at fileURL will be attached with each bug report being sent. The file is only copied
|
||||||
|
@ -3,9 +3,6 @@
|
|||||||
"version": "1.0.7",
|
"version": "1.0.7",
|
||||||
"description": "React Native plugin for integrating the Instabug SDK",
|
"description": "React Native plugin for integrating the Instabug SDK",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
|
||||||
},
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/Instabug/instabug-reactnative.git"
|
"url": "git+https://github.com/Instabug/instabug-reactnative.git"
|
||||||
@ -28,8 +25,5 @@
|
|||||||
"android": {
|
"android": {
|
||||||
"packageInstance": "new RNInstabugReactnativePackage(MainApplication.this)"
|
"packageInstance": "new RNInstabugReactnativePackage(MainApplication.this)"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"stacktrace-parser": "0.1.3"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
import {NativeModules, Platform} from 'react-native';
|
|
||||||
let {Instabug} = NativeModules;
|
|
||||||
let stacktraceParser = require('stacktrace-parser');
|
|
||||||
|
|
||||||
let parseErrorStack = (error) => {
|
|
||||||
if (!error || !error.stack) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return Array.isArray(error.stack) ? error.stack :
|
|
||||||
stacktraceParser.parse(error.stack);
|
|
||||||
};
|
|
||||||
|
|
||||||
let init = () => {
|
|
||||||
if (__DEV__) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const originalHandler = global.ErrorUtils.getGlobalHandler();
|
|
||||||
|
|
||||||
function errorHandler(e, isFatal) {
|
|
||||||
let jsStackTrace = parseErrorStack(error);
|
|
||||||
Instabug.reportJsException(jsStackTrace, e.message, "unhandled");
|
|
||||||
if (originalHandler) {
|
|
||||||
if (Platform.OS === 'ios') {
|
|
||||||
originalHandler(e, isFatal);
|
|
||||||
} else {
|
|
||||||
setTimeout(() => {
|
|
||||||
originalHandler(e, isFatal);
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
global.ErrorUtils.setGlobalHandler(errorHandler);
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
parseErrorStack: parseErrorStack,
|
|
||||||
captureJsErrors: init
|
|
||||||
};
|
|
Loading…
x
Reference in New Issue
Block a user