I want to send my frontend logs to backend on react project. where can i implement window.onerror method so all of the unhandled exceptions will be thrown to backend within that method.
is it possible to write this method to app.js or something so all errors will be captured. Or should I add this method to all of my components
this post really helped me alot github.com/facebook/react/issues/19613
I wrote below Event listener in src/index.js and it raises error
window.addEventListener('error', (event) => {
console.log(Error(event.message ?? event));
const { message, filename, lineno, colno, error } = event;
console.log('Captured uncaught error:', message, filename, lineno, colno, error.stack);
})