From 2455c5397eec237e268064844e668aff9ff020b2 Mon Sep 17 00:00:00 2001 From: Davide Date: Wed, 23 Oct 2024 17:32:49 +0200 Subject: [PATCH] Attach provider ID to issue report Fixes #710 --- .../Sources/AppUI/Domain/Issue+Metadata.swift | 5 ++++- .../Library/Sources/AppUI/Domain/Issue.swift | 17 ++++++++++++++--- .../Views/Diagnostics/DiagnosticsView.swift | 2 +- .../Views/Diagnostics/ReportIssueButton.swift | 12 ++++++++++++ .../Diagnostics/iOS/ReportIssueButton+iOS.swift | 1 + .../macOS/ReportIssueButton+macOS.swift | 1 + .../AppUI/Views/UI/View+Environment.swift | 1 + 7 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Passepartout/Library/Sources/AppUI/Domain/Issue+Metadata.swift b/Passepartout/Library/Sources/AppUI/Domain/Issue+Metadata.swift index da1aeb11..fa856773 100644 --- a/Passepartout/Library/Sources/AppUI/Domain/Issue+Metadata.swift +++ b/Passepartout/Library/Sources/AppUI/Domain/Issue+Metadata.swift @@ -29,6 +29,8 @@ import PassepartoutKit extension Issue { struct Metadata { + let profile: Profile? + let configuration: PassepartoutConfiguration let versionString: String @@ -70,7 +72,8 @@ extension Issue { appLine: "\(Strings.Unlocalized.appName) \(metadata.versionString)", purchasedProducts: metadata.purchasedProducts, appLog: appLog, - tunnelLog: tunnelLog + tunnelLog: tunnelLog, + providerId: metadata.profile?.firstProviderModuleWithMetadata?.1.id ) } } diff --git a/Passepartout/Library/Sources/AppUI/Domain/Issue.swift b/Passepartout/Library/Sources/AppUI/Domain/Issue.swift index f915791e..668ceec6 100644 --- a/Passepartout/Library/Sources/AppUI/Domain/Issue.swift +++ b/Passepartout/Library/Sources/AppUI/Domain/Issue.swift @@ -26,11 +26,13 @@ #if os(iOS) import CommonLibrary import Foundation +import PassepartoutKit import UIKit #else import AppKit import CommonLibrary import Foundation +import PassepartoutKit #endif struct Issue: Identifiable { @@ -48,7 +50,15 @@ struct Issue: Identifiable { let deviceLine: String? - init(appLine: String?, purchasedProducts: Set, appLog: Data? = nil, tunnelLog: Data? = nil) { + let providerName: String? + + init( + appLine: String?, + purchasedProducts: Set, + appLog: Data? = nil, + tunnelLog: Data? = nil, + providerId: ProviderID? + ) { id = UUID() self.appLine = appLine self.purchasedProducts = purchasedProducts @@ -74,6 +84,8 @@ struct Issue: Identifiable { osLine = "\(osName) \(osVersion)" deviceLine = deviceType + + providerName = providerId?.rawValue } var body: String { @@ -81,8 +93,7 @@ struct Issue: Identifiable { .replacingOccurrences(of: "$appLine", with: appLine ?? "unknown") .replacingOccurrences(of: "$osLine", with: osLine) .replacingOccurrences(of: "$deviceLine", with: deviceLine ?? "unknown") - // FIXME: #710, report provider in issue - .replacingOccurrences(of: "$providerName", with: "none") + .replacingOccurrences(of: "$providerName", with: providerName ?? "none") .replacingOccurrences(of: "$providerLastUpdate", with: "unknown") .replacingOccurrences(of: "$purchasedProducts", with: purchasedProducts.map(\.rawValue).description) } diff --git a/Passepartout/Library/Sources/AppUI/Views/Diagnostics/DiagnosticsView.swift b/Passepartout/Library/Sources/AppUI/Views/Diagnostics/DiagnosticsView.swift index 28bfbf8d..3e3c5277 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Diagnostics/DiagnosticsView.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Diagnostics/DiagnosticsView.swift @@ -45,7 +45,7 @@ struct DiagnosticsView: View { private var connectionObserver: ConnectionObserver @EnvironmentObject - var iapManager: IAPManager + private var iapManager: IAPManager @AppStorage(AppPreference.logsPrivateData.key, store: .appGroup) private var logsPrivateData = false diff --git a/Passepartout/Library/Sources/AppUI/Views/Diagnostics/ReportIssueButton.swift b/Passepartout/Library/Sources/AppUI/Views/Diagnostics/ReportIssueButton.swift index f040bebe..b4e2ad61 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Diagnostics/ReportIssueButton.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Diagnostics/ReportIssueButton.swift @@ -23,10 +23,15 @@ // along with Passepartout. If not, see . // +import AppLibrary import PassepartoutKit import SwiftUI struct ReportIssueButton { + + @EnvironmentObject + private var profileManager: ProfileManager + let tunnel: Tunnel let title: String @@ -41,4 +46,11 @@ struct ReportIssueButton { @State var issueBeingReported: Issue? + + var installedProfile: Profile? { + guard let id = tunnel.currentProfile?.id else { + return nil + } + return profileManager.profile(withId: id) + } } diff --git a/Passepartout/Library/Sources/AppUI/Views/Diagnostics/iOS/ReportIssueButton+iOS.swift b/Passepartout/Library/Sources/AppUI/Views/Diagnostics/iOS/ReportIssueButton+iOS.swift index 6b690c19..91793f31 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Diagnostics/iOS/ReportIssueButton+iOS.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Diagnostics/iOS/ReportIssueButton+iOS.swift @@ -69,6 +69,7 @@ private extension ReportIssueButton { isPending = false } let issue = await Issue.withMetadata(.init( + profile: installedProfile, configuration: .shared, versionString: BundleConfiguration.mainVersionString, purchasedProducts: purchasedProducts, diff --git a/Passepartout/Library/Sources/AppUI/Views/Diagnostics/macOS/ReportIssueButton+macOS.swift b/Passepartout/Library/Sources/AppUI/Views/Diagnostics/macOS/ReportIssueButton+macOS.swift index 064bfd71..35311d9e 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Diagnostics/macOS/ReportIssueButton+macOS.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Diagnostics/macOS/ReportIssueButton+macOS.swift @@ -50,6 +50,7 @@ private extension ReportIssueButton { return } let issue = await Issue.withMetadata(.init( + profile: installedProfile, configuration: .shared, versionString: BundleConfiguration.mainVersionString, purchasedProducts: purchasedProducts, diff --git a/Passepartout/Library/Sources/AppUI/Views/UI/View+Environment.swift b/Passepartout/Library/Sources/AppUI/Views/UI/View+Environment.swift index a9642c42..5e95cbec 100644 --- a/Passepartout/Library/Sources/AppUI/Views/UI/View+Environment.swift +++ b/Passepartout/Library/Sources/AppUI/Views/UI/View+Environment.swift @@ -31,6 +31,7 @@ extension View { public func withEnvironment(from context: AppContext, theme: Theme) -> some View { environmentObject(theme) .environmentObject(context.iapManager) + .environmentObject(context.profileManager) .environmentObject(context.profileProcessor) .environmentObject(context.connectionObserver) .environmentObject(context.providerManager)