-
Notifications
You must be signed in to change notification settings - Fork 32
[AI-FSSDK] [FSSDK-12670] Block ODP identify event for single identifier #629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
97dcc38
[AI-FSSDK] [FSSDK-12670] Block ODP identify event for single identifier
jaeopt c50684d
[FSSDK-12670] Restore deprecated identifyUser overloads for backward …
jaeopt af82dcf
[FSSDK-12670] Address review feedback: fix log message and null guard
jaeopt 3158e18
[FSSDK-12670] Retrigger CI
jaeopt 436cbe2
[FSSDK-12670] Add comment explaining the < 2 identifiers guard
jaeopt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,7 +203,10 @@ public void prepareCorrectPayloadForIdentifyUser() throws InterruptedException { | |
| eventManager.updateSettings(odpConfig); | ||
| eventManager.start(); | ||
| for (int i = 0; i < 2; i++) { | ||
| eventManager.identifyUser("the-vuid-" + i, "the-fs-user-id-" + i); | ||
| Map<String, String> identifiers = new HashMap<>(); | ||
| identifiers.put("vuid", "the-vuid-" + i); | ||
| identifiers.put("fs_user_id", "the-fs-user-id-" + i); | ||
| eventManager.identifyUser(identifiers); | ||
| } | ||
|
|
||
| Thread.sleep(1500); | ||
|
|
@@ -290,61 +293,88 @@ public void preparePayloadForIdentifyUserWithVariationsOfFsUserId() throws Inter | |
| } | ||
|
|
||
| @Test | ||
| public void identifyUserWithVuidAndUserId() throws InterruptedException { | ||
| public void identifyUserWithMultipleIdentifiers() throws InterruptedException { | ||
| ODPEventManager eventManager = spy(new ODPEventManager(mockApiManager)); | ||
| ArgumentCaptor<ODPEvent> captor = ArgumentCaptor.forClass(ODPEvent.class); | ||
|
|
||
| eventManager.identifyUser("vuid_123", "test-user"); | ||
| Map<String, String> identifiers = new HashMap<>(); | ||
| identifiers.put("vuid", "vuid_123"); | ||
| identifiers.put("fs_user_id", "test-user"); | ||
| eventManager.identifyUser(identifiers); | ||
| verify(eventManager, times(1)).sendEvent(captor.capture()); | ||
|
|
||
| ODPEvent event = captor.getValue(); | ||
| Map<String, String> identifiers = event.getIdentifiers(); | ||
| assertEquals(identifiers.size(), 2); | ||
| assertEquals(identifiers.get("vuid"), "vuid_123"); | ||
| assertEquals(identifiers.get("fs_user_id"), "test-user"); | ||
| Map<String, String> eventIdentifiers = event.getIdentifiers(); | ||
| assertEquals(2, eventIdentifiers.size()); | ||
| assertEquals("vuid_123", eventIdentifiers.get("vuid")); | ||
| assertEquals("test-user", eventIdentifiers.get("fs_user_id")); | ||
| } | ||
|
|
||
| @Test | ||
| public void identifyUserWithVuidOnly() throws InterruptedException { | ||
| public void identifyUserSkippedWithSingleIdentifier() throws InterruptedException { | ||
| ODPEventManager eventManager = spy(new ODPEventManager(mockApiManager)); | ||
| ArgumentCaptor<ODPEvent> captor = ArgumentCaptor.forClass(ODPEvent.class); | ||
|
|
||
| eventManager.identifyUser("vuid_123", null); | ||
| verify(eventManager, times(1)).sendEvent(captor.capture()); | ||
| Map<String, String> identifiers = new HashMap<>(); | ||
| identifiers.put("fs_user_id", "test-user"); | ||
| eventManager.identifyUser(identifiers); | ||
| verify(eventManager, never()).sendEvent(any(ODPEvent.class)); | ||
| logbackVerifier.expectMessage(Level.DEBUG, "ODP identify event is not dispatched (fewer than 2 valid identifiers)."); | ||
| } | ||
|
|
||
| ODPEvent event = captor.getValue(); | ||
| Map<String, String> identifiers = event.getIdentifiers(); | ||
| assertEquals(identifiers.size(), 1); | ||
| assertEquals(identifiers.get("vuid"), "vuid_123"); | ||
| @Test | ||
| public void identifyUserSkippedWithEmptyValues() throws InterruptedException { | ||
| ODPEventManager eventManager = spy(new ODPEventManager(mockApiManager)); | ||
|
|
||
| // Two keys but one has empty value - only 1 valid identifier | ||
| Map<String, String> identifiers = new HashMap<>(); | ||
| identifiers.put("fs_user_id", "test-user"); | ||
| identifiers.put("email", ""); | ||
| eventManager.identifyUser(identifiers); | ||
| verify(eventManager, never()).sendEvent(any(ODPEvent.class)); | ||
| logbackVerifier.expectMessage(Level.DEBUG, "ODP identify event is not dispatched (fewer than 2 valid identifiers)."); | ||
| } | ||
|
|
||
| @Test | ||
| public void identifyUserWithUserIdOnly() throws InterruptedException { | ||
| public void identifyUserSkippedWithNullValues() throws InterruptedException { | ||
| ODPEventManager eventManager = spy(new ODPEventManager(mockApiManager)); | ||
| ArgumentCaptor<ODPEvent> captor = ArgumentCaptor.forClass(ODPEvent.class); | ||
|
|
||
| eventManager.identifyUser(null, "test-user"); | ||
| verify(eventManager, times(1)).sendEvent(captor.capture()); | ||
| // Two keys but one has null value - only 1 valid identifier | ||
| Map<String, String> identifiers = new HashMap<>(); | ||
| identifiers.put("fs_user_id", "test-user"); | ||
| identifiers.put("vuid", null); | ||
| eventManager.identifyUser(identifiers); | ||
| verify(eventManager, never()).sendEvent(any(ODPEvent.class)); | ||
| logbackVerifier.expectMessage(Level.DEBUG, "ODP identify event is not dispatched (fewer than 2 valid identifiers)."); | ||
| } | ||
|
|
||
| ODPEvent event = captor.getValue(); | ||
| Map<String, String> identifiers = event.getIdentifiers(); | ||
| assertEquals(identifiers.size(), 1); | ||
| assertEquals(identifiers.get("fs_user_id"), "test-user"); | ||
| @Test | ||
| public void identifyUserSkippedWithEmptyMap() throws InterruptedException { | ||
| ODPEventManager eventManager = spy(new ODPEventManager(mockApiManager)); | ||
|
|
||
| Map<String, String> identifiers = new HashMap<>(); | ||
| eventManager.identifyUser(identifiers); | ||
| verify(eventManager, never()).sendEvent(any(ODPEvent.class)); | ||
| logbackVerifier.expectMessage(Level.DEBUG, "ODP identify event is not dispatched (fewer than 2 valid identifiers)."); | ||
| } | ||
|
|
||
| @Test | ||
| public void identifyUserWithVuidAsUserId() throws InterruptedException { | ||
| public void identifyUserSendsWithThreeIdentifiers() throws InterruptedException { | ||
| ODPEventManager eventManager = spy(new ODPEventManager(mockApiManager)); | ||
| ArgumentCaptor<ODPEvent> captor = ArgumentCaptor.forClass(ODPEvent.class); | ||
|
|
||
| eventManager.identifyUser(null, "vuid_123"); | ||
| Map<String, String> identifiers = new HashMap<>(); | ||
| identifiers.put("vuid", "vuid_123"); | ||
| identifiers.put("fs_user_id", "test-user"); | ||
| identifiers.put("email", "[email protected]"); | ||
| eventManager.identifyUser(identifiers); | ||
| verify(eventManager, times(1)).sendEvent(captor.capture()); | ||
|
|
||
| ODPEvent event = captor.getValue(); | ||
| Map<String, String> identifiers = event.getIdentifiers(); | ||
| assertEquals(identifiers.size(), 1); | ||
| // SDK will convert userId to vuid when userId has a valid vuid format. | ||
| assertEquals(identifiers.get("vuid"), "vuid_123"); | ||
| Map<String, String> eventIdentifiers = event.getIdentifiers(); | ||
| assertEquals(3, eventIdentifiers.size()); | ||
| assertEquals("vuid_123", eventIdentifiers.get("vuid")); | ||
| assertEquals("test-user", eventIdentifiers.get("fs_user_id")); | ||
| assertEquals("[email protected]", eventIdentifiers.get("email")); | ||
| } | ||
|
|
||
| @Test | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.