The main way to track the client side error is window.onerror()
which has been around for a while now and supported by major modern browsers. Let's get the trace of error object and and log it.
npm install
- Open config.js, edit your appPort, db.path, db.collection settings here.
npm start
- If there's any window error, post the error object in the same format shown above, through your save api.
window.onerror = function (msg, url, line, column, error) {
// Step 1. Prepare the error object to save
var data = {
url: window.location.href,
file: url,
line: line,
column: column,
error: error,
createdOn: new Date()
};
// Step 2. Post the above data to your api now
return false;
}
- Check the error logs on {path}/show/
Note: {path} above denotes where your app is running, 1300 is default.
This work is under MIT Open Source license.