@sentry/react 7.67.0-beta.0 → 7.68.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.
@@ -103,7 +103,14 @@ class ErrorBoundary extends React__namespace.Component {
103
103
  if (beforeCapture) {
104
104
  beforeCapture(scope, error, componentStack);
105
105
  }
106
+
107
+ scope.addEventProcessor(event => {
108
+ utils.addExceptionMechanism(event, { handled: false });
109
+ return event;
110
+ });
111
+
106
112
  const eventId = browser.captureException(error, { contexts: { react: { componentStack } } });
113
+
107
114
  if (onError) {
108
115
  onError(error, componentStack, eventId);
109
116
  }
@@ -189,8 +196,8 @@ function withErrorBoundary(
189
196
  const componentDisplayName = WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;
190
197
 
191
198
  const Wrapped = (props) => (
192
- React__namespace.createElement(ErrorBoundary, { ...errorBoundaryOptions, __self: this, __source: {fileName: _jsxFileName, lineNumber: 227}}
193
- , React__namespace.createElement(WrappedComponent, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 228}} )
199
+ React__namespace.createElement(ErrorBoundary, { ...errorBoundaryOptions, __self: this, __source: {fileName: _jsxFileName, lineNumber: 234}}
200
+ , React__namespace.createElement(WrappedComponent, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 235}} )
194
201
  )
195
202
  );
196
203
 
@@ -1 +1 @@
1
- {"version":3,"file":"errorboundary.js","sources":["../../src/errorboundary.tsx"],"sourcesContent":["import type { ReportDialogOptions, Scope } from '@sentry/browser';\nimport { captureException, getCurrentHub, showReportDialog, withScope } from '@sentry/browser';\nimport { isError, logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\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;\n eventId: string;\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 | {\n componentStack: null;\n error: null;\n eventId: null;\n }\n | {\n componentStack: React.ErrorInfo['componentStack'];\n error: Error;\n eventId: string;\n };\n\nconst INITIAL_STATE = {\n componentStack: null,\n error: null,\n eventId: null,\n};\n\nfunction setCause(error: Error & { cause?: Error }, cause: Error): void {\n const seenErrors = new WeakMap<Error, boolean>();\n\n function recurse(error: Error & { cause?: Error }, cause: Error): void {\n // If we've already seen the error, there is a recursive loop somewhere in the error's\n // cause chain. Let's just bail out then to prevent a stack overflow.\n if (seenErrors.has(error)) {\n return;\n }\n if (error.cause) {\n seenErrors.set(error, true);\n return recurse(error.cause, cause);\n }\n error.cause = cause;\n }\n\n recurse(error, cause);\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;\n\n private readonly _openFallbackReportDialog: boolean;\n\n private _lastEventId?: string;\n\n public constructor(props: ErrorBoundaryProps) {\n super(props);\n\n this.state = INITIAL_STATE;\n this._openFallbackReportDialog = true;\n\n const client = getCurrentHub().getClient();\n if (client && client.on && props.showDialog) {\n this._openFallbackReportDialog = false;\n client.on('afterSendEvent', event => {\n if (!event.type && event.event_id === this._lastEventId) {\n showReportDialog({ ...props.dialogOptions, eventId: this._lastEventId });\n }\n });\n }\n }\n\n public componentDidCatch(error: Error & { cause?: Error }, { componentStack }: React.ErrorInfo): void {\n const { beforeCapture, onError, showDialog, dialogOptions } = this.props;\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 // See: https://reactjs.org/blog/2020/08/10/react-v17-rc.html#native-component-stacks\n //\n // Although `componentDidCatch` is typed to accept an `Error` object, it can also be invoked\n // with non-error objects. This is why we need to check if the error is an error-like object.\n // See: https://github.com/getsentry/sentry-javascript/issues/6167\n if (isAtLeastReact17(React.version) && isError(error)) {\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 setCause(error, 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 this._lastEventId = eventId;\n if (this._openFallbackReportDialog) {\n showReportDialog({ ...dialogOptions, eventId });\n }\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 state = this.state;\n\n if (state.error) {\n let element: React.ReactElement | undefined = undefined;\n if (typeof fallback === 'function') {\n element = fallback({\n error: state.error,\n componentStack: state.componentStack,\n resetError: this.resetErrorBoundary,\n eventId: state.eventId,\n });\n } else {\n element = fallback;\n }\n\n if (React.isValidElement(element)) {\n return element;\n }\n\n if (fallback) {\n __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":["React","getCurrentHub","showReportDialog","withScope","isError","captureException","logger","hoistNonReactStatics"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAA,YAAA,GAAA,4FAAA,CAAA;AAKA;AACA,SAAA,gBAAA,CAAA,OAAA,EAAA;AACA,EAAA,MAAA,KAAA,GAAA,OAAA,CAAA,KAAA,CAAA,UAAA,CAAA,CAAA;AACA,EAAA,OAAA,KAAA,KAAA,IAAA,IAAA,QAAA,CAAA,KAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EAAA,CAAA;AACA,CAAA;AACA;AACA,MAAA,iBAAA,GAAA,UAAA;;AAmDA,MAAA,aAAA,GAAA;AACA,EAAA,cAAA,EAAA,IAAA;AACA,EAAA,KAAA,EAAA,IAAA;AACA,EAAA,OAAA,EAAA,IAAA;AACA,CAAA,CAAA;AACA;AACA,SAAA,QAAA,CAAA,KAAA,EAAA,KAAA,EAAA;AACA,EAAA,MAAA,UAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AACA;AACA,EAAA,SAAA,OAAA,CAAA,KAAA,EAAA,KAAA,EAAA;AACA;AACA;AACA,IAAA,IAAA,UAAA,CAAA,GAAA,CAAA,KAAA,CAAA,EAAA;AACA,MAAA,OAAA;AACA,KAAA;AACA,IAAA,IAAA,KAAA,CAAA,KAAA,EAAA;AACA,MAAA,UAAA,CAAA,GAAA,CAAA,KAAA,EAAA,IAAA,CAAA,CAAA;AACA,MAAA,OAAA,OAAA,CAAA,KAAA,CAAA,KAAA,EAAA,KAAA,CAAA,CAAA;AACA,KAAA;AACA,IAAA,KAAA,CAAA,KAAA,GAAA,KAAA,CAAA;AACA,GAAA;AACA;AACA,EAAA,OAAA,CAAA,KAAA,EAAA,KAAA,CAAA,CAAA;AACA,CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAA,aAAA,SAAAA,gBAAA,CAAA,SAAA,CAAA;;AAOA,GAAA,WAAA,CAAA,KAAA,EAAA;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AAA,IAAA,CAAA,+CAAA,CAAA,CAAA;AACA,OAAA;AACA;AACA;AACA,MAAA,OAAA,IAAA,CAAA;AACA,KAAA;AACA;AACA,IAAA,IAAA,OAAA,QAAA,KAAA,UAAA,EAAA;AACA,MAAA,OAAA,CAAA,QAAA,IAAA,CAAA;AACA,KAAA;AACA,IAAA,OAAA,QAAA,CAAA;AACA,GAAA;AACA,CAAA;AACA;AACA;AACA,SAAA,iBAAA;AACA,EAAA,gBAAA;AACA,EAAA,oBAAA;AACA,EAAA;AACA;AACA,EAAA,MAAA,oBAAA,GAAA,gBAAA,CAAA,WAAA,IAAA,gBAAA,CAAA,IAAA,IAAA,iBAAA,CAAA;AACA;AACA,EAAA,MAAA,OAAA,GAAA,CAAA,KAAA;AACA,IAAAN,gBAAA,CAAA,aAAA,CAAA,aAAA,EAAA,EAAA,GAAA,oBAAA,EAAA,MAAA,EAAA,IAAA,EAAA,QAAA,EAAA,CAAA,QAAA,EAAA,YAAA,EAAA,UAAA,EAAA,GAAA,CAAA,CAAA;AACA,QAAAA,gBAAA,CAAA,aAAA,CAAA,gBAAA,EAAA,EAAA,GAAA,KAAA,EAAA,MAAA,EAAA,IAAA,EAAA,QAAA,EAAA,CAAA,QAAA,EAAA,YAAA,EAAA,UAAA,EAAA,GAAA,CAAA,CAAA,EAAA;AACA,KAAA;AACA,GAAA,CAAA;AACA;AACA;AACA,EAAA,OAAA,CAAA,WAAA,GAAA,CAAA,cAAA,EAAA,oBAAA,CAAA,CAAA,CAAA,CAAA;AACA;AACA;AACA;AACA,EAAAO,6BAAA,CAAA,OAAA,EAAA,gBAAA,CAAA,CAAA;AACA,EAAA,OAAA,OAAA,CAAA;AACA;;;;;;;"}
1
+ {"version":3,"file":"errorboundary.js","sources":["../../src/errorboundary.tsx"],"sourcesContent":["import type { ReportDialogOptions, Scope } from '@sentry/browser';\nimport { captureException, getCurrentHub, showReportDialog, withScope } from '@sentry/browser';\nimport { addExceptionMechanism, isError, logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\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;\n eventId: string;\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 | {\n componentStack: null;\n error: null;\n eventId: null;\n }\n | {\n componentStack: React.ErrorInfo['componentStack'];\n error: Error;\n eventId: string;\n };\n\nconst INITIAL_STATE = {\n componentStack: null,\n error: null,\n eventId: null,\n};\n\nfunction setCause(error: Error & { cause?: Error }, cause: Error): void {\n const seenErrors = new WeakMap<Error, boolean>();\n\n function recurse(error: Error & { cause?: Error }, cause: Error): void {\n // If we've already seen the error, there is a recursive loop somewhere in the error's\n // cause chain. Let's just bail out then to prevent a stack overflow.\n if (seenErrors.has(error)) {\n return;\n }\n if (error.cause) {\n seenErrors.set(error, true);\n return recurse(error.cause, cause);\n }\n error.cause = cause;\n }\n\n recurse(error, cause);\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;\n\n private readonly _openFallbackReportDialog: boolean;\n\n private _lastEventId?: string;\n\n public constructor(props: ErrorBoundaryProps) {\n super(props);\n\n this.state = INITIAL_STATE;\n this._openFallbackReportDialog = true;\n\n const client = getCurrentHub().getClient();\n if (client && client.on && props.showDialog) {\n this._openFallbackReportDialog = false;\n client.on('afterSendEvent', event => {\n if (!event.type && event.event_id === this._lastEventId) {\n showReportDialog({ ...props.dialogOptions, eventId: this._lastEventId });\n }\n });\n }\n }\n\n public componentDidCatch(error: Error & { cause?: Error }, { componentStack }: React.ErrorInfo): void {\n const { beforeCapture, onError, showDialog, dialogOptions } = this.props;\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 // See: https://reactjs.org/blog/2020/08/10/react-v17-rc.html#native-component-stacks\n //\n // Although `componentDidCatch` is typed to accept an `Error` object, it can also be invoked\n // with non-error objects. This is why we need to check if the error is an error-like object.\n // See: https://github.com/getsentry/sentry-javascript/issues/6167\n if (isAtLeastReact17(React.version) && isError(error)) {\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 setCause(error, errorBoundaryError);\n }\n\n if (beforeCapture) {\n beforeCapture(scope, error, componentStack);\n }\n\n scope.addEventProcessor(event => {\n addExceptionMechanism(event, { handled: false })\n return event;\n })\n\n const eventId = captureException(error, { contexts: { react: { componentStack } } });\n\n if (onError) {\n onError(error, componentStack, eventId);\n }\n if (showDialog) {\n this._lastEventId = eventId;\n if (this._openFallbackReportDialog) {\n showReportDialog({ ...dialogOptions, eventId });\n }\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 state = this.state;\n\n if (state.error) {\n let element: React.ReactElement | undefined = undefined;\n if (typeof fallback === 'function') {\n element = fallback({\n error: state.error,\n componentStack: state.componentStack,\n resetError: this.resetErrorBoundary,\n eventId: state.eventId,\n });\n } else {\n element = fallback;\n }\n\n if (React.isValidElement(element)) {\n return element;\n }\n\n if (fallback) {\n __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":["React","getCurrentHub","showReportDialog","withScope","isError","addExceptionMechanism","captureException","logger","hoistNonReactStatics"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAA,YAAA,GAAA,4FAAA,CAAA;AAKA;AACA,SAAA,gBAAA,CAAA,OAAA,EAAA;AACA,EAAA,MAAA,KAAA,GAAA,OAAA,CAAA,KAAA,CAAA,UAAA,CAAA,CAAA;AACA,EAAA,OAAA,KAAA,KAAA,IAAA,IAAA,QAAA,CAAA,KAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EAAA,CAAA;AACA,CAAA;AACA;AACA,MAAA,iBAAA,GAAA,UAAA;;AAmDA,MAAA,aAAA,GAAA;AACA,EAAA,cAAA,EAAA,IAAA;AACA,EAAA,KAAA,EAAA,IAAA;AACA,EAAA,OAAA,EAAA,IAAA;AACA,CAAA,CAAA;AACA;AACA,SAAA,QAAA,CAAA,KAAA,EAAA,KAAA,EAAA;AACA,EAAA,MAAA,UAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AACA;AACA,EAAA,SAAA,OAAA,CAAA,KAAA,EAAA,KAAA,EAAA;AACA;AACA;AACA,IAAA,IAAA,UAAA,CAAA,GAAA,CAAA,KAAA,CAAA,EAAA;AACA,MAAA,OAAA;AACA,KAAA;AACA,IAAA,IAAA,KAAA,CAAA,KAAA,EAAA;AACA,MAAA,UAAA,CAAA,GAAA,CAAA,KAAA,EAAA,IAAA,CAAA,CAAA;AACA,MAAA,OAAA,OAAA,CAAA,KAAA,CAAA,KAAA,EAAA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A,EAAA,UAAA,EAAA,GAAA,CAAA,CAAA,EAAA;AACA,KAAA;AACA,GAAA,CAAA;AACA;AACA;AACA,EAAA,OAAA,CAAA,WAAA,GAAA,CAAA,cAAA,EAAA,oBAAA,CAAA,CAAA,CAAA,CAAA;AACA;AACA;AACA;AACA,EAAAQ,6BAAA,CAAA,OAAA,EAAA,gBAAA,CAAA,CAAA;AACA,EAAA,OAAA,OAAA,CAAA;AACA;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { getCurrentHub, showReportDialog, withScope, captureException } from '@sentry/browser';
2
- import { isError, logger } from '@sentry/utils';
2
+ import { isError, addExceptionMechanism, logger } from '@sentry/utils';
3
3
  import hoistNonReactStatics from 'hoist-non-react-statics';
4
4
  import * as React from 'react';
5
5
 
@@ -84,7 +84,14 @@ class ErrorBoundary extends React.Component {
84
84
  if (beforeCapture) {
85
85
  beforeCapture(scope, error, componentStack);
86
86
  }
87
+
88
+ scope.addEventProcessor(event => {
89
+ addExceptionMechanism(event, { handled: false });
90
+ return event;
91
+ });
92
+
87
93
  const eventId = captureException(error, { contexts: { react: { componentStack } } });
94
+
88
95
  if (onError) {
89
96
  onError(error, componentStack, eventId);
90
97
  }
@@ -170,8 +177,8 @@ function withErrorBoundary(
170
177
  const componentDisplayName = WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;
171
178
 
172
179
  const Wrapped = (props) => (
173
- React.createElement(ErrorBoundary, { ...errorBoundaryOptions, __self: this, __source: {fileName: _jsxFileName, lineNumber: 227}}
174
- , React.createElement(WrappedComponent, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 228}} )
180
+ React.createElement(ErrorBoundary, { ...errorBoundaryOptions, __self: this, __source: {fileName: _jsxFileName, lineNumber: 234}}
181
+ , React.createElement(WrappedComponent, { ...props, __self: this, __source: {fileName: _jsxFileName, lineNumber: 235}} )
175
182
  )
176
183
  );
177
184
 
@@ -1 +1 @@
1
- {"version":3,"file":"errorboundary.js","sources":["../../src/errorboundary.tsx"],"sourcesContent":["import type { ReportDialogOptions, Scope } from '@sentry/browser';\nimport { captureException, getCurrentHub, showReportDialog, withScope } from '@sentry/browser';\nimport { isError, logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\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;\n eventId: string;\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 | {\n componentStack: null;\n error: null;\n eventId: null;\n }\n | {\n componentStack: React.ErrorInfo['componentStack'];\n error: Error;\n eventId: string;\n };\n\nconst INITIAL_STATE = {\n componentStack: null,\n error: null,\n eventId: null,\n};\n\nfunction setCause(error: Error & { cause?: Error }, cause: Error): void {\n const seenErrors = new WeakMap<Error, boolean>();\n\n function recurse(error: Error & { cause?: Error }, cause: Error): void {\n // If we've already seen the error, there is a recursive loop somewhere in the error's\n // cause chain. Let's just bail out then to prevent a stack overflow.\n if (seenErrors.has(error)) {\n return;\n }\n if (error.cause) {\n seenErrors.set(error, true);\n return recurse(error.cause, cause);\n }\n error.cause = cause;\n }\n\n recurse(error, cause);\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;\n\n private readonly _openFallbackReportDialog: boolean;\n\n private _lastEventId?: string;\n\n public constructor(props: ErrorBoundaryProps) {\n super(props);\n\n this.state = INITIAL_STATE;\n this._openFallbackReportDialog = true;\n\n const client = getCurrentHub().getClient();\n if (client && client.on && props.showDialog) {\n this._openFallbackReportDialog = false;\n client.on('afterSendEvent', event => {\n if (!event.type && event.event_id === this._lastEventId) {\n showReportDialog({ ...props.dialogOptions, eventId: this._lastEventId });\n }\n });\n }\n }\n\n public componentDidCatch(error: Error & { cause?: Error }, { componentStack }: React.ErrorInfo): void {\n const { beforeCapture, onError, showDialog, dialogOptions } = this.props;\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 // See: https://reactjs.org/blog/2020/08/10/react-v17-rc.html#native-component-stacks\n //\n // Although `componentDidCatch` is typed to accept an `Error` object, it can also be invoked\n // with non-error objects. This is why we need to check if the error is an error-like object.\n // See: https://github.com/getsentry/sentry-javascript/issues/6167\n if (isAtLeastReact17(React.version) && isError(error)) {\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 setCause(error, 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 this._lastEventId = eventId;\n if (this._openFallbackReportDialog) {\n showReportDialog({ ...dialogOptions, eventId });\n }\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 state = this.state;\n\n if (state.error) {\n let element: React.ReactElement | undefined = undefined;\n if (typeof fallback === 'function') {\n element = fallback({\n error: state.error,\n componentStack: state.componentStack,\n resetError: this.resetErrorBoundary,\n eventId: state.eventId,\n });\n } else {\n element = fallback;\n }\n\n if (React.isValidElement(element)) {\n return element;\n }\n\n if (fallback) {\n __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,MAAA,YAAA,GAAA,4FAAA,CAAA;AAKA;AACA,SAAA,gBAAA,CAAA,OAAA,EAAA;AACA,EAAA,MAAA,KAAA,GAAA,OAAA,CAAA,KAAA,CAAA,UAAA,CAAA,CAAA;AACA,EAAA,OAAA,KAAA,KAAA,IAAA,IAAA,QAAA,CAAA,KAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EAAA,CAAA;AACA,CAAA;AACA;AACA,MAAA,iBAAA,GAAA,UAAA;;AAmDA,MAAA,aAAA,GAAA;AACA,EAAA,cAAA,EAAA,IAAA;AACA,EAAA,KAAA,EAAA,IAAA;AACA,EAAA,OAAA,EAAA,IAAA;AACA,CAAA,CAAA;AACA;AACA,SAAA,QAAA,CAAA,KAAA,EAAA,KAAA,EAAA;AACA,EAAA,MAAA,UAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AACA;AACA,EAAA,SAAA,OAAA,CAAA,KAAA,EAAA,KAAA,EAAA;AACA;AACA;AACA,IAAA,IAAA,UAAA,CAAA,GAAA,CAAA,KAAA,CAAA,EAAA;AACA,MAAA,OAAA;AACA,KAAA;AACA,IAAA,IAAA,KAAA,CAAA,KAAA,EAAA;AACA,MAAA,UAAA,CAAA,GAAA,CAAA,KAAA,EAAA,IAAA,CAAA,CAAA;AACA,MAAA,OAAA,OAAA,CAAA,KAAA,CAAA,KAAA,EAAA,KAAA,CAAA,CA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A,CAAA,CAAA;AACA,EAAA,OAAA,OAAA,CAAA;AACA;;;;"}
1
+ {"version":3,"file":"errorboundary.js","sources":["../../src/errorboundary.tsx"],"sourcesContent":["import type { ReportDialogOptions, Scope } from '@sentry/browser';\nimport { captureException, getCurrentHub, showReportDialog, withScope } from '@sentry/browser';\nimport { addExceptionMechanism, isError, logger } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\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;\n eventId: string;\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 | {\n componentStack: null;\n error: null;\n eventId: null;\n }\n | {\n componentStack: React.ErrorInfo['componentStack'];\n error: Error;\n eventId: string;\n };\n\nconst INITIAL_STATE = {\n componentStack: null,\n error: null,\n eventId: null,\n};\n\nfunction setCause(error: Error & { cause?: Error }, cause: Error): void {\n const seenErrors = new WeakMap<Error, boolean>();\n\n function recurse(error: Error & { cause?: Error }, cause: Error): void {\n // If we've already seen the error, there is a recursive loop somewhere in the error's\n // cause chain. Let's just bail out then to prevent a stack overflow.\n if (seenErrors.has(error)) {\n return;\n }\n if (error.cause) {\n seenErrors.set(error, true);\n return recurse(error.cause, cause);\n }\n error.cause = cause;\n }\n\n recurse(error, cause);\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;\n\n private readonly _openFallbackReportDialog: boolean;\n\n private _lastEventId?: string;\n\n public constructor(props: ErrorBoundaryProps) {\n super(props);\n\n this.state = INITIAL_STATE;\n this._openFallbackReportDialog = true;\n\n const client = getCurrentHub().getClient();\n if (client && client.on && props.showDialog) {\n this._openFallbackReportDialog = false;\n client.on('afterSendEvent', event => {\n if (!event.type && event.event_id === this._lastEventId) {\n showReportDialog({ ...props.dialogOptions, eventId: this._lastEventId });\n }\n });\n }\n }\n\n public componentDidCatch(error: Error & { cause?: Error }, { componentStack }: React.ErrorInfo): void {\n const { beforeCapture, onError, showDialog, dialogOptions } = this.props;\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 // See: https://reactjs.org/blog/2020/08/10/react-v17-rc.html#native-component-stacks\n //\n // Although `componentDidCatch` is typed to accept an `Error` object, it can also be invoked\n // with non-error objects. This is why we need to check if the error is an error-like object.\n // See: https://github.com/getsentry/sentry-javascript/issues/6167\n if (isAtLeastReact17(React.version) && isError(error)) {\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 setCause(error, errorBoundaryError);\n }\n\n if (beforeCapture) {\n beforeCapture(scope, error, componentStack);\n }\n\n scope.addEventProcessor(event => {\n addExceptionMechanism(event, { handled: false })\n return event;\n })\n\n const eventId = captureException(error, { contexts: { react: { componentStack } } });\n\n if (onError) {\n onError(error, componentStack, eventId);\n }\n if (showDialog) {\n this._lastEventId = eventId;\n if (this._openFallbackReportDialog) {\n showReportDialog({ ...dialogOptions, eventId });\n }\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 state = this.state;\n\n if (state.error) {\n let element: React.ReactElement | undefined = undefined;\n if (typeof fallback === 'function') {\n element = fallback({\n error: state.error,\n componentStack: state.componentStack,\n resetError: this.resetErrorBoundary,\n eventId: state.eventId,\n });\n } else {\n element = fallback;\n }\n\n if (React.isValidElement(element)) {\n return element;\n }\n\n if (fallback) {\n __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,MAAA,YAAA,GAAA,4FAAA,CAAA;AAKA;AACA,SAAA,gBAAA,CAAA,OAAA,EAAA;AACA,EAAA,MAAA,KAAA,GAAA,OAAA,CAAA,KAAA,CAAA,UAAA,CAAA,CAAA;AACA,EAAA,OAAA,KAAA,KAAA,IAAA,IAAA,QAAA,CAAA,KAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EAAA,CAAA;AACA,CAAA;AACA;AACA,MAAA,iBAAA,GAAA,UAAA;;AAmDA,MAAA,aAAA,GAAA;AACA,EAAA,cAAA,EAAA,IAAA;AACA,EAAA,KAAA,EAAA,IAAA;AACA,EAAA,OAAA,EAAA,IAAA;AACA,CAAA,CAAA;AACA;AACA,SAAA,QAAA,CAAA,KAAA,EAAA,KAAA,EAAA;AACA,EAAA,MAAA,UAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AACA;AACA,EAAA,SAAA,OAAA,CAAA,KAAA,EAAA,KAAA,EAAA;AACA;AACA;AACA,IAAA,IAAA,UAAA,CAAA,GAAA,CAAA,KAAA,CAAA,EAAA;AACA,MAAA,OAAA;AACA,KAAA;AACA,IAAA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AA,KAAA,CAAA,aAAA,CAAA,gBAAA,EAAA,EAAA,GAAA,KAAA,EAAA,MAAA,EAAA,IAAA,EAAA,QAAA,EAAA,CAAA,QAAA,EAAA,YAAA,EAAA,UAAA,EAAA,GAAA,CAAA,CAAA,EAAA;AACA,KAAA;AACA,GAAA,CAAA;AACA;AACA;AACA,EAAA,OAAA,CAAA,WAAA,GAAA,CAAA,cAAA,EAAA,oBAAA,CAAA,CAAA,CAAA,CAAA;AACA;AACA;AACA;AACA,EAAA,oBAAA,CAAA,OAAA,EAAA,gBAAA,CAAA,CAAA;AACA,EAAA,OAAA,OAAA,CAAA;AACA;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/react",
3
- "version": "7.67.0-beta.0",
3
+ "version": "7.68.0",
4
4
  "description": "Official Sentry SDK for React.js",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/react",
@@ -14,7 +14,7 @@
14
14
  "types": "types/index.d.ts",
15
15
  "typesVersions": {
16
16
  "<4.9": {
17
- "build/types/index.d.ts": [
17
+ "types/index.d.ts": [
18
18
  "types-ts3.8/index.d.ts"
19
19
  ]
20
20
  }
@@ -23,9 +23,9 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@sentry/browser": "7.67.0-beta.0",
27
- "@sentry/types": "7.67.0-beta.0",
28
- "@sentry/utils": "7.67.0-beta.0",
26
+ "@sentry/browser": "7.68.0",
27
+ "@sentry/types": "7.68.0",
28
+ "@sentry/utils": "7.68.0",
29
29
  "hoist-non-react-statics": "^3.3.2",
30
30
  "tslib": "^2.4.1 || ^1.9.3"
31
31
  },
@@ -1 +1 @@
1
- {"version":3,"file":"errorboundary.d.ts","sourceRoot":"","sources":["../../src/errorboundary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC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P = "ui.react.render";
2
+ export declare const REACT_UPDATE_OP = "ui.react.update";
3
+ export declare const REACT_MOUNT_OP = "ui.react.mount";
4
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1,70 @@
1
+ import { ReportDialogOptions, Scope } from '@sentry/browser';
2
+ import * as React from 'react';
3
+ export declare function isAtLeastReact17(version: string): boolean;
4
+ export declare const UNKNOWN_COMPONENT = "unknown";
5
+ export type FallbackRender = (errorData: {
6
+ error: Error;
7
+ componentStack: string;
8
+ eventId: string;
9
+ resetError(): void;
10
+ }) => React.ReactElement;
11
+ export type ErrorBoundaryProps = {
12
+ children?: React.ReactNode | (() => React.ReactNode);
13
+ /** If a Sentry report dialog should be rendered on error */
14
+ showDialog?: boolean;
15
+ /**
16
+ * Options to be passed into the Sentry report dialog.
17
+ * No-op if {@link showDialog} is false.
18
+ */
19
+ dialogOptions?: ReportDialogOptions;
20
+ /**
21
+ * A fallback component that gets rendered when the error boundary encounters an error.
22
+ *
23
+ * Can either provide a React Component, or a function that returns React Component as
24
+ * a valid fallback prop. If a function is provided, the function will be called with
25
+ * the error, the component stack, and an function that resets the error boundary on error.
26
+ *
27
+ */
28
+ fallback?: React.ReactElement | FallbackRender;
29
+ /** Called when the error boundary encounters an error */
30
+ onError?(error: Error, componentStack: string, eventId: string): void;
31
+ /** Called on componentDidMount() */
32
+ onMount?(): void;
33
+ /** Called if resetError() is called from the fallback render props function */
34
+ onReset?(error: Error | null, componentStack: string | null, eventId: string | null): void;
35
+ /** Called on componentWillUnmount() */
36
+ onUnmount?(error: Error | null, componentStack: string | null, eventId: string | null): void;
37
+ /** Called before the error is captured by Sentry, allows for you to add tags or context using the scope */
38
+ beforeCapture?(scope: Scope, error: Error | null, componentStack: string | null): void;
39
+ };
40
+ type ErrorBoundaryState = {
41
+ componentStack: null;
42
+ error: null;
43
+ eventId: null;
44
+ } | {
45
+ componentStack: React.ErrorInfo['componentStack'];
46
+ error: Error;
47
+ eventId: string;
48
+ };
49
+ /**
50
+ * A ErrorBoundary component that logs errors to Sentry. Requires React >= 16.
51
+ * NOTE: If you are a Sentry user, and you are seeing this stack frame, it means the
52
+ * Sentry React SDK ErrorBoundary caught an error invoking your application code. This
53
+ * is expected behavior and NOT indicative of a bug with the Sentry React SDK.
54
+ */
55
+ declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
56
+ state: ErrorBoundaryState;
57
+ private readonly _openFallbackReportDialog;
58
+ private _lastEventId?;
59
+ constructor(props: ErrorBoundaryProps);
60
+ componentDidCatch(error: Error & {
61
+ cause?: Error;
62
+ }, { componentStack }: React.ErrorInfo): void;
63
+ componentDidMount(): void;
64
+ componentWillUnmount(): void;
65
+ resetErrorBoundary: () => void;
66
+ render(): React.ReactNode;
67
+ }
68
+ declare function withErrorBoundary<P extends Record<string, any>>(WrappedComponent: React.ComponentType<P>, errorBoundaryOptions: ErrorBoundaryProps): React.FC<P>;
69
+ export { ErrorBoundary, withErrorBoundary };
70
+ //# sourceMappingURL=errorboundary.d.ts.map
@@ -0,0 +1,10 @@
1
+ export * from '@sentry/browser';
2
+ export { init } from './sdk';
3
+ export { Profiler, withProfiler, useProfiler } from './profiler';
4
+ export { ErrorBoundaryProps, FallbackRender } from './errorboundary';
5
+ export { ErrorBoundary, withErrorBoundary } from './errorboundary';
6
+ export { createReduxEnhancer } from './redux';
7
+ export { reactRouterV3Instrumentation } from './reactrouterv3';
8
+ export { reactRouterV4Instrumentation, reactRouterV5Instrumentation, withSentryRouting } from './reactrouter';
9
+ export { reactRouterV6Instrumentation, withSentryReactRouterV6Routing, wrapUseRoutes, wrapCreateBrowserRouter, } from './reactrouterv6';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,60 @@
1
+ import { Hub } from '@sentry/browser';
2
+ import { Span, Transaction } from '@sentry/types';
3
+ import * as React from 'react';
4
+ export declare const UNKNOWN_COMPONENT = "unknown";
5
+ export type ProfilerProps = {
6
+ name: string;
7
+ disabled?: boolean;
8
+ includeRender?: boolean;
9
+ includeUpdates?: boolean;
10
+ children?: React.ReactNode;
11
+ updateProps: {
12
+ [key: string]: unknown;
13
+ };
14
+ };
15
+ /**
16
+ * The Profiler component leverages Sentry's Tracing integration to generate
17
+ * spans based on component lifecycles.
18
+ */
19
+ declare class Profiler extends React.Component<ProfilerProps> {
20
+ /**
21
+ * The span of the mount activity
22
+ * Made protected for the React Native SDK to access
23
+ */
24
+ protected _mountSpan: Span | undefined;
25
+ /**
26
+ * The span that represents the duration of time between shouldComponentUpdate and componentDidUpdate
27
+ */
28
+ protected _updateSpan: Span | undefined;
29
+ static defaultProps: Partial<ProfilerProps>;
30
+ constructor(props: ProfilerProps);
31
+ componentDidMount(): void;
32
+ shouldComponentUpdate({ updateProps, includeUpdates }: ProfilerProps): boolean;
33
+ componentDidUpdate(): void;
34
+ componentWillUnmount(): void;
35
+ render(): React.ReactNode;
36
+ }
37
+ /**
38
+ * withProfiler is a higher order component that wraps a
39
+ * component in a {@link Profiler} component. It is recommended that
40
+ * the higher order component be used over the regular {@link Profiler} component.
41
+ *
42
+ * @param WrappedComponent component that is wrapped by Profiler
43
+ * @param options the {@link ProfilerProps} you can pass into the Profiler
44
+ */
45
+ declare function withProfiler<P extends Record<string, any>>(WrappedComponent: React.ComponentType<P>, options?: Pick<Partial<ProfilerProps>, Exclude<keyof ProfilerProps, 'updateProps' | 'children'>>): React.FC<P>;
46
+ /**
47
+ *
48
+ * `useProfiler` is a React hook that profiles a React component.
49
+ *
50
+ * Requires React 16.8 or above.
51
+ * @param name displayName of component being profiled
52
+ */
53
+ declare function useProfiler(name: string, options?: {
54
+ disabled?: boolean;
55
+ hasRenderSpan?: boolean;
56
+ }): void;
57
+ export { withProfiler, Profiler, useProfiler };
58
+ /** Grabs active transaction off scope */
59
+ export declare function getActiveTransaction<T extends Transaction>(hub?: Hub): T | undefined;
60
+ //# sourceMappingURL=profiler.d.ts.map
@@ -0,0 +1,25 @@
1
+ import * as React from 'react';
2
+ import { Action, Location, ReactRouterInstrumentation } from './types';
3
+ type Match = {
4
+ path: string;
5
+ url: string;
6
+ params: Record<string, any>;
7
+ isExact: boolean;
8
+ };
9
+ export type RouterHistory = {
10
+ location?: Location;
11
+ listen?(cb: (location: Location, action: Action) => void): void;
12
+ } & Record<string, any>;
13
+ export type RouteConfig = {
14
+ [propName: string]: unknown;
15
+ path?: string | string[];
16
+ exact?: boolean;
17
+ component?: JSX.Element;
18
+ routes?: RouteConfig[];
19
+ };
20
+ type MatchPath = (pathname: string, props: string | string[] | any, parent?: Match | null) => Match | null;
21
+ export declare function reactRouterV4Instrumentation(history: RouterHistory, routes?: RouteConfig[], matchPath?: MatchPath): ReactRouterInstrumentation;
22
+ export declare function reactRouterV5Instrumentation(history: RouterHistory, routes?: RouteConfig[], matchPath?: MatchPath): ReactRouterInstrumentation;
23
+ export declare function withSentryRouting<P extends Record<string, any>, R extends React.ComponentType<P>>(Route: R): R;
24
+ export {};
25
+ //# sourceMappingURL=reactrouter.d.ts.map
@@ -0,0 +1,26 @@
1
+ import { Location, ReactRouterInstrumentation } from './types';
2
+ type HistoryV3 = {
3
+ location?: Location;
4
+ listen?(cb: (location: Location) => void): void;
5
+ } & Record<string, any>;
6
+ export type Route = {
7
+ path?: string;
8
+ childRoutes?: Route[];
9
+ };
10
+ export type Match = (props: {
11
+ location: Location;
12
+ routes: Route[];
13
+ }, cb: (error?: Error, _redirectLocation?: Location, renderProps?: {
14
+ routes?: Route[];
15
+ }) => void) => void;
16
+ /**
17
+ * Creates routing instrumentation for React Router v3
18
+ * Works for React Router >= 3.2.0 and < 4.0.0
19
+ *
20
+ * @param history object from the `history` library
21
+ * @param routes a list of all routes, should be
22
+ * @param match `Router.match` utility
23
+ */
24
+ export declare function reactRouterV3Instrumentation(history: HistoryV3, routes: Route[], match: Match): ReactRouterInstrumentation;
25
+ export {};
26
+ //# sourceMappingURL=reactrouterv3.d.ts.map
@@ -0,0 +1,8 @@
1
+ import { Transaction, TransactionContext } from '@sentry/types';
2
+ import * as React from 'react';
3
+ import { CreateRouterFunction, CreateRoutesFromChildren, MatchRoutes, Router, RouterState, UseEffect, UseLocation, UseNavigationType, UseRoutes } from './types';
4
+ export declare function reactRouterV6Instrumentation(useEffect: UseEffect, useLocation: UseLocation, useNavigationType: UseNavigationType, createRoutesFromChildren: CreateRoutesFromChildren, matchRoutes: MatchRoutes): (customStartTransaction: (context: TransactionContext) => Transaction | undefined, startTransactionOnPageLoad?: boolean, startTransactionOnLocationChange?: boolean) => void;
5
+ export declare function withSentryReactRouterV6Routing<P extends Record<string, any>, R extends React.FC<P>>(Routes: R): R;
6
+ export declare function wrapUseRoutes(origUseRoutes: UseRoutes): UseRoutes;
7
+ export declare function wrapCreateBrowserRouter<TState extends RouterState = RouterState, TRouter extends Router<TState> = Router<TState>>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter>;
8
+ //# sourceMappingURL=reactrouterv6.d.ts.map
@@ -0,0 +1,33 @@
1
+ import { Scope } from '@sentry/types';
2
+ interface Action<T = any> {
3
+ type: T;
4
+ }
5
+ interface AnyAction extends Action {
6
+ [extraProps: string]: any;
7
+ }
8
+ export interface SentryEnhancerOptions<S = any> {
9
+ /**
10
+ * Transforms the state before attaching it to an event.
11
+ * Use this to remove any private data before sending it to Sentry.
12
+ * Return null to not attach the state.
13
+ */
14
+ stateTransformer(state: S | undefined): (S & any) | null;
15
+ /**
16
+ * Transforms the action before sending it as a breadcrumb.
17
+ * Use this to remove any private data before sending it to Sentry.
18
+ * Return null to not send the breadcrumb.
19
+ */
20
+ actionTransformer(action: AnyAction): AnyAction | null;
21
+ /**
22
+ * Called on every state update, configure the Sentry Scope with the redux state.
23
+ */
24
+ configureScopeWithState?(scope: Scope, state: S): void;
25
+ }
26
+ /**
27
+ * Creates an enhancer that would be passed to Redux's createStore to log actions and the latest state to Sentry.
28
+ *
29
+ * @param enhancerOptions Options to pass to the enhancer
30
+ */
31
+ declare function createReduxEnhancer(enhancerOptions?: Partial<SentryEnhancerOptions>): any;
32
+ export { createReduxEnhancer };
33
+ //# sourceMappingURL=redux.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { BrowserOptions } from '@sentry/browser';
2
+ /**
3
+ * Inits the React SDK
4
+ */
5
+ export declare function init(options: BrowserOptions): void;
6
+ //# sourceMappingURL=sdk.d.ts.map
@@ -0,0 +1,163 @@
1
+ /// <reference types="react" />
2
+ import { Transaction, TransactionContext } from '@sentry/types';
3
+ export type Action = 'PUSH' | 'REPLACE' | 'POP';
4
+ export type Location = {
5
+ pathname: string;
6
+ action?: Action;
7
+ } & Record<string, any>;
8
+ export type ReactRouterInstrumentation = <T extends Transaction>(startTransaction: (context: TransactionContext) => T | undefined, startTransactionOnPageLoad?: boolean, startTransactionOnLocationChange?: boolean) => void;
9
+ export interface NonIndexRouteObject {
10
+ caseSensitive?: boolean;
11
+ children?: RouteObject[];
12
+ element?: React.ReactNode | null;
13
+ errorElement?: React.ReactNode | null;
14
+ index?: any;
15
+ path?: string;
16
+ }
17
+ export interface IndexRouteObject {
18
+ caseSensitive?: boolean;
19
+ children?: undefined;
20
+ element?: React.ReactNode | null;
21
+ errorElement?: React.ReactNode | null;
22
+ index: any;
23
+ path?: string;
24
+ }
25
+ export type RouteObject = (IndexRouteObject | NonIndexRouteObject) & Record<string, any>;
26
+ export type Params<Key extends string = string> = {
27
+ readonly [key in Key]: string | undefined;
28
+ };
29
+ export type UseRoutes = (routes: RouteObject[], locationArg?: Partial<Location> | string) => React.ReactElement | null;
30
+ export interface RouteMatch<ParamKey extends string = string> {
31
+ /**
32
+ * The names and values of dynamic parameters in the URL.
33
+ */
34
+ params: Params<ParamKey>;
35
+ /**
36
+ * The portion of the URL pathname that was matched.
37
+ */
38
+ pathname: string;
39
+ /**
40
+ * The portion of the URL pathname that was matched before child routes.
41
+ */
42
+ pathnameBase: string;
43
+ /**
44
+ * The route object that was used to match.
45
+ */
46
+ route: RouteObject;
47
+ }
48
+ export type UseEffect = (cb: () => void, deps: unknown[]) => void;
49
+ export type UseLocation = () => Location;
50
+ export type UseNavigationType = () => Action;
51
+ export type RouteObjectArrayAlias = any;
52
+ export type RouteMatchAlias = any;
53
+ export type CreateRoutesFromChildren = (children: JSX.Element[]) => RouteObjectArrayAlias;
54
+ export type MatchRoutes = (routes: RouteObjectArrayAlias, location: Location, basename?: string) => RouteMatchAlias[] | null;
55
+ export type ShouldRevalidateFunction = (args: any) => boolean;
56
+ interface DataFunctionArgs {
57
+ request: Request;
58
+ params: Params;
59
+ }
60
+ type LoaderFunctionArgs = DataFunctionArgs;
61
+ type ActionFunctionArgs = DataFunctionArgs;
62
+ export interface LoaderFunction {
63
+ (args: LoaderFunctionArgs): Promise<Response> | Response | Promise<any> | any;
64
+ }
65
+ export interface ActionFunction {
66
+ (args: ActionFunctionArgs): Promise<Response> | Response | Promise<any> | any;
67
+ }
68
+ declare type AgnosticBaseRouteObject = {
69
+ caseSensitive?: boolean;
70
+ path?: string;
71
+ id?: string;
72
+ loader?: LoaderFunction;
73
+ action?: ActionFunction;
74
+ hasErrorBoundary?: boolean;
75
+ shouldRevalidate?: ShouldRevalidateFunction;
76
+ handle?: any;
77
+ };
78
+ export declare type AgnosticIndexRouteObject = AgnosticBaseRouteObject & Record<string, any>;
79
+ export declare type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & Record<string, any>;
80
+ export declare type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
81
+ id: string;
82
+ };
83
+ export declare type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
84
+ children?: AgnosticDataRouteObject[];
85
+ id: string;
86
+ };
87
+ export interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
88
+ params: Params<ParamKey>;
89
+ pathname: string;
90
+ pathnameBase: string;
91
+ route: RouteObjectType;
92
+ }
93
+ export type AgnosticDataRouteMatch = AgnosticRouteMatch<string, AgnosticDataRouteObject>;
94
+ interface UseMatchesMatch {
95
+ id: string;
96
+ pathname: string;
97
+ params: AgnosticRouteMatch['params'];
98
+ data: unknown;
99
+ handle: unknown;
100
+ }
101
+ export interface GetScrollRestorationKeyFunction {
102
+ (location: Location, matches: UseMatchesMatch[]): string | null;
103
+ }
104
+ export interface Path {
105
+ pathname: string;
106
+ search: string;
107
+ hash: string;
108
+ }
109
+ export interface RouterSubscriber<TState extends RouterState = RouterState> {
110
+ (state: TState): void;
111
+ }
112
+ export interface GetScrollPositionFunction {
113
+ (): number;
114
+ }
115
+ declare type LinkNavigateOptions = {
116
+ replace?: boolean;
117
+ state?: any;
118
+ preventScrollReset?: boolean;
119
+ };
120
+ export declare type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
121
+ export declare type To = string | Partial<Path>;
122
+ export declare type HydrationState = any;
123
+ export declare type FormMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
124
+ export declare type FormEncType = 'application/x-www-form-urlencoded' | 'multipart/form-data';
125
+ export declare type RouterNavigateOptions = LinkNavigateOptions | SubmissionNavigateOptions;
126
+ export declare type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
127
+ declare type SubmissionNavigateOptions = {
128
+ replace?: boolean;
129
+ state?: any;
130
+ formMethod?: FormMethod;
131
+ formEncType?: FormEncType;
132
+ formData: FormData;
133
+ };
134
+ export interface RouterInit {
135
+ basename: string;
136
+ routes: AgnosticRouteObject[];
137
+ history: History;
138
+ hydrationData?: HydrationState;
139
+ }
140
+ export type NavigationStates = {
141
+ Idle: any;
142
+ Loading: any;
143
+ Submitting: any;
144
+ };
145
+ export type Navigation = NavigationStates[keyof NavigationStates];
146
+ export type RouteData = any;
147
+ export type Fetcher = any;
148
+ export declare enum HistoryAction {
149
+ Pop = "POP",
150
+ Push = "PUSH",
151
+ Replace = "REPLACE"
152
+ }
153
+ export interface RouterState {
154
+ historyAction: Action | HistoryAction | any;
155
+ location: Location;
156
+ }
157
+ export interface Router<TState extends RouterState = RouterState> {
158
+ state: TState;
159
+ subscribe(fn: RouterSubscriber<TState>): () => void;
160
+ }
161
+ export type CreateRouterFunction<TState extends RouterState = RouterState, TRouter extends Router<TState> = Router<TState>> = (routes: RouteObject[], opts?: any) => TRouter;
162
+ export {};
163
+ //# sourceMappingURL=types.d.ts.map