rollbar 2.22.1 → 2.27.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/pull_request_template.md +25 -0
  3. data/.rubocop.yml +136 -0
  4. data/.travis.yml +33 -30
  5. data/Gemfile +2 -0
  6. data/README.md +1 -1
  7. data/data/rollbar.snippet.js +1 -1
  8. data/docs/configuration.md +8 -0
  9. data/gemfiles/rails42.gemfile +4 -0
  10. data/gemfiles/rails50.gemfile +6 -2
  11. data/gemfiles/rails51.gemfile +6 -2
  12. data/gemfiles/rails60.gemfile +1 -1
  13. data/lib/rails/rollbar_runner.rb +3 -1
  14. data/lib/rollbar/capistrano.rb +1 -1
  15. data/lib/rollbar/capistrano_tasks.rb +10 -1
  16. data/lib/rollbar/configuration.rb +28 -6
  17. data/lib/rollbar/delay/girl_friday.rb +3 -7
  18. data/lib/rollbar/delay/resque.rb +2 -3
  19. data/lib/rollbar/delay/sidekiq.rb +2 -4
  20. data/lib/rollbar/delay/sucker_punch.rb +3 -4
  21. data/lib/rollbar/delay/thread.rb +14 -0
  22. data/lib/rollbar/deploy.rb +2 -0
  23. data/lib/rollbar/encoding/encoder.rb +10 -3
  24. data/lib/rollbar/item/backtrace.rb +12 -2
  25. data/lib/rollbar/item/frame.rb +2 -0
  26. data/lib/rollbar/item/locals.rb +45 -1
  27. data/lib/rollbar/item.rb +22 -14
  28. data/lib/rollbar/json.rb +1 -0
  29. data/lib/rollbar/middleware/js.rb +13 -3
  30. data/lib/rollbar/notifier.rb +154 -61
  31. data/lib/rollbar/plugins/active_job.rb +6 -2
  32. data/lib/rollbar/plugins/delayed_job/plugin.rb +11 -1
  33. data/lib/rollbar/plugins/error_context.rb +11 -0
  34. data/lib/rollbar/rake_tasks.rb +1 -1
  35. data/lib/rollbar/request_data_extractor.rb +7 -1
  36. data/lib/rollbar/rollbar_test.rb +6 -117
  37. data/lib/rollbar/scrubbers/url.rb +10 -5
  38. data/lib/rollbar/scrubbers.rb +1 -5
  39. data/lib/rollbar/truncation/frames_strategy.rb +1 -1
  40. data/lib/rollbar/truncation/mixin.rb +1 -1
  41. data/lib/rollbar/truncation/strings_strategy.rb +4 -2
  42. data/lib/rollbar/util.rb +4 -0
  43. data/lib/rollbar/version.rb +1 -1
  44. data/rollbar.gemspec +1 -0
  45. data/spec/support/rollbar_api.rb +67 -0
  46. metadata +6 -4
@@ -6,7 +6,7 @@ module Rollbar
6
6
  class StringsStrategy
7
7
  include ::Rollbar::Truncation::Mixin
8
8
 
9
- STRING_THRESHOLDS = [1024, 512, 256].freeze
9
+ STRING_THRESHOLDS = [1024, 512, 256, 128].freeze
10
10
 
11
11
  def self.call(payload)
12
12
  new.call(payload)
@@ -29,7 +29,9 @@ module Rollbar
29
29
 
30
30
  def truncate_strings_proc(threshold)
31
31
  proc do |value|
32
- if value.is_a?(String) && value.bytesize > threshold
32
+ # Rollbar::Util.truncate will operate on characters, not bytes,
33
+ # so use value.length, not bytesize.
34
+ if value.is_a?(String) && value.length > threshold
33
35
  Rollbar::Util.truncate(value, threshold)
34
36
  else
35
37
  value
data/lib/rollbar/util.rb CHANGED
@@ -2,6 +2,10 @@ require 'rollbar/util/hash'
2
2
 
3
3
  module Rollbar
4
4
  module Util # :nodoc:
5
+ def self.iterate_and_update_with_block(obj, &block)
6
+ iterate_and_update(obj, block)
7
+ end
8
+
5
9
  def self.iterate_and_update(obj, block, seen = {})
6
10
  return if obj.frozen? || seen[obj.object_id]
7
11
 
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = '2.22.1'.freeze
2
+ VERSION = '2.27.1'.freeze
3
3
  end
data/rollbar.gemspec CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.homepage = 'https://rollbar.com'
14
14
  gem.license = 'MIT'
15
15
  gem.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ gem.files += ['spec/support/rollbar_api.rb'] # useful helper for app spec/tests.
16
17
  gem.name = 'rollbar'
17
18
  gem.require_paths = ['lib']
18
19
  gem.required_ruby_version = '>= 1.9.3'
@@ -0,0 +1,67 @@
1
+ require 'rack/request'
2
+
3
+ class RollbarAPI
4
+ UNAUTHORIZED_ACCESS_TOKEN = 'unauthorized'.freeze
5
+
6
+ def call(env)
7
+ request = Rack::Request.new(env)
8
+ json = JSON.parse(request.body.read)
9
+
10
+ return unauthorized unless authorized?(json, request)
11
+
12
+ return bad_request(json) unless valid_data?(json, request)
13
+
14
+ success(json, request)
15
+ end
16
+
17
+ protected
18
+
19
+ def authorized?(_json, request)
20
+ request.env['HTTP_X_ROLLBAR_ACCESS_TOKEN'] != UNAUTHORIZED_ACCESS_TOKEN
21
+ end
22
+
23
+ def response_headers
24
+ {
25
+ 'Content-Type' => 'application/json'
26
+ }
27
+ end
28
+
29
+ def valid_data?(_json, request)
30
+ !!request.env['HTTP_X_ROLLBAR_ACCESS_TOKEN']
31
+ end
32
+
33
+ def unauthorized
34
+ [401, response_headers, [unauthorized_body]]
35
+ end
36
+
37
+ def bad_request(_json)
38
+ [400, response_headers, [bad_request_body]]
39
+ end
40
+
41
+ def success(json, request)
42
+ [200, response_headers, [success_body(json, request)]]
43
+ end
44
+
45
+ def unauthorized_body
46
+ result(1, nil, 'invalid access token')
47
+ end
48
+
49
+ def bad_request_body
50
+ result(1, nil, 'bad request')
51
+ end
52
+
53
+ def success_body(json, _request)
54
+ result(0, {
55
+ :id => rand(1_000_000),
56
+ :uuid => json['data']['uuid']
57
+ }, nil)
58
+ end
59
+
60
+ def result(err, body, message)
61
+ {
62
+ :err => err,
63
+ :result => body,
64
+ :message => message
65
+ }.to_json
66
+ end
67
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.22.1
4
+ version: 2.27.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rollbar, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-30 00:00:00.000000000 Z
11
+ date: 2020-08-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Easy and powerful exception tracking for Ruby
14
14
  email:
@@ -19,6 +19,7 @@ extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
21
  - ".codeclimate.yml"
22
+ - ".github/pull_request_template.md"
22
23
  - ".gitignore"
23
24
  - ".gitmodules"
24
25
  - ".rubocop.yml"
@@ -95,6 +96,7 @@ files:
95
96
  - lib/rollbar/plugins/delayed_job.rb
96
97
  - lib/rollbar/plugins/delayed_job/job_data.rb
97
98
  - lib/rollbar/plugins/delayed_job/plugin.rb
99
+ - lib/rollbar/plugins/error_context.rb
98
100
  - lib/rollbar/plugins/goalie.rb
99
101
  - lib/rollbar/plugins/rack.rb
100
102
  - lib/rollbar/plugins/rails.rb
@@ -133,6 +135,7 @@ files:
133
135
  - lib/tasks/benchmark.rake
134
136
  - lib/tasks/tasks.rake
135
137
  - rollbar.gemspec
138
+ - spec/support/rollbar_api.rb
136
139
  homepage: https://rollbar.com
137
140
  licenses:
138
141
  - MIT
@@ -157,8 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
160
  - !ruby/object:Gem::Version
158
161
  version: '0'
159
162
  requirements: []
160
- rubyforge_project:
161
- rubygems_version: 2.7.7
163
+ rubygems_version: 3.1.2
162
164
  signing_key:
163
165
  specification_version: 4
164
166
  summary: Reports exceptions to Rollbar