rollbar 0.10.6 → 0.10.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ **0.10.7**
4
+ - Add ability to report form validation errors
5
+ - Add MIT license to gemspec
6
+
3
7
  **0.10.6**
4
8
  - Fix json dump when rack.errors is an IO stream
5
9
 
data/README.md CHANGED
@@ -60,6 +60,14 @@ $ rake rollbar:test
60
60
 
61
61
  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.
62
62
 
63
+ ## Reporting form validation errors
64
+
65
+ To get form validation errors automatically reported to Rollbar just add the following ```after_validation``` callback to your models:
66
+
67
+ ```ruby
68
+ after_validation :report_validation_errors_to_rollbar
69
+ ```
70
+
63
71
  ## Manually reporting exceptions and messages
64
72
 
65
73
  To report a caught exception to Rollbar, simply call ```Rollbar.report_exception```:
@@ -136,7 +144,7 @@ config.person_email_method = "email_address" # default is "email"
136
144
 
137
145
  ## Including additional runtime data
138
146
 
139
- You can provide a lambda that will be called for each exception or message report. ```custom_data_method``` should be a lambda that takes no arguments and returns a hash.
147
+ You can provide a lambda that will be called for each exception or message report. ```custom_data_method``` should be a lambda that takes no arguments and returns a hash.
140
148
 
141
149
  Add the following in ```config/initializers/rollbar.rb```:
142
150
 
@@ -170,7 +178,7 @@ Rollbar.silenced {
170
178
 
171
179
  ## Asynchronous reporting
172
180
 
173
- By default, all messages are reported synchronously. You can enable asynchronous reporting with [girl_friday](https://github.com/mperham/girl_friday) or [Sidekiq](https://github.com/mperham/sidekiq).
181
+ By default, all messages are reported synchronously. You can enable asynchronous reporting with [girl_friday](https://github.com/mperham/girl_friday) or [Sidekiq](https://github.com/mperham/sidekiq).
174
182
 
175
183
  ### Using girl_friday
176
184
 
@@ -249,7 +257,7 @@ Available options:
249
257
  </dd>
250
258
  <dt>rollbar_env</dt>
251
259
  <dd>Deploy environment name
252
-
260
+
253
261
  Default: ```rails_env```
254
262
 
255
263
  </dd>
@@ -286,7 +294,7 @@ Check out [resque-rollbar](https://github.com/CrowdFlower/resque-rollbar) for us
286
294
 
287
295
  ## Using with Zeus
288
296
 
289
- Some users have reported problems with Zeus when ```rake``` was not explicitly included in their Gemfile. If the zeus server fails to start after installing the rollbar gem, try explicitly adding ```gem 'rake'``` to your ```Gemfile```. See [this thread](https://github.com/rollbar/rollbar-gem/issues/30) for more information.
297
+ Some users have reported problems with Zeus when ```rake``` was not explicitly included in their Gemfile. If the zeus server fails to start after installing the rollbar gem, try explicitly adding ```gem 'rake'``` to your ```Gemfile```. See [this thread](https://github.com/rollbar/rollbar-gem/issues/30) for more information.
290
298
 
291
299
 
292
300
  ## Help / Support
@@ -11,6 +11,7 @@ require 'rollbar/version'
11
11
  require 'rollbar/configuration'
12
12
  require 'rollbar/request_data_extractor'
13
13
  require 'rollbar/exception_reporter'
14
+ require 'rollbar/active_record_extension'
14
15
 
15
16
  require 'rollbar/railtie' if defined?(Rails)
16
17
 
@@ -31,7 +32,7 @@ module Rollbar
31
32
  # end
32
33
  def configure
33
34
  require_hooks
34
-
35
+
35
36
  # if configuration.enabled has not been set yet (is still 'nil'), set to true.
36
37
  if configuration.enabled.nil?
37
38
  configuration.enabled = true
@@ -144,7 +145,7 @@ module Rollbar
144
145
  end
145
146
 
146
147
  private
147
-
148
+
148
149
  def require_hooks()
149
150
  require 'rollbar/delayed_job' if defined?(Delayed) && defined?(Delayed::Plugins)
150
151
  require 'rollbar/sidekiq' if defined?(Sidekiq)
@@ -255,25 +256,25 @@ module Rollbar
255
256
  end
256
257
  end
257
258
 
258
- def send_payload_using_eventmachine(payload)
259
+ def send_payload_using_eventmachine(payload)
259
260
  req = EventMachine::HttpRequest.new(configuration.endpoint).post(:body => payload)
260
261
  req.callback do
261
262
  if req.response_header.status == 200
262
263
  logger.info '[Rollbar] Success'
263
264
  else
264
265
  logger.warn "[Rollbar] Got unexpected status code from Rollbar.io api: #{req.response_header.status}"
265
- logger.info "[Rollbar] Response: #{req.response}"
266
+ logger.info "[Rollbar] Response: #{req.response}"
266
267
  end
267
268
  end
268
269
  req.errback do
269
270
  logger.warn "[Rollbar] Call to API failed, status code: #{req.response_header.status}"
270
- logger.info "[Rollbar] Error's response: #{req.response}"
271
+ logger.info "[Rollbar] Error's response: #{req.response}"
271
272
  end
272
273
  end
273
274
 
274
275
  def send_payload(payload)
275
276
  logger.info '[Rollbar] Sending payload'
276
-
277
+
277
278
  if configuration.use_eventmachine
278
279
  send_payload_using_eventmachine(payload)
279
280
  return
@@ -0,0 +1,14 @@
1
+ module Rollbar
2
+ module ActiveRecordExtension
3
+ extend ActiveSupport::Concern
4
+
5
+ def report_validation_errors_to_rollbar
6
+ self.errors.full_messages.each do |error|
7
+ logger.info "[Rollbar] Reporting form validation error: #{error} for #{self.to_s}"
8
+ Rollbar.report_message("Form Validation Error: #{error} for #{self.to_s}")
9
+ end
10
+ end
11
+ end
12
+ end
13
+
14
+ ActiveRecord::Base.send(:include, Rollbar::ActiveRecordExtension)
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = "0.10.6"
2
+ VERSION = "0.10.7"
3
3
  end
@@ -7,6 +7,7 @@ Gem::Specification.new do |gem|
7
7
  gem.description = %q{Rails plugin to catch and send exceptions to Rollbar}
8
8
  gem.summary = %q{Reports exceptions to Rollbar}
9
9
  gem.homepage = "https://github.com/rollbar/rollbar-gem"
10
+ gem.license = 'MIT'
10
11
 
11
12
  gem.files = `git ls-files`.split($\)
12
13
  gem.test_files = gem.files.grep(%r{^(spec)/})
@@ -44,7 +44,7 @@ describe Rollbar do
44
44
 
45
45
  it 'should not be enabled when not configured' do
46
46
  Rollbar.unconfigure
47
-
47
+
48
48
  Rollbar.configuration.enabled.should be_nil
49
49
  Rollbar.report_exception(@exception).should == 'disabled'
50
50
  end
@@ -59,7 +59,7 @@ describe Rollbar do
59
59
 
60
60
  # now configure again (perhaps to change some other values)
61
61
  Rollbar.configure do |config| end
62
-
62
+
63
63
  Rollbar.configuration.enabled.should == false
64
64
  Rollbar.report_exception(@exception).should == 'disabled'
65
65
  end
@@ -165,6 +165,7 @@ describe Rollbar do
165
165
  end
166
166
 
167
167
  let(:logger_mock) { double("Rails.logger").as_null_object }
168
+ let(:user) { User.create(:email => 'email@example.com', :encrypted_password => '', :created_at => Time.now, :updated_at => Time.now) }
168
169
 
169
170
  it 'should report simple messages' do
170
171
  logger_mock.should_receive(:info).with('[Rollbar] Scheduling payload')
@@ -201,6 +202,18 @@ describe Rollbar do
201
202
  Rollbar.report_message("Test message with circular extra data", 'debug', a)
202
203
  end
203
204
 
205
+ it 'should be able to report form validation errors when they are present' do
206
+ logger_mock.should_receive(:info).with('[Rollbar] Success')
207
+ user.errors.add(:example, "error")
208
+ user.report_validation_errors_to_rollbar
209
+ end
210
+
211
+ it 'should not report form validation errors when they are not present' do
212
+ logger_mock.should_not_receive(:info).with('[Rollbar] Success')
213
+ user.errors.clear
214
+ user.report_validation_errors_to_rollbar
215
+ end
216
+
204
217
  after(:each) do
205
218
  Rollbar.configure do |config|
206
219
  config.logger = ::Rails.logger
@@ -420,7 +433,7 @@ describe Rollbar do
420
433
  trace[:exception][:class].should match(/^(NameError|NoMethodError)$/)
421
434
  trace[:exception][:message].should match(/^(undefined local variable or method `bar'|undefined method `bar' on an instance of)/)
422
435
  end
423
-
436
+
424
437
  it 'should include custom data when configured' do
425
438
  Rollbar.configure do |config|
426
439
  config.custom_data_method = lambda { {:foo => "baz", :hello => [4, 5, 6]} }
@@ -492,17 +505,17 @@ describe Rollbar do
492
505
  data[:language].should == 'ruby'
493
506
  data[:framework].should match(/^Rails/)
494
507
  end
495
-
508
+
496
509
  it 'should have a default production environment' do
497
510
  data = Rollbar.send(:base_data)
498
511
  data[:environment].should == 'production'
499
512
  end
500
-
513
+
501
514
  it 'should have an overridden environment' do
502
515
  Rollbar.configure do |config|
503
516
  config.environment = 'overridden'
504
517
  end
505
-
518
+
506
519
  data = Rollbar.send(:base_data)
507
520
  data[:environment].should == 'overridden'
508
521
  end
@@ -546,19 +559,19 @@ describe Rollbar do
546
559
  it "should include gem paths for specified project gems in the payload" do
547
560
  gems = ['rack', 'rspec-rails']
548
561
  gem_paths = []
549
-
562
+
550
563
  Rollbar.configure do |config|
551
564
  config.project_gems = gems
552
565
  end
553
-
566
+
554
567
  gems.each {|gem|
555
568
  gem_paths.push(Gem::Specification.find_by_name(gem).gem_dir)
556
569
  }
557
-
570
+
558
571
  data = Rollbar.send(:message_data, 'test', 'info', {})
559
572
  data[:project_package_paths].kind_of?(Array).should == true
560
573
  data[:project_package_paths].length.should == gem_paths.length
561
-
574
+
562
575
  data[:project_package_paths].each_with_index{|path, index|
563
576
  path.should == gem_paths[index]
564
577
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.6
4
+ version: 0.10.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -131,6 +131,7 @@ files:
131
131
  - lib/generators/rollbar/rollbar_generator.rb
132
132
  - lib/generators/rollbar/templates/initializer.rb
133
133
  - lib/rollbar.rb
134
+ - lib/rollbar/active_record_extension.rb
134
135
  - lib/rollbar/better_errors.rb
135
136
  - lib/rollbar/capistrano.rb
136
137
  - lib/rollbar/configuration.rb
@@ -207,7 +208,8 @@ files:
207
208
  - spec/rollbar_spec.rb
208
209
  - spec/spec_helper.rb
209
210
  homepage: https://github.com/rollbar/rollbar-gem
210
- licenses: []
211
+ licenses:
212
+ - MIT
211
213
  post_install_message:
212
214
  rdoc_options: []
213
215
  require_paths: