Skip to content

Refactor CustomerInfo listener and cache logic into CustomerInfoUpdater#1052

Merged
tonidero merged 7 commits into
mainfrom
toniricodiez/sdk-3155-android-if-sdk-detects-unsynced-purchases-when-calling-1
Jun 20, 2023
Merged

Refactor CustomerInfo listener and cache logic into CustomerInfoUpdater#1052
tonidero merged 7 commits into
mainfrom
toniricodiez/sdk-3155-android-if-sdk-detects-unsynced-purchases-when-calling-1

Conversation

@tonidero

@tonidero tonidero commented Jun 6, 2023

Copy link
Copy Markdown
Contributor

Description

First part of SDK-3155

This PR refactors the customer info listener and caching logic out of CustomerInfoHelper and into CustomerInfoUpdater. This is in preparation of a future refactor to be able to refresh customer info by posting unsynced receipts.

There are no behavior changes in this PR.

The relevant dependencies look like this:
Untitled drawing (2)

@codecov

codecov Bot commented Jun 6, 2023

Copy link
Copy Markdown

Codecov Report

Merging #1052 (e9d41c1) into main (8ae7c65) will decrease coverage by 0.01%.
The diff coverage is 92.59%.

@@            Coverage Diff             @@
##             main    #1052      +/-   ##
==========================================
- Coverage   85.76%   85.75%   -0.01%     
==========================================
  Files         176      177       +1     
  Lines        6265     6284      +19     
  Branches      864      866       +2     
==========================================
+ Hits         5373     5389      +16     
- Misses        557      559       +2     
- Partials      335      336       +1     
Impacted Files Coverage Δ
.../revenuecat/purchases/CustomerInfoUpdateHandler.kt 87.87% <87.87%> (ø)
...lin/com/revenuecat/purchases/CustomerInfoHelper.kt 89.61% <100.00%> (-1.39%) ⬇️
...tlin/com/revenuecat/purchases/PostReceiptHelper.kt 94.11% <100.00%> (-0.07%) ⬇️
.../main/kotlin/com/revenuecat/purchases/Purchases.kt 81.09% <100.00%> (+0.02%) ⬆️
...otlin/com/revenuecat/purchases/PurchasesFactory.kt 85.41% <100.00%> (+0.97%) ⬆️

@tonidero tonidero Jun 6, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I'm not sure if this was the best name but I thought it was ok... I explained a bit in the comment for this class.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine, but if requires explanation maybe it's worth giving it another thought. I don't have a better idea, but it's true that updater makes it seem like it will fetch it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed it to CustomerInfoUpdateReceiver, what to you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not convinced about the Receiver part, since it's also notifying. What about CustomerInfoUpdatesHandler?

@tonidero tonidero Jun 19, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that, I renamed to the singular version of it CustomerInfoUpdateHandler in e9d41c1

@tonidero tonidero marked this pull request as ready for review June 8, 2023 06:38
@tonidero tonidero requested a review from a team June 8, 2023 06:39
@tonidero tonidero force-pushed the toniricodiez/sdk-3155-android-if-sdk-detects-unsynced-purchases-when-calling-1 branch 2 times, most recently from 2a4f9b1 to a3172f6 Compare June 13, 2023 09:46
Comment thread purchases/src/main/kotlin/com/revenuecat/purchases/CustomerInfoUpdater.kt Outdated
Comment thread purchases/src/test/java/com/revenuecat/purchases/CustomerInfoUpdaterTest.kt Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine, but if requires explanation maybe it's worth giving it another thought. I don't have a better idea, but it's true that updater makes it seem like it will fetch it

@tonidero tonidero force-pushed the toniricodiez/sdk-3155-android-if-sdk-detects-unsynced-purchases-when-calling-1 branch from 53de5f0 to 7a6f2a5 Compare June 19, 2023 08:22
@tonidero tonidero requested a review from vegaro June 19, 2023 13:36
@tonidero tonidero merged commit 9d1cfe9 into main Jun 20, 2023
@tonidero tonidero deleted the toniricodiez/sdk-3155-android-if-sdk-detects-unsynced-purchases-when-calling-1 branch June 20, 2023 08:18
tonidero added a commit that referenced this pull request Jun 20, 2023
### Description
Followup to #1052 and #1058 

This changes the behavior of fetching customer info. Now, when fetching
customer info, we will first try to sync any pending purchases if any.
If there are pending purchases, we will return the customer info from
the last request sent. If there aren't, we will then hit the current
customer info endpoint to get the latest customer info.
tonidero pushed a commit that referenced this pull request Jun 23, 2023
**This is an automatic release.**

### Bugfixes
* Default customer info schema version to latest known by SDK (#1080)
via Toni Rico (@tonidero)
* Handle other diagnostics-related exceptions (#1076) via Toni Rico
(@tonidero)
* Return error in queryPurchases if error connecting to billing client
(#1072) via Toni Rico (@tonidero)
### Other Changes
* Fix offline entitlements integration tests (#1085) via Toni Rico
(@tonidero)
* Add defaultsRelease variant tests run configuration (#1074) via Toni
Rico (@tonidero)
* Compose sample app: move to gradle catalog (#1081) via Toni Rico
(@tonidero)
* Compose sample app: automate builds (#1082) via Toni Rico (@tonidero)
* Compose sample app (#1056) via Toni Rico (@tonidero)
* Migrate to Gradle version catalog (#1059) via Cesar de la Vega
(@vegaro)
* Trusted entitlements: Add logs with verification mode (#1067) via Toni
Rico (@tonidero)
* Sync pending purchases before getting customer info (#1073) via Toni
Rico (@tonidero)
* Refactor syncing pending transactions logic out of `Purchases` (#1058)
via Toni Rico (@tonidero)
* Refactor CustomerInfo listener and cache logic into
CustomerInfoUpdater (#1052) via Toni Rico (@tonidero)
* Trusted entitlements: Add integration tests (#1071) via Toni Rico
(@tonidero)
* Trusted entitlements: Add internal mechanism to force signing errors
for tests (#1070) via Toni Rico (@tonidero)

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
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