Loading lib/src/main/java/foundation/e/lib/telemetry/Telemetry.kt +18 −2 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ import io.sentry.android.core.SentryAndroid object Telemetry { private var identifier: String = "" private lateinit var application: Application /** * Call this function in `onCreate()` of custom Application class. Loading @@ -16,7 +17,8 @@ object Telemetry { */ fun init(identifier: String, application: Application) { this.identifier = identifier if (isTelemetryEnabled(application)) { this.application = application if (isTelemetryEnabled()) { SentryAndroid.init(application) { options -> options.dsn = identifier } Loading @@ -31,11 +33,25 @@ object Telemetry { Sentry.captureMessage(message) } @Deprecated( "Use isTelemetryEnabled() without parameters.", ReplaceWith("isTelemetryEnabled()"), ) fun isTelemetryEnabled(application: Application): Boolean { return try { Settings.System.getInt(application.contentResolver, SETTINGS_TELEMETRY_FIELD) == 1 } catch (e: Settings.SettingNotFoundException) { false } catch (_: Exception) { false } } /** * Read from OS developer options. * Pass false by default. */ fun isTelemetryEnabled(application: Application): Boolean { fun isTelemetryEnabled(): Boolean { return try { Settings.System.getInt(application.contentResolver, SETTINGS_TELEMETRY_FIELD) == 1 } catch (e: Settings.SettingNotFoundException) { Loading Loading
lib/src/main/java/foundation/e/lib/telemetry/Telemetry.kt +18 −2 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ import io.sentry.android.core.SentryAndroid object Telemetry { private var identifier: String = "" private lateinit var application: Application /** * Call this function in `onCreate()` of custom Application class. Loading @@ -16,7 +17,8 @@ object Telemetry { */ fun init(identifier: String, application: Application) { this.identifier = identifier if (isTelemetryEnabled(application)) { this.application = application if (isTelemetryEnabled()) { SentryAndroid.init(application) { options -> options.dsn = identifier } Loading @@ -31,11 +33,25 @@ object Telemetry { Sentry.captureMessage(message) } @Deprecated( "Use isTelemetryEnabled() without parameters.", ReplaceWith("isTelemetryEnabled()"), ) fun isTelemetryEnabled(application: Application): Boolean { return try { Settings.System.getInt(application.contentResolver, SETTINGS_TELEMETRY_FIELD) == 1 } catch (e: Settings.SettingNotFoundException) { false } catch (_: Exception) { false } } /** * Read from OS developer options. * Pass false by default. */ fun isTelemetryEnabled(application: Application): Boolean { fun isTelemetryEnabled(): Boolean { return try { Settings.System.getInt(application.contentResolver, SETTINGS_TELEMETRY_FIELD) == 1 } catch (e: Settings.SettingNotFoundException) { Loading