Skip to content

Commit

Permalink
debugRevenueCatOverlay: display receiptURL
Browse files Browse the repository at this point in the history
Useful when debugging issues like #2558.
  • Loading branch information
NachoSoto committed Jun 15, 2023
1 parent 1637db2 commit 59cc794
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
4 changes: 4 additions & 0 deletions Sources/Purchasing/Purchases/Purchases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,10 @@ internal extension Purchases {
return self.systemInfo.responseVerificationMode.publicKey
}

var receiptURL: URL? {
return self.receiptFetcher.receiptURL
}

}

#endif
Expand Down
43 changes: 33 additions & 10 deletions Sources/Support/DebugUI/DebugContentViews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
import StoreKit
import SwiftUI

#if os(macOS)
import AppKit
#endif

// swiftlint:disable file_length

@available(iOS 16.0, macOS 13.0, *)
struct DebugSwiftUIRootView: View {

Expand Down Expand Up @@ -113,18 +119,35 @@ internal struct DebugSummaryView: View {
Text("Loading...")

case let .loaded(config):
LabeledContent("SDK version", value: config.sdkVersion)
LabeledContent("Observer mode", value: config.observerMode.description)
LabeledContent("Sandbox", value: config.sandbox.description)
LabeledContent("StoreKit 2", value: config.storeKit2Enabled ? "on" : "off")
LabeledContent("Offline Customer Info",
value: config.offlineCustomerInfoSupport ? "enabled" : "disabled")
LabeledContent("Entitlement Verification Mode", value: config.verificationMode)

ShareLink(item: config, preview: .init("Configuration")) {
Label("Share", systemImage: "square.and.arrow.up")
Group {
LabeledContent("SDK version", value: config.sdkVersion)
LabeledContent("Observer mode", value: config.observerMode.description)
LabeledContent("Sandbox", value: config.sandbox.description)
LabeledContent("StoreKit 2", value: config.storeKit2Enabled ? "on" : "off")
LabeledContent("Offline Customer Info",
value: config.offlineCustomerInfoSupport ? "enabled" : "disabled")
LabeledContent("Entitlement Verification Mode", value: config.verificationMode)
LabeledContent("Receipt URL", value: config.receiptURL?.absoluteString ?? "")
#if os(macOS)
.contextMenu {
Button {
if let url = config.receiptURL {
NSWorkspace.shared.selectFile(
nil,
inFileViewerRootedAtPath: url.deletingLastPathComponent().path
)
}
} label: {
Text("Show in Finder")
}
}
#endif

ShareLink(item: config, preview: .init("Configuration")) {
Label("Share", systemImage: "square.and.arrow.up")
}
}
.textSelection(.enabled)
.frame(maxWidth: .infinity)
}
}
Expand Down
4 changes: 3 additions & 1 deletion Sources/Support/DebugUI/DebugViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ final class DebugViewModel: ObservableObject {
var storeKit2Enabled: Bool
var offlineCustomerInfoSupport: Bool
var verificationMode: String
var receiptURL: URL?

}

Expand Down Expand Up @@ -125,7 +126,8 @@ private extension DebugViewModel.Configuration {
sandbox: purchases.isSandbox,
storeKit2Enabled: purchases.storeKit2Setting.isEnabledAndAvailable,
offlineCustomerInfoSupport: purchases.offlineCustomerInfoEnabled,
verificationMode: purchases.responseVerificationMode.display
verificationMode: purchases.responseVerificationMode.display,
receiptURL: purchases.receiptURL
)
}

Expand Down

0 comments on commit 59cc794

Please sign in to comment.