Commit d5c07b65567ed16e3c4531d3dfc0332dab5b40b0
Exists in
master
Merge pull request #1 from stevecrozz/new_user_payload
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 | 69 | end |
70 | 70 | |
71 | 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 | 80 | end |
77 | 81 | |
78 | 82 | def url | ... | ... |
spec/fixtures/api_v3_request_with_deprecated_user_keys.json
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 | "sourceMapEnabled":true, |
23 | 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 | 24 | "url":"http://localhost:3000/kontakt", |
25 | - "userId":1,"userUsername":"john", | |
25 | + "userId":1, | |
26 | 26 | "userName":"John Doe", |
27 | 27 | "userUsername": "john", |
28 | 28 | "userEmail":"john.doe@example.org", | ... | ... |