@honeybadger-io/react 1.0.2 → 2.1.0
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/README.md +12 -1
- package/dist/DefaultErrorComponent.d.ts +13 -0
- package/dist/HoneybadgerErrorBoundary.d.ts +24 -0
- package/dist/honeybadger-react.cjs.js +45 -194
- package/dist/honeybadger-react.cjs.js.map +1 -1
- package/dist/honeybadger-react.esm.js +38 -194
- package/dist/honeybadger-react.esm.js.map +1 -1
- package/dist/honeybadger-react.js +51 -200
- package/dist/honeybadger-react.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.test.d.ts +1 -0
- package/package.json +27 -30
- package/CHANGELOG.md +0 -55
- package/honeybadger-react.d.ts +0 -15
package/README.md
CHANGED
|
@@ -54,11 +54,12 @@ REACT_APP_HONEYBADGER_API_KEY=b425b636 npm run start
|
|
|
54
54
|
|
|
55
55
|
This will serve the demo app with hot reload at localhost:3000
|
|
56
56
|
|
|
57
|
-
For a detailed explanation on how hot reloading works, check out the [
|
|
57
|
+
For a detailed explanation on how hot reloading works, check out the [documentation](https://webpack.js.org/concepts/hot-module-replacement/).
|
|
58
58
|
|
|
59
59
|
## Changelog
|
|
60
60
|
|
|
61
61
|
See https://github.com/honeybadger-io/honeybadger-react/blob/master/CHANGELOG.md
|
|
62
|
+
Changelog is automatically generated with [our release automation process](#release-automation).
|
|
62
63
|
|
|
63
64
|
## Contributing
|
|
64
65
|
|
|
@@ -92,6 +93,16 @@ npm run start
|
|
|
92
93
|
2. To publish the release, use `npm publish`. See `npm help publish` for
|
|
93
94
|
documentation.
|
|
94
95
|
|
|
96
|
+
### Release Automation
|
|
97
|
+
|
|
98
|
+
We use [Ship.js](https://github.com/algolia/shipjs) to automate releasing.
|
|
99
|
+
|
|
100
|
+
Ship.js creates a PR once per week when unreleased changes are present. You can also trigger a release PR by saying "@shipjs prepare" in any issue or pull request comment on GitHub.
|
|
101
|
+
|
|
102
|
+
#### Troubleshooting a failed Ship.js release
|
|
103
|
+
|
|
104
|
+
If a ship.js release fails, you need to revert the release commit and delete the release branch (e.g `releases/v1.1.0`)
|
|
105
|
+
Then, you can debug the issue by simulating the release process locally (`npm run release -- --dry-run --yes --no-browse`).
|
|
95
106
|
|
|
96
107
|
### License
|
|
97
108
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { Component } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
export interface DefaultErrorComponentProps {
|
|
4
|
+
error: Error | null;
|
|
5
|
+
info: React.ErrorInfo | null;
|
|
6
|
+
}
|
|
7
|
+
export default class DefaultErrorComponent extends Component<DefaultErrorComponentProps, {}> {
|
|
8
|
+
static propTypes: {
|
|
9
|
+
error: PropTypes.Requireable<object>;
|
|
10
|
+
info: PropTypes.Requireable<object>;
|
|
11
|
+
};
|
|
12
|
+
render(): JSX.Element;
|
|
13
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { Component, ReactNode } from 'react';
|
|
2
|
+
import HoneybadgerClient from '@honeybadger-io/js/dist/browser/types/core/client';
|
|
3
|
+
import { DefaultErrorComponentProps } from "./DefaultErrorComponent";
|
|
4
|
+
import PropTypes from "prop-types";
|
|
5
|
+
interface HoneybadgerErrorBoundaryProps {
|
|
6
|
+
honeybadger: HoneybadgerClient;
|
|
7
|
+
ErrorComponent?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
interface HoneybadgerErrorBoundaryState extends DefaultErrorComponentProps {
|
|
10
|
+
errorOccurred: boolean;
|
|
11
|
+
}
|
|
12
|
+
export default class HoneybadgerErrorBoundary extends Component<HoneybadgerErrorBoundaryProps, HoneybadgerErrorBoundaryState> {
|
|
13
|
+
static propTypes: {
|
|
14
|
+
honeybadger: PropTypes.Validator<object>;
|
|
15
|
+
children: PropTypes.Requireable<PropTypes.ReactElementLike>;
|
|
16
|
+
ErrorComponent: PropTypes.Requireable<PropTypes.ReactElementLike | ((...args: any[]) => any)>;
|
|
17
|
+
};
|
|
18
|
+
constructor(props: HoneybadgerErrorBoundaryProps);
|
|
19
|
+
static getDerivedStateFromError(error: Error): HoneybadgerErrorBoundaryState;
|
|
20
|
+
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
|
|
21
|
+
private getErrorComponent;
|
|
22
|
+
render(): JSX.Element;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -1,213 +1,64 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var js = require('@honeybadger-io/js');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
3
7
|
var React = require('react');
|
|
4
8
|
var PropTypes = require('prop-types');
|
|
5
9
|
|
|
6
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
11
|
|
|
12
|
+
var js__default = /*#__PURE__*/_interopDefaultLegacy(js);
|
|
8
13
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
9
14
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function _defineProperties(target, props) {
|
|
18
|
-
for (var i = 0; i < props.length; i++) {
|
|
19
|
-
var descriptor = props[i];
|
|
20
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
21
|
-
descriptor.configurable = true;
|
|
22
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
23
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
28
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
29
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
30
|
-
return Constructor;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function _defineProperty(obj, key, value) {
|
|
34
|
-
if (key in obj) {
|
|
35
|
-
Object.defineProperty(obj, key, {
|
|
36
|
-
value: value,
|
|
37
|
-
enumerable: true,
|
|
38
|
-
configurable: true,
|
|
39
|
-
writable: true
|
|
40
|
-
});
|
|
41
|
-
} else {
|
|
42
|
-
obj[key] = value;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return obj;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function _inherits(subClass, superClass) {
|
|
49
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
50
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
54
|
-
constructor: {
|
|
55
|
-
value: subClass,
|
|
56
|
-
writable: true,
|
|
57
|
-
configurable: true
|
|
16
|
+
class DefaultErrorComponent extends React.Component {
|
|
17
|
+
render() {
|
|
18
|
+
return (jsxRuntime.jsxs("div", { className: 'error', children: [jsxRuntime.jsx("div", { children: "An Error Occurred" }), jsxRuntime.jsx("div", { children: JSON.stringify(this.props.error, null, 2) }), jsxRuntime.jsx("div", { children: this.props.info ? JSON.stringify(this.props.info, null, 2) : '' })] }));
|
|
58
19
|
}
|
|
59
|
-
});
|
|
60
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function _getPrototypeOf(o) {
|
|
64
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
65
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
66
|
-
};
|
|
67
|
-
return _getPrototypeOf(o);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function _setPrototypeOf(o, p) {
|
|
71
|
-
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
72
|
-
o.__proto__ = p;
|
|
73
|
-
return o;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
return _setPrototypeOf(o, p);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function _isNativeReflectConstruct() {
|
|
80
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
81
|
-
if (Reflect.construct.sham) return false;
|
|
82
|
-
if (typeof Proxy === "function") return true;
|
|
83
|
-
|
|
84
|
-
try {
|
|
85
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
86
|
-
return true;
|
|
87
|
-
} catch (e) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function _assertThisInitialized(self) {
|
|
93
|
-
if (self === void 0) {
|
|
94
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return self;
|
|
98
20
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return function _createSuperInternal() {
|
|
114
|
-
var Super = _getPrototypeOf(Derived),
|
|
115
|
-
result;
|
|
116
|
-
|
|
117
|
-
if (hasNativeReflectConstruct) {
|
|
118
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
119
|
-
|
|
120
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
121
|
-
} else {
|
|
122
|
-
result = Super.apply(this, arguments);
|
|
21
|
+
DefaultErrorComponent.propTypes = {
|
|
22
|
+
error: PropTypes__default["default"].object,
|
|
23
|
+
info: PropTypes__default["default"].object
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
class HoneybadgerErrorBoundary extends React.Component {
|
|
27
|
+
constructor(props) {
|
|
28
|
+
super(props);
|
|
29
|
+
this.state = {
|
|
30
|
+
error: null,
|
|
31
|
+
info: null,
|
|
32
|
+
errorOccurred: false
|
|
33
|
+
};
|
|
123
34
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
var DefaultErrorComponent = /*#__PURE__*/function (_Component) {
|
|
130
|
-
_inherits(DefaultErrorComponent, _Component);
|
|
131
|
-
|
|
132
|
-
var _super = _createSuper(DefaultErrorComponent);
|
|
133
|
-
|
|
134
|
-
function DefaultErrorComponent() {
|
|
135
|
-
_classCallCheck(this, DefaultErrorComponent);
|
|
136
|
-
|
|
137
|
-
return _super.apply(this, arguments);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
_createClass(DefaultErrorComponent, [{
|
|
141
|
-
key: "render",
|
|
142
|
-
value: function render() {
|
|
143
|
-
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
144
|
-
className: "error"
|
|
145
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", null, "An Error Occurred"), /*#__PURE__*/React__default['default'].createElement("div", null, this.error), /*#__PURE__*/React__default['default'].createElement("div", null, this.info));
|
|
35
|
+
static getDerivedStateFromError(error) {
|
|
36
|
+
return { error: error, errorOccurred: true, info: null };
|
|
146
37
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}(React.Component);
|
|
151
|
-
|
|
152
|
-
var HoneyBadgerErrorBoundary = /*#__PURE__*/function (_Component2) {
|
|
153
|
-
_inherits(HoneyBadgerErrorBoundary, _Component2);
|
|
154
|
-
|
|
155
|
-
var _super2 = _createSuper(HoneyBadgerErrorBoundary);
|
|
156
|
-
|
|
157
|
-
function HoneyBadgerErrorBoundary(props) {
|
|
158
|
-
var _this;
|
|
159
|
-
|
|
160
|
-
_classCallCheck(this, HoneyBadgerErrorBoundary);
|
|
161
|
-
|
|
162
|
-
_this = _super2.call(this, props);
|
|
163
|
-
_this.state = {
|
|
164
|
-
error: null,
|
|
165
|
-
info: null,
|
|
166
|
-
errorOccurred: false
|
|
167
|
-
};
|
|
168
|
-
return _this;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
_createClass(HoneyBadgerErrorBoundary, [{
|
|
172
|
-
key: "componentDidCatch",
|
|
173
|
-
value: function componentDidCatch(error, info) {
|
|
174
|
-
this.setState({
|
|
175
|
-
errorOccurred: true,
|
|
176
|
-
error: error,
|
|
177
|
-
info: info
|
|
178
|
-
});
|
|
179
|
-
this.props.honeybadger.notify(error, {
|
|
180
|
-
context: info
|
|
181
|
-
});
|
|
38
|
+
componentDidCatch(error, errorInfo) {
|
|
39
|
+
this.setState({ errorOccurred: true, error: error, info: errorInfo });
|
|
40
|
+
this.props.honeybadger.notify(error, { context: errorInfo });
|
|
182
41
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
var ErrorComponent = this.props.ErrorComponent;
|
|
188
|
-
return ErrorComponent ? /*#__PURE__*/React__default['default'].createElement(ErrorComponent, this.state) : /*#__PURE__*/React__default['default'].createElement(DefaultErrorComponent, null);
|
|
189
|
-
} else {
|
|
190
|
-
return this.props.children;
|
|
191
|
-
}
|
|
42
|
+
getErrorComponent() {
|
|
43
|
+
return this.props.ErrorComponent
|
|
44
|
+
? React__default["default"].createElement(this.props.ErrorComponent, this.state)
|
|
45
|
+
: jsxRuntime.jsx(DefaultErrorComponent, { ...this.state });
|
|
192
46
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
errorOccurred: true,
|
|
198
|
-
error: error
|
|
199
|
-
};
|
|
47
|
+
render() {
|
|
48
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: this.state.errorOccurred
|
|
49
|
+
? this.getErrorComponent()
|
|
50
|
+
: this.props.children }));
|
|
200
51
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
52
|
+
}
|
|
53
|
+
HoneybadgerErrorBoundary.propTypes = {
|
|
54
|
+
honeybadger: PropTypes__default["default"].object.isRequired,
|
|
55
|
+
children: PropTypes__default["default"].element,
|
|
56
|
+
ErrorComponent: PropTypes__default["default"].oneOfType([PropTypes__default["default"].element, PropTypes__default["default"].func])
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
Object.defineProperty(exports, 'Honeybadger', {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function () { return js__default["default"]; }
|
|
210
62
|
});
|
|
211
|
-
|
|
212
|
-
module.exports = HoneyBadgerErrorBoundary;
|
|
63
|
+
exports.HoneybadgerErrorBoundary = HoneybadgerErrorBoundary;
|
|
213
64
|
//# sourceMappingURL=honeybadger-react.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"honeybadger-react.cjs.js","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"honeybadger-react.cjs.js","sources":["../../src/DefaultErrorComponent.tsx","../../src/HoneybadgerErrorBoundary.tsx"],"sourcesContent":["import React, {Component} from \"react\"\nimport PropTypes from \"prop-types\";\n\nexport interface DefaultErrorComponentProps {\n error: Error | null\n info: React.ErrorInfo | null\n}\n\nexport default class DefaultErrorComponent extends Component<DefaultErrorComponentProps, {}> {\n\n static propTypes = {\n error: PropTypes.object,\n info: PropTypes.object\n }\n\n render() {\n return (\n <div className='error'>\n <div>\n An Error Occurred\n </div>\n <div>\n {JSON.stringify(this.props.error, null, 2)}\n </div>\n <div>\n {this.props.info ? JSON.stringify(this.props.info, null, 2) : ''}\n </div>\n </div>\n )\n }\n}\n","import React, {Component, ReactNode} from 'react'\nimport HoneybadgerClient from '@honeybadger-io/js/dist/browser/types/core/client'\nimport DefaultErrorComponent, {DefaultErrorComponentProps} from \"./DefaultErrorComponent\"\nimport PropTypes from \"prop-types\";\n\ninterface HoneybadgerErrorBoundaryProps {\n honeybadger: HoneybadgerClient\n ErrorComponent?: ReactNode\n}\n\ninterface HoneybadgerErrorBoundaryState extends DefaultErrorComponentProps {\n errorOccurred: boolean\n}\n\nexport default class HoneybadgerErrorBoundary extends Component<HoneybadgerErrorBoundaryProps, HoneybadgerErrorBoundaryState> {\n\n static propTypes = {\n honeybadger: PropTypes.object.isRequired,\n children: PropTypes.element,\n ErrorComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func])\n }\n\n constructor(props: HoneybadgerErrorBoundaryProps) {\n super(props)\n this.state = {\n error: null,\n info: null,\n errorOccurred: false\n }\n }\n\n public static getDerivedStateFromError(error: Error): HoneybadgerErrorBoundaryState {\n return {error: error, errorOccurred: true, info: null}\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n this.setState({errorOccurred: true, error: error, info: errorInfo})\n this.props.honeybadger.notify(error, {context: errorInfo as any})\n }\n\n private getErrorComponent(): ReactNode {\n return this.props.ErrorComponent\n ? React.createElement(this.props.ErrorComponent as any, this.state)\n : <DefaultErrorComponent {...this.state} />\n }\n\n render() {\n return (\n <>\n {this.state.errorOccurred\n ? this.getErrorComponent()\n : this.props.children\n }\n </>\n )\n }\n}\n"],"names":["Component","_jsxs","_jsx","PropTypes","React","_Fragment"],"mappings":";;;;;;;;;;;;;;;AAQqB,MAAA,qBAAsB,SAAQA,eAAyC,CAAA;IAO1F,MAAM,GAAA;QACJ,QACEC,eAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,OAAO,aACpBC,cAEM,CAAA,KAAA,EAAA,EAAA,QAAA,EAAA,mBAAA,EAAA,CAAA,EACNA,cACG,CAAA,KAAA,EAAA,EAAA,QAAA,EAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EACtC,CAAA,EACNA,cACG,CAAA,KAAA,EAAA,EAAA,QAAA,EAAA,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,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AA,EAAA,IAAI,CAAC,KAAK,CAAC,aAAa;AACvB,kBAAE,IAAI,CAAC,iBAAiB,EAAE;kBACxB,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAA,CAEtB,EACJ;KACF;;AAvCM,wBAAA,CAAA,SAAS,GAAG;AACjB,IAAA,WAAW,EAAEF,6BAAS,CAAC,MAAM,CAAC,UAAU;IACxC,QAAQ,EAAEA,6BAAS,CAAC,OAAO;AAC3B,IAAA,cAAc,EAAEA,6BAAS,CAAC,SAAS,CAAC,CAACA,6BAAS,CAAC,OAAO,EAAEA,6BAAS,CAAC,IAAI,CAAC,CAAC;CACzE;;;;;;;;"}
|
|
@@ -1,206 +1,50 @@
|
|
|
1
|
+
export { default as Honeybadger } from '@honeybadger-io/js';
|
|
2
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
1
3
|
import React, { Component } from 'react';
|
|
2
4
|
import PropTypes from 'prop-types';
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function _defineProperties(target, props) {
|
|
11
|
-
for (var i = 0; i < props.length; i++) {
|
|
12
|
-
var descriptor = props[i];
|
|
13
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
14
|
-
descriptor.configurable = true;
|
|
15
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
16
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
21
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
22
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
23
|
-
return Constructor;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function _defineProperty(obj, key, value) {
|
|
27
|
-
if (key in obj) {
|
|
28
|
-
Object.defineProperty(obj, key, {
|
|
29
|
-
value: value,
|
|
30
|
-
enumerable: true,
|
|
31
|
-
configurable: true,
|
|
32
|
-
writable: true
|
|
33
|
-
});
|
|
34
|
-
} else {
|
|
35
|
-
obj[key] = value;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return obj;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function _inherits(subClass, superClass) {
|
|
42
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
43
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
47
|
-
constructor: {
|
|
48
|
-
value: subClass,
|
|
49
|
-
writable: true,
|
|
50
|
-
configurable: true
|
|
6
|
+
class DefaultErrorComponent extends Component {
|
|
7
|
+
render() {
|
|
8
|
+
return (jsxs("div", { className: 'error', children: [jsx("div", { children: "An Error Occurred" }), jsx("div", { children: JSON.stringify(this.props.error, null, 2) }), jsx("div", { children: this.props.info ? JSON.stringify(this.props.info, null, 2) : '' })] }));
|
|
51
9
|
}
|
|
52
|
-
});
|
|
53
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function _getPrototypeOf(o) {
|
|
57
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
58
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
59
|
-
};
|
|
60
|
-
return _getPrototypeOf(o);
|
|
61
10
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (typeof Proxy === "function") return true;
|
|
76
|
-
|
|
77
|
-
try {
|
|
78
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
79
|
-
return true;
|
|
80
|
-
} catch (e) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function _assertThisInitialized(self) {
|
|
86
|
-
if (self === void 0) {
|
|
87
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return self;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function _possibleConstructorReturn(self, call) {
|
|
94
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
95
|
-
return call;
|
|
96
|
-
} else if (call !== void 0) {
|
|
97
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return _assertThisInitialized(self);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function _createSuper(Derived) {
|
|
104
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
105
|
-
|
|
106
|
-
return function _createSuperInternal() {
|
|
107
|
-
var Super = _getPrototypeOf(Derived),
|
|
108
|
-
result;
|
|
109
|
-
|
|
110
|
-
if (hasNativeReflectConstruct) {
|
|
111
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
112
|
-
|
|
113
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
114
|
-
} else {
|
|
115
|
-
result = Super.apply(this, arguments);
|
|
11
|
+
DefaultErrorComponent.propTypes = {
|
|
12
|
+
error: PropTypes.object,
|
|
13
|
+
info: PropTypes.object
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
class HoneybadgerErrorBoundary extends Component {
|
|
17
|
+
constructor(props) {
|
|
18
|
+
super(props);
|
|
19
|
+
this.state = {
|
|
20
|
+
error: null,
|
|
21
|
+
info: null,
|
|
22
|
+
errorOccurred: false
|
|
23
|
+
};
|
|
116
24
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
var DefaultErrorComponent = /*#__PURE__*/function (_Component) {
|
|
123
|
-
_inherits(DefaultErrorComponent, _Component);
|
|
124
|
-
|
|
125
|
-
var _super = _createSuper(DefaultErrorComponent);
|
|
126
|
-
|
|
127
|
-
function DefaultErrorComponent() {
|
|
128
|
-
_classCallCheck(this, DefaultErrorComponent);
|
|
129
|
-
|
|
130
|
-
return _super.apply(this, arguments);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
_createClass(DefaultErrorComponent, [{
|
|
134
|
-
key: "render",
|
|
135
|
-
value: function render() {
|
|
136
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
137
|
-
className: "error"
|
|
138
|
-
}, /*#__PURE__*/React.createElement("div", null, "An Error Occurred"), /*#__PURE__*/React.createElement("div", null, this.error), /*#__PURE__*/React.createElement("div", null, this.info));
|
|
25
|
+
static getDerivedStateFromError(error) {
|
|
26
|
+
return { error: error, errorOccurred: true, info: null };
|
|
139
27
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}(Component);
|
|
144
|
-
|
|
145
|
-
var HoneyBadgerErrorBoundary = /*#__PURE__*/function (_Component2) {
|
|
146
|
-
_inherits(HoneyBadgerErrorBoundary, _Component2);
|
|
147
|
-
|
|
148
|
-
var _super2 = _createSuper(HoneyBadgerErrorBoundary);
|
|
149
|
-
|
|
150
|
-
function HoneyBadgerErrorBoundary(props) {
|
|
151
|
-
var _this;
|
|
152
|
-
|
|
153
|
-
_classCallCheck(this, HoneyBadgerErrorBoundary);
|
|
154
|
-
|
|
155
|
-
_this = _super2.call(this, props);
|
|
156
|
-
_this.state = {
|
|
157
|
-
error: null,
|
|
158
|
-
info: null,
|
|
159
|
-
errorOccurred: false
|
|
160
|
-
};
|
|
161
|
-
return _this;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
_createClass(HoneyBadgerErrorBoundary, [{
|
|
165
|
-
key: "componentDidCatch",
|
|
166
|
-
value: function componentDidCatch(error, info) {
|
|
167
|
-
this.setState({
|
|
168
|
-
errorOccurred: true,
|
|
169
|
-
error: error,
|
|
170
|
-
info: info
|
|
171
|
-
});
|
|
172
|
-
this.props.honeybadger.notify(error, {
|
|
173
|
-
context: info
|
|
174
|
-
});
|
|
28
|
+
componentDidCatch(error, errorInfo) {
|
|
29
|
+
this.setState({ errorOccurred: true, error: error, info: errorInfo });
|
|
30
|
+
this.props.honeybadger.notify(error, { context: errorInfo });
|
|
175
31
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
var ErrorComponent = this.props.ErrorComponent;
|
|
181
|
-
return ErrorComponent ? /*#__PURE__*/React.createElement(ErrorComponent, this.state) : /*#__PURE__*/React.createElement(DefaultErrorComponent, null);
|
|
182
|
-
} else {
|
|
183
|
-
return this.props.children;
|
|
184
|
-
}
|
|
32
|
+
getErrorComponent() {
|
|
33
|
+
return this.props.ErrorComponent
|
|
34
|
+
? React.createElement(this.props.ErrorComponent, this.state)
|
|
35
|
+
: jsx(DefaultErrorComponent, { ...this.state });
|
|
185
36
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
errorOccurred: true,
|
|
191
|
-
error: error
|
|
192
|
-
};
|
|
37
|
+
render() {
|
|
38
|
+
return (jsx(Fragment, { children: this.state.errorOccurred
|
|
39
|
+
? this.getErrorComponent()
|
|
40
|
+
: this.props.children }));
|
|
193
41
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
honeybadger: PropTypes.object,
|
|
201
|
-
children: PropTypes.element,
|
|
202
|
-
ErrorComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func])
|
|
203
|
-
});
|
|
42
|
+
}
|
|
43
|
+
HoneybadgerErrorBoundary.propTypes = {
|
|
44
|
+
honeybadger: PropTypes.object.isRequired,
|
|
45
|
+
children: PropTypes.element,
|
|
46
|
+
ErrorComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func])
|
|
47
|
+
};
|
|
204
48
|
|
|
205
|
-
export {
|
|
49
|
+
export { HoneybadgerErrorBoundary };
|
|
206
50
|
//# sourceMappingURL=honeybadger-react.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"honeybadger-react.esm.js","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"honeybadger-react.esm.js","sources":["../../src/DefaultErrorComponent.tsx","../../src/HoneybadgerErrorBoundary.tsx"],"sourcesContent":["import React, {Component} from \"react\"\nimport PropTypes from \"prop-types\";\n\nexport interface DefaultErrorComponentProps {\n error: Error | null\n info: React.ErrorInfo | null\n}\n\nexport default class DefaultErrorComponent extends Component<DefaultErrorComponentProps, {}> {\n\n static propTypes = {\n error: PropTypes.object,\n info: PropTypes.object\n }\n\n render() {\n return (\n <div className='error'>\n <div>\n An Error Occurred\n </div>\n <div>\n {JSON.stringify(this.props.error, null, 2)}\n </div>\n <div>\n {this.props.info ? JSON.stringify(this.props.info, null, 2) : ''}\n </div>\n </div>\n )\n }\n}\n","import React, {Component, ReactNode} from 'react'\nimport HoneybadgerClient from '@honeybadger-io/js/dist/browser/types/core/client'\nimport DefaultErrorComponent, {DefaultErrorComponentProps} from \"./DefaultErrorComponent\"\nimport PropTypes from \"prop-types\";\n\ninterface HoneybadgerErrorBoundaryProps {\n honeybadger: HoneybadgerClient\n ErrorComponent?: ReactNode\n}\n\ninterface HoneybadgerErrorBoundaryState extends DefaultErrorComponentProps {\n errorOccurred: boolean\n}\n\nexport default class HoneybadgerErrorBoundary extends Component<HoneybadgerErrorBoundaryProps, HoneybadgerErrorBoundaryState> {\n\n static propTypes = {\n honeybadger: PropTypes.object.isRequired,\n children: PropTypes.element,\n ErrorComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func])\n }\n\n constructor(props: HoneybadgerErrorBoundaryProps) {\n super(props)\n this.state = {\n error: null,\n info: null,\n errorOccurred: false\n }\n }\n\n public static getDerivedStateFromError(error: Error): HoneybadgerErrorBoundaryState {\n return {error: error, errorOccurred: true, info: null}\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n this.setState({errorOccurred: true, error: error, info: errorInfo})\n this.props.honeybadger.notify(error, {context: errorInfo as any})\n }\n\n private getErrorComponent(): ReactNode {\n return this.props.ErrorComponent\n ? React.createElement(this.props.ErrorComponent as any, this.state)\n : <DefaultErrorComponent {...this.state} />\n }\n\n render() {\n return (\n <>\n {this.state.errorOccurred\n ? this.getErrorComponent()\n : this.props.children\n }\n </>\n )\n }\n}\n"],"names":["_jsxs","_jsx","_Fragment"],"mappings":";;;;;AAQqB,MAAA,qBAAsB,SAAQ,SAAyC,CAAA;IAO1F,MAAM,GAAA;QACJ,QACEA,IAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,OAAO,aACpBC,GAEM,CAAA,KAAA,EAAA,EAAA,QAAA,EAAA,mBAAA,EAAA,CAAA,EACNA,GACG,CAAA,KAAA,EAAA,EAAA,QAAA,EAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EACtC,CAAA,EACNA,GACG,CAAA,KAAA,EAAA,EAAA,QAAA,EAAA,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,EAAA,CAC5D,CACF,EAAA,CAAA,EACP;KACF;;AAnBM,qBAAA,CAAA,SAAS,GAAG;IACjB,KAAK,EAAE,SAAS,CAAC,MAAM;IACvB,IAAI,EAAE,SAAS,CAAC,MAAM;CACvB;;ACCkB,MAAA,wBAAyB,SAAQ,SAAuE,CAAA;AAQ3H,IAAA,WAAA,CAAY,KAAoC,EAAA;QAC9C,KAAK,CAAC,KAAK,CAAC,CAAA;QACZ,IAAI,CAAC,KAAK,GAAG;AACX,YAAA,KAAK,EAAE,IAAI;AACX,YAAA,IAAI,EAA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-
var HoneybadgerReact = (function (React, PropTypes) {
|
|
2
|
-
|
|
1
|
+
var HoneybadgerReact = (function (exports, js, jsxRuntime, React, PropTypes) {
|
|
2
|
+
'use strict';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
var js__default = /*#__PURE__*/_interopDefaultLegacy(js);
|
|
7
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
8
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function _defineProperties(target, props) {
|
|
16
|
-
for (var i = 0; i < props.length; i++) {
|
|
17
|
-
var descriptor = props[i];
|
|
18
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
19
|
-
descriptor.configurable = true;
|
|
20
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
21
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
26
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
27
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
28
|
-
return Constructor;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function _defineProperty(obj, key, value) {
|
|
32
|
-
if (key in obj) {
|
|
33
|
-
Object.defineProperty(obj, key, {
|
|
34
|
-
value: value,
|
|
35
|
-
enumerable: true,
|
|
36
|
-
configurable: true,
|
|
37
|
-
writable: true
|
|
38
|
-
});
|
|
39
|
-
} else {
|
|
40
|
-
obj[key] = value;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return obj;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function _inherits(subClass, superClass) {
|
|
47
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
48
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
10
|
+
class DefaultErrorComponent extends React.Component {
|
|
11
|
+
render() {
|
|
12
|
+
return (jsxRuntime.jsxs("div", { className: 'error', children: [jsxRuntime.jsx("div", { children: "An Error Occurred" }), jsxRuntime.jsx("div", { children: JSON.stringify(this.props.error, null, 2) }), jsxRuntime.jsx("div", { children: this.props.info ? JSON.stringify(this.props.info, null, 2) : '' })] }));
|
|
13
|
+
}
|
|
49
14
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
value: subClass,
|
|
54
|
-
writable: true,
|
|
55
|
-
configurable: true
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function _getPrototypeOf(o) {
|
|
62
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
63
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
15
|
+
DefaultErrorComponent.propTypes = {
|
|
16
|
+
error: PropTypes__default["default"].object,
|
|
17
|
+
info: PropTypes__default["default"].object
|
|
64
18
|
};
|
|
65
|
-
return _getPrototypeOf(o);
|
|
66
|
-
}
|
|
67
19
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return self;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function _possibleConstructorReturn(self, call) {
|
|
99
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
100
|
-
return call;
|
|
101
|
-
} else if (call !== void 0) {
|
|
102
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
20
|
+
class HoneybadgerErrorBoundary extends React.Component {
|
|
21
|
+
constructor(props) {
|
|
22
|
+
super(props);
|
|
23
|
+
this.state = {
|
|
24
|
+
error: null,
|
|
25
|
+
info: null,
|
|
26
|
+
errorOccurred: false
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
static getDerivedStateFromError(error) {
|
|
30
|
+
return { error: error, errorOccurred: true, info: null };
|
|
31
|
+
}
|
|
32
|
+
componentDidCatch(error, errorInfo) {
|
|
33
|
+
this.setState({ errorOccurred: true, error: error, info: errorInfo });
|
|
34
|
+
this.props.honeybadger.notify(error, { context: errorInfo });
|
|
35
|
+
}
|
|
36
|
+
getErrorComponent() {
|
|
37
|
+
return this.props.ErrorComponent
|
|
38
|
+
? React__default["default"].createElement(this.props.ErrorComponent, this.state)
|
|
39
|
+
: jsxRuntime.jsx(DefaultErrorComponent, { ...this.state });
|
|
40
|
+
}
|
|
41
|
+
render() {
|
|
42
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: this.state.errorOccurred
|
|
43
|
+
? this.getErrorComponent()
|
|
44
|
+
: this.props.children }));
|
|
45
|
+
}
|
|
103
46
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
function _createSuper(Derived) {
|
|
109
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
110
|
-
|
|
111
|
-
return function _createSuperInternal() {
|
|
112
|
-
var Super = _getPrototypeOf(Derived),
|
|
113
|
-
result;
|
|
114
|
-
|
|
115
|
-
if (hasNativeReflectConstruct) {
|
|
116
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
117
|
-
|
|
118
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
119
|
-
} else {
|
|
120
|
-
result = Super.apply(this, arguments);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return _possibleConstructorReturn(this, result);
|
|
47
|
+
HoneybadgerErrorBoundary.propTypes = {
|
|
48
|
+
honeybadger: PropTypes__default["default"].object.isRequired,
|
|
49
|
+
children: PropTypes__default["default"].element,
|
|
50
|
+
ErrorComponent: PropTypes__default["default"].oneOfType([PropTypes__default["default"].element, PropTypes__default["default"].func])
|
|
124
51
|
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
var DefaultErrorComponent = /*#__PURE__*/function (_Component) {
|
|
128
|
-
_inherits(DefaultErrorComponent, _Component);
|
|
129
|
-
|
|
130
|
-
var _super = _createSuper(DefaultErrorComponent);
|
|
131
|
-
|
|
132
|
-
function DefaultErrorComponent() {
|
|
133
|
-
_classCallCheck(this, DefaultErrorComponent);
|
|
134
|
-
|
|
135
|
-
return _super.apply(this, arguments);
|
|
136
|
-
}
|
|
137
52
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", null, "An Error Occurred"), /*#__PURE__*/React__default['default'].createElement("div", null, this.error), /*#__PURE__*/React__default['default'].createElement("div", null, this.info));
|
|
144
|
-
}
|
|
145
|
-
}]);
|
|
146
|
-
|
|
147
|
-
return DefaultErrorComponent;
|
|
148
|
-
}(React.Component);
|
|
149
|
-
|
|
150
|
-
var HoneyBadgerErrorBoundary = /*#__PURE__*/function (_Component2) {
|
|
151
|
-
_inherits(HoneyBadgerErrorBoundary, _Component2);
|
|
152
|
-
|
|
153
|
-
var _super2 = _createSuper(HoneyBadgerErrorBoundary);
|
|
154
|
-
|
|
155
|
-
function HoneyBadgerErrorBoundary(props) {
|
|
156
|
-
var _this;
|
|
157
|
-
|
|
158
|
-
_classCallCheck(this, HoneyBadgerErrorBoundary);
|
|
159
|
-
|
|
160
|
-
_this = _super2.call(this, props);
|
|
161
|
-
_this.state = {
|
|
162
|
-
error: null,
|
|
163
|
-
info: null,
|
|
164
|
-
errorOccurred: false
|
|
165
|
-
};
|
|
166
|
-
return _this;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
_createClass(HoneyBadgerErrorBoundary, [{
|
|
170
|
-
key: "componentDidCatch",
|
|
171
|
-
value: function componentDidCatch(error, info) {
|
|
172
|
-
this.setState({
|
|
173
|
-
errorOccurred: true,
|
|
174
|
-
error: error,
|
|
175
|
-
info: info
|
|
176
|
-
});
|
|
177
|
-
this.props.honeybadger.notify(error, {
|
|
178
|
-
context: info
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}, {
|
|
182
|
-
key: "render",
|
|
183
|
-
value: function render() {
|
|
184
|
-
if (this.state.errorOccurred) {
|
|
185
|
-
var ErrorComponent = this.props.ErrorComponent;
|
|
186
|
-
return ErrorComponent ? /*#__PURE__*/React__default['default'].createElement(ErrorComponent, this.state) : /*#__PURE__*/React__default['default'].createElement(DefaultErrorComponent, null);
|
|
187
|
-
} else {
|
|
188
|
-
return this.props.children;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}], [{
|
|
192
|
-
key: "getDerivedStateFromError",
|
|
193
|
-
value: function getDerivedStateFromError(error) {
|
|
194
|
-
return {
|
|
195
|
-
errorOccurred: true,
|
|
196
|
-
error: error
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
}]);
|
|
200
|
-
|
|
201
|
-
return HoneyBadgerErrorBoundary;
|
|
202
|
-
}(React.Component);
|
|
53
|
+
Object.defineProperty(exports, 'Honeybadger', {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function () { return js__default["default"]; }
|
|
56
|
+
});
|
|
57
|
+
exports.HoneybadgerErrorBoundary = HoneybadgerErrorBoundary;
|
|
203
58
|
|
|
204
|
-
|
|
205
|
-
honeybadger: PropTypes__default['default'].object,
|
|
206
|
-
children: PropTypes__default['default'].element,
|
|
207
|
-
ErrorComponent: PropTypes__default['default'].oneOfType([PropTypes__default['default'].element, PropTypes__default['default'].func])
|
|
208
|
-
});
|
|
59
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
209
60
|
|
|
210
|
-
|
|
61
|
+
return exports;
|
|
211
62
|
|
|
212
|
-
}(React, PropTypes)
|
|
63
|
+
})({}, Honeybadger, jsxRuntime, React, PropTypes);
|
|
213
64
|
//# sourceMappingURL=honeybadger-react.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"honeybadger-react.js","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"honeybadger-react.js","sources":["../../src/DefaultErrorComponent.tsx","../../src/HoneybadgerErrorBoundary.tsx"],"sourcesContent":["import React, {Component} from \"react\"\nimport PropTypes from \"prop-types\";\n\nexport interface DefaultErrorComponentProps {\n error: Error | null\n info: React.ErrorInfo | null\n}\n\nexport default class DefaultErrorComponent extends Component<DefaultErrorComponentProps, {}> {\n\n static propTypes = {\n error: PropTypes.object,\n info: PropTypes.object\n }\n\n render() {\n return (\n <div className='error'>\n <div>\n An Error Occurred\n </div>\n <div>\n {JSON.stringify(this.props.error, null, 2)}\n </div>\n <div>\n {this.props.info ? JSON.stringify(this.props.info, null, 2) : ''}\n </div>\n </div>\n )\n }\n}\n","import React, {Component, ReactNode} from 'react'\nimport HoneybadgerClient from '@honeybadger-io/js/dist/browser/types/core/client'\nimport DefaultErrorComponent, {DefaultErrorComponentProps} from \"./DefaultErrorComponent\"\nimport PropTypes from \"prop-types\";\n\ninterface HoneybadgerErrorBoundaryProps {\n honeybadger: HoneybadgerClient\n ErrorComponent?: ReactNode\n}\n\ninterface HoneybadgerErrorBoundaryState extends DefaultErrorComponentProps {\n errorOccurred: boolean\n}\n\nexport default class HoneybadgerErrorBoundary extends Component<HoneybadgerErrorBoundaryProps, HoneybadgerErrorBoundaryState> {\n\n static propTypes = {\n honeybadger: PropTypes.object.isRequired,\n children: PropTypes.element,\n ErrorComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func])\n }\n\n constructor(props: HoneybadgerErrorBoundaryProps) {\n super(props)\n this.state = {\n error: null,\n info: null,\n errorOccurred: false\n }\n }\n\n public static getDerivedStateFromError(error: Error): HoneybadgerErrorBoundaryState {\n return {error: error, errorOccurred: true, info: null}\n }\n\n componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n this.setState({errorOccurred: true, error: error, info: errorInfo})\n this.props.honeybadger.notify(error, {context: errorInfo as any})\n }\n\n private getErrorComponent(): ReactNode {\n return this.props.ErrorComponent\n ? React.createElement(this.props.ErrorComponent as any, this.state)\n : <DefaultErrorComponent {...this.state} />\n }\n\n render() {\n return (\n <>\n {this.state.errorOccurred\n ? this.getErrorComponent()\n : this.props.children\n }\n </>\n )\n }\n}\n"],"names":["Component","_jsxs","_jsx","PropTypes","React","_Fragment"],"mappings":";;;;;;;;;IAQqB,MAAA,qBAAsB,SAAQA,eAAyC,CAAA;QAO1F,MAAM,GAAA;YACJ,QACEC,eAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,OAAO,aACpBC,cAEM,CAAA,KAAA,EAAA,EAAA,QAAA,EAAA,mBAAA,EAAA,CAAA,EACNA,cACG,CAAA,KAAA,EAAA,EAAA,QAAA,EAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EACtC,CAAA,EACNA,cACG,CAAA,KAAA,EAAA,EAAA,QAAA,EAAA,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,EAAA,CAC5D,CACF,EAAA,CAAA,EACP;SACF;;IAnBM,qBAAA,CAAA,SAAS,GAAG;QACjB,KAAK,EAAEC,6BAAS,CAAC,MAAM;QACvB,IAAI,EAAEA,6BAAS,CAAC,MAAM;KACvB;;ICCkB,MAA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ACxC,QAAQ,EAAEA,6BAAS,CAAC,OAAO;IAC3B,IAAA,cAAc,EAAEA,6BAAS,CAAC,SAAS,CAAC,CAACA,6BAAS,CAAC,OAAO,EAAEA,6BAAS,CAAC,IAAI,CAAC,CAAC;KACzE;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@honeybadger-io/react",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "React.js integration for honeybadger",
|
|
5
5
|
"author": "Jason Truesdell <jason@yuzuten.com> (https://github.com/JasonTrue)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git+ssh://git@github.com/honeybadger-io/honeybadger-react.git"
|
|
10
10
|
},
|
|
11
11
|
"main": "dist/honeybadger-react.cjs.js",
|
|
12
|
-
"types": "./
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
13
|
"module": "dist/honeybadger-react.esm.js",
|
|
14
14
|
"unpkg": "dist/honeybadger-react.js",
|
|
15
15
|
"jsnext:main": "dist/honeybadger-react.esm.js",
|
|
@@ -20,49 +20,46 @@
|
|
|
20
20
|
"scripts": {
|
|
21
21
|
"test": "cross-env CI=1 react-scripts test --env=jsdom",
|
|
22
22
|
"test:watch": "react-scripts test --env=jsdom",
|
|
23
|
-
"build": "rollup -c",
|
|
23
|
+
"build": "tsc --emitDeclarationOnly --noEmit false && rollup -c",
|
|
24
24
|
"start": "rollup -c -w",
|
|
25
|
-
"prepare": "npm run build",
|
|
25
|
+
"prepare": "npm run build && husky install",
|
|
26
26
|
"predeploy": "cd example && npm install && npm run build",
|
|
27
27
|
"deploy": "gh-pages -d example/build",
|
|
28
28
|
"preversion": "npm test",
|
|
29
29
|
"version": "scripts/update-versions.sh",
|
|
30
30
|
"postversion": "git push && git push --tags",
|
|
31
|
-
"prepublishOnly": "npm build && npm test"
|
|
31
|
+
"prepublishOnly": "npm run build && npm test",
|
|
32
|
+
"release": "shipjs prepare"
|
|
32
33
|
},
|
|
33
34
|
"peerDependencies": {
|
|
34
35
|
"prop-types": "^15.5.4",
|
|
35
|
-
"react": "^15.0.0 || ^16.0.0 || ^17.0.0",
|
|
36
|
-
"react-dom": "^15.0.0 || ^16.0.0 || ^17.0.0"
|
|
36
|
+
"react": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0",
|
|
37
|
+
"react-dom": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"@svgr/rollup": "^5.3.1",
|
|
40
|
+
"@commitlint/cli": "^17.0.0",
|
|
41
|
+
"@commitlint/config-conventional": "^17.0.0",
|
|
42
|
+
"@rollup/plugin-commonjs": "^22.0.0",
|
|
43
|
+
"@rollup/plugin-typescript": "^8.3.2",
|
|
44
|
+
"@types/jest": "^27.4.1",
|
|
45
|
+
"@types/react": "^17.0.44",
|
|
46
|
+
"@types/react-test-renderer": "^18.0.0",
|
|
47
|
+
"@types/sinon": "^10.0.11",
|
|
48
48
|
"cross-env": "^7.0.0",
|
|
49
|
-
"gh-pages": "^
|
|
50
|
-
"
|
|
51
|
-
"react
|
|
52
|
-
"react-scripts": "^
|
|
53
|
-
"react-test-renderer": "^
|
|
54
|
-
"rollup": "^2.
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"rollup-plugin-uglify": "^6.0.4",
|
|
59
|
-
"sinon": "^11.1.2"
|
|
49
|
+
"gh-pages": "^4.0.0",
|
|
50
|
+
"husky": "^8.0.0",
|
|
51
|
+
"react": "^18.1.0",
|
|
52
|
+
"react-scripts": "^5.0.1",
|
|
53
|
+
"react-test-renderer": "^18.1.0",
|
|
54
|
+
"rollup": "^2.70.2",
|
|
55
|
+
"shipjs": "0.24.4",
|
|
56
|
+
"sinon": "^14.0.0",
|
|
57
|
+
"typescript": "^4.6.3"
|
|
60
58
|
},
|
|
61
59
|
"files": [
|
|
62
|
-
"dist"
|
|
63
|
-
"honeybadger-react.d.ts"
|
|
60
|
+
"dist"
|
|
64
61
|
],
|
|
65
62
|
"dependencies": {
|
|
66
|
-
"@honeybadger-io/js": "^
|
|
63
|
+
"@honeybadger-io/js": "^4.0.3"
|
|
67
64
|
}
|
|
68
65
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
All notable changes to this project will be documented in this file.
|
|
3
|
-
|
|
4
|
-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
|
-
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
|
-
|
|
7
|
-
## [Unreleased]
|
|
8
|
-
|
|
9
|
-
## [1.0.2] - 2021-09-14
|
|
10
|
-
### Fixed
|
|
11
|
-
- Fix typescript definitions (#272)
|
|
12
|
-
|
|
13
|
-
## [1.0.1] - 2021-02-18
|
|
14
|
-
### Fixed
|
|
15
|
-
- Bump peerDependencies version for React 17
|
|
16
|
-
|
|
17
|
-
## [1.0.0] - 2021-01-19
|
|
18
|
-
### Changed
|
|
19
|
-
- Migrate honeybadger-js dependency to @honeybadger-io/js 3.0.0
|
|
20
|
-
See https://docs.honeybadger.io/lib/javascript/support/upgrading-to-v3.html
|
|
21
|
-
|
|
22
|
-
## [0.0.8] - 2020-09-24
|
|
23
|
-
### Fixed
|
|
24
|
-
- Update honeybadger-js to 2.3.0
|
|
25
|
-
|
|
26
|
-
## [0.0.7] - 2020-04-24
|
|
27
|
-
### Fixed
|
|
28
|
-
- Update honeybadger-js to 2.2.1 (security release, see
|
|
29
|
-
[here](https://github.com/honeybadger-io/honeybadger-js/blob/master/CHANGELOG.md#220---2020-03-16))
|
|
30
|
-
|
|
31
|
-
## [0.0.6] - 2020-01-08
|
|
32
|
-
### Fixed
|
|
33
|
-
- Fix TypeScript type definitions
|
|
34
|
-
|
|
35
|
-
## [0.0.5] - 2019-12-18
|
|
36
|
-
### Fixed
|
|
37
|
-
- Deps & security updates
|
|
38
|
-
- Proptypes bug (#39) (#40)
|
|
39
|
-
|
|
40
|
-
## [0.0.4] - 2019-07-01
|
|
41
|
-
### Fixed
|
|
42
|
-
- Fix PropType mismatch #38 @andrewsouthard
|
|
43
|
-
|
|
44
|
-
## [0.0.3] - 2019-04-16
|
|
45
|
-
### Changed
|
|
46
|
-
- Update honeybadger-js to v1.0. See
|
|
47
|
-
https://github.com/honeybadger-io/honeybadger-js/blob/master/CHANGELOG.md
|
|
48
|
-
|
|
49
|
-
## [0.0.2] - 2019-01-21
|
|
50
|
-
### Added
|
|
51
|
-
- Add TypeScript definition
|
|
52
|
-
|
|
53
|
-
## [0.0.1] - 2018-11-30
|
|
54
|
-
### Added
|
|
55
|
-
- Initial release
|
package/honeybadger-react.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
declare module "@honeybadger-io/react" {
|
|
2
|
-
import React from "react";
|
|
3
|
-
import BrowserClient from "@honeybadger-io/js/dist/browser/types/core/client";
|
|
4
|
-
import ServerClient from "@honeybadger-io/js/dist/server/types/core/client";
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
honeybadger: BrowserClient & ServerClient;
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
ErrorComponent?: React.ReactNode | Function;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare const ErrorBoundary: React.ComponentType<Props>;
|
|
13
|
-
|
|
14
|
-
export default ErrorBoundary;
|
|
15
|
-
}
|