Skip to content

Commit

Permalink
debugRevenueCatOverlay improvements
Browse files Browse the repository at this point in the history
- Separate `User ID` and `Original User ID`
- Share button to be able to copy / send configuration as pretty-printed JSON
  • Loading branch information
NachoSoto committed Jun 7, 2023
1 parent 3b53f24 commit 1c29f30
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
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

0 comments on commit 1c29f30

Please sign in to comment.