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

[Release PR] Add StoreKit debugging metadata to the debug menu #3637

Merged
merged 2 commits into from
Nov 29, 2024
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
35 changes: 27 additions & 8 deletions DuckDuckGo/Debug.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -1001,12 +1001,28 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" id="gpq-tH-ki5">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" textLabel="Geg-YQ-MpF" detailTextLabel="zsc-Ui-Vd6" style="IBUITableViewCellStyleValue1" id="gpq-tH-ki5">
<rect key="frame" x="0.0" y="50" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="gpq-tH-ki5" id="Jxo-Ud-82c">
<rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Geg-YQ-MpF">
<rect key="frame" x="20" y="12" width="33" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="zsc-Ui-Vd6">
<rect key="frame" x="350" y="12" width="44" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
Expand All @@ -1031,17 +1047,17 @@
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="ConfigurationURLTableViewCell" id="i6Y-Di-PX3" customClass="ConfigurationURLTableViewCell" customModule="DuckDuckGo" customModuleProvider="target">
<rect key="frame" x="0.0" y="50" width="414" height="94.5"/>
<rect key="frame" x="0.0" y="50" width="414" height="95"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="i6Y-Di-PX3" id="qn4-gq-5fa">
<rect key="frame" x="0.0" y="0.0" width="414" height="94.5"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="95"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="pKD-Xm-Eu1">
<rect key="frame" x="20" y="11" width="374" height="72.5"/>
<rect key="frame" x="20" y="11" width="374" height="73"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="j3A-OZ-DWy">
<rect key="frame" x="0.0" y="0.0" width="44" height="72.5"/>
<rect key="frame" x="0.0" y="0.0" width="44" height="73"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="gKw-J7-XIW">
<rect key="frame" x="0.0" y="0.0" width="44" height="24"/>
Expand All @@ -1051,22 +1067,22 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Subtitle" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="UrI-B0-rWf">
<rect key="frame" x="0.0" y="24" width="44" height="24"/>
<rect key="frame" x="0.0" y="24" width="44" height="24.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" name="accent"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6RK-ug-mZa">
<rect key="frame" x="0.0" y="48.5" width="44" height="24"/>
<rect key="frame" x="0.0" y="49" width="44" height="24"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Nkj-yK-cgm">
<rect key="frame" x="350" y="0.0" width="24" height="72.5"/>
<rect key="frame" x="350" y="0.0" width="24" height="73"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="Reload-24"/>
</button>
Expand Down Expand Up @@ -1125,6 +1141,9 @@
<systemColor name="labelColor">
<color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="secondaryLabelColor">
<color red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
Expand Down
41 changes: 40 additions & 1 deletion DuckDuckGo/SubscriptionDebugViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import UIKit
import Subscription
import Core
import NetworkProtection
import StoreKit

final class SubscriptionDebugViewController: UITableViewController {

Expand All @@ -39,6 +40,7 @@ final class SubscriptionDebugViewController: UITableViewController {
Sections.appstore: "App Store",
Sections.environment: "Environment",
Sections.pixels: "Promo Pixel Parameters",
Sections.metadata: "StoreKit Metadata"
]

enum Sections: Int, CaseIterable {
Expand All @@ -47,6 +49,7 @@ final class SubscriptionDebugViewController: UITableViewController {
case appstore
case environment
case pixels
case metadata
}

enum AuthorizationRows: Int, CaseIterable {
Expand Down Expand Up @@ -74,10 +77,23 @@ final class SubscriptionDebugViewController: UITableViewController {
case randomize
}

enum MetadataRows: Int, CaseIterable {
case storefrontID
case countryCode
}

private var storefrontID = "Loading"
private var storefrontCountryCode = "Loading"
samsymons marked this conversation as resolved.
Show resolved Hide resolved

override func numberOfSections(in tableView: UITableView) -> Int {
return Sections.allCases.count
}

override func viewDidLoad() {
super.viewDidLoad()
loadStoreKitMetadata()
}

override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
guard let section = Sections(rawValue: section) else { return nil }
return titles[section]
Expand Down Expand Up @@ -145,6 +161,18 @@ final class SubscriptionDebugViewController: UITableViewController {
case .none:
break
}

case .metadata:
switch MetadataRows(rawValue: indexPath.row) {
case .storefrontID:
cell.textLabel?.text = "Storefront ID"
cell.detailTextLabel?.text = storefrontID
case .countryCode:
cell.textLabel?.text = "Country Code"
cell.detailTextLabel?.text = storefrontCountryCode
case .none:
break
}
case .none:
break
}
Expand All @@ -159,8 +187,8 @@ final class SubscriptionDebugViewController: UITableViewController {
case .appstore: return AppStoreRows.allCases.count
case .environment: return EnvironmentRows.allCases.count
case .pixels: return PixelsRows.allCases.count
case .metadata: return MetadataRows.allCases.count
case .none: return 0

}
}

Expand Down Expand Up @@ -193,6 +221,8 @@ final class SubscriptionDebugViewController: UITableViewController {
case .randomize: showRandomizedParamters()
default: break
}
case .metadata:
break
case .none:
break
}
Expand Down Expand Up @@ -389,6 +419,15 @@ final class SubscriptionDebugViewController: UITableViewController {
NetworkProtectionLocationListCompositeRepository.clearCache()
}
}

private func loadStoreKitMetadata() {
Task { @MainActor in
let storefront = await Storefront.current
self.storefrontID = storefront?.id ?? "nil"
self.storefrontCountryCode = storefront?.countryCode ?? "nil"
self.tableView.reloadData()
}
}
}

extension Bool {
Expand Down
Loading