From 52cf4721da29cc7a49053b31dbd799f511240e84 Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Wed, 27 Aug 2014 16:04:59 -0700 Subject: [PATCH] lib/bugsnag/middleware/rack_request: early load session for Rails 4 Fixes #144 (Rails 4 sessions appear in custom tab) Context: https://github.com/rails/rails/issues/10813 --- CHANGELOG.md | 5 +++++ lib/bugsnag/middleware/rack_request.rb | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33f61ee34..407ccb681 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Changelog ========= +?????? +------ + +- Fix Rails 4 sessions appearing in Custom tab instead of its own ([144](https://github.com/bugsnag/bugsnag-ruby/issues/144)) + 2.4.0 ----- - Allow filters to be regular expressions (thanks @tamird) diff --git a/lib/bugsnag/middleware/rack_request.rb b/lib/bugsnag/middleware/rack_request.rb index d8168fd83..dc89b3ad4 100644 --- a/lib/bugsnag/middleware/rack_request.rb +++ b/lib/bugsnag/middleware/rack_request.rb @@ -39,7 +39,15 @@ def call(notification) notification.add_tab(:environment, env) # Add a session tab - notification.add_tab(:session, session) if session + if session + if session.is_a?(Hash) + # Rails 3 + notification.add_tab(:session, session) + elsif session.respond_to?(:to_hash) + # Rails 4 + notification.add_tab(:session, session.to_hash) + end + end # Add a cookies tab cookies = request.cookies