@honeybadger-io/react-native 0.0.6 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/README.md +44 -0
- package/example/package-lock.json +1575 -2021
- package/example/package.json +1 -1
- package/example/yarn.lock +1017 -1075
- package/index.d.ts +61 -0
- package/index.js +53 -4
- package/package.json +7 -6
- package/tsconfig.json +11 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export default honeybadger;
|
|
2
|
+
declare namespace honeybadger {
|
|
3
|
+
/**
|
|
4
|
+
* Initialize and configure the Honeybadger React Native library.
|
|
5
|
+
* @param {string} apiKey - Your Honeybadger API key.
|
|
6
|
+
* @param {boolean} [reportErrors=true] reportErrors - Whether to send error reports to Honeybadger (disable for dev environments, etc.)
|
|
7
|
+
* @param {string=} revision - The git revision of the current build.
|
|
8
|
+
* @param {string=} projectRoot - The path to the project root.
|
|
9
|
+
*/
|
|
10
|
+
function configure(apiKey: string, reportErrors?: boolean, revision?: string, projectRoot?: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Initialize and configure the Honeybadger React Native library.
|
|
13
|
+
* @param {string} apiKey - Your Honeybadger API key.
|
|
14
|
+
* @param {boolean} [reportErrors=true] reportErrors - Whether to send error reports to Honeybadger (disable for dev environments, etc.)
|
|
15
|
+
* @param {string=} revision - The git revision of the current build.
|
|
16
|
+
* @param {string=} projectRoot - The path to the project root.
|
|
17
|
+
*/
|
|
18
|
+
function configure(apiKey: string, reportErrors?: boolean, revision?: string, projectRoot?: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Send any kind of error, exception, object, String, etc. to Honeybadger.
|
|
21
|
+
* @param {string|object} err - The error string or object.
|
|
22
|
+
* @param {string|object} additionalData - Additional data to include with the error.
|
|
23
|
+
*/
|
|
24
|
+
function notify(err: any, additionalData: any): void;
|
|
25
|
+
/**
|
|
26
|
+
* Send any kind of error, exception, object, String, etc. to Honeybadger.
|
|
27
|
+
* @param {string|object} err - The error string or object.
|
|
28
|
+
* @param {string|object} additionalData - Additional data to include with the error.
|
|
29
|
+
*/
|
|
30
|
+
function notify(err: any, additionalData: any): void;
|
|
31
|
+
/**
|
|
32
|
+
* Include additional data whenever an error or an exception occurs. This can be called as many times as needed. New context data will be merged with any previously-set context data.
|
|
33
|
+
* @param {object} context - Additional data to include with all errors and exceptions.
|
|
34
|
+
*/
|
|
35
|
+
function setContext(context: any): void;
|
|
36
|
+
/**
|
|
37
|
+
* Include additional data whenever an error or an exception occurs. This can be called as many times as needed. New context data will be merged with any previously-set context data.
|
|
38
|
+
* @param {object} context - Additional data to include with all errors and exceptions.
|
|
39
|
+
*/
|
|
40
|
+
function setContext(context: any): void;
|
|
41
|
+
/**
|
|
42
|
+
* Clears/resets any data previously set through setContext().
|
|
43
|
+
* @param {object=} context - Optional new context to set.
|
|
44
|
+
*/
|
|
45
|
+
function resetContext(context?: any): void;
|
|
46
|
+
/**
|
|
47
|
+
* Clears/resets any data previously set through setContext().
|
|
48
|
+
* @param {object=} context - Optional new context to set.
|
|
49
|
+
*/
|
|
50
|
+
function resetContext(context?: any): void;
|
|
51
|
+
/**
|
|
52
|
+
* Sets the logging level for the Honeybadger library.
|
|
53
|
+
* @param {('debug'|'warning'|'error')} [level=warning] - The logging level.
|
|
54
|
+
*/
|
|
55
|
+
function setLogLevel(level?: "error" | "warning" | "debug"): void;
|
|
56
|
+
/**
|
|
57
|
+
* Sets the logging level for the Honeybadger library.
|
|
58
|
+
* @param {('debug'|'warning'|'error')} [level=warning] - The logging level.
|
|
59
|
+
*/
|
|
60
|
+
function setLogLevel(level?: "error" | "warning" | "debug"): void;
|
|
61
|
+
}
|
package/index.js
CHANGED
|
@@ -14,6 +14,11 @@ let _apiKey = null;
|
|
|
14
14
|
let _initialized = false;
|
|
15
15
|
let _context = {};
|
|
16
16
|
let _logLevel = "warning"; // "error", "warning", "debug"
|
|
17
|
+
let _previousJSGlobalExceptionHandler = null;
|
|
18
|
+
let _revision = "";
|
|
19
|
+
let _projectRoot = "";
|
|
20
|
+
let _reportErrors = true;
|
|
21
|
+
|
|
17
22
|
|
|
18
23
|
|
|
19
24
|
// ----------------------------------------------------------------------------
|
|
@@ -21,7 +26,14 @@ let _logLevel = "warning"; // "error", "warning", "debug"
|
|
|
21
26
|
// ----------------------------------------------------------------------------
|
|
22
27
|
const honeybadger = {
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Initialize and configure the Honeybadger React Native library.
|
|
31
|
+
* @param {string} apiKey - Your Honeybadger API key.
|
|
32
|
+
* @param {boolean} [reportErrors=true] reportErrors - Whether to send error reports to Honeybadger (disable for dev environments, etc.)
|
|
33
|
+
* @param {string=} revision - The git revision of the current build.
|
|
34
|
+
* @param {string=} projectRoot - The path to the project root.
|
|
35
|
+
*/
|
|
36
|
+
configure ( apiKey, reportErrors = true, revision = '', projectRoot = '' )
|
|
25
37
|
{
|
|
26
38
|
if ( !isValidAPIKey(apiKey) )
|
|
27
39
|
{
|
|
@@ -30,6 +42,9 @@ const honeybadger = {
|
|
|
30
42
|
}
|
|
31
43
|
|
|
32
44
|
_apiKey = apiKey.trim();
|
|
45
|
+
_revision = (revision || '').trim();
|
|
46
|
+
_projectRoot = (projectRoot || '').trim();
|
|
47
|
+
_reportErrors = reportErrors;
|
|
33
48
|
|
|
34
49
|
if ( !_initialized )
|
|
35
50
|
{
|
|
@@ -39,7 +54,11 @@ const honeybadger = {
|
|
|
39
54
|
}
|
|
40
55
|
},
|
|
41
56
|
|
|
42
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Send any kind of error, exception, object, String, etc. to Honeybadger.
|
|
59
|
+
* @param {string|object} err - The error string or object.
|
|
60
|
+
* @param {string|object} additionalData - Additional data to include with the error.
|
|
61
|
+
*/
|
|
43
62
|
notify ( err, additionalData )
|
|
44
63
|
{
|
|
45
64
|
if ( !isValidAPIKey(_apiKey) ) {
|
|
@@ -100,6 +119,10 @@ const honeybadger = {
|
|
|
100
119
|
},
|
|
101
120
|
|
|
102
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Include additional data whenever an error or an exception occurs. This can be called as many times as needed. New context data will be merged with any previously-set context data.
|
|
124
|
+
* @param {object} context - Additional data to include with all errors and exceptions.
|
|
125
|
+
*/
|
|
103
126
|
setContext ( context )
|
|
104
127
|
{
|
|
105
128
|
if ( isObject(context) ) {
|
|
@@ -108,12 +131,20 @@ const honeybadger = {
|
|
|
108
131
|
},
|
|
109
132
|
|
|
110
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Clears/resets any data previously set through setContext().
|
|
136
|
+
* @param {object=} context - Optional new context to set.
|
|
137
|
+
*/
|
|
111
138
|
resetContext ( context )
|
|
112
139
|
{
|
|
113
140
|
_context = (isObject(context) ? context : {});
|
|
114
141
|
},
|
|
115
142
|
|
|
116
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Sets the logging level for the Honeybadger library.
|
|
146
|
+
* @param {('debug'|'warning'|'error')} [level=warning] - The logging level.
|
|
147
|
+
*/
|
|
117
148
|
setLogLevel ( level = "warning" )
|
|
118
149
|
{
|
|
119
150
|
if ( !level ) {
|
|
@@ -153,13 +184,26 @@ function isValidAPIKey(apiKey) {
|
|
|
153
184
|
}
|
|
154
185
|
|
|
155
186
|
|
|
156
|
-
|
|
187
|
+
|
|
188
|
+
function setJavaScriptErrorHandler()
|
|
189
|
+
{
|
|
157
190
|
logDebug("Setting up the JavaScript global error handler.");
|
|
191
|
+
|
|
192
|
+
_previousJSGlobalExceptionHandler = global.ErrorUtils.getGlobalHandler();
|
|
193
|
+
|
|
158
194
|
global.ErrorUtils.setGlobalHandler(function(err, isFatal) {
|
|
159
195
|
logDebug("JavaScript global error handler triggered.");
|
|
196
|
+
|
|
160
197
|
onJavaScriptError(err, {
|
|
161
198
|
initialHandler: 'Global JavaScript Error Handler',
|
|
162
199
|
});
|
|
200
|
+
|
|
201
|
+
// Allowing the default error handler to process the error after
|
|
202
|
+
// we're done with it will show the useful RN red info box in dev.
|
|
203
|
+
if ( _previousJSGlobalExceptionHandler && _previousJSGlobalExceptionHandler != this ) {
|
|
204
|
+
logDebug("Passing error to previous error handler.");
|
|
205
|
+
_previousJSGlobalExceptionHandler(err, isFatal);
|
|
206
|
+
}
|
|
163
207
|
});
|
|
164
208
|
}
|
|
165
209
|
|
|
@@ -188,10 +232,13 @@ function setNativeExceptionHandler() {
|
|
|
188
232
|
|
|
189
233
|
|
|
190
234
|
function sendToHoneybadger(payload) {
|
|
191
|
-
if ( !payload || !isValidAPIKey(_apiKey) ) {
|
|
235
|
+
if ( !payload || !isValidAPIKey(_apiKey) || !_reportErrors ) {
|
|
192
236
|
return;
|
|
193
237
|
}
|
|
194
238
|
|
|
239
|
+
|
|
240
|
+
logDebug("Sending error report to Honeybadger...");
|
|
241
|
+
|
|
195
242
|
const params = {
|
|
196
243
|
method: 'POST',
|
|
197
244
|
headers: {
|
|
@@ -243,6 +290,8 @@ function buildPayload ( data ) {
|
|
|
243
290
|
},
|
|
244
291
|
server : {
|
|
245
292
|
environment_name: (__DEV__ ? "development" : "production"),
|
|
293
|
+
project_root: _projectRoot || '',
|
|
294
|
+
revision: _revision || ''
|
|
246
295
|
},
|
|
247
296
|
};
|
|
248
297
|
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@honeybadger-io/react-native",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Honeybadger.io for React Native.",
|
|
5
5
|
"author": "Andrey Butov <andreybutov@antair.com> (https://andreybutov.com)",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"types": "index.d.ts",
|
|
7
8
|
"main": "index.js",
|
|
8
9
|
"scripts": {
|
|
9
10
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
10
11
|
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
"bin": {
|
|
13
|
+
"honeybadger-generate-sourcemaps": "./honeybadger-generate-sourcemaps.sh"
|
|
14
|
+
},
|
|
14
15
|
"repository": {
|
|
15
16
|
"type": "git",
|
|
16
17
|
"url": "git+ssh://git@github.com:honeybadger-io/honeybadger-react-native.git"
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"react": "^16.13.1",
|
|
28
|
-
"react-native": "^0.63.3"
|
|
29
|
+
"react-native": "^0.63.3",
|
|
30
|
+
"typescript": "^4.3.5"
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
|
-
|