Skip to content

Commit

Permalink
Merge branch 'main' into rehan/mbl-755-screen-config-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Shahroz16 authored Dec 17, 2024
2 parents 14ffd19 + 9b3efeb commit 0a6fdb3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class CustomerIO private constructor(
}

// this is the current userId that is identified in the SDK
val currentlyIdentifiedProfile = this.userId
val currentlyIdentifiedProfile = this.userId.takeUnless { it.isNullOrBlank() }
val isChangingIdentifiedProfile = currentlyIdentifiedProfile != null && currentlyIdentifiedProfile != userId
val isFirstTimeIdentifying = currentlyIdentifiedProfile == null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,29 @@ class DataPipelinesInteractionTests : JUnitTest() {
identifyEvent.traits.shouldBeEqualTo(emptyJsonObject)
}

@Test
fun identify_givenProfileAttributesAndNoIdentifier_expectSetNewProfileWithoutAttributes() {
val givenIdentifier = String.random

analytics.userId().shouldBeNull()
every { globalPreferenceStore.getDeviceToken() } returns String.random

sdkInstance.profileAttributes = mapOf("first_name" to "Dana", "ageInYears" to 30)
analytics.userId() shouldBe ""
sdkInstance.identify(givenIdentifier)

analytics.userId().shouldBeEqualTo(givenIdentifier)
analytics.traits().shouldBeEqualTo(emptyJsonObject)

outputReaderPlugin.identifyEvents.size shouldBeEqualTo 2
val identifyEvent = outputReaderPlugin.identifyEvents.lastOrNull()
identifyEvent.shouldNotBeNull()
identifyEvent.userId.shouldBeEqualTo(givenIdentifier)
identifyEvent.traits.shouldBeEqualTo(emptyJsonObject)

outputReaderPlugin.trackEvents.size shouldBeEqualTo 1
}

@Test
fun identify_givenIdentifierWithMap_expectSetNewProfileWithAttributes() {
val givenIdentifier = String.random
Expand Down

0 comments on commit 0a6fdb3

Please sign in to comment.