lib/sinatra/toadhopper.rb in toadhopper-sinatra-0.3 vs lib/sinatra/toadhopper.rb in toadhopper-sinatra-0.4

- old
+ new

@@ -4,26 +4,32 @@ module Sinatra # The Toadhopper helper methods module Toadhopper # Reports the current sinatra error to Hoptoad def post_error_to_hoptoad! - if options.respond_to?(:toadhopper) - options.toadhopper.each_pair {|k, v| ::Toadhopper.__send__("#{k}=", v)} - end + options.toadhopper.each_pair {|k, v| ::Toadhopper.__send__("#{k}=", v)} unless ::Toadhopper.api_key STDERR.puts "WARNING: Ignoring hoptoad notification - :api_key not set" return end ::Toadhopper.post!( env['sinatra.error'], { - :parameters => params, - :url => request.url, - :cgi_data => request.env, - :environment_vars => ENV, - :session_data => session.to_hash + :environment => ENV, + :request => { + :params => params, + :rails_root => options.root, + :url => request.url + }, + :session => { + :key => 42, # Doesn't apply to Rack sessions + :data => session + } } ) end + end + def self.registered(app) + app.set :hoptoad, {} end helpers Toadhopper end