diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ce08a0564..5de4798c06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * BraintreeCore * Prevent duplicate outbound `v1/configuration` requests * Add network timeout of 30 seconds + * Update `endpoint` syntax sent to FPTI for 3D Secure and Venmo flows ## 6.23.0 (2024-07-15) * BraintreeShopperInsights (BETA) diff --git a/Sources/BraintreeCore/BTAPIClient.swift b/Sources/BraintreeCore/BTAPIClient.swift index cb646b2449..6c9da34960 100644 --- a/Sources/BraintreeCore/BTAPIClient.swift +++ b/Sources/BraintreeCore/BTAPIClient.swift @@ -401,7 +401,12 @@ import Foundation // MARK: BTAPITimingDelegate conformance func fetchAPITiming(path: String, connectionStartTime: Int?, requestStartTime: Int?, startTime: Int, endTime: Int) { - let cleanedPath = path.replacingOccurrences(of: "/merchants/([A-Za-z0-9]+)/client_api", with: "", options: .regularExpression) + var cleanedPath = path.replacingOccurrences(of: "/merchants/([A-Za-z0-9]+)/client_api", with: "", options: .regularExpression) + cleanedPath = cleanedPath.replacingOccurrences( + of: "payment_methods/.*/three_d_secure", + with: "payment_methods/three_d_secure", + options: .regularExpression + ) if cleanedPath != "/v1/tracking/batch/events" { analyticsService?.sendAnalyticsEvent( diff --git a/Sources/BraintreeCore/BTHTTP.swift b/Sources/BraintreeCore/BTHTTP.swift index 7815e4e310..ef72f275e9 100644 --- a/Sources/BraintreeCore/BTHTTP.swift +++ b/Sources/BraintreeCore/BTHTTP.swift @@ -446,8 +446,12 @@ class BTHTTP: NSObject, URLSessionTaskDelegate { let json = try? JSONSerialization.jsonObject(with: data) let body = BTJSON(value: json) - guard let mutationName = body["operationName"].asString() else { return nil } - - return "mutation \(mutationName)" + guard let query = body["query"].asString() else { + return nil + } + + let queryDiscardHolder = query.replacingOccurrences(of: #"^[^\(]*"#, with: "", options: .regularExpression) + let finalQuery = query.replacingOccurrences(of: queryDiscardHolder, with: "") + return finalQuery } } diff --git a/UnitTests/BraintreeCoreTests/BTHTTP_Tests.swift b/UnitTests/BraintreeCoreTests/BTHTTP_Tests.swift index 4a63babe51..3da79f517b 100644 --- a/UnitTests/BraintreeCoreTests/BTHTTP_Tests.swift +++ b/UnitTests/BraintreeCoreTests/BTHTTP_Tests.swift @@ -757,7 +757,8 @@ final class BTHTTP_Tests: XCTestCase { var originalRequest = URLRequest(url: URL(string: "https://example.com/graphql")!) originalRequest.httpBody = """ { - "operationName": "TestMutation" + "operationName": "TestMutation", + "query": "mutation TestMutation()" } """.data(using: .utf8) let task = testURLSession.dataTask(with: originalRequest)