rollbar 2.23.2 → 2.26.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9073beef837ad644c6679c6f95599b7eb6e387d089c9f8d88448cbf39960ea22
4
- data.tar.gz: 148751730bba10444641bd319314b7af7ee69a51e2c15cc686a909f797eec379
3
+ metadata.gz: cd45e6b870eee21793378f297cf881406be39872d66be7cf69327aa7bc06a027
4
+ data.tar.gz: d575825e0dc9715370e04b4a667d94eec34a089dedbbd4c0ef92df991ac9ecbf
5
5
  SHA512:
6
- metadata.gz: c8b0529b951944385beba61f53f43c3ea4270fe38c94fb85639a55a833d2e67c92ae61e88325ba3e3c4a0b64492aab3c95bc6faa6f458df1e9ad792c1e38e77d
7
- data.tar.gz: 6d12a2415ac6ba94b7e5b00b944a4de7afe5a4fa6e43c9d86618c944d0968e0aeb8d601a34363fd97b89bc4ff5316b7dfa2cff6a54aee1a7f198b5690391da23
6
+ metadata.gz: 51ebdecd60cef3c8cb540ed24179b00840f296a137fad69f68c19b7ddff65e987129b4e7ef6fa138bd5e6b5e823f4a9e9a3aef471524797efe8a6ff9b41efd34
7
+ data.tar.gz: 17de152e3dadb969fae494fae14d00903bc7e31781d1d0bbe3d6410b8623e96b7f58b52b9cb9bcab03d517ad894acd1d908a23ffe722b4bd748f93450a7b0abf
@@ -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/UncommunicativeMethodParamName:
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.
@@ -69,6 +69,10 @@ Style/FrozenStringLiteralComment:
69
69
  # throughout the project, in order to prepare for a future Ruby 3.x.
70
70
  Enabled: false
71
71
 
72
+ Style/SafeNavigation:
73
+ # Not available in Ruby < 2.3.
74
+ Enabled: false
75
+
72
76
  #
73
77
  # Performance cops are opt in, and `Enabled: true` is always required.
74
78
  # Full list is here: https://github.com/rubocop-hq/rubocop-performance/tree/master/lib/rubocop/cop/performance
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Rollbar-gem
2
- [![Build Status](https://api.travis-ci.org/rollbar/rollbar-gem.svg?branch=master)](https://travis-ci.org/rollbar/rollbar-gem/branches)
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
 
@@ -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.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}}}}]);
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}}}}]);
@@ -129,6 +129,7 @@ An array of backup handlers if the async handlers fails. Each should respond to
129
129
 
130
130
  For use with `write_to_file`. Indicates location of the rollbar log file being
131
131
  tracked by [rollbar-agent](https://github.com/rollbar/rollbar-agent).
132
+ Enable `files_with_pid_name_enabled` if you want to have different files for each process(only works if extension `rollbar`)
132
133
 
133
134
  ### framework
134
135
 
@@ -44,8 +44,12 @@ elsif RUBY_VERSION.start_with?('2')
44
44
  gem 'simplecov'
45
45
  end
46
46
 
47
- # We need last sinatra that uses rack 2.x
48
- gem 'sinatra', :git => 'https://github.com/sinatra/sinatra'
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'
@@ -44,8 +44,12 @@ elsif RUBY_VERSION.start_with?('2')
44
44
  gem 'simplecov'
45
45
  end
46
46
 
47
- # We need last sinatra that uses rack 2.x
48
- gem 'sinatra', :git => 'https://github.com/sinatra/sinatra'
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
@@ -39,7 +39,7 @@ module Rails
39
39
  end
40
40
 
41
41
  def eval_runner
42
- if Rails.version >= '5.1.0'
42
+ if Gem::Version.new(Rails.version) >= Gem::Version.new('5.1.0')
43
43
  rails5_runner
44
44
  else
45
45
  legacy_runner
@@ -55,6 +55,8 @@ module Rails
55
55
  end
56
56
 
57
57
  def rails5_runner
58
+ require 'rails/command'
59
+
58
60
  Rails::Command.invoke 'runner', ARGV
59
61
  end
60
62
 
@@ -35,7 +35,7 @@ module Rollbar
35
35
  _cset(:rollbar_user) { ENV['USER'] || ENV['USERNAME'] }
36
36
  _cset(:rollbar_env) { fetch(:rails_env, 'production') }
37
37
  _cset(:rollbar_token) { abort("Please specify the Rollbar access token, set :rollbar_token, 'your token'") }
38
- _cset(:rollbar_revision) { current_revision }
38
+ _cset(:rollbar_revision) { real_revision }
39
39
  _cset(:rollbar_comment) { nil }
40
40
  end
41
41
  end
@@ -40,6 +40,9 @@ module Rollbar
40
40
  capistrano_300_warning(logger)
41
41
  logger.info opts[:desc] if opts[:desc]
42
42
  yield
43
+
44
+ rescue StandardError => e
45
+ logger.error "Error reporting to Rollbar: #{e.inspect}"
43
46
  end
44
47
 
45
48
  def deploy_update(capistrano, logger, dry_run, opts = {})
@@ -61,7 +64,11 @@ module Rollbar
61
64
  end
62
65
 
63
66
  def capistrano_300_warning(logger)
64
- logger.warn("You need to upgrade capistrano to '>= 3.1' version in order to correctly report deploys to Rollbar. (On 3.0, the reported revision will be incorrect.)") if ::Capistrano::VERSION =~ /^3\.0/
67
+ return unless ::Capistrano.const_defined?('VERSION') && ::Capistrano::VERSION =~ /^3\.0/
68
+
69
+ logger.warn('You need to upgrade capistrano to >= 3.1 version in order'\
70
+ 'to correctly report deploys to Rollbar. (On 3.0, the reported revision'\
71
+ 'will be incorrect.)')
65
72
  end
66
73
 
67
74
  def report_deploy_started(capistrano, dry_run)
@@ -83,6 +90,7 @@ module Rollbar
83
90
  def report_deploy_succeeded(capistrano, dry_run)
84
91
  ::Rollbar::Deploy.update(
85
92
  {
93
+ :comment => capistrano.fetch(:rollbar_comment),
86
94
  :proxy => :ENV,
87
95
  :dry_run => dry_run
88
96
  },
@@ -95,6 +103,7 @@ module Rollbar
95
103
  def report_deploy_failed(capistrano, dry_run)
96
104
  ::Rollbar::Deploy.update(
97
105
  {
106
+ :comment => capistrano.fetch(:rollbar_comment),
98
107
  :proxy => :ENV,
99
108
  :dry_run => dry_run
100
109
  },
@@ -24,7 +24,6 @@ module Rollbar
24
24
  attr_accessor :environment
25
25
  attr_accessor :exception_level_filters
26
26
  attr_accessor :failover_handlers
27
- attr_accessor :filepath
28
27
  attr_accessor :framework
29
28
  attr_accessor :ignored_person_ids
30
29
  attr_accessor :host
@@ -61,7 +60,6 @@ module Rollbar
61
60
  attr_accessor :async_json_payload
62
61
  attr_reader :use_eventmachine
63
62
  attr_accessor :web_base
64
- attr_accessor :write_to_file
65
63
  attr_reader :send_extra_frame_data
66
64
  attr_accessor :use_exception_level_filters_default
67
65
  attr_accessor :proxy
@@ -70,6 +68,13 @@ module Rollbar
70
68
  attr_accessor :log_payload
71
69
  attr_accessor :backtrace_cleaner
72
70
 
71
+ attr_accessor :write_to_file
72
+ attr_accessor :filepath
73
+ attr_accessor :files_with_pid_name_enabled
74
+ attr_accessor :files_processed_enabled
75
+ attr_accessor :files_processed_duration # seconds
76
+ attr_accessor :files_processed_size # bytes
77
+
73
78
  attr_reader :project_gem_paths
74
79
  attr_accessor :configured_options
75
80
 
@@ -134,7 +139,6 @@ module Rollbar
134
139
  @use_eventmachine = false
135
140
  @verify_ssl_peer = true
136
141
  @web_base = DEFAULT_WEB_BASE
137
- @write_to_file = false
138
142
  @send_extra_frame_data = :none
139
143
  @project_gem_paths = []
140
144
  @use_exception_level_filters_default = false
@@ -150,6 +154,12 @@ module Rollbar
150
154
  :on_report_internal_error => nil # params: exception
151
155
  }
152
156
 
157
+ @write_to_file = false
158
+ @files_with_pid_name_enabled = false
159
+ @files_processed_enabled = false
160
+ @files_processed_duration = 60
161
+ @files_processed_size = 5 * 1000 * 1000
162
+
153
163
  @configured_options = ConfiguredOptions.new(self)
154
164
  end
155
165
 
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  module Rollbar
2
4
  # Deploy Tracking API wrapper module
3
5
  module Deploy
@@ -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
@@ -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
- uuid,
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
@@ -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.unshift(trace_data(cause))
58
+ traces << trace_data(cause)
59
59
  visited << cause
60
60
  current_exception = cause
61
61
  end
@@ -1,4 +1,5 @@
1
1
  require 'rollbar/language_support'
2
+ require 'json'
2
3
 
3
4
  module Rollbar
4
5
  module JSON # :nodoc:
@@ -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
- response = ::Rack::Response.new(response_string, app_result[0],
84
- app_result[1])
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)
@@ -19,7 +19,9 @@ module Rollbar
19
19
  attr_accessor :last_report
20
20
  attr_accessor :scope_object
21
21
 
22
- @file_semaphore = Mutex.new
22
+ MUTEX = Mutex.new
23
+ EXTENSION_REGEXP = /.rollbar\z/.freeze
24
+ FAILSAFE_STRING_LENGTH = 10_000
23
25
 
24
26
  def initialize(parent_notifier = nil, payload_options = nil, scope = nil)
25
27
  if parent_notifier
@@ -103,10 +105,10 @@ module Rollbar
103
105
 
104
106
  # Sends a report to Rollbar.
105
107
  #
106
- # Accepts any number of arguments. The last String argument will become
107
- # the message or description of the report. The last Exception argument
108
- # will become the associated exception for the report. The last hash
109
- # 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.
110
112
  #
111
113
  # If the extra hash contains a symbol key :custom_data_method_context
112
114
  # the value of the key will be used as the context for
@@ -117,14 +119,14 @@ module Rollbar
117
119
  # begin
118
120
  # foo = bar
119
121
  # rescue => e
120
- # Rollbar.log(e)
122
+ # Rollbar.log('error', e)
121
123
  # end
122
124
  #
123
125
  # @example
124
- # Rollbar.log('This is a simple log message')
126
+ # Rollbar.log('info', 'This is a simple log message')
125
127
  #
126
128
  # @example
127
- # Rollbar.log(e, 'This is a description of the exception')
129
+ # Rollbar.log('error', e, 'This is a description of the exception')
128
130
  #
129
131
  def log(level, *args)
130
132
  return 'disabled' unless enabled?
@@ -157,7 +159,13 @@ module Rollbar
157
159
  def report_with_rescue(level, message, exception, extra, context)
158
160
  report(level, message, exception, extra, context)
159
161
  rescue StandardError, SystemStackError => e
160
- report_internal_error(e)
162
+ original_error = {
163
+ :message => message,
164
+ :exception => exception,
165
+ :configuration => configuration
166
+ }
167
+
168
+ report_internal_error(e, original_error)
161
169
 
162
170
  'error'
163
171
  end
@@ -200,11 +208,11 @@ module Rollbar
200
208
  def process_item(item)
201
209
  if configuration.write_to_file
202
210
  if configuration.use_async
203
- @file_semaphore.synchronize do
204
- write_item(item)
211
+ MUTEX.synchronize do
212
+ do_write_item(item)
205
213
  end
206
214
  else
207
- write_item(item)
215
+ do_write_item(item)
208
216
  end
209
217
  else
210
218
  send_item(item)
@@ -261,35 +269,34 @@ module Rollbar
261
269
  end
262
270
  end
263
271
 
264
- def send_failsafe(message, exception, uuid = nil, host = nil)
265
- exception_reason = failsafe_reason(message, exception)
266
-
267
- log_error "[Rollbar] Sending failsafe response due to #{exception_reason}"
268
-
269
- body = failsafe_body(exception_reason)
270
-
271
- failsafe_data = {
272
+ def failsafe_initial_data(exception_reason)
273
+ {
272
274
  :level => 'error',
273
275
  :environment => configuration.environment.to_s,
274
276
  :body => {
275
277
  :message => {
276
- :body => body
278
+ :body => failsafe_body(exception_reason)
277
279
  }
278
280
  },
279
281
  :notifier => {
280
282
  :name => 'rollbar-gem',
281
283
  :version => VERSION
282
284
  },
283
- :custom => {
284
- :orig_uuid => uuid,
285
- :orig_host => host
286
- },
287
285
  :internal => true,
288
- :failsafe => true
286
+ 'failsafe' => true
289
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)
290
298
 
291
299
  failsafe_payload = {
292
- 'access_token' => configuration.access_token,
293
300
  'data' => failsafe_data
294
301
  }
295
302
 
@@ -298,7 +305,9 @@ module Rollbar
298
305
  :notifier => self,
299
306
  :configuration => configuration,
300
307
  :logger => logger)
301
- schedule_item(item)
308
+
309
+ process_item(item)
310
+ log_and_return_item_data(item)
302
311
  rescue StandardError => e
303
312
  log_error "[Rollbar] Error sending failsafe : #{e}"
304
313
  end
@@ -306,6 +315,57 @@ module Rollbar
306
315
  failsafe_payload
307
316
  end
308
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
+
309
369
  ## Logging
310
370
  %w[debug info warn error].each do |level|
311
371
  define_method(:"log_#{level}") do |message|
@@ -461,7 +521,7 @@ module Rollbar
461
521
  # Reports an internal error in the Rollbar library. This will be reported within the configured
462
522
  # Rollbar project. We'll first attempt to provide a report including the exception traceback.
463
523
  # If that fails, we'll fall back to a more static failsafe response.
464
- def report_internal_error(exception)
524
+ def report_internal_error(exception, original_error = nil)
465
525
  log_error '[Rollbar] Reporting internal error encountered while sending data to Rollbar.'
466
526
 
467
527
  configuration.execute_hook(:on_report_internal_error, exception)
@@ -469,7 +529,7 @@ module Rollbar
469
529
  begin
470
530
  item = build_item('error', nil, exception, { :internal => true }, nil)
471
531
  rescue StandardError => e
472
- send_failsafe('build_item in exception_data', e)
532
+ send_failsafe('build_item in exception_data', e, original_error)
473
533
  log_error "[Rollbar] Exception: #{exception}"
474
534
  return
475
535
  end
@@ -477,7 +537,7 @@ module Rollbar
477
537
  begin
478
538
  process_item(item)
479
539
  rescue StandardError => e
480
- send_failsafe('error in process_item', e)
540
+ send_failsafe('error in process_item', e, original_error)
481
541
  log_error "[Rollbar] Item: #{item}"
482
542
  return
483
543
  end
@@ -485,7 +545,7 @@ module Rollbar
485
545
  begin
486
546
  log_instance_link(item['data'])
487
547
  rescue StandardError => e
488
- send_failsafe('error logging instance link', e)
548
+ send_failsafe('error logging instance link', e, original_error)
489
549
  log_error "[Rollbar] Item: #{item}"
490
550
  return
491
551
  end
@@ -675,27 +735,24 @@ module Rollbar
675
735
  end
676
736
  end
677
737
 
678
- def write_item(item)
679
- if configuration.use_async
680
- @file_semaphore.synchronize do
681
- do_write_item(item)
682
- end
683
- else
684
- do_write_item(item)
685
- end
686
- end
687
-
688
738
  def do_write_item(item)
689
739
  log_info '[Rollbar] Writing item to file'
690
740
 
691
741
  body = item.dump
692
742
  return unless body
693
743
 
744
+ file_name = if configuration.files_with_pid_name_enabled
745
+ configuration.filepath.gsub(EXTENSION_REGEXP, "_#{Process.pid}\\0")
746
+ else
747
+ configuration.filepath
748
+ end
749
+
694
750
  begin
695
- @file ||= File.open(configuration.filepath, 'a')
751
+ @file ||= File.open(file_name, 'a')
696
752
 
697
753
  @file.puts(body)
698
754
  @file.flush
755
+ update_file(@file, file_name)
699
756
 
700
757
  log_info '[Rollbar] Success'
701
758
  rescue IOError => e
@@ -703,6 +760,18 @@ module Rollbar
703
760
  end
704
761
  end
705
762
 
763
+ def update_file(file, file_name)
764
+ return unless configuration.files_processed_enabled
765
+
766
+ time_now = Time.now
767
+ return if configuration.files_processed_duration > time_now - file.birthtime && file.size < configuration.files_processed_size
768
+
769
+ new_file_name = file_name.gsub(EXTENSION_REGEXP, "_processed_#{time_now.to_i}\\0")
770
+ File.rename(file, new_file_name)
771
+ file.close
772
+ @file = File.open(file_name, 'a')
773
+ end
774
+
706
775
  def failsafe_reason(message, exception)
707
776
  body = ''
708
777
 
@@ -794,7 +863,7 @@ module Rollbar
794
863
  end
795
864
 
796
865
  def via_failsafe?(item)
797
- item.payload.fetch('data', {}).fetch(:failsafe, false)
866
+ item.payload.fetch('data', {}).fetch('failsafe', false)
798
867
  end
799
868
  end
800
869
  end
@@ -12,7 +12,13 @@ module Rollbar
12
12
  lifecycle.around(:invoke_job, &Delayed.invoke_job_callback)
13
13
  lifecycle.after(:failure) do |_, job, _, _|
14
14
  data = Rollbar::Delayed.build_job_data(job)
15
- ::Rollbar.scope(:request => data).error("Job has failed and won't be retried anymore: " + job.last_error, :use_exception_level_filters => true) if job.last_error
15
+
16
+ # DelayedJob < 4.1 doesn't provide job#error
17
+ if job.class.method_defined? :error
18
+ ::Rollbar.scope(:request => data).error(job.error, :use_exception_level_filters => true) if job.error
19
+ elsif job.last_error
20
+ ::Rollbar.scope(:request => data).error("Job has failed and won't be retried anymore: " + job.last_error, :use_exception_level_filters => true)
21
+ end
16
22
  end
17
23
  end
18
24
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  namespace :rollbar do
3
- desc 'Verify your gem installation by sending a test exception to Rollbar'
3
+ desc 'Verify your gem installation by sending a test message to Rollbar'
4
4
  task :test => [:environment] do
5
5
  rollbar_dir = Gem.loaded_specs['rollbar'].full_gem_path
6
6
  require "#{rollbar_dir}/lib/rollbar/rollbar_test"
@@ -131,6 +131,7 @@ module Rollbar
131
131
  host = host.split(',').first.strip unless host.empty?
132
132
 
133
133
  path = env['ORIGINAL_FULLPATH'] || env['REQUEST_URI']
134
+ path ||= "#{env['SCRIPT_NAME']}#{env['PATH_INFO']}#{"?#{env['QUERY_STRING']}" unless env['QUERY_STRING'].to_s.empty?}"
134
135
  unless path.nil? || path.empty?
135
136
  path = '/' + path.to_s if path.to_s.slice(0, 1) != '/'
136
137
  end
@@ -247,7 +248,12 @@ module Rollbar
247
248
  end
248
249
 
249
250
  def sensitive_headers_list
250
- Rollbar.configuration.scrub_headers || []
251
+ return [] unless Rollbar.configuration.scrub_headers && Rollbar.configuration.scrub_headers.is_a?(Array)
252
+
253
+ # Normalize into the expected matching format
254
+ Rollbar.configuration.scrub_headers.map do |header|
255
+ header.split(/[-_]/).map(&:capitalize).join('-').gsub(/^Http-/, '')
256
+ end
251
257
  end
252
258
  end
253
259
  end
@@ -1,48 +1,16 @@
1
1
  require 'rollbar'
2
- begin
3
- require 'rack/mock'
4
- rescue LoadError
5
- puts 'Cannot load rack/mock'
6
- end
7
- require 'logger'
8
2
 
9
- # Module to inject into the Rails controllers or rack apps
10
3
  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
4
  def self.run
18
5
  return unless confirmed_token?
19
6
 
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
7
+ puts 'Test sending to Rollbar...'
8
+ result = Rollbar.info('Test message from rollbar:test')
42
9
 
43
- Rails.logger.level = Logger::DEBUG
44
- Rollbar.preconfigure do |config|
45
- config.logger = Rails.logger
10
+ if result == 'error'
11
+ puts error_message
12
+ else
13
+ puts success_message
46
14
  end
47
15
  end
48
16
 
@@ -54,69 +22,6 @@ module RollbarTest # :nodoc:
54
22
  false
55
23
  end
56
24
 
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
25
  def self.token_error_message
121
26
  'Rollbar needs an access token configured. Check the README for instructions.'
122
27
  end
@@ -129,19 +34,3 @@ module RollbarTest # :nodoc:
129
34
  'Testing rollbar with "rake rollbar:test". If you can see this, it works.'
130
35
  end
131
36
  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
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = '2.23.2'.freeze
2
+ VERSION = '2.26.1'.freeze
3
3
  end
@@ -13,6 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.homepage = 'https://rollbar.com'
14
14
  gem.license = 'MIT'
15
15
  gem.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ gem.files += ['spec/support/rollbar_api.rb'] # useful helper for app spec/tests.
16
17
  gem.name = 'rollbar'
17
18
  gem.require_paths = ['lib']
18
19
  gem.required_ruby_version = '>= 1.9.3'
@@ -0,0 +1,67 @@
1
+ require 'rack/request'
2
+
3
+ class RollbarAPI
4
+ UNAUTHORIZED_ACCESS_TOKEN = 'unauthorized'.freeze
5
+
6
+ def call(env)
7
+ request = Rack::Request.new(env)
8
+ json = JSON.parse(request.body.read)
9
+
10
+ return unauthorized unless authorized?(json, request)
11
+
12
+ return bad_request(json) unless valid_data?(json, request)
13
+
14
+ success(json, request)
15
+ end
16
+
17
+ protected
18
+
19
+ def authorized?(_json, request)
20
+ request.env['HTTP_X_ROLLBAR_ACCESS_TOKEN'] != UNAUTHORIZED_ACCESS_TOKEN
21
+ end
22
+
23
+ def response_headers
24
+ {
25
+ 'Content-Type' => 'application/json'
26
+ }
27
+ end
28
+
29
+ def valid_data?(_json, request)
30
+ !!request.env['HTTP_X_ROLLBAR_ACCESS_TOKEN']
31
+ end
32
+
33
+ def unauthorized
34
+ [401, response_headers, [unauthorized_body]]
35
+ end
36
+
37
+ def bad_request(_json)
38
+ [400, response_headers, [bad_request_body]]
39
+ end
40
+
41
+ def success(json, request)
42
+ [200, response_headers, [success_body(json, request)]]
43
+ end
44
+
45
+ def unauthorized_body
46
+ result(1, nil, 'invalid access token')
47
+ end
48
+
49
+ def bad_request_body
50
+ result(1, nil, 'bad request')
51
+ end
52
+
53
+ def success_body(json, _request)
54
+ result(0, {
55
+ :id => rand(1_000_000),
56
+ :uuid => json['data']['uuid']
57
+ }, nil)
58
+ end
59
+
60
+ def result(err, body, message)
61
+ {
62
+ :err => err,
63
+ :result => body,
64
+ :message => message
65
+ }.to_json
66
+ end
67
+ end
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.23.2
4
+ version: 2.26.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: 2020-01-13 00:00:00.000000000 Z
11
+ date: 2020-07-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Easy and powerful exception tracking for Ruby
14
14
  email:
@@ -134,6 +134,7 @@ files:
134
134
  - lib/tasks/benchmark.rake
135
135
  - lib/tasks/tasks.rake
136
136
  - rollbar.gemspec
137
+ - spec/support/rollbar_api.rb
137
138
  homepage: https://rollbar.com
138
139
  licenses:
139
140
  - MIT
@@ -158,7 +159,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
159
  - !ruby/object:Gem::Version
159
160
  version: '0'
160
161
  requirements: []
161
- rubygems_version: 3.1.2
162
+ rubyforge_project:
163
+ rubygems_version: 2.7.7
162
164
  signing_key:
163
165
  specification_version: 4
164
166
  summary: Reports exceptions to Rollbar