Skip to content

Commit

Permalink
identify should not emit events if user key is "" (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
keelerm84 authored Jan 28, 2022
1 parent 64b2549 commit 275b005
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/ldclient-rb/ldclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ def variation_detail(key, user, default)
# @return [void]
#
def identify(user)
if !user || user[:key].nil?
@config.logger.warn("Identify called with nil user or nil user key!")
if !user || user[:key].nil? || user[:key].empty?
@config.logger.warn("Identify called with nil user or empty user key!")
return
end
sanitize_user(user)
Expand Down
4 changes: 2 additions & 2 deletions spec/ldclient_events_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,13 @@ def event_processor(client)
end
end

it "does not send event, and logs warning, if user key is nil" do
it "does not send event, and logs warning, if user key is blank" do
logger = double().as_null_object

with_client(test_config(logger: logger)) do |client|
expect(event_processor(client)).not_to receive(:add_event)
expect(logger).to receive(:warn)
client.identify({ key: nil })
client.identify({ key: "" })
end
end
end
Expand Down

0 comments on commit 275b005

Please sign in to comment.