rollbar 2.15.5 → 2.15.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +15 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +2 -1
- data/README.md +129 -6
- data/data/rollbar.snippet.js +1 -1
- data/gemfiles/rails42.gemfile +1 -1
- data/gemfiles/rails51.gemfile +58 -0
- data/gemfiles/ruby_1_8_and_1_9_2.gemfile +1 -1
- data/lib/rollbar.rb +1 -0
- data/lib/rollbar/item.rb +10 -2
- data/lib/rollbar/logger.rb +6 -1
- data/lib/rollbar/middleware/js.rb +15 -9
- data/lib/rollbar/notifier.rb +22 -8
- data/lib/rollbar/plugins/delayed_job/plugin.rb +2 -1
- data/lib/rollbar/request_data_extractor.rb +6 -1
- data/lib/rollbar/tasks/rollbar.cap +25 -0
- data/lib/rollbar/version.rb +1 -1
- data/spec/controllers/home_controller_spec.rb +22 -14
- data/spec/dummyapp/app/controllers/users_controller.rb +1 -1
- data/spec/rollbar/item_spec.rb +44 -1
- data/spec/rollbar/logger_spec.rb +10 -0
- data/spec/rollbar/middleware/js_spec.rb +69 -0
- data/spec/rollbar/notifier_spec.rb +13 -0
- data/spec/rollbar/plugins/delayed_job_spec.rb +16 -0
- data/spec/rollbar_spec.rb +49 -27
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 308597023c833b27f29c551f13eb92c9b4ae24c3
|
4
|
+
data.tar.gz: f0b5bebb851e64c0f831c7fe4f0c8d05bb3dca80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a03bb676d4bff746f6c691c92bedf00e14d6b6a0ff8ca0afee5dc3b8c8ee8f96bdad2d912a037f7914c86424c1aae7b64fa8c6a338da0918dc553142c5835a7
|
7
|
+
data.tar.gz: f9597a902bbba23e993f2bc2c8473e5b22a3e1a18337648ea5697e7a9762880e0cd6024c51b40e2d2c1c6f38a3bf3ffda80cee045c2c3acf3e79c6ee0f6e259b
|
data/.travis.yml
CHANGED
@@ -31,6 +31,7 @@ gemfile:
|
|
31
31
|
- gemfiles/rails41.gemfile
|
32
32
|
- gemfiles/rails42.gemfile
|
33
33
|
- gemfiles/rails50.gemfile
|
34
|
+
- gemfiles/rails51.gemfile
|
34
35
|
matrix:
|
35
36
|
include:
|
36
37
|
- rvm: 1.8.7
|
@@ -114,6 +115,8 @@ matrix:
|
|
114
115
|
gemfile: gemfiles/rails42.gemfile
|
115
116
|
- rvm: 1.8.7
|
116
117
|
gemfile: gemfiles/rails50.gemfile
|
118
|
+
- rvm: 1.8.7
|
119
|
+
gemfile: gemfiles/rails51.gemfile
|
117
120
|
- rvm: 1.9.2
|
118
121
|
gemfile: gemfiles/rails31.gemfile
|
119
122
|
- rvm: 1.9.2
|
@@ -126,12 +129,20 @@ matrix:
|
|
126
129
|
gemfile: gemfiles/rails42.gemfile
|
127
130
|
- rvm: 1.9.2
|
128
131
|
gemfile: gemfiles/rails50.gemfile
|
132
|
+
- rvm: 1.9.2
|
133
|
+
gemfile: gemfiles/rails51.gemfile
|
129
134
|
- rvm: 1.9.3
|
130
135
|
gemfile: gemfiles/rails50.gemfile
|
136
|
+
- rvm: 1.9.3
|
137
|
+
gemfile: gemfiles/rails51.gemfile
|
131
138
|
- rvm: 2.0.0
|
132
139
|
gemfile: gemfiles/rails50.gemfile
|
140
|
+
- rvm: 2.0.0
|
141
|
+
gemfile: gemfiles/rails51.gemfile
|
133
142
|
- rvm: 2.1.0
|
134
143
|
gemfile: gemfiles/rails50.gemfile
|
144
|
+
- rvm: 2.1.0
|
145
|
+
gemfile: gemfiles/rails51.gemfile
|
135
146
|
- rvm: 2.2.2
|
136
147
|
gemfile: gemfiles/rails30.gemfile
|
137
148
|
- rvm: 2.2.2
|
@@ -162,6 +173,8 @@ matrix:
|
|
162
173
|
gemfile: gemfiles/rails42.gemfile
|
163
174
|
- rvm: jruby-19mode
|
164
175
|
gemfile: gemfiles/rails50.gemfile
|
176
|
+
- rvm: jruby-19mode
|
177
|
+
gemfile: gemfiles/rails51.gemfile
|
165
178
|
- rvm: rbx
|
166
179
|
gemfile: gemfiles/rails30.gemfile
|
167
180
|
- rvm: rbx
|
@@ -176,3 +189,5 @@ matrix:
|
|
176
189
|
gemfile: gemfiles/rails42.gemfile
|
177
190
|
- rvm: rbx
|
178
191
|
gemfile: gemfiles/rails50.gemfile
|
192
|
+
- rvm: rbx
|
193
|
+
gemfile: gemfiles/rails51.gemfile
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 2.15.6
|
4
|
+
- Update rollbar.js snippet to `v2.3.8` [#680](https://github.com/rollbar/rollbar-gem/issues/680)
|
5
|
+
- Update `delayed_job` dependency to `4.1.3` [#672](https://github.com/rollbar/rollbar-gem/issues/672)
|
6
|
+
- Add rollbar.js snippet on all responses regardless of status code [#664](https://github.com/rollbar/rollbar-gem/issues/664)
|
7
|
+
- Add documentation for `sinatra/namespace` vs `rake` conflict to `README.md` [#663](https://github.com/rollbar/rollbar-gem/issues/663)
|
8
|
+
- Add `aws-sdk-sqs` gem dependency [#659](https://github.com/rollbar/rollbar-gem/issues/659)
|
9
|
+
- Upgrade `rails` gem dependency to `4.2.7.1` [#656](https://github.com/rollbar/rollbar-gem/issues/656)
|
10
|
+
- Add documentation note for usage of `Rollbar.scope!` to `README.md` [#653](https://github.com/rollbar/rollbar-gem/issues/653)
|
11
|
+
- Add example of using `Grape` to deal with `500` responses status [#645](https://github.com/rollbar/rollbar-gem/issues/645)
|
12
|
+
- Always report errors from `delayed_job` to deal with `dj_threshold > 0` edge case [#615](https://github.com/rollbar/rollbar-gem/issues/615)
|
13
|
+
|
3
14
|
## 2.15.5
|
4
15
|
|
5
16
|
- Support proxies [#626](https://github.com/rollbar/rollbar-gem/pull/626)
|
data/Gemfile
CHANGED
@@ -7,7 +7,7 @@ is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && RUBY_ENGINE == '
|
|
7
7
|
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
8
8
|
gem 'appraisal'
|
9
9
|
gem 'jruby-openssl', :platform => :jruby
|
10
|
-
gem 'rails', '4.2.
|
10
|
+
gem 'rails', '4.2.7.1'
|
11
11
|
gem 'rake'
|
12
12
|
gem 'rspec-rails', '~> 3.4'
|
13
13
|
gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
|
@@ -33,6 +33,7 @@ elsif RUBY_VERSION.start_with?('2')
|
|
33
33
|
gem 'sucker_punch', '~> 2.0'
|
34
34
|
end
|
35
35
|
|
36
|
+
gem 'aws-sdk-sqs'
|
36
37
|
gem 'database_cleaner', '~> 1.0.0'
|
37
38
|
gem 'delayed_job', :require => false
|
38
39
|
gem 'generator_spec'
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Rollbar [![Build Status](https://api.travis-ci.org/rollbar/rollbar-gem.svg?branch=
|
1
|
+
# Rollbar [![Build Status](https://api.travis-ci.org/rollbar/rollbar-gem.svg?branch=master)](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.
|
@@ -26,7 +26,7 @@ $ gem install rollbar
|
|
26
26
|
Unless you are using JRuby, we suggest also installing [Oj](https://github.com/ohler55/oj) for JSON serialization. Add this line to your Gemfile:
|
27
27
|
|
28
28
|
```ruby
|
29
|
-
gem 'oj', '~> 2.
|
29
|
+
gem 'oj', '~> 2.16.1'
|
30
30
|
```
|
31
31
|
|
32
32
|
and then `bundle install` again.
|
@@ -61,6 +61,21 @@ $ heroku config:add ROLLBAR_ACCESS_TOKEN=POST_SERVER_ITEM_ACCESS_TOKEN
|
|
61
61
|
|
62
62
|
That's all you need to use Rollbar with Rails.
|
63
63
|
|
64
|
+
#### Grape
|
65
|
+
|
66
|
+
To capture 500s inside the API gem "Grape" for Rails applications, add the following as a global exception handler:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
rescue_from :all do |e|
|
70
|
+
if Rails.env.development?
|
71
|
+
raise e
|
72
|
+
else
|
73
|
+
Rollbar.error(e)
|
74
|
+
error_response(message: "Internal server error", status: 500)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
```
|
78
|
+
|
64
79
|
|
65
80
|
### Sinatra
|
66
81
|
|
@@ -85,7 +100,27 @@ class MyApp < Sinatra::Base
|
|
85
100
|
# ...
|
86
101
|
end
|
87
102
|
```
|
103
|
+
#### Note
|
104
|
+
There is a known conflict between Sinatra and other gems where Sinatra's top-level-binded methods get overriden by other gems (more details here: https://github.com/sinatra/sinatra-contrib/issues/111 and https://github.com/rollbar/rollbar-gem/issues/663). This came to attention when using `sinatra/namespace` and `Rollbar.configure`. If your top-level-binded methods get overshadowed by other gems, like `Rake::DSL.namespace`, you will need to redefine the method manually as intended by Sinatra.
|
88
105
|
|
106
|
+
Here is an example if you want to use `sinatra/namespace`:
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
configure do
|
110
|
+
Rollbar.configure do |config|
|
111
|
+
...
|
112
|
+
end
|
113
|
+
|
114
|
+
# Redefine :namespace to use Sinatra's :namespace method
|
115
|
+
self.instance_eval do
|
116
|
+
undef :namespace
|
117
|
+
|
118
|
+
define_singleton_method(:namespace) do |*args, &block|
|
119
|
+
Sinatra::Delegator.target.send(:namespace, *args, &block)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
```
|
89
124
|
|
90
125
|
### Rack
|
91
126
|
|
@@ -323,6 +358,7 @@ class NotificationJob
|
|
323
358
|
end
|
324
359
|
```
|
325
360
|
|
361
|
+
Note: if you are using `Rollbar.scope!` within a scoped block, your context will only apply within that scoped block because of how Rollbar gets shadowed.
|
326
362
|
|
327
363
|
## Person tracking
|
328
364
|
|
@@ -466,7 +502,7 @@ config.scrub_fields = :scrub_all
|
|
466
502
|
|
467
503
|
## Including additional runtime data
|
468
504
|
|
469
|
-
You can provide a callable 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.
|
505
|
+
You can provide a callable that will be called for each exception or message report. ```custom_data_method``` should be a lambda that either takes no arguments or takes three arguments (message, exception, context) and returns a hash.
|
470
506
|
|
471
507
|
Add the following in ```config/initializers/rollbar.rb```:
|
472
508
|
|
@@ -476,10 +512,80 @@ config.custom_data_method = lambda {
|
|
476
512
|
}
|
477
513
|
```
|
478
514
|
|
515
|
+
Or
|
516
|
+
|
517
|
+
```ruby
|
518
|
+
config.custom_data_method = lambda{ |message, exception, context|
|
519
|
+
{ :some_key => :some_value, :complex_key => {:a => 1, :b => [2, 3, 4]} }
|
520
|
+
}
|
521
|
+
```
|
522
|
+
|
479
523
|
This data will appear in the Occurrences tab and on the Occurrence Detail pages in the Rollbar interface.
|
480
524
|
|
481
525
|
If your `custom_data_method` crashes while reporting an error, Rollbar will report that new error and will attach its uuid URL to the parent error report.
|
482
526
|
|
527
|
+
`context` for your `custom_data_method` is the value passed in the `:custom_data_method_context` key of your `log` method's `extra_data` argument. Note that once the value is passed as `context` it is removed from your `extra_data` and will be not be included in your `extra` by default.
|
528
|
+
|
529
|
+
```ruby
|
530
|
+
config.custom_data_method = lambda { |message, exception, context|
|
531
|
+
{
|
532
|
+
fully_qualified_controller_name: "MyApp::" + context[:controller_name]
|
533
|
+
}
|
534
|
+
}
|
535
|
+
|
536
|
+
Rollbar.log(
|
537
|
+
"error",
|
538
|
+
"Simple message",
|
539
|
+
{
|
540
|
+
extra_data_1: "some value",
|
541
|
+
custom_data_method_context: {
|
542
|
+
controller_name: "ExampleController"
|
543
|
+
}
|
544
|
+
}
|
545
|
+
)
|
546
|
+
```
|
547
|
+
|
548
|
+
The above example will result in the following `extra`:
|
549
|
+
|
550
|
+
```ruby
|
551
|
+
{
|
552
|
+
extra_data_1: "some value",
|
553
|
+
fully_qualified_controller_name: "MyApp::ExampleController"
|
554
|
+
}
|
555
|
+
```
|
556
|
+
|
557
|
+
As you can see, the `custom_data_method_context` will not be directly included in your `extra`.
|
558
|
+
|
559
|
+
Below is an example usage in a Rails application:
|
560
|
+
|
561
|
+
```ruby
|
562
|
+
# config/initializers/rollbar.rb
|
563
|
+
Rollbar.configure do |config|
|
564
|
+
...
|
565
|
+
|
566
|
+
config.custom_data_method = lambda do |message, exception, context|
|
567
|
+
{ controller_name: context[:controller].controller_name }
|
568
|
+
end
|
569
|
+
end
|
570
|
+
```
|
571
|
+
|
572
|
+
```ruby
|
573
|
+
# app/controller/welcome_controller.rb
|
574
|
+
class WelcomeController < ApplicationController
|
575
|
+
def check_context
|
576
|
+
Rollbar.log(
|
577
|
+
'info',
|
578
|
+
'This is a message from Welcome#check_context',
|
579
|
+
{
|
580
|
+
custom_data_method_context: {
|
581
|
+
controller: self
|
582
|
+
}
|
583
|
+
}
|
584
|
+
)
|
585
|
+
end
|
586
|
+
end
|
587
|
+
```
|
588
|
+
|
483
589
|
## Exception level filters
|
484
590
|
|
485
591
|
By default, all uncaught exceptions are reported at the "error" level, except for the following, which are reported at "warning" level:
|
@@ -778,7 +884,7 @@ ENV['AWS_ACCESS_KEY_ID'] = 'xxx'
|
|
778
884
|
ENV['AWS_SECRET_ACCESS_KEY'] = 'xxx'
|
779
885
|
ENV['AWS_REGION'] = 'xxx'
|
780
886
|
```
|
781
|
-
Read more about [Shoryuken configuration]https://github.com/phstc/shoryuken/wiki/Shoryuken-options
|
887
|
+
Read more about [Shoryuken configuration](https://github.com/phstc/shoryuken/wiki/Shoryuken-options).
|
782
888
|
|
783
889
|
Also create the SQS channels equals to your environments, as follows:
|
784
890
|
The queues to report will be equal to ```rollbar_{CURRENT_ENVIRONMENT}``` ex: if the project runs in staging environment the SQS to throw messages to will be equal to ```rollbar_staging```
|
@@ -900,15 +1006,26 @@ First, move your `config/initializers/rollbar.rb` file to `config/rollbar.rb`. T
|
|
900
1006
|
require File.expand_path('../application', __FILE__)
|
901
1007
|
require File.expand_path('../rollbar', __FILE__)
|
902
1008
|
|
1009
|
+
notify = ->(e) do
|
1010
|
+
begin
|
1011
|
+
Rollbar.with_config(use_async: false) do
|
1012
|
+
Rollbar.error(e)
|
1013
|
+
end
|
1014
|
+
rescue
|
1015
|
+
Rails.logger.error "Synchronous Rollbar notification failed. Sending async to preserve info"
|
1016
|
+
Rollbar.error(e)
|
1017
|
+
end
|
1018
|
+
end
|
1019
|
+
|
903
1020
|
begin
|
904
1021
|
Rails.application.initialize!
|
905
1022
|
rescue Exception => e
|
906
|
-
|
1023
|
+
notify.(e)
|
907
1024
|
raise
|
908
1025
|
end
|
909
1026
|
```
|
910
1027
|
|
911
|
-
How this works: first, Rollbar config (which is now at `config/rollbar.rb` is required). Later, `Rails.application/initialize` statement is wrapped with a `begin/rescue` and any exceptions within will be reported to Rollbar.
|
1028
|
+
How this works: first, Rollbar config (which is now at `config/rollbar.rb` is required). Later, `Rails.application/initialize` statement is wrapped with a `begin/rescue` and any exceptions within will be reported to Rollbar. We first try to send the notification synchronously since, with our app failing to boot, it is likely the async handler relies on the app booting, and will not process the notification.
|
912
1029
|
|
913
1030
|
## Rails runner command
|
914
1031
|
|
@@ -939,6 +1056,12 @@ set :rollbar_env, Proc.new { fetch :stage }
|
|
939
1056
|
set :rollbar_role, Proc.new { :app }
|
940
1057
|
```
|
941
1058
|
|
1059
|
+
If you want to upload sourcemaps to Rollbar on each deployment, then you also need to specify `rollbar_sourcemaps_minified_url_base`, where `rollbar_sourcemaps_minified_url_base` is your asset host.
|
1060
|
+
|
1061
|
+
```ruby
|
1062
|
+
set :rollbar_sourcemaps_minified_url_base, "https://www.my-site.com"
|
1063
|
+
```
|
1064
|
+
|
942
1065
|
NOTE: We've seen problems with Capistrano version `3.0.x` where the revision reported is incorrect. Version `3.1.0` and higher works correctly.
|
943
1066
|
|
944
1067
|
### Capistrano 2
|
data/data/rollbar.snippet.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(r){function
|
1
|
+
!function(r){function e(n){if(o[n])return o[n].exports;var t=o[n]={exports:{},id:n,loaded:!1};return r[n].call(t.exports,t,t.exports,e),t.loaded=!0,t.exports}var o={};return e.m=r,e.c=o,e.p="",e(0)}([function(r,e,o){"use strict";var n=o(1),t=o(4);_rollbarConfig=_rollbarConfig||{},_rollbarConfig.rollbarJsUrl=_rollbarConfig.rollbarJsUrl||"https://cdnjs.cloudflare.com/ajax/libs/rollbar.js/2.3.8/rollbar.min.js",_rollbarConfig.async=void 0===_rollbarConfig.async||_rollbarConfig.async;var a=n.setupShim(window,_rollbarConfig),l=t(_rollbarConfig);window.rollbar=n.Rollbar,a.loadFull(window,document,!_rollbarConfig.async,_rollbarConfig,l)},function(r,e,o){"use strict";function n(r){return function(){try{return r.apply(this,arguments)}catch(r){try{console.error("[Rollbar]: Internal error",r)}catch(r){}}}}function t(r,e){this.options=r,this._rollbarOldOnError=null;var o=s++;this.shimId=function(){return o},"undefined"!=typeof window&&window._rollbarShims&&(window._rollbarShims[o]={handler:e,messages:[]})}function a(r,e){if(r){var o=e.globalAlias||"Rollbar";if("object"==typeof r[o])return r[o];r._rollbarShims={},r._rollbarWrappedError=null;var t=new p(e);return n(function(){e.captureUncaught&&(t._rollbarOldOnError=r.onerror,i.captureUncaughtExceptions(r,t,!0),i.wrapGlobals(r,t,!0)),e.captureUnhandledRejections&&i.captureUnhandledRejections(r,t,!0);var n=e.autoInstrument;return e.enabled!==!1&&(void 0===n||n===!0||"object"==typeof n&&n.network)&&r.addEventListener&&(r.addEventListener("load",t.captureLoad.bind(t)),r.addEventListener("DOMContentLoaded",t.captureDomContentLoaded.bind(t))),r[o]=t,t})()}}function l(r){return n(function(){var e=this,o=Array.prototype.slice.call(arguments,0),n={shim:e,method:r,args:o,ts:new Date};window._rollbarShims[this.shimId()].messages.push(n)})}var i=o(2),s=0,d=o(3),c=function(r,e){return new t(r,e)},p=d.bind(null,c);t.prototype.loadFull=function(r,e,o,t,a){var l=function(){var e;if(void 0===r._rollbarDidLoad){e=new Error("rollbar.js did not load");for(var o,n,t,l,i=0;o=r._rollbarShims[i++];)for(o=o.messages||[];n=o.shift();)for(t=n.args||[],i=0;i<t.length;++i)if(l=t[i],"function"==typeof l){l(e);break}}"function"==typeof a&&a(e)},i=!1,s=e.createElement("script"),d=e.getElementsByTagName("script")[0],c=d.parentNode;s.crossOrigin="",s.src=t.rollbarJsUrl,o||(s.async=!0),s.onload=s.onreadystatechange=n(function(){if(!(i||this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState)){s.onload=s.onreadystatechange=null;try{c.removeChild(s)}catch(r){}i=!0,l()}}),c.insertBefore(s,d)},t.prototype.wrap=function(r,e,o){try{var n;if(n="function"==typeof e?e:function(){return e||{}},"function"!=typeof r)return r;if(r._isWrap)return r;if(!r._rollbar_wrapped&&(r._rollbar_wrapped=function(){o&&"function"==typeof o&&o.apply(this,arguments);try{return r.apply(this,arguments)}catch(o){var e=o;throw"string"==typeof e&&(e=new String(e)),e._rollbarContext=n()||{},e._rollbarContext._wrappedSource=r.toString(),window._rollbarWrappedError=e,e}},r._rollbar_wrapped._isWrap=!0,r.hasOwnProperty))for(var t in r)r.hasOwnProperty(t)&&(r._rollbar_wrapped[t]=r[t]);return r._rollbar_wrapped}catch(e){return r}};for(var u="log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleUnhandledRejection,captureEvent,captureDomContentLoaded,captureLoad".split(","),f=0;f<u.length;++f)t.prototype[u[f]]=l(u[f]);r.exports={setupShim:a,Rollbar:p}},function(r,e){"use strict";function o(r,e,o){if(r){var t;"function"==typeof e._rollbarOldOnError?t=e._rollbarOldOnError:r.onerror&&!r.onerror.belongsToShim&&(t=r.onerror,e._rollbarOldOnError=t);var a=function(){var o=Array.prototype.slice.call(arguments,0);n(r,e,t,o)};a.belongsToShim=o,r.onerror=a}}function n(r,e,o,n){r._rollbarWrappedError&&(n[4]||(n[4]=r._rollbarWrappedError),n[5]||(n[5]=r._rollbarWrappedError._rollbarContext),r._rollbarWrappedError=null),e.handleUncaughtException.apply(e,n),o&&o.apply(r,n)}function t(r,e,o){if(r){"function"==typeof r._rollbarURH&&r._rollbarURH.belongsToShim&&r.removeEventListener("unhandledrejection",r._rollbarURH);var n=function(r){var o,n,t;try{o=r.reason}catch(r){o=void 0}try{n=r.promise}catch(r){n="[unhandledrejection] error getting `promise` from event"}try{t=r.detail,!o&&t&&(o=t.reason,n=t.promise)}catch(r){t="[unhandledrejection] error getting `detail` from event"}o||(o="[unhandledrejection] error getting `reason` from event"),e&&e.handleUnhandledRejection&&e.handleUnhandledRejection(o,n)};n.belongsToShim=o,r._rollbarURH=n,r.addEventListener("unhandledrejection",n)}}function a(r,e,o){if(r){var n,t,a="EventTarget,Window,Node,ApplicationCache,AudioTrackList,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload".split(",");for(n=0;n<a.length;++n)t=a[n],r[t]&&r[t].prototype&&l(e,r[t].prototype,o)}}function l(r,e,o){if(e.hasOwnProperty&&e.hasOwnProperty("addEventListener")){for(var n=e.addEventListener;n._rollbarOldAdd&&n.belongsToShim;)n=n._rollbarOldAdd;var t=function(e,o,t){n.call(this,e,r.wrap(o),t)};t._rollbarOldAdd=n,t.belongsToShim=o,e.addEventListener=t;for(var a=e.removeEventListener;a._rollbarOldRemove&&a.belongsToShim;)a=a._rollbarOldRemove;var l=function(r,e,o){a.call(this,r,e&&e._rollbar_wrapped||e,o)};l._rollbarOldRemove=a,l.belongsToShim=o,e.removeEventListener=l}}r.exports={captureUncaughtExceptions:o,captureUnhandledRejections:t,wrapGlobals:a}},function(r,e){"use strict";function o(r,e){this.impl=r(e,this),this.options=e,n(o.prototype)}function n(r){for(var e=function(r){return function(){var e=Array.prototype.slice.call(arguments,0);if(this.impl[r])return this.impl[r].apply(this.impl,e)}},o="log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleUnhandledRejection,_createItem,wrap,loadFull,shimId,captureEvent,captureDomContentLoaded,captureLoad".split(","),n=0;n<o.length;n++)r[o[n]]=e(o[n])}o.prototype._swapAndProcessMessages=function(r,e){this.impl=r(this.options);for(var o,n,t;o=e.shift();)n=o.method,t=o.args,this[n]&&"function"==typeof this[n]&&("captureDomContentLoaded"===n||"captureLoad"===n?this[n].apply(this,[t[0],o.ts]):this[n].apply(this,t));return this},r.exports=o},function(r,e){"use strict";r.exports=function(r){return function(e){if(!e&&!window._rollbarInitialized){r=r||{};for(var o,n,t=r.globalAlias||"Rollbar",a=window.rollbar,l=function(r){return new a(r)},i=0;o=window._rollbarShims[i++];)n||(n=o.handler),o.handler._swapAndProcessMessages(l,o.messages);window[t]=n,window._rollbarInitialized=!0}}}}]);
|
data/gemfiles/rails42.gemfile
CHANGED
@@ -8,7 +8,7 @@ is_not_jruby = !is_jruby
|
|
8
8
|
gem 'appraisal'
|
9
9
|
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
10
10
|
gem 'jruby-openssl', :platform => :jruby
|
11
|
-
gem 'rails', '4.2.
|
11
|
+
gem 'rails', '4.2.7.1'
|
12
12
|
gem 'rake'
|
13
13
|
gem 'rspec-rails', '~> 3.4'
|
14
14
|
gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rubygems/version'
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && 'jruby' == RUBY_ENGINE)
|
6
|
+
|
7
|
+
gem 'appraisal'
|
8
|
+
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
9
|
+
gem 'jruby-openssl', :platform => :jruby
|
10
|
+
gem 'rails', '~> 5.1.0'
|
11
|
+
gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
|
12
|
+
|
13
|
+
gem 'rspec-core', '~> 3.5.0.beta3'
|
14
|
+
gem 'rspec-rails', '~> 3.5.0.beta3'
|
15
|
+
gem 'rspec-support', '~> 3.5.0.beta3'
|
16
|
+
gem 'rspec-expectations', '~> 3.5.0.beta3'
|
17
|
+
gem 'rspec-mocks', '~> 3.5.0.beta3'
|
18
|
+
|
19
|
+
gem 'rake'
|
20
|
+
|
21
|
+
gem 'oj', '~> 2.16.1' unless is_jruby
|
22
|
+
if RUBY_VERSION > '1.8.7' && RUBY_VERSION < '2.2.2'
|
23
|
+
gem 'sidekiq', '>= 2.13.0', '< 5.0'
|
24
|
+
else
|
25
|
+
gem 'sidekiq', '>= 2.13.0'
|
26
|
+
end
|
27
|
+
|
28
|
+
platforms :rbx do
|
29
|
+
gem 'minitest'
|
30
|
+
gem 'racc'
|
31
|
+
gem 'rubinius-developer_tools'
|
32
|
+
gem 'rubysl', '~> 2.0' unless RUBY_VERSION.start_with?('1')
|
33
|
+
end
|
34
|
+
|
35
|
+
if RUBY_VERSION.start_with?('1.9')
|
36
|
+
gem 'sucker_punch', '~> 1.0'
|
37
|
+
elsif RUBY_VERSION.start_with?('2')
|
38
|
+
gem 'sucker_punch', '~> 2.0'
|
39
|
+
end
|
40
|
+
|
41
|
+
# We need last sinatra that uses rack 2.x
|
42
|
+
gem 'sinatra', :git => 'https://github.com/sinatra/sinatra'
|
43
|
+
|
44
|
+
gem 'codeclimate-test-reporter', :group => :test, :require => nil
|
45
|
+
gem 'database_cleaner', '~> 1.x'
|
46
|
+
gem 'delayed_job', :require => false
|
47
|
+
gem 'generator_spec'
|
48
|
+
gem 'girl_friday', '>= 0.11.1'
|
49
|
+
gem 'redis'
|
50
|
+
gem 'resque'
|
51
|
+
|
52
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0')
|
53
|
+
gem 'mime-types', '< 3.0'
|
54
|
+
end
|
55
|
+
|
56
|
+
gem 'webmock', :require => false
|
57
|
+
|
58
|
+
gemspec :path => '../'
|
data/lib/rollbar.rb
CHANGED
data/lib/rollbar/item.rb
CHANGED
@@ -26,11 +26,13 @@ module Rollbar
|
|
26
26
|
attr_reader :message
|
27
27
|
attr_reader :exception
|
28
28
|
attr_reader :extra
|
29
|
-
|
29
|
+
|
30
30
|
attr_reader :configuration
|
31
31
|
attr_reader :scope
|
32
32
|
attr_reader :logger
|
33
33
|
attr_reader :notifier
|
34
|
+
|
35
|
+
attr_reader :context
|
34
36
|
|
35
37
|
def_delegators :payload, :[]
|
36
38
|
|
@@ -52,6 +54,7 @@ module Rollbar
|
|
52
54
|
@scope = options[:scope]
|
53
55
|
@payload = nil
|
54
56
|
@notifier = options[:notifier]
|
57
|
+
@context = options[:context]
|
55
58
|
end
|
56
59
|
|
57
60
|
def payload
|
@@ -165,7 +168,12 @@ module Rollbar
|
|
165
168
|
end
|
166
169
|
|
167
170
|
def custom_data
|
168
|
-
|
171
|
+
if configuration.custom_data_method.arity == 3
|
172
|
+
data = configuration.custom_data_method.call(message, exception, context)
|
173
|
+
else
|
174
|
+
data = configuration.custom_data_method.call
|
175
|
+
end
|
176
|
+
|
169
177
|
Rollbar::Util.deep_copy(data)
|
170
178
|
rescue => e
|
171
179
|
return {} if configuration.safely?
|
data/lib/rollbar/logger.rb
CHANGED
@@ -28,7 +28,7 @@ module Rollbar
|
|
28
28
|
|
29
29
|
message ||= block_given? ? yield : progname
|
30
30
|
|
31
|
-
return true if
|
31
|
+
return true if blank?(message)
|
32
32
|
|
33
33
|
rollbar.log(rollbar_level(severity), message)
|
34
34
|
end
|
@@ -65,6 +65,11 @@ module Rollbar
|
|
65
65
|
|
66
66
|
private
|
67
67
|
|
68
|
+
def blank?(message)
|
69
|
+
return message.blank? if message.respond_to?(:blank?)
|
70
|
+
message.respond_to?(:empty?) ? !!message.empty? : !message
|
71
|
+
end
|
72
|
+
|
68
73
|
# Find correct Rollbar level to use using the indexes in Logger::Severity
|
69
74
|
# DEBUG = 0
|
70
75
|
# INFO = 1
|