rollbar 2.20.2 → 2.22.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.travis.yml +19 -7
- data/Gemfile +18 -12
- data/data/rollbar.snippet.js +1 -1
- data/gemfiles/rails30.gemfile +0 -8
- data/gemfiles/rails31.gemfile +0 -8
- data/gemfiles/rails32.gemfile +0 -8
- data/gemfiles/rails40.gemfile +0 -8
- data/gemfiles/rails41.gemfile +0 -8
- data/gemfiles/rails42.gemfile +0 -10
- data/gemfiles/rails50.gemfile +0 -10
- data/gemfiles/rails51.gemfile +0 -10
- data/gemfiles/rails52.gemfile +0 -10
- data/gemfiles/rails60.gemfile +67 -0
- data/lib/rollbar/configuration.rb +35 -1
- data/lib/rollbar/item.rb +22 -1
- data/lib/rollbar/json.rb +2 -51
- data/lib/rollbar/notifier.rb +3 -3
- data/lib/rollbar/plugins/basic_socket.rb +1 -1
- data/lib/rollbar/rake_tasks.rb +3 -147
- data/lib/rollbar/rollbar_test.rb +147 -0
- data/lib/rollbar/truncation.rb +3 -1
- data/lib/rollbar/truncation/remove_any_key_strategy.rb +123 -0
- data/lib/rollbar/util.rb +2 -2
- data/lib/rollbar/util/hash.rb +15 -0
- data/lib/rollbar/version.rb +1 -1
- data/rollbar.gemspec +0 -2
- metadata +8 -20
- data/lib/rollbar/json/default.rb +0 -11
- data/lib/rollbar/json/oj.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c56a90107593b66c2be899fd4f36abe3ad657abcd0e2d822964efbc8e47efdbb
|
4
|
+
data.tar.gz: cd95d87f45d3e65f3dc499c9be88c3c18b84ccd359eda34ed2ab88e941909754
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6fe31a226014d67e1225234e408030b1e9bab112973e3a312607e26c71c98e6c64d56d7ea2163e0d1cfdd5af3755c384e15c6e11c3166f9478b384f4c0a512f
|
7
|
+
data.tar.gz: 12c63a9346dc60827b7b5765b6e63ce9d5c814fdb90c0e685952e4751669bb0f0770344830d625070cac6d656958f6bbd2862522cd7d51d1e0cae039bfd0efb5
|
data/.rubocop.yml
CHANGED
@@ -61,3 +61,8 @@ Style/CaseEquality:
|
|
61
61
|
# or a string and `str1 =~ str2` isn't valid. Whoever enables this cop should carefully
|
62
62
|
# review and test each of these.
|
63
63
|
Enabled: false
|
64
|
+
|
65
|
+
Style/FrozenStringLiteralComment:
|
66
|
+
# If we do this, it will be in its own PR. It requires adding these magic comments
|
67
|
+
# throughout the project, in order to prepare for a future Ruby 3.x.
|
68
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -21,7 +21,9 @@ rvm:
|
|
21
21
|
- 2.6.0
|
22
22
|
- 2.6.3
|
23
23
|
- rbx
|
24
|
-
|
24
|
+
# Travis's own rvm installer is failing on JRuby builds, TODO: reenable when fixed.
|
25
|
+
# - jruby-9.1.9.0
|
26
|
+
|
25
27
|
#
|
26
28
|
# # About legacy JRuby
|
27
29
|
#
|
@@ -64,6 +66,7 @@ gemfile:
|
|
64
66
|
- gemfiles/rails50.gemfile
|
65
67
|
- gemfiles/rails51.gemfile
|
66
68
|
- gemfiles/rails52.gemfile
|
69
|
+
- gemfiles/rails60.gemfile
|
67
70
|
matrix:
|
68
71
|
include: []
|
69
72
|
|
@@ -147,6 +150,13 @@ matrix:
|
|
147
150
|
- rvm: rbx
|
148
151
|
jdk: oraclejdk9
|
149
152
|
|
153
|
+
# Rails 6.x requires Ruby 2.5.0 or higher
|
154
|
+
- rvm: 2.2.2
|
155
|
+
gemfile: gemfiles/rails60.gemfile
|
156
|
+
- rvm: 2.3.8
|
157
|
+
gemfile: gemfiles/rails60.gemfile
|
158
|
+
- rvm: 2.4.5
|
159
|
+
gemfile: gemfiles/rails60.gemfile
|
150
160
|
# Rails 5.x requires Ruby 2.2.2 or higher
|
151
161
|
- rvm: 1.9.3
|
152
162
|
gemfile: gemfiles/rails50.gemfile
|
@@ -154,6 +164,8 @@ matrix:
|
|
154
164
|
gemfile: gemfiles/rails51.gemfile
|
155
165
|
- rvm: 1.9.3
|
156
166
|
gemfile: gemfiles/rails52.gemfile
|
167
|
+
- rvm: 1.9.3
|
168
|
+
gemfile: gemfiles/rails60.gemfile
|
157
169
|
# Rails 5.x requires Ruby 2.2.2 or higher
|
158
170
|
- rvm: 2.0.0
|
159
171
|
gemfile: gemfiles/rails50.gemfile
|
@@ -161,6 +173,8 @@ matrix:
|
|
161
173
|
gemfile: gemfiles/rails51.gemfile
|
162
174
|
- rvm: 2.0.0
|
163
175
|
gemfile: gemfiles/rails52.gemfile
|
176
|
+
- rvm: 2.0.0
|
177
|
+
gemfile: gemfiles/rails60.gemfile
|
164
178
|
# Rails 5.x requires Ruby 2.2.2 or higher
|
165
179
|
- rvm: 2.1.0
|
166
180
|
gemfile: gemfiles/rails50.gemfile
|
@@ -168,18 +182,14 @@ matrix:
|
|
168
182
|
gemfile: gemfiles/rails51.gemfile
|
169
183
|
- rvm: 2.1.0
|
170
184
|
gemfile: gemfiles/rails52.gemfile
|
185
|
+
- rvm: 2.1.0
|
186
|
+
gemfile: gemfiles/rails60.gemfile
|
171
187
|
# MRI 2.2.2 supports Rails 3.2.x and higher
|
172
188
|
- rvm: 2.2.2
|
173
189
|
gemfile: gemfiles/rails30.gemfile
|
174
190
|
- rvm: 2.2.2
|
175
191
|
gemfile: gemfiles/rails31.gemfile
|
176
192
|
# MRI 2.3.x supports Rails 4.0.x and higher
|
177
|
-
- rvm: 2.3.0
|
178
|
-
gemfile: gemfiles/rails30.gemfile
|
179
|
-
- rvm: 2.3.0
|
180
|
-
gemfile: gemfiles/rails31.gemfile
|
181
|
-
- rvm: 2.3.0
|
182
|
-
gemfile: gemfiles/rails32.gemfile
|
183
193
|
- rvm: 2.3.8
|
184
194
|
gemfile: gemfiles/rails30.gemfile
|
185
195
|
- rvm: 2.3.8
|
@@ -267,3 +277,5 @@ matrix:
|
|
267
277
|
gemfile: gemfiles/rails51.gemfile
|
268
278
|
- rvm: rbx
|
269
279
|
gemfile: gemfiles/rails52.gemfile
|
280
|
+
- rvm: rbx
|
281
|
+
gemfile: gemfiles/rails60.gemfile
|
data/Gemfile
CHANGED
@@ -11,22 +11,24 @@ ENV['CURRENT_GEMFILE'] ||= __FILE__
|
|
11
11
|
|
12
12
|
is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby')
|
13
13
|
|
14
|
+
GEMFILE_RAILS_VERSION = '5.2.2'.freeze
|
15
|
+
|
14
16
|
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
15
17
|
gem 'appraisal'
|
16
18
|
gem 'jruby-openssl', :platform => :jruby
|
17
|
-
gem 'rails',
|
19
|
+
gem 'rails', GEMFILE_RAILS_VERSION
|
18
20
|
gem 'rake'
|
19
|
-
|
20
|
-
gem '
|
21
|
+
if GEMFILE_RAILS_VERSION < '6.0'
|
22
|
+
gem 'rspec-rails', '~> 3.4'
|
23
|
+
else
|
24
|
+
# TODO: update this when 4.x becomes available on Rubygems
|
25
|
+
gem 'rspec-rails', :git => 'https://github.com/rspec/rspec-rails', :ref => 'v4.0.0.beta2' # rubocop:disable Bundler/DuplicatedGem
|
26
|
+
end
|
21
27
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
gem 'oj', '~> 2.16.1' # rubocop:disable Bundler/DuplicatedGem
|
27
|
-
else
|
28
|
-
gem 'oj', '~> 2.12.14' # rubocop:disable Bundler/DuplicatedGem
|
29
|
-
end
|
28
|
+
if GEMFILE_RAILS_VERSION < '6.0'
|
29
|
+
gem 'sqlite3', '< 1.4.0', :platform => [:ruby, :mswin, :mingw]
|
30
|
+
else
|
31
|
+
gem 'sqlite3', '~> 1.4', :platform => [:ruby, :mswin, :mingw] # rubocop:disable Bundler/DuplicatedGem
|
30
32
|
end
|
31
33
|
|
32
34
|
if RUBY_VERSION < '2.2.2'
|
@@ -61,7 +63,11 @@ end
|
|
61
63
|
|
62
64
|
gem 'aws-sdk-sqs'
|
63
65
|
gem 'database_cleaner'
|
64
|
-
|
66
|
+
if GEMFILE_RAILS_VERSION < '6.0'
|
67
|
+
gem 'delayed_job', :require => false
|
68
|
+
else
|
69
|
+
gem 'delayed_job', '~> 4.1', :require => false # rubocop:disable Bundler/DuplicatedGem
|
70
|
+
end
|
65
71
|
gem 'generator_spec'
|
66
72
|
gem 'girl_friday', '>= 0.11.1'
|
67
73
|
gem 'redis'
|
data/data/rollbar.snippet.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(r){var e={};function o(n){if(e[n])return e[n].exports;var t=e[n]={i:n,l:!1,exports:{}};return r[n].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.m=r,o.c=e,o.d=function(r,e,n){o.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},o.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},o.t=function(r,e){if(1&e&&(r=o(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var t in r)o.d(n,t,function(e){return r[e]}.bind(null,t));return n},o.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return o.d(e,"a",e),e},o.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},o.p="",o(o.s=0)}([function(r,e,o){var n=o(1),t=o(4);_rollbarConfig=_rollbarConfig||{},_rollbarConfig.rollbarJsUrl=_rollbarConfig.rollbarJsUrl||"https://cdnjs.cloudflare.com/ajax/libs/rollbar.js/2.
|
1
|
+
!function(r){var e={};function o(n){if(e[n])return e[n].exports;var t=e[n]={i:n,l:!1,exports:{}};return r[n].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.m=r,o.c=e,o.d=function(r,e,n){o.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},o.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},o.t=function(r,e){if(1&e&&(r=o(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var t in r)o.d(n,t,function(e){return r[e]}.bind(null,t));return n},o.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return o.d(e,"a",e),e},o.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},o.p="",o(o.s=0)}([function(r,e,o){var n=o(1),t=o(4);_rollbarConfig=_rollbarConfig||{},_rollbarConfig.rollbarJsUrl=_rollbarConfig.rollbarJsUrl||"https://cdnjs.cloudflare.com/ajax/libs/rollbar.js/2.12.3/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){var n=o(2);function t(r){return function(){try{return r.apply(this,arguments)}catch(r){try{console.error("[Rollbar]: Internal error",r)}catch(r){}}}}var a=0;function l(r,e){this.options=r,this._rollbarOldOnError=null;var o=a++;this.shimId=function(){return o},"undefined"!=typeof window&&window._rollbarShims&&(window._rollbarShims[o]={handler:e,messages:[]})}var i=o(3),s=function(r,e){return new l(r,e)},d=function(r){return new i(s,r)};function c(r){return t(function(){var e=Array.prototype.slice.call(arguments,0),o={shim:this,method:r,args:e,ts:new Date};window._rollbarShims[this.shimId()].messages.push(o)})}l.prototype.loadFull=function(r,e,o,n,a){var l=!1,i=e.createElement("script"),s=e.getElementsByTagName("script")[0],d=s.parentNode;i.crossOrigin="",i.src=n.rollbarJsUrl,o||(i.async=!0),i.onload=i.onreadystatechange=t(function(){if(!(l||this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState)){i.onload=i.onreadystatechange=null;try{d.removeChild(i)}catch(r){}l=!0,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("function"==typeof(l=t[i])){l(e);break}}"function"==typeof a&&a(e)}()}}),d.insertBefore(i,s)},l.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 e&&("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 p="log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleAnonymousErrors,handleUnhandledRejection,captureEvent,captureDomContentLoaded,captureLoad".split(","),u=0;u<p.length;++u)l.prototype[p[u]]=c(p[u]);r.exports={setupShim:function(r,e){if(r){var o=e.globalAlias||"Rollbar";if("object"==typeof r[o])return r[o];r._rollbarShims={},r._rollbarWrappedError=null;var a=new d(e);return t(function(){e.captureUncaught&&(a._rollbarOldOnError=r.onerror,n.captureUncaughtExceptions(r,a,!0),e.wrapGlobalEventHandlers&&n.wrapGlobals(r,a,!0)),e.captureUnhandledRejections&&n.captureUnhandledRejections(r,a,!0);var t=e.autoInstrument;return!1!==e.enabled&&(void 0===t||!0===t||"object"==typeof t&&t.network)&&r.addEventListener&&(r.addEventListener("load",a.captureLoad.bind(a)),r.addEventListener("DOMContentLoaded",a.captureDomContentLoaded.bind(a))),r[o]=a,a})()}},Rollbar:d}},function(r,e){function o(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:function(r,e,o){if(r){var n;if("function"==typeof e._rollbarOldOnError)n=e._rollbarOldOnError;else if(r.onerror){for(n=r.onerror;n._rollbarOldOnError;)n=n._rollbarOldOnError;e._rollbarOldOnError=n}e.handleAnonymousErrors();var t=function(){var o=Array.prototype.slice.call(arguments,0);!function(r,e,o,n){r._rollbarWrappedError&&(n[4]||(n[4]=r._rollbarWrappedError),n[5]||(n[5]=r._rollbarWrappedError._rollbarContext),r._rollbarWrappedError=null);var t=e.handleUncaughtException.apply(e,n);o&&o.apply(r,n),"anonymous"===t&&(e.anonymousErrorsPending+=1)}(r,e,n,o)};o&&(t._rollbarOldOnError=n),r.onerror=t}},captureUnhandledRejections:function(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){}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)}},wrapGlobals:function(r,e,n){if(r){var t,a,l="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(t=0;t<l.length;++t)r[a=l[t]]&&r[a].prototype&&o(e,r[a].prototype,n)}}}},function(r,e){function o(r,e){this.impl=r(e,this),this.options=e,function(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,handleAnonymousErrors,handleUnhandledRejection,_createItem,wrap,loadFull,shimId,captureEvent,captureDomContentLoaded,captureLoad".split(","),n=0;n<o.length;n++)r[o[n]]=e(o[n])}(o.prototype)}o.prototype._swapAndProcessMessages=function(r,e){var o,n,t;for(this.impl=r(this.options);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){r.exports=function(r){return function(e){if(!e&&!window._rollbarInitialized){for(var o,n,t=(r=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/rails30.gemfile
CHANGED
@@ -20,14 +20,6 @@ gem 'hitimes', '< 1.2.2'
|
|
20
20
|
gem 'rake', '< 11'
|
21
21
|
gem 'rspec-rails', '>= 2.14.0'
|
22
22
|
|
23
|
-
unless is_jruby
|
24
|
-
if RUBY_VERSION >= '2.4.0'
|
25
|
-
gem 'oj', '~> 2.16.1'
|
26
|
-
else
|
27
|
-
gem 'oj', '~> 2.12.14'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
23
|
if RUBY_VERSION < '2.2.2'
|
32
24
|
gem 'sidekiq', '~> 2.13.0'
|
33
25
|
else
|
data/gemfiles/rails31.gemfile
CHANGED
@@ -19,14 +19,6 @@ gem 'rails', '3.1.12'
|
|
19
19
|
gem 'rspec-rails', '~> 3.4'
|
20
20
|
gem 'rake'
|
21
21
|
|
22
|
-
unless is_jruby
|
23
|
-
if RUBY_VERSION >= '2.4.0'
|
24
|
-
gem 'oj', '~> 2.16.1'
|
25
|
-
else
|
26
|
-
gem 'oj', '~> 2.12.14'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
22
|
if RUBY_VERSION < '2.2.2'
|
31
23
|
gem 'sidekiq', '~> 2.13.0'
|
32
24
|
else
|
data/gemfiles/rails32.gemfile
CHANGED
@@ -21,14 +21,6 @@ gem 'sqlite3', '< 1.4.0', :platform => [:ruby, :mswin, :mingw]
|
|
21
21
|
# Please see https://github.com/rspec/rspec-rails/issues/1273
|
22
22
|
gem 'test-unit'
|
23
23
|
|
24
|
-
unless is_jruby
|
25
|
-
if RUBY_VERSION >= '2.4.0'
|
26
|
-
gem 'oj', '~> 2.16.1'
|
27
|
-
else
|
28
|
-
gem 'oj', '~> 2.12.14'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
24
|
if RUBY_VERSION < '2.2.2'
|
33
25
|
gem 'sidekiq', '~> 2.13.0'
|
34
26
|
else
|
data/gemfiles/rails40.gemfile
CHANGED
@@ -21,14 +21,6 @@ gem 'sqlite3', '< 1.4.0', :platform => [:ruby, :mswin, :mingw]
|
|
21
21
|
# Please see https://github.com/rspec/rspec-rails/issues/1273
|
22
22
|
gem 'test-unit'
|
23
23
|
|
24
|
-
unless is_jruby
|
25
|
-
if RUBY_VERSION >= '2.4.0'
|
26
|
-
gem 'oj', '~> 2.16.1'
|
27
|
-
else
|
28
|
-
gem 'oj', '~> 2.12.14'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
24
|
if RUBY_VERSION < '2.2.2'
|
33
25
|
gem 'sidekiq', '~> 2.13.0'
|
34
26
|
else
|
data/gemfiles/rails41.gemfile
CHANGED
@@ -19,14 +19,6 @@ gem 'rake'
|
|
19
19
|
gem 'rspec-rails', '~> 3.4'
|
20
20
|
gem 'sqlite3', '< 1.4.0', :platform => [:ruby, :mswin, :mingw]
|
21
21
|
|
22
|
-
unless is_jruby
|
23
|
-
if RUBY_VERSION >= '2.4.0'
|
24
|
-
gem 'oj', '~> 2.16.1'
|
25
|
-
else
|
26
|
-
gem 'oj', '~> 2.12.14'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
22
|
if RUBY_VERSION < '2.2.2'
|
31
23
|
gem 'sidekiq', '~> 2.13.0'
|
32
24
|
else
|
data/gemfiles/rails42.gemfile
CHANGED
@@ -27,16 +27,6 @@ platforms :rbx do
|
|
27
27
|
gem 'rubysl', '~> 2.0' unless RUBY_VERSION.start_with?('1')
|
28
28
|
end
|
29
29
|
|
30
|
-
unless is_jruby
|
31
|
-
if RUBY_VERSION >= '2.5'
|
32
|
-
gem 'oj'
|
33
|
-
elsif RUBY_VERSION >= '2.4.0'
|
34
|
-
gem 'oj', '~> 2.16.1'
|
35
|
-
else
|
36
|
-
gem 'oj', '~> 2.12.14'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
30
|
if RUBY_VERSION < '2.2.2'
|
41
31
|
gem 'sidekiq', '~> 2.13.0'
|
42
32
|
else
|
data/gemfiles/rails50.gemfile
CHANGED
@@ -27,16 +27,6 @@ gem 'rake'
|
|
27
27
|
|
28
28
|
gem 'sidekiq', '>= 2.13.0'
|
29
29
|
|
30
|
-
unless is_jruby
|
31
|
-
if RUBY_VERSION >= '2.5'
|
32
|
-
gem 'oj'
|
33
|
-
elsif RUBY_VERSION >= '2.4.0'
|
34
|
-
gem 'oj', '~> 2.16.1'
|
35
|
-
else
|
36
|
-
gem 'oj', '~> 2.12.14'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
30
|
platforms :rbx do
|
41
31
|
gem 'minitest'
|
42
32
|
gem 'racc'
|
data/gemfiles/rails51.gemfile
CHANGED
@@ -27,16 +27,6 @@ gem 'rake'
|
|
27
27
|
|
28
28
|
gem 'sidekiq', '>= 2.13.0'
|
29
29
|
|
30
|
-
unless is_jruby
|
31
|
-
if RUBY_VERSION >= '2.5'
|
32
|
-
gem 'oj'
|
33
|
-
elsif RUBY_VERSION >= '2.4.0'
|
34
|
-
gem 'oj', '~> 2.16.1'
|
35
|
-
else
|
36
|
-
gem 'oj', '~> 2.12.14'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
30
|
platforms :rbx do
|
41
31
|
gem 'minitest'
|
42
32
|
gem 'racc'
|
data/gemfiles/rails52.gemfile
CHANGED
@@ -25,16 +25,6 @@ gem 'rspec-mocks', '~> 3.8.0'
|
|
25
25
|
|
26
26
|
gem 'rake'
|
27
27
|
|
28
|
-
unless is_jruby
|
29
|
-
if RUBY_VERSION >= '2.5'
|
30
|
-
gem 'oj'
|
31
|
-
elsif RUBY_VERSION >= '2.4.0'
|
32
|
-
gem 'oj', '~> 2.16.1'
|
33
|
-
else
|
34
|
-
gem 'oj', '~> 2.12.14'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
28
|
gem 'sidekiq', '>= 2.13.0'
|
39
29
|
|
40
30
|
platforms :rbx do
|
@@ -0,0 +1,67 @@
|
|
1
|
+
|
2
|
+
require 'rubygems/version'
|
3
|
+
|
4
|
+
source 'https://rubygems.org'
|
5
|
+
|
6
|
+
# Used by spec/commands/rollbar_rails_runner_spec, and can be used whenever a
|
7
|
+
# new process is created during tests. (Testing rake tasks, for example.)
|
8
|
+
# This is a workaround for ENV['BUNDLE_GEMFILE'] not working as expected on Travis.
|
9
|
+
# We use the ||= assignment because Travis loads the gemfile twice, the second time
|
10
|
+
# with the wrong gemfile path.
|
11
|
+
ENV['CURRENT_GEMFILE'] ||= __FILE__
|
12
|
+
|
13
|
+
is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && 'jruby' == RUBY_ENGINE)
|
14
|
+
|
15
|
+
gem 'appraisal'
|
16
|
+
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
17
|
+
gem 'jruby-openssl', :platform => :jruby
|
18
|
+
gem 'rails', '6.0.0.rc1'
|
19
|
+
gem 'sqlite3', '~> 1.4', :platform => [:ruby, :mswin, :mingw]
|
20
|
+
|
21
|
+
gem 'rspec-core', '~> 3.8.0'
|
22
|
+
gem 'rspec-support', '~> 3.8.0'
|
23
|
+
gem 'rspec-expectations', '~> 3.8.0'
|
24
|
+
gem 'rspec-mocks', '~> 3.8.0'
|
25
|
+
# TODO: update this when 4.x becomes available on Rubygems
|
26
|
+
gem 'rspec-rails', :git => 'https://github.com/rspec/rspec-rails', :ref => 'v4.0.0.beta2' # rubocop:disable Bundler/DuplicatedGem
|
27
|
+
|
28
|
+
gem 'rake'
|
29
|
+
|
30
|
+
gem 'sidekiq', '>= 2.13.0'
|
31
|
+
|
32
|
+
platforms :rbx do
|
33
|
+
gem 'minitest'
|
34
|
+
gem 'racc'
|
35
|
+
gem 'rubinius-developer_tools'
|
36
|
+
gem 'rubysl', '~> 2.0' unless RUBY_VERSION.start_with?('1')
|
37
|
+
end
|
38
|
+
|
39
|
+
gem 'sucker_punch', '~> 2.0'
|
40
|
+
|
41
|
+
# We need last sinatra that uses rack 2.x
|
42
|
+
gem 'sinatra', :git => 'https://github.com/sinatra/sinatra'
|
43
|
+
|
44
|
+
gem 'database_cleaner'
|
45
|
+
gem 'codacy-coverage'
|
46
|
+
gem 'delayed_job', '4.1.8.beta1', :require => false
|
47
|
+
gem 'generator_spec'
|
48
|
+
gem 'girl_friday', '>= 0.11.1'
|
49
|
+
gem 'redis'
|
50
|
+
gem 'resque'
|
51
|
+
gem 'simplecov'
|
52
|
+
|
53
|
+
unless is_jruby
|
54
|
+
# JRuby doesn't support fork, which is required for this test helper.
|
55
|
+
gem 'rspec-command'
|
56
|
+
end
|
57
|
+
|
58
|
+
gem 'mime-types'
|
59
|
+
|
60
|
+
gem 'webmock', :require => false
|
61
|
+
|
62
|
+
gem 'aws-sdk-sqs'
|
63
|
+
gem 'shoryuken'
|
64
|
+
|
65
|
+
gem 'capistrano', :require => false
|
66
|
+
|
67
|
+
gemspec :path => '../'
|
@@ -68,6 +68,7 @@ module Rollbar
|
|
68
68
|
attr_accessor :log_payload
|
69
69
|
|
70
70
|
attr_reader :project_gem_paths
|
71
|
+
attr_accessor :configured_options
|
71
72
|
|
72
73
|
alias safely? safely
|
73
74
|
|
@@ -114,7 +115,7 @@ module Rollbar
|
|
114
115
|
@locals = {}
|
115
116
|
@scrub_fields = [:passwd, :password, :password_confirmation, :secret,
|
116
117
|
:confirm_password, :password_confirmation, :secret_token,
|
117
|
-
:api_key, :access_token, :session_id]
|
118
|
+
:api_key, :access_token, :accessToken, :session_id]
|
118
119
|
@scrub_user = true
|
119
120
|
@scrub_password = true
|
120
121
|
@randomize_scrub_length = true
|
@@ -142,6 +143,8 @@ module Rollbar
|
|
142
143
|
:on_error_response => nil, # params: response
|
143
144
|
:on_report_internal_error => nil # params: exception
|
144
145
|
}
|
146
|
+
|
147
|
+
@configured_options = ConfiguredOptions.new(self)
|
145
148
|
end
|
146
149
|
|
147
150
|
def initialize_copy(orig)
|
@@ -153,6 +156,15 @@ module Rollbar
|
|
153
156
|
end
|
154
157
|
end
|
155
158
|
|
159
|
+
def wrapped_clone
|
160
|
+
original_clone.tap do |new_config|
|
161
|
+
new_config.configured_options = ConfiguredOptions.new(new_config)
|
162
|
+
new_config.configured_options.configured = configured_options.configured
|
163
|
+
end
|
164
|
+
end
|
165
|
+
alias original_clone clone
|
166
|
+
alias clone wrapped_clone
|
167
|
+
|
156
168
|
def merge(options)
|
157
169
|
new_configuration = clone
|
158
170
|
new_configuration.merge!(options)
|
@@ -303,4 +315,26 @@ module Rollbar
|
|
303
315
|
hook(symbol).call(*args) if hook(symbol).is_a?(Proc)
|
304
316
|
end
|
305
317
|
end
|
318
|
+
|
319
|
+
class ConfiguredOptions
|
320
|
+
attr_accessor :configuration, :configured
|
321
|
+
|
322
|
+
def initialize(configuration)
|
323
|
+
@configuration = configuration
|
324
|
+
@configured = {}
|
325
|
+
end
|
326
|
+
|
327
|
+
def method_missing(method, *args, &block)
|
328
|
+
return super unless configuration.respond_to?(method)
|
329
|
+
|
330
|
+
method_string = method.to_s
|
331
|
+
configured[method_string.chomp('=').to_sym] = args.first if method_string.end_with?('=')
|
332
|
+
|
333
|
+
configuration.send(method, *args, &block)
|
334
|
+
end
|
335
|
+
|
336
|
+
def respond_to_missing?(method)
|
337
|
+
configuration.respond_to?(method) || super
|
338
|
+
end
|
339
|
+
end
|
306
340
|
end
|
data/lib/rollbar/item.rb
CHANGED
@@ -84,7 +84,8 @@ module Rollbar
|
|
84
84
|
:server => server_data,
|
85
85
|
:notifier => {
|
86
86
|
:name => 'rollbar-gem',
|
87
|
-
:version => VERSION
|
87
|
+
:version => VERSION,
|
88
|
+
:configured_options => configured_options
|
88
89
|
},
|
89
90
|
:body => build_body
|
90
91
|
}
|
@@ -102,6 +103,26 @@ module Rollbar
|
|
102
103
|
data
|
103
104
|
end
|
104
105
|
|
106
|
+
def configured_options
|
107
|
+
if Gem.loaded_specs['activesupport'] && Gem.loaded_specs['activesupport'].version < Gem::Version.new('4.1')
|
108
|
+
# There are too many types that crash ActiveSupport JSON serialization, and not worth
|
109
|
+
# the risk just to send this diagnostic object. In versions < 4.1, ActiveSupport hooks
|
110
|
+
# Ruby's JSON.generate so deeply there's no workaround.
|
111
|
+
'not serialized in ActiveSupport < 4.1'
|
112
|
+
elsif configuration.use_async
|
113
|
+
# Currently serialization is performed by each handler, and this invariably
|
114
|
+
# means it is actually performed by ActiveSupport.
|
115
|
+
#
|
116
|
+
# TODO: Since serialization must be done prior to scheduling the job,
|
117
|
+
# it should at least be done by rollbar-gem itself. Much work has been done
|
118
|
+
# to avoid the bugs in ActiveSupport JSON. The async handlers are currently
|
119
|
+
# still subject to all those knnown issues.
|
120
|
+
'not serialized for async/delayed handlers'
|
121
|
+
else
|
122
|
+
scrub(configuration.configured_options.configured)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
105
126
|
def dump
|
106
127
|
# Ensure all keys are strings since we can receive the payload inline or
|
107
128
|
# from an async handler job, which can be serialized.
|
data/lib/rollbar/json.rb
CHANGED
@@ -1,13 +1,5 @@
|
|
1
|
-
require 'multi_json'
|
2
|
-
require 'rollbar/json/oj'
|
3
|
-
require 'rollbar/json/default'
|
4
1
|
require 'rollbar/language_support'
|
5
2
|
|
6
|
-
begin
|
7
|
-
require 'oj'
|
8
|
-
rescue LoadError
|
9
|
-
end
|
10
|
-
|
11
3
|
module Rollbar
|
12
4
|
module JSON # :nodoc:
|
13
5
|
extend self
|
@@ -15,54 +7,13 @@ module Rollbar
|
|
15
7
|
attr_writer :options_module
|
16
8
|
|
17
9
|
def dump(object)
|
18
|
-
# `basic_socket` plugin addresses the following issue: https://github.com/rollbar/rollbar-gem/issues/845
|
19
10
|
Rollbar.plugins.get('basic_socket').load_scoped!(true) do
|
20
|
-
|
11
|
+
::JSON.generate(object)
|
21
12
|
end
|
22
13
|
end
|
23
14
|
|
24
15
|
def load(string)
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
def with_adapter(&block)
|
29
|
-
MultiJson.with_adapter(detect_multi_json_adapter, &block)
|
30
|
-
end
|
31
|
-
|
32
|
-
def detect_multi_json_adapter
|
33
|
-
options = {}
|
34
|
-
options[:adapter] = :oj if defined?(::Oj)
|
35
|
-
|
36
|
-
MultiJson.current_adapter(options)
|
37
|
-
end
|
38
|
-
|
39
|
-
def adapter_options
|
40
|
-
options_module.options
|
41
|
-
end
|
42
|
-
|
43
|
-
def options_module
|
44
|
-
@options_module ||= find_options_module
|
45
|
-
end
|
46
|
-
|
47
|
-
def find_options_module
|
48
|
-
module_name = multi_json_adapter_module_name
|
49
|
-
|
50
|
-
if LanguageSupport.const_defined?(Rollbar::JSON, module_name, false)
|
51
|
-
LanguageSupport.const_get(Rollbar::JSON, module_name, false)
|
52
|
-
else
|
53
|
-
Default
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# MultiJson adapters have this name structure:
|
58
|
-
# "MultiJson::Adapters::{AdapterModule}"
|
59
|
-
#
|
60
|
-
# Ex: MultiJson::Adapters::Oj
|
61
|
-
# Ex: MultiJson::Adapters::JsonGem
|
62
|
-
#
|
63
|
-
# In this method we just get the last module name.
|
64
|
-
def multi_json_adapter_module_name
|
65
|
-
detect_multi_json_adapter.name[/^MultiJson::Adapters::(.*)$/, 1]
|
16
|
+
::JSON.parse(string)
|
66
17
|
end
|
67
18
|
end
|
68
19
|
end
|
data/lib/rollbar/notifier.rb
CHANGED
@@ -42,21 +42,21 @@ module Rollbar
|
|
42
42
|
# Similar to configure below, but used only internally within the gem
|
43
43
|
# to configure it without initializing any of the third party hooks
|
44
44
|
def preconfigure
|
45
|
-
yield(configuration)
|
45
|
+
yield(configuration.configured_options)
|
46
46
|
end
|
47
47
|
|
48
48
|
# Configures the notifier instance
|
49
49
|
def configure
|
50
50
|
configuration.enabled = true if configuration.enabled.nil?
|
51
51
|
|
52
|
-
yield(configuration)
|
52
|
+
yield(configuration.configured_options)
|
53
53
|
end
|
54
54
|
|
55
55
|
def reconfigure
|
56
56
|
self.configuration = Configuration.new
|
57
57
|
configuration.enabled = true
|
58
58
|
|
59
|
-
yield(configuration)
|
59
|
+
yield(configuration.configured_options)
|
60
60
|
end
|
61
61
|
|
62
62
|
def unconfigure
|
@@ -6,7 +6,7 @@ Rollbar.plugins.define('basic_socket') do
|
|
6
6
|
# Needed to avoid active_support (< 4.1.0) bug serializing JSONs
|
7
7
|
dependency do
|
8
8
|
defined?(ActiveSupport::VERSION::STRING) &&
|
9
|
-
Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new('
|
9
|
+
Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new('4.1.0')
|
10
10
|
end
|
11
11
|
|
12
12
|
execute do
|
data/lib/rollbar/rake_tasks.rb
CHANGED
@@ -1,154 +1,10 @@
|
|
1
|
-
require 'rollbar'
|
2
|
-
begin
|
3
|
-
require 'rack/mock'
|
4
|
-
rescue LoadError
|
5
|
-
puts 'Cannot load rack/mock'
|
6
|
-
end
|
7
|
-
require 'logger'
|
8
1
|
|
9
2
|
namespace :rollbar do
|
10
3
|
desc 'Verify your gem installation by sending a test exception to Rollbar'
|
11
4
|
task :test => [:environment] do
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
# Module to inject into the Rails controllers or rack apps
|
17
|
-
module RollbarTest # :nodoc:
|
18
|
-
def test_rollbar
|
19
|
-
puts 'Raising RollbarTestingException to simulate app failure.'
|
20
|
-
|
21
|
-
raise RollbarTestingException.new, ::RollbarTest.success_message
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.run
|
25
|
-
return unless confirmed_token?
|
26
|
-
|
27
|
-
configure_rails if defined?(Rails)
|
28
|
-
|
29
|
-
puts 'Testing manual report...'
|
30
|
-
Rollbar.error('Test error from rollbar:test')
|
31
|
-
|
32
|
-
return unless defined?(Rack::MockRequest)
|
33
|
-
|
34
|
-
protocol, app = setup_app
|
35
|
-
|
36
|
-
puts 'Processing...'
|
37
|
-
env = Rack::MockRequest.env_for("#{protocol}://www.example.com/verify", 'REMOTE_ADDR' => '127.0.0.1')
|
38
|
-
status, = app.call(env)
|
39
|
-
|
40
|
-
puts error_message unless status.to_i == 500
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.configure_rails
|
44
|
-
Rails.logger = if defined?(ActiveSupport::TaggedLogging)
|
45
|
-
ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
|
46
|
-
else
|
47
|
-
Logger.new(STDOUT)
|
48
|
-
end
|
49
|
-
|
50
|
-
Rails.logger.level = Logger::DEBUG
|
51
|
-
Rollbar.preconfigure do |config|
|
52
|
-
config.logger = Rails.logger
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def self.confirmed_token?
|
57
|
-
return true if Rollbar.configuration.access_token
|
58
|
-
|
59
|
-
puts token_error_message
|
60
|
-
|
61
|
-
false
|
62
|
-
end
|
63
|
-
|
64
|
-
def self.authlogic_config
|
65
|
-
# from http://stackoverflow.com/questions/5270835/authlogic-activation-problems
|
66
|
-
return unless defined?(Authlogic)
|
67
|
-
|
68
|
-
Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
|
69
|
-
end
|
70
|
-
|
71
|
-
def self.setup_app
|
72
|
-
puts 'Setting up the test app.'
|
73
|
-
|
74
|
-
if defined?(Rails)
|
75
|
-
app = rails_app
|
5
|
+
rollbar_dir = Gem.loaded_specs['rollbar'].full_gem_path
|
6
|
+
require "#{rollbar_dir}/lib/rollbar/rollbar_test"
|
76
7
|
|
77
|
-
|
78
|
-
|
79
|
-
authlogic_config
|
80
|
-
|
81
|
-
[rails_protocol(app), app]
|
82
|
-
else
|
83
|
-
['http', rack_app]
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def self.rails_app
|
88
|
-
# The setup below is needed for Rails 5.x, but not for Rails 4.x and below.
|
89
|
-
# (And fails on Rails 4.x in various ways depending on the exact version.)
|
90
|
-
return Rails.application if Rails.version < '5.0.0'
|
91
|
-
|
92
|
-
# Spring now runs by default in development on all new Rails installs. This causes
|
93
|
-
# the new `/verify` route to not get picked up if `config.cache_classes == false`
|
94
|
-
# which is also a default in development env.
|
95
|
-
#
|
96
|
-
# `config.cache_classes` needs to be set, but the only possible time is at app load,
|
97
|
-
# so here we clone the default app with an updated config.
|
98
|
-
#
|
99
|
-
config = Rails.application.config
|
100
|
-
config.cache_classes = true
|
101
|
-
|
102
|
-
# Make a copy of the app, so the config can be updated.
|
103
|
-
Rails.application.class.name.constantize.new(:config => config)
|
104
|
-
end
|
105
|
-
|
106
|
-
def self.draw_rails_route(app)
|
107
|
-
app.routes_reloader.execute_if_updated
|
108
|
-
app.routes.draw do
|
109
|
-
get 'verify' => 'rollbar_test#verify', :as => 'verify'
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def self.rails_protocol(app)
|
114
|
-
defined?(app.config.force_ssl && app.config.force_ssl) ? 'https' : 'http'
|
115
|
-
end
|
116
|
-
|
117
|
-
def self.rack_app
|
118
|
-
Class.new do
|
119
|
-
include RollbarTest
|
120
|
-
|
121
|
-
def self.call(_env)
|
122
|
-
new.test_rollbar
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def self.token_error_message
|
128
|
-
'Rollbar needs an access token configured. Check the README for instructions.'
|
129
|
-
end
|
130
|
-
|
131
|
-
def self.error_message
|
132
|
-
'Test failed! You may have a configuration issue, or you could be using a gem that\'s blocking the test. Contact support@rollbar.com if you need help troubleshooting.'
|
133
|
-
end
|
134
|
-
|
135
|
-
def self.success_message
|
136
|
-
'Testing rollbar with "rake rollbar:test". If you can see this, it works.'
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
class RollbarTestingException < RuntimeError; end
|
141
|
-
|
142
|
-
if defined?(Rails)
|
143
|
-
class RollbarTestController < ActionController::Base # :nodoc:
|
144
|
-
include RollbarTest
|
145
|
-
|
146
|
-
def verify
|
147
|
-
test_rollbar
|
148
|
-
end
|
149
|
-
|
150
|
-
def logger
|
151
|
-
nil
|
152
|
-
end
|
8
|
+
RollbarTest.run
|
153
9
|
end
|
154
10
|
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
require 'rollbar'
|
2
|
+
begin
|
3
|
+
require 'rack/mock'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'Cannot load rack/mock'
|
6
|
+
end
|
7
|
+
require 'logger'
|
8
|
+
|
9
|
+
# Module to inject into the Rails controllers or rack apps
|
10
|
+
module RollbarTest # :nodoc:
|
11
|
+
def test_rollbar
|
12
|
+
puts 'Raising RollbarTestingException to simulate app failure.'
|
13
|
+
|
14
|
+
raise RollbarTestingException.new, ::RollbarTest.success_message
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.run
|
18
|
+
return unless confirmed_token?
|
19
|
+
|
20
|
+
configure_rails if defined?(Rails)
|
21
|
+
|
22
|
+
puts 'Testing manual report...'
|
23
|
+
Rollbar.error('Test error from rollbar:test')
|
24
|
+
|
25
|
+
return unless defined?(Rack::MockRequest)
|
26
|
+
|
27
|
+
protocol, app = setup_app
|
28
|
+
|
29
|
+
puts 'Processing...'
|
30
|
+
env = Rack::MockRequest.env_for("#{protocol}://www.example.com/verify", 'REMOTE_ADDR' => '127.0.0.1')
|
31
|
+
status, = app.call(env)
|
32
|
+
|
33
|
+
puts error_message unless status.to_i == 500
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.configure_rails
|
37
|
+
Rails.logger = if defined?(ActiveSupport::TaggedLogging)
|
38
|
+
ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
|
39
|
+
else
|
40
|
+
Logger.new(STDOUT)
|
41
|
+
end
|
42
|
+
|
43
|
+
Rails.logger.level = Logger::DEBUG
|
44
|
+
Rollbar.preconfigure do |config|
|
45
|
+
config.logger = Rails.logger
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.confirmed_token?
|
50
|
+
return true if Rollbar.configuration.access_token
|
51
|
+
|
52
|
+
puts token_error_message
|
53
|
+
|
54
|
+
false
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.authlogic_config
|
58
|
+
# from http://stackoverflow.com/questions/5270835/authlogic-activation-problems
|
59
|
+
return unless defined?(Authlogic)
|
60
|
+
|
61
|
+
Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.setup_app
|
65
|
+
puts 'Setting up the test app.'
|
66
|
+
|
67
|
+
if defined?(Rails)
|
68
|
+
app = rails_app
|
69
|
+
|
70
|
+
draw_rails_route(app)
|
71
|
+
|
72
|
+
authlogic_config
|
73
|
+
|
74
|
+
[rails_protocol(app), app]
|
75
|
+
else
|
76
|
+
['http', rack_app]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.rails_app
|
81
|
+
# The setup below is needed for Rails 5.x, but not for Rails 4.x and below.
|
82
|
+
# (And fails on Rails 4.x in various ways depending on the exact version.)
|
83
|
+
return Rails.application if Rails.version < '5.0.0'
|
84
|
+
|
85
|
+
# Spring now runs by default in development on all new Rails installs. This causes
|
86
|
+
# the new `/verify` route to not get picked up if `config.cache_classes == false`
|
87
|
+
# which is also a default in development env.
|
88
|
+
#
|
89
|
+
# `config.cache_classes` needs to be set, but the only possible time is at app load,
|
90
|
+
# so here we clone the default app with an updated config.
|
91
|
+
#
|
92
|
+
config = Rails.application.config
|
93
|
+
config.cache_classes = true
|
94
|
+
|
95
|
+
# Make a copy of the app, so the config can be updated.
|
96
|
+
Rails.application.class.name.constantize.new(:config => config)
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.draw_rails_route(app)
|
100
|
+
app.routes_reloader.execute_if_updated
|
101
|
+
app.routes.draw do
|
102
|
+
get 'verify' => 'rollbar_test#verify', :as => 'verify'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.rails_protocol(app)
|
107
|
+
defined?(app.config.force_ssl && app.config.force_ssl) ? 'https' : 'http'
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.rack_app
|
111
|
+
Class.new do
|
112
|
+
include RollbarTest
|
113
|
+
|
114
|
+
def self.call(_env)
|
115
|
+
new.test_rollbar
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.token_error_message
|
121
|
+
'Rollbar needs an access token configured. Check the README for instructions.'
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.error_message
|
125
|
+
'Test failed! You may have a configuration issue, or you could be using a gem that\'s blocking the test. Contact support@rollbar.com if you need help troubleshooting.'
|
126
|
+
end
|
127
|
+
|
128
|
+
def self.success_message
|
129
|
+
'Testing rollbar with "rake rollbar:test". If you can see this, it works.'
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
class RollbarTestingException < RuntimeError; end
|
134
|
+
|
135
|
+
if defined?(Rails)
|
136
|
+
class RollbarTestController < ActionController::Base # :nodoc:
|
137
|
+
include RollbarTest
|
138
|
+
|
139
|
+
def verify
|
140
|
+
test_rollbar
|
141
|
+
end
|
142
|
+
|
143
|
+
def logger
|
144
|
+
nil
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
data/lib/rollbar/truncation.rb
CHANGED
@@ -6,6 +6,7 @@ require 'rollbar/truncation/strings_strategy'
|
|
6
6
|
require 'rollbar/truncation/min_body_strategy'
|
7
7
|
require 'rollbar/truncation/remove_request_strategy'
|
8
8
|
require 'rollbar/truncation/remove_extra_strategy'
|
9
|
+
require 'rollbar/truncation/remove_any_key_strategy'
|
9
10
|
|
10
11
|
module Rollbar
|
11
12
|
module Truncation
|
@@ -17,7 +18,8 @@ module Rollbar
|
|
17
18
|
StringsStrategy,
|
18
19
|
MinBodyStrategy,
|
19
20
|
RemoveRequestStrategy,
|
20
|
-
RemoveExtraStrategy
|
21
|
+
RemoveExtraStrategy,
|
22
|
+
RemoveAnyKeyStrategy].freeze
|
21
23
|
|
22
24
|
def self.truncate(payload, attempts = [])
|
23
25
|
result = nil
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'rollbar/util'
|
2
|
+
|
3
|
+
module Rollbar
|
4
|
+
module Truncation
|
5
|
+
class RemoveAnyKeyStrategy
|
6
|
+
include ::Rollbar::Truncation::Mixin
|
7
|
+
|
8
|
+
attr_accessor :payload, :data, :sizes, :extracted_title
|
9
|
+
|
10
|
+
def self.call(payload)
|
11
|
+
new(payload).call
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(payload)
|
15
|
+
@payload = payload
|
16
|
+
@data = payload['data']
|
17
|
+
@extracted_title = extract_title(data['body']) if data['body']
|
18
|
+
end
|
19
|
+
|
20
|
+
def call
|
21
|
+
remove_unknown_root_keys
|
22
|
+
|
23
|
+
json_payload = remove_oversized_data_keys
|
24
|
+
|
25
|
+
return json_payload if json_payload
|
26
|
+
|
27
|
+
dump(payload)
|
28
|
+
end
|
29
|
+
|
30
|
+
def remove_unknown_root_keys
|
31
|
+
payload.keys.reject { |key| root_keys.include?(key) }.each do |key|
|
32
|
+
truncation_key['root'] ||= {}
|
33
|
+
size = dump(payload.delete(key)).bytesize
|
34
|
+
truncation_key['root'][key] = "unknown root key removed, size: #{size} bytes"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def remove_oversized_data_keys
|
39
|
+
data_keys.keys.sort { |a, b| data_keys[b] <=> data_keys[a] }.each do |key|
|
40
|
+
json_payload = remove_key_and_return_payload(key)
|
41
|
+
|
42
|
+
return json_payload unless truncate?(json_payload)
|
43
|
+
end
|
44
|
+
|
45
|
+
false
|
46
|
+
end
|
47
|
+
|
48
|
+
def remove_key_and_return_payload(key)
|
49
|
+
size = data_keys[key]
|
50
|
+
|
51
|
+
data.delete(key)
|
52
|
+
|
53
|
+
replace_message_body if key == 'body'
|
54
|
+
|
55
|
+
truncation_key[key] = "key removed, size: #{size} bytes"
|
56
|
+
|
57
|
+
dump(payload)
|
58
|
+
end
|
59
|
+
|
60
|
+
def replace_message_body
|
61
|
+
data['body'] = message_key
|
62
|
+
data['title'] ||= extracted_title if extracted_title
|
63
|
+
end
|
64
|
+
|
65
|
+
def truncation_key
|
66
|
+
@truncation_key ||=
|
67
|
+
# initialize the diagnostic key for truncation
|
68
|
+
(data['notifier']['diagnostic'] ||= {}) &&
|
69
|
+
(data['notifier']['diagnostic']['truncation'] ||= {})
|
70
|
+
end
|
71
|
+
|
72
|
+
def root_keys
|
73
|
+
# Valid keys in root of payload
|
74
|
+
%w[access_token data]
|
75
|
+
end
|
76
|
+
|
77
|
+
def skip_keys
|
78
|
+
# Don't try to truncate these data keys
|
79
|
+
%w[notifier uuid title platform language framework level]
|
80
|
+
end
|
81
|
+
|
82
|
+
def message_key
|
83
|
+
# use this message if data.body gets removed
|
84
|
+
{
|
85
|
+
'message' => {
|
86
|
+
'body' => 'Payload keys removed due to oversized payload. See diagnostic key'
|
87
|
+
}
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
def extract_title(body)
|
92
|
+
return body['message']['body'] if body['message'] && body['message']['body']
|
93
|
+
return extract_title_from_trace(body['trace']) if body['trace']
|
94
|
+
return extract_title_from_trace(body['trace_chain'][0]) if body['trace_chain'] && body['trace_chain'][0]
|
95
|
+
end
|
96
|
+
|
97
|
+
def extract_title_from_trace(trace)
|
98
|
+
exception = trace['exception']
|
99
|
+
|
100
|
+
"#{exception['class']}: #{exception['message']}"
|
101
|
+
end
|
102
|
+
|
103
|
+
def data_keys
|
104
|
+
@data_keys ||= {}.tap do |hash|
|
105
|
+
data.keys.reject { |key| skip_keys.include?(key) }.each do |key|
|
106
|
+
set_key_size(key, hash)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def set_key_size(key, hash)
|
112
|
+
size = dump(data[key]).bytesize
|
113
|
+
hash[key] = size
|
114
|
+
rescue ::JSON::GeneratorError
|
115
|
+
hash[key] = 0 # don't try to truncate non JSON object
|
116
|
+
|
117
|
+
# Log it
|
118
|
+
truncation_key['non_json_keys'] ||= {}
|
119
|
+
truncation_key['non_json_keys'][key] = data[key].class
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/lib/rollbar/util.rb
CHANGED
data/lib/rollbar/util/hash.rb
CHANGED
@@ -5,6 +5,7 @@ module Rollbar
|
|
5
5
|
return if seen[hash.object_id]
|
6
6
|
|
7
7
|
seen[hash.object_id] = true
|
8
|
+
replace_seen_children(hash, seen)
|
8
9
|
|
9
10
|
hash.reduce({}) do |h, (key, value)|
|
10
11
|
h[key.to_s] = map_value(value, :deep_stringify_keys, seen)
|
@@ -22,12 +23,26 @@ module Rollbar
|
|
22
23
|
thing
|
23
24
|
else
|
24
25
|
seen[thing.object_id] = true
|
26
|
+
replace_seen_children(thing, seen)
|
25
27
|
thing.map { |v| map_value(v, meth, seen) }
|
26
28
|
end
|
27
29
|
else
|
28
30
|
thing
|
29
31
|
end
|
30
32
|
end
|
33
|
+
|
34
|
+
def self.replace_seen_children(thing, seen)
|
35
|
+
case thing
|
36
|
+
when ::Hash
|
37
|
+
thing.keys.each do |key|
|
38
|
+
thing[key] = "removed circular reference: #{thing[key]}" if seen[thing[key].object_id]
|
39
|
+
end
|
40
|
+
when Array
|
41
|
+
thing.each_with_index do |_, i|
|
42
|
+
thing[i] = "removed circular reference: #{thing[i]}" if seen[thing[i].object_id]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
31
46
|
end
|
32
47
|
end
|
33
48
|
end
|
data/lib/rollbar/version.rb
CHANGED
data/rollbar.gemspec
CHANGED
@@ -18,8 +18,6 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.required_ruby_version = '>= 1.9.3'
|
19
19
|
gem.version = Rollbar::VERSION
|
20
20
|
|
21
|
-
gem.add_runtime_dependency 'multi_json'
|
22
|
-
|
23
21
|
if gem.respond_to?(:metadata)
|
24
22
|
gem.metadata['changelog_uri'] = 'https://github.com/rollbar/rollbar-gem/releases'
|
25
23
|
gem.metadata['source_code_uri'] = 'https://github.com/rollbar/rollbar-gem'
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rollbar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.22.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-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: multi_json
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
11
|
+
date: 2019-08-30 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description: Easy and powerful exception tracking for Ruby
|
28
14
|
email:
|
29
15
|
- support@rollbar.com
|
@@ -59,6 +45,7 @@ files:
|
|
59
45
|
- gemfiles/rails50.gemfile
|
60
46
|
- gemfiles/rails51.gemfile
|
61
47
|
- gemfiles/rails52.gemfile
|
48
|
+
- gemfiles/rails60.gemfile
|
62
49
|
- lib/generators/rollbar/rollbar_generator.rb
|
63
50
|
- lib/generators/rollbar/templates/initializer.rb
|
64
51
|
- lib/rails/rollbar_runner.rb
|
@@ -87,8 +74,6 @@ files:
|
|
87
74
|
- lib/rollbar/item/locals.rb
|
88
75
|
- lib/rollbar/js.rb
|
89
76
|
- lib/rollbar/json.rb
|
90
|
-
- lib/rollbar/json/default.rb
|
91
|
-
- lib/rollbar/json/oj.rb
|
92
77
|
- lib/rollbar/language_support.rb
|
93
78
|
- lib/rollbar/lazy_store.rb
|
94
79
|
- lib/rollbar/logger.rb
|
@@ -127,6 +112,7 @@ files:
|
|
127
112
|
- lib/rollbar/rails.rb
|
128
113
|
- lib/rollbar/rake_tasks.rb
|
129
114
|
- lib/rollbar/request_data_extractor.rb
|
115
|
+
- lib/rollbar/rollbar_test.rb
|
130
116
|
- lib/rollbar/scrubbers.rb
|
131
117
|
- lib/rollbar/scrubbers/params.rb
|
132
118
|
- lib/rollbar/scrubbers/url.rb
|
@@ -135,6 +121,7 @@ files:
|
|
135
121
|
- lib/rollbar/truncation/min_body_strategy.rb
|
136
122
|
- lib/rollbar/truncation/mixin.rb
|
137
123
|
- lib/rollbar/truncation/raw_strategy.rb
|
124
|
+
- lib/rollbar/truncation/remove_any_key_strategy.rb
|
138
125
|
- lib/rollbar/truncation/remove_extra_strategy.rb
|
139
126
|
- lib/rollbar/truncation/remove_request_strategy.rb
|
140
127
|
- lib/rollbar/truncation/strings_strategy.rb
|
@@ -170,7 +157,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
157
|
- !ruby/object:Gem::Version
|
171
158
|
version: '0'
|
172
159
|
requirements: []
|
173
|
-
|
160
|
+
rubyforge_project:
|
161
|
+
rubygems_version: 2.7.7
|
174
162
|
signing_key:
|
175
163
|
specification_version: 4
|
176
164
|
summary: Reports exceptions to Rollbar
|
data/lib/rollbar/json/default.rb
DELETED