Skip to content

PostReceiptDataOperation: print receipt data if debug logs are enabled#1940

Merged
NachoSoto merged 3 commits into
mainfrom
post-receipt-operation-log-receipt
Sep 27, 2022
Merged

PostReceiptDataOperation: print receipt data if debug logs are enabled#1940
NachoSoto merged 3 commits into
mainfrom
post-receipt-operation-log-receipt

Conversation

@NachoSoto

@NachoSoto NachoSoto commented Sep 27, 2022

Copy link
Copy Markdown
Contributor

For CSDK-478.
Follow up to #1929.

Example:

DEBUG: ℹ️ PostReceiptDataOperation: Started
INFO: ℹ️ Receipt parsed successfully
DEBUG: ℹ️ PostReceiptDataOperation: Posting receipt: {
"opaque_value" : "Rn/39QYAAAA=",
"sha1_hash" : "Ii8Z7ocZm524eJcWFOvVauNrNHs=",
"bundle_id" : "com.revenuecat.StoreKitTestApp",
"in_app_purchases" : [
{
"quantity" : 1,
"product_id" : "com.revenuecat.monthly_4.99.1_week_intro",
"purchase_date" : "2022-09-27T19:09:47Z",
"transaction_id" : "0",
"is_in_intro_offer_period" : true,
"expires_date" : "2022-09-27T19:09:57Z"
}
],
"application_version" : "1",
"creation_date" : "2022-09-27T19:09:47Z",
"expiration_date" : "4001-01-01T00:00:00Z"
}
DEBUG: ℹ️ There are no requests currently running, starting request POST receipts
DEBUG: ℹ️ API request started: POST /v1/receipts
DEBUG: ℹ️ API request completed: POST /v1/receipts 200
DEBUG: ℹ️ PostReceiptDataOperation: Finished
DEBUG: ℹ️ Serial request done: POST receipts, 0 requests left in the queue
DEBUG: ℹ️ Sending updated CustomerInfo to delegate.
INFO: 😻💰 Purchased product - 'com.revenuecat.monthly_4.99.1_week_intro'
INFO: 💰 Finishing transaction com.revenuecat.monthly_4.99.1_week_intro 0 ()

@NachoSoto NachoSoto requested review from a team and aboedo September 27, 2022 19:08
@NachoSoto NachoSoto changed the title PostReceiptDataOperation: print receipt data if debug logs are enabled PostReceiptDataOperation: print receipt data if debug logs are enabled Sep 27, 2022

@aboedo aboedo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is gonna save a tooon of time when debugging

Comment on lines +137 to +145
static let prettyPrinted: JSONEncoder = {
let encoder = JSONEncoder()
encoder.keyEncodingStrategy = .convertToSnakeCase
encoder.dateEncodingStrategy = .iso8601
encoder.outputFormatting = .prettyPrinted

return encoder
}()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👏 I just went through the terrible experience of formatting some receipts we had printed with the default format and it was terrible

Comment thread Sources/Networking/Operations/PostReceiptDataOperation.swift Outdated
case parsing_receipt
case refreshing_empty_receipt
case unable_to_load_receipt
case posting_receipt(AppleReceipt)

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.

Type-safe logging APIs FTW

do {
let receipt = try await Purchases.shared.fetchReceipt(.always)
let description = receipt.map { $0.description } ?? "<null>"
let description = receipt.map { $0.debugDescription } ?? "<null>"

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.

Using the new code from tests as well.

@NachoSoto NachoSoto merged commit b32859d into main Sep 27, 2022
@NachoSoto NachoSoto deleted the post-receipt-operation-log-receipt branch September 27, 2022 19:50
NachoSoto pushed a commit that referenced this pull request Sep 28, 2022
**This is an automatic release.**

### Other Changes
* `ProductsFetcherSK2`: removed now redundant caching logic (#1908) via
NachoSoto (@NachoSoto)
* Created `CachingProductsManager` to provide consistent caching logic
when fetching products (#1907) via NachoSoto (@NachoSoto)
* Refactored `ReceiptFetcher.receiptData` (#1941) via NachoSoto
(@NachoSoto)
* Abstracted conversion from `async` to completion-block APIs (#1943)
via NachoSoto (@NachoSoto)
* Moved `InAppPurchase` into `AppleReceipt` (#1942) via NachoSoto
(@NachoSoto)
* `Purchases+async`: combined `@available` statements into a single one
(#1944) via NachoSoto (@NachoSoto)
* `Integration Tests`: don't initialize `Purchases` until the
`SKTestSession` has been re-created (#1946) via NachoSoto (@NachoSoto)
* `PostReceiptDataOperation`: print receipt data if `debug` logs are
enabled (#1940) via NachoSoto (@NachoSoto)

Co-authored-by: RCGitBot <dev+RCGitBot@revenuecat.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