bugsnag 5.0.1 → 5.1.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: 23cafc9f023e6c956fe901ba153135c7c6443247
4
- data.tar.gz: 0f46e18ea6d4e69601e3c68038dd04be2b1316c9
3
+ metadata.gz: 3f0f6a45c465fe50809b882075249dcfcc1ef50b
4
+ data.tar.gz: be4d6495a21ed0d396e8c225520d3f99c3809796
5
5
  SHA512:
6
- metadata.gz: 87006c230acdf61331523fda1d3245e5a527c03475d723e46748843a2f3992431514d426bed9e03364fc8a1711dcf8149fd95457630768943d128541157216eb
7
- data.tar.gz: 5808f705aac760af3d681caffe5b4ff5a34b8f870ef3069a2374f280fe0df285f4b737fe95ebfb5d435db82fe006ffef60f1dde6555fe564e3a06f6fe0bf069e
6
+ metadata.gz: 922f1851260cfe26d8f650eaeb2363a79a6f8d23c4eb5967cf3d9cbcf4343eab4649bc4bb61e1b96b93943396644820f31af8b1c0ade13e8507aa02693151f0f
7
+ data.tar.gz: 3950c972f77ccd51637f3f167207cc4b2b17be9db6ff4165b88ba8d1bae5416a0313e48923d84c021038983bfa8caa9d20b54e163653737113e37fdf413d9ca9
@@ -10,5 +10,4 @@ rvm:
10
10
  - jruby-19mode
11
11
 
12
12
  before_install:
13
- - gem update --system 2.1.11
14
13
  - gem --version
@@ -1,6 +1,22 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## 5.1.0 (23 January 2017)
5
+
6
+ ### Bug fixes
7
+
8
+ * Fix behavior to not override Rails 5 `belongs_to` association
9
+ | [#314](https://github.com/bugsnag/bugsnag-ruby/pull/314)
10
+
11
+ ### Enhancements
12
+
13
+ * Add Clearance support
14
+ | [Jonathan Rochkind](https://github.com/jrochkind)
15
+ | [#313](https://github.com/bugsnag/bugsnag-ruby/pull/313)
16
+ * Add Shoruken support
17
+ | [Nigel Ramsay](https://github.com/nigelramsay)
18
+ | [#324](https://github.com/bugsnag/bugsnag-ruby/pull/324)
19
+
4
20
  ## 5.0.1 (7 September 2016)
5
21
 
6
22
  ### Bug fixes
@@ -30,7 +30,7 @@ If you're a member of the core team, follow these instructions for releasing bug
30
30
  * Commit/push your changes
31
31
 
32
32
  ```
33
- git commit -am v2.X.X
33
+ git commit -am v5.X.X
34
34
  git push origin master
35
35
  ```
36
36
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.0.1
1
+ 5.1.0
@@ -24,5 +24,5 @@ Gem::Specification.new do |s|
24
24
  s.add_development_dependency 'rdoc'
25
25
  s.add_development_dependency 'pry'
26
26
  s.add_development_dependency 'addressable', '~> 2.3.8'
27
- s.add_development_dependency 'webmock'
27
+ s.add_development_dependency 'webmock', '2.1.0'
28
28
  end
@@ -18,6 +18,7 @@ require "bugsnag/railtie" if defined?(Rails::Railtie)
18
18
 
19
19
  require "bugsnag/middleware/rack_request"
20
20
  require "bugsnag/middleware/warden_user"
21
+ require "bugsnag/middleware/clearance_user"
21
22
  require "bugsnag/middleware/callbacks"
22
23
  require "bugsnag/middleware/rails3_request"
23
24
  require "bugsnag/middleware/sidekiq"
@@ -130,7 +131,7 @@ module Bugsnag
130
131
  end
131
132
  end
132
133
 
133
- [:resque, :sidekiq, :mailman, :delayed_job].each do |integration|
134
+ [:resque, :sidekiq, :mailman, :delayed_job, :shoryuken].each do |integration|
134
135
  begin
135
136
  require "bugsnag/#{integration}"
136
137
  rescue LoadError
@@ -37,7 +37,7 @@ module Bugsnag
37
37
  end
38
38
  clean_hash
39
39
  when Array, Set
40
- obj.map { |el| traverse_object(el, seen, scope) }.compact
40
+ obj.map { |el| traverse_object(el, seen, scope) }
41
41
  when Numeric, TrueClass, FalseClass
42
42
  obj
43
43
  when String
@@ -13,6 +13,7 @@ module Bugsnag
13
13
  # Trim the size of value if the serialized JSON value is longer than is
14
14
  # accepted by Bugsnag
15
15
  def self.trim_if_needed(value)
16
+ value = "" if value.nil?
16
17
  sanitized_value = Bugsnag::Cleaner.clean_object_encoding(value)
17
18
  return sanitized_value unless payload_too_long?(sanitized_value)
18
19
  reduced_value = trim_strings_in_value(sanitized_value)
@@ -67,7 +68,11 @@ module Bugsnag
67
68
  # Validate that the serialized JSON string value is below maximum payload
68
69
  # length
69
70
  def self.payload_too_long?(value)
70
- ::JSON.dump(value).length >= MAX_PAYLOAD_LENGTH
71
+ if value.is_a?(String)
72
+ value.length >= MAX_PAYLOAD_LENGTH
73
+ else
74
+ ::JSON.dump(value).length >= MAX_PAYLOAD_LENGTH
75
+ end
71
76
  end
72
77
 
73
78
  def self.trim_strings_in_hash(hash)
@@ -0,0 +1,31 @@
1
+ module Bugsnag::Middleware
2
+ class ClearanceUser
3
+ COMMON_USER_FIELDS = [:email, :name, :first_name, :last_name, :created_at, :id]
4
+
5
+ def initialize(bugsnag)
6
+ @bugsnag = bugsnag
7
+ end
8
+
9
+ def call(notification)
10
+ if notification.request_data[:rack_env] &&
11
+ notification.request_data[:rack_env][:clearance] &&
12
+ notification.request_data[:rack_env][:clearance].signed_in? &&
13
+ notification.request_data[:rack_env][:clearance].current_user
14
+
15
+ # Extract useful user information
16
+ user = {}
17
+ user_object = notification.request_data[:rack_env][:clearance].current_user
18
+ if user_object
19
+ # Build the bugsnag user info from the current user record
20
+ COMMON_USER_FIELDS.each do |field|
21
+ user[field] = user_object.send(field) if user_object.respond_to?(field)
22
+ end
23
+ end
24
+
25
+ notification.user = user unless user.empty?
26
+ end
27
+
28
+ @bugsnag.call(notification)
29
+ end
30
+ end
31
+ end
@@ -20,6 +20,7 @@ module Bugsnag
20
20
  # Hook up rack-based notification middlewares
21
21
  config.middleware.insert_before([Bugsnag::Middleware::Rails3Request,Bugsnag::Middleware::Callbacks], Bugsnag::Middleware::RackRequest) if defined?(::Rack)
22
22
  config.middleware.insert_before(Bugsnag::Middleware::Callbacks, Bugsnag::Middleware::WardenUser) if defined?(Warden)
23
+ config.middleware.insert_before(Bugsnag::Middleware::Callbacks, Bugsnag::Middleware::ClearanceUser) if defined?(Clearance)
23
24
 
24
25
  Bugsnag.configuration.app_type ||= "rack"
25
26
  end
@@ -31,7 +31,7 @@ module Bugsnag
31
31
 
32
32
  # Auto-load configuration settings from config/bugsnag.yml if it exists
33
33
  config_file = File.join(rails_root, "config", "bugsnag.yml")
34
- config = YAML.load_file(config_file) if File.exists?(config_file)
34
+ config = YAML.load_file(config_file) if File.exist?(config_file)
35
35
  Bugsnag.configure(config[rails_env] ? config[rails_env] : config) if config
36
36
 
37
37
  Bugsnag.configuration.app_type = "rails"
@@ -34,7 +34,7 @@ module Bugsnag
34
34
 
35
35
  # Auto-load configuration settings from config/bugsnag.yml if it exists
36
36
  config_file = ::Rails.root.join("config", "bugsnag.yml")
37
- config = YAML.load_file(config_file) if File.exists?(config_file)
37
+ config = YAML.load_file(config_file) if File.exist?(config_file)
38
38
  Bugsnag.configure(config[::Rails.env] ? config[::Rails.env] : config) if config
39
39
 
40
40
  if defined?(::ActionController::Base)
@@ -44,9 +44,9 @@ module Bugsnag
44
44
  if defined?(ActionController::API)
45
45
  ActionController::API.send(:include, Bugsnag::Rails::ControllerMethods)
46
46
  end
47
- if defined?(ActiveRecord::Base)
47
+ ActiveSupport.on_load(:active_record) do
48
48
  require "bugsnag/rails/active_record_rescue"
49
- ActiveRecord::Base.send(:include, Bugsnag::Rails::ActiveRecordRescue)
49
+ include Bugsnag::Rails::ActiveRecordRescue
50
50
  end
51
51
 
52
52
  Bugsnag.configuration.app_type = "rails"
@@ -0,0 +1,34 @@
1
+ require 'shoryuken'
2
+
3
+ module Bugsnag
4
+ class Shoryuken
5
+ def initialize
6
+ Bugsnag.configuration.app_type = "shoryuken"
7
+ Bugsnag.configuration.delivery_method = :synchronous
8
+ end
9
+
10
+ def call(_, queue, _, body)
11
+ begin
12
+ Bugsnag.before_notify_callbacks << lambda {|notification|
13
+ notification.add_tab(:shoryuken, {
14
+ queue: queue,
15
+ body: body
16
+ })
17
+ }
18
+
19
+ yield
20
+ rescue Exception => ex
21
+ Bugsnag.auto_notify(ex) unless [Interrupt, SystemExit, SignalException].include?(ex.class)
22
+ raise
23
+ ensure
24
+ Bugsnag.clear_request_data
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ ::Shoryuken.configure_server do |config|
31
+ config.server_middleware do |chain|
32
+ chain.add ::Bugsnag::Shoryuken
33
+ end
34
+ end
@@ -19,6 +19,11 @@ describe Bugsnag::Cleaner do
19
19
  expect(subject.clean_object(a)).to eq(["[RECURSION]", "hello"])
20
20
  end
21
21
 
22
+ it "doesn't remove nil from arrays" do
23
+ a = ["b", nil, "c"]
24
+ expect(subject.clean_object(a)).to eq(["b", nil, "c"])
25
+ end
26
+
22
27
  it "allows multiple copies of the same string" do
23
28
  a = {:name => "bugsnag"}
24
29
  a[:second] = a[:name]
@@ -62,7 +62,7 @@ describe Bugsnag::Helpers do
62
62
  context "value is a String" do
63
63
  it "trims length" do
64
64
  value = Bugsnag::Helpers.trim_if_needed(SecureRandom.hex(500_000/2))
65
- expect(::JSON.dump(value.length).length).to be < Bugsnag::Helpers::MAX_STRING_LENGTH
65
+ expect(value.length).to be <= Bugsnag::Helpers::MAX_STRING_LENGTH
66
66
  end
67
67
  end
68
68
 
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: 5.0.1
4
+ version: 5.1.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: 2016-09-07 00:00:00.000000000 Z
11
+ date: 2017-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: webmock
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '='
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 2.1.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 2.1.0
97
97
  description: Ruby notifier for bugsnag.com
98
98
  email: james@bugsnag.com
99
99
  executables: []
@@ -130,6 +130,7 @@ files:
130
130
  - lib/bugsnag/mailman.rb
131
131
  - lib/bugsnag/meta_data.rb
132
132
  - lib/bugsnag/middleware/callbacks.rb
133
+ - lib/bugsnag/middleware/clearance_user.rb
133
134
  - lib/bugsnag/middleware/mailman.rb
134
135
  - lib/bugsnag/middleware/rack_request.rb
135
136
  - lib/bugsnag/middleware/rails2_request.rb
@@ -147,6 +148,7 @@ files:
147
148
  - lib/bugsnag/railtie.rb
148
149
  - lib/bugsnag/rake.rb
149
150
  - lib/bugsnag/resque.rb
151
+ - lib/bugsnag/shoryuken.rb
150
152
  - lib/bugsnag/sidekiq.rb
151
153
  - lib/bugsnag/tasks.rb
152
154
  - lib/bugsnag/tasks/bugsnag.cap
@@ -188,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
190
  version: '0'
189
191
  requirements: []
190
192
  rubyforge_project:
191
- rubygems_version: 2.4.5
193
+ rubygems_version: 2.2.2
192
194
  signing_key:
193
195
  specification_version: 4
194
196
  summary: Ruby notifier for bugsnag.com