lib/jt-rails-toolbox.rb in jt-rails-toolbox-2.5.0 vs lib/jt-rails-toolbox.rb in jt-rails-toolbox-2.6.0

- old
+ new

@@ -5,10 +5,12 @@ require 'validates_phone_format_of' require 'rails_i18n' require 'jt-rails-meta' require 'jt-rails-generator-user' require 'jt-rails-tokenizable' +require 'jt-rails-address' +require 'jt-rails-enum' require 'oj' require 'oj_mimic_json' require 'yaml' @@ -18,13 +20,14 @@ initializer "jt-rails-toolbox" do |app| @params = {} if ::File.exists?('config/jt-toolbox.yml') - yaml = YAML::load(ERB.new(File.read('config/jt-toolbox.yml'), 0, '<>').result) + yaml = YAML.load(ERB.new(File.read('config/jt-toolbox.yml'), 0, '<>').result) if yaml - @params = yaml[Rails.env.to_s] || {} + @params = yaml['shared'] || {} + @params.deep_merge!(yaml[Rails.env.to_s] || {}) end end process_params configure_sidekiq(app) @@ -73,12 +76,11 @@ def configure_exception_notification(app) return if @params['exception'].nil? if @params['exception']['airbrake'] - require 'airbrake' - require 'airbrake/sidekiq/error_handler' unless sidekiq_disabled? + require 'airbrake-ruby' Airbrake.configure do |c| if @params['exception']['airbrake']['host'] c.host = @params['exception']['airbrake']['host'] end @@ -92,22 +94,10 @@ c.ignore_environments = @params['exception']['airbrake']['ignore_environments'] else c.ignore_environments = %w(development test) end end - - # Default ignored exceptions in Exception Notification - exceptions_to_ignore = %w{ActiveRecord::RecordNotFound Mongoid::Errors::DocumentNotFound AbstractController::ActionNotFound ActionController::RoutingError ActionController::UnknownFormat ActionController::UrlGenerationError} - - # Additionnal exceptions to ignore - exceptions_to_ignore.push *%w{ActionController::InvalidCrossOriginRequest ActionController::InvalidAuthenticityToken} - - Airbrake.add_filter do |notice| - if notice[:errors].any? { |error| exceptions_to_ignore.include?(error[:type]) } - notice.ignore! - end - end end require 'exception_notification' require 'exception_notification/rails' require 'exception_notification/sidekiq' unless sidekiq_disabled? @@ -124,9 +114,15 @@ if @params['exception']['exception_recipients'] config.add_notifier :email, { email_prefix: @params['exception']['email_prefix'], sender_address: @params['exception']['sender_address'], exception_recipients: @params['exception']['exception_recipients'] + } + end + + if @params['exception']['airbrake'] + config.add_notifier :airbrake, -> (exception, options) { + Airbrake.notify(exception) } end end end \ No newline at end of file