-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[etk/error-reporting] Setup action hook callback to capture React Error Boundary exceptions #65503
[etk/error-reporting] Setup action hook callback to capture React Error Boundary exceptions #65503
Conversation
This PR modifies the release build for editing-toolkit To test your changes on WordPress.com, run To deploy your changes after merging, see the documentation: PCYsg-mMA-p2 |
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
The code changes LGTM! I'll wait to test until GB is on edge to make things easier, unless you want quicker feedback :) |
8bbabd9
to
b187cad
Compare
@noahtallen Thanks! I've just rebased it, and it should be ready to test! I'll also have a last look tomorrow :) |
… in Gutenberg with Sentry Register a callback to `editor.ErrorBoundary.errorLogged` action that will forward the error to Sentry everytime the action is called. The action has been added to all active React Error Boundaries in Gutenberg in the following changeset: WordPress/gutenberg#42024 .
b187cad
to
221feb2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to sync a Gutenberg build which causes an error in the PostTitle component. I then looked in the network requests and verified that data was posted to Sentry which includes a full error report for the exception. I also checked with the trunk build of ETK and verified that it does not send a full exception to Sentry.
@@ -18,6 +19,12 @@ function activateSentry() { | |||
release: 'wpcom-test-01', | |||
} ); | |||
|
|||
// Capture exceptions from Gutenberg React Error Boundaries | |||
addAction( 'editor.ErrorBoundary.errorLogged', 'etk/error-reporting', ( error ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work on Atomic if gutenberg is disabled? (I assume it would, as long as addAction
doesn't crash everything if the action doesn't exist.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Atomic doesn't activate this module yet, but if it did, I don't see why it would crash -- if AT didn't have Gutenberg (and if the block editor still doesn't have the call to doAction
) then the callback will just be registered here but never triggered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was that what you had in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, yeah. I was wondering what addAction
does if the given "action type" doesn't exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's not loaded (I keep forgetting that!) I agree we don't need to worry about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, yeah. I was wondering what addAction does if the given "action type" doesn't exist
I don't think it implements such a check -- though I agree it'd be nice to double check, though! I'll check this out in the following days.
Follow up to: WordPress/gutenberg#42024.
Proposed Changes
Register a callback to
editor.ErrorBoundary.errorLogged
WP action hook that will forward the error to Sentry every time the action is called.The action has been added to all active React Error Boundaries in Gutenberg in the following changeset: WordPress/gutenberg#42024 .
Testing Instructions
install-plugin.sh
to install from this branch);a8c-wp-env
to easily sync)wpcom-gutenberg-wp-admin
project)WARNING: Even if the testing plan passes, this should only be merged when GB 13.7 is shipped to WPCOM simple.