Skip to content

OfflineEntitlementsManager: disable offline CustomerInfo in observer mode#2520

Merged
NachoSoto merged 3 commits into
mainfrom
nacho/sdk-3140-offline-entitlements-disable-feature-in
May 24, 2023
Merged

OfflineEntitlementsManager: disable offline CustomerInfo in observer mode#2520
NachoSoto merged 3 commits into
mainfrom
nacho/sdk-3140-offline-entitlements-disable-feature-in

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

No description provided.

@NachoSoto NachoSoto requested a review from a team May 22, 2023 19:05
@NachoSoto NachoSoto force-pushed the nacho/sdk-3140-offline-entitlements-disable-feature-in branch from 96d8e61 to 0463104 Compare May 22, 2023 19:05
@codecov

codecov Bot commented May 22, 2023

Copy link
Copy Markdown

Codecov Report

Merging #2520 (d4621ff) into main (2dcac57) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #2520      +/-   ##
==========================================
+ Coverage   87.85%   87.90%   +0.05%     
==========================================
  Files         199      199              
  Lines       13721    13729       +8     
==========================================
+ Hits        12054    12068      +14     
+ Misses       1667     1661       -6     
Impacted Files Coverage Δ
...s/Logging/Strings/OfflineEntitlementsStrings.swift 84.31% <100.00%> (+1.96%) ⬆️
Sources/Networking/Backend.swift 89.13% <100.00%> (+0.36%) ⬆️
...flineEntitlements/OfflineCustomerInfoCreator.swift 91.22% <100.00%> (+3.50%) ⬆️
...flineEntitlements/OfflineEntitlementsManager.swift 100.00% <100.00%> (ø)
Sources/Purchasing/Purchases/Purchases.swift 77.29% <100.00%> (+0.11%) ⬆️

... and 1 file with indirect coverage changes


func shouldComputeOfflineCustomerInfo(appUserID: String) -> Bool {
return self.deviceCache.cachedCustomerInfoData(appUserID: appUserID) == nil
return (!self.systemInfo.observerMode &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I also disabled getting the product-entitlement mapping in observer mode... Shouldn't really matter but it would further reduce unneeded operations in observer mode. Probably a good idea to not do that there as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea.

Comment thread Sources/OfflineEntitlements/OfflineEntitlementsManager.swift Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the thorough review @tonidero.
I moved the checks to OfflineCustomerInfoCreator.createIfAvailable, so none of the offline stuff is created in observer mode.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also added this @tonidero

@NachoSoto NachoSoto force-pushed the nacho/sdk-3140-offline-entitlements-disable-feature-in branch from f5f24b5 to f699abe Compare May 23, 2023 17:01

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@tonidero also added these tests to ensure the SDK is configured correctly.

@NachoSoto NachoSoto force-pushed the nacho/sdk-3140-offline-entitlements-disable-feature-in branch from f699abe to d4621ff Compare May 23, 2023 17:02
@NachoSoto NachoSoto requested a review from tonidero May 23, 2023 17:02

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great!

completion: (@MainActor @Sendable (Result<(), Error>) -> Void)?
) {
guard #available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *),
!self.systemInfo.observerMode,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This logic lives both in OfflineEntitlementsManager and in OfflineCustomerInfoCreator. It would be great to unify it, but probably not a blocker.

@NachoSoto NachoSoto merged commit c48b080 into main May 24, 2023
@NachoSoto NachoSoto deleted the nacho/sdk-3140-offline-entitlements-disable-feature-in branch May 24, 2023 18:51
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