feat(feedback): Add onClose callback to showReportDialog (#9433) #9550
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.
Adds an
onClosecallback toshowReportDialog.The callback is invoked when a
__sentry_reportdialog_closed__MessageEvent is received. This is sent from the error page embed viawindow.postMessageand listened to in the sdk.Please have a look at the accompanying PRs
And here is a sample project that uses
onCloseto color the background green again after closing the widget:https://github.com/arya-s/sentry-onclose-report-dialog
Caveats
__sentry_reportdialog_closed__message will callonClose, so if users use more than one widget per page it could wrongly triggeronClose. I figured the widget takes over the entire page and having more than one wouldn't make much sense, but if this is an issue I could generate a key in the sdk and pass it along to the backend and specifically listen for it back, please advise.onClosethrows, prevents jest from failing when encountering the uncaught exception when firing off theMessageEvent. This seems a bit hackish, and I had to dig intojest-environment-jsdom's source to figure out how to prevent the test from failing.Curiously, I couldn't reproduce this on codesandbox: https://codesandbox.io/s/distracted-dubinsky-7x59dy?file=/src/index.test.js
Before submitting a pull request, please take a look at our
Contributing guidelines and verify:
yarn lint) & (yarn test).