Javascript errors report
Feb. 7th, 2016 03:45 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
When users open my web site I want to know what JavaScript errors users have (if any).
That's why I append this javascript to almost every page on my web site:
Once per day our server aggregates these errors and emails to developers Javascript Errors report.
This is an example of what that report looks like:

We then review these errors on case-by-case basis and decide whether we want to fix that error or we want to suppress that error from report (because we can not fix it).
Still, there are challenges: sometimes it is hard to separate errors that we can fix from errors we can not fix.
For example, we can not fix the most frequent "Uncaught ReferenceError: google is not defined" error, because it is caused by occasional browsers that do not work well with Google Maps API.
But we do not want to suppress that error either, because sometimes, by mistake, we may introduce problem in our own javascript that would generate the same error messages on mass scale for our users.
See: discussion in ivan-gandhi blog.
That's why I append this javascript to almost every page on my web site:
window.onerror = function(errmessage, errurl, errline) { var params = { list: [], add: function(name, value) { if (value != null) this.list.push(name + '=' + encodeURIComponent(value)); return this; }, toString: function() { if (this.list.length) return '?' + this.list.join('&'); return ''; } }; new Image().src='/jeh' + params.add('errmessage', errmessage) .add('errurl', errurl) .add('errline', errline) .add('r', Math.floor((Math.random() * 10) + 1)); }That script reports javascript errors from user browser back to our server.
Once per day our server aggregates these errors and emails to developers Javascript Errors report.
This is an example of what that report looks like:

We then review these errors on case-by-case basis and decide whether we want to fix that error or we want to suppress that error from report (because we can not fix it).
Still, there are challenges: sometimes it is hard to separate errors that we can fix from errors we can not fix.
For example, we can not fix the most frequent "Uncaught ReferenceError: google is not defined" error, because it is caused by occasional browsers that do not work well with Google Maps API.
But we do not want to suppress that error either, because sometimes, by mistake, we may introduce problem in our own javascript that would generate the same error messages on mass scale for our users.
See: discussion in ivan-gandhi blog.
no subject
Date: 2016-02-08 12:02 pm (UTC)2) Do you plan to manually run csv-file extraction from your log every day?
no subject
Date: 2016-02-08 12:05 pm (UTC)2. Cron
no subject
Date: 2016-02-08 12:12 pm (UTC)Are you appending javascript similar to what I showed in this posting to your web pages?
no subject
Date: 2016-02-08 12:21 pm (UTC)no subject
Date: 2016-02-08 12:24 pm (UTC)no subject
Date: 2016-02-08 01:24 pm (UTC)