The JsExceptionNotifier gem detects JS exceptions with TraceKit and sends notifications via email using Exception Notification gem. The TraceKit is attached by default.
-
Ruby 2.0.0 or greater
-
Rails 4.0 or greater
-
Exception Notification gem
-
TraceKit(included in package)
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.
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
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'
bundle cd test/dummy && rails s