bugsnag 1.6.5 → 1.7.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: 717d9f1b2304beb17e79f70136524fe05f02e836
4
- data.tar.gz: ba4b7b6fe97c78d6ca8f7f627e6c696f34516451
3
+ metadata.gz: ea271d0d36a02d47b465c7a9fccd390cec2f447a
4
+ data.tar.gz: aa1f7cacb476081242d3969624ac9b52dcf613f1
5
5
  SHA512:
6
- metadata.gz: 4db0b788c0c54085a2f5d45e221ed4daa33169d1846a75b51319ba416de3eef0e6e6ccbb267ef816077786028f064557204bd7025a53fb1a3dff5ffb41cd50f9
7
- data.tar.gz: 1c335846a6340ff3f2c9eec2797d4a0288f3b77073221532dd6bcb5ae001af956eac3e4a7d1c511df7f0c3b2e6781e642c7da21d89c8dd129d7c46d928e0a2d3
6
+ metadata.gz: 920c18c4fa6679f2a0b7f9609ca542100734fd113fb4fc624d7960c32cf029d6f2b1950fab1ee0ae5bc55cbc5be7b4fc4ed05cccf20993ac06031ed47122e25a
7
+ data.tar.gz: 89acbdf699198a962b65c51e6935459a7310ce30581ee7f35e2963ccd799b03615b986505d768a4a6144a7b817fe3f700541250695f00bb5f77c7ad86a46c457
@@ -1,11 +1,10 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
+ - 2.0.0
4
5
  - 1.9.3
5
6
  - jruby-18mode
6
7
  - jruby-19mode
7
- - rbx-18mode
8
- - rbx-19mode
9
8
  - 1.8.7
10
9
 
11
10
  notifications:
@@ -1,6 +1,12 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ 1.7.0
5
+ -----
6
+ - Allow users to configure app type
7
+ - Send severity of error to bugsnag
8
+ - Allo users to configure users in a structured way for search etc.
9
+
4
10
  1.6.5
5
11
  -----
6
12
  - Send hostname to Bugsnag
data/README.md CHANGED
@@ -87,10 +87,18 @@ class MyController < ApplicationController
87
87
 
88
88
  private
89
89
  def add_user_info_to_bugsnag(notif)
90
+ # Set the user that this bug affected
91
+ # Email, name and id are searchable on bugsnag.com
92
+ notif.user = {
93
+ email: current_user.email,
94
+ name: current_user.name,
95
+ id: current_user.id
96
+ }
97
+
90
98
  # Add some app-specific data which will be displayed on a custom
91
- # "User Info" tab on each error page on bugsnag.com
92
- notif.add_tab(:user_info, {
93
- name: current_user.name
99
+ # "Diagnostics" tab on each error page on bugsnag.com
100
+ notif.add_tab(:diagnostics, {
101
+ product: current_product.name
94
102
  })
95
103
  end
96
104
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.5
1
+ 1.7.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "bugsnag"
8
- s.version = "1.6.5"
8
+ s.version = "1.7.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 = "2013-12-14"
12
+ s.date = "2013-12-17"
13
13
  s.description = "Ruby notifier for bugsnag.com"
14
14
  s.email = "james@bugsnag.com"
15
15
  s.extra_rdoc_files = [
@@ -61,6 +61,8 @@ module Bugsnag
61
61
  # rescuers, unless auto notification is disabled, or we should ignore this
62
62
  # error class
63
63
  def auto_notify(exception, overrides=nil, request_data=nil)
64
+ overrides ||= {}
65
+ overrides.merge!({:severity => "fatal"})
64
66
  notify_or_ignore(exception, overrides, request_data) if configuration.auto_notify
65
67
  end
66
68
 
@@ -12,6 +12,7 @@ module Bugsnag
12
12
  attr_accessor :use_ssl
13
13
  attr_accessor :project_root
14
14
  attr_accessor :app_version
15
+ attr_accessor :app_type
15
16
  attr_accessor :params_filters
16
17
  attr_accessor :ignore_classes
17
18
  attr_accessor :ignore_user_agents
@@ -1,7 +1,7 @@
1
1
  module Bugsnag::Middleware
2
2
  class WardenUser
3
3
  SCOPE_PATTERN = /^warden\.user\.([^.]+)\.key$/
4
- COMMON_USER_FIELDS = [:email, :name, :first_name, :last_name, :created_at]
4
+ COMMON_USER_FIELDS = [:email, :name, :first_name, :last_name, :created_at, :id]
5
5
 
6
6
  def initialize(bugsnag)
7
7
  @bugsnag = bugsnag
@@ -18,33 +18,18 @@ module Bugsnag::Middleware
18
18
  # Pick the best scope for unique id (the default is "user")
19
19
  best_scope = warden_scopes.include?("user") ? "user" : warden_scopes.first
20
20
 
21
- # Set the user_id
22
- if best_scope
23
- scope_key = "warden.user.#{best_scope}.key"
24
- scope = session[scope_key]
25
- if scope.is_a? Array
26
- user_ids = scope.detect {|el| el.is_a? Array}
27
- if user_ids
28
- user_id = user_ids.first
29
- notification.user_id = user_id unless user_id.nil?
30
- end
31
- end
32
- end
33
-
34
21
  # Extract useful user information
35
- warden_tab = {}
36
- warden_scopes.each do |scope|
37
- user_object = env["warden"].user({:scope => scope, :run_callbacks => false}) rescue nil
38
- if user_object
39
- # Build the user info for this scope
40
- scope_hash = warden_tab["Warden #{scope.capitalize}"] = {}
41
- COMMON_USER_FIELDS.each do |field|
42
- scope_hash[field] = user_object.send(field) if user_object.respond_to?(field)
43
- end
22
+ user = {}
23
+ user_object = env["warden"].user({:scope => best_scope, :run_callbacks => false}) rescue nil
24
+ if user_object
25
+ # Build the user info for this scope
26
+ COMMON_USER_FIELDS.each do |field|
27
+ user[field] = user_object.send(field) if user_object.respond_to?(field)
44
28
  end
45
29
  end
46
30
 
47
- notification.add_tab(:user, warden_tab) unless warden_tab.empty?
31
+ # We merge the first warden scope down, so that it is the main "user" for the request
32
+ notification.user = user unless user.empty?
48
33
  end
49
34
  end
50
35
 
@@ -15,12 +15,14 @@ module Bugsnag
15
15
 
16
16
  MAX_EXCEPTIONS_TO_UNWRAP = 5
17
17
 
18
+ SUPPORTED_SEVERITIES = ["fatal", "error", "warning", "info"]
19
+
18
20
  # HTTParty settings
19
21
  headers "Content-Type" => "application/json"
20
22
  default_timeout 5
21
23
 
22
24
  attr_accessor :context
23
- attr_accessor :user_id
25
+ attr_accessor :user
24
26
  attr_accessor :configuration
25
27
 
26
28
  class << self
@@ -52,6 +54,10 @@ module Bugsnag
52
54
  @overrides = Bugsnag::Helpers.flatten_meta_data(overrides) || {}
53
55
  @request_data = request_data
54
56
  @meta_data = {}
57
+ @user = {}
58
+
59
+ self.severity = @overrides[:severity]
60
+ @overrides.delete :severity
55
61
 
56
62
  # Unwrap exceptions
57
63
  @exceptions = []
@@ -110,6 +116,26 @@ module Bugsnag
110
116
  @meta_data.delete(name.to_sym)
111
117
  end
112
118
 
119
+ def user_id=(user_id)
120
+ @user[:id] = user_id
121
+ end
122
+
123
+ def user_id
124
+ @user[:id]
125
+ end
126
+
127
+ def user=(user = {})
128
+ @user.merge!(user).delete_if{|k,v| v == nil}
129
+ end
130
+
131
+ def severity=(severity)
132
+ @severity = severity if SUPPORTED_SEVERITIES.include?(severity)
133
+ end
134
+
135
+ def severity
136
+ @severity || "error"
137
+ end
138
+
113
139
  # Deliver this notification to bugsnag.com Also runs through the middleware as required.
114
140
  def deliver
115
141
  return unless @configuration.should_notify?
@@ -142,7 +168,7 @@ module Bugsnag
142
168
  end
143
169
  end
144
170
 
145
- [:user_id, :context].each do |symbol|
171
+ [:user_id, :context, :user].each do |symbol|
146
172
  if @overrides[symbol]
147
173
  self.send("#{symbol}=", @overrides[symbol])
148
174
  @overrides.delete symbol
@@ -155,11 +181,15 @@ module Bugsnag
155
181
 
156
182
  # Build the payload's exception event
157
183
  payload_event = {
158
- :releaseStage => @configuration.release_stage,
159
- :appVersion => @configuration.app_version,
184
+ :app => {
185
+ :version => @configuration.app_version,
186
+ :releaseStage => @configuration.release_stage,
187
+ :type => @configuration.app_type
188
+ },
160
189
  :context => self.context,
161
- :userId => self.user_id,
190
+ :user => @user,
162
191
  :exceptions => exception_list,
192
+ :severity => self.severity,
163
193
  :metaData => Bugsnag::Helpers.cleanup_obj(generate_meta_data(@exceptions, @overrides), @configuration.params_filters)
164
194
  }.reject {|k,v| v.nil? }
165
195
 
@@ -41,6 +41,26 @@ describe Bugsnag::MiddlewareStack do
41
41
  Bugsnag.notify(BugsnagTestException.new("It crashed"))
42
42
  callback_run_count.should be == 1
43
43
  end
44
+
45
+ it "should run before_bugsnag_notify callbacks, setting the user" do
46
+ Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
47
+ event = get_event_from_payload(payload)
48
+ event[:user].should_not be_nil
49
+ event[:user][:id].should be == "here"
50
+ event[:user][:email].should be == "also here"
51
+ event[:user][:name].should be == "also here too"
52
+ event[:user][:random_key].should be == "also here too too"
53
+ end
54
+
55
+ callback_run_count = 0
56
+ Bugsnag.before_notify_callbacks << lambda {|notif|
57
+ notif.user = {:id => "here", :email => "also here", :name => "also here too", :random_key => "also here too too"}
58
+ callback_run_count += 1
59
+ }
60
+
61
+ Bugsnag.notify(BugsnagTestException.new("It crashed"))
62
+ callback_run_count.should be == 1
63
+ end
44
64
 
45
65
  it "overrides should override data set in before_notify" do
46
66
  Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
@@ -144,7 +144,7 @@ describe Bugsnag::Notification do
144
144
  it "should accept user_id from an exception that mixes in Bugsnag::MetaData" do
145
145
  Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
146
146
  event = get_event_from_payload(payload)
147
- event[:userId].should be == "exception_user_id"
147
+ event[:user][:id].should be == "exception_user_id"
148
148
  end
149
149
 
150
150
  exception = BugsnagTestExceptionWithMetaData.new("It crashed")
@@ -156,7 +156,7 @@ describe Bugsnag::Notification do
156
156
  it "should accept user_id from an exception that mixes in Bugsnag::MetaData, but override using the overrides" do
157
157
  Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
158
158
  event = get_event_from_payload(payload)
159
- event[:userId].should be == "override_user_id"
159
+ event[:user][:id].should be == "override_user_id"
160
160
  end
161
161
 
162
162
  exception = BugsnagTestExceptionWithMetaData.new("It crashed")
@@ -224,6 +224,46 @@ describe Bugsnag::Notification do
224
224
  })
225
225
  end
226
226
 
227
+ it "should accept a severity in overrides" do
228
+ Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
229
+ event = get_event_from_payload(payload)
230
+ event[:severity].should be == "info"
231
+ end
232
+
233
+ Bugsnag.notify(BugsnagTestException.new("It crashed"), {
234
+ :severity => "info"
235
+ })
236
+ end
237
+
238
+ it "should default to error severity" do
239
+ Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
240
+ event = get_event_from_payload(payload)
241
+ event[:severity].should be == "error"
242
+ end
243
+
244
+ Bugsnag.notify(BugsnagTestException.new("It crashed"))
245
+ end
246
+
247
+ it "should not accept a bad severity in overrides" do
248
+ Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
249
+ event = get_event_from_payload(payload)
250
+ event[:severity].should be == "error"
251
+ end
252
+
253
+ Bugsnag.notify(BugsnagTestException.new("It crashed"), {
254
+ :severity => "infffo"
255
+ })
256
+ end
257
+
258
+ it "should autonotify fatal errors" do
259
+ Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
260
+ event = get_event_from_payload(payload)
261
+ event[:severity].should be == "fatal"
262
+ end
263
+
264
+ Bugsnag.auto_notify(BugsnagTestException.new("It crashed"))
265
+ end
266
+
227
267
  it "should accept a context in overrides" do
228
268
  Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
229
269
  event = get_event_from_payload(payload)
@@ -238,7 +278,7 @@ describe Bugsnag::Notification do
238
278
  it "should accept a user_id in overrides" do
239
279
  Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
240
280
  event = get_event_from_payload(payload)
241
- event[:userId].should be == "test_user"
281
+ event[:user][:id].should be == "test_user"
242
282
  end
243
283
 
244
284
  Bugsnag.notify(BugsnagTestException.new("It crashed"), {
@@ -263,7 +303,7 @@ describe Bugsnag::Notification do
263
303
 
264
304
  Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
265
305
  event = get_event_from_payload(payload)
266
- event[:releaseStage].should be == "production"
306
+ event[:app][:releaseStage].should be == "production"
267
307
  end
268
308
 
269
309
  Bugsnag.auto_notify(BugsnagTestException.new("It crashed"))
@@ -347,7 +387,7 @@ describe Bugsnag::Notification do
347
387
  it "should add app_version to the payload if it is set" do
348
388
  Bugsnag::Notification.should_receive(:deliver_exception_payload) do |endpoint, payload|
349
389
  event = get_event_from_payload(payload)
350
- event[:appVersion].should be == "1.1.1"
390
+ event[:app][:version].should be == "1.1.1"
351
391
  end
352
392
 
353
393
  Bugsnag.configuration.app_version = "1.1.1"
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: 1.6.5
4
+ version: 1.7.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: 2013-12-14 00:00:00.000000000 Z
11
+ date: 2013-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json