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

TransactionPoster: added transaction ID and Date to log #3026

Merged
merged 2 commits into from
Aug 16, 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
10 changes: 7 additions & 3 deletions Sources/Logging/Strings/PurchaseStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ enum PurchaseStrings {
case begin_refund_customer_info_error(entitlementID: String?)
case missing_cached_customer_info
case sk2_transactions_update_received_transaction(productID: String)
case transaction_poster_handling_transaction(productID: String, offeringID: String?)
case transaction_poster_handling_transaction(transactionID: String,
productID: String,
transactionDate: Date,
offeringID: String?)
case caching_presented_offering_identifier(offeringID: String, productID: String)
case payment_queue_wrapper_delegate_call_sk1_enabled
case restorepurchases_called_with_allow_sharing_appstore_account_false
Expand Down Expand Up @@ -298,8 +301,9 @@ extension PurchaseStrings: LogMessage {
case let .sk2_transactions_update_received_transaction(productID):
return "StoreKit.Transaction.updates: received transaction for product '\(productID)'"

case let .transaction_poster_handling_transaction(productID, offeringID):
let prefix = "TransactionPoster: handling transaction for product '\(productID)'"
case let .transaction_poster_handling_transaction(transactionID, productID, date, offeringID):
let prefix = "TransactionPoster: handling transaction '\(transactionID)' " +
"for product '\(productID)' (date: \(date))"

if let offeringIdentifier = offeringID {
return prefix + " in Offering '\(offeringIdentifier)'"
Expand Down
2 changes: 2 additions & 0 deletions Sources/Purchasing/Purchases/TransactionPoster.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ final class TransactionPoster: TransactionPosterType {
data: PurchasedTransactionData,
completion: @escaping CustomerAPI.CustomerInfoResponseHandler) {
Logger.debug(Strings.purchase.transaction_poster_handling_transaction(
transactionID: transaction.transactionIdentifier,
productID: transaction.productIdentifier,
transactionDate: transaction.purchaseDate,
offeringID: data.presentedOfferingID
))

Expand Down
8 changes: 6 additions & 2 deletions Tests/BackendIntegrationTests/StoreKitIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ class StoreKit1IntegrationTests: BaseStoreKitIntegrationTests {

func testCanPurchasePackage() async throws {
let package = try await self.monthlyPackage
try await self.purchaseMonthlyOffering()
let transaction = try await XCTAsyncUnwrap(try await self.purchaseMonthlyOffering().transaction)

self.logger.verifyMessageWasLogged(
Strings.purchase.transaction_poster_handling_transaction(
transactionID: transaction.transactionIdentifier,
productID: package.storeProduct.productIdentifier,
transactionDate: transaction.purchaseDate,
offeringID: package.offeringIdentifier
)
)
Expand Down Expand Up @@ -88,11 +90,13 @@ class StoreKit1IntegrationTests: BaseStoreKitIntegrationTests {
productIdentifier: package.storeProduct.productIdentifier
)

try await self.purchaseMonthlyProduct()
let transaction = try await XCTAsyncUnwrap(try await self.purchaseMonthlyProduct().transaction)

self.logger.verifyMessageWasLogged(
Strings.purchase.transaction_poster_handling_transaction(
transactionID: transaction.transactionIdentifier,
productID: package.storeProduct.productIdentifier,
transactionDate: transaction.purchaseDate,
offeringID: package.offeringIdentifier
)
)
Expand Down