MODx JSLog – Log JS errors server-side

modx-color

Since the rise of JS-frameworks (like jQuery, prototype, ExtJS) it has become a huge part of nowadays web-based applications. DOM-manipulation became easy, AJAX requests are done everywhere, form validation, animations, and all those things which were and are done via JS. And it is all happening on the client-side so nothing to worry about server-side. The client’s browser is responsible for the correct interpretation of JS.

Generally everything seems to be fine. But if we look at some differences especially in older versions of some browsers sometimes things don’t quiet end up the way we planned it, or if your client’s computer somehow has some special settings. What then? Well, you can either try to reproduce the error by going through all kind of versions and settings and suddenly being lucky when the error pops up.

For a recent project we had this issue with either old versions of browsers or some very specific settings. We had a really hard time to reproduce the errors happening in their environment. It really bugged me to waste time to reproduce an error which definitely happened but I couldn’t not reproduce therefore localize.

So I wrote a small extra which logs all JS-errors into a server-side log file and, if enabled, sends emails. To not flood your mailbox you can set an interval which prevents duplicate error mails (though it still logs it). Furthermore you can enable ExtJS message (MODx Message) to let your current user know that an error happened and you were informed about it. It is probably only useful in Manager-Context.

Github Repository:  MODx JSLog

Leave a Reply

Your email address will not be published. Required fields are marked *