Sha256: f2aeae2bdc697d9f6072747f9d57779756a25b0be935d99aec9b67aab87d6b1f
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
module Airbrake module Rack ## # Adds context (URL, User-Agent, framework version, controller and more). # # @since v5.7.0 class ContextFilter def initialize @framework_version = if defined?(::Rails) "Rails/#{::Rails.version}" elsif defined?(::Sinatra) "Sinatra/#{Sinatra::VERSION}" else "Rack.version/#{::Rack.version} Rack.release/#{::Rack.release}" end.freeze end ## # @see {Airbrake::FilterChain#refine} def call(notice) return unless (request = notice.stash[:rack_request]) context = notice[:context] context[:url] = request.url context[:userAgent] = request.user_agent add_framework_version(context) controller = request.env['action_controller.instance'] if controller context[:component] = controller.controller_name context[:action] = controller.action_name end user = Airbrake::Rack::User.extract(request.env) notice[:context].merge!(user.as_json) if user end private def add_framework_version(context) if context.key?(:version) context[:version] += " #{@framework_version}" else context[:version] = @framework_version end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
airbrake-5.7.0 | lib/airbrake/rack/context_filter.rb |
airbrake-5.7.0.rc.1 | lib/airbrake/rack/context_filter.rb |