-
Notifications
You must be signed in to change notification settings - Fork 997
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
Add attestation event logging to FC API clients #4481
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
15e538a
Use mobile signup endpoint for verified FC flows
mats-stripe 910ba9a
Mark assertion as completed when finished
mats-stripe 8d8a695
Pass session_id, email_source, and request_surface to new lookup API
mats-stripe 6646e2a
Update for async api client
mats-stripe c938ccb
Add attestation event logging to FC API clients
mats-stripe 030e3db
Finalize event parameters, remove initial success log
mats-stripe 1177b3f
Fix test API conformances
mats-stripe 5f5d685
Rebase and fix issues
mats-stripe 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 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 |
---|---|---|
|
@@ -65,6 +65,7 @@ | |
495539EE2C484DC200543D18 /* FinancialConnectionsTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 495539ED2C484DC200543D18 /* FinancialConnectionsTheme.swift */; }; | ||
496A6AE72C29E0BB00D34F8E /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 496A6AE62C29E0BB00D34F8E /* [email protected] */; }; | ||
497142BC2C514B08000DFA64 /* FlowRouterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 497142BB2C514B08000DFA64 /* FlowRouterTests.swift */; }; | ||
499EEAFD2D3E948B00E1BE85 /* FinancialConnectionsAPIClientLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 499EEAFC2D3E948B00E1BE85 /* FinancialConnectionsAPIClientLogger.swift */; }; | ||
49A0B5862C5D2F3C00D697D9 /* FinancialConnectionsAPIClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49A0B5852C5D2F3C00D697D9 /* FinancialConnectionsAPIClientTests.swift */; }; | ||
49AC518C2C52DE2C00B712CC /* FinancialConnectionsLinkLoginPane.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49AC518B2C52DE2C00B712CC /* FinancialConnectionsLinkLoginPane.swift */; }; | ||
49C911372C597EAF00589E0D /* LinkLoginDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49C911332C597EAF00589E0D /* LinkLoginDataSource.swift */; }; | ||
|
@@ -330,6 +331,7 @@ | |
495539ED2C484DC200543D18 /* FinancialConnectionsTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinancialConnectionsTheme.swift; sourceTree = "<group>"; }; | ||
496A6AE62C29E0BB00D34F8E /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; }; | ||
497142BB2C514B08000DFA64 /* FlowRouterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlowRouterTests.swift; sourceTree = "<group>"; }; | ||
499EEAFC2D3E948B00E1BE85 /* FinancialConnectionsAPIClientLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinancialConnectionsAPIClientLogger.swift; sourceTree = "<group>"; }; | ||
49A0B5852C5D2F3C00D697D9 /* FinancialConnectionsAPIClientTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinancialConnectionsAPIClientTests.swift; sourceTree = "<group>"; }; | ||
49AC518B2C52DE2C00B712CC /* FinancialConnectionsLinkLoginPane.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinancialConnectionsLinkLoginPane.swift; sourceTree = "<group>"; }; | ||
49C911332C597EAF00589E0D /* LinkLoginDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LinkLoginDataSource.swift; sourceTree = "<group>"; }; | ||
|
@@ -657,6 +659,7 @@ | |
4E2EAD7059FF8358E674774A /* FinancialConnectionsAPIClient.swift */, | ||
49F1B8392D2DAE7100136303 /* FinancialConnectionsAsyncAPIClient.swift */, | ||
49F1B83D2D2EC82300136303 /* FinancialConnectionsAsyncAPIClient+Legacy.swift */, | ||
499EEAFC2D3E948B00E1BE85 /* FinancialConnectionsAPIClientLogger.swift */, | ||
); | ||
path = "API Bindings"; | ||
sourceTree = "<group>"; | ||
|
@@ -1319,6 +1322,7 @@ | |
CBF7BE2271D309F2B1E794CC /* FinancialConnectionsDataAccessNotice.swift in Sources */, | ||
F67624595BD2CD7B6793BFDA /* FinancialConnectionsImage.swift in Sources */, | ||
07712610C7D2F484AAB96982 /* FinancialConnectionsInstitution.swift in Sources */, | ||
499EEAFD2D3E948B00E1BE85 /* FinancialConnectionsAPIClientLogger.swift in Sources */, | ||
7386E1F9256B23CE29BF996D /* FinancialConnectionsInstitutionSearchResultResource.swift in Sources */, | ||
C7D2763ACCE2CC71E788E18F /* FinancialConnectionsLegalDetailsNotice.swift in Sources */, | ||
B271AAF41C9FE6AE392B88D3 /* FinancialConnectionsMixedOAuthParams.swift in Sources */, | ||
|
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
78 changes: 78 additions & 0 deletions
78
.../StripeFinancialConnections/Source/API Bindings/FinancialConnectionsAPIClientLogger.swift
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,78 @@ | ||
// | ||
// FinancialConnectionsAPIClientLogger.swift | ||
// StripeFinancialConnections | ||
// | ||
// Created by Mat Schmid on 2025-01-20. | ||
// | ||
|
||
import Foundation | ||
@_spi(STP) import StripeCore | ||
|
||
struct FinancialConnectionsAPIClientLogger { | ||
private var analyticsClient = FinancialConnectionsAnalyticsClient() | ||
|
||
enum API: String { | ||
case consumerSessionLookup = "consumer_session_lookup" | ||
case linkSignUp = "link_sign_up" | ||
} | ||
|
||
enum Event { | ||
/// When checking if generating attestation is supported does not succeed. | ||
case attestationInitFailed | ||
/// When an attestation token gets generated successfully. | ||
case attestationRequestTokenSucceeded(API) | ||
/// When a token generation attempt fails client-side. | ||
case attestationRequestTokenFailed(API, Error) | ||
/// When an attestation verdict fails backend side and we get an attestation related error. | ||
case attestationVerdictFailed(API) | ||
|
||
var name: String { | ||
switch self { | ||
case .attestationInitFailed: | ||
return "attestation.init_failed" | ||
case .attestationRequestTokenSucceeded: | ||
return "attestation.request_token_succeeded" | ||
case .attestationRequestTokenFailed: | ||
return "attestation.request_token_failed" | ||
case .attestationVerdictFailed: | ||
return "attestation.verdict_failed" | ||
} | ||
} | ||
|
||
var parameters: [String: Any] { | ||
switch self { | ||
case .attestationInitFailed: | ||
var reason: String | ||
if #available(iOS 14.0, *) { | ||
// If the iOS version is supported, we assume the device is unsupported (i.e. simulator). | ||
reason = "ios_device_unsupported" | ||
} else { | ||
// Otherwise, attestation is unavailable due to the OS version being unsupported. | ||
reason = "ios_os_version_unsupported" | ||
} | ||
return ["reason": reason] | ||
case .attestationRequestTokenFailed(let api, let error): | ||
var errorReason: String | ||
if let attestationError = error as? StripeAttest.AttestationError { | ||
errorReason = attestationError.rawValue | ||
} else { | ||
errorReason = "unknown" | ||
} | ||
return [ | ||
"api": api.rawValue, | ||
"error_reason": errorReason, | ||
] | ||
case .attestationRequestTokenSucceeded(let api), .attestationVerdictFailed(let api): | ||
return ["api": api.rawValue] | ||
} | ||
} | ||
} | ||
|
||
func log(_ event: Event, pane: FinancialConnectionsSessionManifest.NextPane) { | ||
analyticsClient.log( | ||
eventName: event.name, | ||
parameters: event.parameters, | ||
pane: pane | ||
) | ||
} | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carlosmuvi-stripe let me know which other parameters we should include for each event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be good with these + the default parameters sent on all requests