bugsnag 6.19.0 → 6.23.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/bugsnag.rb CHANGED
@@ -5,6 +5,7 @@ require "bugsnag/version"
5
5
  require "bugsnag/configuration"
6
6
  require "bugsnag/meta_data"
7
7
  require "bugsnag/report"
8
+ require "bugsnag/event"
8
9
  require "bugsnag/cleaner"
9
10
  require "bugsnag/helpers"
10
11
  require "bugsnag/session_tracker"
@@ -28,10 +29,13 @@ require "bugsnag/middleware/rake"
28
29
  require "bugsnag/middleware/classify_error"
29
30
  require "bugsnag/middleware/delayed_job"
30
31
 
32
+ require "bugsnag/breadcrumb_type"
31
33
  require "bugsnag/breadcrumbs/validator"
32
34
  require "bugsnag/breadcrumbs/breadcrumb"
33
35
  require "bugsnag/breadcrumbs/breadcrumbs"
34
36
 
37
+ require "bugsnag/utility/metadata_delegate"
38
+
35
39
  # rubocop:todo Metrics/ModuleLength
36
40
  module Bugsnag
37
41
  LOCK = Mutex.new
@@ -79,7 +83,12 @@ module Bugsnag
79
83
  report = Report.new(exception, configuration, auto_notify)
80
84
 
81
85
  # If this is an auto_notify we yield the block before the any middleware is run
82
- yield(report) if block_given? && auto_notify
86
+ begin
87
+ yield(report) if block_given? && auto_notify
88
+ rescue StandardError => e
89
+ configuration.warn("Error in internal notify block: #{e}")
90
+ configuration.warn("Error in internal notify block stacktrace: #{e.backtrace.inspect}")
91
+ end
83
92
 
84
93
  if report.ignore?
85
94
  configuration.debug("Not notifying #{report.exceptions.last[:errorClass]} due to ignore being signified in auto_notify block")
@@ -106,7 +115,12 @@ module Bugsnag
106
115
 
107
116
  # If this is not an auto_notify then the block was provided by the user. This should be the last
108
117
  # block that is run as it is the users "most specific" block.
109
- yield(report) if block_given? && !auto_notify
118
+ begin
119
+ yield(report) if block_given? && !auto_notify
120
+ rescue StandardError => e
121
+ configuration.warn("Error in notify block: #{e}")
122
+ configuration.warn("Error in notify block stacktrace: #{e.backtrace.inspect}")
123
+ end
110
124
 
111
125
  if report.ignore?
112
126
  configuration.debug("Not notifying #{report.exceptions.last[:errorClass]} due to ignore being signified in user provided block")
@@ -227,7 +241,7 @@ module Bugsnag
227
241
  #
228
242
  # @param name [String] the main breadcrumb name/message
229
243
  # @param meta_data [Hash] String, Numeric, or Boolean meta data to attach
230
- # @param type [String] the breadcrumb type, from Bugsnag::Breadcrumbs::VALID_BREADCRUMB_TYPES
244
+ # @param type [String] the breadcrumb type, see {Bugsnag::BreadcrumbType}
231
245
  # @param auto [Symbol] set to :auto if the breadcrumb is automatically created
232
246
  # @return [void]
233
247
  def leave_breadcrumb(name, meta_data={}, type=Bugsnag::Breadcrumbs::MANUAL_BREADCRUMB_TYPE, auto=:manual)
@@ -240,7 +254,7 @@ module Bugsnag
240
254
  # Skip if it's already invalid
241
255
  return if breadcrumb.ignore?
242
256
 
243
- # Run callbacks
257
+ # Run before_breadcrumb_callbacks
244
258
  configuration.before_breadcrumb_callbacks.each do |c|
245
259
  c.arity > 0 ? c.call(breadcrumb) : c.call
246
260
  break if breadcrumb.ignore?
@@ -249,6 +263,10 @@ module Bugsnag
249
263
  # Return early if ignored
250
264
  return if breadcrumb.ignore?
251
265
 
266
+ # Run on_breadcrumb callbacks
267
+ configuration.on_breadcrumb_callbacks.call(breadcrumb)
268
+ return if breadcrumb.ignore?
269
+
252
270
  # Validate again in case of callback alteration
253
271
  validator.validate(breadcrumb)
254
272
 
@@ -265,7 +283,7 @@ module Bugsnag
265
283
  # Returning false from an on_error callback will cause the error to be ignored
266
284
  # and will prevent any remaining callbacks from being called
267
285
  #
268
- # @param callback [Proc]
286
+ # @param callback [Proc, Method, #call]
269
287
  # @return [void]
270
288
  def add_on_error(callback)
271
289
  configuration.add_on_error(callback)
@@ -283,6 +301,44 @@ module Bugsnag
283
301
  configuration.remove_on_error(callback)
284
302
  end
285
303
 
304
+ ##
305
+ # Add the given callback to the list of on_breadcrumb callbacks
306
+ #
307
+ # The on_breadcrumb callbacks will be called when a breadcrumb is left and
308
+ # are passed the {Breadcrumbs::Breadcrumb Breadcrumb} object
309
+ #
310
+ # Returning false from an on_breadcrumb callback will cause the breadcrumb
311
+ # to be ignored and will prevent any remaining callbacks from being called
312
+ #
313
+ # @param callback [Proc, Method, #call]
314
+ # @return [void]
315
+ def add_on_breadcrumb(callback)
316
+ configuration.add_on_breadcrumb(callback)
317
+ end
318
+
319
+ ##
320
+ # Remove the given callback from the list of on_breadcrumb callbacks
321
+ #
322
+ # Note that this must be the same instance that was passed to
323
+ # {add_on_breadcrumb}, otherwise it will not be removed
324
+ #
325
+ # @param callback [Proc, Method, #call]
326
+ # @return [void]
327
+ def remove_on_breadcrumb(callback)
328
+ configuration.remove_on_breadcrumb(callback)
329
+ end
330
+
331
+ ##
332
+ # Returns the current list of breadcrumbs
333
+ #
334
+ # This is a per-thread circular buffer, containing at most 'max_breadcrumbs'
335
+ # breadcrumbs
336
+ #
337
+ # @return [Bugsnag::Utility::CircularBuffer]
338
+ def breadcrumbs
339
+ configuration.breadcrumbs
340
+ end
341
+
286
342
  ##
287
343
  # Returns the client's Cleaner object, or creates one if not yet created.
288
344
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugsnag
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.19.0
4
+ version: 6.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-06 00:00:00.000000000 Z
11
+ date: 2021-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -40,8 +40,10 @@ files:
40
40
  - VERSION
41
41
  - bugsnag.gemspec
42
42
  - lib/bugsnag.rb
43
+ - lib/bugsnag/breadcrumb_type.rb
43
44
  - lib/bugsnag/breadcrumbs/breadcrumb.rb
44
45
  - lib/bugsnag/breadcrumbs/breadcrumbs.rb
46
+ - lib/bugsnag/breadcrumbs/on_breadcrumb_callback_list.rb
45
47
  - lib/bugsnag/breadcrumbs/validator.rb
46
48
  - lib/bugsnag/cleaner.rb
47
49
  - lib/bugsnag/code_extractor.rb
@@ -49,12 +51,15 @@ files:
49
51
  - lib/bugsnag/delivery.rb
50
52
  - lib/bugsnag/delivery/synchronous.rb
51
53
  - lib/bugsnag/delivery/thread_queue.rb
54
+ - lib/bugsnag/error.rb
55
+ - lib/bugsnag/event.rb
52
56
  - lib/bugsnag/helpers.rb
53
57
  - lib/bugsnag/integrations/delayed_job.rb
54
58
  - lib/bugsnag/integrations/mailman.rb
55
59
  - lib/bugsnag/integrations/mongo.rb
56
60
  - lib/bugsnag/integrations/que.rb
57
61
  - lib/bugsnag/integrations/rack.rb
62
+ - lib/bugsnag/integrations/rails/active_job.rb
58
63
  - lib/bugsnag/integrations/rails/active_record_rescue.rb
59
64
  - lib/bugsnag/integrations/rails/controller_methods.rb
60
65
  - lib/bugsnag/integrations/rails/rails_breadcrumbs.rb
@@ -64,6 +69,7 @@ files:
64
69
  - lib/bugsnag/integrations/shoryuken.rb
65
70
  - lib/bugsnag/integrations/sidekiq.rb
66
71
  - lib/bugsnag/meta_data.rb
72
+ - lib/bugsnag/middleware/active_job.rb
67
73
  - lib/bugsnag/middleware/breadcrumbs.rb
68
74
  - lib/bugsnag/middleware/callbacks.rb
69
75
  - lib/bugsnag/middleware/classify_error.rb
@@ -88,6 +94,7 @@ files:
88
94
  - lib/bugsnag/tasks.rb
89
95
  - lib/bugsnag/tasks/bugsnag.rake
90
96
  - lib/bugsnag/utility/circular_buffer.rb
97
+ - lib/bugsnag/utility/metadata_delegate.rb
91
98
  - lib/bugsnag/version.rb
92
99
  - lib/generators/bugsnag/bugsnag_generator.rb
93
100
  homepage: https://github.com/bugsnag/bugsnag-ruby
@@ -109,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
116
  - !ruby/object:Gem::Version
110
117
  version: '0'
111
118
  requirements: []
112
- rubygems_version: 3.2.0
119
+ rubygems_version: 3.2.11
113
120
  signing_key:
114
121
  specification_version: 4
115
122
  summary: Ruby notifier for bugsnag.com