Commit cb1212fa8c9bcf1e0c98e21d29fdfa225d2b3a41
1 parent
8f0aefe2
Exists in
master
and in
1 other branch
Added user_info data to notices, to retrieve and display info about the currently logged in user.
This allows us to know who took the action that caused the error, so we can follow up via email or phone if we need further information about the context.
Showing
6 changed files
with
25 additions
and
5 deletions
Show diff stats
app/models/error_report.rb
... | ... | @@ -2,7 +2,7 @@ require 'digest/md5' |
2 | 2 | require 'hoptoad_notifier' |
3 | 3 | |
4 | 4 | class ErrorReport |
5 | - attr_reader :klass, :message, :backtrace, :request, :server_environment, :api_key, :notifier | |
5 | + attr_reader :klass, :message, :backtrace, :request, :server_environment, :api_key, :notifier, :user_info | |
6 | 6 | |
7 | 7 | def initialize(xml_or_attributes) |
8 | 8 | @attributes = (xml_or_attributes.is_a?(String) ? Hoptoad.parse_xml!(xml_or_attributes) : xml_or_attributes).with_indifferent_access |
... | ... | @@ -35,7 +35,8 @@ class ErrorReport |
35 | 35 | :backtrace => backtrace, |
36 | 36 | :request => request, |
37 | 37 | :server_environment => server_environment, |
38 | - :notifier => notifier) | |
38 | + :notifier => notifier, | |
39 | + :user_info => user_info) | |
39 | 40 | |
40 | 41 | err = app.find_or_create_err!( |
41 | 42 | :klass => klass, | ... | ... |
app/models/notice.rb
app/views/errs/show.html.haml
... | ... | @@ -50,6 +50,7 @@ |
50 | 50 | %ul |
51 | 51 | %li= link_to 'Summary', '#summary', :rel => 'summary', :class => 'button' |
52 | 52 | %li= link_to 'Backtrace', '#backtrace', :rel => 'backtrace', :class => 'button' |
53 | + %li= link_to 'Application User', '#user_info', :rel => 'user_info', :class => 'button' | |
53 | 54 | %li= link_to 'Environment', '#environment', :rel => 'environment', :class => 'button' |
54 | 55 | %li= link_to 'Parameters', '#params', :rel => 'params', :class => 'button' |
55 | 56 | %li= link_to 'Session', '#session', :rel => 'session', :class => 'button' |
... | ... | @@ -63,6 +64,11 @@ |
63 | 64 | %h3 Backtrace |
64 | 65 | = render 'notices/backtrace', :lines => @notice.backtrace |
65 | 66 | |
67 | + - if @notice.user_info.present? | |
68 | + #user_info | |
69 | + %h3 User | |
70 | + = render 'notices/user_info', :user => @notice.user_info | |
71 | + | |
66 | 72 | #environment |
67 | 73 | %h3 Environment |
68 | 74 | = render 'notices/environment', :notice => @notice |
... | ... | @@ -74,4 +80,3 @@ |
74 | 80 | #session |
75 | 81 | %h3 Session |
76 | 82 | = render 'notices/session', :notice => @notice |
77 | - | ... | ... |
lib/hoptoad/v2.rb
lib/tasks/errbit/demo.rake
... | ... | @@ -52,7 +52,13 @@ namespace :errbit do |
52 | 52 | 'action' => 'error' |
53 | 53 | }, |
54 | 54 | :server_environment => {'environment-name' => Rails.env.to_s}, |
55 | - :notifier => {:name => "seeds.rb"} | |
55 | + :notifier => {:name => "seeds.rb"}, | |
56 | + :app_user => { | |
57 | + :id => "1234", | |
58 | + :username => "jsmith", | |
59 | + :name => "John Smith", | |
60 | + :url => "http://www.example.com/users/jsmith" | |
61 | + } | |
56 | 62 | }) |
57 | 63 | |
58 | 64 | app.report_error!(error_report) | ... | ... |