Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimingUtil: removed slow purchase logs #2677

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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