Logging: avoid logging "updating offerings" when request is cached#2896
Merged
NachoSoto merged 1 commit intoJul 26, 2023
Conversation
I noticed this in our logs: ``` [offering] DEBUG: ℹ️ No cached Offerings, fetching from network [purchases] VERBOSE: Updating all caches [offering] DEBUG: ℹ️ Offerings cache is stale, updating from network in foreground [offering] DEBUG: ℹ️ Offerings cache is stale, updating from network in foreground [network] DEBUG: ℹ️ Network operation 'GetOfferingsOperation' found with the same cache key 'GetOfferingsOpe...'. Skipping request. [network] DEBUG: ℹ️ GetOfferingsOperation: Started ``` The double "updating from network" can be confusing, so this fixes it so it's only logged if the request will actually be started. Also added/updated our tests to verify the correct logs as well as caching behavior.
NachoSoto
commented
Jul 26, 2023
| self.backendConfig.addCacheableOperation( | ||
| with: factory, | ||
| withRandomDelay: randomDelay, | ||
| withRandomDelay: isAppBackgrounded, |
Contributor
Author
There was a problem hiding this comment.
This decision makes more sense in this "API" type than in OfferingsManager.
NachoSoto
commented
Jul 26, 2023
| ) | ||
| } | ||
|
|
||
| func testOfferingsAreOnlyFetchedOnceOnSDKInitialization() async throws { |
NachoSoto
commented
Jul 26, 2023
| func testOfferingsAreOnlyFetchedOnceOnSDKInitialization() async throws { | ||
| self.logger.verifyMessageWasLogged(Strings.offering.offerings_stale_updating_in_foreground, | ||
| level: .debug, | ||
| expectedCount: 1) |
Contributor
Author
There was a problem hiding this comment.
This was the failing test that this fixes.
NachoSoto
commented
Jul 26, 2023
| expectedCount: 1) | ||
| self.logger.verifyMessageWasLogged("GetOfferingsOperation: Started", | ||
| level: .debug, | ||
| expectedCount: 1) |
Contributor
Author
There was a problem hiding this comment.
But this also doesn't hurt to verify.
Codecov Report
@@ Coverage Diff @@
## nacho/sdk-3243-422s-fix-bug-where-transactions-are-misidentified-as #2896 +/- ##
=======================================================================================================
+ Coverage 86.58% 86.60% +0.02%
=======================================================================================================
Files 217 217
Lines 15531 15533 +2
=======================================================================================================
+ Hits 13447 13453 +6
+ Misses 2084 2080 -4
|
aboedo
approved these changes
Jul 26, 2023
Contributor
Author
|
Ugh damn it I merged this in the wrong branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I noticed this in our logs:
The double "updating from network" can be confusing, so this fixes it so it's only logged if the request will actually be started. Also added/updated our tests to verify the correct logs as well as caching behavior.