Documentation

Overview

JS-Analytics works by setting up a monitor object on your website, that will look for errors and report them back to the server for your convinience.
The monitor can be set up with different settings, and have methods that you can use yourself in your code.


Monitor functions

Guard

The guard method allows you to ensure that any error thrown in the specfied function will be caught and reported back to JS-Analytics. This method is primarily intended for scenarios where the normal error collection is not activated, or errors will not be collected normally for some reason. It can also be used if you just want to guard a certain part of your code.

Usage:
JSAMonitor.guard(function() { 
// your code here
});

Report

The report method is used to report an error caught by you. It takes an exception and reports it back to JS-Analytics.

Usage:
JSAMonitor.report(your_error);

Settings

The constructor of the JS-Analytics monitor takes a settings object. You can use this to change the behaviour of the monitor. The only setting you must provide is your project-id. Your project-id is set in the code that is provided to you in your project page.

Setting: pid

This setting is not optional

This setting should be your project-id. The example code given in your project page has your project-id set.

Example:
window.JSAMonitor = new JSEAMonitor({pid:1234} );

Setting: useGlobalErrorEvent

This setting is used to specify if you want the monitor to use the window.onerror "event". It is suggested that this is used for fully reporting coverage on the browsers that support this event. For more information please read the How does it work page.

Possible values: true or false

Example:
window.JSAMonitor = new JSEAMonitor({pid:1234, useGlobalErrorEvent:true});

Setting: useJQuery

Specify this setting if you want to use JQuery to provide full coverage on pages that do not support the window.onerror event. If this is set to true, then the monitor will look for your JQuery object and extend it to report errors back to JS-Analytics.

Possible values: true or false

Example:
window.JSAMonitor = new JSEAMonitor({pid:1234, useGlobalErrorEvent:true, useJQuery:true} );

Setting: suppressError

If you specify this setting then all errors caught by JS-Analytics will be suppressed. This means that the errors will not be displayed for your websites user, but instead reported back to you.

Possible values: true or false

Example:
window.JSAMonitor = new JSEAMonitor({pid:1234, useGlobalErrorEvent:true, useJQuery:true, supressError:true} );

Setting: errorCallback

The errorCallback allows you to execute your own code when an error is reported to the monitor. Your callback can recieve the errors message as input parameter. This allows you to present the user with more helpfull error message, or otherwise react to the error.

Possible values: a function that can take a message as input.

Example:
window.JSAMonitor = new JSEAMonitor({pid:1234, useGlobalErrorEvent:true, useJQuery:true, supressError:true, errorCallback:function(message) {
//your code to be executed when error is placed here.
}
} );


Comments