Skip to content

Commit

Permalink
Merge pull request #119 from MindscapeHQ/fix-affected-user-tracking
Browse files Browse the repository at this point in the history
Use lowercase user identifier keys
  • Loading branch information
UberMouse authored May 8, 2017
2 parents d6967fd + 1b5221f commit ac51d5d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 21 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
## 2.2.0
## 2.3.0 (09/05/2017)

Bugfixes
- Fix issue preventing affected users for a crash report from showing up in the affected users page ([#119](https://github.com/MindscapeHQ/raygun4ruby/pull/119))

## 2.2.0 (05/05/2017)

Features
- Opt in support for sending exceptions in a background thread to not block web request thread during IO ([#117](https://github.com/MindscapeHQ/raygun4ruby/pull/117))

Bugfixes
- Don't attempt to read raw data during GET requests or if rack.input buffer is empty

## 2.1.0
## 2.1.0 (27/04/2017)

Features
- Ability to record breadcrumbs in your code that will be sent to Raygun along with a raised exception ([#113](https://github.com/MindscapeHQ/raygun4ruby/pull/113))
Expand Down
16 changes: 8 additions & 8 deletions lib/raygun/affected_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class AffectedUser
}.freeze
SUPPORTED_ATTRIBUTES = DEFAULT_MAPPING.keys.freeze
NAME_TO_RAYGUN_NAME_MAPPING = {
identifier: :Identifier,
email: :Email,
full_name: :FullName,
first_name: :FirstName,
uuid: :UUID
identifier: :identifier,
email: :email,
full_name: :fullName,
first_name: :firstName,
uuid: :uuid
}.freeze

class << self
Expand All @@ -29,13 +29,13 @@ def information_hash(user_object)
private

def handle_anonymous_user(user_object)
result = { IsAnonymous: true }
result[:Identifier] = user_object unless user_object.nil?
result = { isAnonymous: true }
result[:identifier] = user_object unless user_object.nil?
result
end

def handle_known_user(user_object)
SUPPORTED_ATTRIBUTES.reduce({ IsAnonymous: false }) do |result, attribute|
SUPPORTED_ATTRIBUTES.reduce({ isAnonymous: false }) do |result, attribute|
mapping = Raygun.configuration.affected_user_mapping
method = mapping[attribute]

Expand Down
2 changes: 1 addition & 1 deletion lib/raygun/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Raygun
VERSION = "2.2.0"
VERSION = "2.3.0"
end
12 changes: 6 additions & 6 deletions test/unit/affected_user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_inserting_user_object_with_email
begin
@middleware.call("action_controller.instance" => @controller)
rescue TestException
user_hash = { :Identifier => 123, :Email => "[email protected]", :IsAnonymous => false }
user_hash = { :identifier => 123, :email => "[email protected]", :isAnonymous => false }
assert_equal user_hash, @app.env["raygun.affected_user"]
end
end
Expand All @@ -77,7 +77,7 @@ def test_changing_method_mapping
begin
@middleware.call("action_controller.instance" => @controller)
rescue TestException
user_hash = { :Identifier => "topsecret", :IsAnonymous => false }
user_hash = { :identifier => "topsecret", :isAnonymous => false }
assert_equal user_hash, @app.env["raygun.affected_user"]
end
end
Expand All @@ -89,7 +89,7 @@ def test_inserting_user_as_plain_string
begin
@middleware.call("action_controller.instance" => @controller)
rescue TestException
user_hash = { :Identifier => "some-string-identifier", :IsAnonymous => true }
user_hash = { :identifier => "some-string-identifier", :isAnonymous => true }
assert_equal user_hash, @app.env["raygun.affected_user"]
end
end
Expand All @@ -101,7 +101,7 @@ def test_with_a_nil_user
begin
@middleware.call("action_controller.instance" => @controller)
rescue TestException
user_hash = { :IsAnonymous => true }
user_hash = { :isAnonymous => true }
assert_equal user_hash, @app.env["raygun.affected_user"]
end
end
Expand All @@ -113,7 +113,7 @@ def test_with_private_method
begin
@middleware.call("action_controller.instance" => @controller)
rescue TestException
user_hash = {:IsAnonymous=>false, :Identifier=>123, :Email=>"[email protected]"}
user_hash = {:isAnonymous=>false, :identifier=>123, :email=>"[email protected]"}
assert_equal user_hash, @app.env["raygun.affected_user"]
end
end
Expand All @@ -129,7 +129,7 @@ def test_with_proc_for_mapping
begin
@middleware.call("action_controller.instance" => @controller)
rescue TestException
user_hash = {:IsAnonymous=>false, :Identifier=>123, :Email=>"[email protected]", :FullName => "Taylor Lodge", :FirstName => "Taylor"}
user_hash = {:isAnonymous=>false, :identifier=>123, :email=>"[email protected]", :fullName => "Taylor Lodge", :firstName => "Taylor"}
assert_equal user_hash, @app.env["raygun.affected_user"]
end
end
Expand Down
8 changes: 4 additions & 4 deletions test/unit/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,10 @@ def test_filter_payload_with_whitelist_request_specific_keys
def test_build_payload_hash_adds_affected_user_details_when_supplied_with_user
user = OpenStruct.new(id: '123', email: '[email protected]', first_name: 'Taylor')
expected_details = {
:IsAnonymous => false,
:Identifier => '123',
:Email => '[email protected]',
:FirstName => 'Taylor',
:isAnonymous => false,
:identifier => '123',
:email => '[email protected]',
:firstName => 'Taylor',
}

user_details = @client.send(:build_payload_hash, test_exception, sample_env_hash, user)[:details][:user]
Expand Down

0 comments on commit ac51d5d

Please sign in to comment.