The raygun4js provider

Raygun4js is a library that you can easily add to your website or web application, which will then allow you to transmit all exceptions to your Raygun.io dashboard. Installation is painless, and configuring your site to transmit errors takes only 5 minutes.

The library is a single script which includes the sole dependency, allowing you to drop it straight in.

For complete instructions visit the Raygun4js GitHub repository.

How do I send to Raygun.io?

Raygun4js has two functions, the first to transmit exceptions manually caught in try-catch blocks, and the second which is a handler to catch and send all errors caught in window.onerror.

Installation

With Bower

Using the Bower package manager, you can install it by running this command in a shell:

bower install raygun4js

With NuGet

Visual Studio users can get it by opening the Package Manager Console and typing:

Install-Package raygun4js

CDN

Raygun4JS is available from our content delivery network:

<script type="text/javascript" src="https://cdn.raygun.io/raygun4js/raygun.min.js"></script>

The most current release is always available in /raygun4js/, while previous releases are available as subdirectories, for instance /raygun4js/1.14.0/raygun.js. The vanilla versions are also available as below.

Manual download

Download the production version or the development version.

You can also download vanilla versions without jQuery hooks (if you are not using jQuery, to provide your own hooks or remove Ajax error tracking): vanilla production  and vanilla development.

Usage

To get Raygun to report exceptions automatically, add this code to your web page:

<script src="dist/raygun.min.js"></script>
<script>
  Raygun.init('yourApiKey').attach();
</script>

Manual sending info

In order to get stack traces, you need to wrap your code in a try/catch block like below. Otherwise the error hits window.onerror handler and will only contain the error message, line number, and column number. You also need to throw errors with throw new Error('foo') instead of throw 'foo'.

Raygun.init('yourApiKey');
try {
  // your code
  throw new Error('oops');
}
catch(e) {
  Raygun.send(e);
}

Documentation

View the complete documentation here, including custom data, user tracking and IE 8 support.

 

Raygun4js GitHub Repository

 

To get the source code and troubleshooting, visit the GitHub repository here.