Skip to content

Commit

Permalink
- Launched the same analytic event that was triggered on the old flow…
Browse files Browse the repository at this point in the history
… tied to the logIn button, but on the OAuth flow is launched once the token and user are retrieved successfully (#1973)

(cherry picked from commit 33bebd8)

Co-authored-by: mtgriego <[email protected]>
  • Loading branch information
Arkariang and mtgriego authored Mar 8, 2024
1 parent a46e185 commit 484f230
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class OAuthViewModel(
private val logcat = "Oauth :"
private val hostEndpoint = environment.webEndpoint()
private val loginUseCase = LoginUseCase(environment)
private val analyticEvents = requireNotNull(environment.analytics())
private val apiClient = requireNotNull(environment.apiClientV2())
private val clientID = when (hostEndpoint) {
WebEndpoint.PRODUCTION -> Secrets.Api.Client.PRODUCTION
Expand Down Expand Up @@ -103,6 +104,7 @@ class OAuthViewModel(
user = user,
)
)
analyticEvents.trackLogInButtonCtaClicked()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.kickstarter.KSRobolectricTestCase
import com.kickstarter.libs.Environment
import com.kickstarter.libs.MockCurrentUserV2
import com.kickstarter.libs.utils.CodeVerifier
import com.kickstarter.libs.utils.EventName
import com.kickstarter.libs.utils.PKCE
import com.kickstarter.libs.utils.Secrets
import com.kickstarter.mock.factories.ApiExceptionFactory
Expand Down Expand Up @@ -125,7 +126,7 @@ class OAuthViewModelTest : KSRobolectricTestCase() {
}

@Test
fun testProduceState_getTokeAndUser() = runTest {
fun testProduceState_getTokenAndUser() = runTest {

val user = UserFactory.user()
val apiClient = object : MockApiClientV2() {
Expand Down Expand Up @@ -183,6 +184,7 @@ class OAuthViewModelTest : KSRobolectricTestCase() {
)

assertEquals(currentUserV2.accessToken, "token")
this@OAuthViewModelTest.segmentTrack.assertValues(EventName.CTA_CLICKED.eventName)
}

@Test
Expand Down Expand Up @@ -245,6 +247,7 @@ class OAuthViewModelTest : KSRobolectricTestCase() {
)

assertEquals(currentUserV2.accessToken, null)
this@OAuthViewModelTest.segmentTrack.assertNoValues()
}

fun testProduceState_getTokeAndUser_ErrorWhileToken() = runTest {
Expand Down

0 comments on commit 484f230

Please sign in to comment.