Allow the services that are configured by secrets to be disabled. (#3961)

* Make the map tiler key optional.

* Make the bug report URL optional.

* Make the sentry URL optional.

* Make the analytics configuration optional and handle consent taking Sentry into account.

* Stop prompting users to report crashes when Sentry is disabled.
This commit is contained in:
Doug
2025-04-01 09:24:12 +01:00
committed by GitHub
parent 36903bf3fb
commit 5e50823223
71 changed files with 321 additions and 134 deletions
@@ -140,19 +140,23 @@ struct SettingsScreen: View {
})
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.about)
ListRow(label: .default(title: L10n.commonReportAProblem,
icon: \.chatProblem),
kind: .navigationLink {
context.send(viewAction: .reportBug)
})
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.reportBug)
if context.viewState.isBugReportServiceEnabled {
ListRow(label: .default(title: L10n.commonReportAProblem,
icon: \.chatProblem),
kind: .navigationLink {
context.send(viewAction: .reportBug)
})
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.reportBug)
}
ListRow(label: .default(title: L10n.commonAnalytics,
icon: \.chart),
kind: .navigationLink {
context.send(viewAction: .analytics)
})
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.analytics)
if context.viewState.showAnalyticsSettings {
ListRow(label: .default(title: L10n.commonAnalytics,
icon: \.chart),
kind: .navigationLink {
context.send(viewAction: .analytics)
})
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.analytics)
}
ListRow(label: .default(title: L10n.commonAdvancedSettings,
icon: \.settings),
@@ -230,18 +234,32 @@ struct SettingsScreen: View {
// MARK: - Previews
struct SettingsScreen_Previews: PreviewProvider, TestablePreview {
static let viewModel = {
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "@userid:example.com",
deviceID: "AAAAAAAAAAA"))))
return SettingsScreenViewModel(userSession: userSession)
}()
static let viewModel = makeViewModel()
static let bugReportDisabledViewModel = makeViewModel(isBugReportServiceEnabled: false)
static var previews: some View {
NavigationStack {
SettingsScreen(context: viewModel.context)
.snapshotPreferences(expect: viewModel.context.$viewState.map { state in
state.accountSessionsListURL != nil
})
}
.snapshotPreferences(expect: viewModel.context.$viewState.map { state in
state.accountSessionsListURL != nil
})
.previewDisplayName("Default")
NavigationStack {
SettingsScreen(context: bugReportDisabledViewModel.context)
}
.snapshotPreferences(expect: bugReportDisabledViewModel.context.$viewState.map { state in
state.accountSessionsListURL != nil
})
.previewDisplayName("Bug report disabled")
}
static func makeViewModel(isBugReportServiceEnabled: Bool = true) -> SettingsScreenViewModel {
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "@userid:example.com",
deviceID: "AAAAAAAAAAA"))))
return SettingsScreenViewModel(userSession: userSession,
appSettings: ServiceLocator.shared.settings,
isBugReportServiceEnabled: isBugReportServiceEnabled)
}
}