-
Notifications
You must be signed in to change notification settings - Fork 663
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds attestation analytics events. (#9831)
- Loading branch information
1 parent
61c18c7
commit 2b6caa8
Showing
12 changed files
with
164 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
37 changes: 37 additions & 0 deletions
37
...ons/src/main/java/com/stripe/android/financialconnections/domain/RequestIntegrityToken.kt
This file contains 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.stripe.android.financialconnections.domain | ||
|
||
import com.stripe.android.financialconnections.analytics.FinancialConnectionsAnalyticsEvent.AttestationEndpoint | ||
import com.stripe.android.financialconnections.analytics.FinancialConnectionsAnalyticsEvent.AttestationRequestFailed | ||
import com.stripe.android.financialconnections.analytics.FinancialConnectionsAnalyticsEvent.AttestationRequestSucceeded | ||
import com.stripe.android.financialconnections.analytics.FinancialConnectionsAnalyticsTracker | ||
import com.stripe.android.financialconnections.model.FinancialConnectionsSessionManifest | ||
import com.stripe.attestation.IntegrityRequestManager | ||
import jakarta.inject.Inject | ||
|
||
internal class RequestIntegrityToken @Inject constructor( | ||
private val integrityRequestManager: IntegrityRequestManager, | ||
private val analyticsTracker: FinancialConnectionsAnalyticsTracker | ||
) { | ||
suspend operator fun invoke( | ||
endpoint: AttestationEndpoint, | ||
pane: FinancialConnectionsSessionManifest.Pane | ||
): String = integrityRequestManager.requestToken() | ||
.onSuccess { | ||
analyticsTracker.track( | ||
AttestationRequestSucceeded( | ||
pane = pane, | ||
endpoint = endpoint | ||
) | ||
) | ||
} | ||
.onFailure { | ||
analyticsTracker.track( | ||
AttestationRequestFailed( | ||
pane = pane, | ||
endpoint = endpoint, | ||
error = it | ||
) | ||
) | ||
} | ||
.getOrThrow() | ||
} |
This file contains 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 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 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 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 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 |
---|---|---|
|
@@ -6,12 +6,12 @@ import com.stripe.android.financialconnections.ApiKeyFixtures.syncResponse | |
import com.stripe.android.financialconnections.domain.AttachConsumerToLinkAccountSession | ||
import com.stripe.android.financialconnections.domain.GetOrFetchSync | ||
import com.stripe.android.financialconnections.domain.HandleError | ||
import com.stripe.android.financialconnections.domain.RequestIntegrityToken | ||
import com.stripe.android.financialconnections.features.networkinglinksignup.NetworkingLinkSignupState.Payload | ||
import com.stripe.android.financialconnections.model.FinancialConnectionsSessionManifest.Pane | ||
import com.stripe.android.financialconnections.navigation.NavigationManager | ||
import com.stripe.android.financialconnections.presentation.Async | ||
import com.stripe.android.financialconnections.repository.FinancialConnectionsConsumerSessionRepository | ||
import com.stripe.android.financialconnections.utils.TestIntegrityRequestManager | ||
import kotlinx.coroutines.test.runTest | ||
import org.junit.Before | ||
import org.mockito.kotlin.any | ||
|
@@ -29,7 +29,7 @@ class LinkSignupHandlerForInstantDebitsTest { | |
private val consumerRepository = mock<FinancialConnectionsConsumerSessionRepository>() | ||
private val getOrFetchSync = mock<GetOrFetchSync>() | ||
private val attachConsumerToLinkAccountSession = mock<AttachConsumerToLinkAccountSession>() | ||
private val integrityRequestManager = TestIntegrityRequestManager() | ||
private val requestIntegrityToken = mock<RequestIntegrityToken>() | ||
private val navigationManager = mock<NavigationManager>() | ||
private val handleError = mock<HandleError>() | ||
|
||
|
@@ -38,7 +38,7 @@ class LinkSignupHandlerForInstantDebitsTest { | |
handler = LinkSignupHandlerForInstantDebits( | ||
consumerRepository, | ||
attachConsumerToLinkAccountSession, | ||
integrityRequestManager, | ||
requestIntegrityToken, | ||
getOrFetchSync, | ||
navigationManager, | ||
"applicationId", | ||
|
@@ -61,14 +61,16 @@ class LinkSignupHandlerForInstantDebitsTest { | |
|
||
@Test | ||
fun `performSignup should navigate to next pane on success`() = runTest { | ||
val expectedToken = "token" | ||
val expectedPane = Pane.INSTITUTION_PICKER | ||
val testState = NetworkingLinkSignupState( | ||
validEmail = "[email protected]", | ||
validPhone = "+123456789", | ||
isInstantDebits = true, | ||
payload = Async.Success(validPayload) | ||
) | ||
|
||
val expectedPane = Pane.INSTITUTION_PICKER | ||
whenever(requestIntegrityToken(anyOrNull(), anyOrNull())).thenReturn(expectedToken) | ||
whenever(getOrFetchSync(anyOrNull(), anyOrNull())).thenReturn( | ||
syncResponse( | ||
sessionManifest().copy( | ||
|
Oops, something went wrong.