Attach provider ID to issue report

Fixes #710
This commit is contained in:
Davide 2024-10-23 17:32:49 +02:00
parent 295ba4d662
commit 2455c5397e
No known key found for this signature in database
GPG Key ID: A48836171C759F5E
7 changed files with 34 additions and 5 deletions

View File

@ -29,6 +29,8 @@ import PassepartoutKit
extension Issue { extension Issue {
struct Metadata { struct Metadata {
let profile: Profile?
let configuration: PassepartoutConfiguration let configuration: PassepartoutConfiguration
let versionString: String let versionString: String
@ -70,7 +72,8 @@ extension Issue {
appLine: "\(Strings.Unlocalized.appName) \(metadata.versionString)", appLine: "\(Strings.Unlocalized.appName) \(metadata.versionString)",
purchasedProducts: metadata.purchasedProducts, purchasedProducts: metadata.purchasedProducts,
appLog: appLog, appLog: appLog,
tunnelLog: tunnelLog tunnelLog: tunnelLog,
providerId: metadata.profile?.firstProviderModuleWithMetadata?.1.id
) )
} }
} }

View File

@ -26,11 +26,13 @@
#if os(iOS) #if os(iOS)
import CommonLibrary import CommonLibrary
import Foundation import Foundation
import PassepartoutKit
import UIKit import UIKit
#else #else
import AppKit import AppKit
import CommonLibrary import CommonLibrary
import Foundation import Foundation
import PassepartoutKit
#endif #endif
struct Issue: Identifiable { struct Issue: Identifiable {
@ -48,7 +50,15 @@ struct Issue: Identifiable {
let deviceLine: String? let deviceLine: String?
init(appLine: String?, purchasedProducts: Set<AppProduct>, appLog: Data? = nil, tunnelLog: Data? = nil) { let providerName: String?
init(
appLine: String?,
purchasedProducts: Set<AppProduct>,
appLog: Data? = nil,
tunnelLog: Data? = nil,
providerId: ProviderID?
) {
id = UUID() id = UUID()
self.appLine = appLine self.appLine = appLine
self.purchasedProducts = purchasedProducts self.purchasedProducts = purchasedProducts
@ -74,6 +84,8 @@ struct Issue: Identifiable {
osLine = "\(osName) \(osVersion)" osLine = "\(osName) \(osVersion)"
deviceLine = deviceType deviceLine = deviceType
providerName = providerId?.rawValue
} }
var body: String { var body: String {
@ -81,8 +93,7 @@ struct Issue: Identifiable {
.replacingOccurrences(of: "$appLine", with: appLine ?? "unknown") .replacingOccurrences(of: "$appLine", with: appLine ?? "unknown")
.replacingOccurrences(of: "$osLine", with: osLine) .replacingOccurrences(of: "$osLine", with: osLine)
.replacingOccurrences(of: "$deviceLine", with: deviceLine ?? "unknown") .replacingOccurrences(of: "$deviceLine", with: deviceLine ?? "unknown")
// FIXME: #710, report provider in issue .replacingOccurrences(of: "$providerName", with: providerName ?? "none")
.replacingOccurrences(of: "$providerName", with: "none")
.replacingOccurrences(of: "$providerLastUpdate", with: "unknown") .replacingOccurrences(of: "$providerLastUpdate", with: "unknown")
.replacingOccurrences(of: "$purchasedProducts", with: purchasedProducts.map(\.rawValue).description) .replacingOccurrences(of: "$purchasedProducts", with: purchasedProducts.map(\.rawValue).description)
} }

View File

@ -45,7 +45,7 @@ struct DiagnosticsView: View {
private var connectionObserver: ConnectionObserver private var connectionObserver: ConnectionObserver
@EnvironmentObject @EnvironmentObject
var iapManager: IAPManager private var iapManager: IAPManager
@AppStorage(AppPreference.logsPrivateData.key, store: .appGroup) @AppStorage(AppPreference.logsPrivateData.key, store: .appGroup)
private var logsPrivateData = false private var logsPrivateData = false

View File

@ -23,10 +23,15 @@
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>. // along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
// //
import AppLibrary
import PassepartoutKit import PassepartoutKit
import SwiftUI import SwiftUI
struct ReportIssueButton { struct ReportIssueButton {
@EnvironmentObject
private var profileManager: ProfileManager
let tunnel: Tunnel let tunnel: Tunnel
let title: String let title: String
@ -41,4 +46,11 @@ struct ReportIssueButton {
@State @State
var issueBeingReported: Issue? var issueBeingReported: Issue?
var installedProfile: Profile? {
guard let id = tunnel.currentProfile?.id else {
return nil
}
return profileManager.profile(withId: id)
}
} }

View File

@ -69,6 +69,7 @@ private extension ReportIssueButton {
isPending = false isPending = false
} }
let issue = await Issue.withMetadata(.init( let issue = await Issue.withMetadata(.init(
profile: installedProfile,
configuration: .shared, configuration: .shared,
versionString: BundleConfiguration.mainVersionString, versionString: BundleConfiguration.mainVersionString,
purchasedProducts: purchasedProducts, purchasedProducts: purchasedProducts,

View File

@ -50,6 +50,7 @@ private extension ReportIssueButton {
return return
} }
let issue = await Issue.withMetadata(.init( let issue = await Issue.withMetadata(.init(
profile: installedProfile,
configuration: .shared, configuration: .shared,
versionString: BundleConfiguration.mainVersionString, versionString: BundleConfiguration.mainVersionString,
purchasedProducts: purchasedProducts, purchasedProducts: purchasedProducts,

View File

@ -31,6 +31,7 @@ extension View {
public func withEnvironment(from context: AppContext, theme: Theme) -> some View { public func withEnvironment(from context: AppContext, theme: Theme) -> some View {
environmentObject(theme) environmentObject(theme)
.environmentObject(context.iapManager) .environmentObject(context.iapManager)
.environmentObject(context.profileManager)
.environmentObject(context.profileProcessor) .environmentObject(context.profileProcessor)
.environmentObject(context.connectionObserver) .environmentObject(context.connectionObserver)
.environmentObject(context.providerManager) .environmentObject(context.providerManager)