-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore
New analytics initial call (#1497)
New analytics replacing the existing checkout attempt Id fetch and initial telemetry with a single call. The new analytics is on a new webapp so it requires a new `baseURL` which needs a new environment, thus `AnalayticsEnvironment` is added. - A new api context with this environment (`analyticsApiContext`) is created internally during the original context's creation. This new call combines sending the analytics data and returns the checkout attempt id in the response. So this call needs to be done only once per payment flow. So the call is made on component load unless the component is inside dropIn in which case dropIn will have made the call already.
- Loading branch information
Showing
70 changed files
with
765 additions
and
665 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,22 @@ | ||
// | ||
// Copyright (c) 2023 Adyen N.V. | ||
// | ||
// This file is open source and available under the MIT license. See the LICENSE file for more info. | ||
// | ||
|
||
import Foundation | ||
|
||
@_spi(AdyenInternal) | ||
public enum AnalyticsFlavor { | ||
case components(type: PaymentMethodType) | ||
case dropIn(type: String = "dropin", paymentMethods: [String]) | ||
|
||
public var value: String { | ||
switch self { | ||
case .components: | ||
return "components" | ||
case .dropIn: | ||
return "dropin" | ||
} | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,33 @@ | ||
// | ||
// Copyright (c) 2023 Adyen N.V. | ||
// | ||
// This file is open source and available under the MIT license. See the LICENSE file for more info. | ||
// | ||
|
||
import Foundation | ||
|
||
@_spi(AdyenInternal) | ||
/// Used as a singleton to update the sessionId | ||
public final class AnalyticsForSession { | ||
|
||
/// Needed to be able to determine if using session | ||
public static var sessionId: String? | ||
|
||
private init() { /* Private empty init */ } | ||
} | ||
|
||
@_spi(AdyenInternal) | ||
/// A protocol that defines the events that can occur under Checkout Analytics. | ||
public protocol AnalyticsEvent: Encodable { | ||
var timestamp: TimeInterval { get } | ||
|
||
var component: String { get } | ||
} | ||
|
||
@_spi(AdyenInternal) | ||
public extension AnalyticsEvent { | ||
|
||
var timestamp: TimeInterval { | ||
Date().timeIntervalSince1970 | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// Copyright (c) 2023 Adyen N.V. | ||
// | ||
// This file is open source and available under the MIT license. See the LICENSE file for more info. | ||
// | ||
|
||
import Foundation | ||
|
||
@_spi(AdyenInternal) | ||
/// Represents an error in the analytics scheme that indicates the flow was interrupted due to an error in the SDK. | ||
public struct AnalyticsEventError: AnalyticsEvent { | ||
|
||
public var component: String | ||
|
||
public var type: ErrorType | ||
|
||
public var code: String? | ||
|
||
public var message: String? | ||
|
||
public enum ErrorType: String, Encodable { | ||
case network = "Network" | ||
case implementation = "Implementation" | ||
case `internal` = "Internal" | ||
case api = "ApiError" | ||
case sdk = "SdkError" | ||
case thirdParty = "ThirdParty" | ||
case generic = "Generic" | ||
} | ||
} |
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,34 @@ | ||
// | ||
// Copyright (c) 2023 Adyen N.V. | ||
// | ||
// This file is open source and available under the MIT license. See the LICENSE file for more info. | ||
// | ||
|
||
import Foundation | ||
|
||
@_spi(AdyenInternal) | ||
/// Represents an info event in the analytics scheme that can occur | ||
/// multiple times during the checkout flow, such as input field focus/unfocus etc. | ||
public struct AnalyticsEventInfo: AnalyticsEvent { | ||
public var component: String | ||
|
||
public var type: InfoType | ||
|
||
public var target: String? | ||
|
||
public var isStoredPaymentMethod: Bool? | ||
|
||
public var brand: String? | ||
|
||
public var validationErrorCode: String? | ||
|
||
public var validationErrorMessage: String? | ||
|
||
public enum InfoType: String, Encodable { | ||
case selected = "Selected" | ||
case focus = "Focus" | ||
case unfocus = "Unfocus" | ||
case validationError = "ValidationError" | ||
case rendered = "Rendered" | ||
} | ||
} |
Oops, something went wrong.