Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EXTERNAL] Add ExperimentalPreviewRevenueCatPurchasesAPI opt-in requirement to Purchases.awaitCustomerInfo() #1060

Conversation

pablo-guardiola
Copy link
Contributor

Checklist

  • If applicable, unit tests
  • If applicable, create follow-up issues for purchases-ios and hybrids

Motivation

Why is this change required? What problem does it solve?

Follow up from https://github.com/RevenueCat/purchases-android/pull/1012/files#r1223917692

Instead of only noting that Purchases.awaitCustomerInfo() is experimental in the docs (which are often overlooked 😬), we can be more explicit and add an opt-in requirement annotation ExperimentalPreviewRevenueCatPurchasesAPI.

Capturing from the Kotlin Opt-in requirements docs:

The Kotlin standard library provides a mechanism for requiring and giving explicit consent for using certain elements of APIs. This mechanism lets library developers inform users of their APIs about specific conditions that require opt-in, for example, if an API is in the experimental state and is likely to change in the future.

To prevent potential issues, the compiler warns users of such APIs about these conditions and requires them to opt in before using the API.

This opens the door to use this annotation in any other APIs which are experimental, in preview or under cooking, to get initial feedback and iterate "without" breaking SemVer 🚀

Description

Describe your changes in detail

  • Create ExperimentalPreviewRevenueCatPurchasesAPI opt-in requirement annotation
  • Opt in to using ExperimentalPreviewRevenueCatPurchasesAPI wherever Purchases.awaitCustomerInfo() is called

Please describe in detail how you tested your changes

  • Run purchases tests
  • Run examples.purchase-test app

cc @tonidero @vegaro

Copy link
Contributor

@vegaro vegaro left a comment

Choose a reason for hiding this comment

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

Thanks for opening. I think this makes a lot of sense to me. What do you think @tonidero

import kotlinx.coroutines.test.runTest
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@OptIn(ExperimentalPreviewRevenueCatPurchasesAPI::class, ExperimentalCoroutinesApi::class)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is ExperimentalCoroutinesApi needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's needed to remove the runTest warning:

This declaration needs opt-in. Its usage should be marked with '@kotlinx.coroutines.ExperimentalCoroutinesApi' or '@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)'

@MustBeDocumented
@Retention(value = AnnotationRetention.BINARY)
@Target(
    AnnotationTarget.CLASS,
    AnnotationTarget.ANNOTATION_CLASS,
    AnnotationTarget.PROPERTY,
    AnnotationTarget.FIELD,
    AnnotationTarget.LOCAL_VARIABLE,
    AnnotationTarget.VALUE_PARAMETER,
    AnnotationTarget.CONSTRUCTOR,
    AnnotationTarget.FUNCTION,
    AnnotationTarget.PROPERTY_GETTER,
    AnnotationTarget.PROPERTY_SETTER,
    AnnotationTarget.TYPEALIAS
)
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
public annotation class ExperimentalCoroutinesApi

I can remove it if you prefer so, as it's not mandatory.

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, because I get that message (This declaration needs opt-in...) in the annotation itself not in the runTest, that's why I am confused

Screenshot 2023-06-13 at 11 37 36 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That @OptIn warning is different 👀

Screen Shot 2023-06-13 at 9 47 52 AM

BTW note that what you're seeing are the docs from @ExperimentalCoroutinesApi that's not the warning you get if you don't add the @OptIn, if you remove it you should get it (followed by the docs) 👀

Screen Shot 2023-06-13 at 9 47 07 AM

Copy link
Contributor

Choose a reason for hiding this comment

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

I am seeing it today, but I didn't yesterday! Weird, I was very confused 😆

Thanks for taking the time taking screenshots and explaining

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gradle... :trollface:

@tonidero
Copy link
Contributor

Yeah I think this makes sense. We probably won't get many users if they need to use this annotation, but if the API is subject to change, that's how it should be 👍

@pablo-guardiola
Copy link
Contributor Author

We probably won't get many users if they need to use this annotation

You know that we developers love to live on the edge 🔥 😅

Jokes aside, I believe a bunch of customers will start using it (especially the ones that already use / integrate Coroutines in their codebase / apps) and we can start gathering feedback 🚀

@tonidero
Copy link
Contributor

Yeah, in any case I think this is a good addition 👍

@tonidero tonidero changed the title Add ExperimentalPreviewRevenueCatPurchasesAPI opt-in requirement to Purchases.awaitCustomerInfo() [EXTERNAL] Add ExperimentalPreviewRevenueCatPurchasesAPI opt-in requirement to Purchases.awaitCustomerInfo() Jun 14, 2023
@tonidero tonidero changed the base branch from main to external/pablo-guardiola/pg-add-experimental-preview-revenuecat-api June 14, 2023 08:30
@tonidero tonidero merged commit 0578c24 into RevenueCat:external/pablo-guardiola/pg-add-experimental-preview-revenuecat-api Jun 14, 2023
@pablo-guardiola pablo-guardiola deleted the pg-add-experimental-preview-revenuecat-api branch June 14, 2023 10:21
tonidero pushed a commit that referenced this pull request Jun 14, 2023
…uirement to `Purchases.awaitCustomerInfo()` (#1060)

<!-- Thank you for contributing to Purchases! Before pressing the
"Create Pull Request" button, please provide the following: -->

### Checklist
- [ ] If applicable, unit tests
- [ ] If applicable, create follow-up issues for `purchases-ios` and
hybrids

### Motivation
**Why is this change required? What problem does it solve?**

Follow up from
https://github.com/RevenueCat/purchases-android/pull/1012/files#r1223917692

Instead of only noting that `Purchases.awaitCustomerInfo()` is
experimental in the docs (which are often overlooked 😬), we can be more
explicit and add an opt-in requirement annotation
`ExperimentalPreviewRevenueCatPurchasesAPI`.

Capturing from the [Kotlin Opt-in requirements
docs](https://kotlinlang.org/docs/opt-in-requirements.html):

> The Kotlin standard library provides a mechanism for requiring and
giving explicit consent for using certain elements of APIs. This
mechanism lets library developers inform users of their APIs about
specific conditions that require opt-in, for example, if an API is in
the experimental state and is likely to change in the future.
>
> To prevent potential issues, the compiler warns users of such APIs
about these conditions and requires them to opt in before using the API.

This opens the door to use this annotation in any other APIs which are
experimental, in preview or under cooking, to get initial feedback and
iterate "without" breaking SemVer 🚀

<!-- Please link to issues following this format: Resolves #999999 -->

### Description
**Describe your changes in detail**

- Create `ExperimentalPreviewRevenueCatPurchasesAPI` opt-in requirement
annotation
- Opt in to using `ExperimentalPreviewRevenueCatPurchasesAPI` wherever
`Purchases.awaitCustomerInfo()` is called

**Please describe in detail how you tested your changes**
- Run `purchases` tests
- Run `examples.purchase-test` app

cc @tonidero @vegaro
tonidero added a commit that referenced this pull request Jun 14, 2023
…uirement to `Purchases.awaitCustomerInfo()` (#1060) (#1065)

<!-- Thank you for contributing to Purchases! Before pressing the
"Create Pull Request" button, please provide the following: -->

### Checklist
- [ ] If applicable, unit tests
- [ ] If applicable, create follow-up issues for `purchases-ios` and
hybrids

### Motivation
**Why is this change required? What problem does it solve?**

Follow up from

https://github.com/RevenueCat/purchases-android/pull/1012/files#r1223917692

Instead of only noting that `Purchases.awaitCustomerInfo()` is
experimental in the docs (which are often overlooked 😬), we can be more
explicit and add an opt-in requirement annotation
`ExperimentalPreviewRevenueCatPurchasesAPI`.

Capturing from the [Kotlin Opt-in requirements
docs](https://kotlinlang.org/docs/opt-in-requirements.html):

> The Kotlin standard library provides a mechanism for requiring and
giving explicit consent for using certain elements of APIs. This
mechanism lets library developers inform users of their APIs about
specific conditions that require opt-in, for example, if an API is in
the experimental state and is likely to change in the future.
>
> To prevent potential issues, the compiler warns users of such APIs
about these conditions and requires them to opt in before using the API.

This opens the door to use this annotation in any other APIs which are
experimental, in preview or under cooking, to get initial feedback and
iterate "without" breaking SemVer 🚀

<!-- Please link to issues following this format: Resolves #999999 -->

### Description
**Describe your changes in detail**

- Create `ExperimentalPreviewRevenueCatPurchasesAPI` opt-in requirement
annotation
- Opt in to using `ExperimentalPreviewRevenueCatPurchasesAPI` wherever
`Purchases.awaitCustomerInfo()` is called

Note that this isn't a breaking change since coroutines haven't shipped
yet.

**Please describe in detail how you tested your changes**
- Run `purchases` tests
- Run `examples.purchase-test` app

Contributed by @pablo-guardiola

Co-authored-by: pablo-guardiola <[email protected]>
tonidero added a commit that referenced this pull request Jun 14, 2023
### Description
This PR has changes from #1060 and is based on #1061 

This adds a require opt in requirement to use the trusted entitlements
API.
tonidero added a commit that referenced this pull request Jun 14, 2023
**This is an automatic release.**

### New experimental features
* Trusted entitlements (#1048) via Toni Rico (@tonidero)

This new feature prevents MitM attacks between the SDK and the
RevenueCat server.
With verification enabled, the SDK ensures that the response created by
the server was not modified by a third-party, and the entitlements
received are exactly what was sent.
This is 100% opt-in. `EntitlementInfos` have a new `VerificationResult`
property, which will indicate the validity of the responses when this
feature is enabled.

This feature is experimental and requires opt in. It's also only
available in Kotlin.

```kotlin
@OptIn(ExperimentalPreviewRevenueCatPurchasesAPI::class)
fun configureRevenueCat() {
    val configuration = PurchasesConfiguration.Builder(context, apiKey)
        .informationalVerificationModeAndDiagnosticsEnabled(true)
        .build()
    Purchases.configure(configuration)
}
```

* Add Coroutine support to Purchases#getCustomerInfo (#1012) via Cesar
de la Vega (@vegaro)
### Bugfixes
* [EXTERNAL] Fix `README` `CONTRIBUTING` guide broken link (#1035) via
@pablo-guardiola (#1036) via Toni Rico (@tonidero)
### Dependency Updates
* Update targetSDK version to 33 (#1050) via Toni Rico (@tonidero)
* Update gradle plugin to 8.0.2 (#1049) via Toni Rico (@tonidero)
* Bump danger from 9.3.0 to 9.3.1 (#1054) via dependabot[bot]
(@dependabot[bot])
* [EXTERNAL] Update Kover to 0.7.0 (#1031) via @mikescamell (#1037) via
Toni Rico (@tonidero)
### Other Changes
* [EXTERNAL] Add `ExperimentalPreviewRevenueCatPurchasesAPI` opt-in
requirement to `Purchases.awaitCustomerInfo()` (#1060) (#1065) via Toni
Rico (@tonidero)
* Update to latest android executor image (#1062) via Toni Rico
(@tonidero)
* Diagnostics: Track http requests as counters (#1047) via Toni Rico
(@tonidero)
* Fix backend integration test flakiness (#1053) via Toni Rico
(@tonidero)
* [EXTERNAL] Replace `@Deprecated` usage of `skus` by `productIds`
from`PurchasedProductsFetcher` (#986) via @pablo-guardiola (#1044) via
Toni Rico (@tonidero)
* [EXTERNAL] Add `MagicWeather` app note to the main `README` and fix a
typo (#1041) (#1043) via Toni Rico (@tonidero)
* Detekt enable trailing comma (#1046) via Toni Rico (@tonidero)
* Detekt update to 1.23.0 and run autocorrect (#1045) via Toni Rico
(@tonidero)
* [PurchaseTester] Update CustomerInfo from listener in overview screen
(#1034) via Toni Rico (@tonidero)

---------

Co-authored-by: revenuecat-ops <[email protected]>
Co-authored-by: Toni Rico <[email protected]>
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.

3 participants