Skip to content

Commit

Permalink
TimingUtil: removed slow purchase logs (#2677)
Browse files Browse the repository at this point in the history
  • Loading branch information
NachoSoto authored Jun 20, 2023
1 parent c9b36e5 commit cde63f2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
8 changes: 0 additions & 8 deletions Sources/Logging/Strings/PurchaseStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ enum PurchaseStrings {
case sk2_transactions_update_received_transaction(productID: String)
case transaction_poster_handling_transaction(productID: String, offeringID: String?)
case caching_presented_offering_identifier(offeringID: String, productID: String)
case sk1_purchase_too_slow
case sk2_purchase_too_slow
case payment_queue_wrapper_delegate_call_sk1_enabled
case restorepurchases_called_with_allow_sharing_appstore_account_false

Expand Down Expand Up @@ -297,12 +295,6 @@ extension PurchaseStrings: LogMessage {
case let .caching_presented_offering_identifier(offeringID, productID):
return "Caching presented offering identifier '\(offeringID)' for product '\(productID)'"

case .sk1_purchase_too_slow:
return "StoreKit 1 purchase took longer than expected"

case .sk2_purchase_too_slow:
return "StoreKit 2 purchase took longer than expected"

case .payment_queue_wrapper_delegate_call_sk1_enabled:
return "Unexpectedly received PaymentQueueWrapperDelegate call with SK1 enabled"

Expand Down
1 change: 0 additions & 1 deletion Sources/Purchasing/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ extension Configuration {
internal enum TimingThreshold: TimingUtil.Duration {

case productRequest = 3
case purchase = 7
case introEligibility = 2
case purchasedProducts = 1

Expand Down
28 changes: 12 additions & 16 deletions Sources/Purchasing/Purchases/PurchasesOrchestrator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -440,24 +440,20 @@ final class PurchasesOrchestrator {
let result: Product.PurchaseResult

do {
result = try await TimingUtil.measureAndLogIfTooSlow(
threshold: .purchase,
message: Strings.purchase.sk2_purchase_too_slow.description) {
var options: Set<Product.PurchaseOption> = [
.simulatesAskToBuyInSandbox(Purchases.simulatesAskToBuyInSandbox)
]

if let signedData = promotionalOffer {
Logger.debug(
Strings.storeKit.sk2_purchasing_added_promotional_offer_option(signedData.identifier)
)
options.insert(try signedData.sk2PurchaseOption)
}
var options: Set<Product.PurchaseOption> = [
.simulatesAskToBuyInSandbox(Purchases.simulatesAskToBuyInSandbox)
]

self.cachePresentedOfferingIdentifier(package: package, productIdentifier: sk2Product.id)
if let signedData = promotionalOffer {
Logger.debug(
Strings.storeKit.sk2_purchasing_added_promotional_offer_option(signedData.identifier)
)
options.insert(try signedData.sk2PurchaseOption)
}

return try await sk2Product.purchase(options: options)
}
self.cachePresentedOfferingIdentifier(package: package, productIdentifier: sk2Product.id)

result = try await sk2Product.purchase(options: options)
} catch StoreKitError.userCancelled {
guard !self.systemInfo.dangerousSettings.customEntitlementComputation else {
throw ErrorUtils.purchaseCancelledError()
Expand Down

0 comments on commit cde63f2

Please sign in to comment.