diff --git a/Tusker/AppDelegate.swift b/Tusker/AppDelegate.swift index c306483f..30c461c2 100644 --- a/Tusker/AppDelegate.swift +++ b/Tusker/AppDelegate.swift @@ -70,6 +70,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate { options.enableNetworkTracking = false options.enableAppHangTracking = false options.enableCoreDataTracking = false + + options.beforeSend = { event in + Preferences.shared.reportErrorsAutomatically ? event : nil + } } } diff --git a/Tusker/Preferences/Preferences.swift b/Tusker/Preferences/Preferences.swift index e143c0ce..50de575e 100644 --- a/Tusker/Preferences/Preferences.swift +++ b/Tusker/Preferences/Preferences.swift @@ -149,6 +149,7 @@ class Preferences: Codable, ObservableObject { // MARK: Advanced @Published var statusContentType: StatusContentType = .plain + @Published var reportErrorsAutomatically = true // MARK: @Published var hasShownLocalTimelineDescription = false diff --git a/Tusker/Screens/Preferences/AdvancedPrefsView.swift b/Tusker/Screens/Preferences/AdvancedPrefsView.swift index f47515c4..6a68980d 100644 --- a/Tusker/Screens/Preferences/AdvancedPrefsView.swift +++ b/Tusker/Screens/Preferences/AdvancedPrefsView.swift @@ -15,6 +15,7 @@ struct AdvancedPrefsView : View { var body: some View { List { formattingSection + errorReportingSection cachingSection } .listStyle(InsetGroupedListStyle()) @@ -36,6 +37,22 @@ struct AdvancedPrefsView : View { } } + var errorReportingSection: some View { + Section { + Toggle("Report Errors Automatically", isOn: $preferences.reportErrorsAutomatically) + } footer: { + var privacyPolicy: AttributedString = "Privacy Policy" + let _ = privacyPolicy.link = URL(string: "https://vaccor.space/tusker#privacy")! + if preferences.reportErrorsAutomatically { + Text(AttributedString("App crashes and errors will be automatically reported to the developer. You may be prompted to add additional information.\n") + privacyPolicy) + .lineLimit(nil) + } else { + Text(AttributedString("Errors will not be reported automatically. When a crash occurs, you may be asked to report it manually.\n") + privacyPolicy) + .lineLimit(nil) + } + } + } + var cachingSection: some View { Section(header: Text("Caching"), footer: Text("Clearing caches will restart the app.")) { Button(action: clearCache) {