OfferingsManager: added ability to fail if any product is not found#1976
Conversation
There was a problem hiding this comment.
SKProduct 😅
tonidero
left a comment
There was a problem hiding this comment.
Looks good! Just a couple of comments
There was a problem hiding this comment.
Do we need to return after this?
There was a problem hiding this comment.
No, not in this case. This is the existing behavior, which was to simply log and keep going with the products that are found.
There was a problem hiding this comment.
Hmm do we have plans to add other policies here? Just wondering whether it would be better to just make this a boolean instead of an enum.
There was a problem hiding this comment.
Even if we don't, this allows us to document the behavior in the name. As for performance, this has essentially the same representation as a boolean.
The advantage over a Bool is that we don't have to wonder in every place what true or false means, and that's much more error prone.
There was a problem hiding this comment.
Looks like we are not testing these new methods directly. This is called by the existing getOfferings method, so it's tested with a default fetch policy but since it's a public method, even if it's internal, I think we should add a quick test for this just in case.
…1975) We had no test coverage for [`OfferingsManager`'s ability to ignore products that aren't found](https://github.com/RevenueCat/purchases-ios/blob/4.13.1/Sources/Purchasing/OfferingsManager.swift#L134-L140). Added this before expanding this behavior in #1976.
The default behavior is unchanged: if any products aren't found, those are logged, but an `Offerings` value is returned with the found products. This introduces a new `OfferingsManager.FetchPolicy` that allows receiving an error if any product is not found. For the time being, this is `internal` only, and will be used for [CSDK-451], since we don't want to ignore those errors when using this new SDK tester.
bdfcec9 to
b717efd
Compare
Finishes [CSDK-451].
This new small public API allows users to quickly figure out if everything in the SDK is correctly configured in a simple way:
```swift
let tester = SDKTester.default
do {
try await tester.test()
} catch {
print(error)
}
```
The specific underlying errors will provide information about what failed.
We can continue growing this to check for more specific things, but for now it does 4 things:
- Verify API connectivity: networking issues, firewalling, etc.
- Verify API key is correct
- Verify `Offerings` are configured correctly
- Verify that all products in `Offerings` are configured correctly and found in `StoreKit`
This new API is covered by:
- API testers
- Unit tests
- Integration tests (both on `SK1` and `SK2`)
- #1970
- #1971
- #1973
- #1974
- #1975
- #1976
Finishes [CSDK-451].
This new small public API allows users to quickly figure out if everything in the SDK is correctly configured in a simple way:
```swift
let tester = SDKTester.default
do {
try await tester.test()
} catch {
print(error)
}
```
The specific underlying errors will provide information about what failed.
We can continue growing this to check for more specific things, but for now it does 4 things:
- Verify API connectivity: networking issues, firewalling, etc.
- Verify API key is correct
- Verify `Offerings` are configured correctly
- Verify that all products in `Offerings` are configured correctly and found in `StoreKit`
This new API is covered by:
- API testers
- Unit tests
- Integration tests (both on `SK1` and `SK2`)
- #1970
- #1971
- #1973
- #1974
- #1975
- #1976
Finishes [CSDK-451].
This new small public API allows users to quickly figure out if everything in the SDK is correctly configured in a simple way:
```swift
let tester = SDKTester.default
do {
try await tester.test()
} catch {
print(error)
}
```
The specific underlying errors will provide information about what failed.
We can continue growing this to check for more specific things, but for now it does 4 things:
- Verify API connectivity: networking issues, firewalling, etc.
- Verify API key is correct
- Verify `Offerings` are configured correctly
- Verify that all products in `Offerings` are configured correctly and found in `StoreKit`
This new API is covered by:
- API testers
- Unit tests
- Integration tests (both on `SK1` and `SK2`)
- #1970
- #1971
- #1973
- #1974
- #1975
- #1976
…errors (#1977) Finishes [CSDK-451]. This new small public API allows users to quickly figure out if everything in the SDK is correctly configured in a simple way: ```swift let diagnostics = PurchasesDiagnostics.default do { try await diagnostics.testSDKHealth() } catch { print(error) } ``` The specific underlying errors will provide information about what failed. We can continue growing this to check for more specific things, but for now it does 4 things: - Verify API connectivity: networking issues, firewalling, etc. - Verify API key is correct - Verify `Offerings` are configured correctly - Verify that all products in `Offerings` are configured correctly and found in `StoreKit` This new API is covered by: - API testers - Unit tests - Integration tests (both on `SK1` and `SK2`) _I've taken the "shortcut" of making this `async` only (while still compatible with Objective-C), which means it's not compatible with iOS 12.x. But that made the implementation a lot simpler, which I think is a useful tradeoff._ ### Depends on: - #1970 - #1971 - #1973 - #1974 - #1975 - #1976 [CSDK-451]: https://revenuecats.atlassian.net/browse/CSDK-451?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
The default behavior is unchanged: if any products aren't found, those are logged, but an
Offeringsvalue is returned with the found products.This introduces a new
OfferingsManager.FetchPolicythat allows receiving an error if any product is not found. For the time being, this isinternalonly, and will be used for CSDK-451, since we don't want to ignore those errors when using this new SDK tester.