jystewart / js-exception-notifier

Exception notification for Javascript errors made simple

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JsExceptionNotifier

The JsExceptionNotifier gem detects JS exceptions with TraceKit and sends notifications via email using Exception Notification gem. The TraceKit is attached by default.

Requirements

  • Ruby 2.0.0 or greater

  • Rails 4.0 or greater

  • Exception Notification gem

  • TraceKit(included in package)

Getting Started

Add the following line to your application’s Gemfile:

gem "js_exception_notifier", :git => "git://github.com/shorelabs/js-exception-notifier.git"

That’s it, the configuration ends up here.

Usage

Add the following line at the beginning of the javascript file

javascript_include_tag "js_exception_notifier.js"

Or just include files within the asset pipeline:

//= require js_exception_notifier

Usage when serving JS from CDN

Due to a potential security issue, browsers traditionally don’t provide access to error data if the script violates the same-origin policy. Instead, browsers just report a meaningless Script error on line 0, with no additional data.

If you are serving your javascript assets through a CDN (Cloudfront for eg), you need to

  • have HTTP CORS headers (not covered here)

  • load your JS with a crossorigin tag to enable error reporting

The latter is done with

javascript_include_tag "js_exception_notifier.js", crossorigin: 'anonymous'

Or if js_exception_notifier is added to the asset pipeline

javascript_include_tag "application", crossorigin: 'anonymous'

JsExceptionNotifier comes with a dummy app:

bundle
cd test/dummy && rails s

About

Exception notification for Javascript errors made simple


Languages

Language:JavaScript 65.9%Language:Ruby 27.7%Language:HTML 5.6%Language:CSS 0.7%