bugsnag 2.4.1 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0293abdf77561e74847883fc613ca6dc008cebab
4
- data.tar.gz: 619d14f7854cfc80f580d3d02737f1df3e67b661
3
+ metadata.gz: 3eb0d383ce8b03fd84cafce08eb5e087a6163fe7
4
+ data.tar.gz: 09433fa6a18a8f972a6fc8fbd27327e9820279b3
5
5
  SHA512:
6
- metadata.gz: cf05cd8421771e2af00139da267a9bdb3f29104d1cc9b20974db805677582676289e5f2ffaf8248ca4d9b660aa879b0099a85fbdc1e0709859d26b6da170f0b3
7
- data.tar.gz: f3b7696c70a8eedf524ab3a8bfdac71a0e6dfd8f3c823270a51f7a3f1a20c46321cfdf4e03a3490193e8ad7e9c3b0071f81e2e78f1d04208eda214945a65c1d3
6
+ metadata.gz: 7b6ce5c4483f4ee3d40b55a624d6f82762e71d42328ee89158cdabdc33addc3b68e935807a3e3194c5bb4161e28c184a9e0a7bd93151b4054333e08231c2cc37
7
+ data.tar.gz: fbe2f141ffd43808aedf115121774fbdf2a465bea5be05a9bea456705bc14d1c155665998ae6d3dfb7b327b411f5fe902eafd67b82449b2865ad92710d109190
@@ -1,6 +1,11 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ 2.5.0
5
+ -----
6
+ - Allow access to the metadata object in before bugsnag notify callbacks
7
+ - Dont send the rack env by default
8
+
4
9
  2.4.1
5
10
  ------
6
11
 
data/README.md CHANGED
@@ -83,9 +83,7 @@ exceptions, to help debug problems.
83
83
 
84
84
  ### Rails Apps
85
85
 
86
- In any rails controller you can define a `before_bugsnag_notify` callback,
87
- which allows you to add this additional data by calling `add_tab` on the
88
- exception notification object.
86
+ In any rails controller you can define a `before_bugsnag_notify` callback, which allows you to add this additional data by calling `add_tab` on the exception notification object. Please see the [Notification Object](#notification-object) for details on the notification parameter.
89
87
 
90
88
  ```ruby
91
89
  class MyController < ApplicationController
@@ -115,10 +113,7 @@ end
115
113
 
116
114
  ### Other Ruby Apps
117
115
 
118
- In other ruby apps, you can provide lambda functions to execute before any
119
- `Bugsnag.notify` calls as follows. Don't forget to clear the callbacks at the
120
- end of each request or session. In Rack applications like Sinatra, however, the
121
- gem will clear the callbacks for you.
116
+ In other ruby apps, you can provide lambda functions to execute before any `Bugsnag.notify` calls as follows. Don't forget to clear the callbacks at the end of each request or session. In Rack applications like Sinatra, this is automatically done for you.
122
117
 
123
118
  ```ruby
124
119
  # Set a before notify callback
@@ -134,6 +129,90 @@ Bugsnag.before_notify_callbacks << lambda {|notif|
134
129
  Bugsnag.before_notify_callbacks.clear
135
130
  ```
136
131
 
132
+ ### Notification Object
133
+
134
+ The notification object is passed to all [before bugsnag notify](#sending-custom-data-with-exceptions) callbacks and is used to manipulate the error report before it is transmitted.
135
+
136
+ #### add_tab
137
+
138
+ Call add_tab on a notification object to add a tab to the error report so that it would appear on your dashboard.
139
+
140
+ ```ruby
141
+ notif.add_tab(:user_info, {
142
+ name: current_user.name
143
+ })
144
+ ```
145
+
146
+ The first parameter is the tab name that will appear in the error report and the second is the key, value list that will be displayed in the tab.
147
+
148
+ #### remove_tab
149
+
150
+ Removes a tab completely from the error report
151
+
152
+ ```ruby
153
+ notif.remove_tab(:request)
154
+ ```
155
+
156
+ #### ignore!
157
+
158
+ Calling ignore! on a notification object will cause the notification to not be sent to bugsnag. This means that you can choose dynamically not to send an error depending on application state or the error itself.
159
+
160
+ ```ruby
161
+ notif.ignore! if foo == 'bar'
162
+ ```
163
+
164
+ #### grouping_hash
165
+
166
+ Sets the grouping hash of the error report. All errors with the same grouping hash are grouped together. This is an advanced usage of the library and mis-using it will cause your errors not to group properly in your dashboard.
167
+
168
+ ```ruby
169
+ notif.grouping_hash = "#{exception.message}#{exception.class}"
170
+ ```
171
+
172
+ #### severity
173
+
174
+ Set the severity of the error. Severity can be `error`, `warning` or `info`.
175
+
176
+ ```ruby
177
+ notif.severity = "error"
178
+ ```
179
+
180
+ #### context
181
+
182
+ Set the context of the error report. This is notionally the location of the error and should be populated automatically. Context is displayed in the dashboard prominently.
183
+
184
+ ```ruby
185
+ notif.context = "billing"
186
+ ```
187
+
188
+ #### user
189
+
190
+ You can set or read the user with the user property of the notification. The user will be a hash of `email`, `id` and `name`.
191
+
192
+ ```ruby
193
+ notif.user = {
194
+ id: current_user.id,
195
+ email: current_user.email,
196
+ name: current_user.name
197
+ }
198
+ ```
199
+
200
+ #### exceptions
201
+
202
+ Allows you to read the exceptions that will be combined into the report.
203
+
204
+ ```ruby
205
+ puts "#{notif.exceptions.first.message} found!"
206
+ ```
207
+
208
+ #### meta_data
209
+
210
+ Provides access to the meta_data in the error report.
211
+
212
+ ```ruby
213
+ notif.ignore! if notif.meta_data[:sidekiq][:retry_count] > 2
214
+ ```
215
+
137
216
  ### Exceptions with Meta Data
138
217
 
139
218
  If you include the `Bugsnag::MetaData` module into your own exceptions, you can
@@ -463,6 +542,16 @@ config.app_type = "resque"
463
542
  This is usually used to represent if you are running in a Rails server, Sidekiq job or
464
543
  Rake task for example. Bugsnag will automatically detect most application types for you.
465
544
 
545
+ ###send_environment
546
+
547
+ Bugsnag can transmit your rack environment to help diagnose issues. This environment
548
+ can sometimes contain private information so Bugsnag does not transmit by default. To
549
+ send your rack environment, set the `send_environment` option to `true`.
550
+
551
+ ```ruby
552
+ config.send_environment = true
553
+ ```
554
+
466
555
  Bugsnag Middleware
467
556
  ------------------
468
557
 
data/Rakefile CHANGED
@@ -24,8 +24,6 @@ end
24
24
  # RSpec tasks
25
25
  require 'rspec/core'
26
26
  require "rspec/core/rake_task"
27
- RSpec::Core::RakeTask.new(:spec) do |spec|
28
- spec.pattern = FileList['spec/**/*_spec.rb']
29
- end
27
+ RSpec::Core::RakeTask.new(:spec)
30
28
 
31
29
  task :default => :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.4.1
1
+ 2.5.0
@@ -10,6 +10,7 @@ module Bugsnag
10
10
  attr_accessor :notify_release_stages
11
11
  attr_accessor :auto_notify
12
12
  attr_accessor :use_ssl
13
+ attr_accessor :send_environment
13
14
  attr_accessor :project_root
14
15
  attr_accessor :app_version
15
16
  attr_accessor :app_type
@@ -53,6 +54,7 @@ module Bugsnag
53
54
  # Set up the defaults
54
55
  self.auto_notify = true
55
56
  self.use_ssl = true
57
+ self.send_environment = false
56
58
  self.params_filters = Set.new(DEFAULT_PARAMS_FILTERS)
57
59
  self.ignore_classes = Set.new(DEFAULT_IGNORE_CLASSES)
58
60
  self.ignore_user_agents = Set.new(DEFAULT_IGNORE_USER_AGENTS)
@@ -36,7 +36,9 @@ module Bugsnag::Middleware
36
36
  })
37
37
 
38
38
  # Add an environment tab
39
- notification.add_tab(:environment, env)
39
+ if notification.configuration.send_environment
40
+ notification.add_tab(:environment, env)
41
+ end
40
42
 
41
43
  # Add a session tab
42
44
  if session
@@ -3,7 +3,7 @@ module Bugsnag::Middleware
3
3
  def initialize(bugsnag)
4
4
  @bugsnag = bugsnag
5
5
  end
6
-
6
+
7
7
  def call(notification)
8
8
  if notification.request_data[:rails2_request]
9
9
  request = notification.request_data[:rails2_request]
@@ -30,7 +30,9 @@ module Bugsnag::Middleware
30
30
  })
31
31
 
32
32
  # Add an environment tab
33
- notification.add_tab(:environment, request.env) if request.env
33
+ if request.env && notification.configuration.send_environment
34
+ notification.add_tab(:environment, request.env)
35
+ end
34
36
 
35
37
  # Add a session tab
36
38
  notification.add_tab(:session, session_data) if session_data
@@ -3,7 +3,7 @@ module Bugsnag::Middleware
3
3
  def initialize(bugsnag)
4
4
  @bugsnag = bugsnag
5
5
  end
6
-
6
+
7
7
  def call(notification)
8
8
  if notification.request_data[:rack_env]
9
9
  env = notification.request_data[:rack_env]
@@ -21,9 +21,11 @@ module Bugsnag::Middleware
21
21
  end
22
22
 
23
23
  # Add the rails version
24
- notification.add_tab(:environment, {
25
- :railsVersion => Rails::VERSION::STRING
26
- })
24
+ if notification.configuration.send_environment
25
+ notification.add_tab(:environment, {
26
+ :railsVersion => Rails::VERSION::STRING
27
+ })
28
+ end
27
29
  end
28
30
 
29
31
  @bugsnag.call(notification)
@@ -31,6 +31,7 @@ module Bugsnag
31
31
  attr_accessor :context
32
32
  attr_accessor :user
33
33
  attr_accessor :configuration
34
+ attr_accessor :meta_data
34
35
 
35
36
  @queue = Bugsnag::Queue.new
36
37
 
@@ -127,4 +127,20 @@ describe Bugsnag::MiddlewareStack do
127
127
  end
128
128
  Bugsnag.notify(BugsnagTestException.new("It crashed"))
129
129
  end
130
+
131
+ it "allows inspection of meta_data before ignoring exception" do
132
+ expect(Bugsnag::Notification).not_to receive(:deliver_exception_payload)
133
+
134
+ # Use before notify callbacks as only the callback based metadata is
135
+ # available to before_notify_callbacks
136
+ Bugsnag.before_notify_callbacks << lambda do |notif|
137
+ notif.add_tab(:sidekiq, {:retry_count => 4})
138
+ end
139
+
140
+ Bugsnag.before_notify_callbacks << lambda do |notif|
141
+ notif.ignore! if notif.meta_data[:sidekiq][:retry_count] > 3
142
+ end
143
+
144
+ Bugsnag.notify(BugsnagTestException.new("It crashed"))
145
+ end
130
146
  end
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: 2.4.1
4
+ version: 2.5.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: 2014-09-02 00:00:00.000000000 Z
11
+ date: 2014-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json