* feat: disable postAttributionData requests when in UI preview mode
* tests: add unit test to check `AttributionPoster`'s new `clearPostponedAttributionData` method
* tests: add unit tests to check that `AttributionData` is never posted in UI preview mode
* refactor: simplify implementation of avoiding `AttributionPoster` requests in UI preview mode
* feat: add missing properties to `apple_purchase_attempt` diagnostics event
* tests: add + edit unit tests for new diagnostics parameters for SK1 purchase attempt
* fix implementation of sk2 product purchase to catch promotional offer signature error again
* tests: edit unit tests for new diagnostics parameters for SK2 purchase attempt
* fix failing test
* refactor: separate error handling in purchase SK2 product method into its own method
* address PR #4835 comments
* lint
* tests: remove `Equatable` conformance of `DiagnosticsEvent` and `AnyEncodable` from RevenueCat and added to test targets (where it's needed)
* Use Arrays instead of Sets in Diagnostics events to have predictable order in sent events
* tests: compare Sets vs Arrays in unit test
The conversion from Array --> Set --> Array may change the order of the elements
* remove `DiagnosticsEvent+Equatable` from some targets
* PR #4839 fixes
* remove `AnyEncodable+Equatable.swift` from some targets
* Prevent calling the GET request to the intro eligibility endpoint when in UI Preview mode
* fix lint warning
* tests: add unit tests for `TrialOrIntroPriceEligibilityChecker` in UI preview mode
* fake `unknown` intro eligibility status for products in UI preview mode
* tests: remove empty check on intro eligibility result dictionary when in UI preview mode
* add comment to early return for check eligibility in UI preview mode
* Added tests
* Removed compiler flags because extra work to handle this on CI unit tests when we are releasing this soon and this isn't really that dangerous
* Fix lint
* Some naming improvements
* Passing UIConfig into Offering
* Reorged some data structures
* Fixed some lint
* This
* Send paywall events when the app is backgrounded.
* - Add tests for syncing paywall events when backgrounding
- Send events after a successful purchase + tests
* typo
* typo
* Introduce PurchaseParams to allow passing extra configuration info when making a purchase
* simplify naming
* fallback to old method when flag is not enabled
* Add $(inherited) to the test targets so they pick up compiler flags from Local.xcconfig
* Include product/package inside PurchaseParams
* fix tests
* add compiler flag check
* update purchase tester
* fix docs
* add tests
* Update Sources/Networking/Operations/PostReceiptDataOperation.swift
Co-authored-by: Toni Rico <toni.rico.diez@revenuecat.com>
---------
Co-authored-by: Toni Rico <toni.rico.diez@revenuecat.com>
* [Diagnostics] Add apple_products_request event
* Fixes from review
* Change tests to use to(beNil())
* Make MockDiagnosticsTracker sendable to fix tests
* Add new property to track storekit error type
* Use new method to process sk errors
* replace withCheckedThrowingContinuation calls with withUnsafeThrowingContinuation
* replaced instances of withCheckedContinuation -> withUnsafeContinuation
* update the links in comments to point to the issue not the PR
* linting
---------
Co-authored-by: andy boedo <andresboedo@gmail.com>
<!-- Thank you for contributing to Purchases! Before pressing the
"Create Pull Request" button, please provide the following: -->
### Checklist
- [x] If applicable, unit tests
- [ ] If applicable, create follow-up issues for `purchases-android` and
hybrids
### Motivation
When calling syncPurchases with StoreKit 2, we aren't including any
unsynced subscriber attributes.
### Description
This PR modifies the StoreKit 2 syncPurchases network request to include
unsynced subscriber attributes, the storefront, and a nil
`presentedOfferingContext`.
---------
Co-authored-by: Will Taylor <wtaylor151@gmail.com>
## Motivation
- Compile errors in Xcode 15 with iOS 16
- Flaky tests
## Description
### iOS 16 fixes
The following things aren't available:
- `@available(visionOS)`
- `.topBarTrailing` (need to use `.navigationBarTrailing`)
- Fix issues with `Locale(identifier: "")` now returning `en` but ONLY
on iOS 16 in Xcode 15
- iOS 17 returns the expected `nil` in Xcode 15
- There was a test using `#if swift` that was now being run by iOS 16
tests that needed an additional
`AvailabilityChecks.iOS17APIAvailableOrSkipTest()`
### Flaky tests fixes
Using new `scan_with_flaky_test_retries` action from in
`fastlane-plugin-revenuecat_internal`
- Replaces the `retry_failed_tests` lane that did a similar thing
- Removed a bunch of duplicated steps in the `.circle/config.yml` that
needed to run the `retry_failed_tests`
- `scan_with_flaky_test_retries` is now used in:
- `test_ios`
- `test_tvos`
- `test_watchos`
- `backend_integration_tests`
### Carthage tests timing out
The carthage installation tests timed out pretty regularly. They will
now use the large resource class (where everything else uses the medium)
### Description
This moves the offline backend integration tests to run on M1 machines
in CircleCI.
Since this causes tests to be much more flaky, this includes a
cherry-pick of the changes in the 5.0 branch that improves those:
https://github.com/RevenueCat/purchases-ios/pull/3902
---------
Co-authored-by: Josh Holtz <me@joshholtz.com>
Co-authored-by: Will Taylor <wtaylor151@gmail.com>
Co-authored-by: Andy Boedo <andresboedo@gmail.com>
### Description
This makes it so, if we detect the diagnostics file gets too big while
tracking an event, we just clear it and start over. Additionally, we add
an event tracking that this happened to the diagnostics file.
Create `DiagnosticsTracker` and adds it to the `Purchases`
initialization. I don't expose the `diagnosticsEnabled` yet
---------
Co-authored-by: Toni Rico <antonio.rico.diez@revenuecat.com>
Follow up to #3599 and #3600.
These `@MainActor` annotations don't work anymore because of this:
> Main actor-isolated class '...' has different actor isolation from
nonisolated superclass 'TestCase'; this is an error in Swift 6
They were necessary with an older version of Xcode (likely 13.x), but
not anymore.
---------
Co-authored-by: Mark Villacampa <m@markvillacampa.com>
### Motivation
Get more context with targeting information
### Description
- Parse targeting information into `Offerings`
- Add targeting context into `Offerings.current`
- Add targeting context into `getCurrentOffering(forPlacement: String)`
- Post targeting context in post receipts
---------
Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com>
### Motivation
New function to get `Offering` by a placement identifier
### Description
New `currentOffering(forPlacement: String): Offering?` method on
`Offerings`
- Added demo button for this in purchase tester app
```swift
// Example usage
if let offering = offerings.currentOffering(forPlacement: "onboarding") {
showPaywall(offering)
}
```
#### Logic flow
- If a placement identifier explicitly exists within the
`placements.offeringIdsByPlacement` dictionary, the method attempts to
fetch the corresponding `Offering` without resorting to a fallback
- Example: when there is a `nil` / null value for a placement, we don't
want to use the fallback
- If the placement identifier does not exist, the method then attempts
to fetch a fallback offering defined by `placements.fallbackOfferingId`
#### New placements object in offerings response
```js
{
// other offerings stuff
"placements": {
"fallback_offering_id": "offering_a", // can be null
"offering_ids_by_placement": {
"onboarding_start": null,
"onboarding_end": "offering_b",
}
}
}
```
---------
Co-authored-by: Guido Torres <guido@revenuecat.com>
Co-authored-by: Josh Holtz <me@joshholtz.com>
Co-authored-by: RevenueCat Git Bot <72824662+RCGitBot@users.noreply.github.com>
Checking for the presence of `Xcode/DerivedData` in the receipt path was
failing for TestFlight builds or if the .app bundle generated by Xcode
was moved from the folder.
Additionally, checking for `MASReceipt/receipt` seems less robust than
simply using compiler directives.
Instead, for macOS apps, we check the environment embedded in the receipt and alternatively check the signature of the app bundle.
---------
Co-authored-by: NachoSoto <NachoSoto@users.noreply.github.com>