CustomEntitlementComputation: New Purchases class#1153
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1153 +/- ##
==========================================
+ Coverage 85.40% 85.64% +0.24%
==========================================
Files 177 178 +1
Lines 6275 6160 -115
Branches 921 916 -5
==========================================
- Hits 5359 5276 -83
+ Misses 571 543 -28
+ Partials 345 341 -4 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Honestly, I would like to run the linter in the tests as well... But there were a bunch of issues and didn't want to make this PR even bigger, so I'm just excluding this for now.
There was a problem hiding this comment.
I renamed this file to ListenerConversionsCommon, this is technically a breaking change in Java, since users in Java would need to upgrade from using ListenerConversionsKt to ListenerConversionsCommonKt for this... I would say people shouldn't be using these extension functions in Java, but they "can".
An alternative to this is to just not have a "common" file and duplicate all functions in both flavors... I wanted to try to reduce the duplication, but might be worth it... Thoughts?
(Note that this doesn't affect the CoroutinesConversionCommon since those functions are marked as @JvmSynthetic so they shouldn't be available in Java.)
There was a problem hiding this comment.
Hmm, probably worth asking the rest of the team, but I think we can rename, imo
There was a problem hiding this comment.
I only added the functions that were needed looking at the API in iOS, but please confirm the API is what we expect. Also, I didn't add any deprecated functions. No need to add those to a new package.
There was a problem hiding this comment.
It's also annoying that we have to duplicate the docs 😢
There was a problem hiding this comment.
I'd actually argue that it's not that bad, given that the docs could be different - for one, the configuration in custom entitlements mode has a non-nullable app user id, so its usage is slightly different, copy can accommodate for that
There was a problem hiding this comment.
I kept these in the main source set... I don't think these should be public, but we use them internally, so they would need to be public in defaults to not cause a breaking change but internal in customEntitlementComputation.
There was a problem hiding this comment.
I tried to split the tests in "Common" for those that should be run in both flavors, and flavor specific ones.
There was a problem hiding this comment.
I went back to using the purchaseOrchestrator for these... the one in Purchases is deprecated in the defaults flavor and it doesn't exist in the customEntitlementComputation flavor, so this allowed me to share the test between both flavors and use non-deprecated functions.
5148d25 to
58592a5
Compare
33341fa to
ca42170
Compare
There was a problem hiding this comment.
This was missed from #1144. Made the change here to avoid conflicts later
There was a problem hiding this comment.
I guess this doesn't really matter since we use these 2 only when configuring the SDK, and we use the value from Purchases, not PurchasesOrchestrator... We might be able to remove the ones in PurchasesOrchestrator. But for now, this seems more secure.
|
Moving back to draft. Exploring using a public base class instead to try to share more code |
There was a problem hiding this comment.
nitpick
We have typically lowercased these files since they are files and not classes. Not sure if that's what we should be doing, but that's what they other files look like.
There was a problem hiding this comment.
Well, detekt was complaining with the lowercase... I think we should try to move toward this instead. Lmk if you think otherwise!
There was a problem hiding this comment.
oh ok! yeah, I don't care, if we go with uppercase, let's make sure we start moving towards that
There was a problem hiding this comment.
nitpick
Same comment about lowercasing the file
…d also extension functions
bf5776f to
85d6dc5
Compare
There was a problem hiding this comment.
I'd actually argue that it's not that bad, given that the docs could be different - for one, the configuration in custom entitlements mode has a non-nullable app user id, so its usage is slightly different, copy can accommodate for that
| /** | ||
| * Invalidates the cache for customer information. | ||
| * | ||
| * Most apps will not need to use this method; invalidating the cache can leave your app in an invalid state. | ||
| * Refer to https://rev.cat/customer-info-cache for more information on | ||
| * using the cache properly. | ||
| * | ||
| * This is useful for cases where purchaser information might have been updated outside of the | ||
| * app, like if a promotional subscription is granted through the RevenueCat dashboard. | ||
| */ | ||
| fun invalidateCustomerInfoCache() { | ||
| purchasesOrchestrator.invalidateCustomerInfoCache() |
There was a problem hiding this comment.
I believe this one is available in iOS. But yeah, I think it's probably ok to remove it. CC @NachoSoto
There was a problem hiding this comment.
Just asked to see if it's being used 👀
|
Removed some extra methods from the custom entitlement computation flavor here, so asking for a rereview, 🙏 |
**This is an automatic release.** ### New Features Introduced Custom Entitlements Computation mode. This is new library intended for apps that will do their own entitlement computation separate from RevenueCat. It's distributed as a separate artifact in Maven. Apps using this mode rely on webhooks to signal their backends to refresh entitlements with RevenueCat. See the [demo app for an example and usage instructions](https://github.com/RevenueCat/purchases-android/tree/main/examples/CustomEntitlementComputationSample). * Custom entitlements: add README and other improvements (#1167) via Andy Boedo (@aboedo) * Update Custom Entitlements Sample app (#1166) via Andy Boedo (@aboedo) * purchase coroutine (#1142) via Andy Boedo (@aboedo) * Add switchUser (#1156) via Cesar de la Vega (@vegaro) * CustomEntitlementsComputation: disable first listener callback when set (#1152) via Andy Boedo (@aboedo) * CustomEntitlementsComputation: Prevent posting subscriber attributes in post receipt (#1151) via Andy Boedo (@aboedo) * Fix `customEntitlementComputation` library deployment (#1169) via Toni Rico (@tonidero) * CustomEntitlementComputation: Configure method for customEntitlementComputation mode (#1168) via Toni Rico (@tonidero) * Add publish system for customEntitlementComputation package (#1149) via Cesar de la Vega (@vegaro) * Use purchase coroutine in CustomEntitlementComputationSample (#1162) via Cesar de la Vega (@vegaro) * Adds CustomEntitlementComputationSample (#1160) via Cesar de la Vega (@vegaro) * Fix tests in customEntitlementComputation after merges (#1161) via Toni Rico (@tonidero) * CustomEntitlementComputation: Remove custom entitlement computation flavor for amazon module (#1158) via Toni Rico (@tonidero) * CustomEntitlementComputation: Generate dokka docs only for defaults flavor (#1159) via Toni Rico (@tonidero) * CustomEntitlementComputation: Create different PurchasesConfiguration that requires an appUserId parameter (#1154) via Toni Rico (@tonidero) * CustomEntitlementComputation: New Purchases class (#1153) via Toni Rico (@tonidero) * CustomEntitlementComputation: Disable automatic cache refresh (#1157) via Toni Rico (@tonidero) * Add `customEntitlementComputation` flavor (#1147) via Toni Rico (@tonidero) * Make `customEntitlementComputation` singular (#1148) via Toni Rico (@tonidero) * Disable offline entitlements in custom entitlements computation mode (#1146) via Toni Rico (@tonidero) * Remove integration test flavor (#1143) via Toni Rico (@tonidero) * Add header to requests when in custom entitlement computation mode (#1145) via Toni Rico (@tonidero) * Add internal customEntitlementsComputation mode to app config (#1141) via Toni Rico (@tonidero) ### New Coroutines * `awaitPurchase` is available as a coroutine-friendly alternative to `purchase()`. (#1142) via Andy Boedo (@aboedo) ### Dependency Updates * Bump fastlane from 2.213.0 to 2.214.0 (#1140) via dependabot[bot] (@dependabot[bot]) ### Other changes * CI: make all Codecov jobs informational (#1155) via Cesar de la Vega (@vegaro) * Creates PurchasesOrchestrator (#1144) via Cesar de la Vega (@vegaro) --------- Co-authored-by: revenuecat-ops <ops@revenuecat.com> Co-authored-by: Andy Boedo <andresboedo@gmail.com>
### New Features Introduced Custom Entitlements Computation mode. This is new library intended for apps that will do their own entitlement computation separate from RevenueCat. It's distributed as a separate artifact in Maven. Apps using this mode rely on webhooks to signal their backends to refresh entitlements with RevenueCat. See the [demo app for an example and usage instructions](https://github.com/RevenueCat/purchases-android/tree/main/examples/CustomEntitlementComputationSample). * Custom entitlements: add README and other improvements (#1167) via Andy Boedo (@aboedo) * Update Custom Entitlements Sample app (#1166) via Andy Boedo (@aboedo) * purchase coroutine (#1142) via Andy Boedo (@aboedo) * Add switchUser (#1156) via Cesar de la Vega (@vegaro) * CustomEntitlementsComputation: disable first listener callback when set (#1152) via Andy Boedo (@aboedo) * CustomEntitlementsComputation: Prevent posting subscriber attributes in post receipt (#1151) via Andy Boedo (@aboedo) * Fix `customEntitlementComputation` library deployment (#1169) via Toni Rico (@tonidero) * CustomEntitlementComputation: Configure method for customEntitlementComputation mode (#1168) via Toni Rico (@tonidero) * Add publish system for customEntitlementComputation package (#1149) via Cesar de la Vega (@vegaro) * Use purchase coroutine in CustomEntitlementComputationSample (#1162) via Cesar de la Vega (@vegaro) * Adds CustomEntitlementComputationSample (#1160) via Cesar de la Vega (@vegaro) * Fix tests in customEntitlementComputation after merges (#1161) via Toni Rico (@tonidero) * CustomEntitlementComputation: Remove custom entitlement computation flavor for amazon module (#1158) via Toni Rico (@tonidero) * CustomEntitlementComputation: Generate dokka docs only for defaults flavor (#1159) via Toni Rico (@tonidero) * CustomEntitlementComputation: Create different PurchasesConfiguration that requires an appUserId parameter (#1154) via Toni Rico (@tonidero) * CustomEntitlementComputation: New Purchases class (#1153) via Toni Rico (@tonidero) * CustomEntitlementComputation: Disable automatic cache refresh (#1157) via Toni Rico (@tonidero) * Add `customEntitlementComputation` flavor (#1147) via Toni Rico (@tonidero) * Make `customEntitlementComputation` singular (#1148) via Toni Rico (@tonidero) * Disable offline entitlements in custom entitlements computation mode (#1146) via Toni Rico (@tonidero) * Remove integration test flavor (#1143) via Toni Rico (@tonidero) * Add header to requests when in custom entitlement computation mode (#1145) via Toni Rico (@tonidero) * Add internal customEntitlementsComputation mode to app config (#1141) via Toni Rico (@tonidero) ### New Coroutines * `awaitPurchase` is available as a coroutine-friendly alternative to `purchase()`. (#1142) via Andy Boedo (@aboedo) ### Dependency Updates * Bump fastlane from 2.213.0 to 2.214.0 (#1140) via dependabot[bot] (@dependabot[bot]) ### Other changes * CI: make all Codecov jobs informational (#1155) via Cesar de la Vega (@vegaro) * Creates PurchasesOrchestrator (#1144) via Cesar de la Vega (@vegaro) --------- Co-authored-by: revenuecat-ops <ops@revenuecat.com> Co-authored-by: Andy Boedo <andresboedo@gmail.com>
Description
This PR moves the existing
Purchasesclass into thedefaultsflavor and creates a newPurchasesclass in thecustomEntitlementComputationflavor. It also moves some of the extension functions to thedefaultsflavor since they aren't possible in thecustomEntitlementComputationflavor. It also splits the tests and api tests to run some tests on thedefaultsflavor only