Closed scannillo closed 4 months ago
Known issue with Unit Tests not completing addressed in https://github.com/braintree/braintree_ios/pull/1324
I just discovered from manual testing that this PR was not properly sending our core-latency analytic events (the line http?.networkTimingDelegate = self
was missing from BTAPIClient). However, our tests did not catch this error and were passing.
We should have testing in place to enforce the new latency analytics functionality, either unit or integration test. (I fixed it for this PR in 2b2bfcee7d9f65fe4dda44b9b631f0f03be42d99)
Summary
This PR is take 2 of https://github.com/braintree/braintree_ios/pull/1294 (see that PR for full description of issue). The goal is to re-use a single TCP connection b/w the 1st
v1/configuration
call and subsequent GW API calls. This could shave ~50-100ms of our E2E latency.https://github.com/braintree/braintree_ios/pull/1294 revealed several tangles in our SDK's networking logic. BTAPIClient was managing 2 instances of BTHTTP, 1 for fetching the config and another for everything else. On top of that, BTHTTP had ternary logic that was hard to reason about and was specific to the
v1/configuration
call.This PR has a lot (sorry), but cleaning this up at the Authorization & BTHTTP init level felt like the cleanest way.
Changes
ClientAuthorization
TokenizationKey
typeClientAuthorization
protocol to unify both auth typesBTHTTP
ClientAuthorization
provided, or a passedBTConfiguration
, to extract the URL to usecustomBaseURL
override (we need this for analytics for now. But, when we address Item 2 below, the AnalyticsService can interact with a raw HTTP layer vs a BT-specific HTTP layer)BTConfiguration
, to extract the clientAPIURL & graphQLAPIURLsNext
These changes reveal a lot of room for architecture improvements. Let's add the following tasks to our JIRA:
.post()
methods to require non-optionalBTConfiguration
parametersBTAPIClient.fetchConfig()
versus optional value in completionTesting
Checklist
Authors
@scannillo