rollbar 2.24.0 → 2.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/README.md +1 -1
- data/data/rollbar.snippet.js +1 -1
- data/gemfiles/rails50.gemfile +6 -2
- data/gemfiles/rails51.gemfile +6 -2
- data/lib/rollbar/deploy.rb +2 -0
- data/lib/rollbar/encoding/encoder.rb +3 -0
- data/lib/rollbar/item/backtrace.rb +1 -1
- data/lib/rollbar/item.rb +9 -3
- data/lib/rollbar/json.rb +1 -0
- data/lib/rollbar/middleware/js.rb +7 -2
- data/lib/rollbar/notifier.rb +88 -29
- data/lib/rollbar/version.rb +1 -1
- data/spec/support/rollbar_api.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69307fc6496e1b12a3ebbe3e40b7341f725a7f4efadd6a1a5e76d7246bc86928
|
4
|
+
data.tar.gz: 117fb5d03ab1f140f9469558c6560963180806935d3d56eeeb35da9cf450edc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61587004c5ba54fffb2bd34d9f4abdfd182a82002ebcbe688c8c500975797f43f2caac63ce3ca510276828e1b2132cda95027b42ea02533221a18a008d8d654b
|
7
|
+
data.tar.gz: 9b62efc68f689811910cb92ae3262447c41732eaa6ebdc14019b7fd96114fcfebddf921e29699480e1fa7a21d54281e9130e99a3c85f8104f2d4440fd22f840d
|
data/.rubocop.yml
CHANGED
@@ -51,7 +51,7 @@ Style/Documentation:
|
|
51
51
|
# As is, we currently add :nodoc: if anything at all.
|
52
52
|
Enabled: false
|
53
53
|
|
54
|
-
Naming/
|
54
|
+
Naming/MethodParameterName:
|
55
55
|
# It's possible to configure this cop to allow just about anything, but what's the point.
|
56
56
|
# The default min length of a param name is 3, but the the default whitelist includes things
|
57
57
|
# like `db` and `io`. So, short names really can be useful.
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Rollbar-gem
|
2
|
-
[![Build Status](https://
|
2
|
+
[![Build Status](https://travis-ci.org/rollbar/rollbar-gem.svg?branch=master)](https://travis-ci.org/rollbar/rollbar-gem/branches)
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/rollbar.svg)](http://badge.fury.io/rb/rollbar)
|
4
4
|
[![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=rollbar&package-manager=bundler&version-scheme=semver&target-version=latest)](https://dependabot.com/compatibility-score.html?dependency-name=rollbar&package-manager=bundler&version-scheme=semver&new-version=latest)
|
5
5
|
|
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://
|
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){"use strict";var n=o(1),t=o(4);_rollbarConfig=_rollbarConfig||{},_rollbarConfig.rollbarJsUrl=_rollbarConfig.rollbarJsUrl||"https://cdn.rollbar.com/rollbarjs/refs/tags/v2.15.2/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";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=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)}))}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 u="log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleAnonymousErrors,handleUnhandledRejection,captureEvent,captureDomContentLoaded,captureLoad".split(","),p=0;p<u.length;++p)l.prototype[u[p]]=c(u[p]);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,o){"use strict";function n(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)}function t(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 t;if("function"==typeof e._rollbarOldOnError)t=e._rollbarOldOnError;else if(r.onerror){for(t=r.onerror;t._rollbarOldOnError;)t=t._rollbarOldOnError;e._rollbarOldOnError=t}e.handleAnonymousErrors();var a=function(){var o=Array.prototype.slice.call(arguments,0);n(r,e,t,o)};o&&(a._rollbarOldOnError=t),r.onerror=a}},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,o){if(r){var n,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(n=0;n<l.length;++n)r[a=l[n]]&&r[a].prototype&&t(e,r[a].prototype,o)}}}},function(r,e,o){"use strict";function n(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])}(n.prototype)}n.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=n},function(r,e,o){"use strict";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/rails50.gemfile
CHANGED
@@ -44,8 +44,12 @@ elsif RUBY_VERSION.start_with?('2')
|
|
44
44
|
gem 'simplecov'
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
gem '
|
47
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3')
|
48
|
+
gem 'rack', '2.1.2'
|
49
|
+
end
|
50
|
+
|
51
|
+
# We need last sinatra that uses rack 2.1.x
|
52
|
+
gem 'sinatra', :git => 'https://github.com/sinatra/sinatra', :tag => 'v2.0.8'
|
49
53
|
gem 'database_cleaner'
|
50
54
|
gem 'delayed_job', :require => false
|
51
55
|
gem 'generator_spec'
|
data/gemfiles/rails51.gemfile
CHANGED
@@ -44,8 +44,12 @@ elsif RUBY_VERSION.start_with?('2')
|
|
44
44
|
gem 'simplecov'
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
gem '
|
47
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3')
|
48
|
+
gem 'rack', '2.1.2'
|
49
|
+
end
|
50
|
+
|
51
|
+
# We need last sinatra that uses rack 2.1.x
|
52
|
+
gem 'sinatra', :git => 'https://github.com/sinatra/sinatra', :tag => 'v2.0.8'
|
49
53
|
|
50
54
|
gem 'database_cleaner'
|
51
55
|
gem 'delayed_job', :require => false
|
data/lib/rollbar/deploy.rb
CHANGED
@@ -30,6 +30,9 @@ module Rollbar
|
|
30
30
|
end
|
31
31
|
|
32
32
|
object.is_a?(Symbol) ? encoded_value.to_sym : encoded_value
|
33
|
+
rescue StandardError => e
|
34
|
+
# If encoding fails for any reason, replace the string with a diagnostic error.
|
35
|
+
"error encoding string: #{e.class}: #{e.message}"
|
33
36
|
end
|
34
37
|
|
35
38
|
private
|
@@ -55,7 +55,7 @@ module Rollbar
|
|
55
55
|
current_exception = exception
|
56
56
|
|
57
57
|
while current_exception.respond_to?(:cause) && (cause = current_exception.cause) && cause.is_a?(Exception) && !visited.include?(cause)
|
58
|
-
traces
|
58
|
+
traces << trace_data(cause)
|
59
59
|
visited << cause
|
60
60
|
current_exception = cause
|
61
61
|
end
|
data/lib/rollbar/item.rb
CHANGED
@@ -65,7 +65,6 @@ module Rollbar
|
|
65
65
|
def build
|
66
66
|
data = build_data
|
67
67
|
self.payload = {
|
68
|
-
'access_token' => configuration.access_token,
|
69
68
|
'data' => data
|
70
69
|
}
|
71
70
|
|
@@ -137,11 +136,18 @@ module Rollbar
|
|
137
136
|
uuid = stringified_payload['data']['uuid']
|
138
137
|
host = stringified_payload['data'].fetch('server', {})['host']
|
139
138
|
|
139
|
+
original_error = {
|
140
|
+
:message => message,
|
141
|
+
:exception => exception,
|
142
|
+
:configuration => configuration,
|
143
|
+
:uuid => uuid,
|
144
|
+
:host => host
|
145
|
+
}
|
146
|
+
|
140
147
|
notifier.send_failsafe(
|
141
148
|
too_large_payload_string(attempts),
|
142
149
|
nil,
|
143
|
-
|
144
|
-
host
|
150
|
+
original_error
|
145
151
|
)
|
146
152
|
logger.error("[Rollbar] Payload too large to be sent for UUID #{uuid}: #{Rollbar::JSON.dump(payload)}")
|
147
153
|
end
|
data/lib/rollbar/json.rb
CHANGED
@@ -80,8 +80,11 @@ module Rollbar
|
|
80
80
|
return app_result unless response_string
|
81
81
|
|
82
82
|
env[JS_IS_INJECTED_KEY] = true
|
83
|
-
|
84
|
-
|
83
|
+
|
84
|
+
status, headers, = app_result
|
85
|
+
headers['Content-Length'] = response_string.bytesize.to_s if headers.key?('Content-Length')
|
86
|
+
|
87
|
+
response = ::Rack::Response.new(response_string, status, headers)
|
85
88
|
|
86
89
|
finished = response.finish
|
87
90
|
|
@@ -121,6 +124,8 @@ module Rollbar
|
|
121
124
|
end
|
122
125
|
|
123
126
|
def config_js_tag(env)
|
127
|
+
require 'json'
|
128
|
+
|
124
129
|
js_config = Rollbar::Util.deep_copy(config[:options])
|
125
130
|
|
126
131
|
add_person_data(js_config, env)
|
data/lib/rollbar/notifier.rb
CHANGED
@@ -21,6 +21,7 @@ module Rollbar
|
|
21
21
|
|
22
22
|
MUTEX = Mutex.new
|
23
23
|
EXTENSION_REGEXP = /.rollbar\z/.freeze
|
24
|
+
FAILSAFE_STRING_LENGTH = 10_000
|
24
25
|
|
25
26
|
def initialize(parent_notifier = nil, payload_options = nil, scope = nil)
|
26
27
|
if parent_notifier
|
@@ -104,10 +105,10 @@ module Rollbar
|
|
104
105
|
|
105
106
|
# Sends a report to Rollbar.
|
106
107
|
#
|
107
|
-
# Accepts any number of arguments. The last String
|
108
|
-
# the message or description of the report. The last
|
109
|
-
# will become the associated exception for the report.
|
110
|
-
# argument will be used as the extra data for the report.
|
108
|
+
# Accepts a level string plus any number of arguments. The last String
|
109
|
+
# argument will become the message or description of the report. The last
|
110
|
+
# Exception argument will become the associated exception for the report.
|
111
|
+
# The last hash argument will be used as the extra data for the report.
|
111
112
|
#
|
112
113
|
# If the extra hash contains a symbol key :custom_data_method_context
|
113
114
|
# the value of the key will be used as the context for
|
@@ -118,14 +119,14 @@ module Rollbar
|
|
118
119
|
# begin
|
119
120
|
# foo = bar
|
120
121
|
# rescue => e
|
121
|
-
# Rollbar.log(e)
|
122
|
+
# Rollbar.log('error', e)
|
122
123
|
# end
|
123
124
|
#
|
124
125
|
# @example
|
125
|
-
# Rollbar.log('This is a simple log message')
|
126
|
+
# Rollbar.log('info', 'This is a simple log message')
|
126
127
|
#
|
127
128
|
# @example
|
128
|
-
# Rollbar.log(e, 'This is a description of the exception')
|
129
|
+
# Rollbar.log('error', e, 'This is a description of the exception')
|
129
130
|
#
|
130
131
|
def log(level, *args)
|
131
132
|
return 'disabled' unless enabled?
|
@@ -158,7 +159,13 @@ module Rollbar
|
|
158
159
|
def report_with_rescue(level, message, exception, extra, context)
|
159
160
|
report(level, message, exception, extra, context)
|
160
161
|
rescue StandardError, SystemStackError => e
|
161
|
-
|
162
|
+
original_error = {
|
163
|
+
:message => message,
|
164
|
+
:exception => exception,
|
165
|
+
:configuration => configuration
|
166
|
+
}
|
167
|
+
|
168
|
+
report_internal_error(e, original_error)
|
162
169
|
|
163
170
|
'error'
|
164
171
|
end
|
@@ -262,35 +269,34 @@ module Rollbar
|
|
262
269
|
end
|
263
270
|
end
|
264
271
|
|
265
|
-
def
|
266
|
-
|
267
|
-
|
268
|
-
log_error "[Rollbar] Sending failsafe response due to #{exception_reason}"
|
269
|
-
|
270
|
-
body = failsafe_body(exception_reason)
|
271
|
-
|
272
|
-
failsafe_data = {
|
272
|
+
def failsafe_initial_data(exception_reason)
|
273
|
+
{
|
273
274
|
:level => 'error',
|
274
275
|
:environment => configuration.environment.to_s,
|
275
276
|
:body => {
|
276
277
|
:message => {
|
277
|
-
:body =>
|
278
|
+
:body => failsafe_body(exception_reason)
|
278
279
|
}
|
279
280
|
},
|
280
281
|
:notifier => {
|
281
282
|
:name => 'rollbar-gem',
|
282
283
|
:version => VERSION
|
283
284
|
},
|
284
|
-
:custom => {
|
285
|
-
:orig_uuid => uuid,
|
286
|
-
:orig_host => host
|
287
|
-
},
|
288
285
|
:internal => true,
|
289
|
-
|
286
|
+
'failsafe' => true
|
290
287
|
}
|
288
|
+
end
|
289
|
+
|
290
|
+
def send_failsafe(message, exception, original_error = nil)
|
291
|
+
exception_reason = failsafe_reason(message, exception)
|
292
|
+
|
293
|
+
log_error "[Rollbar] Sending failsafe response due to #{exception_reason}"
|
294
|
+
|
295
|
+
failsafe_data = failsafe_initial_data(exception_reason)
|
296
|
+
|
297
|
+
failsafe_add_original_error_data(failsafe_data[:notifier], original_error)
|
291
298
|
|
292
299
|
failsafe_payload = {
|
293
|
-
'access_token' => configuration.access_token,
|
294
300
|
'data' => failsafe_data
|
295
301
|
}
|
296
302
|
|
@@ -299,7 +305,9 @@ module Rollbar
|
|
299
305
|
:notifier => self,
|
300
306
|
:configuration => configuration,
|
301
307
|
:logger => logger)
|
302
|
-
|
308
|
+
|
309
|
+
process_item(item)
|
310
|
+
log_and_return_item_data(item)
|
303
311
|
rescue StandardError => e
|
304
312
|
log_error "[Rollbar] Error sending failsafe : #{e}"
|
305
313
|
end
|
@@ -307,6 +315,57 @@ module Rollbar
|
|
307
315
|
failsafe_payload
|
308
316
|
end
|
309
317
|
|
318
|
+
def failsafe_add_original_error_data(payload_notifier, original_error)
|
319
|
+
return unless original_error
|
320
|
+
|
321
|
+
payload_notifier[:diagnostic] ||= {}
|
322
|
+
|
323
|
+
add_original_host(payload_notifier[:diagnostic], original_error)
|
324
|
+
add_original_uuid(payload_notifier[:diagnostic], original_error)
|
325
|
+
add_original_message(payload_notifier[:diagnostic], original_error)
|
326
|
+
add_original_error(payload_notifier[:diagnostic], original_error)
|
327
|
+
add_configured_options(payload_notifier, original_error)
|
328
|
+
end
|
329
|
+
|
330
|
+
def add_original_message(diagnostic, original_error)
|
331
|
+
diagnostic[:original_message] = original_error[:message].truncate(FAILSAFE_STRING_LENGTH) if original_error[:message]
|
332
|
+
|
333
|
+
rescue StandardError => e
|
334
|
+
diagnostic[:original_message] = "Failed: #{e.message}"
|
335
|
+
end
|
336
|
+
|
337
|
+
def add_original_error(diagnostic, original_error)
|
338
|
+
if original_error[:exception]
|
339
|
+
backtrace = original_error[:exception].backtrace
|
340
|
+
message = original_error[:exception].message
|
341
|
+
diagnostic[:original_error] = {
|
342
|
+
:message => message && message.truncate(FAILSAFE_STRING_LENGTH),
|
343
|
+
:stack => backtrace && backtrace.join(', ').truncate(FAILSAFE_STRING_LENGTH)
|
344
|
+
}
|
345
|
+
end
|
346
|
+
|
347
|
+
rescue StandardError => e
|
348
|
+
diagnostic[:original_error] = "Failed: #{e.message}"
|
349
|
+
end
|
350
|
+
|
351
|
+
def add_configured_options(payload_notifier, original_error)
|
352
|
+
if original_error[:configuration]
|
353
|
+
configured = original_error[:configuration].configured_options.configured
|
354
|
+
payload_notifier[:configured_options] = ::JSON.generate(configured).truncate(FAILSAFE_STRING_LENGTH)
|
355
|
+
end
|
356
|
+
|
357
|
+
rescue StandardError => e
|
358
|
+
payload_notifier[:configured_options] = "Failed: #{e.message}"
|
359
|
+
end
|
360
|
+
|
361
|
+
def add_original_host(diagnostic, original_error)
|
362
|
+
diagnostic[:original_host] = original_error[:host] if original_error[:host]
|
363
|
+
end
|
364
|
+
|
365
|
+
def add_original_uuid(diagnostic, original_error)
|
366
|
+
diagnostic[:original_uuid] = original_error[:uuid] if original_error[:uuid]
|
367
|
+
end
|
368
|
+
|
310
369
|
## Logging
|
311
370
|
%w[debug info warn error].each do |level|
|
312
371
|
define_method(:"log_#{level}") do |message|
|
@@ -462,7 +521,7 @@ module Rollbar
|
|
462
521
|
# Reports an internal error in the Rollbar library. This will be reported within the configured
|
463
522
|
# Rollbar project. We'll first attempt to provide a report including the exception traceback.
|
464
523
|
# If that fails, we'll fall back to a more static failsafe response.
|
465
|
-
def report_internal_error(exception)
|
524
|
+
def report_internal_error(exception, original_error = nil)
|
466
525
|
log_error '[Rollbar] Reporting internal error encountered while sending data to Rollbar.'
|
467
526
|
|
468
527
|
configuration.execute_hook(:on_report_internal_error, exception)
|
@@ -470,7 +529,7 @@ module Rollbar
|
|
470
529
|
begin
|
471
530
|
item = build_item('error', nil, exception, { :internal => true }, nil)
|
472
531
|
rescue StandardError => e
|
473
|
-
send_failsafe('build_item in exception_data', e)
|
532
|
+
send_failsafe('build_item in exception_data', e, original_error)
|
474
533
|
log_error "[Rollbar] Exception: #{exception}"
|
475
534
|
return
|
476
535
|
end
|
@@ -478,7 +537,7 @@ module Rollbar
|
|
478
537
|
begin
|
479
538
|
process_item(item)
|
480
539
|
rescue StandardError => e
|
481
|
-
send_failsafe('error in process_item', e)
|
540
|
+
send_failsafe('error in process_item', e, original_error)
|
482
541
|
log_error "[Rollbar] Item: #{item}"
|
483
542
|
return
|
484
543
|
end
|
@@ -486,7 +545,7 @@ module Rollbar
|
|
486
545
|
begin
|
487
546
|
log_instance_link(item['data'])
|
488
547
|
rescue StandardError => e
|
489
|
-
send_failsafe('error logging instance link', e)
|
548
|
+
send_failsafe('error logging instance link', e, original_error)
|
490
549
|
log_error "[Rollbar] Item: #{item}"
|
491
550
|
return
|
492
551
|
end
|
@@ -804,7 +863,7 @@ module Rollbar
|
|
804
863
|
end
|
805
864
|
|
806
865
|
def via_failsafe?(item)
|
807
|
-
item.payload.fetch('data', {}).fetch(
|
866
|
+
item.payload.fetch('data', {}).fetch('failsafe', false)
|
808
867
|
end
|
809
868
|
end
|
810
869
|
end
|
data/lib/rollbar/version.rb
CHANGED
data/spec/support/rollbar_api.rb
CHANGED
@@ -16,8 +16,8 @@ class RollbarAPI
|
|
16
16
|
|
17
17
|
protected
|
18
18
|
|
19
|
-
def authorized?(
|
20
|
-
|
19
|
+
def authorized?(_json, request)
|
20
|
+
request.env['HTTP_X_ROLLBAR_ACCESS_TOKEN'] != UNAUTHORIZED_ACCESS_TOKEN
|
21
21
|
end
|
22
22
|
|
23
23
|
def response_headers
|
@@ -26,8 +26,8 @@ class RollbarAPI
|
|
26
26
|
}
|
27
27
|
end
|
28
28
|
|
29
|
-
def valid_data?(
|
30
|
-
!!
|
29
|
+
def valid_data?(_json, request)
|
30
|
+
!!request.env['HTTP_X_ROLLBAR_ACCESS_TOKEN']
|
31
31
|
end
|
32
32
|
|
33
33
|
def unauthorized
|
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.
|
4
|
+
version: 2.26.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: 2020-
|
11
|
+
date: 2020-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Easy and powerful exception tracking for Ruby
|
14
14
|
email:
|