Skip to content

Offline Entitlements: allow creating offline CustomerInfo with empty ProductEntitlementMapping#2504

Merged
NachoSoto merged 1 commit into
mainfrom
offline-customer-info-empty-entitlements
May 19, 2023
Merged

Offline Entitlements: allow creating offline CustomerInfo with empty ProductEntitlementMapping#2504
NachoSoto merged 1 commit into
mainfrom
offline-customer-info-empty-entitlements

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

This matches the behavior in Android. It still will fail if the mapping hasn't been fetched yet, but if it has and it's empty, it'll still create a CustomerInfo. This is useful for apps that don't use entitlements. They'll still be able to check the product ID in activeSubscriptions.

@NachoSoto NachoSoto requested a review from a team May 18, 2023 17:12
@codecov

codecov Bot commented May 18, 2023

Copy link
Copy Markdown

Codecov Report

Merging #2504 (744b76f) into main (e4f6c99) will increase coverage by 0.15%.
The diff coverage is 92.90%.

❗ Current head 744b76f differs from pull request most recent head 3cf1e9b. Consider uploading reports for the commit 3cf1e9b to get more accurate results

@@            Coverage Diff             @@
##             main    #2504      +/-   ##
==========================================
+ Coverage   87.68%   87.83%   +0.15%     
==========================================
  Files         197      198       +1     
  Lines       13327    13582     +255     
==========================================
+ Hits        11686    11930     +244     
- Misses       1641     1652      +11     
Impacted Files Coverage Δ
Sources/Logging/Strings/Strings.swift 100.00% <ø> (ø)
...urces/Networking/Responses/OfferingsResponse.swift 100.00% <ø> (ø)
...OfflineEntitlements/PurchasedProductsFetcher.swift 84.61% <ø> (ø)
...rces/OfflineEntitlements/PurchasedSK2Product.swift 92.85% <ø> (ø)
...ntitlements/CustomerInfo+OfflineEntitlements.swift 89.06% <62.50%> (-2.17%) ⬇️
Sources/Caching/DeviceCache.swift 93.39% <74.19%> (-1.57%) ⬇️
Sources/Logging/Strings/CustomerInfoStrings.swift 91.11% <75.00%> (-1.58%) ⬇️
...flineEntitlements/OfflineCustomerInfoCreator.swift 88.46% <88.46%> (ø)
...s/Logging/Strings/OfflineEntitlementsStrings.swift 80.55% <93.33%> (+9.12%) ⬆️
Sources/Identity/CustomerInfoManager.swift 94.53% <94.59%> (+0.25%) ⬆️
... and 15 more

... and 2 files with indirect coverage changes

@NachoSoto NachoSoto force-pushed the nacho/sdk-2991-write-flow-to-use-locally-computed branch from 14d252b to 777318f Compare May 18, 2023 17:40
@NachoSoto NachoSoto force-pushed the offline-customer-info-empty-entitlements branch 2 times, most recently from 2a09cc9 to 744b76f Compare May 18, 2023 23:54
Base automatically changed from nacho/sdk-2991-write-flow-to-use-locally-computed to main May 19, 2023 17:27
…pty `ProductEntitlementMapping`

This matches the behavior in Android. It still will fail if the mapping hasn't been fetched yet, but if it has and it's empty, it'll still create a `CustomerInfo`.
This is useful for apps that don't use entitlements. They'll still be able to check the product ID in `activeSubscriptions`.
@NachoSoto NachoSoto force-pushed the offline-customer-info-empty-entitlements branch from 744b76f to 3cf1e9b Compare May 19, 2023 17:32
@NachoSoto NachoSoto enabled auto-merge (squash) May 19, 2023 17:32
@NachoSoto NachoSoto merged commit 2396680 into main May 19, 2023
@NachoSoto NachoSoto deleted the offline-customer-info-empty-entitlements branch May 19, 2023 18:07
This was referenced May 31, 2023
@NachoSoto NachoSoto mentioned this pull request May 31, 2023
NachoSoto added a commit that referenced this pull request Jun 1, 2023
**This is an automatic release.**

### New Features
* `Offline Entitlements`: use offline-computed `CustomerInfo` when
server is down (#2368) via NachoSoto (@NachoSoto)

### Bugfixes
* `AppleReceipt.debugDescription`: don't pretty-print JSON (#2564) via
NachoSoto (@NachoSoto)
* `SK2StoreProduct`: fix crash on iOS 12 (#2565) via NachoSoto
(@NachoSoto)
* `GetCustomerInfo` posts receipts if there are pending transactions
(#2533) via NachoSoto (@NachoSoto)
### Performance Improvements
* `PurchasedProductsFetcher`: cache current entitlements (#2507) via
NachoSoto (@NachoSoto)
* Performance: new check to ensure serialization / deserialization is
done from background thread (#2496) via NachoSoto (@NachoSoto)
### Dependency Updates
* Bump fastlane from 2.212.2 to 2.213.0 (#2544) via dependabot[bot]
(@dependabot[bot])
### Other Changes
* `CustomerInfoManager`: post all unfinished transactions (#2563) via
NachoSoto (@NachoSoto)
* `PostReceiptOperation`: added ability to also post `AdServices` token
(#2566) via NachoSoto (@NachoSoto)
* `Offline Entitlements`: improved computation log (#2562) via NachoSoto
(@NachoSoto)
* Added `TransactionPoster` tests (#2557) via NachoSoto (@NachoSoto)
* Refactored `TransactionPoster`: removed 2 dependencies and abstracted
parameters (#2542) via NachoSoto (@NachoSoto)
* `CustomerInfoManagerTests`: wait for `getAndCacheCustomerInfo` to
finish (#2555) via NachoSoto (@NachoSoto)
* `StoreTransaction`: implemented `description` (#2556) via NachoSoto
(@NachoSoto)
* `Backend.ResponseHandler` is now `@Sendable` (#2541) via NachoSoto
(@NachoSoto)
* Extracted `TransactionPoster` from `PurchasesOrchestrator` (#2540) via
NachoSoto (@NachoSoto)
* `enableAdServicesAttributionTokenCollection`: added integration test
(#2551) via NachoSoto (@NachoSoto)
* `AttributionPoster`: replaced hardcoded strings with constants (#2548)
via NachoSoto (@NachoSoto)
* `DefaultDecodable`: moved to `Misc/Codable/DefaultDecodable.swift`
(#2528) via NachoSoto (@NachoSoto)
* `CircleCI`: specify device to run `backend_integration_tests` (#2547)
via NachoSoto (@NachoSoto)
* Created `StoreKit2TransactionFetcher` (#2539) via NachoSoto
(@NachoSoto)
* Fix load shedder integration tests (#2546) via Josh Holtz
(@joshdholtz)
* Fix doc on `Offering.getMetadataValue` (#2545) via Josh Holtz
(@joshdholtz)
* Extracted and tested `AsyncSequence.extractValues` (#2538) via
NachoSoto (@NachoSoto)
* `Offline Entitlements`: don't compute offline `CustomerInfo` when
purchasing a consumable products (#2522) via NachoSoto (@NachoSoto)
* `OfflineEntitlementsManager`: disable offline `CustomerInfo` in
observer mode (#2520) via NachoSoto (@NachoSoto)
* `BasePurchasesTests`: fixed leak detection (#2534) via NachoSoto
(@NachoSoto)
* `PurchaseTesterSwiftUI`: added `ProxyView` to `iOS` (#2531) via
NachoSoto (@NachoSoto)
* `PurchasedProductsFetcher`: removed `AppStore.sync` call (#2521) via
NachoSoto (@NachoSoto)
* `PurchaseTesterSwiftUI`: added new window on Mac to manage proxy
(#2518) via NachoSoto (@NachoSoto)
* `PurchasedProductsFetcher`: added log if fetching purchased products
is slow (#2515) via NachoSoto (@NachoSoto)
* `Offline Entitlements`: disable for custom entitlements mode (#2509)
via NachoSoto (@NachoSoto)
* `Offline Entitlements`: fixed iOS 12 tests (#2514) via NachoSoto
(@NachoSoto)
* `PurchasedProductsFetcher`: don't throw errors if purchased products
were found (#2506) via NachoSoto (@NachoSoto)
* `Offline Entitlements`: allow creating offline `CustomerInfo` with
empty `ProductEntitlementMapping` (#2504) via NachoSoto (@NachoSoto)
* `Offline Entitlements`: integration tests (#2501) via NachoSoto
(@NachoSoto)
* `CustomerInfoManager`: don't cache offline `CustomerInfo` (#2378) via
NachoSoto (@NachoSoto)
* `DangerousSettings`: debug-only `forceServerErrors` (#2486) via
NachoSoto (@NachoSoto)
* `CocoapodsInstallation`: fixed `Xcode 14.3.0` issue (#2489) via
NachoSoto (@NachoSoto)
* `CarthageInstallation`: removed workaround (#2488) via NachoSoto
(@NachoSoto)

---------

Co-authored-by: NachoSoto <ignaciosoto90@gmail.com>
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.

2 participants