diff --git a/Risk.podspec b/Risk.podspec index b668e6e..40f9f0e 100644 --- a/Risk.podspec +++ b/Risk.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Risk" - s.version = "3.0.1" + s.version = "3.0.2" s.summary = "Checkout Risk package in Swift" s.description = <<-DESC Checkout Risk package in Swift. diff --git a/Sources/Risk/Logging/Constants.swift b/Sources/Risk/Logging/Constants.swift index 384670f..2d1b78c 100644 --- a/Sources/Risk/Logging/Constants.swift +++ b/Sources/Risk/Logging/Constants.swift @@ -9,7 +9,7 @@ import Foundation enum Constants { static let productName = "risk-ios-sdk" - static let riskSdkVersion = "3.0.1" + static let riskSdkVersion = "3.0.2" static let userAgent = "checkout-sdk-risk-ios/\(riskSdkVersion)" static let loggerTypeIdentifier = "com.checkout.risk-mobile-sdk" } diff --git a/iOSExampleRiskCocoapods/Podfile b/iOSExampleRiskCocoapods/Podfile index 37fa487..7f86197 100644 --- a/iOSExampleRiskCocoapods/Podfile +++ b/iOSExampleRiskCocoapods/Podfile @@ -6,7 +6,7 @@ target 'iOSExampleRiskCocoapods' do use_frameworks! # Pods for iOS Example Custom - pod 'Risk', '2.0.1' + pod 'Risk', '3.0.1' end diff --git a/iOSExampleRiskCocoapods/Podfile.lock b/iOSExampleRiskCocoapods/Podfile.lock index d44451b..dcea4de 100644 --- a/iOSExampleRiskCocoapods/Podfile.lock +++ b/iOSExampleRiskCocoapods/Podfile.lock @@ -1,12 +1,12 @@ PODS: - CheckoutEventLoggerKit (1.2.4) - FingerprintPro (2.2.0) - - Risk (2.0.1): + - Risk (3.0.1): - CheckoutEventLoggerKit (~> 1.2.4) - FingerprintPro (= 2.2.0) DEPENDENCIES: - - Risk (= 2.0.1) + - Risk (= 3.0.1) SPEC REPOS: trunk: @@ -17,8 +17,8 @@ SPEC REPOS: SPEC CHECKSUMS: CheckoutEventLoggerKit: b780dec46295a34942780ea6230d0d5fd08aa05a FingerprintPro: 72e35dc0315b75ba36eafaaed996dbb2f35f7326 - Risk: 5afc8c739782cae0c26b3d605975339ea6bd0c62 + Risk: d7e3e210b7e6d3a8a711fde8b9d439f66d91d889 -PODFILE CHECKSUM: c10bf95d52beebaf38c52a3ee16182e3dbcc4434 +PODFILE CHECKSUM: d80b05ce77ca9c8da581b865b80efc83a8885d28 -COCOAPODS: 1.14.3 +COCOAPODS: 1.15.2 diff --git a/iOSExampleRiskCocoapods/Pods/Manifest.lock b/iOSExampleRiskCocoapods/Pods/Manifest.lock index d44451b..dcea4de 100644 --- a/iOSExampleRiskCocoapods/Pods/Manifest.lock +++ b/iOSExampleRiskCocoapods/Pods/Manifest.lock @@ -1,12 +1,12 @@ PODS: - CheckoutEventLoggerKit (1.2.4) - FingerprintPro (2.2.0) - - Risk (2.0.1): + - Risk (3.0.1): - CheckoutEventLoggerKit (~> 1.2.4) - FingerprintPro (= 2.2.0) DEPENDENCIES: - - Risk (= 2.0.1) + - Risk (= 3.0.1) SPEC REPOS: trunk: @@ -17,8 +17,8 @@ SPEC REPOS: SPEC CHECKSUMS: CheckoutEventLoggerKit: b780dec46295a34942780ea6230d0d5fd08aa05a FingerprintPro: 72e35dc0315b75ba36eafaaed996dbb2f35f7326 - Risk: 5afc8c739782cae0c26b3d605975339ea6bd0c62 + Risk: d7e3e210b7e6d3a8a711fde8b9d439f66d91d889 -PODFILE CHECKSUM: c10bf95d52beebaf38c52a3ee16182e3dbcc4434 +PODFILE CHECKSUM: d80b05ce77ca9c8da581b865b80efc83a8885d28 -COCOAPODS: 1.14.3 +COCOAPODS: 1.15.2 diff --git a/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Logging/Constants.swift b/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Logging/Constants.swift index c3866a4..384670f 100644 --- a/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Logging/Constants.swift +++ b/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Logging/Constants.swift @@ -9,7 +9,7 @@ import Foundation enum Constants { static let productName = "risk-ios-sdk" - static let riskSdkVersion = "2.0.1" + static let riskSdkVersion = "3.0.1" static let userAgent = "checkout-sdk-risk-ios/\(riskSdkVersion)" static let loggerTypeIdentifier = "com.checkout.risk-mobile-sdk" } diff --git a/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Logging/LoggerService.swift b/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Logging/LoggerService.swift index 2f529f7..619e3a0 100644 --- a/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Logging/LoggerService.swift +++ b/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Logging/LoggerService.swift @@ -17,6 +17,18 @@ enum RiskEvent: String, Codable { case loadFailure = "riskLoadFailure" } +struct Elapsed { + let block: Double? // time to retrieve configuration or loadFailure + let deviceDataPersist: Double? // time to persist data + let fpload: Double? // time to load fingerprint + let fppublish: Double? // time to publish fingerprint data + let total: Double? // total time + + private enum CodingKeys: String, CodingKey { + case block = "Block", deviceDataPersist = "DeviceDataPersist", fpload = "FpLoad", fppublish = "FpPublish", total = "Total" + } +} + struct RiskLogError { let reason: String // service method let message: String // description of error @@ -30,14 +42,15 @@ struct RiskLogError { protocol LoggerServiceProtocol { init(internalConfig: RiskSDKInternalConfig) - func log(riskEvent: RiskEvent, deviceSessionId: String?, requestId: String?, error: RiskLogError?) + func log(riskEvent: RiskEvent, blockTime: Double?, deviceDataPersistTime: Double?, fpLoadTime: Double?, fpPublishTime: Double?, deviceSessionId: String?, requestId: String?, error: RiskLogError?) } extension LoggerServiceProtocol { - func formatEvent(internalConfig: RiskSDKInternalConfig, riskEvent: RiskEvent, deviceSessionId: String?, requestId: String?, error: RiskLogError?) -> Event { + func formatEvent(internalConfig: RiskSDKInternalConfig, riskEvent: RiskEvent, deviceSessionId: String?, requestId: String?, error: RiskLogError?, latencyMetric: Elapsed) -> Event { let maskedPublicKey = getMaskedPublicKey(publicKey: internalConfig.merchantPublicKey) let ddTags = getDDTags(environment: internalConfig.environment.rawValue) var monitoringLevel: MonitoringLevel + let framesMode = internalConfig.framesOptions != nil let properties: [String: AnyCodable] switch riskEvent { @@ -56,19 +69,29 @@ extension LoggerServiceProtocol { switch riskEvent { case .published, .collected: properties = [ + "Block": AnyCodable(latencyMetric.block), + "DeviceDataPersist": AnyCodable(latencyMetric.deviceDataPersist), + "FpLoad": AnyCodable(latencyMetric.fpload), + "FpPublish": AnyCodable(latencyMetric.fppublish), + "Total": AnyCodable(latencyMetric.total), "EventType": AnyCodable(riskEvent.rawValue), - "FramesMode": AnyCodable(internalConfig.framesMode), + "FramesMode": AnyCodable(framesMode), "MaskedPublicKey": AnyCodable(maskedPublicKey), "ddTags": AnyCodable(ddTags), "RiskSDKVersion": AnyCodable(Constants.riskSdkVersion), "Timezone": AnyCodable(TimeZone.current.identifier), - "RequestId": AnyCodable(requestId), + "FpRequestId": AnyCodable(requestId), "DeviceSessionId": AnyCodable(deviceSessionId), ] case .publishFailure, .loadFailure, .publishDisabled: properties = [ + "Block": AnyCodable(latencyMetric.block), + "DeviceDataPersist": AnyCodable(latencyMetric.deviceDataPersist), + "FpLoad": AnyCodable(latencyMetric.fpload), + "FpPublish": AnyCodable(latencyMetric.fppublish), + "Total": AnyCodable(latencyMetric.total), "EventType": AnyCodable(riskEvent.rawValue), - "FramesMode": AnyCodable(internalConfig.framesMode), + "FramesMode": AnyCodable(framesMode), "MaskedPublicKey": AnyCodable(maskedPublicKey), "ddTags": AnyCodable(ddTags), "RiskSDKVersion": AnyCodable(Constants.riskSdkVersion), @@ -80,7 +103,7 @@ extension LoggerServiceProtocol { } return Event( - typeIdentifier: Constants.loggerTypeIdentifier, + typeIdentifier: riskEvent.rawValue, time: Date(), monitoringLevel: monitoringLevel, properties: properties @@ -107,15 +130,9 @@ struct LoggerService: LoggerServiceProtocol { } private func setup() { - - let appBundle = Bundle.main - let appPackageName = appBundle.bundleIdentifier ?? "unavailableAppPackageName" - let appPackageVersion = appBundle - .infoDictionary?["CFBundleShortVersionString"] as? String ?? "unavailableAppPackageVersion" - - let deviceName = getDeviceModel() - let osVersion = UIDevice.current.systemVersion let logEnvironment: Environment + let productIdentifier = internalConfig.framesOptions?.productIdentifier ?? Constants.productName + let productVersion = internalConfig.framesOptions?.version ?? Constants.riskSdkVersion switch internalConfig.environment { case .qa, .sandbox: @@ -131,37 +148,20 @@ struct LoggerService: LoggerServiceProtocol { logger.enableRemoteProcessor( environment: logEnvironment, remoteProcessorMetadata: RemoteProcessorMetadata( - productIdentifier: Constants.productName, - productVersion: Constants.riskSdkVersion, - environment: internalConfig.environment.rawValue, - appPackageName: appPackageName, - appPackageVersion: appPackageVersion, - deviceName: deviceName, - platform: "iOS", - osVersion: osVersion + productIdentifier: productIdentifier, + productVersion: productVersion, + environment: internalConfig.environment.rawValue ) ) - } - func log(riskEvent: RiskEvent, deviceSessionId: String? = nil, requestId: String? = nil, error: RiskLogError? = nil) { - let event = formatEvent(internalConfig: internalConfig, riskEvent: riskEvent, deviceSessionId: deviceSessionId, requestId: requestId, error: error) + func log(riskEvent: RiskEvent, blockTime: Double? = nil, deviceDataPersistTime: Double? = nil, fpLoadTime: Double? = nil, fpPublishTime: Double? = nil, deviceSessionId: String? = nil, requestId: String? = nil, error: RiskLogError? = nil) { + + let totalLatency = (blockTime ?? 0.00) + (deviceDataPersistTime ?? 0.00) + (fpLoadTime ?? 0.00) + (fpPublishTime ?? 0.00) + + let latencyMetric = Elapsed(block: blockTime, deviceDataPersist: deviceDataPersistTime, fpload: fpLoadTime, fppublish: fpPublishTime, total: totalLatency) + + let event = formatEvent(internalConfig: internalConfig, riskEvent: riskEvent, deviceSessionId: deviceSessionId, requestId: requestId, error: error, latencyMetric: latencyMetric) logger.log(event: event) } - - private func getDeviceModel() -> String { - #if targetEnvironment(simulator) - if let identifier = ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] { - return identifier - } - #endif - - var systemInfo = utsname() - uname(&systemInfo) - let machineMirror = Mirror(reflecting: systemInfo.machine) - return machineMirror.children.reduce("") { identifier, element in - guard let value = element.value as? Int8, value != 0 else { return identifier } - return identifier + String(UnicodeScalar(UInt8(value))) - } - } } diff --git a/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Models/RiskSDKInternalConfig.swift b/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Models/RiskSDKInternalConfig.swift index 964f19b..953d3e5 100644 --- a/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Models/RiskSDKInternalConfig.swift +++ b/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Models/RiskSDKInternalConfig.swift @@ -13,13 +13,14 @@ struct RiskSDKInternalConfig { let fingerprintEndpoint: String let integrationType: RiskIntegrationType let sourceType: SourceType - let framesMode: Bool let environment: RiskEnvironment + let framesOptions: FramesOptions? init(config: RiskConfig) { + framesOptions = config.framesOptions + let framesMode = framesOptions != nil merchantPublicKey = config.publicKey environment = config.environment - framesMode = config.framesMode integrationType = framesMode ? .inFrames : .standalone sourceType = framesMode ? .cardToken : .riskSDK diff --git a/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Risk.swift b/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Risk.swift index 0c4900e..9753da0 100644 --- a/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Risk.swift +++ b/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Risk.swift @@ -30,7 +30,8 @@ public final class Risk { self.fingerprintService = FingerprintService( fingerprintPublicKey: configuration.publicKey, internalConfig: self.internalConfig, - loggerService: self.loggerService + loggerService: self.loggerService, + blockTime: configuration.blockTime ) completion(.success(())) @@ -50,8 +51,8 @@ public final class Risk { guard let self = self else { return } switch fpResult { - case .success(let requestId): - self.persistFpData(cardToken: cardToken, fingerprintRequestId: requestId, completion: completion) + case .success(let response): + self.persistFpData(cardToken: cardToken, fingerprintRequestId: response.requestId, fpLoadTime: response.fpLoadTime, fpPublishTime: response.fpPublishTime, completion: completion) case .failure(let error): completion(.failure(error)) @@ -59,8 +60,8 @@ public final class Risk { } } - private func persistFpData(cardToken: String?, fingerprintRequestId: String, completion: @escaping (Result) -> Void) { - self.deviceDataService.persistFpData(fingerprintRequestId: fingerprintRequestId, cardToken: cardToken) { result in + private func persistFpData(cardToken: String?, fingerprintRequestId: String, fpLoadTime: Double, fpPublishTime: Double, completion: @escaping (Result) -> Void) { + self.deviceDataService.persistFpData(fingerprintRequestId: fingerprintRequestId, fpLoadTime: fpLoadTime, fpPublishTime: fpPublishTime, cardToken: cardToken) { result in switch result { case .success(let response): completion(.success(PublishRiskData(deviceSessionId: response.deviceSessionId))) diff --git a/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/RiskSDKConfig.swift b/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/RiskSDKConfig.swift index fa48193..5a5795e 100644 --- a/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/RiskSDKConfig.swift +++ b/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/RiskSDKConfig.swift @@ -18,11 +18,21 @@ public enum RiskEnvironment: String { public struct RiskConfig { let publicKey: String let environment: RiskEnvironment - let framesMode: Bool + let framesOptions: FramesOptions? - public init(publicKey: String, environment: RiskEnvironment, framesMode: Bool = false) { + public init(publicKey: String, environment: RiskEnvironment, framesOptions: FramesOptions? = nil) { self.publicKey = publicKey self.environment = environment - self.framesMode = framesMode + self.framesOptions = framesOptions + } +} + +public struct FramesOptions { + let version: String + let productIdentifier: String + + public init(productIdentifier: String, version: String) { + self.productIdentifier = productIdentifier + self.version = version } } diff --git a/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Services/DeviceDataService.swift b/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Services/DeviceDataService.swift index d50b5b5..cf58c30 100644 --- a/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Services/DeviceDataService.swift +++ b/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Services/DeviceDataService.swift @@ -7,6 +7,7 @@ // import Foundation +import QuartzCore struct FingerprintIntegration: Decodable, Equatable { let enabled: Bool @@ -15,6 +16,7 @@ struct FingerprintIntegration: Decodable, Equatable { struct FingerprintConfiguration: Equatable { let publicKey: String + let blockTime: Double } struct DeviceDataConfiguration: Decodable, Equatable { @@ -42,46 +44,50 @@ struct PersistDeviceDataResponse: Decodable, Equatable { protocol DeviceDataServiceProtocol { func getConfiguration(completion: @escaping (Result) -> Void) - func persistFpData(fingerprintRequestId: String, cardToken: String?, completion: @escaping (Result) -> Void) + func persistFpData(fingerprintRequestId: String, fpLoadTime: Double, fpPublishTime: Double, cardToken: String?, completion: @escaping (Result) -> Void) } -struct DeviceDataService: DeviceDataServiceProtocol { +final class DeviceDataService: DeviceDataServiceProtocol { let config: RiskSDKInternalConfig let apiService: APIServiceProtocol let loggerService: LoggerServiceProtocol + var blockTime: Double init(config: RiskSDKInternalConfig, apiService: APIServiceProtocol = APIService(), loggerService: LoggerServiceProtocol) { self.config = config self.apiService = apiService self.loggerService = loggerService + self.blockTime = 0.00 } func getConfiguration(completion: @escaping (Result) -> Void) { - let endpoint = "\(config.deviceDataEndpoint)/configuration?integrationType=\(config.integrationType.rawValue)&riskSdkVersion=\(Constants.riskSdkVersion)" + let startBlockTime = CACurrentMediaTime() + let endpoint = "\(config.deviceDataEndpoint)/configuration?integrationType=\(config.integrationType.rawValue)&riskSdkVersion=\(Constants.riskSdkVersion)&timezone=\(TimeZone.current.identifier)" let authToken = config.merchantPublicKey apiService.getJSONFromAPIWithAuthorization(endpoint: endpoint, authToken: authToken, responseType: DeviceDataConfiguration.self) { result in switch result { case .success(let configuration): - + let endBlockTime = CACurrentMediaTime() + self.blockTime = (endBlockTime - startBlockTime) * 1000 guard configuration.fingerprintIntegration.enabled, let fingerprintPublicKey = configuration.fingerprintIntegration.publicKey else { - loggerService.log(riskEvent: .publishDisabled, deviceSessionId: nil, requestId: nil, error: RiskLogError(reason: "getConfiguration", message: RiskError.Configuration.integrationDisabled.localizedDescription, status: nil, type: "Error")) + self.loggerService.log(riskEvent: .publishDisabled, blockTime: self.blockTime, deviceDataPersistTime: nil, fpLoadTime: nil, fpPublishTime: nil, deviceSessionId: nil, requestId: nil, error: RiskLogError(reason: "getConfiguration", message: RiskError.Configuration.integrationDisabled.localizedDescription, status: nil, type: "Error")) return completion(.failure(.integrationDisabled)) } completion(.success( - FingerprintConfiguration.init(publicKey: fingerprintPublicKey))) + FingerprintConfiguration.init(publicKey: fingerprintPublicKey, blockTime: self.blockTime))) case .failure(let error): - - loggerService.log(riskEvent: .loadFailure, deviceSessionId: nil, requestId: nil, error: RiskLogError(reason: "getConfiguration", message: error.localizedDescription, status: nil, type: "Error")) + self.loggerService.log(riskEvent: .loadFailure, blockTime: nil, deviceDataPersistTime: nil, fpLoadTime: nil, fpPublishTime: nil, deviceSessionId: nil, requestId: nil, error: RiskLogError(reason: "getConfiguration", message: error.localizedDescription, status: nil, type: "Error")) return completion(.failure(.couldNotRetrieveConfiguration)) } } } - func persistFpData(fingerprintRequestId: String, cardToken: String?, completion: @escaping (Result) -> Void) { + func persistFpData(fingerprintRequestId: String, fpLoadTime: Double, fpPublishTime: Double, cardToken: String?, completion: @escaping (Result) -> Void) { + let startPersistTime = CACurrentMediaTime() let endpoint = "\(config.deviceDataEndpoint)/fingerprint?riskSdkVersion=\(Constants.riskSdkVersion)" let authToken = config.merchantPublicKey let integrationType = config.integrationType @@ -96,11 +102,13 @@ struct DeviceDataService: DeviceDataServiceProtocol { switch result { case .success(let response): - loggerService.log(riskEvent: .published, deviceSessionId: response.deviceSessionId, requestId: fingerprintRequestId, error: nil) + let endPersistTime = CACurrentMediaTime() + let persistTime = (endPersistTime - startPersistTime) * 1000 + self.loggerService.log(riskEvent: .published, blockTime: self.blockTime, deviceDataPersistTime: persistTime, fpLoadTime: fpLoadTime, fpPublishTime: fpPublishTime, deviceSessionId: response.deviceSessionId, requestId: fingerprintRequestId, error: nil) completion(.success(response)) case .failure(let error): - loggerService.log(riskEvent: .publishFailure, deviceSessionId: nil, requestId: nil, error: RiskLogError(reason: "persistFpData", message: error.localizedDescription, status: nil, type: "Error")) + self.loggerService.log(riskEvent: .publishFailure, blockTime: self.blockTime, deviceDataPersistTime: nil, fpLoadTime: fpLoadTime, fpPublishTime: fpPublishTime, deviceSessionId: nil, requestId: nil, error: RiskLogError(reason: "persistFpData", message: error.localizedDescription, status: nil, type: "Error")) completion(.failure(.couldNotPersisRiskData)) } diff --git a/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Services/FingerprintService.swift b/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Services/FingerprintService.swift index ea489be..a276b0a 100644 --- a/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Services/FingerprintService.swift +++ b/iOSExampleRiskCocoapods/Pods/Risk/Sources/Risk/Services/FingerprintService.swift @@ -7,9 +7,10 @@ import FingerprintPro import Foundation +import QuartzCore protocol FingerprintServiceProtocol { - func publishData(completion: @escaping (Result) -> Void) + func publishData(completion: @escaping (Result) -> Void) } extension FingerprintServiceProtocol { @@ -22,24 +23,41 @@ extension FingerprintServiceProtocol { } } +struct FpPublishData { + let requestId: String + let fpLoadTime: Double + let fpPublishTime: Double +} + final class FingerprintService: FingerprintServiceProtocol { private var requestId: String? private let client: FingerprintClientProviding private let internalConfig: RiskSDKInternalConfig private let loggerService: LoggerServiceProtocol + private let fpLoadTime: Double + private var fpPublishTime: Double + private let blockTime: Double - init(fingerprintPublicKey: String, internalConfig: RiskSDKInternalConfig, loggerService: LoggerServiceProtocol) { + init(fingerprintPublicKey: String, internalConfig: RiskSDKInternalConfig, loggerService: LoggerServiceProtocol, blockTime: Double) { + + let startBlockTime = CACurrentMediaTime() + let customDomain: Region = .custom(domain: internalConfig.fingerprintEndpoint) let configuration = Configuration(apiKey: fingerprintPublicKey, region: customDomain) client = FingerprintProFactory.getInstance(configuration) + let endBlockTime = CACurrentMediaTime() + self.fpLoadTime = (endBlockTime - startBlockTime) * 1000 + self.fpPublishTime = 0.00 + self.blockTime = blockTime self.internalConfig = internalConfig self.loggerService = loggerService } - func publishData(completion: @escaping (Result) -> Void) { + func publishData(completion: @escaping (Result) -> Void) { + let startFpPublishTime = CACurrentMediaTime() guard requestId == nil else { - return completion(.success(requestId!)) + return completion(.success(FpPublishData(requestId: requestId!, fpLoadTime: self.fpLoadTime, fpPublishTime: self.fpPublishTime))) } let metadata = createMetadata(sourceType: internalConfig.sourceType.rawValue) @@ -48,14 +66,16 @@ final class FingerprintService: FingerprintServiceProtocol { switch result { case .failure(let error): - self?.loggerService.log(riskEvent: .publishFailure, deviceSessionId: nil, requestId: nil, error: RiskLogError(reason: "publishData", message: error.localizedDescription, status: nil, type: "Error")) + self?.loggerService.log(riskEvent: .publishFailure, blockTime: self?.blockTime, deviceDataPersistTime: nil, fpLoadTime: self?.fpLoadTime, fpPublishTime: nil, deviceSessionId: nil, requestId: nil, error: RiskLogError(reason: "publishData", message: error.localizedDescription, status: nil, type: "Error")) return completion(.failure(.couldNotPublishRiskData)) case let .success(response): - self?.loggerService.log(riskEvent: .collected, deviceSessionId: nil, requestId: response.requestId, error: nil) + let endFpPublishTime = CACurrentMediaTime() + self?.fpPublishTime = (endFpPublishTime - startFpPublishTime) * 1000 + self?.loggerService.log(riskEvent: .collected, blockTime: self?.blockTime, deviceDataPersistTime: nil, fpLoadTime: self?.fpLoadTime, fpPublishTime: self?.fpPublishTime, deviceSessionId: nil, requestId: response.requestId, error: nil) self?.requestId = response.requestId - completion(.success(response.requestId)) + completion(.success(FpPublishData(requestId: response.requestId, fpLoadTime: self?.fpLoadTime ?? 0.00, fpPublishTime: self?.fpPublishTime ?? 0.00))) } } } diff --git a/iOSExampleRiskCocoapods/Pods/Target Support Files/Risk/Risk-Info.plist b/iOSExampleRiskCocoapods/Pods/Target Support Files/Risk/Risk-Info.plist index c32d058..a541232 100644 --- a/iOSExampleRiskCocoapods/Pods/Target Support Files/Risk/Risk-Info.plist +++ b/iOSExampleRiskCocoapods/Pods/Target Support Files/Risk/Risk-Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.0.1 + 3.0.1 CFBundleSignature ???? CFBundleVersion