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

Distributed Error Reporting: Frontend Error reporting #12291

Conversation

thesujai
Copy link
Contributor

@thesujai thesujai commented Jun 17, 2024

Summary

  • Adds New Resource to call /api/errorreports/report for reporting all the error in frontend
  • Add Vue errorHandler, and window object's error and unhandledrejection to detect the unhandler error

References

Fixes #12284

Reviewer guidance


Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@thesujai thesujai marked this pull request as ready for review June 18, 2024 10:58

window.addEventListener('error', e => {
logging.error(`Unexpected Error: ${e.error}`);
ErrorReportResource.report(e.error);
Copy link
Member

Choose a reason for hiding this comment

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

I think for purposes of context it would be good to get the entire error object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be a good thing. But the report() will have too many conditions to make the code look not so clean. Eg:

  1. The Vue handler object will be handled with e.message and e.stack
  2. The error event will be handled with e.error.message and e.error.stack
  3. The promise rejection will be handled as e.reason.message and e.reason.stack

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the later stage, we can do that. We will be optimizing the model anyway.

Copy link
Member

Choose a reason for hiding this comment

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

Thats my whole point, Its better to pass it as an object since we will be moving onto the optimizations next. We wouldn't need to change the contract in this case. We would just read values from it into the model. I think implementing the logic as utility function should suffice.
The better approach would be to adopt the adapter pattern that should standardize the data from all three or n sources. I recommend reading about the adapter pattern. Also here is an example in JS

{vueError}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright I will do the changes

window.addEventListener('unhandledrejection', event => {
event.preventDefault();
logging.error(`Unhandled Rejection: ${event.reason}`);
ErrorReportResource.report(event.reason);
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@akolson akolson left a comment

Choose a reason for hiding this comment

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

Pr looks good, generally. I left a few comments below. @thesujai

Copy link
Member

@akolson akolson left a comment

Choose a reason for hiding this comment

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

Changes look correct to me! Thanks @thesujai

@akolson akolson merged commit cb259fa into learningequality:distributed-error-reporting Jun 20, 2024
10 checks passed
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.

2 participants