Dynamically fetch OAuth URLs when needed #3841
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relates to #3692
Changes proposed in this Pull Request:
This introduces a minor improvement to the Stripe Settings page load by avoiding Stripe OAuth API calls when not required.
Stripe API calls are costly and making those calls on page load introduces ~2s page load time when testing locally. Currently there are 2 cases where we make API calls to Stripe.
This PR only addresses the 1st case.
There are three states where OAuth URL is needed.
With this PR, we only make the external Stripe API calls to get OAuth URLs if the store is in 1st or 2nd states.
For 3rd state, we delay the URL fetch until the modal is opened.
In my local tests, this saves ~400ms when loading the settings page.
For comparison, following is how the cachegrind call tree looks like for
curl_exec
before and after for a connected merchant.Before
![Image](https://private-user-images.githubusercontent.com/6216000/405755412-9097f67b-7d11-4ece-a3d0-c1011b2c43a3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMzcxODQsIm5iZiI6MTczOTMzNjg4NCwicGF0aCI6Ii82MjE2MDAwLzQwNTc1NTQxMi05MDk3ZjY3Yi03ZDExLTRlY2UtYTNkMC1jMTAxMWIyYzQzYTMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMDUwODA0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MGRjNmFiZjUyYzBkOTAzZTQ4MThkZmE2ZGNiNGViNmUyZWM4ZmM1MDNkZmFiODZlMzViYWNjNDY2NjA5NDg4NCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.XzXu_lGJouw28gUf71UHe2d_okgAhcqc0RWmjBI9NqU)
After
![cachegrind2](https://private-user-images.githubusercontent.com/6216000/410154587-ae6f1656-7ee0-4922-bde9-8f0f91a31291.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMzcxODQsIm5iZiI6MTczOTMzNjg4NCwicGF0aCI6Ii82MjE2MDAwLzQxMDE1NDU4Ny1hZTZmMTY1Ni03ZWUwLTQ5MjItYmRlOS04ZjBmOTFhMzEyOTEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMDUwODA0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZjdkZmYwOTBmNDMwM2Q0ZmZjZDFkMjE3YTA0MjY5YzQ1MWEwNWI4MzZhYjA1ZDVmM2E0Y2RhNzFmNzQ5NzQzMCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.pyKw4CzluuVI2VZEu-NxrAW_CVCl2EmT8psFXqTamgg)
Testing instructions
We mainly want to do regression tests around the three scenarios where the OAuth URL is used.
changelog.txt
andreadme.txt
(or does not apply)Post merge