-
Notifications
You must be signed in to change notification settings - Fork 995
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add attestation event logging to FC API clients
- Loading branch information
1 parent
ac88f3b
commit d8d06bc
Showing
12 changed files
with
184 additions
and
49 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
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
65 changes: 65 additions & 0 deletions
65
.../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,65 @@ | ||
// | ||
// FinancialConnectionsAPIClientLogger.swift | ||
// StripeFinancialConnections | ||
// | ||
// Created by Mat Schmid on 2025-01-20. | ||
// | ||
|
||
import Foundation | ||
|
||
struct FinancialConnectionsAPIClientLogger { | ||
private var analyticsClient = FinancialConnectionsAnalyticsClient() | ||
|
||
enum Event { | ||
/// When checking if generating attestation is supported succeeds. | ||
case attestationInitSucceeded | ||
/// When checking if generating attestation is supported does not succeed. | ||
case attestationInitFailed | ||
/// When an attestation token gets generated successfully. | ||
case attestationRequestTokenSucceeded | ||
/// When a token generation attempt fails client-side. | ||
case attestationRequestTokenFailed | ||
/// When an attestation verdict fails backend side and we get an attestation related error. | ||
case attestationVerdictFailed | ||
|
||
var name: String { | ||
switch self { | ||
case .attestationInitSucceeded: | ||
return "attestation.init_succeeded" | ||
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] | ||
default: | ||
return [:] | ||
} | ||
} | ||
} | ||
|
||
func log(_ event: Event, pane: FinancialConnectionsSessionManifest.NextPane) { | ||
analyticsClient.log( | ||
eventName: event.name, | ||
parameters: event.parameters, | ||
pane: pane | ||
) | ||
} | ||
} |
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
Oops, something went wrong.