Skip to content

PurchasesOrchestrator: changed ReceiptRefreshPolicy.always to .onlyIfEmpty after a purchase#2245

Merged
NachoSoto merged 1 commit into
mainfrom
receipt-refresh-only-if-empty
Jan 25, 2023
Merged

PurchasesOrchestrator: changed ReceiptRefreshPolicy.always to .onlyIfEmpty after a purchase#2245
NachoSoto merged 1 commit into
mainfrom
receipt-refresh-only-if-empty

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

We've had reports of receipt fetching throttling errors (#2116). #2146 improved this by throttling receipt refreshing.
However, we can avoid this altogether by not refreshing the receipt unless it's empty.

The main reason being that the backend will automatically refresh the receipt using /verifyReceipt, so it doesn't matter if the receipt we post is slightly out of date.

…nlyIfEmpty` after a purchase

We've had reports of receipt fetching throttling errors (#2116). #2146 improved this by throttling receipt refreshing.
However, we can avoid this altogether by not refreshing the receipt unless it's empty.

The main reason being that the backend will automatically refresh the receipt using `/verifyReceipt`, so it doesn't matter if the receipt we post is slightly out of date.
@NachoSoto NachoSoto requested a review from a team January 25, 2023 16:53
@codecov

codecov Bot commented Jan 25, 2023

Copy link
Copy Markdown

Codecov Report

Merging #2245 (a079308) into main (fdd7874) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #2245   +/-   ##
=======================================
  Coverage   85.85%   85.85%           
=======================================
  Files         183      183           
  Lines       12105    12105           
=======================================
  Hits        10393    10393           
  Misses       1712     1712           
Impacted Files Coverage Δ
...s/Purchasing/Purchases/PurchasesOrchestrator.swift 85.92% <100.00%> (ø)
Sources/Logging/Strings/StoreKitStrings.swift 89.70% <0.00%> (-1.48%) ⬇️
...urces/FoundationExtensions/Result+Extensions.swift 100.00% <0.00%> (+2.12%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@NachoSoto NachoSoto merged commit 1cd96e3 into main Jan 25, 2023
@NachoSoto NachoSoto deleted the receipt-refresh-only-if-empty branch January 25, 2023 18:40
tonidero pushed a commit that referenced this pull request Feb 1, 2023
**This is an automatic release.**

### Bugfixes
* `CustomerInfoManager`: improved thread-safety (#2224) via NachoSoto
(@NachoSoto)
### Other Changes
* `StoreKitIntegrationTests`: replaced `XCTSkipIf` with
`XCTExpectFailure` (#2244) via NachoSoto (@NachoSoto)
* `PurchasesOrchestrator`: changed `ReceiptRefreshPolicy.always` to
`.onlyIfEmpty` after a purchase (#2245) via NachoSoto (@NachoSoto)
NachoSoto added a commit that referenced this pull request Feb 15, 2023
Fixes #2260 and [SDKONCALL-216].
Follow up to #2245.

The change in #2245 was meant to avoid receipt refresh throttling errors (#2116).
However, that was a regression when using StoreKit config files because those don't get refreshed in the backend.

Unfortunately the workaround introduced in #1945 prevented us from noticing this, because we use `DangerousSettings.InternalSettings.enableReceiptFetchRetry` in our own integration tests.
I added an integration test that explicitly covers this scenario. That fails without this change if disabling that dangerous setting. I thought about making that test run without the setting, but that might lead to flaky failures in CI, which is why we introduced that workaround in the first place. But at least now we have an explicit integration test for this, as well as 2 unit tests.
NachoSoto added a commit that referenced this pull request Feb 15, 2023
…2280)

Fixes #2260 and [SDKONCALL-216].
Follow up to #2245.

The change in #2245 was meant to avoid receipt refresh throttling errors
(#2116).
However, that was a regression when using StoreKit config files because
those don't get refreshed in the backend.

Unfortunately the workaround introduced in #1945 prevented us from
noticing this, because we use
`DangerousSettings.InternalSettings.enableReceiptFetchRetry` in our own
integration tests.
I added an integration test that explicitly covers this scenario. That
fails without this change if disabling that dangerous setting. I thought
about making that test run without the setting, but that might lead to
flaky failures in CI, which is why we introduced that workaround in the
first place. But at least now we have an explicit integration test for
this, as well as 2 unit tests.


[SDKONCALL-216]:
https://revenuecats.atlassian.net/browse/SDKONCALL-216?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants