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

debugRevenueCatOverlay improvements #2594

Merged
merged 1 commit into from
Jun 8, 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
31 changes: 20 additions & 11 deletions Sources/Support/DebugUI/DebugContentViews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,19 @@ private struct DebugSummaryView: View {
Text("Loading...")

case let .loaded(config):
LabeledContent("SDK version", value: SystemInfo.frameworkVersion)
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.display)
LabeledContent("Entitlement Verification Mode", value: config.verificationMode)

ShareLink(item: config, preview: .init("Configuration")) {
Label("Share", systemImage: "square.and.arrow.up")

}
.frame(maxWidth: .infinity)
}
}
}
Expand All @@ -113,7 +119,8 @@ private struct DebugSummaryView: View {
Text("Loading...")

case let .loaded(info):
LabeledContent("User ID", value: info.originalAppUserId)
LabeledContent("User ID", value: Purchases.shared.appUserID)
LabeledContent("Original User ID", value: info.originalAppUserId)
LabeledContent("Active Entitlements", value: info.entitlements.active.count.description)

if let latestExpiration = info.latestExpirationDate {
Expand Down Expand Up @@ -240,14 +247,16 @@ private struct DebugPackageView: View {

}

private extension Signing.ResponseVerificationMode {

var display: String {
switch self {
case .disabled: return "disabled"
case .informational: return "informational"
case .enforced: return "enforced"
}
@available(iOS 16.0, *)
extension DebugViewModel.Configuration: Transferable {

static var transferRepresentation: some TransferRepresentation {
return CodableRepresentation(
for: DebugViewModel.Configuration.self,
contentType: .plainText,
encoder: JSONEncoder.prettyPrinted,
decoder: JSONDecoder.default
)
}

}
Expand Down
27 changes: 20 additions & 7 deletions Sources/Support/DebugUI/DebugViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ import SwiftUI
@available(iOS 16.0, *)
final class DebugViewModel: ObservableObject {

struct Configuration {
struct Configuration: Codable {

let observerMode: Bool
let sandbox: Bool
let storeKit2Enabled: Bool
let offlineCustomerInfoSupport: Bool
let verificationMode: Signing.ResponseVerificationMode
var sdkVersion: String = SystemInfo.frameworkVersion
var observerMode: Bool
var sandbox: Bool
var storeKit2Enabled: Bool
var offlineCustomerInfoSupport: Bool
var verificationMode: String

}

Expand Down Expand Up @@ -121,10 +122,22 @@ private extension DebugViewModel.Configuration {
sandbox: purchases.isSandbox,
storeKit2Enabled: purchases.storeKit2Setting.isEnabledAndAvailable,
offlineCustomerInfoSupport: purchases.offlineCustomerInfoEnabled,
verificationMode: purchases.responseVerificationMode
verificationMode: purchases.responseVerificationMode.display
)
}

}

private extension Signing.ResponseVerificationMode {

var display: String {
switch self {
case .disabled: return "disabled"
case .informational: return "informational"
case .enforced: return "enforced"
}
}

}

#endif