@sentry/react 7.0.0-alpha.1 → 7.0.0-beta.2

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.
Files changed (92) hide show
  1. package/README.md +2 -3
  2. package/cjs/constants.js +12 -5
  3. package/cjs/constants.js.map +1 -1
  4. package/cjs/errorboundary.js +139 -112
  5. package/cjs/errorboundary.js.map +1 -1
  6. package/cjs/flags.js +7 -3
  7. package/cjs/flags.js.map +1 -1
  8. package/cjs/index.js +30 -21
  9. package/cjs/index.js.map +1 -1
  10. package/cjs/profiler.js +178 -147
  11. package/cjs/profiler.js.map +1 -1
  12. package/cjs/reactrouter.js +147 -100
  13. package/cjs/reactrouter.js.map +1 -1
  14. package/cjs/reactrouterv3.js +107 -83
  15. package/cjs/reactrouterv3.js.map +1 -1
  16. package/cjs/reactrouterv6.js +163 -0
  17. package/cjs/reactrouterv6.js.map +1 -0
  18. package/cjs/redux.js +51 -42
  19. package/cjs/redux.js.map +1 -1
  20. package/cjs/sdk.js +18 -15
  21. package/cjs/sdk.js.map +1 -1
  22. package/esm/constants.js +8 -4
  23. package/esm/constants.js.map +1 -1
  24. package/esm/errorboundary.js +124 -107
  25. package/esm/errorboundary.js.map +1 -1
  26. package/esm/flags.js +5 -2
  27. package/esm/flags.js.map +1 -1
  28. package/esm/index.js +8 -7
  29. package/esm/index.js.map +1 -1
  30. package/esm/profiler.js +161 -140
  31. package/esm/profiler.js.map +1 -1
  32. package/esm/reactrouter.js +133 -94
  33. package/esm/reactrouter.js.map +1 -1
  34. package/esm/reactrouterv3.js +103 -79
  35. package/esm/reactrouterv3.js.map +1 -1
  36. package/esm/reactrouterv6.js +153 -0
  37. package/esm/reactrouterv6.js.map +1 -0
  38. package/esm/redux.js +49 -41
  39. package/esm/redux.js.map +1 -1
  40. package/esm/sdk.js +17 -14
  41. package/esm/sdk.js.map +1 -1
  42. package/package.json +5 -5
  43. package/types/errorboundary.d.ts +1 -0
  44. package/types/errorboundary.d.ts.map +1 -1
  45. package/types/index.d.ts +1 -0
  46. package/types/index.d.ts.map +1 -1
  47. package/types/reactrouterv6.d.ts +27 -0
  48. package/types/reactrouterv6.d.ts.map +1 -0
  49. package/cjs/constants.d.ts +0 -4
  50. package/cjs/constants.d.ts.map +0 -1
  51. package/cjs/errorboundary.d.ts +0 -62
  52. package/cjs/errorboundary.d.ts.map +0 -1
  53. package/cjs/flags.d.ts +0 -3
  54. package/cjs/flags.d.ts.map +0 -1
  55. package/cjs/index.d.ts +0 -8
  56. package/cjs/index.d.ts.map +0 -1
  57. package/cjs/profiler.d.ts +0 -54
  58. package/cjs/profiler.d.ts.map +0 -1
  59. package/cjs/reactrouter.d.ts +0 -25
  60. package/cjs/reactrouter.d.ts.map +0 -1
  61. package/cjs/reactrouterv3.d.ts +0 -26
  62. package/cjs/reactrouterv3.d.ts.map +0 -1
  63. package/cjs/redux.d.ts +0 -33
  64. package/cjs/redux.d.ts.map +0 -1
  65. package/cjs/sdk.d.ts +0 -6
  66. package/cjs/sdk.d.ts.map +0 -1
  67. package/cjs/types.d.ts +0 -8
  68. package/cjs/types.d.ts.map +0 -1
  69. package/cjs/types.js +0 -2
  70. package/cjs/types.js.map +0 -1
  71. package/esm/constants.d.ts +0 -4
  72. package/esm/constants.d.ts.map +0 -1
  73. package/esm/errorboundary.d.ts +0 -62
  74. package/esm/errorboundary.d.ts.map +0 -1
  75. package/esm/flags.d.ts +0 -3
  76. package/esm/flags.d.ts.map +0 -1
  77. package/esm/index.d.ts +0 -8
  78. package/esm/index.d.ts.map +0 -1
  79. package/esm/profiler.d.ts +0 -54
  80. package/esm/profiler.d.ts.map +0 -1
  81. package/esm/reactrouter.d.ts +0 -25
  82. package/esm/reactrouter.d.ts.map +0 -1
  83. package/esm/reactrouterv3.d.ts +0 -26
  84. package/esm/reactrouterv3.d.ts.map +0 -1
  85. package/esm/redux.d.ts +0 -33
  86. package/esm/redux.d.ts.map +0 -1
  87. package/esm/sdk.d.ts +0 -6
  88. package/esm/sdk.d.ts.map +0 -1
  89. package/esm/types.d.ts +0 -8
  90. package/esm/types.d.ts.map +0 -1
  91. package/esm/types.js +0 -1
  92. package/esm/types.js.map +0 -1
package/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  <p align="center">
2
- <a href="https://sentry.io" target="_blank" align="center">
3
- <img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
2
+ <a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
3
+ <img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
4
4
  </a>
5
- <br />
6
5
  </p>
7
6
 
8
7
  # Official Sentry SDK for ReactJS
package/cjs/constants.js CHANGED
@@ -1,5 +1,12 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.REACT_RENDER_OP = 'ui.react.render';
3
- exports.REACT_UPDATE_OP = 'ui.react.update';
4
- exports.REACT_MOUNT_OP = 'ui.react.mount';
5
- //# sourceMappingURL=constants.js.map
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+
3
+ var REACT_RENDER_OP = 'ui.react.render';
4
+
5
+ var REACT_UPDATE_OP = 'ui.react.update';
6
+
7
+ var REACT_MOUNT_OP = 'ui.react.mount';
8
+
9
+ exports.REACT_MOUNT_OP = REACT_MOUNT_OP;
10
+ exports.REACT_RENDER_OP = REACT_RENDER_OP;
11
+ exports.REACT_UPDATE_OP = REACT_UPDATE_OP;
12
+ //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";AAAa,QAAA,eAAe,GAAG,iBAAiB,CAAC;AAEpC,QAAA,eAAe,GAAG,iBAAiB,CAAC;AAEpC,QAAA,cAAc,GAAG,gBAAgB,CAAC","sourcesContent":["export const REACT_RENDER_OP = 'ui.react.render';\n\nexport const REACT_UPDATE_OP = 'ui.react.update';\n\nexport const REACT_MOUNT_OP = 'ui.react.mount';\n"]}
1
+ {"version":3,"file":"constants.js","sources":["../../src/constants.ts"],"sourcesContent":["export const REACT_RENDER_OP = 'ui.react.render';\n\nexport const REACT_UPDATE_OP = 'ui.react.update';\n\nexport const REACT_MOUNT_OP = 'ui.react.mount';\n"],"names":[],"mappings":";;;AACA;;AAEA;;;;;;;"}
@@ -1,125 +1,152 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- var tslib_1 = require("tslib");
3
- var browser_1 = require("@sentry/browser");
4
- var utils_1 = require("@sentry/utils");
5
- var hoist_non_react_statics_1 = tslib_1.__importDefault(require("hoist-non-react-statics"));
6
- var React = tslib_1.__importStar(require("react"));
7
- var flags_1 = require("./flags");
1
+ var {
2
+ _interopDefault,
3
+ _interopNamespace
4
+ } = require('@sentry/utils/cjs/buildPolyfills');
5
+
6
+ Object.defineProperty(exports, '__esModule', { value: true });
7
+
8
+ var browser = require('@sentry/browser');
9
+ var utils = require('@sentry/utils');
10
+ var hoistNonReactStatics = require('hoist-non-react-statics');
11
+ var React = require('react');
12
+ var flags = require('./flags.js');
13
+
14
+ var hoistNonReactStatics__default = /*#__PURE__*/_interopDefault(hoistNonReactStatics);
15
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
16
+
17
+ var _jsxFileName = "/home/runner/work/sentry-javascript/sentry-javascript/packages/react/src/errorboundary.tsx";
8
18
  function isAtLeastReact17(version) {
9
- var major = version.match(/^([^.]+)/);
10
- return major !== null && parseInt(major[0]) >= 17;
19
+ var major = version.match(/^([^.]+)/);
20
+ return major !== null && parseInt(major[0]) >= 17;
11
21
  }
12
- exports.isAtLeastReact17 = isAtLeastReact17;
13
- exports.UNKNOWN_COMPONENT = 'unknown';
22
+
23
+ var UNKNOWN_COMPONENT = 'unknown';
24
+
14
25
  var INITIAL_STATE = {
15
- componentStack: null,
16
- error: null,
17
- eventId: null,
26
+ componentStack: null,
27
+ error: null,
28
+ eventId: null,
18
29
  };
30
+
19
31
  /**
20
32
  * A ErrorBoundary component that logs errors to Sentry. Requires React >= 16.
21
33
  * NOTE: If you are a Sentry user, and you are seeing this stack frame, it means the
22
34
  * Sentry React SDK ErrorBoundary caught an error invoking your application code. This
23
35
  * is expected behavior and NOT indicative of a bug with the Sentry React SDK.
24
36
  */
25
- var ErrorBoundary = /** @class */ (function (_super) {
26
- tslib_1.__extends(ErrorBoundary, _super);
27
- function ErrorBoundary() {
28
- var _this = _super !== null && _super.apply(this, arguments) || this;
29
- _this.state = INITIAL_STATE;
30
- _this.resetErrorBoundary = function () {
31
- var onReset = _this.props.onReset;
32
- var _a = _this.state, error = _a.error, componentStack = _a.componentStack, eventId = _a.eventId;
33
- if (onReset) {
34
- onReset(error, componentStack, eventId);
35
- }
36
- _this.setState(INITIAL_STATE);
37
- };
38
- return _this;
37
+ class ErrorBoundary extends React__namespace.Component {constructor(...args) { super(...args); ErrorBoundary.prototype.__init.call(this);ErrorBoundary.prototype.__init2.call(this); }
38
+ __init() {this.state = INITIAL_STATE;}
39
+
40
+ componentDidCatch(error, { componentStack }) {
41
+ const { beforeCapture, onError, showDialog, dialogOptions } = this.props;
42
+
43
+ browser.withScope(scope => {
44
+ // If on React version >= 17, create stack trace from componentStack param and links
45
+ // to to the original error using `error.cause` otherwise relies on error param for stacktrace.
46
+ // Linking errors requires the `LinkedErrors` integration be enabled.
47
+ if (isAtLeastReact17(React__namespace.version)) {
48
+ var errorBoundaryError = new Error(error.message);
49
+ errorBoundaryError.name = `React ErrorBoundary ${errorBoundaryError.name}`;
50
+ errorBoundaryError.stack = componentStack;
51
+
52
+ // Using the `LinkedErrors` integration to link the errors together.
53
+ error.cause = errorBoundaryError;
54
+ }
55
+
56
+ if (beforeCapture) {
57
+ beforeCapture(scope, error, componentStack);
58
+ }
59
+ var eventId = browser.captureException(error, { contexts: { react: { componentStack } } });
60
+ if (onError) {
61
+ onError(error, componentStack, eventId);
62
+ }
63
+ if (showDialog) {
64
+ browser.showReportDialog({ ...dialogOptions, eventId });
65
+ }
66
+
67
+ // componentDidCatch is used over getDerivedStateFromError
68
+ // so that componentStack is accessible through state.
69
+ this.setState({ error, componentStack, eventId });
70
+ });
71
+ }
72
+
73
+ componentDidMount() {
74
+ const { onMount } = this.props;
75
+ if (onMount) {
76
+ onMount();
39
77
  }
40
- ErrorBoundary.prototype.componentDidCatch = function (error, _a) {
41
- var _this = this;
42
- var componentStack = _a.componentStack;
43
- var _b = this.props, beforeCapture = _b.beforeCapture, onError = _b.onError, showDialog = _b.showDialog, dialogOptions = _b.dialogOptions;
44
- browser_1.withScope(function (scope) {
45
- // If on React version >= 17, create stack trace from componentStack param and links
46
- // to to the original error using `error.cause` otherwise relies on error param for stacktrace.
47
- // Linking errors requires the `LinkedErrors` integration be enabled.
48
- if (isAtLeastReact17(React.version)) {
49
- var errorBoundaryError = new Error(error.message);
50
- errorBoundaryError.name = "React ErrorBoundary " + errorBoundaryError.name;
51
- errorBoundaryError.stack = componentStack;
52
- // Using the `LinkedErrors` integration to link the errors together.
53
- error.cause = errorBoundaryError;
54
- }
55
- if (beforeCapture) {
56
- beforeCapture(scope, error, componentStack);
57
- }
58
- var eventId = browser_1.captureException(error, { contexts: { react: { componentStack: componentStack } } });
59
- if (onError) {
60
- onError(error, componentStack, eventId);
61
- }
62
- if (showDialog) {
63
- browser_1.showReportDialog(tslib_1.__assign(tslib_1.__assign({}, dialogOptions), { eventId: eventId }));
64
- }
65
- // componentDidCatch is used over getDerivedStateFromError
66
- // so that componentStack is accessible through state.
67
- _this.setState({ error: error, componentStack: componentStack, eventId: eventId });
68
- });
69
- };
70
- ErrorBoundary.prototype.componentDidMount = function () {
71
- var onMount = this.props.onMount;
72
- if (onMount) {
73
- onMount();
74
- }
75
- };
76
- ErrorBoundary.prototype.componentWillUnmount = function () {
77
- var _a = this.state, error = _a.error, componentStack = _a.componentStack, eventId = _a.eventId;
78
- var onUnmount = this.props.onUnmount;
79
- if (onUnmount) {
80
- onUnmount(error, componentStack, eventId);
81
- }
82
- };
83
- ErrorBoundary.prototype.render = function () {
84
- var _a = this.props, fallback = _a.fallback, children = _a.children;
85
- var _b = this.state, error = _b.error, componentStack = _b.componentStack, eventId = _b.eventId;
86
- if (error) {
87
- var element = undefined;
88
- if (typeof fallback === 'function') {
89
- element = fallback({ error: error, componentStack: componentStack, resetError: this.resetErrorBoundary, eventId: eventId });
90
- }
91
- else {
92
- element = fallback;
93
- }
94
- if (React.isValidElement(element)) {
95
- return element;
96
- }
97
- if (fallback) {
98
- flags_1.IS_DEBUG_BUILD && utils_1.logger.warn('fallback did not produce a valid ReactElement');
99
- }
100
- // Fail gracefully if no fallback provided or is not valid
101
- return null;
102
- }
103
- if (typeof children === 'function') {
104
- return children();
105
- }
106
- return children;
107
- };
108
- return ErrorBoundary;
109
- }(React.Component));
110
- exports.ErrorBoundary = ErrorBoundary;
111
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
112
- function withErrorBoundary(WrappedComponent, errorBoundaryOptions) {
113
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
114
- var componentDisplayName = WrappedComponent.displayName || WrappedComponent.name || exports.UNKNOWN_COMPONENT;
115
- var Wrapped = function (props) { return (React.createElement(ErrorBoundary, tslib_1.__assign({}, errorBoundaryOptions),
116
- React.createElement(WrappedComponent, tslib_1.__assign({}, props)))); };
117
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
118
- Wrapped.displayName = "errorBoundary(" + componentDisplayName + ")";
119
- // Copy over static methods from Wrapped component to Profiler HOC
120
- // See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over
121
- hoist_non_react_statics_1.default(Wrapped, WrappedComponent);
122
- return Wrapped;
78
+ }
79
+
80
+ componentWillUnmount() {
81
+ const { error, componentStack, eventId } = this.state;
82
+ const { onUnmount } = this.props;
83
+ if (onUnmount) {
84
+ onUnmount(error, componentStack, eventId);
85
+ }
86
+ }
87
+
88
+ __init2() {this.resetErrorBoundary = () => {
89
+ const { onReset } = this.props;
90
+ const { error, componentStack, eventId } = this.state;
91
+ if (onReset) {
92
+ onReset(error, componentStack, eventId);
93
+ }
94
+ this.setState(INITIAL_STATE);
95
+ };}
96
+
97
+ render() {
98
+ const { fallback, children } = this.props;
99
+ const { error, componentStack, eventId } = this.state;
100
+
101
+ if (error) {
102
+ let element = undefined;
103
+ if (typeof fallback === 'function') {
104
+ element = fallback({ error, componentStack, resetError: this.resetErrorBoundary, eventId });
105
+ } else {
106
+ element = fallback;
107
+ }
108
+
109
+ if (React__namespace.isValidElement(element)) {
110
+ return element;
111
+ }
112
+
113
+ if (fallback) {
114
+ flags.IS_DEBUG_BUILD && utils.logger.warn('fallback did not produce a valid ReactElement');
115
+ }
116
+
117
+ // Fail gracefully if no fallback provided or is not valid
118
+ return null;
119
+ }
120
+
121
+ if (typeof children === 'function') {
122
+ return (children )();
123
+ }
124
+ return children;
125
+ }
126
+ }
127
+
128
+ function withErrorBoundary(
129
+ WrappedComponent,
130
+ errorBoundaryOptions,
131
+ ) {
132
+ var componentDisplayName = WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;
133
+
134
+ var Wrapped = (props) => (
135
+ React__namespace.createElement(ErrorBoundary, { ...errorBoundaryOptions, __self: this, __source: {fileName: _jsxFileName, lineNumber: 170}}
136
+ , React__namespace.createElement(WrappedComponent, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 171}} )
137
+ )
138
+ );
139
+
140
+ Wrapped.displayName = `errorBoundary(${componentDisplayName})`;
141
+
142
+ // Copy over static methods from Wrapped component to Profiler HOC
143
+ // See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over
144
+ hoistNonReactStatics__default(Wrapped, WrappedComponent);
145
+ return Wrapped;
123
146
  }
147
+
148
+ exports.ErrorBoundary = ErrorBoundary;
149
+ exports.UNKNOWN_COMPONENT = UNKNOWN_COMPONENT;
150
+ exports.isAtLeastReact17 = isAtLeastReact17;
124
151
  exports.withErrorBoundary = withErrorBoundary;
125
- //# sourceMappingURL=errorboundary.js.map
152
+ //# sourceMappingURL=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iCAAoB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IAChD,OAAO,OAAO,CAAC;AACjB,CAAC;AAEuB,8CAAiB","sourcesContent":["import { captureException, ReportDialogOptions, Scope, showReportDialog, withScope } from '@sentry/browser';\nimport { logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { IS_DEBUG_BUILD } from './flags';\n\nexport function isAtLeastReact17(version: string): boolean {\n const major = version.match(/^([^.]+)/);\n return major !== null && parseInt(major[0]) >= 17;\n}\n\nexport const UNKNOWN_COMPONENT = 'unknown';\n\nexport type FallbackRender = (errorData: {\n error: Error;\n componentStack: string | null;\n eventId: string | null;\n resetError(): void;\n}) => React.ReactElement;\n\nexport type ErrorBoundaryProps = {\n /** If a Sentry report dialog should be rendered on error */\n showDialog?: boolean;\n /**\n * Options to be passed into the Sentry report dialog.\n * No-op if {@link showDialog} is false.\n */\n dialogOptions?: ReportDialogOptions;\n /**\n * A fallback component that gets rendered when the error boundary encounters an error.\n *\n * Can either provide a React Component, or a function that returns React Component as\n * a valid fallback prop. If a function is provided, the function will be called with\n * the error, the component stack, and an function that resets the error boundary on error.\n *\n */\n fallback?: React.ReactElement | FallbackRender;\n /** Called when the error boundary encounters an error */\n onError?(error: Error, componentStack: string, eventId: string): void;\n /** Called on componentDidMount() */\n onMount?(): void;\n /** Called if resetError() is called from the fallback render props function */\n onReset?(error: Error | null, componentStack: string | null, eventId: string | null): void;\n /** Called on componentWillUnmount() */\n onUnmount?(error: Error | null, componentStack: string | null, eventId: string | null): void;\n /** Called before the error is captured by Sentry, allows for you to add tags or context using the scope */\n beforeCapture?(scope: Scope, error: Error | null, componentStack: string | null): void;\n};\n\ntype ErrorBoundaryState = {\n componentStack: React.ErrorInfo['componentStack'] | null;\n error: Error | null;\n eventId: string | null;\n};\n\nconst INITIAL_STATE = {\n componentStack: null,\n error: null,\n eventId: null,\n};\n\n/**\n * A ErrorBoundary component that logs errors to Sentry. Requires React >= 16.\n * NOTE: If you are a Sentry user, and you are seeing this stack frame, it means the\n * Sentry React SDK ErrorBoundary caught an error invoking your application code. This\n * is expected behavior and NOT indicative of a bug with the Sentry React SDK.\n */\nclass ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {\n public state: ErrorBoundaryState = INITIAL_STATE;\n\n public componentDidCatch(error: Error & { cause?: Error }, { componentStack }: React.ErrorInfo): void {\n const { beforeCapture, onError, showDialog, dialogOptions } = this.props;\n\n withScope(scope => {\n // If on React version >= 17, create stack trace from componentStack param and links\n // to to the original error using `error.cause` otherwise relies on error param for stacktrace.\n // Linking errors requires the `LinkedErrors` integration be enabled.\n if (isAtLeastReact17(React.version)) {\n const errorBoundaryError = new Error(error.message);\n errorBoundaryError.name = `React ErrorBoundary ${errorBoundaryError.name}`;\n errorBoundaryError.stack = componentStack;\n\n // Using the `LinkedErrors` integration to link the errors together.\n error.cause = errorBoundaryError;\n }\n\n if (beforeCapture) {\n beforeCapture(scope, error, componentStack);\n }\n const eventId = captureException(error, { contexts: { react: { componentStack } } });\n if (onError) {\n onError(error, componentStack, eventId);\n }\n if (showDialog) {\n showReportDialog({ ...dialogOptions, eventId });\n }\n\n // componentDidCatch is used over getDerivedStateFromError\n // so that componentStack is accessible through state.\n this.setState({ error, componentStack, eventId });\n });\n }\n\n public componentDidMount(): void {\n const { onMount } = this.props;\n if (onMount) {\n onMount();\n }\n }\n\n public componentWillUnmount(): void {\n const { error, componentStack, eventId } = this.state;\n const { onUnmount } = this.props;\n if (onUnmount) {\n onUnmount(error, componentStack, eventId);\n }\n }\n\n public resetErrorBoundary: () => void = () => {\n const { onReset } = this.props;\n const { error, componentStack, eventId } = this.state;\n if (onReset) {\n onReset(error, componentStack, eventId);\n }\n this.setState(INITIAL_STATE);\n };\n\n public render(): React.ReactNode {\n const { fallback, children } = this.props;\n const { error, componentStack, eventId } = this.state;\n\n if (error) {\n let element: React.ReactElement | undefined = undefined;\n if (typeof fallback === 'function') {\n element = fallback({ error, componentStack, resetError: this.resetErrorBoundary, eventId });\n } else {\n element = fallback;\n }\n\n if (React.isValidElement(element)) {\n return element;\n }\n\n if (fallback) {\n IS_DEBUG_BUILD && logger.warn('fallback did not produce a valid ReactElement');\n }\n\n // Fail gracefully if no fallback provided or is not valid\n return null;\n }\n\n if (typeof children === 'function') {\n return children();\n }\n return children;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction withErrorBoundary<P extends Record<string, any>>(\n WrappedComponent: React.ComponentType<P>,\n errorBoundaryOptions: ErrorBoundaryProps,\n): React.FC<P> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const componentDisplayName = WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;\n\n const Wrapped: React.FC<P> = (props: P) => (\n <ErrorBoundary {...errorBoundaryOptions}>\n <WrappedComponent {...props} />\n </ErrorBoundary>\n );\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n Wrapped.displayName = `errorBoundary(${componentDisplayName})`;\n\n // Copy over static methods from Wrapped component to Profiler HOC\n // See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over\n hoistNonReactStatics(Wrapped, WrappedComponent);\n return Wrapped;\n}\n\nexport { ErrorBoundary, withErrorBoundary };\n"]}
1
+ {"version":3,"file":"errorboundary.js","sources":["../../src/errorboundary.tsx"],"sourcesContent":["import { captureException, ReportDialogOptions, Scope, showReportDialog, withScope } from '@sentry/browser';\nimport { logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { IS_DEBUG_BUILD } from './flags';\n\nexport function isAtLeastReact17(version: string): boolean {\n const major = version.match(/^([^.]+)/);\n return major !== null && parseInt(major[0]) >= 17;\n}\n\nexport const UNKNOWN_COMPONENT = 'unknown';\n\nexport type FallbackRender = (errorData: {\n error: Error;\n componentStack: string | null;\n eventId: string | null;\n resetError(): void;\n}) => React.ReactElement;\n\nexport type ErrorBoundaryProps = {\n children?: React.ReactNode | (() => React.ReactNode);\n /** If a Sentry report dialog should be rendered on error */\n showDialog?: boolean;\n /**\n * Options to be passed into the Sentry report dialog.\n * No-op if {@link showDialog} is false.\n */\n dialogOptions?: ReportDialogOptions;\n /**\n * A fallback component that gets rendered when the error boundary encounters an error.\n *\n * Can either provide a React Component, or a function that returns React Component as\n * a valid fallback prop. If a function is provided, the function will be called with\n * the error, the component stack, and an function that resets the error boundary on error.\n *\n */\n fallback?: React.ReactElement | FallbackRender;\n /** Called when the error boundary encounters an error */\n onError?(error: Error, componentStack: string, eventId: string): void;\n /** Called on componentDidMount() */\n onMount?(): void;\n /** Called if resetError() is called from the fallback render props function */\n onReset?(error: Error | null, componentStack: string | null, eventId: string | null): void;\n /** Called on componentWillUnmount() */\n onUnmount?(error: Error | null, componentStack: string | null, eventId: string | null): void;\n /** Called before the error is captured by Sentry, allows for you to add tags or context using the scope */\n beforeCapture?(scope: Scope, error: Error | null, componentStack: string | null): void;\n};\n\ntype ErrorBoundaryState = {\n componentStack: React.ErrorInfo['componentStack'] | null;\n error: Error | null;\n eventId: string | null;\n};\n\nconst INITIAL_STATE = {\n componentStack: null,\n error: null,\n eventId: null,\n};\n\n/**\n * A ErrorBoundary component that logs errors to Sentry. Requires React >= 16.\n * NOTE: If you are a Sentry user, and you are seeing this stack frame, it means the\n * Sentry React SDK ErrorBoundary caught an error invoking your application code. This\n * is expected behavior and NOT indicative of a bug with the Sentry React SDK.\n */\nclass ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {\n public state: ErrorBoundaryState = INITIAL_STATE;\n\n public componentDidCatch(error: Error & { cause?: Error }, { componentStack }: React.ErrorInfo): void {\n const { beforeCapture, onError, showDialog, dialogOptions } = this.props;\n\n withScope(scope => {\n // If on React version >= 17, create stack trace from componentStack param and links\n // to to the original error using `error.cause` otherwise relies on error param for stacktrace.\n // Linking errors requires the `LinkedErrors` integration be enabled.\n if (isAtLeastReact17(React.version)) {\n const errorBoundaryError = new Error(error.message);\n errorBoundaryError.name = `React ErrorBoundary ${errorBoundaryError.name}`;\n errorBoundaryError.stack = componentStack;\n\n // Using the `LinkedErrors` integration to link the errors together.\n error.cause = errorBoundaryError;\n }\n\n if (beforeCapture) {\n beforeCapture(scope, error, componentStack);\n }\n const eventId = captureException(error, { contexts: { react: { componentStack } } });\n if (onError) {\n onError(error, componentStack, eventId);\n }\n if (showDialog) {\n showReportDialog({ ...dialogOptions, eventId });\n }\n\n // componentDidCatch is used over getDerivedStateFromError\n // so that componentStack is accessible through state.\n this.setState({ error, componentStack, eventId });\n });\n }\n\n public componentDidMount(): void {\n const { onMount } = this.props;\n if (onMount) {\n onMount();\n }\n }\n\n public componentWillUnmount(): void {\n const { error, componentStack, eventId } = this.state;\n const { onUnmount } = this.props;\n if (onUnmount) {\n onUnmount(error, componentStack, eventId);\n }\n }\n\n public resetErrorBoundary: () => void = () => {\n const { onReset } = this.props;\n const { error, componentStack, eventId } = this.state;\n if (onReset) {\n onReset(error, componentStack, eventId);\n }\n this.setState(INITIAL_STATE);\n };\n\n public render(): React.ReactNode {\n const { fallback, children } = this.props;\n const { error, componentStack, eventId } = this.state;\n\n if (error) {\n let element: React.ReactElement | undefined = undefined;\n if (typeof fallback === 'function') {\n element = fallback({ error, componentStack, resetError: this.resetErrorBoundary, eventId });\n } else {\n element = fallback;\n }\n\n if (React.isValidElement(element)) {\n return element;\n }\n\n if (fallback) {\n IS_DEBUG_BUILD && logger.warn('fallback did not produce a valid ReactElement');\n }\n\n // Fail gracefully if no fallback provided or is not valid\n return null;\n }\n\n if (typeof children === 'function') {\n return (children as () => React.ReactNode)();\n }\n return children;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction withErrorBoundary<P extends Record<string, any>>(\n WrappedComponent: React.ComponentType<P>,\n errorBoundaryOptions: ErrorBoundaryProps,\n): React.FC<P> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const componentDisplayName = WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;\n\n const Wrapped: React.FC<P> = (props: P) => (\n <ErrorBoundary {...errorBoundaryOptions}>\n <WrappedComponent {...props} />\n </ErrorBoundary>\n );\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n Wrapped.displayName = `errorBoundary(${componentDisplayName})`;\n\n // Copy over static methods from Wrapped component to Profiler HOC\n // See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over\n hoistNonReactStatics(Wrapped, WrappedComponent);\n return Wrapped;\n}\n\nexport { ErrorBoundary, withErrorBoundary };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;AAUA;;;;AA+CA;;;;AAIA;;AAEA;;;;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyFA;;AAEA;;;AAIA;;;;;;;;;;;;;;;AAiBA;;;;;"}
package/cjs/flags.js CHANGED
@@ -1,3 +1,5 @@
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+
1
3
  /*
2
4
  * This file defines flags and constants that can be modified during compile time in order to facilitate tree shaking
3
5
  * for users.
@@ -11,7 +13,9 @@
11
13
  * our, or the user's build process. Take care when introducing new flags - they must not throw if they are not
12
14
  * replaced.
13
15
  */
14
- Object.defineProperty(exports, "__esModule", { value: true });
16
+
15
17
  /** Flag that is true for debug builds, false otherwise. */
16
- exports.IS_DEBUG_BUILD = typeof __SENTRY_DEBUG__ === 'undefined' ? true : __SENTRY_DEBUG__;
17
- //# sourceMappingURL=flags.js.map
18
+ var IS_DEBUG_BUILD = typeof __SENTRY_DEBUG__ === 'undefined' ? true : __SENTRY_DEBUG__;
19
+
20
+ exports.IS_DEBUG_BUILD = IS_DEBUG_BUILD;
21
+ //# sourceMappingURL=flags.js.map
package/cjs/flags.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"flags.js","sourceRoot":"","sources":["../../src/flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;;AAIH,2DAA2D;AAC9C,QAAA,cAAc,GAAG,OAAO,gBAAgB,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC","sourcesContent":["/*\n * This file defines flags and constants that can be modified during compile time in order to facilitate tree shaking\n * for users.\n *\n * Debug flags need to be declared in each package individually and must not be imported across package boundaries,\n * because some build tools have trouble tree-shaking imported guards.\n *\n * As a convention, we define debug flags in a `flags.ts` file in the root of a package's `src` folder.\n *\n * Debug flag files will contain \"magic strings\" like `__SENTRY_DEBUG__` that may get replaced with actual values during\n * our, or the user's build process. Take care when introducing new flags - they must not throw if they are not\n * replaced.\n */\n\ndeclare const __SENTRY_DEBUG__: boolean;\n\n/** Flag that is true for debug builds, false otherwise. */\nexport const IS_DEBUG_BUILD = typeof __SENTRY_DEBUG__ === 'undefined' ? true : __SENTRY_DEBUG__;\n"]}
1
+ {"version":3,"file":"flags.js","sources":["../../src/flags.ts"],"sourcesContent":["/*\n * This file defines flags and constants that can be modified during compile time in order to facilitate tree shaking\n * for users.\n *\n * Debug flags need to be declared in each package individually and must not be imported across package boundaries,\n * because some build tools have trouble tree-shaking imported guards.\n *\n * As a convention, we define debug flags in a `flags.ts` file in the root of a package's `src` folder.\n *\n * Debug flag files will contain \"magic strings\" like `__SENTRY_DEBUG__` that may get replaced with actual values during\n * our, or the user's build process. Take care when introducing new flags - they must not throw if they are not\n * replaced.\n */\n\ndeclare const __SENTRY_DEBUG__: boolean;\n\n/** Flag that is true for debug builds, false otherwise. */\nexport const IS_DEBUG_BUILD = typeof __SENTRY_DEBUG__ === 'undefined' ? true : __SENTRY_DEBUG__;\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;;;;;"}
package/cjs/index.js CHANGED
@@ -1,21 +1,30 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- var tslib_1 = require("tslib");
3
- tslib_1.__exportStar(require("@sentry/browser"), exports);
4
- var sdk_1 = require("./sdk");
5
- exports.init = sdk_1.init;
6
- var profiler_1 = require("./profiler");
7
- exports.Profiler = profiler_1.Profiler;
8
- exports.withProfiler = profiler_1.withProfiler;
9
- exports.useProfiler = profiler_1.useProfiler;
10
- var errorboundary_1 = require("./errorboundary");
11
- exports.ErrorBoundary = errorboundary_1.ErrorBoundary;
12
- exports.withErrorBoundary = errorboundary_1.withErrorBoundary;
13
- var redux_1 = require("./redux");
14
- exports.createReduxEnhancer = redux_1.createReduxEnhancer;
15
- var reactrouterv3_1 = require("./reactrouterv3");
16
- exports.reactRouterV3Instrumentation = reactrouterv3_1.reactRouterV3Instrumentation;
17
- var reactrouter_1 = require("./reactrouter");
18
- exports.reactRouterV4Instrumentation = reactrouter_1.reactRouterV4Instrumentation;
19
- exports.reactRouterV5Instrumentation = reactrouter_1.reactRouterV5Instrumentation;
20
- exports.withSentryRouting = reactrouter_1.withSentryRouting;
21
- //# sourceMappingURL=index.js.map
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+
3
+ var browser = require('@sentry/browser');
4
+ var sdk = require('./sdk.js');
5
+ var profiler = require('./profiler.js');
6
+ var errorboundary = require('./errorboundary.js');
7
+ var redux = require('./redux.js');
8
+ var reactrouterv3 = require('./reactrouterv3.js');
9
+ var reactrouter = require('./reactrouter.js');
10
+ var reactrouterv6 = require('./reactrouterv6.js');
11
+
12
+
13
+
14
+ exports.init = sdk.init;
15
+ exports.Profiler = profiler.Profiler;
16
+ exports.useProfiler = profiler.useProfiler;
17
+ exports.withProfiler = profiler.withProfiler;
18
+ exports.ErrorBoundary = errorboundary.ErrorBoundary;
19
+ exports.withErrorBoundary = errorboundary.withErrorBoundary;
20
+ exports.createReduxEnhancer = redux.createReduxEnhancer;
21
+ exports.reactRouterV3Instrumentation = reactrouterv3.reactRouterV3Instrumentation;
22
+ exports.reactRouterV4Instrumentation = reactrouter.reactRouterV4Instrumentation;
23
+ exports.reactRouterV5Instrumentation = reactrouter.reactRouterV5Instrumentation;
24
+ exports.withSentryRouting = reactrouter.withSentryRouting;
25
+ exports.reactRouterV6Instrumentation = reactrouterv6.reactRouterV6Instrumentation;
26
+ exports.withSentryReactRouterV6Routing = reactrouterv6.withSentryReactRouterV6Routing;
27
+ for (var k in browser) {
28
+ if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = browser[k];
29
+ }
30
+ //# sourceMappingURL=index.js.map
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AAAA,0DAAgC;AAEhC,6BAA6B;AAApB,qBAAA,IAAI,CAAA;AACb,uCAAiE;AAAxD,8BAAA,QAAQ,CAAA;AAAE,kCAAA,YAAY,CAAA;AAAE,iCAAA,WAAW,CAAA;AAC5C,iDAAmE;AAA1D,wCAAA,aAAa,CAAA;AAAE,4CAAA,iBAAiB,CAAA;AACzC,iCAA8C;AAArC,sCAAA,mBAAmB,CAAA;AAC5B,iDAA+D;AAAtD,uDAAA,4BAA4B,CAAA;AACrC,6CAA8G;AAArG,qDAAA,4BAA4B,CAAA;AAAE,qDAAA,4BAA4B,CAAA;AAAE,0CAAA,iBAAiB,CAAA","sourcesContent":["export * from '@sentry/browser';\n\nexport { init } from './sdk';\nexport { Profiler, withProfiler, useProfiler } from './profiler';\nexport { ErrorBoundary, withErrorBoundary } from './errorboundary';\nexport { createReduxEnhancer } from './redux';\nexport { reactRouterV3Instrumentation } from './reactrouterv3';\nexport { reactRouterV4Instrumentation, reactRouterV5Instrumentation, withSentryRouting } from './reactrouter';\n"]}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}