From 290721ad9086413d75b36b59b67db5f9d0fa3502 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Wed, 28 Jan 2026 11:58:52 +0200 Subject: [PATCH] Align with android on sentry settings. --- .../Sources/Application/AppCoordinator.swift | 22 +++++++-------- .../Application/Settings/AppSettings.swift | 27 ++++++++++++------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/ElementX/Sources/Application/AppCoordinator.swift b/ElementX/Sources/Application/AppCoordinator.swift index 3adfefd81..b76b73632 100644 --- a/ElementX/Sources/Application/AppCoordinator.swift +++ b/ElementX/Sources/Application/AppCoordinator.swift @@ -949,8 +949,14 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg options.dsn = bugReportSentryURL.absoluteString - if AppSettings.isDevelopmentBuild { - options.environment = "development" + // Matches android, at least for now. + switch AppSettings.appBuildType { + case .debug: + options.environment = "DEBUG" + case .nightly: + options.environment = "NIGHTLY" + case .release: + options.environment = "RELEASE" } // Sentry swizzling shows up quite often as the heaviest stack trace when profiling @@ -975,15 +981,9 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg // Uniform sample rate: 1.0 captures 100% of transactions // In Production you will probably want a smaller number such as 0.5 for 50% - if AppSettings.isDevelopmentBuild { - options.sampleRate = 1.0 - options.tracesSampleRate = 1.0 - options.configureProfiling = { $0.sessionSampleRate = 1.0 } - } else { - options.sampleRate = 0.5 - options.tracesSampleRate = 0.5 - options.configureProfiling = { $0.sessionSampleRate = 1.0 } - } + options.sampleRate = 1.0 + options.tracesSampleRate = 1.0 + options.configureProfiling = { $0.sessionSampleRate = 1.0 } // This callback is only executed once during the entire run of the program to avoid // multiple callbacks if there are multiple crash events to send (see method documentation) diff --git a/ElementX/Sources/Application/Settings/AppSettings.swift b/ElementX/Sources/Application/Settings/AppSettings.swift index 2bb054d53..14ef90261 100644 --- a/ElementX/Sources/Application/Settings/AppSettings.swift +++ b/ElementX/Sources/Application/Settings/AppSettings.swift @@ -25,6 +25,12 @@ protocol CommonSettingsProtocol { var hideQuietNotificationAlerts: Bool { get } } +enum AppBuildType { + case debug + case nightly + case release +} + /// Store Element specific app settings. final class AppSettings { private enum UserDefaultsKeys: String { @@ -82,16 +88,19 @@ final class AppSettings { /// UserDefaults to be used on reads and writes. private static var store: UserDefaults! = UserDefaults(suiteName: suiteName) - /// Whether or not the app is a development build that isn't in production. - static var isDevelopmentBuild: Bool = { + static var appBuildType: AppBuildType { #if DEBUG - true + return .debug #else - let apps = ["io.element.elementx.nightly", "io.element.elementx.pr"] - return apps.contains(InfoPlistReader.main.baseBundleIdentifier) + switch InfoPlistReader.main.baseBundleIdentifier { + case "io.element.elementx.nightly": + return .nightly + default: + return .release + } #endif - }() - + } + static func resetAllSettings() { MXLog.warning("Resetting the AppSettings.") store.removePersistentDomain(forName: suiteName) @@ -336,7 +345,7 @@ final class AppSettings { // MARK: - Room Screen - @UserPreference(key: UserDefaultsKeys.viewSourceEnabled, defaultValue: isDevelopmentBuild, storageType: .userDefaults(store)) + @UserPreference(key: UserDefaultsKeys.viewSourceEnabled, defaultValue: appBuildType == .debug, storageType: .userDefaults(store)) var viewSourceEnabled @UserPreference(key: UserDefaultsKeys.optimizeMediaUploads, defaultValue: true, storageType: .userDefaults(store)) @@ -424,7 +433,7 @@ final class AppSettings { @UserPreference(key: UserDefaultsKeys.spaceFiltersEnabled, defaultValue: false, storageType: .userDefaults(store)) var spaceFiltersEnabled - @UserPreference(key: UserDefaultsKeys.developerOptionsEnabled, defaultValue: isDevelopmentBuild, storageType: .userDefaults(store)) + @UserPreference(key: UserDefaultsKeys.developerOptionsEnabled, defaultValue: appBuildType == .debug, storageType: .userDefaults(store)) var developerOptionsEnabled }