BC8 migration#2477
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2477 +/- ##
==========================================
- Coverage 78.72% 78.33% -0.39%
==========================================
Files 289 286 -3
Lines 10519 10432 -87
Branches 1509 1500 -9
==========================================
- Hits 8281 8172 -109
- Misses 1590 1614 +24
+ Partials 648 646 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| ) { | ||
| log(LogIntent.DEBUG) { RestoreStrings.QUERYING_PURCHASE_WITH_TYPE.format(productId, productType.name) } | ||
| queryAllPurchases( | ||
| queryPurchases( |
There was a problem hiding this comment.
This is a change in behavior in Amazon... but I think this is fine, since this method was only used for upgrades/downgrades which is not really supported in Amazon. I just changed the implementation to make it more sense with the new method name.
There was a problem hiding this comment.
Is there any way to test this?
There was a problem hiding this comment.
Well, as you can see here, we early exit from the purchase if the developer gives us any replacement information (we actually should improve that, since it would actually keep the call forever without returning an error 😬)
There was a problem hiding this comment.
Ouch, yea that's something we should improve. Can be a separate PR though.
| StatusCode.INVALID_PRODUCT_ID_FORMAT -> "INVALID_PRODUCT_ID_FORMAT" | ||
| StatusCode.NO_ELIGIBLE_OFFER -> "NO_ELIGIBLE_OFFER" | ||
| else -> "UNKNOWN_STATUS_CODE: $statusCode" | ||
| } |
There was a problem hiding this comment.
This was interesting, for now I'm just logging to console, but in the future it might be useful to track this information with diagnostics or something else and expose it in the dashboard in case there are issues.
There was a problem hiding this comment.
This might be a fun interview problem 😅
|
|
||
| // Google Play Billing Library 8.0 removed APIs to query historical purchases. | ||
| // This method will from now on only return active purchases in Google Play. | ||
| // However, in Amazon, it will still return historical purchases. |
There was a problem hiding this comment.
TBH, I wasn't sure whether to just remove this method entirely... but I wanted to keep Amazon having the same functionality as long as it's possible and since this is abstracting the Store, I preferred to keep it. Lmk if you think otherwise.
There was a problem hiding this comment.
Might be good to make this actual documentation of the method, so it's surfaced by the IDE?
/**
* Google Play Billing Library 8.0 removed APIs to query historical purchases.
* This method will from now on only return active purchases in Google Play.
* However, in Amazon, it will still return historical purchases.
*/|
|
||
| @SuppressWarnings("LongParameterList") | ||
| abstract fun findPurchaseInPurchaseHistory( | ||
| abstract fun findPurchaseInActivePurchases( |
There was a problem hiding this comment.
This was only being used for upgrades/downgrades. I'm not sure why were were looking in the purchase history, when upgrades/downgrades are only possible with active subs AFAIK. Now we only check for active purchases.
JayShortway
left a comment
There was a problem hiding this comment.
Thanks for taking care of this! Approved as far as I'm concerned, but since this is pretty much the change of the year, we might want another pair of eyes on it.
| * **Important**: until multi-line subscriptions are released, | ||
| * we assume that there will be only a single sku in the purchase. | ||
| * https://android-developers.googleblog.com/2021/05/whats-new-in-google-play-2021.html |
| StatusCode.INVALID_PRODUCT_ID_FORMAT -> "INVALID_PRODUCT_ID_FORMAT" | ||
| StatusCode.NO_ELIGIBLE_OFFER -> "NO_ELIGIBLE_OFFER" | ||
| else -> "UNKNOWN_STATUS_CODE: $statusCode" | ||
| } |
There was a problem hiding this comment.
This might be a fun interview problem 😅
|
|
||
| // Google Play Billing Library 8.0 removed APIs to query historical purchases. | ||
| // This method will from now on only return active purchases in Google Play. | ||
| // However, in Amazon, it will still return historical purchases. |
There was a problem hiding this comment.
Might be good to make this actual documentation of the method, so it's surfaced by the IDE?
/**
* Google Play Billing Library 8.0 removed APIs to query historical purchases.
* This method will from now on only return active purchases in Google Play.
* However, in Amazon, it will still return historical purchases.
*/| ) { | ||
| log(LogIntent.DEBUG) { RestoreStrings.QUERYING_PURCHASE_WITH_TYPE.format(productId, productType.name) } | ||
| queryAllPurchases( | ||
| queryPurchases( |
There was a problem hiding this comment.
Is there any way to test this?
ajpallares
left a comment
There was a problem hiding this comment.
Took a look. Nothing to object! But I'll leave approval to others with more knowledge 🙏
|
|
||
| override fun queryAllPurchases( | ||
| appUserID: String, | ||
| onReceivePurchaseHistory: (List<StoreTransaction>) -> Unit, |
There was a problem hiding this comment.
Maybe these parameters names should be updated.
I wonder if queryAllPurchases can just be queryPurchases now as well
There was a problem hiding this comment.
Right, I left queryAllPurchases as it is... The thing is that Amazon can still query for all products, so I think restore/sync should still do that in Amazon. In that case, we need to differentiate between both... (I guess we could also unify both methods and add a parameter, but I kept it separate for now to minimize the changes and left a comment as seen here
| ) | ||
| } catch (e: NoClassDefFoundError) { | ||
| throw NoCoreLibraryDesugaringException(e) | ||
| } |
There was a problem hiding this comment.
Yup! I was able to test on the device we used to test the issues. Very easy to repro in main. No issues with BC8 🙌
| .firstOrNull { it.getInt(it) == this } | ||
| ?.name | ||
| ?: "$this" | ||
| } |
There was a problem hiding this comment.
I assume getOnPurchasesUpdatedSubResponseCodeName will barely get called but since it's using reflection, you could maybe create a static map that this function can access when called
There was a problem hiding this comment.
Well, it will get called on every purchase attempt... And yeah, might be better to create a map... I just followed what we do for the responseCode itself, but I think creating a map ourselves feels better yeah... Will do the change, and I might change that other mapping we do while I'm at it.
| } | ||
| logErrorIfIssueBuildingBillingParams(received) | ||
| received.takeUnless { it.isEmpty() }?.forEach { | ||
| received.unfetchedProductList.takeIf { it.isNotEmpty() }?.let { |
There was a problem hiding this comment.
oh this unfetchedProductList is nice
We could have somthing similar in Offerings
There was a problem hiding this comment.
Yeah, we might want to expose this somehow... But we should probably agree on what API to use. For now, I'm just logging the reason for it to be unfetched, but I also think it might be good to track it with diagnostics, and even give this information in the dashboard.
|
Removing breaking label since we're making a new release without this for now, so automations are able to continue and make a normal release before we ship this. Reverted in #2501 |
**This is an automatic release.** ## RevenueCat SDK ### ✨ New Features * feat(purchases): Add setPostHogUserId() method to Purchases API (#2495) via Hussain Mustafa (@hussain-mustafa990) ### 🐞 Bugfixes * Improves button progress indicator size calculation. (#2485) via JayShortway (@JayShortway) ### 🔄 Other Changes * Revert "BC8 migration (#2477)" (#2501) via Toni Rico (@tonidero) * Add codelab instructions on README file (#2489) via Jaewoong Eum (@skydoves) * Use collectAsStateWithLifecycle instead of collectAsState in Compose (#2488) via Jaewoong Eum (@skydoves) * Improve Composable stabilities (#2478) via Jaewoong Eum (@skydoves) * [AUTOMATIC][Paywalls V2] Updates paywall-preview-resources submodule (#2486) via RevenueCat Git Bot (@RCGitBot) * BC8 migration (#2477) via Toni Rico (@tonidero) * Fixes building sample apps with SNAPSHOT dependencies (#2483) via JayShortway (@JayShortway) * [AUTOMATIC][Paywalls V2] Updates paywall-preview-resources submodule (#2484) via RevenueCat Git Bot (@RCGitBot) Co-authored-by: revenuecat-ops <ops@revenuecat.com>
This reverts commit 34c61a3. ### Description Reapplies the changes originally from #2477 that were reverted in #2501 to allow making a release in the current major. Migrates to BC8: https://developer.android.com/google/play/billing/release-notes#8-0-0
Description
Migrates to BC8: https://developer.android.com/google/play/billing/release-notes#8-0-0