bugsnag 1.3.8 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,21 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ 1.4.0
5
+ -----
6
+ - Add ignore_user_agents to ignore certain user agents
7
+ - Change bugsnag middleware order to have Callbacks last
8
+ - Allow nil values to be sent to bugsnag
9
+
10
+ 1.3.8
11
+ -----
12
+ - Add truncated only when a field has been truncated
13
+
14
+ 1.3.7
15
+ -----
16
+ - Fix warden bug where user id is an array of ids
17
+ - Filter get params from URLs as well as meta_data
18
+
4
19
  1.3.6
5
20
  -----
6
21
  - Filter out meta-data keys containing the word 'secret' by default
data/README.md CHANGED
@@ -311,6 +311,18 @@ By default, `ignore_classes` contains the following:
311
311
  ]
312
312
  ```
313
313
 
314
+ ###ignore_user_agents
315
+
316
+ Sets an array of Regexps that can be used to ignore exceptions from
317
+ certain user agents.
318
+
319
+ ```ruby
320
+ config.ignore_user_agents << %r{Chrome}
321
+ ```
322
+
323
+ By default, `ignore_user_agents` is empty, so exceptions caused by all
324
+ user agents are reported.
325
+
314
326
  ###logger
315
327
 
316
328
  Sets which logger to use for Bugsnag log messages. In rails apps, this is
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.8
1
+ 1.4.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bugsnag}
8
- s.version = "1.3.8"
8
+ s.version = "1.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["James Smith"]
12
- s.date = %q{2013-06-12}
12
+ s.date = %q{2013-07-09}
13
13
  s.description = %q{Ruby notifier for bugsnag.com}
14
14
  s.email = %q{james@bugsnag.com}
15
15
  s.extra_rdoc_files = [
@@ -13,6 +13,7 @@ module Bugsnag
13
13
  attr_accessor :app_version
14
14
  attr_accessor :params_filters
15
15
  attr_accessor :ignore_classes
16
+ attr_accessor :ignore_user_agents
16
17
  attr_accessor :endpoint
17
18
  attr_accessor :logger
18
19
  attr_accessor :middleware
@@ -35,6 +36,8 @@ module Bugsnag
35
36
  "Mongoid::Errors::DocumentNotFound"
36
37
  ].freeze
37
38
 
39
+ DEFAULT_IGNORE_USER_AGENTS = [].freeze
40
+
38
41
  def initialize
39
42
  # Set up the defaults
40
43
  self.release_stage = nil
@@ -43,6 +46,7 @@ module Bugsnag
43
46
  self.use_ssl = false
44
47
  self.params_filters = Set.new(DEFAULT_PARAMS_FILTERS)
45
48
  self.ignore_classes = Set.new(DEFAULT_IGNORE_CLASSES)
49
+ self.ignore_user_agents = Set.new(DEFAULT_IGNORE_USER_AGENTS)
46
50
  self.endpoint = DEFAULT_ENDPOINT
47
51
 
48
52
  # Set up logging
@@ -74,4 +78,4 @@ module Bugsnag
74
78
  Thread.current[THREAD_LOCAL_NAME] = nil
75
79
  end
76
80
  end
77
- end
81
+ end
@@ -20,7 +20,7 @@ module Bugsnag
20
20
  clean_hash[k] = "[FILTERED]"
21
21
  else
22
22
  clean_obj = cleanup_obj(v, filters)
23
- clean_hash[k] = clean_obj unless clean_obj.nil?
23
+ clean_hash[k] = clean_obj
24
24
  end
25
25
  end
26
26
  clean_hash
@@ -14,7 +14,12 @@ module Bugsnag
14
14
  def insert_after(after, new_middleware)
15
15
  return if @disabled_middleware.include?(new_middleware)
16
16
 
17
- index = @middlewares.rindex(after)
17
+ if after.is_a? Array
18
+ index = @middlewares.rindex {|el| after.include?(el)}
19
+ else
20
+ index = @middlewares.rindex(after)
21
+ end
22
+
18
23
  if index.nil?
19
24
  @middlewares << new_middleware
20
25
  else
@@ -25,8 +30,13 @@ module Bugsnag
25
30
  def insert_before(before, new_middleware)
26
31
  return if @disabled_middleware.include?(new_middleware)
27
32
 
28
- index = @middlewares.index(before) || @middlewares.length
29
- @middlewares.insert index, new_middleware
33
+ if before.is_a? Array
34
+ index = @middlewares.index {|el| before.include?(el)}
35
+ else
36
+ index = @middlewares.index(before)
37
+ end
38
+
39
+ @middlewares.insert index || @middlewares.length, new_middleware
30
40
  end
31
41
 
32
42
  def disable(*middlewares)
@@ -176,10 +176,7 @@ module Bugsnag
176
176
  end
177
177
 
178
178
  def ignore?
179
- ex = @exceptions.last
180
- @configuration.ignore_classes.any? do |to_ignore|
181
- to_ignore.is_a?(Proc) ? to_ignore.call(ex) : to_ignore == error_class(ex)
182
- end
179
+ ignore_exception_class? || ignore_user_agent?
183
180
  end
184
181
 
185
182
  def request_data
@@ -192,6 +189,21 @@ module Bugsnag
192
189
 
193
190
  private
194
191
 
192
+ def ignore_exception_class?
193
+ ex = @exceptions.last
194
+ @configuration.ignore_classes.any? do |to_ignore|
195
+ to_ignore.is_a?(Proc) ? to_ignore.call(ex) : to_ignore == error_class(ex)
196
+ end
197
+ end
198
+
199
+ def ignore_user_agent?
200
+ if @configuration.request_data && @configuration.request_data[:rack_env] && (agent = @configuration.request_data[:rack_env]["HTTP_USER_AGENT"])
201
+ @configuration.ignore_user_agents.any? do |to_ignore|
202
+ agent =~ to_ignore
203
+ end
204
+ end
205
+ end
206
+
195
207
  # Generate the meta data from both the request configuration, the overrides and the exceptions for this notification
196
208
  def generate_meta_data(exceptions, overrides)
197
209
  # Copy the request meta data so we dont edit it by mistake
@@ -23,8 +23,8 @@ module Bugsnag
23
23
  end
24
24
 
25
25
  # Hook up rack-based notification middlewares
26
- config.middleware.insert_before(Bugsnag::Middleware::Rails3Request, Bugsnag::Middleware::RackRequest) if defined?(::Rack)
27
- config.middleware.use Bugsnag::Middleware::WardenUser if defined?(Warden)
26
+ config.middleware.insert_before([Bugsnag::Middleware::Rails3Request,Bugsnag::Middleware::Callbacks], Bugsnag::Middleware::RackRequest) if defined?(::Rack)
27
+ config.middleware.insert_before(Bugsnag::Middleware::Callbacks, Bugsnag::Middleware::WardenUser) if defined?(Warden)
28
28
  end
29
29
  end
30
30
 
@@ -28,7 +28,7 @@ module Bugsnag
28
28
  config.release_stage = RAILS_ENV if defined?(RAILS_ENV)
29
29
  config.project_root = RAILS_ROOT if defined?(RAILS_ROOT)
30
30
 
31
- config.middleware.use Bugsnag::Middleware::Rails2Request
31
+ config.middleware.insert_before(Bugsnag::Middleware::Callbacks,Bugsnag::Middleware::Rails2Request)
32
32
  end
33
33
 
34
34
  # Auto-load configuration settings from config/bugsnag.yml if it exists
@@ -18,7 +18,7 @@ module Bugsnag
18
18
  config.release_stage = Rails.env.to_s
19
19
  config.project_root = Rails.root.to_s
20
20
  config.params_filters += Rails.configuration.filter_parameters
21
- config.middleware.insert_after Bugsnag::Middleware::RackRequest, Bugsnag::Middleware::Rails3Request
21
+ config.middleware.insert_before Bugsnag::Middleware::Callbacks, Bugsnag::Middleware::Rails3Request
22
22
  end
23
23
 
24
24
  # Auto-load configuration settings from config/bugsnag.yml if it exists
@@ -24,7 +24,7 @@ module Bugsnag::Rake
24
24
  notif.context ||= task.name
25
25
  }
26
26
 
27
- yield
27
+ yield if block_given?
28
28
  rescue Exception => e
29
29
  Bugsnag.notify(e)
30
30
  raise
@@ -368,6 +368,18 @@ describe Bugsnag::Notification do
368
368
  Bugsnag.notify(BugsnagTestException.new("It crashed"), {:request => {:params => {:password => "1234", :other_password => "123456", :other_data => "123456"}}})
369
369
  end
370
370
 
371
+ it "should not filter params from payload hashes if their values are nil" do
372
+ Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
373
+ event = get_event_from_payload(payload)
374
+ event[:metaData].should_not be_nil
375
+ event[:metaData][:request].should_not be_nil
376
+ event[:metaData][:request][:params].should_not be_nil
377
+ event[:metaData][:request][:params].should have_key(:nil_param)
378
+ end
379
+
380
+ Bugsnag.notify(BugsnagTestException.new("It crashed"), {:request => {:params => {:nil_param => nil}}})
381
+ end
382
+
371
383
  it "should not notify if the exception class is in the default ignore_classes list" do
372
384
  Bugsnag::Notification.should_not_receive(:deliver_exception_payload)
373
385
 
@@ -390,6 +402,16 @@ describe Bugsnag::Notification do
390
402
  Bugsnag.notify_or_ignore(BugsnagTestException.new("It crashed"))
391
403
  end
392
404
 
405
+ it "should not notify if the user agent is present and matches a regex in ignore_user_agents" do
406
+ Bugsnag.configuration.ignore_user_agents << %r{BugsnagUserAgent}
407
+
408
+ Bugsnag::Notification.should_not_receive(:deliver_exception_payload)
409
+
410
+ ((Thread.current["bugsnag_req_data"] ||= {})[:rack_env] ||= {})["HTTP_USER_AGENT"] = "BugsnagUserAgent"
411
+
412
+ Bugsnag.notify_or_ignore(BugsnagTestException.new("It crashed"))
413
+ end
414
+
393
415
  it "should not unwrap the same exception twice" do
394
416
  Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
395
417
  event = get_event_from_payload(payload)
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 3
8
- - 8
9
- version: 1.3.8
7
+ - 4
8
+ - 0
9
+ version: 1.4.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - James Smith
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2013-06-12 00:00:00 +01:00
17
+ date: 2013-07-09 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency