").append(st.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,a||[e.responseText,t,e])}),this},st.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){st.fn[t]=function(e){return this.on(t,e)}}),st.each(["get","post"],function(e,n){st[n]=function(e,r,i,o){return st.isFunction(r)&&(o=o||i,i=r,r=t),st.ajax({url:e,type:n,dataType:o,data:r,success:i})}}),st.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Dn,type:"GET",isLocal:Fn.test(jn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":In,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":e.String,"text html":!0,"text json":st.parseJSON,"text xml":st.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?H(H(e,st.ajaxSettings),t):H(st.ajaxSettings,e)},ajaxPrefilter:D(Wn),ajaxTransport:D($n),ajax:function(e,n){function r(e,n,r,s){var l,f,v,b,T,N=n;2!==x&&(x=2,u&&clearTimeout(u),i=t,a=s||"",w.readyState=e>0?4:0,r&&(b=M(p,w,r)),e>=200&&300>e||304===e?(p.ifModified&&(T=w.getResponseHeader("Last-Modified"),T&&(st.lastModified[o]=T),T=w.getResponseHeader("etag"),T&&(st.etag[o]=T)),304===e?(l=!0,N="notmodified"):(l=q(p,b),N=l.state,f=l.data,v=l.error,l=!v)):(v=N,(e||!N)&&(N="error",0>e&&(e=0))),w.status=e,w.statusText=(n||N)+"",l?g.resolveWith(d,[f,N,w]):g.rejectWith(d,[w,N,v]),w.statusCode(y),y=t,c&&h.trigger(l?"ajaxSuccess":"ajaxError",[w,p,l?f:v]),m.fireWith(d,[w,N]),c&&(h.trigger("ajaxComplete",[w,p]),--st.active||st.event.trigger("ajaxStop")))}"object"==typeof e&&(n=e,e=t),n=n||{};var i,o,a,s,u,l,c,f,p=st.ajaxSetup({},n),d=p.context||p,h=p.context&&(d.nodeType||d.jquery)?st(d):st.event,g=st.Deferred(),m=st.Callbacks("once memory"),y=p.statusCode||{},v={},b={},x=0,T="canceled",w={readyState:0,getResponseHeader:function(e){var t;if(2===x){if(!s)for(s={};t=_n.exec(a);)s[t[1].toLowerCase()]=t[2];t=s[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===x?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return x||(e=b[n]=b[n]||e,v[e]=t),this},overrideMimeType:function(e){return x||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>x)for(t in e)y[t]=[y[t],e[t]];else w.always(e[w.status]);return this},abort:function(e){var t=e||T;return i&&i.abort(t),r(0,t),this}};if(g.promise(w).complete=m.add,w.success=w.done,w.error=w.fail,p.url=((e||p.url||Dn)+"").replace(Mn,"").replace(Bn,jn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=st.trim(p.dataType||"*").toLowerCase().match(lt)||[""],null==p.crossDomain&&(l=Pn.exec(p.url.toLowerCase()),p.crossDomain=!(!l||l[1]===jn[1]&&l[2]===jn[2]&&(l[3]||("http:"===l[1]?80:443))==(jn[3]||("http:"===jn[1]?80:443)))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=st.param(p.data,p.traditional)),L(Wn,p,n,w),2===x)return w;c=p.global,c&&0===st.active++&&st.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!On.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(Hn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=qn.test(o)?o.replace(qn,"$1_="+Ln++):o+(Hn.test(o)?"&":"?")+"_="+Ln++)),p.ifModified&&(st.lastModified[o]&&w.setRequestHeader("If-Modified-Since",st.lastModified[o]),st.etag[o]&&w.setRequestHeader("If-None-Match",st.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&w.setRequestHeader("Content-Type",p.contentType),w.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+In+"; q=0.01":""):p.accepts["*"]);for(f in p.headers)w.setRequestHeader(f,p.headers[f]);if(p.beforeSend&&(p.beforeSend.call(d,w,p)===!1||2===x))return w.abort();T="abort";for(f in{success:1,error:1,complete:1})w[f](p[f]);if(i=L($n,p,n,w)){w.readyState=1,c&&h.trigger("ajaxSend",[w,p]),p.async&&p.timeout>0&&(u=setTimeout(function(){w.abort("timeout")},p.timeout));try{x=1,i.send(v,r)}catch(N){if(!(2>x))throw N;r(-1,N)}}else r(-1,"No Transport");return w},getScript:function(e,n){return st.get(e,t,n,"script")},getJSON:function(e,t,n){return st.get(e,t,n,"json")}}),st.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return st.globalEval(e),e}}}),st.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),st.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=V.head||st("head")[0]||V.documentElement;return{send:function(t,i){n=V.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var Xn=[],Un=/(=)\?(?=&|$)|\?\?/;st.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Xn.pop()||st.expando+"_"+Ln++;return this[e]=!0,e}}),st.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,u=n.jsonp!==!1&&(Un.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Un.test(n.data)&&"data");return u||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=st.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,u?n[u]=n[u].replace(Un,"$1"+o):n.jsonp!==!1&&(n.url+=(Hn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||st.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,Xn.push(o)),s&&st.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Vn,Yn,Jn=0,Gn=e.ActiveXObject&&function(){var e;for(e in Vn)Vn[e](t,!0)};st.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&_()||F()}:_,Yn=st.ajaxSettings.xhr(),st.support.cors=!!Yn&&"withCredentials"in Yn,Yn=st.support.ajax=!!Yn,Yn&&st.ajaxTransport(function(n){if(!n.crossDomain||st.support.cors){var r;return{send:function(i,o){var a,s,u=n.xhr();if(n.username?u.open(n.type,n.url,n.async,n.username,n.password):u.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)u[s]=n.xhrFields[s];n.mimeType&&u.overrideMimeType&&u.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)u.setRequestHeader(s,i[s])}catch(l){}u.send(n.hasContent&&n.data||null),r=function(e,i){var s,l,c,f,p;try{if(r&&(i||4===u.readyState))if(r=t,a&&(u.onreadystatechange=st.noop,Gn&&delete Vn[a]),i)4!==u.readyState&&u.abort();else{f={},s=u.status,p=u.responseXML,c=u.getAllResponseHeaders(),p&&p.documentElement&&(f.xml=p),"string"==typeof u.responseText&&(f.text=u.responseText);try{l=u.statusText}catch(d){l=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=f.text?200:404}}catch(h){i||o(-1,h)}f&&o(s,l,f,c)},n.async?4===u.readyState?setTimeout(r):(a=++Jn,Gn&&(Vn||(Vn={},st(e).unload(Gn)),Vn[a]=r),u.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Qn,Kn,Zn=/^(?:toggle|show|hide)$/,er=RegExp("^(?:([+-])=|)("+ut+")([a-z%]*)$","i"),tr=/queueHooks$/,nr=[W],rr={"*":[function(e,t){var n,r,i=this.createTween(e,t),o=er.exec(t),a=i.cur(),s=+a||0,u=1,l=20;if(o){if(n=+o[2],r=o[3]||(st.cssNumber[e]?"":"px"),"px"!==r&&s){s=st.css(i.elem,e,!0)||n||1;do u=u||".5",s/=u,st.style(i.elem,e,s+r);while(u!==(u=i.cur()/a)&&1!==u&&--l)}i.unit=r,i.start=s,i.end=o[1]?s+(o[1]+1)*n:n}return i}]};st.Animation=st.extend(P,{tweener:function(e,t){st.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");for(var n,r=0,i=e.length;i>r;r++)n=e[r],rr[n]=rr[n]||[],rr[n].unshift(t)},prefilter:function(e,t){t?nr.unshift(e):nr.push(e)}}),st.Tween=$,$.prototype={constructor:$,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(st.cssNumber[n]?"":"px")},cur:function(){var e=$.propHooks[this.prop];return e&&e.get?e.get(this):$.propHooks._default.get(this)},run:function(e){var t,n=$.propHooks[this.prop];return this.pos=t=this.options.duration?st.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):$.propHooks._default.set(this),this}},$.prototype.init.prototype=$.prototype,$.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=st.css(e.elem,e.prop,"auto"),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){st.fx.step[e.prop]?st.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[st.cssProps[e.prop]]||st.cssHooks[e.prop])?st.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},$.propHooks.scrollTop=$.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},st.each(["toggle","show","hide"],function(e,t){var n=st.fn[t];st.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(I(t,!0),e,r,i)}}),st.fn.extend({fadeTo:function(e,t,n,r){return this.filter(w).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=st.isEmptyObject(e),o=st.speed(t,n,r),a=function(){var t=P(this,st.extend({},e),o);a.finish=function(){t.stop(!0)},(i||st._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=st.timers,a=st._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&tr.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&st.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=st._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=st.timers,a=r?r.length:0;for(n.finish=!0,st.queue(this,e,[]),i&&i.cur&&i.cur.finish&&i.cur.finish.call(this),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}}),st.each({slideDown:I("show"),slideUp:I("hide"),slideToggle:I("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){st.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),st.speed=function(e,t,n){var r=e&&"object"==typeof e?st.extend({},e):{complete:n||!n&&t||st.isFunction(e)&&e,duration:e,easing:n&&t||t&&!st.isFunction(t)&&t};return r.duration=st.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in st.fx.speeds?st.fx.speeds[r.duration]:st.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){st.isFunction(r.old)&&r.old.call(this),r.queue&&st.dequeue(this,r.queue)},r},st.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},st.timers=[],st.fx=$.prototype.init,st.fx.tick=function(){var e,n=st.timers,r=0;for(Qn=st.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||st.fx.stop(),Qn=t},st.fx.timer=function(e){e()&&st.timers.push(e)&&st.fx.start()},st.fx.interval=13,st.fx.start=function(){Kn||(Kn=setInterval(st.fx.tick,st.fx.interval))},st.fx.stop=function(){clearInterval(Kn),Kn=null},st.fx.speeds={slow:600,fast:200,_default:400},st.fx.step={},st.expr&&st.expr.filters&&(st.expr.filters.animated=function(e){return st.grep(st.timers,function(t){return e===t.elem}).length}),st.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){st.offset.setOffset(this,e,t)});var n,r,i={top:0,left:0},o=this[0],a=o&&o.ownerDocument;if(a)return n=a.documentElement,st.contains(n,o)?(o.getBoundingClientRect!==t&&(i=o.getBoundingClientRect()),r=z(a),{top:i.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:i.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):i},st.offset={setOffset:function(e,t,n){var r=st.css(e,"position");"static"===r&&(e.style.position="relative");var i,o,a=st(e),s=a.offset(),u=st.css(e,"top"),l=st.css(e,"left"),c=("absolute"===r||"fixed"===r)&&st.inArray("auto",[u,l])>-1,f={},p={};c?(p=a.position(),i=p.top,o=p.left):(i=parseFloat(u)||0,o=parseFloat(l)||0),st.isFunction(t)&&(t=t.call(e,n,s)),null!=t.top&&(f.top=t.top-s.top+i),null!=t.left&&(f.left=t.left-s.left+o),"using"in t?t.using.call(e,f):a.css(f)}},st.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===st.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),st.nodeName(e[0],"html")||(n=e.offset()),n.top+=st.css(e[0],"borderTopWidth",!0),n.left+=st.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-st.css(r,"marginTop",!0),left:t.left-n.left-st.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var e=this.offsetParent||V.documentElement;e&&!st.nodeName(e,"html")&&"static"===st.css(e,"position");)e=e.offsetParent;return e||V.documentElement})}}),st.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);st.fn[e]=function(i){return st.access(this,function(e,i,o){var a=z(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?st(a).scrollLeft():o,r?o:st(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}}),st.each({Height:"height",Width:"width"},function(e,n){st.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){st.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return st.access(this,function(n,r,i){var o;return st.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?st.css(n,r,s):st.style(n,r,i,s)},n,a?i:t,a,null)}})}),e.jQuery=e.$=st,"function"==typeof define&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return st})})(window);
-//@ sourceMappingURL=jquery.min.map
\ No newline at end of file
diff --git a/example/padrino/test/test.rake b/example/padrino/test/test.rake
deleted file mode 100644
index e6910056e..000000000
--- a/example/padrino/test/test.rake
+++ /dev/null
@@ -1,13 +0,0 @@
-require 'rake/testtask'
-
-test_tasks = Dir['test/*/'].map { |d| File.basename(d) }
-
-test_tasks.each do |folder|
- Rake::TestTask.new("test:#{folder}") do |test|
- test.pattern = "test/#{folder}/**/*_test.rb"
- test.verbose = true
- end
-end
-
-desc "Run application test suite"
-task 'test' => test_tasks.map { |f| "test:#{f}" }
diff --git a/example/padrino/test/test_config.rb b/example/padrino/test/test_config.rb
deleted file mode 100644
index 1dab63b95..000000000
--- a/example/padrino/test/test_config.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-RACK_ENV = 'test' unless defined?(RACK_ENV)
-require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
-require 'mocha/api'
-# Specify your app using the #app helper inside a context.
-# Takes either an app class or a block argument.
- include Mocha::API
-# app { Padrino.application }
-# app { BugsnagPadrino::App.tap { |app| } }
-
-class Riot::Situation
- include Mocha::API
- include Rack::Test::Methods
-
- # You can use this method to custom specify a Rack app
- # you want rack-test to invoke:
- #
- # app BugsnagPadrino::App
- # app BugsnagPadrino::App.tap { |a| }
- # app(BugsnagPadrino::App) do
- # set :foo, :bar
- # end
- #
- def app(app = nil, &blk)
- @app ||= block_given? ? app.instance_eval(&blk) : app
- @app ||= Padrino.application
- end
-end
-
-class Riot::Context
- include Mocha::API
-end
-
diff --git a/example/rack/Gemfile b/example/rack/Gemfile
index dc9792492..42b669e90 100644
--- a/example/rack/Gemfile
+++ b/example/rack/Gemfile
@@ -1,7 +1,7 @@
source 'https://rubygems.org'
if ENV['INTEGRATION_LANGUAGE']
- gem 'bugsnag', path: '../../../../'
+ gem 'bugsnag', path: '../../'
else
gem 'bugsnag'
end
diff --git a/example/rack/README.md b/example/rack/README.md
index 2f34fefb5..74cfdffa1 100644
--- a/example/rack/README.md
+++ b/example/rack/README.md
@@ -1,70 +1,40 @@
# Bugsnag Rack demo
-This Rack application demonstrates how to use Bugsnag with Rack. Before testing
-it, open up the `config.ru` file and configure your API key (you can find the
-configuration block at the bottom of the file).
+This Rack application demonstrates how to use Bugsnag with Rack.
+Further details about integrating Bugsnag with Rack applications can be found [here.](https://docs.bugsnag.com/platforms/ruby/rack/)
-```
-Bugsnag.configure do |config|
- config.api_key = '0a6f5add590596f93a8d601ea89af841'
-end
-```
-
-The other way to configure the API key is to export the `BUGSNAG_API_KEY`
-environment variable.
-
-Activate the Bugsnag Rack middleware by wrapping the `BugsnagDemo` application
-(again, look for it at the bottom of `config.ru`).
-
-```
-Bugsnag::Rack.new(BugsnagDemo.new)
-```
+Install dependencies
-Make use you are not using `ShowExceptions`. Otherwise, in the development
-environment, automatic notifications won't work, as Rack would be swallowing
-exceptions from Bugsnag.
-
-Install dependencies.
-
-```
+```shell
bundle install
```
-Launch the Rack application.
+## Configuring Bugsnag and Rack
-```
-bundle exec ruby config.ru
-```
+1. Set up the Bugsnag configuration in ```server.rb``` by calling `Bugsnag.configure` and setting your API key and any other options [as detailed in the configuration options](https://docs.bugsnag.com/platforms/ruby/rack/configuration-options/):
+ ```ruby
+ Bugsnag.configure do |config|
+ config.api_key = 'YOUR_API_KEY'
+ end
+ ```
+
+2. Alternatively the API key can be set by exported it as a `BUGSNAG_API_KEY` environment variable.
-Next, open your project's dashboard on Bugsnag.
+3. To enable automatic notification in the Rack server the server object must be wrapped in an instance of `Bugsnag::Rack` which is then passed to the `Rack::Server` to be started:
+ ```ruby
+ server = BugsnagDemo.new
+ wrapped_app = Bugsnag::Rack.new(server)
+ Rack::Server.start(app: wrapped_app)
+ ```
-1. [crash](http://localhost:9292/crash)
-
-Crashes the application and sends a notification about the nature of the crash.
-Basically, almost any unhandled exception sends a notification to Bugsnag. See
-the line mentioning `get '/crash'`.
+4. Ensure that `ShowExceptions` is set to false, otherwise notifications will not be sent while in development mode.
-1. [crash and use callbacks](http://localhost:9292/crash_with_callback)
-
-Before crashing, the application would append the Diagnostics tab with some
-predefined information, attached by means of a callback. See the line mentioning
-`get '/crash_with_callback'`.
+## Running the example
-1. [notify](http://localhost:9292/notify)
-
-Bugsnag Ruby provides a way to send notifications on demand by means of
-`Bugsnag.notify`. This API allows to send notifications manually, without
-crashing your application. See the line mentioning `get '/notify'`.
+Run the example using:
-1. [notify with meta data](http://localhost:9292/notify_meta)
-
-Same as `notify`, but also attaches meta data. The meta data is any additional
-information you want to attach to an exception. In this artificial case
-additional information with be sent and displayed in a new tab called
-"Diagnostics". See the line mentioning `get '/notify_meta'`.
+```shell
+bundle exec ruby server.rb
+```
-1. [severity](http://localhost:9292/severity)
-
-Bugsnag supports three severities: 'error', 'warning' and 'info'. You can set
-the severity by passing one of these objects as a string to '#notify'. See the
-line mentioning `get '/severity'`.
+Once the server is running head to the default path for more information on Bugsnag logging examples.
\ No newline at end of file
diff --git a/example/rack/config.ru b/example/rack/server.rb
similarity index 80%
rename from example/rack/config.ru
rename to example/rack/server.rb
index 476edb7f5..c02887894 100644
--- a/example/rack/config.ru
+++ b/example/rack/server.rb
@@ -1,5 +1,4 @@
require 'rack'
-require 'rack/showexceptions'
require 'rack/request'
require 'rack/response'
@@ -8,7 +7,7 @@
Bugsnag.configure do |config|
- config.api_key = 'f35a2472bd230ac0ab0f52715bbdc65d'
+ config.api_key = 'YOUR_API_KEY'
end
class BugsnagDemo
@@ -20,12 +19,12 @@ def call(env)
raise RuntimeError.new('Bugsnag Rack demo says: It crashed! Go check ' +
'bugsnag.com for a new notification!')
when '/crash_with_callback'
- Bugsnag.before_notify_callbacks << proc { |notification|
+ Bugsnag.before_notify_callbacks << proc { |report|
new_tab = {
message: 'Rack demo says: Everything is great',
code: 200
}
- notification.add_tab(:diagnostics, new_tab)
+ report.add_tab(:diagnostics, new_tab)
}
msg = 'Bugsnag Rack demo says: It crashed! But, due to the attached callback' +
@@ -38,36 +37,36 @@ def call(env)
text = "Bugsnag Rack demo says: It didn't crash! " +
'But still go check
https://bugsnag.com' +
' for a new notification.'
- when '/notify_meta'
- meta_data = {
- :user => {
+ when '/notify_data'
+ error = RuntimeError.new("Bugsnag Rack demo says: False alarm, your application didn't crash")
+ Bugsnag.notify error do |report|
+ report.add_tab(:user, {
:username => "bob-hoskins",
:email => 'bugsnag@bugsnag.com',
:registered_user => true
- },
-
- :diagnostics => {
+ })
+ report.add_tab(:diagnostics, {
:message => 'Rack demo says: Everything is great',
:code => 200
- }
- }
- error = RuntimeError.new("Bugsnag Rack demo says: False alarm, your application didn't crash")
- Bugsnag.notify(error, meta_data)
+ })
+ end
text = "Bugsnag Rack demo says: It didn't crash! " +
'But still go check
https://bugsnag.com' +
' for a new notification. Check out the User tab for the meta data'
- when '/severity'
+ when '/notify_severity'
msg = "Bugsnag Rack demo says: Look at the circle on the right side. It's different"
error = RuntimeError.new(msg)
- Bugsnag.notify(error, severity: 'info')
- msg
+ Bugsnag.notify error do |report|
+ report.severity = 'info'
+ end
+ text = msg
else
opts = {
fenced_code_blocks: true
}
renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML, opts)
- text = renderer.render(File.read(File.expand_path('README.md')))
+ text = renderer.render(File.read(File.expand_path('templates/index.md')))
end
res = Rack::Response.new
diff --git a/example/rack/templates/index.md b/example/rack/templates/index.md
new file mode 100644
index 000000000..52695efe2
--- /dev/null
+++ b/example/rack/templates/index.md
@@ -0,0 +1,25 @@
+# Bugsnag Rack demo
+
+This application demonstrates the use of Bugsnag with the Rack web framework.
+
+While testing the examples open [your dashboard](https://app.bugsnag.com) in order to see the example errors and exceptions being received.
+
+1. [Crash](/crash)
+
+ Raises an error within the framework, generating a report in the Bugsnag dashboard.
+
+2. [Crash and use callbacks](/crash_with_callback)
+
+ Raises an exception within the framework, but with additional data attached to the report. By registering a callback before the error occurs useful data can be attached as a tab in the Bugsnag dashboard.
+
+3. [Notify](/notify)
+
+ Sends Bugsnag a report on demand using `bugsnag.notify`. Allows details of handled errors or information to be sent to the Bugsnag dashboard without crashing your code.
+
+4. [Notify with data](/notify_data)
+
+ Same as `notify` but allows you to attach additional data within a `block`, similar to the `before_notify_callbacks` example above. In this case we're adding information about the user to go into the `user` tab, and additional diagnostics as a `diagnostics` tab.
+
+5. [Set the severity](/notify_severity)
+
+ This uses the same mechanism as adding meta-data, but allows you to set he `severity` when notifying Bugsnag of the error. Valid severities are `error`, `warning`, and `info`. Have a look on the dashboard to see the difference in these severities.
\ No newline at end of file
diff --git a/example/rails-32/.gitignore b/example/rails-32/.gitignore
deleted file mode 100644
index eb3489a98..000000000
--- a/example/rails-32/.gitignore
+++ /dev/null
@@ -1,15 +0,0 @@
-# See http://help.github.com/ignore-files/ for more about ignoring files.
-#
-# If you find yourself ignoring temporary files generated by your text editor
-# or operating system, you probably want to add a global ignore instead:
-# git config --global core.excludesfile ~/.gitignore_global
-
-# Ignore bundler config
-/.bundle
-
-# Ignore the default SQLite database.
-/db/*.sqlite3
-
-# Ignore all logfiles and tempfiles.
-/log/*.log
-/tmp
diff --git a/example/rails-32/Gemfile b/example/rails-32/Gemfile
index 0cd5ea4b9..09a043f5b 100644
--- a/example/rails-32/Gemfile
+++ b/example/rails-32/Gemfile
@@ -1,6 +1,6 @@
source 'https://rubygems.org'
-gem 'rails', '3.2.13'
+gem 'rails', '3.2.22.5'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
@@ -37,3 +37,6 @@ gem 'jquery-rails'
# To use debugger
# gem 'debugger'
+
+# Added at 2017-09-28 14:54:05 +0100 by amoinet:
+gem "redcarpet", "~> 3.4"
diff --git a/example/rails-32/README.md b/example/rails-32/README.md
new file mode 100644
index 000000000..a548534ec
--- /dev/null
+++ b/example/rails-32/README.md
@@ -0,0 +1,33 @@
+# Bugsnag Rails v3.2 demo
+
+This Rails application demonstrates how to use Bugsnag with Rails v3.2.
+Further details about integrating Bugsnag with Rack applications can be found [here.](https://docs.bugsnag.com/platforms/ruby/rails/)
+
+Install dependencies
+
+```shell
+bundle install
+```
+
+## Configuring Bugsnag and Rails v3.2
+
+There are two methods of configuring Bugsnag within a Rails application:
+
+1. Your `API_KEY` can be exported as an environment variable `BUGSNAG_API_KEY`.
+
+2. Generate a bugsnag configuration file at ```config/initializers/bugsnag.rb``` which can be populated with the [available configuration options](https://docs.bugsnag.com/platforms/ruby/rails/configuration-options/) by running the rails command:
+ ```shell
+ rails generate bugsnag YOUR_API_KEY_HERE
+ ```
+
+This is sufficient to start reporting unhandled exceptions to Bugsnag.
+
+## Running the example
+
+Run the example using:
+
+```shell
+bundle exec rails server
+```
+
+Once the server is running head to the default path for more information on Bugsnag logging examples.
diff --git a/example/rails-32/README.rdoc b/example/rails-32/README.rdoc
deleted file mode 100644
index 3e1c15c81..000000000
--- a/example/rails-32/README.rdoc
+++ /dev/null
@@ -1,261 +0,0 @@
-== Welcome to Rails
-
-Rails is a web-application framework that includes everything needed to create
-database-backed web applications according to the Model-View-Control pattern.
-
-This pattern splits the view (also called the presentation) into "dumb"
-templates that are primarily responsible for inserting pre-built data in between
-HTML tags. The model contains the "smart" domain objects (such as Account,
-Product, Person, Post) that holds all the business logic and knows how to
-persist themselves to a database. The controller handles the incoming requests
-(such as Save New Account, Update Product, Show Post) by manipulating the model
-and directing data to the view.
-
-In Rails, the model is handled by what's called an object-relational mapping
-layer entitled Active Record. This layer allows you to present the data from
-database rows as objects and embellish these data objects with business logic
-methods. You can read more about Active Record in
-link:files/vendor/rails/activerecord/README.html.
-
-The controller and view are handled by the Action Pack, which handles both
-layers by its two parts: Action View and Action Controller. These two layers
-are bundled in a single package due to their heavy interdependence. This is
-unlike the relationship between the Active Record and Action Pack that is much
-more separate. Each of these packages can be used independently outside of
-Rails. You can read more about Action Pack in
-link:files/vendor/rails/actionpack/README.html.
-
-
-== Getting Started
-
-1. At the command prompt, create a new Rails application:
-
rails new myapp (where
myapp is the application name)
-
-2. Change directory to
myapp and start the web server:
-
cd myapp; rails server (run with --help for options)
-
-3. Go to http://localhost:3000/ and you'll see:
- "Welcome aboard: You're riding Ruby on Rails!"
-
-4. Follow the guidelines to start developing your application. You can find
-the following resources handy:
-
-* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
-* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
-
-
-== Debugging Rails
-
-Sometimes your application goes wrong. Fortunately there are a lot of tools that
-will help you debug it and get it back on the rails.
-
-First area to check is the application log files. Have "tail -f" commands
-running on the server.log and development.log. Rails will automatically display
-debugging and runtime information to these files. Debugging info will also be
-shown in the browser on requests from 127.0.0.1.
-
-You can also log your own messages directly into the log file from your code
-using the Ruby logger class from inside your controllers. Example:
-
- class WeblogController < ActionController::Base
- def destroy
- @weblog = Weblog.find(params[:id])
- @weblog.destroy
- logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
- end
- end
-
-The result will be a message in your log file along the lines of:
-
- Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
-
-More information on how to use the logger is at http://www.ruby-doc.org/core/
-
-Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
-several books available online as well:
-
-* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
-* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
-
-These two books will bring you up to speed on the Ruby language and also on
-programming in general.
-
-
-== Debugger
-
-Debugger support is available through the debugger command when you start your
-Mongrel or WEBrick server with --debugger. This means that you can break out of
-execution at any point in the code, investigate and change the model, and then,
-resume execution! You need to install ruby-debug to run the server in debugging
-mode. With gems, use
sudo gem install ruby-debug. Example:
-
- class WeblogController < ActionController::Base
- def index
- @posts = Post.all
- debugger
- end
- end
-
-So the controller will accept the action, run the first line, then present you
-with a IRB prompt in the server window. Here you can do things like:
-
- >> @posts.inspect
- => "[#
nil, "body"=>nil, "id"=>"1"}>,
- #"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
- >> @posts.first.title = "hello from a debugger"
- => "hello from a debugger"
-
-...and even better, you can examine how your runtime objects actually work:
-
- >> f = @posts.first
- => #nil, "body"=>nil, "id"=>"1"}>
- >> f.
- Display all 152 possibilities? (y or n)
-
-Finally, when you're ready to resume execution, you can enter "cont".
-
-
-== Console
-
-The console is a Ruby shell, which allows you to interact with your
-application's domain model. Here you'll have all parts of the application
-configured, just like it is when the application is running. You can inspect
-domain models, change values, and save to the database. Starting the script
-without arguments will launch it in the development environment.
-
-To start the console, run rails console from the application
-directory.
-
-Options:
-
-* Passing the -s, --sandbox argument will rollback any modifications
- made to the database.
-* Passing an environment name as an argument will load the corresponding
- environment. Example: rails console production.
-
-To reload your controllers and models after launching the console run
-reload!
-
-More information about irb can be found at:
-link:http://www.rubycentral.org/pickaxe/irb.html
-
-
-== dbconsole
-
-You can go to the command line of your database directly through rails
-dbconsole. You would be connected to the database with the credentials
-defined in database.yml. Starting the script without arguments will connect you
-to the development database. Passing an argument will connect you to a different
-database, like rails dbconsole production. Currently works for MySQL,
-PostgreSQL and SQLite 3.
-
-== Description of Contents
-
-The default directory structure of a generated Ruby on Rails application:
-
- |-- app
- | |-- assets
- | | |-- images
- | | |-- javascripts
- | | `-- stylesheets
- | |-- controllers
- | |-- helpers
- | |-- mailers
- | |-- models
- | `-- views
- | `-- layouts
- |-- config
- | |-- environments
- | |-- initializers
- | `-- locales
- |-- db
- |-- doc
- |-- lib
- | |-- assets
- | `-- tasks
- |-- log
- |-- public
- |-- script
- |-- test
- | |-- fixtures
- | |-- functional
- | |-- integration
- | |-- performance
- | `-- unit
- |-- tmp
- | `-- cache
- | `-- assets
- `-- vendor
- |-- assets
- | |-- javascripts
- | `-- stylesheets
- `-- plugins
-
-app
- Holds all the code that's specific to this particular application.
-
-app/assets
- Contains subdirectories for images, stylesheets, and JavaScript files.
-
-app/controllers
- Holds controllers that should be named like weblogs_controller.rb for
- automated URL mapping. All controllers should descend from
- ApplicationController which itself descends from ActionController::Base.
-
-app/models
- Holds models that should be named like post.rb. Models descend from
- ActiveRecord::Base by default.
-
-app/views
- Holds the template files for the view that should be named like
- weblogs/index.html.erb for the WeblogsController#index action. All views use
- eRuby syntax by default.
-
-app/views/layouts
- Holds the template files for layouts to be used with views. This models the
- common header/footer method of wrapping views. In your views, define a layout
- using the layout :default and create a file named default.html.erb.
- Inside default.html.erb, call <% yield %> to render the view using this
- layout.
-
-app/helpers
- Holds view helpers that should be named like weblogs_helper.rb. These are
- generated for you automatically when using generators for controllers.
- Helpers can be used to wrap functionality for your views into methods.
-
-config
- Configuration files for the Rails environment, the routing map, the database,
- and other dependencies.
-
-db
- Contains the database schema in schema.rb. db/migrate contains all the
- sequence of Migrations for your schema.
-
-doc
- This directory is where your application documentation will be stored when
- generated using rake doc:app
-
-lib
- Application specific libraries. Basically, any kind of custom code that
- doesn't belong under controllers, models, or helpers. This directory is in
- the load path.
-
-public
- The directory available for the web server. Also contains the dispatchers and the
- default HTML files. This should be set as the DOCUMENT_ROOT of your web
- server.
-
-script
- Helper scripts for automation and generation.
-
-test
- Unit and functional tests along with fixtures. When using the rails generate
- command, template test files will be generated for you and placed in this
- directory.
-
-vendor
- External libraries that the application depends on. Also includes the plugins
- subdirectory. If the app has frozen rails, those gems also go here, under
- vendor/rails/. This directory is in the load path.
diff --git a/example/rails-32/app/controllers/application_controller.rb b/example/rails-32/app/controllers/application_controller.rb
index 473548d74..4d2f430b3 100644
--- a/example/rails-32/app/controllers/application_controller.rb
+++ b/example/rails-32/app/controllers/application_controller.rb
@@ -2,6 +2,59 @@ class ApplicationController < ActionController::Base
protect_from_forgery
def index
- raise "Yo"
+ @text = File.read(File.expand_path('app/views/index.md'))
end
+
+ def crash
+ raise Exception.new('Bugsnag Rails demo says: It crashed! Go check ' +
+ 'bugsnag.com for a new notification')
+ end
+
+ def callback
+ Bugsnag.before_notify_callbacks << proc { |report|
+ new_tab = {
+ message: 'Rails v3.2 demo says: Everything is great',
+ code: 200
+ }
+ report.add_tab(:diagnostics, new_tab)
+ }
+ raise RuntimeError.new('Bugsnag Rails demo says: It crashed! But, due to the attached callback' +
+ ' the exception has meta information. Go check' +
+ ' bugsnag.com for a new notification (see the Diagnostics tab)!')
+ end
+
+ def notify
+ Bugsnag.notify(RuntimeError.new("Bugsnag Rails demo says: False alarm, your application didn't crash"))
+ @text = "Bugsnag Rack demo says: It didn't crash! " +
+ 'But still go check https://bugsnag.com' +
+ ' for a new notification.'
+ end
+
+ def data
+ error = RuntimeError.new("Bugsnag Rails demo says: False alarm, your application didn't crash")
+ Bugsnag.notify error do |report|
+ report.add_tab(:user, {
+ :username => "bob-hoskins",
+ :email => 'bugsnag@bugsnag.com',
+ :registered_user => true
+ })
+ report.add_tab(:diagnostics, {
+ :message => 'Rails demo says: Everything is great',
+ :code => 200
+ })
+ end
+ @text = "Bugsnag Rails demo says: It didn't crash! " +
+ 'But still go check https://bugsnag.com' +
+ ' for a new notification. Check out the User tab for the meta data'
+ end
+
+ def severity
+ msg = "Bugsnag Rails demo says: Look at the circle on the right side. It's different"
+ error = RuntimeError.new(msg)
+ Bugsnag.notify error do |report|
+ report.severity = 'info'
+ end
+ @text = msg
+ end
+
end
diff --git a/example/rails-32/app/helpers/application_helper.rb b/example/rails-32/app/helpers/application_helper.rb
index de6be7945..6d77519db 100644
--- a/example/rails-32/app/helpers/application_helper.rb
+++ b/example/rails-32/app/helpers/application_helper.rb
@@ -1,2 +1,22 @@
module ApplicationHelper
+ def markdown(text)
+ options = {
+ filter_html: true,
+ hard_wrap: true,
+ link_attributes: { rel: 'nofollow', target: "_blank" },
+ space_after_headers: true,
+ fenced_code_blocks: true
+ }
+
+ extensions = {
+ autolink: true,
+ superscript: true,
+ disable_indented_code_blocks: true
+ }
+
+ renderer = Redcarpet::Render::HTML.new(options)
+ markdown = Redcarpet::Markdown.new(renderer, extensions)
+
+ markdown.render(text).html_safe
+ end
end
diff --git a/example/rails-32/app/views/application/data.html.erb b/example/rails-32/app/views/application/data.html.erb
new file mode 100644
index 000000000..aa2786a7d
--- /dev/null
+++ b/example/rails-32/app/views/application/data.html.erb
@@ -0,0 +1 @@
+<%= markdown(@text)%>
\ No newline at end of file
diff --git a/example/rails-32/app/views/application/index.html.erb b/example/rails-32/app/views/application/index.html.erb
new file mode 100644
index 000000000..aa2786a7d
--- /dev/null
+++ b/example/rails-32/app/views/application/index.html.erb
@@ -0,0 +1 @@
+<%= markdown(@text)%>
\ No newline at end of file
diff --git a/example/rails-32/app/views/application/notify.html.erb b/example/rails-32/app/views/application/notify.html.erb
new file mode 100644
index 000000000..aa2786a7d
--- /dev/null
+++ b/example/rails-32/app/views/application/notify.html.erb
@@ -0,0 +1 @@
+<%= markdown(@text)%>
\ No newline at end of file
diff --git a/example/rails-32/app/views/application/severity.html.erb b/example/rails-32/app/views/application/severity.html.erb
new file mode 100644
index 000000000..aa2786a7d
--- /dev/null
+++ b/example/rails-32/app/views/application/severity.html.erb
@@ -0,0 +1 @@
+<%= markdown(@text)%>
\ No newline at end of file
diff --git a/example/rails-32/app/views/index.md b/example/rails-32/app/views/index.md
new file mode 100644
index 000000000..efbc05be3
--- /dev/null
+++ b/example/rails-32/app/views/index.md
@@ -0,0 +1,25 @@
+# Bugsnag Rails v3.2 demo
+
+This application demonstrates the use of Bugsnag with the Rails web framework.
+
+While testing the examples open [your dashboard](https://app.bugsnag.com) in order to see the example errors and exceptions being received.
+
+1. [Crash](/crash)
+
+ Raises an error within the framework, generating a report in the Bugsnag dashboard.
+
+2. [Crash and use callbacks](/crash_with_callback)
+
+ Raises an exception within the framework, but with additional data attached to the report. By registering a callback before the error occurs useful data can be attached as a tab in the Bugsnag dashboard.
+
+3. [Notify](/notify)
+
+ Sends Bugsnag a report on demand using `bugsnag.notify`. Allows details of handled errors or information to be sent to the Bugsnag dashboard without crashing your code.
+
+4. [Notify with data](/notify_data)
+
+ Same as `notify` but allows you to attach additional data within a `block`, similar to the `before_notify_callbacks` example above. In this case we're adding information about the user to go into the `user` tab, and additional diagnostics as a `diagnostics` tab.
+
+5. [Set the severity](/notify_severity)
+
+ This uses the same mechanism as adding meta-data, but allows you to set he `severity` when notifying Bugsnag of the error. Valid severities are `error`, `warning`, and `info`. Have a look on the dashboard to see the difference in these severities.
\ No newline at end of file
diff --git a/example/rails-32/config/initializers/bugsnag.rb b/example/rails-32/config/initializers/bugsnag.rb
deleted file mode 100644
index 0f3db4807..000000000
--- a/example/rails-32/config/initializers/bugsnag.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-Bugsnag.configure do |config|
- config.api_key = "066f5ad3590596f9aa8d601ea89af845"
-end
diff --git a/example/rails-32/config/routes.rb b/example/rails-32/config/routes.rb
index b1b5ac3f6..d657db6c3 100644
--- a/example/rails-32/config/routes.rb
+++ b/example/rails-32/config/routes.rb
@@ -49,6 +49,11 @@
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
root :to => 'application#index'
+ match 'crash' => 'application#crash'
+ match 'crash_with_callback' => 'application#callback'
+ match 'notify' => 'application#notify'
+ match 'notify_data' => 'application#data'
+ match 'notify_severity' => 'application#severity'
# See how all your routes lay out with "rake routes"
diff --git a/example/rails-32/db/development.sqlite3 b/example/rails-32/db/development.sqlite3
new file mode 100644
index 000000000..85ab63529
Binary files /dev/null and b/example/rails-32/db/development.sqlite3 differ
diff --git a/example/rails-32/db/seeds.rb b/example/rails-32/db/seeds.rb
deleted file mode 100644
index 4edb1e857..000000000
--- a/example/rails-32/db/seeds.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# This file should contain all the record creation needed to seed the database with its default values.
-# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
-#
-# Examples:
-#
-# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
-# Mayor.create(name: 'Emanuel', city: cities.first)
diff --git a/example/rails-32/lib/tasks/.gitkeep b/example/rails-32/lib/tasks/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/example/rails-32/log/.gitkeep b/example/rails-32/log/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/example/rails-32/test/fixtures/.gitkeep b/example/rails-32/test/fixtures/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/example/rails-32/test/functional/.gitkeep b/example/rails-32/test/functional/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/example/rails-32/test/integration/.gitkeep b/example/rails-32/test/integration/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/example/rails-32/test/performance/browsing_test.rb b/example/rails-32/test/performance/browsing_test.rb
deleted file mode 100644
index 3fea27b91..000000000
--- a/example/rails-32/test/performance/browsing_test.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'test_helper'
-require 'rails/performance_test_help'
-
-class BrowsingTest < ActionDispatch::PerformanceTest
- # Refer to the documentation for all available options
- # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
- # :output => 'tmp/performance', :formats => [:flat] }
-
- def test_homepage
- get '/'
- end
-end
diff --git a/example/rails-32/test/test_helper.rb b/example/rails-32/test/test_helper.rb
deleted file mode 100644
index 8bf1192ff..000000000
--- a/example/rails-32/test/test_helper.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-ENV["RAILS_ENV"] = "test"
-require File.expand_path('../../config/environment', __FILE__)
-require 'rails/test_help'
-
-class ActiveSupport::TestCase
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
- #
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
- # -- they do not yet inherit this setting
- fixtures :all
-
- # Add more helper methods to be used by all tests here...
-end
diff --git a/example/rails-32/test/unit/.gitkeep b/example/rails-32/test/unit/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/example/rails-42/Gemfile b/example/rails-42/Gemfile
index cbd91c464..044605255 100644
--- a/example/rails-42/Gemfile
+++ b/example/rails-42/Gemfile
@@ -45,3 +45,9 @@ group :development, :test do
end
gem "sidekiq"
+
+# Added at 2017-09-29 12:13:32 +0100 by amoinet:
+gem "redcarpet", "~> 3.4"
+
+gem 'delayed_job_active_record'
+gem 'daemons'
\ No newline at end of file
diff --git a/example/rails-42/README.md b/example/rails-42/README.md
new file mode 100644
index 000000000..204eaa424
--- /dev/null
+++ b/example/rails-42/README.md
@@ -0,0 +1,58 @@
+# Bugsnag Rails v4.2 demo (with delayed_job)
+
+This Rails application demonstrates how to use Bugsnag with Rails v4.2.
+Further details about integrating Bugsnag with Rack applications can be found [here.](https://docs.bugsnag.com/platforms/ruby/rails/)
+
+Install dependencies
+
+```shell
+bundle install
+```
+
+## Configuring Bugsnag and Rails v4.2
+
+There are two methods of configuring Bugsnag within a Rails application:
+
+1. Your `API_KEY` can be exported as an environment variable `BUGSNAG_API_KEY`.
+
+2. Generate a bugsnag configuration file at ```config/initializers/bugsnag.rb``` which can be populated with the [available configuration options](https://docs.bugsnag.com/platforms/ruby/rails/configuration-options/) by running the rails command:
+ ```shell
+ rails generate bugsnag YOUR_API_KEY_HERE
+ ```
+
+This is sufficient to start reporting unhandled exceptions to Bugsnag.
+
+## Running the example
+
+Run the example using:
+
+```shell
+bundle exec rails server
+```
+
+Once the server is running head to the default path for more information on Bugsnag logging examples.
+
+# Running delayed job
+
+This example comes packaged with a delayed job setup to demonstrate how errors are reported through delayed job. Once the rails setup is complete with an initializer at ```config/initializers/bugsnag.rb``` you don't need to do anything else with delayed job, just run the examples!
+
+The examples can be found at ```app/helpers/test_delayed_job_helper```
+
+In order to run the delayed job example:
+
+1. Open the rails console using the command:
+```shell
+bundle exec bin/rails console
+```
+
+2. Queue up the examples you wish to run. At the moment there are two examples `crash` and `notify`, which are queued by passing the symbol to the `helper.test_dj` like:
+```ruby
+helper.test_dj :crash
+helper.test_dj :notify
+```
+
+3. Exit the rails console using the `exit` command.
+4. Run the queue using rake:
+```shell
+bundle exec rake jobs:work
+```
diff --git a/example/rails-42/README.rdoc b/example/rails-42/README.rdoc
deleted file mode 100644
index dd4e97e22..000000000
--- a/example/rails-42/README.rdoc
+++ /dev/null
@@ -1,28 +0,0 @@
-== README
-
-This README would normally document whatever steps are necessary to get the
-application up and running.
-
-Things you may want to cover:
-
-* Ruby version
-
-* System dependencies
-
-* Configuration
-
-* Database creation
-
-* Database initialization
-
-* How to run the test suite
-
-* Services (job queues, cache servers, search engines, etc.)
-
-* Deployment instructions
-
-* ...
-
-
-Please feel free to use a different markup language if you do not plan to run
-rake doc:app.
diff --git a/example/rails-42/app/controllers/application_controller.rb b/example/rails-42/app/controllers/application_controller.rb
index 55f1e3588..33f2701ff 100644
--- a/example/rails-42/app/controllers/application_controller.rb
+++ b/example/rails-42/app/controllers/application_controller.rb
@@ -1,9 +1,59 @@
class ApplicationController < ActionController::Base
- # Prevent CSRF attacks by raising an exception.
- # For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def index
- raise "YO"
+ @text = File.read(File.expand_path('app/views/index.md'))
+ end
+
+ def crash
+ raise Exception.new('Bugsnag Rails demo says: It crashed! Go check ' +
+ 'bugsnag.com for a new notification')
+ end
+
+ def callback
+ Bugsnag.before_notify_callbacks << proc { |report|
+ new_tab = {
+ message: 'Rails v4.2 demo says: Everything is great',
+ code: 200
+ }
+ report.add_tab(:diagnostics, new_tab)
+ }
+ raise RuntimeError.new('Bugsnag Rails demo says: It crashed! But, due to the attached callback' +
+ ' the exception has meta information. Go check' +
+ ' bugsnag.com for a new notification (see the Diagnostics tab)!')
+ end
+
+ def notify
+ Bugsnag.notify(RuntimeError.new("Bugsnag Rails demo says: False alarm, your application didn't crash"))
+ @text = "Bugsnag Rack demo says: It didn't crash! " +
+ 'But still go check https://bugsnag.com' +
+ ' for a new notification.'
+ end
+
+ def data
+ error = RuntimeError.new("Bugsnag Rails demo says: False alarm, your application didn't crash")
+ Bugsnag.notify error do |report|
+ report.add_tab(:user, {
+ :username => "bob-hoskins",
+ :email => 'bugsnag@bugsnag.com',
+ :registered_user => true
+ })
+ report.add_tab(:diagnostics, {
+ :message => 'Rails demo says: Everything is great',
+ :code => 200
+ })
+ end
+ @text = "Bugsnag Rails demo says: It didn't crash! " +
+ 'But still go check https://bugsnag.com' +
+ ' for a new notification. Check out the User tab for the meta data'
+ end
+
+ def severity
+ msg = "Bugsnag Rails demo says: Look at the circle on the right side. It's different"
+ error = RuntimeError.new(msg)
+ Bugsnag.notify error do |report|
+ report.severity = 'info'
+ end
+ @text = msg
end
end
diff --git a/example/rails-42/app/helpers/application_helper.rb b/example/rails-42/app/helpers/application_helper.rb
index de6be7945..6d77519db 100644
--- a/example/rails-42/app/helpers/application_helper.rb
+++ b/example/rails-42/app/helpers/application_helper.rb
@@ -1,2 +1,22 @@
module ApplicationHelper
+ def markdown(text)
+ options = {
+ filter_html: true,
+ hard_wrap: true,
+ link_attributes: { rel: 'nofollow', target: "_blank" },
+ space_after_headers: true,
+ fenced_code_blocks: true
+ }
+
+ extensions = {
+ autolink: true,
+ superscript: true,
+ disable_indented_code_blocks: true
+ }
+
+ renderer = Redcarpet::Render::HTML.new(options)
+ markdown = Redcarpet::Markdown.new(renderer, extensions)
+
+ markdown.render(text).html_safe
+ end
end
diff --git a/example/rails-42/app/helpers/test_delayed_job_helper.rb b/example/rails-42/app/helpers/test_delayed_job_helper.rb
new file mode 100644
index 000000000..61997c092
--- /dev/null
+++ b/example/rails-42/app/helpers/test_delayed_job_helper.rb
@@ -0,0 +1,23 @@
+require "bugsnag"
+
+module TestDelayedJobHelper
+ def test_dj(func)
+ case func
+ when :crash
+ Testers.delay.crash
+ when :notify
+ Testers.delay.notify
+ end
+ end
+
+ class Testers
+ def self.crash
+ raise StandardError
+ end
+
+ def self.notify
+ Bugsnag.notify(StandardError.new "notify error")
+ end
+ end
+end
+
diff --git a/example/rails-42/app/views/application/data.html.erb b/example/rails-42/app/views/application/data.html.erb
new file mode 100644
index 000000000..aa2786a7d
--- /dev/null
+++ b/example/rails-42/app/views/application/data.html.erb
@@ -0,0 +1 @@
+<%= markdown(@text)%>
\ No newline at end of file
diff --git a/example/rails-42/app/views/application/index.html.erb b/example/rails-42/app/views/application/index.html.erb
new file mode 100644
index 000000000..aa2786a7d
--- /dev/null
+++ b/example/rails-42/app/views/application/index.html.erb
@@ -0,0 +1 @@
+<%= markdown(@text)%>
\ No newline at end of file
diff --git a/example/rails-42/app/views/application/notify.html.erb b/example/rails-42/app/views/application/notify.html.erb
new file mode 100644
index 000000000..aa2786a7d
--- /dev/null
+++ b/example/rails-42/app/views/application/notify.html.erb
@@ -0,0 +1 @@
+<%= markdown(@text)%>
\ No newline at end of file
diff --git a/example/rails-42/app/views/application/severity.html.erb b/example/rails-42/app/views/application/severity.html.erb
new file mode 100644
index 000000000..aa2786a7d
--- /dev/null
+++ b/example/rails-42/app/views/application/severity.html.erb
@@ -0,0 +1 @@
+<%= markdown(@text)%>
\ No newline at end of file
diff --git a/example/rails-42/app/views/index.md b/example/rails-42/app/views/index.md
new file mode 100644
index 000000000..4b37c029c
--- /dev/null
+++ b/example/rails-42/app/views/index.md
@@ -0,0 +1,25 @@
+# Bugsnag Rails v4.2 demo
+
+This application demonstrates the use of Bugsnag with the Rails web framework.
+
+While testing the examples open [your dashboard](https://app.bugsnag.com) in order to see the example errors and exceptions being received.
+
+1. [Crash](/crash)
+
+ Raises an error within the framework, generating a report in the Bugsnag dashboard.
+
+2. [Crash and use callbacks](/crash_with_callback)
+
+ Raises an exception within the framework, but with additional data attached to the report. By registering a callback before the error occurs useful data can be attached as a tab in the Bugsnag dashboard.
+
+3. [Notify](/notify)
+
+ Sends Bugsnag a report on demand using `bugsnag.notify`. Allows details of handled errors or information to be sent to the Bugsnag dashboard without crashing your code.
+
+4. [Notify with data](/notify_data)
+
+ Same as `notify` but allows you to attach additional data within a `block`, similar to the `before_notify_callbacks` example above. In this case we're adding information about the user to go into the `user` tab, and additional diagnostics as a `diagnostics` tab.
+
+5. [Set the severity](/notify_severity)
+
+ This uses the same mechanism as adding meta-data, but allows you to set he `severity` when notifying Bugsnag of the error. Valid severities are `error`, `warning`, and `info`. Have a look on the dashboard to see the difference in these severities.
\ No newline at end of file
diff --git a/example/rails-42/app/workers/hard_worker.rb b/example/rails-42/app/workers/hard_worker.rb
deleted file mode 100644
index becd8ed0a..000000000
--- a/example/rails-42/app/workers/hard_worker.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class HardWorker
- include Sidekiq::Worker
- def perform(how_hard, how_long)
- puts "Workin' #{how_hard} #{how_long}"
- raise 'Uh oh!'
- end
-end
-
-#HardWorker.perform_async('bob', 5)
diff --git a/example/rails-42/config/application.rb b/example/rails-42/config/application.rb
index 610d941ac..9dc198d1a 100644
--- a/example/rails-42/config/application.rb
+++ b/example/rails-42/config/application.rb
@@ -22,5 +22,6 @@ class Application < Rails::Application
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
+ config.active_job.queue_adapter = :delayed_job
end
end
diff --git a/example/rails-42/config/initializers/bugsnag.rb b/example/rails-42/config/initializers/bugsnag.rb
deleted file mode 100644
index 0f3db4807..000000000
--- a/example/rails-42/config/initializers/bugsnag.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-Bugsnag.configure do |config|
- config.api_key = "066f5ad3590596f9aa8d601ea89af845"
-end
diff --git a/example/rails-42/db/migrate/20171006132129_create_delayed_jobs.rb b/example/rails-42/db/migrate/20171006132129_create_delayed_jobs.rb
new file mode 100644
index 000000000..27fdcf6cc
--- /dev/null
+++ b/example/rails-42/db/migrate/20171006132129_create_delayed_jobs.rb
@@ -0,0 +1,22 @@
+class CreateDelayedJobs < ActiveRecord::Migration
+ def self.up
+ create_table :delayed_jobs, force: true do |table|
+ table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue
+ table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually.
+ table.text :handler, null: false # YAML-encoded string of the object that will do work
+ table.text :last_error # reason for last failure (See Note below)
+ table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
+ table.datetime :locked_at # Set when a client is working on this object
+ table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
+ table.string :locked_by # Who is working on this object (if locked)
+ table.string :queue # The name of the queue this job is in
+ table.timestamps null: true
+ end
+
+ add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority"
+ end
+
+ def self.down
+ drop_table :delayed_jobs
+ end
+end
diff --git a/example/rails-42/db/schema.rb b/example/rails-42/db/schema.rb
new file mode 100644
index 000000000..06777146f
--- /dev/null
+++ b/example/rails-42/db/schema.rb
@@ -0,0 +1,32 @@
+# encoding: UTF-8
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended that you check this file into your version control system.
+
+ActiveRecord::Schema.define(version: 20171006132129) do
+
+ create_table "delayed_jobs", force: :cascade do |t|
+ t.integer "priority", default: 0, null: false
+ t.integer "attempts", default: 0, null: false
+ t.text "handler", null: false
+ t.text "last_error"
+ t.datetime "run_at"
+ t.datetime "locked_at"
+ t.datetime "failed_at"
+ t.string "locked_by"
+ t.string "queue"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority"
+
+end
diff --git a/example/rails-42/lib/assets/.keep b/example/rails-42/lib/assets/.keep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/example/rails-42/lib/tasks/.keep b/example/rails-42/lib/tasks/.keep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/example/rails-42/lib/tasks/test.rake b/example/rails-42/lib/tasks/test.rake
deleted file mode 100644
index dcffebe04..000000000
--- a/example/rails-42/lib/tasks/test.rake
+++ /dev/null
@@ -1,5 +0,0 @@
-namespace :test do
- task :uncaught => :environment do
- raise "Uncaught rake"
- end
-end
diff --git a/example/rails-42/log/.keep b/example/rails-42/log/.keep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/example/rails-42/test/controllers/.keep b/example/rails-42/test/controllers/.keep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/example/rails-42/test/fixtures/.keep b/example/rails-42/test/fixtures/.keep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/example/rails-42/test/helpers/.keep b/example/rails-42/test/helpers/.keep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/example/rails-42/test/integration/.keep b/example/rails-42/test/integration/.keep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/example/rails-42/test/mailers/.keep b/example/rails-42/test/mailers/.keep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/example/rails-42/test/models/.keep b/example/rails-42/test/models/.keep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/example/rails-42/test/test_helper.rb b/example/rails-42/test/test_helper.rb
deleted file mode 100644
index 92e39b2d7..000000000
--- a/example/rails-42/test/test_helper.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-ENV['RAILS_ENV'] ||= 'test'
-require File.expand_path('../../config/environment', __FILE__)
-require 'rails/test_help'
-
-class ActiveSupport::TestCase
- # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
- fixtures :all
-
- # Add more helper methods to be used by all tests here...
-end
diff --git a/example/rails-51/.gitignore b/example/rails-51/.gitignore
new file mode 100644
index 000000000..dcc5b36f3
--- /dev/null
+++ b/example/rails-51/.gitignore
@@ -0,0 +1,23 @@
+# See https://help.github.com/articles/ignoring-files for more about ignoring files.
+#
+# If you find yourself ignoring temporary files generated by your text editor
+# or operating system, you probably want to add a global ignore instead:
+# git config --global core.excludesfile '~/.gitignore_global'
+
+# Ignore bundler config.
+/.bundle
+
+# Ignore the default SQLite database.
+/db/*.sqlite3
+/db/*.sqlite3-journal
+
+# Ignore all logfiles and tempfiles.
+/log/*
+/tmp/*
+!/log/.keep
+!/tmp/.keep
+
+/node_modules
+/yarn-error.log
+
+.byebug_history
diff --git a/example/rails-51/Gemfile b/example/rails-51/Gemfile
new file mode 100644
index 000000000..465e96fdc
--- /dev/null
+++ b/example/rails-51/Gemfile
@@ -0,0 +1,57 @@
+source 'https://rubygems.org'
+
+git_source(:github) do |repo_name|
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
+ "https://github.com/#{repo_name}.git"
+end
+
+gem "bugsnag" , path: "../../"
+
+# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
+gem 'rails', '~> 5.1.4'
+# Use sqlite3 as the database for Active Record
+gem 'sqlite3'
+# Use Puma as the app server
+gem 'puma', '~> 3.7'
+# Use SCSS for stylesheets
+gem 'sass-rails', '~> 5.0'
+# Use Uglifier as compressor for JavaScript assets
+gem 'uglifier', '>= 1.3.0'
+# See https://github.com/rails/execjs#readme for more supported runtimes
+# gem 'therubyracer', platforms: :ruby
+
+# Use CoffeeScript for .coffee assets and views
+gem 'coffee-rails', '~> 4.2'
+# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
+gem 'turbolinks', '~> 5'
+# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
+gem 'jbuilder', '~> 2.5'
+# Use Redis adapter to run Action Cable in production
+# gem 'redis', '~> 3.0'
+# Use ActiveModel has_secure_password
+# gem 'bcrypt', '~> 3.1.7'
+
+# Use Capistrano for deployment
+# gem 'capistrano-rails', group: :development
+
+group :development, :test do
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
+ gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
+ # Adds support for Capybara system testing and selenium driver
+ gem 'capybara', '~> 2.13'
+ gem 'selenium-webdriver'
+end
+
+group :development do
+ # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
+ gem 'web-console', '>= 3.3.0'
+ gem 'listen', '>= 3.0.5', '< 3.2'
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
+ gem 'spring'
+ gem 'spring-watcher-listen', '~> 2.0.0'
+end
+
+# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
+gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
+
+gem 'redcarpet'
diff --git a/example/rails-51/README.md b/example/rails-51/README.md
new file mode 100644
index 000000000..7891cb733
--- /dev/null
+++ b/example/rails-51/README.md
@@ -0,0 +1,33 @@
+# Bugsnag Rails v5.1 demo
+
+This Rails application demonstrates how to use Bugsnag with Rails v5.1.
+Further details about integrating Bugsnag with Rack applications can be found [here.](https://docs.bugsnag.com/platforms/ruby/rails/)
+
+Install dependencies
+
+```shell
+bundle install
+```
+
+## Configuring Bugsnag and Rails v5.1
+
+There are two methods of configuring Bugsnag within a Rails application:
+
+1. Your `API_KEY` can be exported as an environment variable `BUGSNAG_API_KEY`.
+
+2. Generate a bugsnag configuration file at ```config/initializers/bugsnag.rb``` which can be populated with the [available configuration options](https://docs.bugsnag.com/platforms/ruby/rails/configuration-options/) by running the rails command:
+ ```shell
+ bin/rails generate bugsnag YOUR_API_KEY_HERE
+ ```
+
+This is sufficient to start reporting unhandled exceptions to Bugsnag.
+
+## Running the example
+
+Run the example using:
+
+```shell
+bundle exec rails server
+```
+
+Once the server is running head to the default path for more information on Bugsnag logging examples.
diff --git a/example/rails-51/Rakefile b/example/rails-51/Rakefile
new file mode 100644
index 000000000..e85f91391
--- /dev/null
+++ b/example/rails-51/Rakefile
@@ -0,0 +1,6 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require_relative 'config/application'
+
+Rails.application.load_tasks
diff --git a/example/rails-51/app/assets/config/manifest.js b/example/rails-51/app/assets/config/manifest.js
new file mode 100644
index 000000000..b16e53d6d
--- /dev/null
+++ b/example/rails-51/app/assets/config/manifest.js
@@ -0,0 +1,3 @@
+//= link_tree ../images
+//= link_directory ../javascripts .js
+//= link_directory ../stylesheets .css
diff --git a/example/rails-42/app/controllers/concerns/.keep b/example/rails-51/app/assets/images/.keep
similarity index 100%
rename from example/rails-42/app/controllers/concerns/.keep
rename to example/rails-51/app/assets/images/.keep
diff --git a/example/rails-51/app/assets/javascripts/application.js b/example/rails-51/app/assets/javascripts/application.js
new file mode 100644
index 000000000..46b20359f
--- /dev/null
+++ b/example/rails-51/app/assets/javascripts/application.js
@@ -0,0 +1,15 @@
+// This is a manifest file that'll be compiled into application.js, which will include all the files
+// listed below.
+//
+// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
+// vendor/assets/javascripts directory can be referenced here using a relative path.
+//
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// compiled file. JavaScript code in this file should be added after the last require_* statement.
+//
+// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
+// about supported directives.
+//
+//= require rails-ujs
+//= require turbolinks
+//= require_tree .
diff --git a/example/rails-51/app/assets/javascripts/cable.js b/example/rails-51/app/assets/javascripts/cable.js
new file mode 100644
index 000000000..739aa5f02
--- /dev/null
+++ b/example/rails-51/app/assets/javascripts/cable.js
@@ -0,0 +1,13 @@
+// Action Cable provides the framework to deal with WebSockets in Rails.
+// You can generate new channels where WebSocket features live using the `rails generate channel` command.
+//
+//= require action_cable
+//= require_self
+//= require_tree ./channels
+
+(function() {
+ this.App || (this.App = {});
+
+ App.cable = ActionCable.createConsumer();
+
+}).call(this);
diff --git a/example/rails-42/app/mailers/.keep b/example/rails-51/app/assets/javascripts/channels/.keep
similarity index 100%
rename from example/rails-42/app/mailers/.keep
rename to example/rails-51/app/assets/javascripts/channels/.keep
diff --git a/example/rails-51/app/assets/stylesheets/application.css b/example/rails-51/app/assets/stylesheets/application.css
new file mode 100644
index 000000000..d05ea0f51
--- /dev/null
+++ b/example/rails-51/app/assets/stylesheets/application.css
@@ -0,0 +1,15 @@
+/*
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
+ * listed below.
+ *
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
+ * vendor/assets/stylesheets directory can be referenced here using a relative path.
+ *
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
+ * files in this directory. Styles in this file should be added after the last require_* statement.
+ * It is generally better to create a new file per style scope.
+ *
+ *= require_tree .
+ *= require_self
+ */
diff --git a/example/rails-51/app/controllers/application_controller.rb b/example/rails-51/app/controllers/application_controller.rb
new file mode 100644
index 000000000..33f2701ff
--- /dev/null
+++ b/example/rails-51/app/controllers/application_controller.rb
@@ -0,0 +1,59 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery with: :exception
+
+ def index
+ @text = File.read(File.expand_path('app/views/index.md'))
+ end
+
+ def crash
+ raise Exception.new('Bugsnag Rails demo says: It crashed! Go check ' +
+ 'bugsnag.com for a new notification')
+ end
+
+ def callback
+ Bugsnag.before_notify_callbacks << proc { |report|
+ new_tab = {
+ message: 'Rails v4.2 demo says: Everything is great',
+ code: 200
+ }
+ report.add_tab(:diagnostics, new_tab)
+ }
+ raise RuntimeError.new('Bugsnag Rails demo says: It crashed! But, due to the attached callback' +
+ ' the exception has meta information. Go check' +
+ ' bugsnag.com for a new notification (see the Diagnostics tab)!')
+ end
+
+ def notify
+ Bugsnag.notify(RuntimeError.new("Bugsnag Rails demo says: False alarm, your application didn't crash"))
+ @text = "Bugsnag Rack demo says: It didn't crash! " +
+ 'But still go check https://bugsnag.com' +
+ ' for a new notification.'
+ end
+
+ def data
+ error = RuntimeError.new("Bugsnag Rails demo says: False alarm, your application didn't crash")
+ Bugsnag.notify error do |report|
+ report.add_tab(:user, {
+ :username => "bob-hoskins",
+ :email => 'bugsnag@bugsnag.com',
+ :registered_user => true
+ })
+ report.add_tab(:diagnostics, {
+ :message => 'Rails demo says: Everything is great',
+ :code => 200
+ })
+ end
+ @text = "Bugsnag Rails demo says: It didn't crash! " +
+ 'But still go check https://bugsnag.com' +
+ ' for a new notification. Check out the User tab for the meta data'
+ end
+
+ def severity
+ msg = "Bugsnag Rails demo says: Look at the circle on the right side. It's different"
+ error = RuntimeError.new(msg)
+ Bugsnag.notify error do |report|
+ report.severity = 'info'
+ end
+ @text = msg
+ end
+end
diff --git a/example/rails-51/app/helpers/application_helper.rb b/example/rails-51/app/helpers/application_helper.rb
new file mode 100644
index 000000000..6d77519db
--- /dev/null
+++ b/example/rails-51/app/helpers/application_helper.rb
@@ -0,0 +1,22 @@
+module ApplicationHelper
+ def markdown(text)
+ options = {
+ filter_html: true,
+ hard_wrap: true,
+ link_attributes: { rel: 'nofollow', target: "_blank" },
+ space_after_headers: true,
+ fenced_code_blocks: true
+ }
+
+ extensions = {
+ autolink: true,
+ superscript: true,
+ disable_indented_code_blocks: true
+ }
+
+ renderer = Redcarpet::Render::HTML.new(options)
+ markdown = Redcarpet::Markdown.new(renderer, extensions)
+
+ markdown.render(text).html_safe
+ end
+end
diff --git a/example/rails-51/app/views/application/data.html.erb b/example/rails-51/app/views/application/data.html.erb
new file mode 100644
index 000000000..aa2786a7d
--- /dev/null
+++ b/example/rails-51/app/views/application/data.html.erb
@@ -0,0 +1 @@
+<%= markdown(@text)%>
\ No newline at end of file
diff --git a/example/rails-51/app/views/application/index.html.erb b/example/rails-51/app/views/application/index.html.erb
new file mode 100644
index 000000000..aa2786a7d
--- /dev/null
+++ b/example/rails-51/app/views/application/index.html.erb
@@ -0,0 +1 @@
+<%= markdown(@text)%>
\ No newline at end of file
diff --git a/example/rails-51/app/views/application/notify.html.erb b/example/rails-51/app/views/application/notify.html.erb
new file mode 100644
index 000000000..aa2786a7d
--- /dev/null
+++ b/example/rails-51/app/views/application/notify.html.erb
@@ -0,0 +1 @@
+<%= markdown(@text)%>
\ No newline at end of file
diff --git a/example/rails-51/app/views/application/severity.html.erb b/example/rails-51/app/views/application/severity.html.erb
new file mode 100644
index 000000000..aa2786a7d
--- /dev/null
+++ b/example/rails-51/app/views/application/severity.html.erb
@@ -0,0 +1 @@
+<%= markdown(@text)%>
\ No newline at end of file
diff --git a/example/rails-51/app/views/index.md b/example/rails-51/app/views/index.md
new file mode 100644
index 000000000..4dac75585
--- /dev/null
+++ b/example/rails-51/app/views/index.md
@@ -0,0 +1,25 @@
+# Bugsnag Rails v5.1 demo
+
+This application demonstrates the use of Bugsnag with the Rails web framework.
+
+While testing the examples open [your dashboard](https://app.bugsnag.com) in order to see the example errors and exceptions being received.
+
+1. [Crash](/crash)
+
+ Raises an error within the framework, generating a report in the Bugsnag dashboard.
+
+2. [Crash and use callbacks](/crash_with_callback)
+
+ Raises an exception within the framework, but with additional data attached to the report. By registering a callback before the error occurs useful data can be attached as a tab in the Bugsnag dashboard.
+
+3. [Notify](/notify)
+
+ Sends Bugsnag a report on demand using `bugsnag.notify`. Allows details of handled errors or information to be sent to the Bugsnag dashboard without crashing your code.
+
+4. [Notify with data](/notify_data)
+
+ Same as `notify` but allows you to attach additional data within a `block`, similar to the `before_notify_callbacks` example above. In this case we're adding information about the user to go into the `user` tab, and additional diagnostics as a `diagnostics` tab.
+
+5. [Set the severity](/notify_severity)
+
+ This uses the same mechanism as adding meta-data, but allows you to set he `severity` when notifying Bugsnag of the error. Valid severities are `error`, `warning`, and `info`. Have a look on the dashboard to see the difference in these severities.
\ No newline at end of file
diff --git a/example/rails-51/app/views/layouts/application.html.erb b/example/rails-51/app/views/layouts/application.html.erb
new file mode 100644
index 000000000..60309efb2
--- /dev/null
+++ b/example/rails-51/app/views/layouts/application.html.erb
@@ -0,0 +1,14 @@
+
+
+
+ Rails42
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
+ <%= csrf_meta_tags %>
+
+
+
+<%= yield %>
+
+
+
diff --git a/example/rails-51/config.ru b/example/rails-51/config.ru
new file mode 100644
index 000000000..f7ba0b527
--- /dev/null
+++ b/example/rails-51/config.ru
@@ -0,0 +1,5 @@
+# This file is used by Rack-based servers to start the application.
+
+require_relative 'config/environment'
+
+run Rails.application
diff --git a/example/rails-51/config/application.rb b/example/rails-51/config/application.rb
new file mode 100644
index 000000000..5c8da3bc1
--- /dev/null
+++ b/example/rails-51/config/application.rb
@@ -0,0 +1,18 @@
+require_relative 'boot'
+
+require 'rails/all'
+
+# Require the gems listed in Gemfile, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(*Rails.groups)
+
+module Rails52
+ class Application < Rails::Application
+ # Initialize configuration defaults for originally generated Rails version.
+ config.load_defaults 5.1
+
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+ end
+end
diff --git a/example/rails-51/config/boot.rb b/example/rails-51/config/boot.rb
new file mode 100644
index 000000000..30f5120df
--- /dev/null
+++ b/example/rails-51/config/boot.rb
@@ -0,0 +1,3 @@
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+
+require 'bundler/setup' # Set up gems listed in the Gemfile.
diff --git a/example/rails-51/config/cable.yml b/example/rails-51/config/cable.yml
new file mode 100644
index 000000000..8a19eab08
--- /dev/null
+++ b/example/rails-51/config/cable.yml
@@ -0,0 +1,10 @@
+development:
+ adapter: async
+
+test:
+ adapter: async
+
+production:
+ adapter: redis
+ url: redis://localhost:6379/1
+ channel_prefix: rails-52_production
diff --git a/example/rails-51/config/database.yml b/example/rails-51/config/database.yml
new file mode 100644
index 000000000..0d02f2498
--- /dev/null
+++ b/example/rails-51/config/database.yml
@@ -0,0 +1,25 @@
+# SQLite version 3.x
+# gem install sqlite3
+#
+# Ensure the SQLite 3 gem is defined in your Gemfile
+# gem 'sqlite3'
+#
+default: &default
+ adapter: sqlite3
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
+ timeout: 5000
+
+development:
+ <<: *default
+ database: db/development.sqlite3
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ <<: *default
+ database: db/test.sqlite3
+
+production:
+ <<: *default
+ database: db/production.sqlite3
diff --git a/example/rails-51/config/environment.rb b/example/rails-51/config/environment.rb
new file mode 100644
index 000000000..426333bb4
--- /dev/null
+++ b/example/rails-51/config/environment.rb
@@ -0,0 +1,5 @@
+# Load the Rails application.
+require_relative 'application'
+
+# Initialize the Rails application.
+Rails.application.initialize!
diff --git a/example/rails-51/config/environments/development.rb b/example/rails-51/config/environments/development.rb
new file mode 100644
index 000000000..5187e2218
--- /dev/null
+++ b/example/rails-51/config/environments/development.rb
@@ -0,0 +1,54 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the web server when you make code changes.
+ config.cache_classes = false
+
+ # Do not eager load code on boot.
+ config.eager_load = false
+
+ # Show full error reports.
+ config.consider_all_requests_local = true
+
+ # Enable/disable caching. By default caching is disabled.
+ if Rails.root.join('tmp/caching-dev.txt').exist?
+ config.action_controller.perform_caching = true
+
+ config.cache_store = :memory_store
+ config.public_file_server.headers = {
+ 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
+ }
+ else
+ config.action_controller.perform_caching = false
+
+ config.cache_store = :null_store
+ end
+
+ # Don't care if the mailer can't send.
+ config.action_mailer.raise_delivery_errors = false
+
+ config.action_mailer.perform_caching = false
+
+ # Print deprecation notices to the Rails logger.
+ config.active_support.deprecation = :log
+
+ # Raise an error on page load if there are pending migrations.
+ config.active_record.migration_error = :page_load
+
+ # Debug mode disables concatenation and preprocessing of assets.
+ # This option may cause significant delays in view rendering with a large
+ # number of complex assets.
+ config.assets.debug = true
+
+ # Suppress logger output for asset requests.
+ config.assets.quiet = true
+
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+
+ # Use an evented file watcher to asynchronously detect changes in source code,
+ # routes, locales, etc. This feature depends on the listen gem.
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
+end
diff --git a/example/rails-51/config/environments/production.rb b/example/rails-51/config/environments/production.rb
new file mode 100644
index 000000000..961695e9c
--- /dev/null
+++ b/example/rails-51/config/environments/production.rb
@@ -0,0 +1,91 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # Code is not reloaded between requests.
+ config.cache_classes = true
+
+ # Eager load code on boot. This eager loads most of Rails and
+ # your application in memory, allowing both threaded web servers
+ # and those relying on copy on write to perform better.
+ # Rake tasks automatically ignore this option for performance.
+ config.eager_load = true
+
+ # Full error reports are disabled and caching is turned on.
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
+
+ # Attempt to read encrypted secrets from `config/secrets.yml.enc`.
+ # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
+ # `config/secrets.yml.key`.
+ config.read_encrypted_secrets = true
+
+ # Disable serving static files from the `/public` folder by default since
+ # Apache or NGINX already handles this.
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
+
+ # Compress JavaScripts and CSS.
+ config.assets.js_compressor = :uglifier
+ # config.assets.css_compressor = :sass
+
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
+ config.assets.compile = false
+
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
+ # config.action_controller.asset_host = 'http://assets.example.com'
+
+ # Specifies the header that your server uses for sending files.
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
+
+ # Mount Action Cable outside main process or domain
+ # config.action_cable.mount_path = nil
+ # config.action_cable.url = 'wss://example.com/cable'
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ # config.force_ssl = true
+
+ # Use the lowest log level to ensure availability of diagnostic information
+ # when problems arise.
+ config.log_level = :debug
+
+ # Prepend all log lines with the following tags.
+ config.log_tags = [ :request_id ]
+
+ # Use a different cache store in production.
+ # config.cache_store = :mem_cache_store
+
+ # Use a real queuing backend for Active Job (and separate queues per environment)
+ # config.active_job.queue_adapter = :resque
+ # config.active_job.queue_name_prefix = "rails-52_#{Rails.env}"
+ config.action_mailer.perform_caching = false
+
+ # Ignore bad email addresses and do not raise email delivery errors.
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation cannot be found).
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners.
+ config.active_support.deprecation = :notify
+
+ # Use default logging formatter so that PID and timestamp are not suppressed.
+ config.log_formatter = ::Logger::Formatter.new
+
+ # Use a different logger for distributed setups.
+ # require 'syslog/logger'
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
+
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
+ logger = ActiveSupport::Logger.new(STDOUT)
+ logger.formatter = config.log_formatter
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
+ end
+
+ # Do not dump schema after migrations.
+ config.active_record.dump_schema_after_migration = false
+end
diff --git a/example/rails-51/config/environments/test.rb b/example/rails-51/config/environments/test.rb
new file mode 100644
index 000000000..8e5cbde53
--- /dev/null
+++ b/example/rails-51/config/environments/test.rb
@@ -0,0 +1,42 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
+
+ # Do not eager load code on boot. This avoids loading your whole application
+ # just for the purpose of running a single test. If you are using a tool that
+ # preloads Rails for running tests, you may have to set it to true.
+ config.eager_load = false
+
+ # Configure public file server for tests with Cache-Control for performance.
+ config.public_file_server.enabled = true
+ config.public_file_server.headers = {
+ 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
+ }
+
+ # Show full error reports and disable caching.
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates.
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment.
+ config.action_controller.allow_forgery_protection = false
+ config.action_mailer.perform_caching = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Print deprecation notices to the stderr.
+ config.active_support.deprecation = :stderr
+
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+end
diff --git a/example/rails-51/config/initializers/application_controller_renderer.rb b/example/rails-51/config/initializers/application_controller_renderer.rb
new file mode 100644
index 000000000..89d2efab2
--- /dev/null
+++ b/example/rails-51/config/initializers/application_controller_renderer.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+# ActiveSupport::Reloader.to_prepare do
+# ApplicationController.renderer.defaults.merge!(
+# http_host: 'example.org',
+# https: false
+# )
+# end
diff --git a/example/rails-51/config/initializers/assets.rb b/example/rails-51/config/initializers/assets.rb
new file mode 100644
index 000000000..4b828e80c
--- /dev/null
+++ b/example/rails-51/config/initializers/assets.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+
+# Version of your assets, change this if you want to expire all your assets.
+Rails.application.config.assets.version = '1.0'
+
+# Add additional assets to the asset load path.
+# Rails.application.config.assets.paths << Emoji.images_path
+# Add Yarn node_modules folder to the asset load path.
+Rails.application.config.assets.paths << Rails.root.join('node_modules')
+
+# Precompile additional assets.
+# application.js, application.css, and all non-JS/CSS in the app/assets
+# folder are already added.
+# Rails.application.config.assets.precompile += %w( admin.js admin.css )
diff --git a/example/rails-51/config/initializers/backtrace_silencers.rb b/example/rails-51/config/initializers/backtrace_silencers.rb
new file mode 100644
index 000000000..59385cdf3
--- /dev/null
+++ b/example/rails-51/config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
diff --git a/example/rails-51/config/initializers/bugsnag.rb b/example/rails-51/config/initializers/bugsnag.rb
new file mode 100644
index 000000000..200cb5051
--- /dev/null
+++ b/example/rails-51/config/initializers/bugsnag.rb
@@ -0,0 +1,3 @@
+Bugsnag.configure do |config|
+ config.api_key = "f35a2472bd230ac0ab0f52715bbdc65d"
+end
diff --git a/example/rails-51/config/initializers/cookies_serializer.rb b/example/rails-51/config/initializers/cookies_serializer.rb
new file mode 100644
index 000000000..5a6a32d37
--- /dev/null
+++ b/example/rails-51/config/initializers/cookies_serializer.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Specify a serializer for the signed and encrypted cookie jars.
+# Valid options are :json, :marshal, and :hybrid.
+Rails.application.config.action_dispatch.cookies_serializer = :json
diff --git a/example/rails-51/config/initializers/filter_parameter_logging.rb b/example/rails-51/config/initializers/filter_parameter_logging.rb
new file mode 100644
index 000000000..4a994e1e7
--- /dev/null
+++ b/example/rails-51/config/initializers/filter_parameter_logging.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Configure sensitive parameters which will be filtered from the log file.
+Rails.application.config.filter_parameters += [:password]
diff --git a/example/rails-51/config/initializers/inflections.rb b/example/rails-51/config/initializers/inflections.rb
new file mode 100644
index 000000000..ac033bf9d
--- /dev/null
+++ b/example/rails-51/config/initializers/inflections.rb
@@ -0,0 +1,16 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format. Inflections
+# are locale specific, and you may define rules for as many different
+# locales as you wish. All of these examples are active by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
+
+# These inflection rules are supported but not enabled by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.acronym 'RESTful'
+# end
diff --git a/example/rails-51/config/initializers/mime_types.rb b/example/rails-51/config/initializers/mime_types.rb
new file mode 100644
index 000000000..dc1899682
--- /dev/null
+++ b/example/rails-51/config/initializers/mime_types.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
diff --git a/example/rails-51/config/initializers/wrap_parameters.rb b/example/rails-51/config/initializers/wrap_parameters.rb
new file mode 100644
index 000000000..bbfc3961b
--- /dev/null
+++ b/example/rails-51/config/initializers/wrap_parameters.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+
+# This file contains settings for ActionController::ParamsWrapper which
+# is enabled by default.
+
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActiveSupport.on_load(:action_controller) do
+ wrap_parameters format: [:json]
+end
+
+# To enable root element in JSON for ActiveRecord objects.
+# ActiveSupport.on_load(:active_record) do
+# self.include_root_in_json = true
+# end
diff --git a/example/rails-51/config/locales/en.yml b/example/rails-51/config/locales/en.yml
new file mode 100644
index 000000000..decc5a857
--- /dev/null
+++ b/example/rails-51/config/locales/en.yml
@@ -0,0 +1,33 @@
+# Files in the config/locales directory are used for internationalization
+# and are automatically loaded by Rails. If you want to use locales other
+# than English, add the necessary files in this directory.
+#
+# To use the locales, use `I18n.t`:
+#
+# I18n.t 'hello'
+#
+# In views, this is aliased to just `t`:
+#
+# <%= t('hello') %>
+#
+# To use a different locale, set it with `I18n.locale`:
+#
+# I18n.locale = :es
+#
+# This would use the information in config/locales/es.yml.
+#
+# The following keys must be escaped otherwise they will not be retrieved by
+# the default I18n backend:
+#
+# true, false, on, off, yes, no
+#
+# Instead, surround them with single quotes.
+#
+# en:
+# 'true': 'foo'
+#
+# To learn more, please read the Rails Internationalization guide
+# available at http://guides.rubyonrails.org/i18n.html.
+
+en:
+ hello: "Hello world"
diff --git a/example/rails-51/config/puma.rb b/example/rails-51/config/puma.rb
new file mode 100644
index 000000000..1e19380dc
--- /dev/null
+++ b/example/rails-51/config/puma.rb
@@ -0,0 +1,56 @@
+# Puma can serve each request in a thread from an internal thread pool.
+# The `threads` method setting takes two numbers: a minimum and maximum.
+# Any libraries that use thread pools should be configured to match
+# the maximum value specified for Puma. Default is set to 5 threads for minimum
+# and maximum; this matches the default thread size of Active Record.
+#
+threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
+threads threads_count, threads_count
+
+# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
+#
+port ENV.fetch("PORT") { 3000 }
+
+# Specifies the `environment` that Puma will run in.
+#
+environment ENV.fetch("RAILS_ENV") { "development" }
+
+# Specifies the number of `workers` to boot in clustered mode.
+# Workers are forked webserver processes. If using threads and workers together
+# the concurrency of the application would be max `threads` * `workers`.
+# Workers do not work on JRuby or Windows (both of which do not support
+# processes).
+#
+# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
+
+# Use the `preload_app!` method when specifying a `workers` number.
+# This directive tells Puma to first boot the application and load code
+# before forking the application. This takes advantage of Copy On Write
+# process behavior so workers use less memory. If you use this option
+# you need to make sure to reconnect any threads in the `on_worker_boot`
+# block.
+#
+# preload_app!
+
+# If you are preloading your application and using Active Record, it's
+# recommended that you close any connections to the database before workers
+# are forked to prevent connection leakage.
+#
+# before_fork do
+# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
+# end
+
+# The code in the `on_worker_boot` will be called if you are using
+# clustered mode by specifying a number of `workers`. After each worker
+# process is booted, this block will be run. If you are using the `preload_app!`
+# option, you will want to use this block to reconnect to any threads
+# or connections that may have been created at application boot, as Ruby
+# cannot share connections between processes.
+#
+# on_worker_boot do
+# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
+# end
+#
+
+# Allow puma to be restarted by `rails restart` command.
+plugin :tmp_restart
diff --git a/example/rails-51/config/routes.rb b/example/rails-51/config/routes.rb
new file mode 100644
index 000000000..2b169b6d8
--- /dev/null
+++ b/example/rails-51/config/routes.rb
@@ -0,0 +1,9 @@
+Rails.application.routes.draw do
+ # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+ get '/', to: 'application#index'
+ get '/crash', to: 'application#crash'
+ get '/crash_with_callback', to: 'application#callback'
+ get '/notify', to: 'application#notify'
+ get '/notify_data', to: 'application#data'
+ get '/notify_severity', to: 'application#severity'
+end
diff --git a/example/rails-51/config/secrets.yml b/example/rails-51/config/secrets.yml
new file mode 100644
index 000000000..4998e7e47
--- /dev/null
+++ b/example/rails-51/config/secrets.yml
@@ -0,0 +1,32 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key is used for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+# You can use `rails secret` to generate a secure secret key.
+
+# Make sure the secrets in this file are kept private
+# if you're sharing your code publicly.
+
+# Shared secrets are available across all environments.
+
+# shared:
+# api_key: a1B2c3D4e5F6
+
+# Environmental secrets are only available for that specific environment.
+
+development:
+ secret_key_base: 2b81b7259b2843d11e9b9ce98872027bcce4f5c043b8f428e978d93627538b36f05a485b7898a378d80604dd623b8f0094aa4c1643eadffd5ed75bfe3446e11d
+
+test:
+ secret_key_base: 0b6d7f7e7eb96c729f3ebdd4b0868b8e3003ad8ebac8c4ce08f61d67b3184bca171364661988179c31e85e07b2d379bfb5f2d7570004805675432ae87811ad4a
+
+# Do not keep production secrets in the unencrypted secrets file.
+# Instead, either read values from the environment.
+# Or, use `bin/rails secrets:setup` to configure encrypted secrets
+# and move the `production:` environment over there.
+
+production:
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
diff --git a/example/rails-51/config/spring.rb b/example/rails-51/config/spring.rb
new file mode 100644
index 000000000..c9119b40c
--- /dev/null
+++ b/example/rails-51/config/spring.rb
@@ -0,0 +1,6 @@
+%w(
+ .ruby-version
+ .rbenv-vars
+ tmp/restart.txt
+ tmp/caching-dev.txt
+).each { |path| Spring.watch(path) }
diff --git a/example/rails-51/db/seeds.rb b/example/rails-51/db/seeds.rb
new file mode 100644
index 000000000..1beea2acc
--- /dev/null
+++ b/example/rails-51/db/seeds.rb
@@ -0,0 +1,7 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
+#
+# Examples:
+#
+# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
+# Character.create(name: 'Luke', movie: movies.first)
diff --git a/example/rails-42/app/models/.keep b/example/rails-51/lib/assets/.keep
similarity index 100%
rename from example/rails-42/app/models/.keep
rename to example/rails-51/lib/assets/.keep
diff --git a/example/rails-42/app/models/concerns/.keep b/example/rails-51/lib/tasks/.keep
similarity index 100%
rename from example/rails-42/app/models/concerns/.keep
rename to example/rails-51/lib/tasks/.keep
diff --git a/example/rails-51/package.json b/example/rails-51/package.json
new file mode 100644
index 000000000..81ffb7178
--- /dev/null
+++ b/example/rails-51/package.json
@@ -0,0 +1,5 @@
+{
+ "name": "rails-52",
+ "private": true,
+ "dependencies": {}
+}
diff --git a/example/rails-51/public/404.html b/example/rails-51/public/404.html
new file mode 100644
index 000000000..2be3af26f
--- /dev/null
+++ b/example/rails-51/public/404.html
@@ -0,0 +1,67 @@
+
+
+
+ The page you were looking for doesn't exist (404)
+
+
+
+
+
+
+
+
+
The page you were looking for doesn't exist.
+
You may have mistyped the address or the page may have moved.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/example/rails-51/public/422.html b/example/rails-51/public/422.html
new file mode 100644
index 000000000..c08eac0d1
--- /dev/null
+++ b/example/rails-51/public/422.html
@@ -0,0 +1,67 @@
+
+
+
+ The change you wanted was rejected (422)
+
+
+
+
+
+
+
+
+
The change you wanted was rejected.
+
Maybe you tried to change something you didn't have access to.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/example/rails-51/public/500.html b/example/rails-51/public/500.html
new file mode 100644
index 000000000..78a030af2
--- /dev/null
+++ b/example/rails-51/public/500.html
@@ -0,0 +1,66 @@
+
+
+
+ We're sorry, but something went wrong (500)
+
+
+
+
+
+
+
+
+
We're sorry, but something went wrong.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/example/rails-32/app/mailers/.gitkeep b/example/rails-51/public/apple-touch-icon-precomposed.png
similarity index 100%
rename from example/rails-32/app/mailers/.gitkeep
rename to example/rails-51/public/apple-touch-icon-precomposed.png
diff --git a/example/rails-32/app/models/.gitkeep b/example/rails-51/public/apple-touch-icon.png
similarity index 100%
rename from example/rails-32/app/models/.gitkeep
rename to example/rails-51/public/apple-touch-icon.png
diff --git a/example/rails-32/lib/assets/.gitkeep b/example/rails-51/public/favicon.ico
similarity index 100%
rename from example/rails-32/lib/assets/.gitkeep
rename to example/rails-51/public/favicon.ico
diff --git a/example/rails-51/public/robots.txt b/example/rails-51/public/robots.txt
new file mode 100644
index 000000000..37b576a4a
--- /dev/null
+++ b/example/rails-51/public/robots.txt
@@ -0,0 +1 @@
+# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
diff --git a/example/resque/README.md b/example/resque/README.md
new file mode 100644
index 000000000..685c8891a
--- /dev/null
+++ b/example/resque/README.md
@@ -0,0 +1,60 @@
+# Bugsnag Resque demo
+
+This Resque application demonstrates how to use Bugsnag with Resque.
+Further details about integrating Bugsnag with Resque can be found [here.](https://docs.bugsnag.com/platforms/ruby/other/)
+
+Install dependencies
+
+```shell
+bundle install
+```
+
+## Configuring Bugsnag and Resque
+
+Configure your `API_KEY` and any other configuration as detailed in the [available configuration options](https://docs.bugsnag.com/platforms/ruby/other/configuration-options/) by calling `Bugsnag.configure` and passing the options to the `configuration` object returned to a provided block:
+ ```ruby
+ Bugsnag.configure do |configuration|
+ configuration.api_key = "YOUR_API_KEY"
+ end
+ ```
+
+In the applications ```Rakefile``` ensure that the `bugsnag/integrations/rake` middleware is loaded to automatically handled any errors.
+
+## Running the examples
+
+Each of the examples can be run individually to verify the behaviour through the [Bugsnag dashboard](https://app.bugsnag.com):
+
+1. Crash
+
+This example shows unhandled errors being captured by Bugsnag and a notification automatically being sent to the Bugsnag dashboard. You can run this example with:
+```shell
+QUEUE=crash bundle exec rake resque:work
+```
+
+2. Crash with a callback
+
+This example is similar to the first, but by registering a callback before the error is caught we can attach additional information that can be viewed in the Bugsnag dashboard. Run this example with:
+```shell
+QUEUE=callback bundle exec rake resque:work
+```
+
+3. Notify
+
+This example will send a notification without crashing the Resque worker. This allows you to send notifications of handled errors to the Bugsnag dashboard. Run this example with:
+```shell
+QUEUE=notify bundle exec rake resque:work
+```
+
+4. Notify with attached data
+
+This example is similar to the above, however adds additional data to the notification using a block. Check out the `diagnostics` and `queue` tabs on the error in the dashboard. Run this example with:
+```shell
+QUEUE=data bundle exec rake resque:work
+```
+
+5. Notify with a custom severity
+
+Finally, this example is similar to the previous, but sets a custom severity on the notification. This will be reflected in the coloured circle shown alongside the event in the bugsnag dashboard. Run this example with:
+```shell
+QUEUE=severity bundle exec rake resque:work
+```
diff --git a/example/resque/Rakefile b/example/resque/Rakefile
index 2b96dea92..decc81ba1 100644
--- a/example/resque/Rakefile
+++ b/example/resque/Rakefile
@@ -1,8 +1,3 @@
load "app.rb"
require "resque/tasks"
-require "bugsnag/rake"
-
-desc "Remove all events that are too old to be accessed"
-task :test_rake do
- raise "DWERP"
-end
+require "bugsnag/integrations/rake"
diff --git a/example/resque/app.rb b/example/resque/app.rb
index 33f457aa3..0fdc27fc3 100644
--- a/example/resque/app.rb
+++ b/example/resque/app.rb
@@ -2,20 +2,78 @@
require 'bugsnag'
Bugsnag.configure do |config|
- config.api_key = '066f5ad3590596f9aa8d601ea89af845'
+ config.api_key = 'YOUR_API_KEY'
end
-# This is a simple Resque job.
-class Archive
- @queue = :test
+# Unhandled Exception example
+class Crash
+ @queue = :crash
- def self.perform(how_hard="super hard", how_long=1)
- puts "Workin' #{how_hard} #{how_long}"
- raise 'Uh oh!'
+ def self.perform
+ raise Exception.new "Crashed - Check your Bugsnag dashboard"
end
end
-Resque.enqueue(Archive, "super hard", 1)
+# Unhandled with callback Exception example
+class Callback
+ @queue = :callback
-# To run a worker run
-#QUEUE=* rake resque:work
+ def self.perform
+ Bugsnag.before_notify_callbacks << proc { |report|
+ new_tab = {
+ message: 'Resque demo says: Everything is great',
+ code: 200
+ }
+ report.add_tab(:diagnostics, new_tab)
+ }
+ raise Exception.new "Crashed - Check the Bugsnag dashboard for diagnostic data"
+ end
+end
+
+# Handled example
+class Notify
+ @queue = :notify
+
+ def self.perform
+ Bugsnag.notify(Exception.new "Didn't crash, but sent a notification anyway")
+ puts "The Resque worker hasn't crashed, but it has sent a notification, so go check out the dashboard!"
+ end
+end
+
+# Handled example with additional data
+class Data
+ @queue = :data
+
+ def self.perform
+ error = Exception.new "Didn't crash, but sent a notification anyway"
+ Bugsnag.notify error do |report|
+ report.add_tab(:queue, {
+ :name => "data",
+ :fatal => false
+ })
+ report.add_tab(:diagnostics, {
+ :message => 'Resque demo says: Everything is great',
+ })
+ end
+ puts "The Resque worker hasn't crashed, but it has sent a notification, with additional data to the dashboard"
+ end
+end
+
+# Handled example with set severity
+class Severity
+ @queue = :severity
+
+ def self.perform
+ error = Exception.new "Didn't crash, but sent a notification anyway"
+ Bugsnag.notify error do |report|
+ report.severity = "info"
+ end
+ puts "The Resque worker hasn't crashed but check the severity of the dashboard notification"
+ end
+end
+
+Resque.enqueue(Crash)
+Resque.enqueue(Callback)
+Resque.enqueue(Notify)
+Resque.enqueue(Data)
+Resque.enqueue(Severity)
diff --git a/example/sidekiq/README.md b/example/sidekiq/README.md
new file mode 100644
index 000000000..f537923f7
--- /dev/null
+++ b/example/sidekiq/README.md
@@ -0,0 +1,74 @@
+# Bugsnag Sidekiq demo
+
+This Sidekiq application demonstrates how to use Bugsnag with Sidekiq.
+Further details about integrating Bugsnag with Sidekiq can be found [here.](https://docs.bugsnag.com/platforms/ruby/sidekiq/)
+
+Install dependencies
+
+```shell
+bundle install
+```
+
+Sidekiq requires a datastore to run, this examples uses [redis](https://redis.io), installation instructions for which can be found [here](https://redis.io/topics/quickstart) and an official docker image can be found [here](https://hub.docker.com/_/redis/).
+
+## Configuring Bugsnag and Sidekiq
+
+Configure your `API_KEY` and any other configuration as detailed in the [available configuration options](https://docs.bugsnag.com/platforms/ruby/sidekiq/configuration-options/) by calling `Bugsnag.configure` and passing the options to the `configuration` object yielded to a provided block:
+ ```ruby
+ Bugsnag.configure do |configuration|
+ configuration.api_key = "YOUR_API_KEY"
+ end
+ ```
+
+## Running the examples
+
+Once the app is configured it can be run using two terminal windows. In the first terminal the Sidekiq application will be started using:
+
+```shell
+bundle exec sidekiq -r ./sidekiq.rb
+```
+
+Once this is running, in the second terminal, you will need to open an interactive Ruby instance with the script loaded into it by running the command:
+
+```shell
+bundle exec irb -r ./sidekiq.rb
+```
+
+This will then allow the workers to be started via Ruby commands in the interactive Ruby instance.
+
+Each of the examples can be run individually to verify the behaviour through the [Bugsnag dashboard](https://app.bugsnag.com):
+
+1. Crash
+
+This example shows unhandled errors being captured by Bugsnag and a notification automatically being sent to the Bugsnag dashboard. You can run this example with:
+```ruby
+Crash.perform_async
+```
+
+2. Crash with a callback
+
+This example is similar to the first, but by registering a callback before the error is caught we can attach additional information that can be viewed in the Bugsnag dashboard. Run this example with:
+```ruby
+Callback.perform_async
+```
+
+3. Notify
+
+This example will send a notification without crashing the Resque worker. This allows you to send notifications of handled errors to the Bugsnag dashboard. Run this example with:
+```ruby
+Notify.perform_async
+```
+
+4. Notify with attached data
+
+This example is similar to the above, however adds additional data to the notification using a block. Check out the `diagnostics` and `queue` tabs on the error in the dashboard. Run this example with:
+```ruby
+Metadata.perform_async
+```
+
+5. Notify with a custom severity
+
+Finally, this example is similar to the previous, but sets a custom severity on the notification. This will be reflected in the coloured circle shown alongside the event in the bugsnag dashboard. Run this example with:
+```ruby
+Severity.perform_async
+```
diff --git a/example/sidekiq/sidekiq.rb b/example/sidekiq/sidekiq.rb
index c2a2d84fb..3edf8663a 100644
--- a/example/sidekiq/sidekiq.rb
+++ b/example/sidekiq/sidekiq.rb
@@ -2,7 +2,7 @@
require 'bugsnag'
Bugsnag.configure do |config|
- config.api_key = '066f5ad3590596f9aa8d601ea89af845'
+ config.api_key = 'YOUR_API_KEY'
end
# If your client is single-threaded, we just need a single connection in our Redis connection pool
@@ -15,18 +15,75 @@
config.redis = { :namespace => 'x' }
end
-# Start up sidekiq via
-# bundle exec sidekiq -r ./sidekiq.rb
-# and then you can open up an IRB session like so:
-# irb -r ./sidekiq.rb
-# where you can then say
-# PlainOldRuby.perform_async "like a dog", 3
-#
-class PlainOldRuby
+# Unhandled example
+class Crash
include Sidekiq::Worker
+ sidekiq_options :retry => false
- def perform(how_hard="super hard", how_long=1)
- puts "Workin' #{how_hard} #{how_long}"
- raise 'Uh oh!'
+ def perform
+ raise Exception.new "Crashed - Check your Bugsnag dashboard"
end
end
+
+# Unhandled example with callback
+class Callback
+ include Sidekiq::Worker
+ sidekiq_options :retry => false
+
+ def perform
+ Bugsnag.before_notify_callbacks << proc { |report|
+ new_tab = {
+ message: 'Sidekiq demo says: Everything is great',
+ code: 200
+ }
+ report.add_tab(:diagnostics, new_tab)
+ }
+ raise Exception.new "Crashed - Check the Bugsnag dashboard for diagnostic data"
+ end
+end
+
+# Handled example
+class Notify
+ include Sidekiq::Worker
+ sidekiq_options :retry => false
+
+ def perform
+ Bugsnag.notify(Exception.new "Didn't crash, but sent a notification anyway")
+ puts "The Sidekiq worker hasn't crashed, but it has sent a notification, so go check out the dashboard!"
+ end
+end
+
+# Handled example with additional data
+class Metadata
+ include Sidekiq::Worker
+ sidekiq_options :retry => false
+
+ def perform
+ error = Exception.new "Didn't crash, but sent a notification anyway"
+ Bugsnag.notify error do |report|
+ report.add_tab(:function, {
+ :name => "Metadata",
+ :fatal => false
+ })
+ report.add_tab(:diagnostics, {
+ :message => 'Sidekiq demo says: Everything is great',
+ })
+ end
+ puts "The Sidekiq worker hasn't crashed, but it has sent a notification, with additional data to the dashboard"
+ end
+end
+
+
+# Handled example with set severity
+class Severity
+ include Sidekiq::Worker
+ sidekiq_options :retry => false
+
+ def perform
+ error = Exception.new "Didn't crash, but sent a notification anyway"
+ Bugsnag.notify error do |report|
+ report.severity = "info"
+ end
+ puts "The Sidekiq worker hasn't crashed but check the severity of the dashboard notification"
+ end
+end
\ No newline at end of file
diff --git a/example/sinatra/Gemfile b/example/sinatra/Gemfile
index a7f9f2c1d..72cbdbaf2 100644
--- a/example/sinatra/Gemfile
+++ b/example/sinatra/Gemfile
@@ -1,7 +1,7 @@
source 'https://rubygems.org'
if ENV['INTEGRATION_LANGUAGE']
- gem 'bugsnag', path: '../../../../'
+ gem 'bugsnag', path: '../../'
else
gem 'bugsnag'
end
diff --git a/example/sinatra/README.md b/example/sinatra/README.md
index b724ef93b..004649289 100644
--- a/example/sinatra/README.md
+++ b/example/sinatra/README.md
@@ -1,86 +1,43 @@
# Bugsnag Sinatra demo
-This Sinatra application demonstrates how to use Bugsnag with Sinatra. Before
-testing it, open up the `config.ru` file (or any other file with your
-configuration details) and configure your API key.
+This Sinatra application demonstrates how to use Bugsnag with Sinatra. Further details about integrating Bugsnag with Sidekiq can
-```
-Bugsnag.configure do |config|
- config.api_key = '0a6f5add590596f93a8d601ea89af841'
-end
+Install dependencies
+
+```shell
+bundle install
```
-The other way to configure the API key is to export the `BUGSNAG_API_KEY`
-environment variable.
+## Configuring Bugsnag and Sinatra
-In the same file activate the Bugsnag Rack middleware.
+The `API_KEY` can be set in one of two ways:
-```
-use Bugsnag::Rack
-```
+1. Export the `API_KEY` as an environment variable, `BUGSNAG_API_KEY` to be used when running the server.
-Be sure that `raise_errors` is set to `true` and `show_exceptions` is set to
-`false`. Otherwise, in the development environment, automatic notifications
-won't work, as Sinatra would be swallowing exceptions from Bugsnag.
+2. Configure the `API_KEY` and any other configuration as detailed in the [available configuration options](https://docs.bugsnag.com/platforms/ruby/rack/configuration-options/) by calling `Bugsnag.configure` and passing the options to the `configuration` object yielded to a provided block:
+ ```ruby
+ Bugsnag.configure do |configuration|
+ configuration.api_key = "YOUR_API_KEY"
+ end
+ ```
+Make sure the server is using the correct Bugsnag Rack middleware by activating it at the top of the file:
+```ruby
+use Bugsnag::Rack
```
+
+Finally, to make sure exceptions are automatically cap[tured and notified in development or testing modes, ensure that the `raise_errors` option is set to `true`, and the `show_exceptions` option is set to `false`:
+```ruby
set :raise_errors, true
set :show_exceptions, false
```
-If you would like to use custom error handlers, then you need to notify Bugsnag
-explicitly.
-
-```
-error 500 do
- Bugsnag.notify($!) do |report|
- report.severity = "error"
- end
- erb :'errors/500'
-end
-```
-
-Install dependencies.
-
-```
-bundle install
-```
+## Running the examples
-Launch the Sinatra application.
+Run the example using:
-```
+```shell
bundle exec rackup
```
-Next, open your project's dashboard on Bugsnag.
-
-1. [crash](http://localhost:9292/crash)
-
-Crashes the application and sends a notification about the nature of the crash.
-Basically, almost any unhandled exception sends a notification to Bugsnag. See
-the line mentioning `get '/crash'`.
-
-1. [crash and use callbacks](http://localhost:9292/crash_with_callback)
-
-Before crashing, the application would append the Diagnostics tab with some
-predefined information, attached by means of a callback. See the line mentioning
-`get '/crash_with_callback'`.
-
-1. [notify](http://localhost:9292/notify)
-
-Bugsnag Ruby provides a way to send notifications on demand by means of
-`Bugsnag.notify`. This API allows to send notifications manually, without
-crashing your application. See the line mentioning `get '/notify'`.
-
-1. [notify with meta data](http://localhost:9292/notify_meta)
-
-Same as `notify`, but also attaches meta data. The meta data is any additional
-information you want to attach to an exception. In this artificial case
-additional information with be sent and displayed in a new tab called
-"Diagnostics". See the line mentioning `get '/notify_meta'`.
-
-1. [severity](http://localhost:9292/severity)
-
-Bugsnag supports three severities: 'error', 'warning' and 'info'. You can set
-the severity by passing one of these objects as a string to '#notify'. See the
-line mentioning `get '/severity'`.
+Next, open your project's dashboard on Bugsnag, and go to the default server route.
\ No newline at end of file
diff --git a/example/sinatra/config.ru b/example/sinatra/config.ru
index 1c46f6965..68efa300b 100644
--- a/example/sinatra/config.ru
+++ b/example/sinatra/config.ru
@@ -7,7 +7,7 @@ set :raise_errors, true
set :show_exceptions, false
Bugsnag.configure do |config|
- config.api_key = 'f35a2472bd230ac0ab0f52715bbdc65d'
+ config.api_key = 'YOUR_API_KEY'
end
get '/' do
@@ -15,7 +15,7 @@ get '/' do
fenced_code_blocks: true
}
renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML, opts)
- renderer.render(File.read(File.expand_path('README.md')))
+ renderer.render(File.read(File.expand_path('templates/index.md')))
end
get '/crash' do
@@ -46,31 +46,31 @@ get '/notify' do
' for a new notification.'
end
-get '/notify_meta' do
- meta_data = {
- :user => {
+get '/notify_data' do
+ error = RuntimeError.new("Bugsnag Sinatra demo says: False alarm, your application didn't crash")
+ Bugsnag.notify error do |report|
+ report.add_tab(:user, {
:username => "bob-hoskins",
:email => 'bugsnag@bugsnag.com',
:registered_user => true
- },
-
- :diagnostics => {
+ })
+ report.add_tab(:diagnostics, {
:message => 'Sinatra demo says: Everything is great',
:code => 200
- }
- }
- error = RuntimeError.new("Bugsnag Sinatra demo says: False alarm, your application didn't crash")
- Bugsnag.notify(error, meta_data)
+ })
+ end
"Bugsnag Sinatra demo says: It didn't crash! " +
'But still go check https://bugsnag.com' +
' for a new notification. Check out the User tab for the meta data'
end
-get '/severity' do
+get '/notify_severity' do
msg = "Bugsnag Sinatra demo says: Look at the circle on the right side. It's different"
error = RuntimeError.new(msg)
- Bugsnag.notify(error, severity: 'info')
+ Bugsnag.notify error do |report|
+ report.severity = 'info'
+ end
msg
end
diff --git a/example/sinatra/templates/index.md b/example/sinatra/templates/index.md
new file mode 100644
index 000000000..52695efe2
--- /dev/null
+++ b/example/sinatra/templates/index.md
@@ -0,0 +1,25 @@
+# Bugsnag Rack demo
+
+This application demonstrates the use of Bugsnag with the Rack web framework.
+
+While testing the examples open [your dashboard](https://app.bugsnag.com) in order to see the example errors and exceptions being received.
+
+1. [Crash](/crash)
+
+ Raises an error within the framework, generating a report in the Bugsnag dashboard.
+
+2. [Crash and use callbacks](/crash_with_callback)
+
+ Raises an exception within the framework, but with additional data attached to the report. By registering a callback before the error occurs useful data can be attached as a tab in the Bugsnag dashboard.
+
+3. [Notify](/notify)
+
+ Sends Bugsnag a report on demand using `bugsnag.notify`. Allows details of handled errors or information to be sent to the Bugsnag dashboard without crashing your code.
+
+4. [Notify with data](/notify_data)
+
+ Same as `notify` but allows you to attach additional data within a `block`, similar to the `before_notify_callbacks` example above. In this case we're adding information about the user to go into the `user` tab, and additional diagnostics as a `diagnostics` tab.
+
+5. [Set the severity](/notify_severity)
+
+ This uses the same mechanism as adding meta-data, but allows you to set he `severity` when notifying Bugsnag of the error. Valid severities are `error`, `warning`, and `info`. Have a look on the dashboard to see the difference in these severities.
\ No newline at end of file