Use createReporter
in React plugin to collect errors
#3257
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Follow up to #3254
The ErrorBoundary component will capture whatever error occurs inside of it and send it to datadog, when this happens it renders the fallback component supplied to it. This works similar to a try/catch, where errors that occur within a component tree will not cause the entire application to crash and instead show a fallback.
As of today there’s a big problem with how ErrorBoundary reports these errors to datadog and how that plays into the Error Tracking product.
The original thrown error is not the one being reported, instead a different error is with a different stack trace (the one obtained from react’s error info) and a different error name (or @error.type in datadog). This messes with Error Tracking’s grouping.
This is the anatomy of a react error sent to Datadog today:
It would make more sense to report the original error so it has the original stack and name, drop the cause since it wouldn’t be needed anymore and instead place the component’s stack as the “Handled by” stack.
Changes
By passing the
info.componentStack
to the SDK throughcreateReporter
we can make it so the "Handled by" stack trace shows the component stackTesting
I have gone over the contributing documentation.