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 {
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
)
}
}

View File

@ -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<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()
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)
}

View File

@ -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

View File

@ -23,10 +23,15 @@
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
//
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)
}
}

View File

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

View File

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

View File

@ -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)