@sentry/react 7.0.0-beta.0 → 7.0.0-beta.1

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 (90) 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 +134 -102
  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 +172 -134
  11. package/cjs/profiler.js.map +1 -1
  12. package/cjs/reactrouter.js +147 -93
  13. package/cjs/reactrouter.js.map +1 -1
  14. package/cjs/reactrouterv3.js +107 -75
  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 +54 -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 +120 -97
  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 +154 -125
  31. package/esm/profiler.js.map +1 -1
  32. package/esm/reactrouter.js +133 -86
  33. package/esm/reactrouter.js.map +1 -1
  34. package/esm/reactrouterv3.js +104 -72
  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 +51 -40
  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 -4
  43. package/types/index.d.ts +1 -0
  44. package/types/index.d.ts.map +1 -1
  45. package/types/reactrouterv6.d.ts +27 -0
  46. package/types/reactrouterv6.d.ts.map +1 -0
  47. package/cjs/constants.d.ts +0 -4
  48. package/cjs/constants.d.ts.map +0 -1
  49. package/cjs/errorboundary.d.ts +0 -63
  50. package/cjs/errorboundary.d.ts.map +0 -1
  51. package/cjs/flags.d.ts +0 -3
  52. package/cjs/flags.d.ts.map +0 -1
  53. package/cjs/index.d.ts +0 -8
  54. package/cjs/index.d.ts.map +0 -1
  55. package/cjs/profiler.d.ts +0 -54
  56. package/cjs/profiler.d.ts.map +0 -1
  57. package/cjs/reactrouter.d.ts +0 -25
  58. package/cjs/reactrouter.d.ts.map +0 -1
  59. package/cjs/reactrouterv3.d.ts +0 -26
  60. package/cjs/reactrouterv3.d.ts.map +0 -1
  61. package/cjs/redux.d.ts +0 -33
  62. package/cjs/redux.d.ts.map +0 -1
  63. package/cjs/sdk.d.ts +0 -6
  64. package/cjs/sdk.d.ts.map +0 -1
  65. package/cjs/types.d.ts +0 -8
  66. package/cjs/types.d.ts.map +0 -1
  67. package/cjs/types.js +0 -2
  68. package/cjs/types.js.map +0 -1
  69. package/esm/constants.d.ts +0 -4
  70. package/esm/constants.d.ts.map +0 -1
  71. package/esm/errorboundary.d.ts +0 -63
  72. package/esm/errorboundary.d.ts.map +0 -1
  73. package/esm/flags.d.ts +0 -3
  74. package/esm/flags.d.ts.map +0 -1
  75. package/esm/index.d.ts +0 -8
  76. package/esm/index.d.ts.map +0 -1
  77. package/esm/profiler.d.ts +0 -54
  78. package/esm/profiler.d.ts.map +0 -1
  79. package/esm/reactrouter.d.ts +0 -25
  80. package/esm/reactrouter.d.ts.map +0 -1
  81. package/esm/reactrouterv3.d.ts +0 -26
  82. package/esm/reactrouterv3.d.ts.map +0 -1
  83. package/esm/redux.d.ts +0 -33
  84. package/esm/redux.d.ts.map +0 -1
  85. package/esm/sdk.d.ts +0 -6
  86. package/esm/sdk.d.ts.map +0 -1
  87. package/esm/types.d.ts +0 -8
  88. package/esm/types.d.ts.map +0 -1
  89. package/esm/types.js +0 -1
  90. package/esm/types.js.map +0 -1
package/esm/constants.js CHANGED
@@ -1,4 +1,8 @@
1
- export const REACT_RENDER_OP = 'ui.react.render';
2
- export const REACT_UPDATE_OP = 'ui.react.update';
3
- export const REACT_MOUNT_OP = 'ui.react.mount';
4
- //# sourceMappingURL=constants.js.map
1
+ var REACT_RENDER_OP = 'ui.react.render';
2
+
3
+ var REACT_UPDATE_OP = 'ui.react.update';
4
+
5
+ var REACT_MOUNT_OP = 'ui.react.mount';
6
+
7
+ export { REACT_MOUNT_OP, REACT_RENDER_OP, REACT_UPDATE_OP };
8
+ //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAEjD,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAEjD,MAAM,CAAC,MAAM,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,116 +1,139 @@
1
- import { captureException, showReportDialog, withScope } from '@sentry/browser';
1
+ import { withScope, captureException, showReportDialog } from '@sentry/browser';
2
2
  import { logger } from '@sentry/utils';
3
3
  import hoistNonReactStatics from 'hoist-non-react-statics';
4
4
  import * as React from 'react';
5
- import { IS_DEBUG_BUILD } from './flags';
6
- export function isAtLeastReact17(version) {
7
- const major = version.match(/^([^.]+)/);
8
- return major !== null && parseInt(major[0]) >= 17;
5
+ import { IS_DEBUG_BUILD } from './flags.js';
6
+
7
+ var _jsxFileName = "/home/runner/work/sentry-javascript/sentry-javascript/packages/react/src/errorboundary.tsx";
8
+ function isAtLeastReact17(version) {
9
+ var major = version.match(/^([^.]+)/);
10
+ return major !== null && parseInt(major[0]) >= 17;
9
11
  }
10
- export const UNKNOWN_COMPONENT = 'unknown';
11
- const INITIAL_STATE = {
12
- componentStack: null,
13
- error: null,
14
- eventId: null,
12
+
13
+ var UNKNOWN_COMPONENT = 'unknown';
14
+
15
+ var INITIAL_STATE = {
16
+ componentStack: null,
17
+ error: null,
18
+ eventId: null,
15
19
  };
20
+
16
21
  /**
17
22
  * A ErrorBoundary component that logs errors to Sentry. Requires React >= 16.
18
23
  * NOTE: If you are a Sentry user, and you are seeing this stack frame, it means the
19
24
  * Sentry React SDK ErrorBoundary caught an error invoking your application code. This
20
25
  * is expected behavior and NOT indicative of a bug with the Sentry React SDK.
21
26
  */
22
- class ErrorBoundary extends React.Component {
23
- constructor() {
24
- super(...arguments);
25
- this.state = INITIAL_STATE;
26
- this.resetErrorBoundary = () => {
27
- const { onReset } = this.props;
28
- const { error, componentStack, eventId } = this.state;
29
- if (onReset) {
30
- onReset(error, componentStack, eventId);
31
- }
32
- this.setState(INITIAL_STATE);
33
- };
27
+ class ErrorBoundary extends React.Component {constructor(...args) { super(...args); ErrorBoundary.prototype.__init.call(this);ErrorBoundary.prototype.__init2.call(this); }
28
+ __init() {this.state = INITIAL_STATE;}
29
+
30
+ componentDidCatch(error, { componentStack }) {
31
+ const { beforeCapture, onError, showDialog, dialogOptions } = this.props;
32
+
33
+ withScope(scope => {
34
+ // If on React version >= 17, create stack trace from componentStack param and links
35
+ // to to the original error using `error.cause` otherwise relies on error param for stacktrace.
36
+ // Linking errors requires the `LinkedErrors` integration be enabled.
37
+ if (isAtLeastReact17(React.version)) {
38
+ var errorBoundaryError = new Error(error.message);
39
+ errorBoundaryError.name = `React ErrorBoundary ${errorBoundaryError.name}`;
40
+ errorBoundaryError.stack = componentStack;
41
+
42
+ // Using the `LinkedErrors` integration to link the errors together.
43
+ error.cause = errorBoundaryError;
44
+ }
45
+
46
+ if (beforeCapture) {
47
+ beforeCapture(scope, error, componentStack);
48
+ }
49
+ var eventId = captureException(error, { contexts: { react: { componentStack } } });
50
+ if (onError) {
51
+ onError(error, componentStack, eventId);
52
+ }
53
+ if (showDialog) {
54
+ showReportDialog({ ...dialogOptions, eventId });
55
+ }
56
+
57
+ // componentDidCatch is used over getDerivedStateFromError
58
+ // so that componentStack is accessible through state.
59
+ this.setState({ error, componentStack, eventId });
60
+ });
61
+ }
62
+
63
+ componentDidMount() {
64
+ const { onMount } = this.props;
65
+ if (onMount) {
66
+ onMount();
34
67
  }
35
- componentDidCatch(error, { componentStack }) {
36
- const { beforeCapture, onError, showDialog, dialogOptions } = this.props;
37
- withScope(scope => {
38
- // If on React version >= 17, create stack trace from componentStack param and links
39
- // to to the original error using `error.cause` otherwise relies on error param for stacktrace.
40
- // Linking errors requires the `LinkedErrors` integration be enabled.
41
- if (isAtLeastReact17(React.version)) {
42
- const errorBoundaryError = new Error(error.message);
43
- errorBoundaryError.name = `React ErrorBoundary ${errorBoundaryError.name}`;
44
- errorBoundaryError.stack = componentStack;
45
- // Using the `LinkedErrors` integration to link the errors together.
46
- error.cause = errorBoundaryError;
47
- }
48
- if (beforeCapture) {
49
- beforeCapture(scope, error, componentStack);
50
- }
51
- const eventId = captureException(error, { contexts: { react: { componentStack } } });
52
- if (onError) {
53
- onError(error, componentStack, eventId);
54
- }
55
- if (showDialog) {
56
- showReportDialog(Object.assign(Object.assign({}, dialogOptions), { eventId }));
57
- }
58
- // componentDidCatch is used over getDerivedStateFromError
59
- // so that componentStack is accessible through state.
60
- this.setState({ error, componentStack, eventId });
61
- });
68
+ }
69
+
70
+ componentWillUnmount() {
71
+ const { error, componentStack, eventId } = this.state;
72
+ const { onUnmount } = this.props;
73
+ if (onUnmount) {
74
+ onUnmount(error, componentStack, eventId);
62
75
  }
63
- componentDidMount() {
64
- const { onMount } = this.props;
65
- if (onMount) {
66
- onMount();
67
- }
76
+ }
77
+
78
+ __init2() {this.resetErrorBoundary = () => {
79
+ const { onReset } = this.props;
80
+ const { error, componentStack, eventId } = this.state;
81
+ if (onReset) {
82
+ onReset(error, componentStack, eventId);
68
83
  }
69
- componentWillUnmount() {
70
- const { error, componentStack, eventId } = this.state;
71
- const { onUnmount } = this.props;
72
- if (onUnmount) {
73
- onUnmount(error, componentStack, eventId);
74
- }
84
+ this.setState(INITIAL_STATE);
85
+ };}
86
+
87
+ render() {
88
+ const { fallback, children } = this.props;
89
+ const { error, componentStack, eventId } = this.state;
90
+
91
+ if (error) {
92
+ let element = undefined;
93
+ if (typeof fallback === 'function') {
94
+ element = fallback({ error, componentStack, resetError: this.resetErrorBoundary, eventId });
95
+ } else {
96
+ element = fallback;
97
+ }
98
+
99
+ if (React.isValidElement(element)) {
100
+ return element;
101
+ }
102
+
103
+ if (fallback) {
104
+ IS_DEBUG_BUILD && logger.warn('fallback did not produce a valid ReactElement');
105
+ }
106
+
107
+ // Fail gracefully if no fallback provided or is not valid
108
+ return null;
75
109
  }
76
- render() {
77
- const { fallback, children } = this.props;
78
- const { error, componentStack, eventId } = this.state;
79
- if (error) {
80
- let element = undefined;
81
- if (typeof fallback === 'function') {
82
- element = fallback({ error, componentStack, resetError: this.resetErrorBoundary, eventId });
83
- }
84
- else {
85
- element = fallback;
86
- }
87
- if (React.isValidElement(element)) {
88
- return element;
89
- }
90
- if (fallback) {
91
- IS_DEBUG_BUILD && logger.warn('fallback did not produce a valid ReactElement');
92
- }
93
- // Fail gracefully if no fallback provided or is not valid
94
- return null;
95
- }
96
- if (typeof children === 'function') {
97
- return children();
98
- }
99
- return children;
110
+
111
+ if (typeof children === 'function') {
112
+ return (children )();
100
113
  }
114
+ return children;
115
+ }
101
116
  }
102
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
103
- function withErrorBoundary(WrappedComponent, errorBoundaryOptions) {
104
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
105
- const componentDisplayName = WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;
106
- const Wrapped = (props) => (React.createElement(ErrorBoundary, Object.assign({}, errorBoundaryOptions),
107
- React.createElement(WrappedComponent, Object.assign({}, props))));
108
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
117
+
118
+ function withErrorBoundary(
119
+ WrappedComponent,
120
+ errorBoundaryOptions,
121
+ ) {
122
+ var componentDisplayName = WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;
123
+
124
+ var Wrapped = (props) => (
125
+ React.createElement(ErrorBoundary, { ...errorBoundaryOptions, __self: this, __source: {fileName: _jsxFileName, lineNumber: 170}}
126
+ , React.createElement(WrappedComponent, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 171}} )
127
+ )
128
+ );
129
+
109
130
  Wrapped.displayName = `errorBoundary(${componentDisplayName})`;
110
- // Copy over static methods from Wrapped component to Profiler HOC
111
- // See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over
112
- hoistNonReactStatics(Wrapped, WrappedComponent);
113
- return Wrapped;
131
+
132
+ // Copy over static methods from Wrapped component to Profiler HOC
133
+ // See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over
134
+ hoistNonReactStatics(Wrapped, WrappedComponent);
135
+ return Wrapped;
114
136
  }
115
- export { ErrorBoundary, withErrorBoundary };
116
- //# sourceMappingURL=errorboundary.js.map
137
+
138
+ export { ErrorBoundary, UNKNOWN_COMPONENT, isAtLeastReact17, withErrorBoundary };
139
+ //# sourceMappingURL=errorboundary.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errorboundary.js","sourceRoot":"","sources":["../../src/errorboundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA8B,gBAAgB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,EAAE,MAAM,EAAE,MAAM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,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IAChD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC","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"]}
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,gHAMA;;AAEA;AACA;AACA;AACA;;;AA8CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;;;;"}
package/esm/flags.js CHANGED
@@ -11,6 +11,9 @@
11
11
  * our, or the user's build process. Take care when introducing new flags - they must not throw if they are not
12
12
  * replaced.
13
13
  */
14
+
14
15
  /** Flag that is true for debug builds, false otherwise. */
15
- export const IS_DEBUG_BUILD = typeof __SENTRY_DEBUG__ === 'undefined' ? true : __SENTRY_DEBUG__;
16
- //# sourceMappingURL=flags.js.map
16
+ var IS_DEBUG_BUILD = typeof __SENTRY_DEBUG__ === 'undefined' ? true : __SENTRY_DEBUG__;
17
+
18
+ export { IS_DEBUG_BUILD };
19
+ //# sourceMappingURL=flags.js.map
package/esm/flags.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"flags.js","sourceRoot":"","sources":["../../src/flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,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/esm/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  export * from '@sentry/browser';
2
- export { init } from './sdk';
3
- export { Profiler, withProfiler, useProfiler } from './profiler';
4
- export { ErrorBoundary, withErrorBoundary } from './errorboundary';
5
- export { createReduxEnhancer } from './redux';
6
- export { reactRouterV3Instrumentation } from './reactrouterv3';
7
- export { reactRouterV4Instrumentation, reactRouterV5Instrumentation, withSentryRouting } from './reactrouter';
8
- //# sourceMappingURL=index.js.map
2
+ export { init } from './sdk.js';
3
+ export { Profiler, useProfiler, withProfiler } from './profiler.js';
4
+ export { ErrorBoundary, withErrorBoundary } from './errorboundary.js';
5
+ export { createReduxEnhancer } from './redux.js';
6
+ export { reactRouterV3Instrumentation } from './reactrouterv3.js';
7
+ export { reactRouterV4Instrumentation, reactRouterV5Instrumentation, withSentryRouting } from './reactrouter.js';
8
+ export { reactRouterV6Instrumentation, withSentryReactRouterV6Routing } from './reactrouterv6.js';
9
+ //# sourceMappingURL=index.js.map
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,4BAA4B,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC","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":";;;;;;;"}