kangguru / rack-google-analytics

Simple Rack middleware for implementing google analytics tracking in your Ruby-Rack based project. Supports synchronous and asynchronous insertion and configurable load options
MIT License
257 stars 53 forks source link

Throws an Internal Server Error on Heroku #49

Closed pbougie closed 9 years ago

pbougie commented 9 years ago

I'm trying to update rack-google-analytics for a Sinatra app that I developed. I keep getting an Internal Server Error on Heroku with versions 1.0.0 and above. Works fine locally. Version 0.14.0 also works fine.

From the Heroku logs:

2014-11-15T15:29:38.060545+00:00 app[web.1]: Unexpected error while processing request: undefined method `to_json' for {}:Hash
2014-11-15T15:29:38.060554+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-google-analytics-1.2.0/lib/rack/google-analytics.rb:49:in `inject'
2014-11-15T15:29:38.060555+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-google-analytics-1.2.0/lib/rack/google-analytics.rb:38:in `block in _call'
2014-11-15T15:29:38.060557+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-google-analytics-1.2.0/lib/rack/google-analytics.rb:38:in `each'
2014-11-15T15:29:38.060559+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-google-analytics-1.2.0/lib/rack/google-analytics.rb:38:in `_call'
2014-11-15T15:29:38.060560+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-google-analytics-1.2.0/lib/rack/google-analytics.rb:15:in `call'
2014-11-15T15:29:38.060562+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-gauges-1.1.0/lib/rack/gauges.rb:15:in `_call'
2014-11-15T15:29:38.060564+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-gauges-1.1.0/lib/rack/gauges.rb:12:in `call'
2014-11-15T15:29:38.060565+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
2014-11-15T15:29:38.060566+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
2014-11-15T15:29:38.060568+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
2014-11-15T15:29:38.060569+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
2014-11-15T15:29:38.060571+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
2014-11-15T15:29:38.060572+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
2014-11-15T15:29:38.060574+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/logger.rb:15:in `call'
2014-11-15T15:29:38.060575+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/commonlogger.rb:33:in `call'
2014-11-15T15:29:38.060577+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:217:in `call'
2014-11-15T15:29:38.060578+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:210:in `call'
2014-11-15T15:29:38.060579+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
2014-11-15T15:29:38.060580+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
2014-11-15T15:29:38.060582+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:180:in `call'
2014-11-15T15:29:38.060583+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:2014:in `call'
2014-11-15T15:29:38.060584+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `block in call'
2014-11-15T15:29:38.060585+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1788:in `synchronize'
2014-11-15T15:29:38.060586+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `call'
2014-11-15T15:29:38.060588+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/connection.rb:86:in `block in pre_process'
2014-11-15T15:29:38.060589+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/connection.rb:84:in `catch'
2014-11-15T15:29:38.060612+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/connection.rb:84:in `pre_process'
2014-11-15T15:29:38.060613+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/connection.rb:53:in `process'
2014-11-15T15:29:38.060615+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/connection.rb:39:in `receive_data'
2014-11-15T15:29:38.060616+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
2014-11-15T15:29:38.060617+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
2014-11-15T15:29:38.060618+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/backends/base.rb:73:in `start'
2014-11-15T15:29:38.060619+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/server.rb:162:in `start'
2014-11-15T15:29:38.060620+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/controllers/controller.rb:87:in `start'
2014-11-15T15:29:38.060622+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/runner.rb:200:in `run_command'
2014-11-15T15:29:38.060623+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/runner.rb:156:in `run!'
2014-11-15T15:29:38.060624+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/bin/thin:6:in `<top (required)>'
2014-11-15T15:29:38.060626+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/bin/thin:23:in `load'
2014-11-15T15:29:38.060627+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/bin/thin:23:in `<main>'

Any help would be appreciated.

kangguru commented 9 years ago

strange thing is that it works locally, normally #to_json will be added by activesupport.

apart from that rack-google-analytics isn't under development anymore, but Rack::Tracker is offering the same functionalities and supports even more tracking services. so i'd encourage you to try that one, hopefully your error will then be vanish into thin air ;)

pbougie commented 9 years ago

Thanks. I'll give Rack::Tracker a try.

kangguru commented 9 years ago

cool ;) see you there