CustomEntitlementComputation: Create different PurchasesConfiguration that requires an appUserId parameter#1154
Conversation
There was a problem hiding this comment.
Also had to create amazon classes for each flavor... Not sure if it's needed but adding it for now
There was a problem hiding this comment.
I'd be more inclined to keep Amazon only in the main flavor, unless there's a technical limitation that forces us to have it
There was a problem hiding this comment.
Hmm I thought of a way to do that, but will do it in a separate PR. For now, I'm just failing when using this in customEntitlementComputation mode.
There was a problem hiding this comment.
I'm wondering, should we disable diagnostics in customEntitlementComputation mode, @aboedo?
There was a problem hiding this comment.
let's keep it disabled on v1 and we can take it from there
There was a problem hiding this comment.
Had to separate these tests per flavor, now that the purchases configuration is different.
There was a problem hiding this comment.
I could have split these tests... But I decided to just use a mock to not have to do that.
Codecov Report
@@ Coverage Diff @@
## main #1154 +/- ##
==========================================
+ Coverage 85.40% 85.69% +0.29%
==========================================
Files 177 176 -1
Lines 6275 6095 -180
Branches 921 915 -6
==========================================
- Hits 5359 5223 -136
+ Misses 571 531 -40
+ Partials 345 341 -4
|
36d9eab to
4e590d0
Compare
33341fa to
ca42170
Compare
4e590d0 to
c0e8cee
Compare
There was a problem hiding this comment.
Originally I wasn't planning to copy the whole PurchasesConfiguration... But I didn't know how to have the Builder have a different constructor per flavor without duplicating everything like this :(
There was a problem hiding this comment.
Could it just be a public extension declared in each flavor?
There was a problem hiding this comment.
I don't think kotlin allows to declare an inner class or a constructor as an extension :(
There was a problem hiding this comment.
Note how I'm doing this, so in case somone using this package changes dangerous settings, we still enable customEntitlementComputation.
There was a problem hiding this comment.
Hmm this makes me think why do we even have the setter in DangerousSettings? If someone in the defaults flavor enables it, they won't access the same API, and if someone in the custom entitlements flavor disables it and sets it here, it will be re-enabled
There was a problem hiding this comment.
Hmm the customEntitlementComputation in DangerousSettings is internal, so devs won't be able to set it up themselves. So it should always be false in the defaults flavor and true in the customEntitlementComputation flavor. Not sure if I'm missing something?
There was a problem hiding this comment.
Oh then nevermind, I had missed that point
20e21e8 to
36ee010
Compare
There was a problem hiding this comment.
Hmm this makes me think why do we even have the setter in DangerousSettings? If someone in the defaults flavor enables it, they won't access the same API, and if someone in the custom entitlements flavor disables it and sets it here, it will be re-enabled
bf5776f to
85d6dc5
Compare
2c28c0c to
10f6340
Compare
There was a problem hiding this comment.
Will remove this class (and the customEntitlementComputation flavor) in a followup PR
There was a problem hiding this comment.
Note that I removed the observerMode setter as well, so it won't be available in the customEntitlementComputation package. CC @aboedo
10f6340 to
5a3529b
Compare
| /** | ||
| * Sets the [EntitlementVerificationMode] to perform signature verification of requests to the | ||
| * RevenueCat backend. | ||
| * | ||
| * When changing from [EntitlementVerificationMode.DISABLED] to other modes, the SDK will clear the | ||
| * CustomerInfo cache. | ||
| * This means users will need to connect to the internet to get their entitlements back. | ||
| * | ||
| * The result of the verification can be obtained from [EntitlementInfos.verification] or | ||
| * [EntitlementInfo.verification]. | ||
| * | ||
| * Default mode is disabled. Please see https://rev.cat/trusted-entitlements for more info. | ||
| */ | ||
| fun entitlementVerificationMode(verificationMode: EntitlementVerificationMode) = apply { | ||
| this.verificationMode = verificationMode | ||
| } |
There was a problem hiding this comment.
this shouldn't be added here, it's not a part of this mode
There was a problem hiding this comment.
I see you're already removing it in #1167
**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 separates
PurchasesConfigurationin 2 for thedefaultsandcustomEntitlementComputationflavor. The one incustomEntitlementComputationwill require an app user id, avoiding initializing the sdk with anonymous users.