rollbar 2.13.3 → 2.14.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: 5dba5f69b86794e277f902a2d82a96dc034005ea
4
- data.tar.gz: 83381bbcdb0587d0050b419d91b2d08353b77c3c
3
+ metadata.gz: 201dcddad5cbac5d014ddc43c7a10b71f13f7e4d
4
+ data.tar.gz: 92a154504dcd984d1b85a616f845a7ebe08c6ba5
5
5
  SHA512:
6
- metadata.gz: b739b19b4f1d717f2910791497b671a83810a0462d5d902300709ca9074c382c7fd406414c3cd49b731dcced02a8b250bf7f422167222f05a64fbf3d6edd5ed6
7
- data.tar.gz: 3cf9bd70e889e85d77825d4ac457a282e60603aabbf4328b680df14ddcdc95566bef64155ebe112364879ea6f1373d16e6dffe70a6819c902557195cab20315c
6
+ metadata.gz: 8b357d97a5f63527be2f32cf942fe6b09d44b5c9c45878b73f006a7c98cf7c578e294c1a91c6a84bdeb00dd9071758cdb2564b318c7c31992f563fa9ece5c116
7
+ data.tar.gz: 75abf8cd614ca8c698a83d4a18e35d54a9cc0742eb401279786ecff94a24ac1ebbcc18b0bf0f4098d3dd8820360276305b70d3108c6495a7795027c5edfd6884
data/.travis.yml CHANGED
@@ -6,6 +6,8 @@ language: ruby
6
6
  before_install:
7
7
  - gem update --system 2.1.11
8
8
  - gem --version
9
+ - gem install bundler
10
+ - bundle --version
9
11
  rvm:
10
12
  - 1.9.3
11
13
  - 2.0.0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.14.0
4
+
5
+ Features:
6
+
7
+ - Add Rollbar::Middleware::Rack. See [#558](https://github.com/rollbar/rollbar-gem/pull/537).
8
+ - Send request body on DELETE request. See [#555](https://github.com/rollbar/rollbar-gem/pull/537).
9
+
10
+ Fixes:
11
+
12
+ - Fix validations plugin on Rails 5.0 with belong_to.See [#556](https://github.com/rollbar/rollbar-gem/pull/537).
13
+ - Remove few warnings when using minitest with rollbar installed. See [#557](https://github.com/rollbar/rollbar-gem/pull/537).
14
+ - Fix tests 1.9. See [#554](https://github.com/rollbar/rollbar-gem/pull/537).
15
+
16
+ Others:
17
+
18
+ - Updating readme. See [#552](https://github.com/rollbar/rollbar-gem/pull/537).
19
+ - Removed doctoc tag. See [#550](https://github.com/rollbar/rollbar-gem/pull/537).
20
+ - Adding info about Sidekiq and ActiveJob. See [#548](https://github.com/rollbar/rollbar-gem/pull/537).
21
+ - Fix wrong version number in Readme. See [#535](https://github.com/rollbar/rollbar-gem/pull/537).
22
+
3
23
  ## 2.13.3
4
24
 
5
25
  - Fix undefined variable name in rollbar.js middleware. See [#537](https://github.com/rollbar/rollbar-gem/pull/537).
data/README.md CHANGED
@@ -1,72 +1,11 @@
1
- # Rollbar [![Build Status](https://api.travis-ci.org/rollbar/rollbar-gem.svg?branch=v2.13.3)](https://travis-ci.org/rollbar/rollbar-gem/branches)
1
+ # Rollbar [![Build Status](https://api.travis-ci.org/rollbar/rollbar-gem.svg?branch=v2.14.0)](https://travis-ci.org/rollbar/rollbar-gem/branches)
2
2
 
3
3
  <!-- RemoveNext -->
4
4
  [Rollbar](https://rollbar.com) is an error tracking service for Ruby and other languages. The Rollbar service will alert you of problems with your code and help you understand them in a ways never possible before. We love it and we hope you will too.
5
5
 
6
6
  This is the Ruby library for Rollbar. It will instrument many kinds of Ruby applications automatically at the framework level. You can also make direct calls to send exceptions and messages to Rollbar.
7
7
 
8
- <!-- START doctoc generated TOC please keep comment here to allow auto update -->
9
- <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
10
- ## Table of Contents
11
-
12
- - [Getting Started](#getting-started)
13
- - [Rails](#rails)
14
- - [Rack](#rack)
15
- - [Plain Ruby](#plain-ruby)
16
- - [Integration with Rollbar.js](#integration-with-rollbarjs)
17
- - [Test your installation](#test-your-installation)
18
- - [Usage](#usage)
19
- - [Uncaught exceptions](#uncaught-exceptions)
20
- - [Caught exceptions and messages](#caught-exceptions-and-messages)
21
- - [Reporting form validation errors](#reporting-form-validation-errors)
22
- - [Advanced usage](#advanced-usage)
23
- - [Person tracking](#person-tracking)
24
- - [Person tracking with Rack applications](#person-tracking-with-rack-applications)
25
- - [Special note about reporting within a request](#special-note-about-reporting-within-a-request)
26
- - [Data sanitization (scrubbing)](#data-sanitization-scrubbing)
27
- - [Including additional runtime data](#including-additional-runtime-data)
28
- - [Exception level filters](#exception-level-filters)
29
- - [Dynamic levels](#dynamic-levels)
30
- - [Before process hook](#before-process-hook)
31
- - [Transform hook](#transform-hook)
32
- - [The Scope](#the-scope)
33
- - [Override configuration](#override-configuration)
34
- - [Code and context](#code-and-context)
35
- - [Silencing exceptions at runtime](#silencing-exceptions-at-runtime)
36
- - [Sending backtrace without rescued exceptions](#sending-backtrace-without-rescued-exceptions)
37
- - [ActiveJob integration](#activejob-integration)
38
- - [Delayed::Job](#delayedjob)
39
- - [Asynchronous reporting](#asynchronous-reporting)
40
- - [girl_friday](#girl_friday)
41
- - [sucker_punch](#sucker_punch)
42
- - [Sidekiq](#sidekiq)
43
- - [Resque](#resque)
44
- - [DelayedJob](#delayedjob)
45
- - [Threading](#threading)
46
- - [Other handlers](#other-handlers)
47
- - [Failover handlers](#failover-handlers)
48
- - [Logger interface](#logger-interface)
49
- - [Using with rollbar-agent](#using-with-rollbar-agent)
50
- - [Rails booting process](#rails-booting-process)
51
- - [Rails runner command](#rails-runner-command)
52
- - [Deploy Tracking with Capistrano](#deploy-tracking-with-capistrano)
53
- - [Capistrano 3](#capistrano-3)
54
- - [Capistrano 2](#capistrano-2)
55
- - [Counting specific gems as in-project code](#counting-specific-gems-as-in-project-code)
56
- - [Goalie](#goalie)
57
- - [Resque](#resque-1)
58
- - [SSL](#ssl)
59
- - [Using with Zeus](#using-with-zeus)
60
- - [Configuration options](#configuration-options)
61
- - [Plugins](#plugins)
62
- - [Backwards Compatibility](#backwards-compatibility)
63
- - [Known Issues](#known-issues)
64
- - [Supported Language/Framework Versions](#supported-languageframework-versions)
65
- - [Help / Support](#help--support)
66
- - [Contributing](#contributing)
67
-
68
- <!-- END doctoc generated TOC please keep comment here to allow auto update -->
69
-
8
+ <!-- Sub:[TOC] -->
70
9
 
71
10
  ## Getting Started
72
11
 
@@ -123,6 +62,31 @@ $ heroku config:add ROLLBAR_ACCESS_TOKEN=POST_SERVER_ITEM_ACCESS_TOKEN
123
62
  That's all you need to use Rollbar with Rails.
124
63
 
125
64
 
65
+ ### Sinatra
66
+
67
+ Initialize Rollbar with your access token somewhere during startup:
68
+
69
+ ```ruby
70
+ Rollbar.configure do |config|
71
+ config.access_token = 'POST_SERVER_ITEM_ACCESS_TOKEN'
72
+ # other configuration settings
73
+ # ...
74
+ end
75
+ ```
76
+
77
+ Then mount the middleware in your app, like:
78
+
79
+ ```ruby
80
+ require 'rollbar/middleware/sinatra'
81
+
82
+ class MyApp < Sinatra::Base
83
+ use Rollbar::Middleware::Sinatra
84
+ # other middleware/etc
85
+ # ...
86
+ end
87
+ ```
88
+
89
+
126
90
  ### Rack
127
91
 
128
92
  Initialize Rollbar with your access token somewhere during startup:
@@ -138,28 +102,22 @@ end
138
102
  <!-- RemoveNextIfProject -->
139
103
  Be sure to replace ```POST_SERVER_ITEM_ACCESS_TOKEN``` with your project's ```post_server_item``` access token, which you can find in the Rollbar.com interface.
140
104
 
141
- This monkey patches `Rack::Builder` to work with Rollbar automatically.
142
-
143
- For more control, disable the monkey patch:
105
+ The gem monkey patches `Rack::Builder` so Rollbar reports will be sent automatically without any other action. If you prefer to disable the monkey patch apply this change to your config:
144
106
 
145
107
  ```ruby
146
108
  Rollbar.configure do |config|
147
- config.disable_monkey_patch = true
109
+ config.disable_rack_monkey_patch = true
148
110
  # other configuration settings
149
111
  # ...
150
112
  end
151
113
  ```
152
114
 
153
- Then mount the middleware in your app, like:
115
+ If you disabled the `Rack::Builder` monkey patch or it doesn't work for the Rack framework you are using, then add our Rack middleware to your app:
154
116
 
155
117
  ```ruby
156
- require 'rollbar/middleware/sinatra'
118
+ require 'rollbar/middleware/rack
157
119
 
158
- class MyApp < Sinatra::Base
159
- use Rollbar::Middleware::Sinatra
160
- # other middleware/etc
161
- # ...
162
- end
120
+ use Rollbar::Middleware::Rack
163
121
  ```
164
122
 
165
123
  ### Plain Ruby
@@ -215,14 +173,6 @@ The `Hash` passed to `#js_options=` should have the same availalbe options that
215
173
 
216
174
  ## Test your installation
217
175
 
218
- To confirm that it worked, run:
219
-
220
- ```bash
221
- $ rake rollbar:test
222
- ```
223
-
224
- This will raise an exception within a test request; if it works, you'll see a stacktrace in the console, and the exception will appear in the Rollbar dashboard.
225
-
226
176
  If you're not using Rails, you may first need to add the following to your Rakefile:
227
177
 
228
178
  ```ruby
@@ -239,6 +189,14 @@ task :environment do
239
189
  end
240
190
  ```
241
191
 
192
+ To confirm that it worked, run:
193
+
194
+ ```bash
195
+ $ rake rollbar:test
196
+ ```
197
+
198
+ This will raise an exception within a test request; if it works, you'll see a stacktrace in the console, and the exception will appear in the Rollbar dashboard.
199
+
242
200
  ## Usage
243
201
 
244
202
  ### Uncaught exceptions
@@ -432,6 +390,8 @@ end
432
390
 
433
391
  # You can add the middleware to your application, for example:
434
392
 
393
+ require 'rollbar/middleware/sinatra'
394
+
435
395
  class App < Sinatra::Base
436
396
  use Rollbar::Middleware::Sinatra
437
397
  use RollbarPersonData
@@ -707,6 +667,8 @@ end
707
667
 
708
668
  If you need to customize the reporting write your own `rescue_from` handler instead of using the `Rollbar::ActiveJob` module.
709
669
 
670
+ Note: If you're using Sidekiq and integrate ActiveJob, you may get double reports of background job errors in Rollbar. The way to avoid this is to rely on the Sidekiq error handling, not ActiveJob in this case.
671
+
710
672
  ## Delayed::Job
711
673
 
712
674
  If `delayed_job` is defined, Rollbar will automatically install a plugin that reports any uncaught exceptions that occur in jobs.
@@ -870,14 +832,14 @@ logger = Rollbar::Logger.new
870
832
  logger.info('Purchase failed!')
871
833
  ```
872
834
 
873
- If you are using Rails you can extend your `Rails.logger` so the log messages are sent to both outputs. You can use this snippet in one initializer:
835
+ If you are using Rails you can extend your `Rails.logger` so the log messages are sent to both outputs. You can use this snippet in one initializer (for example, `config/initializers/rollbar.rb`):
874
836
 
875
837
  ```ruby
876
838
  require 'rollbar/logger'
877
839
 
878
840
  Rails.logger.extend(ActiveSupport::Logger.broadcast(Rollbar::Logger.new))
879
841
  ```
880
-
842
+
881
843
  ## Using with rollbar-agent
882
844
 
883
845
  For even more asynchrony, you can configure the gem to write to a file instead of sending the payload to Rollbar servers directly. [rollbar-agent](https://github.com/rollbar/rollbar-agent) can then be hooked up to this file to actually send the payload across. To enable, add the following in ```config/initializers/rollbar.rb```:
@@ -37,10 +37,13 @@ gem 'genspec', '>= 0.2.8'
37
37
  gem 'girl_friday', '>= 0.11.1'
38
38
 
39
39
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0')
40
+ gem 'public_suffix', '< 1.5'
40
41
  gem 'mime-types', '< 3.0'
42
+ gem 'webmock', '< 2.3.0', :require => false
43
+ else
44
+ gem 'webmock', :require => false
41
45
  end
42
46
 
43
- gem 'webmock', :require => false
44
47
  gem 'resque'
45
48
 
46
49
  gemspec :path => '../'
@@ -18,7 +18,6 @@ gem 'rspec-rails', '~> 3.4'
18
18
  gem 'rake'
19
19
 
20
20
  gem 'oj', '~> 2.12.14' unless is_jruby
21
- gem 'sidekiq', '>= 2.13.0' if RUBY_VERSION != '1.8.7'
22
21
 
23
22
  if RUBY_VERSION.start_with?('1.9')
24
23
  gem 'sucker_punch'
@@ -36,9 +35,14 @@ gem 'generator_spec'
36
35
 
37
36
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0')
38
37
  gem 'mime-types', '< 3.0'
38
+ gem 'public_suffix', '< 1.5'
39
+ gem 'webmock', '< 2.3.0', :require => false
40
+ gem 'sidekiq', '< 2.13.0'
41
+ else
42
+ gem 'webmock', :require => false
43
+ gem 'sidekiq', '>= 2.13.0'
39
44
  end
40
45
 
41
- gem 'webmock', :require => false
42
46
  gem 'resque'
43
47
 
44
48
  gemspec :path => "../"
@@ -38,9 +38,12 @@ gem 'generator_spec'
38
38
 
39
39
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0')
40
40
  gem 'mime-types', '< 3.0'
41
+ gem 'public_suffix', '< 1.5'
42
+ gem 'webmock', '< 2.3.0', :require => false
43
+ else
44
+ gem 'webmock', :require => false
41
45
  end
42
46
 
43
- gem 'webmock', :require => false
44
47
  gem 'resque'
45
48
 
46
49
  gemspec :path => "../"
@@ -40,9 +40,12 @@ gem 'generator_spec'
40
40
 
41
41
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0')
42
42
  gem 'mime-types', '< 3.0'
43
+ gem 'public_suffix', '< 1.5'
44
+ gem 'webmock', '< 2.3.0', :require => false
45
+ else
46
+ gem 'webmock', :require => false
43
47
  end
44
48
 
45
- gem 'webmock', :require => false
46
49
  gem 'resque'
47
50
 
48
51
  gemspec :path => "../"
@@ -36,9 +36,12 @@ gem 'generator_spec'
36
36
 
37
37
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0')
38
38
  gem 'mime-types', '< 3.0'
39
+ gem 'public_suffix', '< 1.5'
40
+ gem 'webmock', '< 2.3.0', :require => false
41
+ else
42
+ gem 'webmock', :require => false
39
43
  end
40
44
 
41
- gem 'webmock', :require => false
42
45
  gem 'resque'
43
46
 
44
47
  gemspec :path => "../"
@@ -41,9 +41,13 @@ gem 'codeclimate-test-reporter', :group => :test, :require => nil
41
41
 
42
42
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0')
43
43
  gem 'mime-types', '< 3.0'
44
+ gem 'public_suffix', '< 1.5'
45
+ gem 'webmock', '< 2.3.0', :require => false
46
+ else
47
+ gem 'webmock', :require => false
44
48
  end
45
49
 
46
- gem 'webmock', :require => false
50
+
47
51
  gem 'resque'
48
52
 
49
53
  gemspec :path => "../"
@@ -36,7 +36,9 @@ gem 'database_cleaner', '~> 1.0.0'
36
36
  gem 'genspec', '= 0.2.8'
37
37
  gem 'girl_friday', '>= 0.11.1'
38
38
 
39
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0')
39
+ ruby_version = RUBY_VERSION.dup
40
+
41
+ if Gem::Version.new(ruby_version) < Gem::Version.new('2.0')
40
42
  gem 'mime-types', '< 3.0'
41
43
  end
42
44
 
data/lib/rollbar.rb CHANGED
@@ -24,7 +24,7 @@ module Rollbar
24
24
  PUBLIC_NOTIFIER_METHODS = %w(debug info warn warning error critical log logger
25
25
  process_item process_from_async_handler scope
26
26
  send_failsafe log_info log_debug log_warning
27
- log_error silenced scope_object with_config).freeze
27
+ log_error silenced scope_object).freeze
28
28
 
29
29
  class << self
30
30
  extend Forwardable
@@ -7,7 +7,7 @@ module Rollbar
7
7
  attr_accessor :access_token
8
8
  attr_accessor :async_handler
9
9
  attr_accessor :branch
10
- attr_accessor :before_process
10
+ attr_reader :before_process
11
11
  attr_accessor :code_version
12
12
  attr_accessor :custom_data_method
13
13
  attr_accessor :delayed_job_enabled
@@ -24,7 +24,7 @@ module Rollbar
24
24
  attr_accessor :filepath
25
25
  attr_accessor :framework
26
26
  attr_accessor :ignored_person_ids
27
- attr_accessor :logger
27
+ attr_writer :logger
28
28
  attr_accessor :payload_options
29
29
  attr_accessor :person_method
30
30
  attr_accessor :person_id_method
@@ -47,10 +47,10 @@ module Rollbar
47
47
  attr_accessor :uncaught_exception_level
48
48
  attr_accessor :scrub_headers
49
49
  attr_accessor :sidekiq_threshold
50
- attr_accessor :transform
50
+ attr_reader :transform
51
51
  attr_accessor :verify_ssl_peer
52
52
  attr_accessor :use_async
53
- attr_accessor :use_eventmachine
53
+ attr_reader :use_eventmachine
54
54
  attr_accessor :web_base
55
55
  attr_accessor :write_to_file
56
56
  attr_reader :send_extra_frame_data
@@ -0,0 +1,49 @@
1
+ require 'rollbar'
2
+ require 'rollbar/exception_reporter'
3
+ require 'rollbar/request_data_extractor'
4
+
5
+ module Rollbar
6
+ module Middleware
7
+ class Rack
8
+ include ::Rollbar::ExceptionReporter
9
+ include RequestDataExtractor
10
+
11
+ def initialize(app)
12
+ @app = app
13
+ end
14
+
15
+ def call(env)
16
+ Rollbar.reset_notifier!
17
+
18
+ Rollbar.scoped(fetch_scope(env)) do
19
+ begin
20
+ response = @app.call(env)
21
+ report_exception_to_rollbar(env, framework_error(env)) if framework_error(env)
22
+ response
23
+ rescue Exception => e
24
+ report_exception_to_rollbar(env, e)
25
+ raise
26
+ end
27
+ end
28
+ end
29
+
30
+ def fetch_scope(env)
31
+ {
32
+ :request => proc { extract_request_data_from_rack(env) },
33
+ :person => person_data_proc(env)
34
+ }
35
+ rescue Exception => e
36
+ report_exception_to_rollbar(env, e)
37
+ raise
38
+ end
39
+
40
+ def person_data_proc(env)
41
+ proc { extract_person_data_from_controller(env) }
42
+ end
43
+
44
+ def framework_error(env)
45
+ nil
46
+ end
47
+ end
48
+ end
49
+ end
@@ -3,7 +3,7 @@ require 'rollbar/request_data_extractor'
3
3
 
4
4
  module Rollbar
5
5
  module Middleware
6
- module Rack
6
+ class Rack
7
7
  module Builder
8
8
  include ExceptionReporter
9
9
  include RequestDataExtractor
@@ -1,6 +1,6 @@
1
1
  module Rollbar
2
2
  module Middleware
3
- module Rack
3
+ class Rack
4
4
  module TestSession
5
5
  include ExceptionReporter
6
6
 
@@ -1,46 +1,8 @@
1
- require 'rollbar'
2
- require 'rollbar/exception_reporter'
3
- require 'rollbar/request_data_extractor'
1
+ require 'rollbar/middleware/rack'
4
2
 
5
3
  module Rollbar
6
4
  module Middleware
7
- class Sinatra
8
- include ::Rollbar::ExceptionReporter
9
- include RequestDataExtractor
10
-
11
- def initialize(app)
12
- @app = app
13
- end
14
-
15
- def call(env)
16
- Rollbar.reset_notifier!
17
-
18
- Rollbar.scoped(fetch_scope(env)) do
19
- begin
20
- response = @app.call(env)
21
- report_exception_to_rollbar(env, framework_error(env)) if framework_error(env)
22
- response
23
- rescue Exception => e
24
- report_exception_to_rollbar(env, e)
25
- raise
26
- end
27
- end
28
- end
29
-
30
- def fetch_scope(env)
31
- {
32
- :request => proc { extract_request_data_from_rack(env) },
33
- :person => person_data_proc(env)
34
- }
35
- rescue Exception => e
36
- report_exception_to_rollbar(env, e)
37
- raise
38
- end
39
-
40
- def person_data_proc(env)
41
- proc { extract_person_data_from_controller(env) }
42
- end
43
-
5
+ class Sinatra < Rollbar::Middleware::Rack
44
6
  def framework_error(env)
45
7
  env['sinatra.error']
46
8
  end
@@ -1,6 +1,5 @@
1
- require 'rollbar'
2
- require 'rollbar/lazy_store'
3
1
  require 'rollbar/configuration'
2
+ require 'rollbar/lazy_store'
4
3
  require 'rollbar/util'
5
4
  require 'rollbar/json'
6
5
  require 'rollbar/exceptions'
@@ -4,11 +4,13 @@ Rollbar.plugins.define('rack') do
4
4
 
5
5
  execute do
6
6
  if defined?(Rack::Builder)
7
+ require 'rollbar/middleware/rack'
7
8
  require 'rollbar/middleware/rack/builder'
8
9
  Rack::Builder.send(:include, Rollbar::Middleware::Rack::Builder)
9
10
  end
10
11
 
11
12
  if defined?(Rack::Test::Session)
13
+ require 'rollbar/middleware/rack'
12
14
  require 'rollbar/middleware/rack/test_session'
13
15
  Rack::Test::Session.send(:include, Rollbar::Middleware::Rack::TestSession)
14
16
  end
@@ -30,13 +30,13 @@ Rollbar.plugins.define('active_model') do
30
30
  include Rollbar::ActiveRecordExtension
31
31
  end
32
32
 
33
- # If ActiveRecord::Base has been already loaded,
34
- # it's including a not updated version of ActiveModel::Validations
35
- # We then want to include Rollbar::ActiveRecordExtension
36
- # in ActiveRecord::Base
37
- if defined?(ActiveRecord::Base)
38
- ActiveRecord::Base.class_eval do
39
- include Rollbar::ActiveRecordExtension
33
+ active_support_was_defined = defined?(ActiveRecord::Base)
34
+
35
+ ActiveSupport.on_load(:active_record) do
36
+ if active_support_was_defined
37
+ ActiveRecord::Base.class_eval do
38
+ include Rollbar::ActiveRecordExtension
39
+ end
40
40
  end
41
41
  end
42
42
  end
@@ -10,6 +10,7 @@ require 'rollbar/json'
10
10
  module Rollbar
11
11
  module RequestDataExtractor
12
12
  ALLOWED_HEADERS_REGEX = /^HTTP_|^CONTENT_TYPE$|^CONTENT_LENGTH$/
13
+ ALLOWED_BODY_PARSEABLE_METHODS = %w(POST PUT PATCH DELETE).freeze
13
14
 
14
15
  def extract_person_data_from_controller(env)
15
16
  if env.has_key?('rollbar.person_data')
@@ -168,7 +169,7 @@ module Rollbar
168
169
  end
169
170
 
170
171
  def rollbar_raw_body_params(rack_req)
171
- correct_method = rack_req.post? || rack_req.put? || rack_req.patch?
172
+ correct_method = ALLOWED_BODY_PARSEABLE_METHODS.include?(rack_req.request_method)
172
173
 
173
174
  return {} unless correct_method
174
175
  return {} unless json_request?(rack_req)
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = '2.13.3'
2
+ VERSION = '2.14.0'
3
3
  end
@@ -0,0 +1,5 @@
1
+ class Book < ActiveRecord::Base
2
+ belongs_to :user
3
+
4
+ after_validation :report_validation_errors_to_rollbar
5
+ end
@@ -0,0 +1,10 @@
1
+ class CreateBooks < ActiveRecord::Migration
2
+ def change
3
+ create_table :books do |t|
4
+ t.string :title
5
+ t.integer :user_id
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class AddUsernameToUsers < ActiveRecord::Migration
2
+ def change
3
+ add_column :users, :username, :string
4
+ end
5
+ end
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  # This file is auto-generated from the current state of the database. Instead
3
2
  # of editing this file, please use the migrations feature of Active Record to
4
3
  # incrementally modify your database, and then regenerate this schema definition.
@@ -9,13 +8,20 @@
9
8
  # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
9
  # you'll amass, the slower it'll run and the greater likelihood for issues).
11
10
  #
12
- # It's strongly recommended to check this file into your version control system.
11
+ # It's strongly recommended that you check this file into your version control system.
13
12
 
14
- ActiveRecord::Schema.define(:version => 20121121184654) do
13
+ ActiveRecord::Schema.define(:version => 20161219185529) do
15
14
 
16
- create_table "users", :force => true do |t|
17
- t.string "email", :default => "", :null => false
18
- t.string "encrypted_password", :default => "", :null => false
15
+ create_table "books", :force => :cascade do |t|
16
+ t.string "title"
17
+ t.integer "user_id"
18
+ t.datetime "created_at", :null => false
19
+ t.datetime "updated_at",:null => false
20
+ end
21
+
22
+ create_table "users", :force => :cascade do |t|
23
+ t.string "email", :default => "", :null => false
24
+ t.string "encrypted_password", :default => "", :null => false
19
25
  t.string "reset_password_token"
20
26
  t.datetime "reset_password_sent_at"
21
27
  t.datetime "remember_created_at"
@@ -24,12 +30,12 @@ ActiveRecord::Schema.define(:version => 20121121184654) do
24
30
  t.datetime "last_sign_in_at"
25
31
  t.string "current_sign_in_ip"
26
32
  t.string "last_sign_in_ip"
27
- t.datetime "created_at", :null => false
28
- t.datetime "updated_at", :null => false
33
+ t.datetime "created_at"
34
+ t.datetime "updated_at"
35
+ t.string "name"
29
36
  t.string "username"
30
37
  end
31
38
 
32
39
  add_index "users", ["email"], :name => "index_users_on_email", :unique => true
33
40
  add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
34
-
35
41
  end
@@ -16,11 +16,11 @@ describe Rollbar::Middleware::Rack::Builder, :reconfigure_notifier => true do
16
16
  let(:app) do
17
17
  action_proc = action
18
18
 
19
- Rack::Builder.new { run action_proc }
19
+ ::Rack::Builder.new { run action_proc }
20
20
  end
21
21
 
22
22
  let(:request) do
23
- Rack::MockRequest.new(app)
23
+ ::Rack::MockRequest.new(app)
24
24
  end
25
25
 
26
26
  let(:exception) { kind_of(RackMockError) }
@@ -17,6 +17,19 @@ describe Rollbar::ActiveRecordExtension do
17
17
 
18
18
  user.valid?
19
19
  end
20
+
21
+ context 'using Rails 5.0' do
22
+ next unless Gem::Version.new(Rails.version) >= Gem::Version.new('5.0')
23
+
24
+ context 'with belongs_to' do
25
+ let(:book) { Book.new }
26
+
27
+ it 'report validations error' do
28
+ expect(book).to receive(:report_validation_errors_to_rollbar)
29
+ book.valid?
30
+ end
31
+ end
32
+ end
20
33
  end
21
34
 
22
35
  context 'with class using ActiveModel::Validations' do
@@ -169,6 +169,42 @@ describe Rollbar::RequestDataExtractor do
169
169
  end
170
170
  end
171
171
 
172
+ context 'with JSON DELETE body' do
173
+ let(:params) { { 'key' => 'value' } }
174
+ let(:body) { params.to_json }
175
+ let(:env) do
176
+ Rack::MockRequest.env_for('/?foo=bar',
177
+ 'CONTENT_TYPE' => 'application/json',
178
+ :input => body,
179
+ :method => 'DELETE')
180
+
181
+
182
+ end
183
+
184
+ it 'extracts the correct user IP' do
185
+ result = subject.extract_request_data_from_rack(env)
186
+ expect(result[:body]).to be_eql(body)
187
+ end
188
+ end
189
+
190
+ context 'with JSON PUT body' do
191
+ let(:params) { { 'key' => 'value' } }
192
+ let(:body) { params.to_json }
193
+ let(:env) do
194
+ Rack::MockRequest.env_for('/?foo=bar',
195
+ 'CONTENT_TYPE' => 'application/json',
196
+ :input => body,
197
+ :method => 'PUT')
198
+
199
+
200
+ end
201
+
202
+ it 'extracts the correct user IP' do
203
+ result = subject.extract_request_data_from_rack(env)
204
+ expect(result[:body]).to be_eql(body)
205
+ end
206
+ end
207
+
172
208
  context 'with POST params' do
173
209
  let(:params) { { 'key' => 'value' } }
174
210
  let(:env) do
data/spec/spec_helper.rb CHANGED
@@ -35,7 +35,12 @@ if ENV['TRAVIS_JDK_VERSION'] == 'oraclejdk7'
35
35
  Rollbar::Configuration::DEFAULT_ENDPOINT = 'https://api-alt.rollbar.com/api/1/item/'
36
36
  end
37
37
 
38
- Rake::Task['dummy:db:setup'].invoke
38
+ if Gem::Version.new(Rails.version) < Gem::Version.new('5.0')
39
+ Rake::Task['dummy:db:setup'].invoke
40
+ else
41
+ Rake::Task['dummy:db:test:prepare'].invoke
42
+ end
43
+
39
44
 
40
45
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
41
46
 
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.13.3
4
+ version: 2.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rollbar, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-06 00:00:00.000000000 Z
11
+ date: 2016-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -88,6 +88,7 @@ files:
88
88
  - lib/rollbar/logger.rb
89
89
  - lib/rollbar/logger_proxy.rb
90
90
  - lib/rollbar/middleware/js.rb
91
+ - lib/rollbar/middleware/rack.rb
91
92
  - lib/rollbar/middleware/rack/builder.rb
92
93
  - lib/rollbar/middleware/rack/test_session.rb
93
94
  - lib/rollbar/middleware/rails/rollbar.rb
@@ -150,6 +151,7 @@ files:
150
151
  - spec/dummyapp/app/helpers/.gitkeep
151
152
  - spec/dummyapp/app/mailers/.gitkeep
152
153
  - spec/dummyapp/app/models/.gitkeep
154
+ - spec/dummyapp/app/models/book.rb
153
155
  - spec/dummyapp/app/models/post.rb
154
156
  - spec/dummyapp/app/models/user.rb
155
157
  - spec/dummyapp/app/views/devise/registrations/edit.html.erb
@@ -186,6 +188,8 @@ files:
186
188
  - spec/dummyapp/config/secrets.yml
187
189
  - spec/dummyapp/db/migrate/20121121184652_devise_create_users.rb
188
190
  - spec/dummyapp/db/migrate/20121121184654_add_name_to_users.rb
191
+ - spec/dummyapp/db/migrate/20161219184410_create_books.rb
192
+ - spec/dummyapp/db/migrate/20161219185529_add_username_to_users.rb
189
193
  - spec/dummyapp/db/schema.rb
190
194
  - spec/dummyapp/db/seeds.rb
191
195
  - spec/dummyapp/lib/assets/.gitkeep
@@ -276,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
276
280
  version: '0'
277
281
  requirements: []
278
282
  rubyforge_project:
279
- rubygems_version: 2.3.0
283
+ rubygems_version: 2.4.5
280
284
  signing_key:
281
285
  specification_version: 4
282
286
  summary: Reports exceptions to Rollbar
@@ -297,6 +301,7 @@ test_files:
297
301
  - spec/dummyapp/app/helpers/.gitkeep
298
302
  - spec/dummyapp/app/mailers/.gitkeep
299
303
  - spec/dummyapp/app/models/.gitkeep
304
+ - spec/dummyapp/app/models/book.rb
300
305
  - spec/dummyapp/app/models/post.rb
301
306
  - spec/dummyapp/app/models/user.rb
302
307
  - spec/dummyapp/app/views/devise/registrations/edit.html.erb
@@ -333,6 +338,8 @@ test_files:
333
338
  - spec/dummyapp/config/secrets.yml
334
339
  - spec/dummyapp/db/migrate/20121121184652_devise_create_users.rb
335
340
  - spec/dummyapp/db/migrate/20121121184654_add_name_to_users.rb
341
+ - spec/dummyapp/db/migrate/20161219184410_create_books.rb
342
+ - spec/dummyapp/db/migrate/20161219185529_add_username_to_users.rb
336
343
  - spec/dummyapp/db/schema.rb
337
344
  - spec/dummyapp/db/seeds.rb
338
345
  - spec/dummyapp/lib/assets/.gitkeep