Skip to content
This repository has been archived by the owner on May 10, 2021. It is now read-only.

Commit

Permalink
add rollbar setting
Browse files Browse the repository at this point in the history
  • Loading branch information
y-yagi committed Feb 24, 2015
1 parent 2eb328d commit 8827eda
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.sample
@@ -1 +1,2 @@
GOOGLE_MAP_API_KEY="hogehoge"
ROLLBAR_ACCESS_TOKEN=""
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -36,6 +36,7 @@ gem 'rails-assets-moment'
gem 'rails-assets-respond'
gem 'rails-assets-smoothscroll'
gem 'rambulance'
gem 'rollbar', '~> 1.4.2'
gem 'sass-rails', '~> 5.0.0'
gem 'slim-rails'
gem 'uglifier', '>= 1.3.0'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Expand Up @@ -295,6 +295,8 @@ GEM
rest-client (1.7.2)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rollbar (1.4.4)
multi_json (~> 1.3)
ruby-prof (0.15.4)
ruby2ruby (2.1.3)
ruby_parser (~> 3.1)
Expand Down Expand Up @@ -415,6 +417,7 @@ DEPENDENCIES
rails-footnotes (~> 4.0)
rails_12factor
rambulance
rollbar (~> 1.4.2)
sass-rails (~> 5.0.0)
slim-rails
spring
Expand Down
10 changes: 10 additions & 0 deletions app/views/application/_rollbar.html.slim
@@ -0,0 +1,10 @@
- if Rails.env.production?
javascript:
var _rollbarConfig = {
accessToken: "0a35372d2c794f0e9c5cf916dca4c642",
captureUncaught: true,
payload: {
environment: "production"
}
};
!function(a,b){function c(b){this.shimId=++h,this.notifier=null,this.parentShim=b,this.logger=function(){},a.console&&void 0===a.console.shimId&&(this.logger=a.console.log)}function d(b,c,d){a._rollbarWrappedError&&(d[4]||(d[4]=a._rollbarWrappedError),d[5]||(d[5]=a._rollbarWrappedError._rollbarContext),a._rollbarWrappedError=null),b.uncaughtError.apply(b,d),c&&c.apply(a,d)}function e(b){var d=c;return g(function(){if(this.notifier)return this.notifier[b].apply(this.notifier,arguments);var c=this,e="scope"===b;e&&(c=new d(this));var f=Array.prototype.slice.call(arguments,0),g={shim:c,method:b,args:f,ts:new Date};return a._rollbarShimQueue.push(g),e?c:void 0})}function f(a,b){if(b.hasOwnProperty&&b.hasOwnProperty("addEventListener")){var c=b.addEventListener;b.addEventListener=function(b,d,e){c.call(this,b,a.wrap(d),e)};var d=b.removeEventListener;b.removeEventListener=function(a,b,c){d.call(this,a,b&&b._wrapped?b._wrapped:b,c)}}}function g(a,b){return b=b||this.logger,function(){try{return a.apply(this,arguments)}catch(c){b("Rollbar internal error:",c)}}}var h=0;c.init=function(a,b){var e=b.globalAlias||"Rollbar";if("object"==typeof a[e])return a[e];a._rollbarShimQueue=[],a._rollbarWrappedError=null,b=b||{};var h=new c;return g(function(){if(h.configure(b),b.captureUncaught){var c=a.onerror;a.onerror=function(){var a=Array.prototype.slice.call(arguments,0);d(h,c,a)};var g,i,j="EventTarget,Window,Node,ApplicationCache,AudioTrackList,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload".split(",");for(g=0;g<j.length;++g)i=j[g],a[i]&&a[i].prototype&&f(h,a[i].prototype)}return a[e]=h,h},h.logger)()},c.prototype.loadFull=function(a,b,c,d,e){var f=g(function(){var a=b.createElement("script"),e=b.getElementsByTagName("script")[0];a.src=d.rollbarJsUrl,a.async=!c,a.onload=h,e.parentNode.insertBefore(a,e)},this.logger),h=g(function(){var b;if(void 0===a._rollbarPayloadQueue){var c,d,f,g;for(b=new Error("rollbar.js did not load");c=a._rollbarShimQueue.shift();)for(f=c.args,g=0;g<f.length;++g)if(d=f[g],"function"==typeof d){d(b);break}}"function"==typeof e&&e(b)},this.logger);g(function(){c?f():a.addEventListener?a.addEventListener("load",f,!1):a.attachEvent("onload",f)},this.logger)()},c.prototype.wrap=function(b,c){try{var d;if(d="function"==typeof c?c:function(){return c||{}},"function"!=typeof b)return b;if(b._isWrap)return b;if(!b._wrapped){b._wrapped=function(){try{return b.apply(this,arguments)}catch(c){throw c._rollbarContext=d()||{},c._rollbarContext._wrappedSource=b.toString(),a._rollbarWrappedError=c,c}},b._wrapped._isWrap=!0;for(var e in b)b.hasOwnProperty(e)&&(b._wrapped[e]=b[e])}return b._wrapped}catch(f){return b}};for(var i="log,debug,info,warn,warning,error,critical,global,configure,scope,uncaughtError".split(","),j=0;j<i.length;++j)c.prototype[i[j]]=e(i[j]);var k="//d37gvrvc0wt4s1.cloudfront.net/js/v1.2/rollbar.min.js";_rollbarConfig.rollbarJsUrl=_rollbarConfig.rollbarJsUrl||k;var l=c.init(a,_rollbarConfig);l.loadFull(a,b,!1,_rollbarConfig)}(window,document);
1 change: 1 addition & 0 deletions app/views/layouts/application.html.slim
Expand Up @@ -18,6 +18,7 @@ html
= include_gon
= favicon_link_tag 'favicon.ico'
= csrf_meta_tags
= render 'rollbar'
body.parallax.animated.fadeIn
.off-canvas-wrap[data-offcanvas]
.inner-wrap
Expand Down
50 changes: 50 additions & 0 deletions config/initializers/rollbar.rb
@@ -0,0 +1,50 @@
require 'rollbar/rails'
Rollbar.configure do |config|
# Without configuration, Rollbar is enabled in all environments.
# To disable in specific environments, set config.enabled=false.

config.access_token = ENV['ROLLBAR_ACCESS_TOKEN']

unless Rails.env.production?
config.enabled = false
end

# By default, Rollbar will try to call the `current_user` controller method
# to fetch the logged-in user object, and then call that object's `id`,
# `username`, and `email` methods to fetch those properties. To customize:
# config.person_method = "my_current_user"
# config.person_id_method = "my_id"
# config.person_username_method = "my_username"
# config.person_email_method = "my_email"

# If you want to attach custom data to all exception and message reports,
# provide a lambda like the following. It should return a hash.
# config.custom_data_method = lambda { {:some_key => "some_value" } }

# Add exception class names to the exception_level_filters hash to
# change the level that exception is reported at. Note that if an exception
# has already been reported and logged the level will need to be changed
# via the rollbar interface.
# Valid levels: 'critical', 'error', 'warning', 'info', 'debug', 'ignore'
# 'ignore' will cause the exception to not be reported at all.
# config.exception_level_filters.merge!('MyCriticalException' => 'critical')
#
# You can also specify a callable, which will be called with the exception instance.
# config.exception_level_filters.merge!('MyCriticalException' => lambda { |e| 'critical' })

# Enable asynchronous reporting (uses girl_friday or Threading if girl_friday
# is not installed)
# config.use_async = true
# Supply your own async handler:
# config.async_handler = Proc.new { |payload|
# Thread.new { Rollbar.process_payload_safely(payload) }
# }

# Enable asynchronous reporting (using sucker_punch)
# config.use_sucker_punch

# Enable delayed reporting (using Sidekiq)
# config.use_sidekiq
# You can supply custom Sidekiq options:
# config.use_sidekiq 'queue' => 'my_queue'
end

0 comments on commit 8827eda

Please sign in to comment.