diff --git a/core/src/main/java/net/ivpn/core/common/prefs/EncryptedSettingsPreference.kt b/core/src/main/java/net/ivpn/core/common/prefs/EncryptedSettingsPreference.kt index 2a03545b8..aad4ff5ad 100644 --- a/core/src/main/java/net/ivpn/core/common/prefs/EncryptedSettingsPreference.kt +++ b/core/src/main/java/net/ivpn/core/common/prefs/EncryptedSettingsPreference.kt @@ -35,7 +35,6 @@ class EncryptedSettingsPreference @Inject constructor(val preference: Preference private const val IS_MIGRATED = "IS_MIGRATED" private const val SETTINGS_LOGGING = "SETTINGS_LOGGING" - private const val SETTINGS_SENTRY = "SETTINGS_SENTRY" private const val SETTINGS_MULTI_HOP = "SETTINGS_MULTI_HOP" private const val SETTINGS_MULTI_HOP_SAME_PROVIDER_ALLOWED = "SETTINGS_MULTI_HOP_SAME_PROVIDER_ALLOWED" private const val SETTINGS_KILL_SWITCH = "SETTINGS_KILL_SWITCH" @@ -452,16 +451,6 @@ class EncryptedSettingsPreference @Inject constructor(val preference: Preference return sharedPreferences.getString(LAST_USED_IP, null) } - fun enableSentry(value: Boolean) { - sharedPreferences.edit() - .putBoolean(SETTINGS_SENTRY, value) - .apply() - } - - fun isSentryEnabled(): Boolean { - return sharedPreferences.getBoolean(SETTINGS_SENTRY, false) - } - fun getFilter(): String? { return sharedPreferences.getString(SETTINGS_FILTER, null) } @@ -515,9 +504,6 @@ class EncryptedSettingsPreference @Inject constructor(val preference: Preference if (oldPreference.contains(SETTINGS_LOGGING)) { putSettingLogging(oldPreference.getBoolean(SETTINGS_LOGGING, false)) } - if (oldPreference.contains(SETTINGS_SENTRY)) { - enableSentry(oldPreference.getBoolean(SETTINGS_SENTRY, true)) - } if (oldPreference.contains(SETTINGS_MULTI_HOP)) { putSettingMultiHop(oldPreference.getBoolean(SETTINGS_MULTI_HOP, false)) } diff --git a/core/src/main/java/net/ivpn/core/common/prefs/Settings.kt b/core/src/main/java/net/ivpn/core/common/prefs/Settings.kt index ac9a539a3..ad5edc1bf 100644 --- a/core/src/main/java/net/ivpn/core/common/prefs/Settings.kt +++ b/core/src/main/java/net/ivpn/core/common/prefs/Settings.kt @@ -143,12 +143,6 @@ class Settings @Inject constructor( settingsPreference.putSettingStartOnBoot(value) } - var isSentryEnabled: Boolean - get() = settingsPreference.isSentryEnabled() - set(value) { - settingsPreference.enableSentry(value) - } - var isAntiSurveillanceEnabled: Boolean get() = settingsPreference.getIsAntiSurveillanceEnabled() set(value) { diff --git a/core/src/main/java/net/ivpn/core/v2/viewmodel/LoggingViewModel.kt b/core/src/main/java/net/ivpn/core/v2/viewmodel/LoggingViewModel.kt index f3cc00370..fd36c3531 100644 --- a/core/src/main/java/net/ivpn/core/v2/viewmodel/LoggingViewModel.kt +++ b/core/src/main/java/net/ivpn/core/v2/viewmodel/LoggingViewModel.kt @@ -39,19 +39,14 @@ class LoggingViewModel @Inject constructor( ) : ViewModel() { val isLoggingEnabled = ObservableBoolean() - val isCrashLoggingEnabled = ObservableBoolean() - val isSentrySupported = ObservableBoolean() var enableLoggingListener = CompoundButton.OnCheckedChangeListener { _: CompoundButton?, value: Boolean -> enableLogging(value) } - var enableCrashLoggingListener = CompoundButton.OnCheckedChangeListener { _: CompoundButton?, value: Boolean -> enableCrashLogging(value) } init { } fun onResume() { isLoggingEnabled.set(getLoggingValue()) - isCrashLoggingEnabled.set(isSentryEnabled()) - isSentrySupported.set(getSentrySupport()) } fun getLogFileUri(context: Context?): Uri { @@ -60,29 +55,14 @@ class LoggingViewModel @Inject constructor( fun reset() { isLoggingEnabled.set(getLoggingValue()) - isCrashLoggingEnabled.set(isSentryEnabled()) - isSentrySupported.set(getSentrySupport()) } private fun getLoggingValue(): Boolean { return logUtil.isLoggingEnabled } - private fun isSentryEnabled(): Boolean { - return IVPNApplication.crashLoggingController.isEnabled - } - - private fun getSentrySupport(): Boolean { - return IVPNApplication.crashLoggingController.isSupported - } - private fun enableLogging(value: Boolean) { isLoggingEnabled.set(value) logUtil.enableLogging(value) } - - private fun enableCrashLogging(value: Boolean) { - isCrashLoggingEnabled.set(value) - IVPNApplication.crashLoggingController.setState(value) - } } \ No newline at end of file diff --git a/core/src/main/res/layout/settings_section_logging.xml b/core/src/main/res/layout/settings_section_logging.xml index 2734fa6dc..14c079cc9 100644 --- a/core/src/main/res/layout/settings_section_logging.xml +++ b/core/src/main/res/layout/settings_section_logging.xml @@ -27,59 +27,6 @@ android:layout_height="wrap_content" android:text="@string/settings_logging" /> - - - - - - - - - - - - diff --git a/site/src/main/java/net/ivpn/client/SiteIVPNApplication.kt b/site/src/main/java/net/ivpn/client/SiteIVPNApplication.kt index 2f99c7b4c..916c931e3 100644 --- a/site/src/main/java/net/ivpn/client/SiteIVPNApplication.kt +++ b/site/src/main/java/net/ivpn/client/SiteIVPNApplication.kt @@ -26,7 +26,6 @@ import androidx.multidex.MultiDexApplication import net.ivpn.client.dagger.DaggerSiteComponent import net.ivpn.client.dagger.SiteComponent import net.ivpn.client.navigation.SiteNavigation -import net.ivpn.client.sentry.SentryController import net.ivpn.client.signup.SiteSignUpViewModel import net.ivpn.client.updates.UpdatesViewModel import net.ivpn.core.IVPNApplication @@ -44,9 +43,6 @@ class SiteIVPNApplication: MultiDexApplication() { @Inject lateinit var viewModel: SiteSignUpViewModel - @Inject - lateinit var sentry: SentryController - @Inject lateinit var updates: UpdatesViewModel @@ -56,8 +52,6 @@ class SiteIVPNApplication: MultiDexApplication() { val appComponent = IVPNApplication.initBy(this) initFeatureConfig() initComponents(appComponent) - //Init crash controller at first - initCrashLogging() initUpdatesController() IVPNApplication.initBaseComponents() initSignUpController() @@ -80,9 +74,4 @@ class SiteIVPNApplication: MultiDexApplication() { private fun initFeatureConfig() { IVPNApplication.applyFeatureConfig(SiteFeatureConfig()) } - - private fun initCrashLogging() { - sentry.init() - IVPNApplication.crashLoggingController = sentry - } } \ No newline at end of file diff --git a/site/src/main/java/net/ivpn/client/sentry/SentryController.kt b/site/src/main/java/net/ivpn/client/sentry/SentryController.kt deleted file mode 100644 index b53c40881..000000000 --- a/site/src/main/java/net/ivpn/client/sentry/SentryController.kt +++ /dev/null @@ -1,76 +0,0 @@ -package net.ivpn.client.sentry - -/* -IVPN Android app -https://github.com/ivpn/android-app - -Created by Oleksandr Mykhailenko. -Copyright (c) 2023 IVPN Limited. - -This file is part of the IVPN Android app. - -The IVPN Android app is free software: you can redistribute it and/or -modify it under the terms of the GNU General Public License as published by the Free -Software Foundation, either version 3 of the License, or (at your option) any later version. - -The IVPN Android app is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License -along with the IVPN Android app. If not, see . -*/ - -import io.sentry.SentryEvent -import io.sentry.SentryOptions.BeforeSendCallback -import io.sentry.android.core.SentryAndroid -import io.sentry.android.core.SentryAndroidOptions -import net.ivpn.client.dagger.SiteScope -import net.ivpn.core.IVPNApplication -import net.ivpn.core.common.logger.CrashLoggingController -import net.ivpn.core.common.prefs.Settings -import org.slf4j.LoggerFactory -import javax.inject.Inject - -@SiteScope -class SentryController @Inject internal constructor( - private val settings: Settings -) : CrashLoggingController() { - - override fun init() { - baseInit() - - SentryAndroid.init(IVPNApplication.application) { options: SentryAndroidOptions -> - // Add a callback that will be used before the event is sent to Sentry. - // With this callback, you can modify the event or, when returning null, also discard the event. - options.beforeSend = BeforeSendCallback { event: SentryEvent?, _: Any? -> - return@BeforeSendCallback if (isEnabled) { - LOGGER.info("Event was sent") - event - } else { - LOGGER.info("Event was NOT sent") - null - } - } - } - } - - override fun setState(isEnabled: Boolean) { - this.isEnabled = isEnabled - settings.isSentryEnabled = isEnabled - } - - override fun reset() { - baseInit() - } - - private fun baseInit() { - isSupported = true - isEnabled = settings.isSentryEnabled - } - - companion object { - private val LOGGER = LoggerFactory.getLogger(SentryController::class.java) - } -} \ No newline at end of file diff --git a/store/src/main/java/net/ivpn/client/StoreIVPNApplication.kt b/store/src/main/java/net/ivpn/client/StoreIVPNApplication.kt index 0e0dbca20..895f26930 100644 --- a/store/src/main/java/net/ivpn/client/StoreIVPNApplication.kt +++ b/store/src/main/java/net/ivpn/client/StoreIVPNApplication.kt @@ -27,7 +27,6 @@ import net.ivpn.client.config.StoreFeatureConfig import net.ivpn.client.dagger.BillingComponent import net.ivpn.client.dagger.DaggerBillingComponent import net.ivpn.client.navigation.StoreNavigation -import net.ivpn.client.sentry.SentryController import net.ivpn.client.signup.SignUpViewModel import net.ivpn.client.updates.UpdatesStubViewModel import net.ivpn.core.IVPNApplication @@ -45,9 +44,6 @@ class StoreIVPNApplication: MultiDexApplication() { @Inject lateinit var viewModel: SignUpViewModel - @Inject - lateinit var sentry: SentryController - var updates = UpdatesStubViewModel() override fun onCreate() { @@ -57,8 +53,6 @@ class StoreIVPNApplication: MultiDexApplication() { initFeatureConfig() initComponents(appComponent) initUpdatesController() - //Init crash controller at first - initCrashLogging() IVPNApplication.initBaseComponents() initSignUpController() IVPNApplication.customNavigation = StoreNavigation @@ -80,9 +74,4 @@ class StoreIVPNApplication: MultiDexApplication() { private fun initFeatureConfig() { IVPNApplication.applyFeatureConfig(StoreFeatureConfig()) } - - private fun initCrashLogging() { - sentry.init() - IVPNApplication.crashLoggingController = sentry - } } \ No newline at end of file diff --git a/store/src/main/java/net/ivpn/client/sentry/SentryController.kt b/store/src/main/java/net/ivpn/client/sentry/SentryController.kt deleted file mode 100644 index 3485fee77..000000000 --- a/store/src/main/java/net/ivpn/client/sentry/SentryController.kt +++ /dev/null @@ -1,76 +0,0 @@ -package net.ivpn.client.sentry - -/* -IVPN Android app -https://github.com/ivpn/android-app - -Created by Oleksandr Mykhailenko. -Copyright (c) 2023 IVPN Limited. - -This file is part of the IVPN Android app. - -The IVPN Android app is free software: you can redistribute it and/or -modify it under the terms of the GNU General Public License as published by the Free -Software Foundation, either version 3 of the License, or (at your option) any later version. - -The IVPN Android app is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License -along with the IVPN Android app. If not, see . -*/ - -import io.sentry.SentryEvent -import io.sentry.SentryOptions.BeforeSendCallback -import io.sentry.android.core.SentryAndroid -import io.sentry.android.core.SentryAndroidOptions -import net.ivpn.client.dagger.BillingScope -import net.ivpn.core.IVPNApplication -import net.ivpn.core.common.logger.CrashLoggingController -import net.ivpn.core.common.prefs.Settings -import org.slf4j.LoggerFactory -import javax.inject.Inject - -@BillingScope -class SentryController @Inject internal constructor( - private val settings: Settings -) : CrashLoggingController() { - - override fun init() { - baseInit() - - SentryAndroid.init(IVPNApplication.application) { options: SentryAndroidOptions -> - // Add a callback that will be used before the event is sent to Sentry. - // With this callback, you can modify the event or, when returning null, also discard the event. - options.beforeSend = BeforeSendCallback { event: SentryEvent?, _: Any? -> - return@BeforeSendCallback if (isEnabled) { - LOGGER.info("Event was sent") - event - } else { - LOGGER.info("Event was NOT sent") - null - } - } - } - } - - override fun setState(isEnabled: Boolean) { - this.isEnabled = isEnabled - settings.isSentryEnabled = isEnabled - } - - override fun reset() { - baseInit() - } - - private fun baseInit() { - isSupported = true - isEnabled = settings.isSentryEnabled - } - - companion object { - private val LOGGER = LoggerFactory.getLogger(SentryController::class.java) - } -} \ No newline at end of file