airbrake 3.1.6 → 11.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/airbrake.rb +23 -150
- data/lib/airbrake/capistrano.rb +6 -42
- data/lib/airbrake/capistrano/capistrano2.rb +40 -0
- data/lib/airbrake/capistrano/capistrano3.rb +23 -0
- data/lib/airbrake/delayed_job.rb +66 -0
- data/lib/airbrake/logger.rb +103 -0
- data/lib/airbrake/rack.rb +30 -45
- data/lib/airbrake/rack/context_filter.rb +65 -0
- data/lib/airbrake/rack/http_headers_filter.rb +44 -0
- data/lib/airbrake/rack/http_params_filter.rb +27 -0
- data/lib/airbrake/rack/instrumentable.rb +136 -0
- data/lib/airbrake/rack/middleware.rb +102 -0
- data/lib/airbrake/rack/request_body_filter.rb +33 -0
- data/lib/airbrake/rack/request_store.rb +34 -0
- data/lib/airbrake/rack/route_filter.rb +51 -0
- data/lib/airbrake/rack/session_filter.rb +25 -0
- data/lib/airbrake/rack/user.rb +74 -0
- data/lib/airbrake/rack/user_filter.rb +25 -0
- data/lib/airbrake/rails.rb +25 -31
- data/lib/airbrake/rails/action_cable.rb +35 -0
- data/lib/airbrake/rails/action_cable/notify_callback.rb +22 -0
- data/lib/airbrake/rails/action_controller.rb +40 -0
- data/lib/airbrake/rails/action_controller_notify_subscriber.rb +32 -0
- data/lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb +51 -0
- data/lib/airbrake/rails/action_controller_route_subscriber.rb +33 -0
- data/lib/airbrake/rails/active_job.rb +50 -0
- data/lib/airbrake/rails/active_record.rb +36 -0
- data/lib/airbrake/rails/active_record_subscriber.rb +46 -0
- data/lib/airbrake/rails/app.rb +78 -0
- data/lib/airbrake/rails/backtrace_cleaner.rb +23 -0
- data/lib/airbrake/rails/curb.rb +32 -0
- data/lib/airbrake/rails/event.rb +81 -0
- data/lib/airbrake/rails/excon_subscriber.rb +25 -0
- data/lib/airbrake/rails/http.rb +14 -0
- data/lib/airbrake/rails/http_client.rb +16 -0
- data/lib/airbrake/rails/net_http.rb +18 -0
- data/lib/airbrake/rails/railtie.rb +151 -0
- data/lib/airbrake/rails/typhoeus.rb +16 -0
- data/lib/airbrake/rake.rb +65 -0
- data/lib/airbrake/rake/tasks.rb +112 -0
- data/lib/airbrake/resque.rb +61 -0
- data/lib/airbrake/shoryuken.rb +54 -0
- data/lib/airbrake/sidekiq.rb +55 -0
- data/lib/airbrake/sidekiq/retryable_jobs_filter.rb +53 -0
- data/lib/airbrake/sneakers.rb +72 -0
- data/lib/airbrake/version.rb +5 -1
- data/lib/generators/airbrake_generator.rb +25 -0
- data/lib/generators/airbrake_initializer.rb.erb +80 -0
- metadata +206 -259
- data/CHANGELOG +0 -944
- data/Gemfile +0 -3
- data/Guardfile +0 -6
- data/INSTALL +0 -20
- data/MIT-LICENSE +0 -22
- data/README.md +0 -556
- data/README_FOR_HEROKU_ADDON.md +0 -94
- data/Rakefile +0 -223
- data/SUPPORTED_RAILS_VERSIONS +0 -38
- data/TESTING.md +0 -41
- data/airbrake.gemspec +0 -40
- data/bin/airbrake +0 -12
- data/features/metal.feature +0 -18
- data/features/rack.feature +0 -60
- data/features/rails.feature +0 -272
- data/features/rails_with_js_notifier.feature +0 -97
- data/features/rake.feature +0 -27
- data/features/sinatra.feature +0 -29
- data/features/step_definitions/file_steps.rb +0 -10
- data/features/step_definitions/metal_steps.rb +0 -23
- data/features/step_definitions/rack_steps.rb +0 -23
- data/features/step_definitions/rails_application_steps.rb +0 -478
- data/features/step_definitions/rake_steps.rb +0 -17
- data/features/support/airbrake_shim.rb.template +0 -16
- data/features/support/env.rb +0 -18
- data/features/support/matchers.rb +0 -35
- data/features/support/rails.rb +0 -201
- data/features/support/rake/Rakefile +0 -68
- data/features/support/terminal.rb +0 -107
- data/features/user_informer.feature +0 -63
- data/generators/airbrake/airbrake_generator.rb +0 -94
- data/generators/airbrake/lib/insert_commands.rb +0 -34
- data/generators/airbrake/lib/rake_commands.rb +0 -24
- data/generators/airbrake/templates/airbrake_tasks.rake +0 -25
- data/generators/airbrake/templates/capistrano_hook.rb +0 -6
- data/generators/airbrake/templates/initializer.rb +0 -6
- data/install.rb +0 -1
- data/lib/airbrake/backtrace.rb +0 -108
- data/lib/airbrake/cli/client.rb +0 -68
- data/lib/airbrake/cli/options.rb +0 -41
- data/lib/airbrake/cli/printer.rb +0 -30
- data/lib/airbrake/cli/project.rb +0 -17
- data/lib/airbrake/cli/project_factory.rb +0 -36
- data/lib/airbrake/cli/runner.rb +0 -48
- data/lib/airbrake/cli/validator.rb +0 -8
- data/lib/airbrake/configuration.rb +0 -311
- data/lib/airbrake/extensions/blank.rb +0 -73
- data/lib/airbrake/notice.rb +0 -390
- data/lib/airbrake/rails/action_controller_catcher.rb +0 -30
- data/lib/airbrake/rails/controller_methods.rb +0 -87
- data/lib/airbrake/rails/error_lookup.rb +0 -33
- data/lib/airbrake/rails/javascript_notifier.rb +0 -47
- data/lib/airbrake/rails/middleware/exceptions_catcher.rb +0 -33
- data/lib/airbrake/rails3_tasks.rb +0 -98
- data/lib/airbrake/railtie.rb +0 -48
- data/lib/airbrake/rake_handler.rb +0 -71
- data/lib/airbrake/sender.rb +0 -128
- data/lib/airbrake/shared_tasks.rb +0 -47
- data/lib/airbrake/tasks.rb +0 -83
- data/lib/airbrake/user_informer.rb +0 -27
- data/lib/airbrake_tasks.rb +0 -64
- data/lib/rails/generators/airbrake/airbrake_generator.rb +0 -100
- data/lib/templates/javascript_notifier.erb +0 -15
- data/lib/templates/rescue.erb +0 -91
- data/rails/init.rb +0 -1
- data/resources/README.md +0 -34
- data/resources/ca-bundle.crt +0 -3376
- data/script/integration_test.rb +0 -38
- data/test/airbrake_2_3.xsd +0 -88
- data/test/airbrake_tasks_test.rb +0 -170
- data/test/backtrace_test.rb +0 -162
- data/test/capistrano_test.rb +0 -34
- data/test/catcher_test.rb +0 -333
- data/test/configuration_test.rb +0 -233
- data/test/helper.rb +0 -263
- data/test/javascript_notifier_test.rb +0 -51
- data/test/logger_test.rb +0 -79
- data/test/notice_test.rb +0 -490
- data/test/notifier_test.rb +0 -276
- data/test/rack_test.rb +0 -58
- data/test/rails_initializer_test.rb +0 -36
- data/test/recursion_test.rb +0 -10
- data/test/sender_test.rb +0 -288
- data/test/user_informer_test.rb +0 -29
data/lib/airbrake/cli/printer.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
module Printer
|
2
|
-
def self.print(collection)
|
3
|
-
collection.each do |element|
|
4
|
-
puts element
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.print_usage
|
9
|
-
puts <<-USAGE
|
10
|
-
Usage: airbrake [COMMAND] [OPTION]...
|
11
|
-
Commands:
|
12
|
-
raise # Raise an exception specified by ERROR and MESSAGE.
|
13
|
-
list # List all the projects for given AUTH_TOKEN and ACCOUNT.
|
14
|
-
create # Create a project with the given NAME.
|
15
|
-
deploy # Send a new deployment notification to a project that matches the API_KEY.
|
16
|
-
|
17
|
-
Options:
|
18
|
-
-e, [--error=ERROR] # Error class to raise. Default: RuntimeError
|
19
|
-
-m, [--message=MESSAGE] # Error message. Default: "I've made a huge mistake"
|
20
|
-
-k, [--api-key=API_KEY] # Api key of your Airbrake application.
|
21
|
-
-h, [--host=HOST] # URL of the Airbrake API server. Default: api.airbrake.io
|
22
|
-
-p, [--port=PORT] # Port of the Airbrake API server. Default: 80
|
23
|
-
-t, [--auth-token=AUTH_TOKEN] # The auth token used for API requests.
|
24
|
-
-a, [--account=ACCOUNT] # The account used for API requests.
|
25
|
-
-n, [--name=NAME] # The name of the project you're trying to create.
|
26
|
-
-E, [--rails-env=NAME] # The name of the environment you're deploying to. Default: production
|
27
|
-
-h, [--help] # Show this usage
|
28
|
-
USAGE
|
29
|
-
end
|
30
|
-
end
|
data/lib/airbrake/cli/project.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
class Project
|
2
|
-
attr_writer :name, :id, :api_key
|
3
|
-
|
4
|
-
def initialize(attributes = {})
|
5
|
-
attributes.keys.each do |key|
|
6
|
-
instance_variable_set("@#{key}",attributes[key])
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_s
|
11
|
-
"#{@name}".rjust(20) + "(#{@id}):".rjust(10) + " #{@api_key}"
|
12
|
-
end
|
13
|
-
|
14
|
-
def valid?
|
15
|
-
@name && @id && @api_key
|
16
|
-
end
|
17
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require File.expand_path( "../project", __FILE__)
|
2
|
-
# Responsible for creating projects when needed.
|
3
|
-
# Creates them from XML received.
|
4
|
-
class ProjectFactory
|
5
|
-
def initialize
|
6
|
-
@project = Project.new
|
7
|
-
@projects = []
|
8
|
-
end
|
9
|
-
|
10
|
-
def project
|
11
|
-
@project
|
12
|
-
end
|
13
|
-
|
14
|
-
def create_projects_from_xml(xml)
|
15
|
-
xml.split("\n").each do |line|
|
16
|
-
/<name[^>]*>(?<name>.*?)<\/name>/ =~ line
|
17
|
-
project.name = name.capitalize if name
|
18
|
-
/<id[^>]*>(?<id>.*?)<\/id>/ =~ line
|
19
|
-
project.id = id if id
|
20
|
-
/<api-key[^>]*>(?<api_key>.*?)<\/api-key>/ =~ line
|
21
|
-
project.api_key = api_key if api_key
|
22
|
-
check_project
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def check_project
|
27
|
-
if @project.valid?
|
28
|
-
projects << @project
|
29
|
-
@project = Project.new
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def projects
|
34
|
-
@projects
|
35
|
-
end
|
36
|
-
end
|
data/lib/airbrake/cli/runner.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require File.expand_path( "../project_factory", __FILE__)
|
2
|
-
require File.expand_path( "../options", __FILE__)
|
3
|
-
require File.expand_path( "../validator", __FILE__)
|
4
|
-
require File.expand_path( "../printer", __FILE__)
|
5
|
-
require File.expand_path( "../client", __FILE__)
|
6
|
-
|
7
|
-
module Runner
|
8
|
-
extend Validator
|
9
|
-
|
10
|
-
extend self
|
11
|
-
|
12
|
-
attr_accessor :options
|
13
|
-
|
14
|
-
def run!(command, cli_options = {})
|
15
|
-
|
16
|
-
self.options = Options.new(cli_options)
|
17
|
-
|
18
|
-
case command
|
19
|
-
when 'raise'
|
20
|
-
validates :api_key
|
21
|
-
Airbrake.configure do |c|
|
22
|
-
c.api_key = options.api_key
|
23
|
-
c.host = options.host if options.host
|
24
|
-
c.port = options.port if options.port
|
25
|
-
end
|
26
|
-
exception_id = Airbrake.notify(:error_class => options.error,
|
27
|
-
:error_message => "#{options.error}: #{options.message}",
|
28
|
-
:cgi_data => ENV)
|
29
|
-
abort "Error sending exception to Airbrake server. Try again later." unless exception_id
|
30
|
-
puts "Exception sent successfully: http://airbrake.io/locate/#{exception_id}"
|
31
|
-
|
32
|
-
when "list"
|
33
|
-
validates :auth_token, :account
|
34
|
-
Client.print_projects
|
35
|
-
|
36
|
-
when "create"
|
37
|
-
validates :auth_token, :account
|
38
|
-
Client.create_project
|
39
|
-
|
40
|
-
when "deploy"
|
41
|
-
validates :api_key
|
42
|
-
Client.create_deploy
|
43
|
-
|
44
|
-
else
|
45
|
-
Printer.print_usage
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,311 +0,0 @@
|
|
1
|
-
module Airbrake
|
2
|
-
# Used to set up and modify settings for the notifier.
|
3
|
-
class Configuration
|
4
|
-
|
5
|
-
OPTIONS = [:api_key, :js_api_key, :backtrace_filters, :development_environments,
|
6
|
-
:development_lookup, :environment_name, :host,
|
7
|
-
:http_open_timeout, :http_read_timeout, :ignore, :ignore_by_filters,
|
8
|
-
:ignore_user_agent, :notifier_name, :notifier_url, :notifier_version,
|
9
|
-
:params_filters, :project_root, :port, :protocol, :proxy_host,
|
10
|
-
:proxy_pass, :proxy_port, :proxy_user, :secure, :use_system_ssl_cert_chain,
|
11
|
-
:framework, :user_information, :rescue_rake_exceptions, :rake_environment_filters].freeze
|
12
|
-
|
13
|
-
# The API key for your project, found on the project edit form.
|
14
|
-
attr_accessor :api_key
|
15
|
-
|
16
|
-
# If you're using the Javascript notifier and would want to separate
|
17
|
-
# Javascript notifications into another Airbrake project, specify
|
18
|
-
# its APi key here.
|
19
|
-
# Defaults to #api_key (of the base project)
|
20
|
-
attr_writer :js_api_key
|
21
|
-
|
22
|
-
# The host to connect to (defaults to airbrake.io).
|
23
|
-
attr_accessor :host
|
24
|
-
|
25
|
-
# The port on which your Airbrake server runs (defaults to 443 for secure
|
26
|
-
# connections, 80 for insecure connections).
|
27
|
-
attr_accessor :port
|
28
|
-
|
29
|
-
# +true+ for https connections, +false+ for http connections.
|
30
|
-
attr_accessor :secure
|
31
|
-
|
32
|
-
# +true+ to use whatever CAs OpenSSL has installed on your system. +false+ to use the ca-bundle.crt file included in Airbrake itself (reccomended and default)
|
33
|
-
attr_accessor :use_system_ssl_cert_chain
|
34
|
-
|
35
|
-
# The HTTP open timeout in seconds (defaults to 2).
|
36
|
-
attr_accessor :http_open_timeout
|
37
|
-
|
38
|
-
# The HTTP read timeout in seconds (defaults to 5).
|
39
|
-
attr_accessor :http_read_timeout
|
40
|
-
|
41
|
-
# The hostname of your proxy server (if using a proxy)
|
42
|
-
attr_accessor :proxy_host
|
43
|
-
|
44
|
-
# The port of your proxy server (if using a proxy)
|
45
|
-
attr_accessor :proxy_port
|
46
|
-
|
47
|
-
# The username to use when logging into your proxy server (if using a proxy)
|
48
|
-
attr_accessor :proxy_user
|
49
|
-
|
50
|
-
# The password to use when logging into your proxy server (if using a proxy)
|
51
|
-
attr_accessor :proxy_pass
|
52
|
-
|
53
|
-
# A list of parameters that should be filtered out of what is sent to Airbrake.
|
54
|
-
# By default, all "password" attributes will have their contents replaced.
|
55
|
-
attr_reader :params_filters
|
56
|
-
|
57
|
-
# A list of filters for cleaning and pruning the backtrace. See #filter_backtrace.
|
58
|
-
attr_reader :backtrace_filters
|
59
|
-
|
60
|
-
# A list of filters for ignoring exceptions. See #ignore_by_filter.
|
61
|
-
attr_reader :ignore_by_filters
|
62
|
-
|
63
|
-
# A list of environment keys that will be ignored from what is sent to Airbrake server
|
64
|
-
# Empty by default and used only in rake handler
|
65
|
-
attr_reader :rake_environment_filters
|
66
|
-
|
67
|
-
# A list of exception classes to ignore. The array can be appended to.
|
68
|
-
attr_reader :ignore
|
69
|
-
|
70
|
-
# A list of user agents that are being ignored. The array can be appended to.
|
71
|
-
attr_reader :ignore_user_agent
|
72
|
-
|
73
|
-
# A list of environments in which notifications should not be sent.
|
74
|
-
attr_accessor :development_environments
|
75
|
-
|
76
|
-
# +true+ if you want to check for production errors matching development errors, +false+ otherwise.
|
77
|
-
attr_accessor :development_lookup
|
78
|
-
|
79
|
-
# The name of the environment the application is running in
|
80
|
-
attr_accessor :environment_name
|
81
|
-
|
82
|
-
# The path to the project in which the error occurred, such as the Rails.root
|
83
|
-
attr_accessor :project_root
|
84
|
-
|
85
|
-
# The name of the notifier library being used to send notifications (such as "Airbrake Notifier")
|
86
|
-
attr_accessor :notifier_name
|
87
|
-
|
88
|
-
# The version of the notifier library being used to send notifications (such as "1.0.2")
|
89
|
-
attr_accessor :notifier_version
|
90
|
-
|
91
|
-
# The url of the notifier library being used to send notifications
|
92
|
-
attr_accessor :notifier_url
|
93
|
-
|
94
|
-
# The logger used by Airbrake
|
95
|
-
attr_accessor :logger
|
96
|
-
|
97
|
-
# The text that the placeholder is replaced with. {{error_id}} is the actual error number.
|
98
|
-
attr_accessor :user_information
|
99
|
-
|
100
|
-
# The framework Airbrake is configured to use
|
101
|
-
attr_accessor :framework
|
102
|
-
|
103
|
-
# Should Airbrake catch exceptions from Rake tasks?
|
104
|
-
# (boolean or nil; set to nil to catch exceptions when rake isn't running from a terminal; default is nil)
|
105
|
-
attr_accessor :rescue_rake_exceptions
|
106
|
-
|
107
|
-
# User attributes that are being captured
|
108
|
-
attr_accessor :user_attributes
|
109
|
-
|
110
|
-
|
111
|
-
DEFAULT_PARAMS_FILTERS = %w(password password_confirmation).freeze
|
112
|
-
|
113
|
-
DEFAULT_USER_ATTRIBUTES = %w(id name username email).freeze
|
114
|
-
|
115
|
-
DEFAULT_BACKTRACE_FILTERS = [
|
116
|
-
lambda { |line|
|
117
|
-
if defined?(Airbrake.configuration.project_root) && Airbrake.configuration.project_root.to_s != ''
|
118
|
-
line.sub(/#{Airbrake.configuration.project_root}/, "[PROJECT_ROOT]")
|
119
|
-
else
|
120
|
-
line
|
121
|
-
end
|
122
|
-
},
|
123
|
-
lambda { |line| line.gsub(/^\.\//, "") },
|
124
|
-
lambda { |line|
|
125
|
-
if defined?(Gem)
|
126
|
-
Gem.path.inject(line) do |line, path|
|
127
|
-
line.gsub(/#{path}/, "[GEM_ROOT]")
|
128
|
-
end
|
129
|
-
end
|
130
|
-
},
|
131
|
-
lambda { |line| line if line !~ %r{lib/airbrake} }
|
132
|
-
].freeze
|
133
|
-
|
134
|
-
IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
|
135
|
-
'ActionController::RoutingError',
|
136
|
-
'ActionController::InvalidAuthenticityToken',
|
137
|
-
'CGI::Session::CookieStore::TamperedWithCookie',
|
138
|
-
'ActionController::UnknownAction',
|
139
|
-
'AbstractController::ActionNotFound',
|
140
|
-
'Mongoid::Errors::DocumentNotFound']
|
141
|
-
|
142
|
-
alias_method :secure?, :secure
|
143
|
-
alias_method :use_system_ssl_cert_chain?, :use_system_ssl_cert_chain
|
144
|
-
|
145
|
-
def initialize
|
146
|
-
@secure = false
|
147
|
-
@use_system_ssl_cert_chain= false
|
148
|
-
@host = 'api.airbrake.io'
|
149
|
-
@http_open_timeout = 2
|
150
|
-
@http_read_timeout = 5
|
151
|
-
@params_filters = DEFAULT_PARAMS_FILTERS.dup
|
152
|
-
@backtrace_filters = DEFAULT_BACKTRACE_FILTERS.dup
|
153
|
-
@ignore_by_filters = []
|
154
|
-
@ignore = IGNORE_DEFAULT.dup
|
155
|
-
@ignore_user_agent = []
|
156
|
-
@development_environments = %w(development test cucumber)
|
157
|
-
@development_lookup = true
|
158
|
-
@notifier_name = 'Airbrake Notifier'
|
159
|
-
@notifier_version = VERSION
|
160
|
-
@notifier_url = 'https://github.com/airbrake/airbrake'
|
161
|
-
@framework = 'Standalone'
|
162
|
-
@user_information = 'Airbrake Error {{error_id}}'
|
163
|
-
@rescue_rake_exceptions = nil
|
164
|
-
@user_attributes = DEFAULT_USER_ATTRIBUTES.dup
|
165
|
-
@rake_environment_filters = []
|
166
|
-
end
|
167
|
-
|
168
|
-
# Takes a block and adds it to the list of backtrace filters. When the filters
|
169
|
-
# run, the block will be handed each line of the backtrace and can modify
|
170
|
-
# it as necessary.
|
171
|
-
#
|
172
|
-
# @example
|
173
|
-
# config.filter_bracktrace do |line|
|
174
|
-
# line.gsub(/^#{Rails.root}/, "[Rails.root]")
|
175
|
-
# end
|
176
|
-
#
|
177
|
-
# @param [Proc] block The new backtrace filter.
|
178
|
-
# @yieldparam [String] line A line in the backtrace.
|
179
|
-
def filter_backtrace(&block)
|
180
|
-
self.backtrace_filters << block
|
181
|
-
end
|
182
|
-
|
183
|
-
# Takes a block and adds it to the list of ignore filters.
|
184
|
-
# When the filters run, the block will be handed the exception.
|
185
|
-
# @example
|
186
|
-
# config.ignore_by_filter do |exception_data|
|
187
|
-
# true if exception_data[:error_class] == "RuntimeError"
|
188
|
-
# end
|
189
|
-
#
|
190
|
-
# @param [Proc] block The new ignore filter
|
191
|
-
# @yieldparam [Hash] data The exception data given to +Airbrake.notify+
|
192
|
-
# @yieldreturn [Boolean] If the block returns true the exception will be ignored, otherwise it will be processed by airbrake.
|
193
|
-
def ignore_by_filter(&block)
|
194
|
-
self.ignore_by_filters << block
|
195
|
-
end
|
196
|
-
|
197
|
-
# Overrides the list of default ignored errors.
|
198
|
-
#
|
199
|
-
# @param [Array<Exception>] names A list of exceptions to ignore.
|
200
|
-
def ignore_only=(names)
|
201
|
-
@ignore = [names].flatten
|
202
|
-
end
|
203
|
-
|
204
|
-
# Overrides the list of default ignored user agents
|
205
|
-
#
|
206
|
-
# @param [Array<String>] A list of user agents to ignore
|
207
|
-
def ignore_user_agent_only=(names)
|
208
|
-
@ignore_user_agent = [names].flatten
|
209
|
-
end
|
210
|
-
|
211
|
-
# Allows config options to be read like a hash
|
212
|
-
#
|
213
|
-
# @param [Symbol] option Key for a given attribute
|
214
|
-
def [](option)
|
215
|
-
send(option)
|
216
|
-
end
|
217
|
-
|
218
|
-
# Returns a hash of all configurable options
|
219
|
-
def to_hash
|
220
|
-
OPTIONS.inject({}) do |hash, option|
|
221
|
-
hash[option.to_sym] = self.send(option)
|
222
|
-
hash
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
# Returns a hash of all configurable options merged with +hash+
|
227
|
-
#
|
228
|
-
# @param [Hash] hash A set of configuration options that will take precedence over the defaults
|
229
|
-
def merge(hash)
|
230
|
-
to_hash.merge(hash)
|
231
|
-
end
|
232
|
-
|
233
|
-
# Determines if the notifier will send notices.
|
234
|
-
# @return [Boolean] Returns +false+ if in a development environment, +true+ otherwise.
|
235
|
-
def public?
|
236
|
-
!development_environments.include?(environment_name)
|
237
|
-
end
|
238
|
-
|
239
|
-
def port
|
240
|
-
@port || default_port
|
241
|
-
end
|
242
|
-
|
243
|
-
# Determines whether protocol should be "http" or "https".
|
244
|
-
# @return [String] Returns +"http"+ if you've set secure to +false+ in
|
245
|
-
# configuration, and +"https"+ otherwise.
|
246
|
-
def protocol
|
247
|
-
if secure?
|
248
|
-
'https'
|
249
|
-
else
|
250
|
-
'http'
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
# Should Airbrake send notifications asynchronously
|
255
|
-
# (boolean, nil or callable; default is nil).
|
256
|
-
# Can be used as callable-setter when block provided.
|
257
|
-
def async(&block)
|
258
|
-
if block_given?
|
259
|
-
@async = block
|
260
|
-
end
|
261
|
-
@async
|
262
|
-
end
|
263
|
-
alias_method :async?, :async
|
264
|
-
|
265
|
-
def async=(use_default_or_this)
|
266
|
-
@async = use_default_or_this == true ?
|
267
|
-
default_async_processor :
|
268
|
-
use_default_or_this
|
269
|
-
end
|
270
|
-
|
271
|
-
def js_api_key
|
272
|
-
@js_api_key || self.api_key
|
273
|
-
end
|
274
|
-
|
275
|
-
def js_notifier=(*args)
|
276
|
-
warn '[AIRBRAKE] config.js_notifier has been deprecated and has no effect. You should use <%= airbrake_javascript_notifier %> directly at the top of your layouts. Be sure to place it before all other javascript.'
|
277
|
-
end
|
278
|
-
|
279
|
-
def ca_bundle_path
|
280
|
-
if use_system_ssl_cert_chain? && File.exist?(OpenSSL::X509::DEFAULT_CERT_FILE)
|
281
|
-
OpenSSL::X509::DEFAULT_CERT_FILE
|
282
|
-
else
|
283
|
-
local_cert_path # ca-bundle.crt built from source, see resources/README.md
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
def local_cert_path
|
288
|
-
File.expand_path(File.join("..", "..", "..", "resources", "ca-bundle.crt"), __FILE__)
|
289
|
-
end
|
290
|
-
|
291
|
-
private
|
292
|
-
# Determines what port should we use for sending notices.
|
293
|
-
# @return [Fixnum] Returns 443 if you've set secure to true in your
|
294
|
-
# configuration, and 80 otherwise.
|
295
|
-
def default_port
|
296
|
-
if secure?
|
297
|
-
443
|
298
|
-
else
|
299
|
-
80
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
# Async notice delivery defaults to girl friday
|
304
|
-
def default_async_processor
|
305
|
-
queue = GirlFriday::WorkQueue.new(nil, :size => 3) do |notice|
|
306
|
-
Airbrake.sender.send_to_airbrake(notice)
|
307
|
-
end
|
308
|
-
lambda {|notice| queue << notice}
|
309
|
-
end
|
310
|
-
end
|
311
|
-
end
|