Skip to content
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

Website: Add error report modal #1102

Merged
merged 50 commits into from
Mar 27, 2024
Merged

Website: Add error report modal #1102

merged 50 commits into from
Mar 27, 2024

Conversation

bgrgicak
Copy link
Collaborator

@bgrgicak bgrgicak commented Mar 12, 2024

This PR is missing data submission and shouldn't be merged.

What is this PR doing?

When a PHP request fails a modal will load that allows users to report errors to us.

What problem is it solving?

It will help us collect Playground errors that we need to improve stability.

How is the problem addressed?

By allowing users to submit error reports to us.

Testing Instructions

  • Checkout this branch
  • Start the local dev server npm run dev
  • Update this line to be true by default
  • Confirm that a modal is opened
  • Modify the input data
  • Click Report error
  • See the submitted report in Slack

Screenshot from 2024-03-22 10-42-32

@bgrgicak bgrgicak self-assigned this Mar 12, 2024
@bgrgicak bgrgicak changed the base branch from add/logger-crash-event to trunk March 12, 2024 11:12
@bgrgicak bgrgicak changed the base branch from trunk to add/logger-crash-event March 12, 2024 11:12
@bgrgicak
Copy link
Collaborator Author

@adamziel What do you think about the copy?

@bgrgicak bgrgicak changed the base branch from trunk to remove/throwonerror-flag March 25, 2024 07:48
@bgrgicak bgrgicak changed the base branch from remove/throwonerror-flag to trunk March 25, 2024 09:57
@@ -33,13 +33,13 @@ function response($ok, $error = null)
function validate_message($message)
{
// Validate description. Description is required
Copy link
Collaborator

@adamziel adamziel Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this be simpler and more reliable if the data was transmitted not as a text blob but as separate POST fields? $_POST['description'], $_POST['logs'] etc? The server could then stitch it together into a slack message.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking the same things while working on the validation but ended up overcomplicating it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, this is definitely much cleaner.

@@ -5,7 +5,7 @@ AddEncoding x-gzip .gz
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
</FilesMatch>
<FilesMatch "index\.js|blueprint-schema\.json|wp-cli.phar">
<FilesMatch "index\.js|blueprint-schema\.json|logger.php|wp-cli.phar">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this for Playground integrators?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for localhost, but it's also required if we want to allow an integrator to send error reports.

response(false, 'Invalid message');
if (isset($_POST['logs'])) {
if (preg_match('/\[\d{2}-[A-Za-z]{3}-\d{4} \d{2}:\d{2}:\d{2} UTC\](.*)/s', $_POST['logs']) !== 1) {
response(false, 'Logs do not match the PHP error log format');
Copy link
Collaborator

@adamziel adamziel Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit skeptical about this check – I think we'll get surprised with some false positives eventually and also this only tests for a single match. What would be a scenario it protects against?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing it does is ensure the format is correct (if the regex works as expected), but it doesn't protect us.
I will remove it and just check if it's empty.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated 74f6c7a

@@ -87,6 +88,7 @@ function Main() {

return (
<PlaygroundContext.Provider value={{ storage }}>
<ErrorReportModal />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up idea – add a "Report an error" button to trigger the modal manually.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done b2dfafc

Copy link
Collaborator

@adamziel adamziel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left two more comments but this looks great overall, thank you @bgrgicak!

@adamziel adamziel changed the title Add error report modal Website: Add error report modal Mar 26, 2024
@bgrgicak bgrgicak merged commit fb0eadc into trunk Mar 27, 2024
5 checks passed
@bgrgicak bgrgicak deleted the add/error-report-modal branch March 27, 2024 08:01
@bgrgicak bgrgicak mentioned this pull request Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants