@honeybadger-io/react-native 0.0.7 → 0.0.10

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/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
@@ -15,6 +15,9 @@ let _initialized = false;
15
15
  let _context = {};
16
16
  let _logLevel = "warning"; // "error", "warning", "debug"
17
17
  let _previousJSGlobalExceptionHandler = null;
18
+ let _revision = "";
19
+ let _projectRoot = "";
20
+ let _reportErrors = true;
18
21
 
19
22
 
20
23
 
@@ -23,7 +26,14 @@ let _previousJSGlobalExceptionHandler = null;
23
26
  // ----------------------------------------------------------------------------
24
27
  const honeybadger = {
25
28
 
26
- configure ( apiKey )
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 = '' )
27
37
  {
28
38
  if ( !isValidAPIKey(apiKey) )
29
39
  {
@@ -32,6 +42,9 @@ const honeybadger = {
32
42
  }
33
43
 
34
44
  _apiKey = apiKey.trim();
45
+ _revision = (revision || '').trim();
46
+ _projectRoot = (projectRoot || '').trim();
47
+ _reportErrors = reportErrors;
35
48
 
36
49
  if ( !_initialized )
37
50
  {
@@ -41,7 +54,11 @@ const honeybadger = {
41
54
  }
42
55
  },
43
56
 
44
-
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
+ */
45
62
  notify ( err, additionalData )
46
63
  {
47
64
  if ( !isValidAPIKey(_apiKey) ) {
@@ -102,6 +119,10 @@ const honeybadger = {
102
119
  },
103
120
 
104
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
+ */
105
126
  setContext ( context )
106
127
  {
107
128
  if ( isObject(context) ) {
@@ -110,12 +131,20 @@ const honeybadger = {
110
131
  },
111
132
 
112
133
 
134
+ /**
135
+ * Clears/resets any data previously set through setContext().
136
+ * @param {object=} context - Optional new context to set.
137
+ */
113
138
  resetContext ( context )
114
139
  {
115
140
  _context = (isObject(context) ? context : {});
116
141
  },
117
142
 
118
143
 
144
+ /**
145
+ * Sets the logging level for the Honeybadger library.
146
+ * @param {('debug'|'warning'|'error')} [level=warning] - The logging level.
147
+ */
119
148
  setLogLevel ( level = "warning" )
120
149
  {
121
150
  if ( !level ) {
@@ -203,10 +232,13 @@ function setNativeExceptionHandler() {
203
232
 
204
233
 
205
234
  function sendToHoneybadger(payload) {
206
- if ( !payload || !isValidAPIKey(_apiKey) ) {
235
+ if ( !payload || !isValidAPIKey(_apiKey) || !_reportErrors ) {
207
236
  return;
208
237
  }
209
238
 
239
+
240
+ logDebug("Sending error report to Honeybadger...");
241
+
210
242
  const params = {
211
243
  method: 'POST',
212
244
  headers: {
@@ -258,6 +290,8 @@ function buildPayload ( data ) {
258
290
  },
259
291
  server : {
260
292
  environment_name: (__DEV__ ? "development" : "production"),
293
+ project_root: _projectRoot || '',
294
+ revision: _revision || ''
261
295
  },
262
296
  };
263
297
 
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@honeybadger-io/react-native",
3
- "version": "0.0.7",
3
+ "version": "0.0.10",
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
- "bin": {
12
- "honeybadger-generate-sourcemaps" : "./honeybadger-generate-sourcemaps.sh"
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"
@@ -20,12 +21,12 @@
20
21
  ],
21
22
  "homepage": "https://github.com/honeybadger-io/honeybadger-react-native",
22
23
  "peerDependencies": {
23
- "react": "^16.13.1",
24
+ "react": ">=16.13.1",
24
25
  "react-native": ">=0.60.0-rc.0 <1.0.x"
25
26
  },
26
27
  "devDependencies": {
27
- "react": "^16.13.1",
28
- "react-native": "^0.63.3"
28
+ "react": "=>16.13.1",
29
+ "react-native": "=>0.63.3",
30
+ "typescript": "^4.3.5"
29
31
  }
30
32
  }
31
-
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "include": ["index.js"],
3
+ "compilerOptions": {
4
+ // Read .js files
5
+ "allowJs": true,
6
+ // Generate d.ts files
7
+ "declaration": true,
8
+ // Only generate d.ts files
9
+ "emitDeclarationOnly": true,
10
+ }
11
+ }