Track JavaScript errors using JSerror

Track JavaScript errors using JSerror


Everyone knows that almost any modern website is not complete without a functional,which is  implemented in JavaScript, and, of course, there may be errors that occur for various reasons - a mistake in the code, features of  the browser (there are a lot of browsers, and even mobile ). They often go unnoticed. Also  typically  errors are retraced only by server tools (error.log, watchdog and so on). So why not do it for the client side? In this article we consider the module JSerror ( for Drupal 7, which allows you to monitor and record in the log client JavaScript errors.


As for installation, here everything is as usual, but there are little nuances that you should be informed beforehand about.

JSerror module for determining the browser uses an enhanced version of the standard function get_browser () from the module Browscap ( Therefore, the installation should  be started with this module (unfortunately at the moment in a stable version of the module used incorrect service reference browserscap, so it's worth ispolzovat dev-version):

drush dl --destination sites / all / contrib browscap-7.x-2.x-dev

Next swing JSerror:

drush dl --destination sites / all / contrib jserror

Then turn on both modules:

drush en browscap jserror

Or do the same things, but only one command:

drush dl --destination = sites / all / modules / contrib browscap-7.x-2.x-dev jserror && drush en browscap jserror

Naturally, all this can be done manually, without the use of Drush.

We go to the module settings page Browscap ( to check if everything is ok:

Everything is looking good, but if you install the current stable version (7.x-2.1), then you still get an error message. Then we'll see what offers module JSerror. Open the configuration page and see:

It should be noted that the Debug Mode - debug mode determines which version (minimized or not) tracking script to give to the client. Here we are talking about the script module JSerror, and not JS-files of the entire site.

Others options should definitely mark in preproduction checklist and do not forget to set up the project in deploem combat environment.


Now let's see how it works, especially for the sake of this write the code with the error:

(function ($) {

   Drupal.behaviors.jserrorTest = {

     attach: function (context, settings) {

       Drupal.callUndefinedFunction ();



}) (jQuery);

In the console, Google Chrome, we obtain the following picture:

Now comes the moment of truth. Come watch the log JSerror (http://test-host/admin/reports/jserror).

Here is the page with reports:

As can be seen from the screenshot, our mistake is registered successfully, the module worked as it should.