airbrake 3.1.4 → 3.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,19 @@
1
+ Version 3.1.5 - 2012-10-05 17:32:23 +0200
2
+ ===============================================================================
3
+
4
+ Hrvoje Šimić (3):
5
+ make collected user attributes customizable
6
+ enable filtering of env vars for rake handler
7
+ add a simple executable
8
+
9
+ Morgan Mikel McDaris (1):
10
+ rake section added
11
+
12
+ Zachary Anker (2):
13
+ Add the ability to pass XML directly to send_to_airbrake
14
+ Remove active_support require since it's no longer necessary
15
+
16
+
1
17
  Version 3.1.4 - 2012-09-11 04:31:51 +0200
2
18
  ===============================================================================
3
19
 
@@ -906,3 +922,4 @@ Nick Quaranto (3):
906
922
 
907
923
 
908
924
 
925
+
data/README.md CHANGED
@@ -212,6 +212,15 @@ To perform custom error processing after Airbrake has been notified, define the
212
212
  instance method `#rescue_action_in_public_without_airbrake(exception)` in your
213
213
  controller.
214
214
 
215
+ Rake Tasks
216
+ ----------
217
+ Do you want Airbrake to report exceptions that happen inside a rake task?
218
+
219
+ Airbrake.configure do |config|
220
+ ...
221
+ config.rescue_rake_exceptions = true
222
+ end
223
+
215
224
  Informing the User
216
225
  ------------------
217
226
 
@@ -240,7 +249,7 @@ automatically in a controller, Airbrake sets that value. If you're, however, cal
240
249
  Current user information
241
250
  ------------------------
242
251
  Airbrake provides information about the current logged in user, so you
243
- could easily determine the user who experienced the error in your app.
252
+ can easily determine the user who experienced the error in your app.
244
253
 
245
254
  It uses `current_user` and `current_member` to identify the
246
255
  authenticated user, where `current_user` takes precendence.
@@ -251,9 +260,23 @@ controller:
251
260
  alias_method :current_duck, :current_user
252
261
  helper_method :current_duck
253
262
 
254
- Voila! You'll get information about a duck that experienced crash about
263
+ Voila! You'll get information about a duck that experienced a crash of
255
264
  your app.
256
265
 
266
+ By default Airbrake collects the following attributes:
267
+ * id
268
+ * name
269
+ * username
270
+ * email
271
+
272
+ You can also customize attributes that will be collected
273
+
274
+ Airbrake.configure do |config|
275
+ ...
276
+ # collect only user ids
277
+ config.user_attributes = [:id] # ["id"] also works
278
+ end
279
+
257
280
  Asynchronous notifications with Airbrake
258
281
  ----------------------------------------
259
282
  When your user experiences error using your application, it gets sent to
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ rescue LoadError
9
9
  end
10
10
  require './lib/airbrake/version'
11
11
 
12
- FEATURES = ["sinatra","rack","metal","user_informer"]
12
+ FEATURES = ["sinatra","rack","metal","user_informer","rake"]
13
13
 
14
14
  desc 'Default: run unit tests.'
15
15
  task :default => [:test, "cucumber:rails:all"] + FEATURES
@@ -8,6 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.summary = %q{Send your application errors to our hosted service and reclaim your inbox.}
9
9
 
10
10
  s.require_paths = ["lib"]
11
+ s.executables << "airbrake"
11
12
  s.files = Dir["{generators/**/*,lib/**/*,rails/**/*,resources/*,script/*}"] +
12
13
  %w(airbrake.gemspec CHANGELOG Gemfile Guardfile INSTALL MIT-LICENSE Rakefile README_FOR_HEROKU_ADDON.md README.md TESTING.md SUPPORTED_RAILS_VERSIONS install.rb)
13
14
  s.test_files = Dir.glob("{test,spec,features}/**/*")
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+ require "airbrake"
3
+
4
+ def parse_options(array = [])
5
+ opts = Hash[*array]
6
+ opts[:error] = opts.delete("-e") || opts.delete("--error") { RuntimeError }
7
+ opts[:message] = opts.delete("-m") || opts.delete("--message") { "I've made a huge mistake" }
8
+ opts[:api_key] = opts.delete("-k") || opts.delete("--api-key")
9
+ opts[:host] = opts.delete("-h") || opts.delete("--host")
10
+ opts[:port] = opts.delete("-p") || opts.delete("--port")
11
+ opts
12
+ end
13
+
14
+ args = ARGV.dup
15
+ command = args.shift.strip rescue nil
16
+
17
+ case command
18
+ when 'raise'
19
+ options = parse_options(ARGV[1..-1])
20
+ abort "You didn't provide API_KEY so nothing was raised."\
21
+ " Refer to usage for more info (airbrake --help)." unless options[:api_key]
22
+ Airbrake.configure do |c|
23
+ c.api_key = options[:api_key]
24
+ c.host = options[:host] if options[:host]
25
+ c.port = options[:port] if options[:port]
26
+ end
27
+ exception_id = Airbrake.notify(:error_class => options[:error],
28
+ :error_message => "#{options[:error]}: #{options[:message]}",
29
+ :cgi_data => ENV)
30
+ abort "Error sending exception to Airbrake server. Try again later." unless exception_id
31
+ puts "Exception sent successfully: http://airbrake.io/locate/#{exception_id}"
32
+ else
33
+ puts <<USAGE
34
+ Usage: airbrake [COMMAND] [OPTION]...
35
+ Commands:
36
+ raise # Raise an exception specified by ERROR and MESSAGE.
37
+
38
+ Options:
39
+ -e, [--error=ERROR] # Error class to raise. Default: RuntimeError
40
+ -m, [--message=MESSAGE] # Error message. Default: "I've made a huge mistake"
41
+ -k, [--api-key=API_KEY] # Api key of your Airbrake application.
42
+ -h, [--host=HOST] # URL of the Airbrake API server. Default: api.airbrake.io
43
+ -p, [--port=PORT] # Port of the Airbrake API server. Default: 80
44
+ -h, [--help] # Show this usage
45
+ USAGE
46
+ end
@@ -7,8 +7,8 @@ module Airbrake
7
7
  :http_open_timeout, :http_read_timeout, :ignore, :ignore_by_filters,
8
8
  :ignore_user_agent, :notifier_name, :notifier_url, :notifier_version,
9
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].freeze
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
12
 
13
13
  # The API key for your project, found on the project edit form.
14
14
  attr_accessor :api_key
@@ -60,6 +60,10 @@ module Airbrake
60
60
  # A list of filters for ignoring exceptions. See #ignore_by_filter.
61
61
  attr_reader :ignore_by_filters
62
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
+
63
67
  # A list of exception classes to ignore. The array can be appended to.
64
68
  attr_reader :ignore
65
69
 
@@ -100,9 +104,14 @@ module Airbrake
100
104
  # (boolean or nil; set to nil to catch exceptions when rake isn't running from a terminal; default is nil)
101
105
  attr_accessor :rescue_rake_exceptions
102
106
 
107
+ # User attributes that are being captured
108
+ attr_accessor :user_attributes
109
+
103
110
 
104
111
  DEFAULT_PARAMS_FILTERS = %w(password password_confirmation).freeze
105
112
 
113
+ DEFAULT_USER_ATTRIBUTES = %w(id name username email).freeze
114
+
106
115
  DEFAULT_BACKTRACE_FILTERS = [
107
116
  lambda { |line|
108
117
  if defined?(Airbrake.configuration.project_root) && Airbrake.configuration.project_root.to_s != ''
@@ -152,6 +161,8 @@ module Airbrake
152
161
  @framework = 'Standalone'
153
162
  @user_information = 'Airbrake Error {{error_id}}'
154
163
  @rescue_rake_exceptions = nil
164
+ @user_attributes = DEFAULT_USER_ATTRIBUTES.dup
165
+ @rake_environment_filters = []
155
166
  end
156
167
 
157
168
  # Takes a block and adds it to the list of backtrace filters. When the filters
@@ -265,11 +276,6 @@ module Airbrake
265
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.'
266
277
  end
267
278
 
268
- def environment_filters
269
- warn 'config.environment_filters has been deprecated and has no effect.'
270
- []
271
- end
272
-
273
279
  def ca_bundle_path
274
280
  if use_system_ssl_cert_chain? && File.exist?(OpenSSL::X509::DEFAULT_CERT_FILE)
275
281
  OpenSSL::X509::DEFAULT_CERT_FILE
@@ -92,7 +92,7 @@ module Airbrake
92
92
  # Private writers for all the attributes
93
93
  attr_writer :exception, :api_key, :backtrace, :error_class, :error_message,
94
94
  :backtrace_filters, :parameters, :params_filters,
95
- :environment_filters, :session_data, :project_root, :url, :ignore,
95
+ :session_data, :project_root, :url, :ignore,
96
96
  :ignore_by_filters, :notifier_name, :notifier_url, :notifier_version,
97
97
  :component, :action, :cgi_data, :environment_name, :hostname, :user
98
98
 
@@ -75,7 +75,9 @@ module Airbrake
75
75
  def airbrake_current_user
76
76
  user = begin current_user rescue current_member end
77
77
  user.attributes.select do |k, v|
78
- /^(id|name|username|email)$/ === k unless v.blank?
78
+ Airbrake.configuration.
79
+ user_attributes.map(&:to_sym).
80
+ include? k.to_sym unless v.blank?
79
81
  end.symbolize_keys
80
82
  rescue NoMethodError, NameError
81
83
  {}
@@ -13,7 +13,7 @@ module Airbrake::RakeHandler
13
13
  (Airbrake.configuration.rescue_rake_exceptions ||
14
14
  (Airbrake.configuration.rescue_rake_exceptions===nil && !self.tty_output?))
15
15
 
16
- Airbrake.notify_or_ignore(ex, :component => reconstruct_command_line, :cgi_data => ENV)
16
+ Airbrake.notify_or_ignore(ex, :component => reconstruct_command_line, :cgi_data => environment_info)
17
17
  end
18
18
 
19
19
  display_error_message_without_airbrake(ex)
@@ -23,6 +23,12 @@ module Airbrake::RakeHandler
23
23
  "rake #{ARGV.join( ' ' )}"
24
24
  end
25
25
 
26
+ def environment_info
27
+ ENV.reject do |k|
28
+ Airbrake.configuration.rake_environment_filters.include? k
29
+ end
30
+ end
31
+
26
32
  # This module brings Rake 0.8.7 error handling to 0.9.0 standards
27
33
  module Rake087Methods
28
34
  # Method taken from Rake 0.9.0 source
@@ -31,9 +31,9 @@ module Airbrake
31
31
 
32
32
  # Sends the notice data off to Airbrake for processing.
33
33
  #
34
- # @param [Notice] notice The notice to be sent off
34
+ # @param [Notice or String] notice The notice to be sent off
35
35
  def send_to_airbrake(notice)
36
- data = notice.to_xml
36
+ data = notice.respond_to?(:to_xml) ? notice.to_xml : notice
37
37
  http = setup_http_connection
38
38
 
39
39
  response = begin
@@ -1,3 +1,3 @@
1
1
  module Airbrake
2
- VERSION = "3.1.4".freeze
2
+ VERSION = "3.1.5".freeze
3
3
  end
@@ -1,6 +1,5 @@
1
1
  require 'net/http'
2
2
  require 'uri'
3
- require 'active_support'
4
3
 
5
4
  # Capistrano tasks for notifying Airbrake of deploys
6
5
  module AirbrakeTasks
@@ -25,6 +25,7 @@ class ConfigurationTest < Test::Unit::TestCase
25
25
  Airbrake::Configuration::DEFAULT_PARAMS_FILTERS
26
26
  assert_config_default :backtrace_filters,
27
27
  Airbrake::Configuration::DEFAULT_BACKTRACE_FILTERS
28
+ assert_config_default :rake_environment_filters, []
28
29
  assert_config_default :ignore,
29
30
  Airbrake::Configuration::IGNORE_DEFAULT
30
31
  assert_config_default :development_lookup, true
@@ -114,12 +115,8 @@ class ConfigurationTest < Test::Unit::TestCase
114
115
  assert_appends_value :params_filters
115
116
  end
116
117
 
117
- should "warn when attempting to read environment filters" do
118
- config = Airbrake::Configuration.new
119
- config.
120
- expects(:warn).
121
- with(regexp_matches(/deprecated/i))
122
- assert_equal [], config.environment_filters
118
+ should "allow rake environment filters to be appended" do
119
+ assert_appends_value :rake_environment_filters
123
120
  end
124
121
 
125
122
  should "warn when attempting to write js_notifier" do
@@ -31,6 +31,32 @@ class SenderTest < Test::Unit::TestCase
31
31
  http
32
32
  end
33
33
 
34
+ should "post to Airbrake with XML passed" do
35
+ xml_notice = Airbrake::Notice.new(:error_class => "FooBar", :error_message => "Foo Bar").to_xml
36
+
37
+ http = stub_http
38
+
39
+ sender = build_sender
40
+ sender.send_to_airbrake(xml_notice)
41
+
42
+ assert_received(http, :post) do |expect|
43
+ expect.with(anything, xml_notice, Airbrake::HEADERS)
44
+ end
45
+ end
46
+
47
+ should "post to Airbrake with a Notice instance passed" do
48
+ notice = Airbrake::Notice.new(:error_class => "FooBar", :error_message => "Foo Bar")
49
+
50
+ http = stub_http
51
+
52
+ sender = build_sender
53
+ sender.send_to_airbrake(notice)
54
+
55
+ assert_received(http, :post) do |expect|
56
+ expect.with(anything, notice.to_xml, Airbrake::HEADERS)
57
+ end
58
+ end
59
+
34
60
  should "post to Airbrake when using an HTTP proxy" do
35
61
  response = stub(:body => 'body')
36
62
  http = stub(:post => response,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbrake
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.4
4
+ version: 3.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-12 00:00:00.000000000 Z
12
+ date: 2012-10-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder
@@ -285,44 +285,45 @@ dependencies:
285
285
  version: '0'
286
286
  description:
287
287
  email: support@airbrake.io
288
- executables: []
288
+ executables:
289
+ - airbrake
289
290
  extensions: []
290
291
  extra_rdoc_files: []
291
292
  files:
292
- - generators/airbrake/airbrake_generator.rb
293
- - generators/airbrake/lib/insert_commands.rb
294
- - generators/airbrake/lib/rake_commands.rb
295
- - generators/airbrake/templates/airbrake_tasks.rake
296
293
  - generators/airbrake/templates/capistrano_hook.rb
297
294
  - generators/airbrake/templates/initializer.rb
298
- - lib/airbrake/backtrace.rb
295
+ - generators/airbrake/templates/airbrake_tasks.rake
296
+ - generators/airbrake/lib/insert_commands.rb
297
+ - generators/airbrake/lib/rake_commands.rb
298
+ - generators/airbrake/airbrake_generator.rb
299
299
  - lib/airbrake/capistrano.rb
300
- - lib/airbrake/configuration.rb
301
- - lib/airbrake/notice.rb
302
- - lib/airbrake/rack.rb
300
+ - lib/airbrake/shared_tasks.rb
301
+ - lib/airbrake/sender.rb
303
302
  - lib/airbrake/rails/action_controller_catcher.rb
304
303
  - lib/airbrake/rails/controller_methods.rb
305
304
  - lib/airbrake/rails/error_lookup.rb
306
305
  - lib/airbrake/rails/javascript_notifier.rb
307
306
  - lib/airbrake/rails/middleware/exceptions_catcher.rb
308
307
  - lib/airbrake/rails.rb
308
+ - lib/airbrake/rack.rb
309
+ - lib/airbrake/tasks.rb
309
310
  - lib/airbrake/rails3_tasks.rb
311
+ - lib/airbrake/configuration.rb
310
312
  - lib/airbrake/railtie.rb
311
313
  - lib/airbrake/rake_handler.rb
312
- - lib/airbrake/sender.rb
313
- - lib/airbrake/shared_tasks.rb
314
- - lib/airbrake/tasks.rb
315
- - lib/airbrake/user_informer.rb
316
- - lib/airbrake/utils/blank.rb
317
314
  - lib/airbrake/version.rb
315
+ - lib/airbrake/backtrace.rb
316
+ - lib/airbrake/utils/blank.rb
317
+ - lib/airbrake/notice.rb
318
+ - lib/airbrake/user_informer.rb
318
319
  - lib/airbrake.rb
319
- - lib/airbrake_tasks.rb
320
320
  - lib/rails/generators/airbrake/airbrake_generator.rb
321
321
  - lib/templates/javascript_notifier.erb
322
322
  - lib/templates/rescue.erb
323
+ - lib/airbrake_tasks.rb
323
324
  - rails/init.rb
324
- - resources/ca-bundle.crt
325
325
  - resources/README.md
326
+ - resources/ca-bundle.crt
326
327
  - script/integration_test.rb
327
328
  - airbrake.gemspec
328
329
  - CHANGELOG
@@ -336,40 +337,41 @@ files:
336
337
  - TESTING.md
337
338
  - SUPPORTED_RAILS_VERSIONS
338
339
  - install.rb
339
- - test/airbrake_2_3.xsd
340
+ - test/configuration_test.rb
340
341
  - test/airbrake_tasks_test.rb
341
- - test/backtrace_test.rb
342
- - test/capistrano_test.rb
343
342
  - test/catcher_test.rb
344
- - test/configuration_test.rb
345
- - test/helper.rb
346
- - test/javascript_notifier_test.rb
347
- - test/logger_test.rb
348
- - test/notice_test.rb
349
343
  - test/notifier_test.rb
344
+ - test/capistrano_test.rb
345
+ - test/user_informer_test.rb
346
+ - test/javascript_notifier_test.rb
347
+ - test/backtrace_test.rb
350
348
  - test/rack_test.rb
351
- - test/rails_initializer_test.rb
352
349
  - test/recursion_test.rb
350
+ - test/airbrake_2_3.xsd
351
+ - test/notice_test.rb
352
+ - test/rails_initializer_test.rb
353
353
  - test/sender_test.rb
354
- - test/user_informer_test.rb
355
- - features/metal.feature
354
+ - test/helper.rb
355
+ - test/logger_test.rb
356
356
  - features/rack.feature
357
- - features/rails.feature
358
- - features/rails_with_js_notifier.feature
359
- - features/rake.feature
360
- - features/sinatra.feature
361
- - features/step_definitions/file_steps.rb
362
- - features/step_definitions/metal_steps.rb
363
- - features/step_definitions/rack_steps.rb
364
- - features/step_definitions/rails_application_steps.rb
365
- - features/step_definitions/rake_steps.rb
357
+ - features/metal.feature
366
358
  - features/support/airbrake_shim.rb.template
367
- - features/support/env.rb
368
- - features/support/matchers.rb
369
- - features/support/rails.rb
370
359
  - features/support/rake/Rakefile
360
+ - features/support/rails.rb
371
361
  - features/support/terminal.rb
362
+ - features/support/matchers.rb
363
+ - features/support/env.rb
364
+ - features/rails.feature
372
365
  - features/user_informer.feature
366
+ - features/step_definitions/rack_steps.rb
367
+ - features/step_definitions/file_steps.rb
368
+ - features/step_definitions/rake_steps.rb
369
+ - features/step_definitions/rails_application_steps.rb
370
+ - features/step_definitions/metal_steps.rb
371
+ - features/rake.feature
372
+ - features/sinatra.feature
373
+ - features/rails_with_js_notifier.feature
374
+ - bin/airbrake
373
375
  homepage: http://www.airbrake.io
374
376
  licenses: []
375
377
  post_install_message:
@@ -395,37 +397,37 @@ signing_key:
395
397
  specification_version: 3
396
398
  summary: Send your application errors to our hosted service and reclaim your inbox.
397
399
  test_files:
398
- - test/airbrake_2_3.xsd
400
+ - test/configuration_test.rb
399
401
  - test/airbrake_tasks_test.rb
400
- - test/backtrace_test.rb
401
- - test/capistrano_test.rb
402
402
  - test/catcher_test.rb
403
- - test/configuration_test.rb
404
- - test/helper.rb
405
- - test/javascript_notifier_test.rb
406
- - test/logger_test.rb
407
- - test/notice_test.rb
408
403
  - test/notifier_test.rb
404
+ - test/capistrano_test.rb
405
+ - test/user_informer_test.rb
406
+ - test/javascript_notifier_test.rb
407
+ - test/backtrace_test.rb
409
408
  - test/rack_test.rb
410
- - test/rails_initializer_test.rb
411
409
  - test/recursion_test.rb
410
+ - test/airbrake_2_3.xsd
411
+ - test/notice_test.rb
412
+ - test/rails_initializer_test.rb
412
413
  - test/sender_test.rb
413
- - test/user_informer_test.rb
414
- - features/metal.feature
414
+ - test/helper.rb
415
+ - test/logger_test.rb
415
416
  - features/rack.feature
416
- - features/rails.feature
417
- - features/rails_with_js_notifier.feature
418
- - features/rake.feature
419
- - features/sinatra.feature
420
- - features/step_definitions/file_steps.rb
421
- - features/step_definitions/metal_steps.rb
422
- - features/step_definitions/rack_steps.rb
423
- - features/step_definitions/rails_application_steps.rb
424
- - features/step_definitions/rake_steps.rb
417
+ - features/metal.feature
425
418
  - features/support/airbrake_shim.rb.template
426
- - features/support/env.rb
427
- - features/support/matchers.rb
428
- - features/support/rails.rb
429
419
  - features/support/rake/Rakefile
420
+ - features/support/rails.rb
430
421
  - features/support/terminal.rb
422
+ - features/support/matchers.rb
423
+ - features/support/env.rb
424
+ - features/rails.feature
431
425
  - features/user_informer.feature
426
+ - features/step_definitions/rack_steps.rb
427
+ - features/step_definitions/file_steps.rb
428
+ - features/step_definitions/rake_steps.rb
429
+ - features/step_definitions/rails_application_steps.rb
430
+ - features/step_definitions/metal_steps.rb
431
+ - features/rake.feature
432
+ - features/sinatra.feature
433
+ - features/rails_with_js_notifier.feature