Commit d8b419332937a169e39abdac8996ee42ff69d055
1 parent
6a547b7d
Exists in
master
simplify old user data json parsing
Showing
2 changed files
with
9 additions
and
5 deletions
Show diff stats
lib/airbrake_api/v3/notice_parser.rb
@@ -69,10 +69,14 @@ module AirbrakeApi | @@ -69,10 +69,14 @@ module AirbrakeApi | ||
69 | end | 69 | end |
70 | 70 | ||
71 | def user_attributes | 71 | def user_attributes |
72 | - context['user'] || begin | ||
73 | - hash = context.slice('userId', 'userUsername', 'userName', 'userEmail') | ||
74 | - Hash[hash.map { |key, value| [key[4..-1].downcase, value] }] | ||
75 | - end | 72 | + return context['user'] if context['user'] |
73 | + | ||
74 | + { | ||
75 | + 'id' => context['userId'], | ||
76 | + 'name' => context['userName'], | ||
77 | + 'email' => context['userEmail'], | ||
78 | + 'username' => context['userUsername'] | ||
79 | + }.compact | ||
76 | end | 80 | end |
77 | 81 | ||
78 | def url | 82 | def url |
spec/fixtures/api_v3_request_with_deprecated_user_keys.json
@@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
22 | "sourceMapEnabled":true, | 22 | "sourceMapEnabled":true, |
23 | "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36", | 23 | "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36", |
24 | "url":"http://localhost:3000/kontakt", | 24 | "url":"http://localhost:3000/kontakt", |
25 | - "userId":1,"userUsername":"john", | 25 | + "userId":1, |
26 | "userName":"John Doe", | 26 | "userName":"John Doe", |
27 | "userUsername": "john", | 27 | "userUsername": "john", |
28 | "userEmail":"john.doe@example.org", | 28 | "userEmail":"john.doe@example.org", |