mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-31 15:54:38 +01:00
Don't log common errors to crashlytics (#775)
This commit is contained in:
parent
b19084cb57
commit
4bd0459155
@ -1,7 +1,6 @@
|
|||||||
package io.github.wulkanowy.services.sync
|
package io.github.wulkanowy.services.sync
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build.VERSION_CODES.LOLLIPOP
|
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.app.NotificationCompat.BigTextStyle
|
import androidx.core.app.NotificationCompat.BigTextStyle
|
||||||
import androidx.core.app.NotificationCompat.PRIORITY_DEFAULT
|
import androidx.core.app.NotificationCompat.PRIORITY_DEFAULT
|
||||||
@ -17,9 +16,9 @@ import io.github.wulkanowy.data.repositories.preferences.PreferencesRepository
|
|||||||
import io.github.wulkanowy.data.repositories.semester.SemesterRepository
|
import io.github.wulkanowy.data.repositories.semester.SemesterRepository
|
||||||
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
||||||
import io.github.wulkanowy.sdk.exception.FeatureDisabledException
|
import io.github.wulkanowy.sdk.exception.FeatureDisabledException
|
||||||
|
import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException
|
||||||
import io.github.wulkanowy.services.sync.channels.DebugChannel
|
import io.github.wulkanowy.services.sync.channels.DebugChannel
|
||||||
import io.github.wulkanowy.services.sync.works.Work
|
import io.github.wulkanowy.services.sync.works.Work
|
||||||
import io.github.wulkanowy.utils.AppInfo
|
|
||||||
import io.github.wulkanowy.utils.getCompatColor
|
import io.github.wulkanowy.utils.getCompatColor
|
||||||
import io.reactivex.Completable
|
import io.reactivex.Completable
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
@ -33,8 +32,7 @@ class SyncWorker @AssistedInject constructor(
|
|||||||
private val semesterRepository: SemesterRepository,
|
private val semesterRepository: SemesterRepository,
|
||||||
private val works: Set<@JvmSuppressWildcards Work>,
|
private val works: Set<@JvmSuppressWildcards Work>,
|
||||||
private val preferencesRepository: PreferencesRepository,
|
private val preferencesRepository: PreferencesRepository,
|
||||||
private val notificationManager: NotificationManagerCompat,
|
private val notificationManager: NotificationManagerCompat
|
||||||
private val appInfo: AppInfo
|
|
||||||
) : RxWorker(appContext, workerParameters) {
|
) : RxWorker(appContext, workerParameters) {
|
||||||
|
|
||||||
override fun createWork(): Single<Result> {
|
override fun createWork(): Single<Result> {
|
||||||
@ -47,6 +45,10 @@ class SyncWorker @AssistedInject constructor(
|
|||||||
.flatMapCompletable { semester ->
|
.flatMapCompletable { semester ->
|
||||||
Completable.mergeDelayError(works.map { work ->
|
Completable.mergeDelayError(works.map { work ->
|
||||||
work.create(student, semester)
|
work.create(student, semester)
|
||||||
|
.onErrorResumeNext {
|
||||||
|
if (it is FeatureDisabledException || it is FeatureNotAvailableException) Completable.complete()
|
||||||
|
else Completable.error(it)
|
||||||
|
}
|
||||||
.doOnSubscribe { Timber.i("${work::class.java.simpleName} is starting") }
|
.doOnSubscribe { Timber.i("${work::class.java.simpleName} is starting") }
|
||||||
.doOnError { Timber.i("${work::class.java.simpleName} result: An exception occurred") }
|
.doOnError { Timber.i("${work::class.java.simpleName} result: An exception occurred") }
|
||||||
.doOnComplete { Timber.i("${work::class.java.simpleName} result: Success") }
|
.doOnComplete { Timber.i("${work::class.java.simpleName} result: Success") }
|
||||||
@ -57,11 +59,11 @@ class SyncWorker @AssistedInject constructor(
|
|||||||
.onErrorReturn {
|
.onErrorReturn {
|
||||||
Timber.e(it, "There was an error during synchronization")
|
Timber.e(it, "There was an error during synchronization")
|
||||||
when {
|
when {
|
||||||
it is FeatureDisabledException -> Result.success()
|
|
||||||
inputData.getBoolean("one_time", false) -> {
|
inputData.getBoolean("one_time", false) -> {
|
||||||
Result.failure(Data.Builder()
|
Result.failure(Data.Builder()
|
||||||
.putString("error", it.toString())
|
.putString("error", it.toString())
|
||||||
.build())
|
.build()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
else -> Result.retry()
|
else -> Result.retry()
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ class GradeStatisticsPresenter @Inject constructor(
|
|||||||
showSubjects(true)
|
showSubjects(true)
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
Timber.e("Loading grade stats subjects result: An exception occurred")
|
Timber.i("Loading grade stats subjects result: An exception occurred")
|
||||||
errorHandler.dispatch(it)
|
errorHandler.dispatch(it)
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@ -179,7 +179,7 @@ class GradeStatisticsPresenter @Inject constructor(
|
|||||||
}
|
}
|
||||||
analytics.logEvent("load_grade_statistics", "items" to it.size, "force_refresh" to forceRefresh)
|
analytics.logEvent("load_grade_statistics", "items" to it.size, "force_refresh" to forceRefresh)
|
||||||
}) {
|
}) {
|
||||||
Timber.e("Loading grade stats result: An exception occurred")
|
Timber.i("Loading grade stats result: An exception occurred")
|
||||||
errorHandler.dispatch(it)
|
errorHandler.dispatch(it)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ class LoginRecoverPresenter @Inject constructor(
|
|||||||
.subscribe({ (resetUrl, siteKey) ->
|
.subscribe({ (resetUrl, siteKey) ->
|
||||||
view?.loadReCaptcha(siteKey, resetUrl)
|
view?.loadReCaptcha(siteKey, resetUrl)
|
||||||
}) {
|
}) {
|
||||||
Timber.e("Obtain captcha site key result: An exception occurred")
|
Timber.i("Obtain captcha site key result: An exception occurred")
|
||||||
errorHandler.dispatch(it)
|
errorHandler.dispatch(it)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ class LoginRecoverPresenter @Inject constructor(
|
|||||||
|
|
||||||
analytics.logEvent("account_recover", "register" to host, "symbol" to symbol, "success" to true)
|
analytics.logEvent("account_recover", "register" to host, "symbol" to symbol, "success" to true)
|
||||||
}) {
|
}) {
|
||||||
Timber.e("Send recover request result: An exception occurred")
|
Timber.i("Send recover request result: An exception occurred")
|
||||||
errorHandler.dispatch(it)
|
errorHandler.dispatch(it)
|
||||||
analytics.logEvent("account_recover", "register" to host, "symbol" to symbol, "success" to false)
|
analytics.logEvent("account_recover", "register" to host, "symbol" to symbol, "success" to false)
|
||||||
})
|
})
|
||||||
|
@ -135,12 +135,12 @@ class SendMessagePresenter @Inject constructor(
|
|||||||
if (selectedRecipientChips.isNotEmpty()) setSelectedRecipients(selectedRecipientChips)
|
if (selectedRecipientChips.isNotEmpty()) setSelectedRecipients(selectedRecipientChips)
|
||||||
showContent(true)
|
showContent(true)
|
||||||
} else {
|
} else {
|
||||||
Timber.e("Loading recipients result: Can't find the reporting unit")
|
Timber.i("Loading recipients result: Can't find the reporting unit")
|
||||||
view?.showEmpty(true)
|
view?.showEmpty(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
Timber.e("Loading recipients result: An exception occurred")
|
Timber.i("Loading recipients result: An exception occurred")
|
||||||
view?.showContent(true)
|
view?.showContent(true)
|
||||||
errorHandler.dispatch(it)
|
errorHandler.dispatch(it)
|
||||||
}))
|
}))
|
||||||
|
@ -7,6 +7,9 @@ import com.crashlytics.android.core.CrashlyticsCore
|
|||||||
import fr.bipi.tressence.crash.CrashlyticsLogExceptionTree
|
import fr.bipi.tressence.crash.CrashlyticsLogExceptionTree
|
||||||
import fr.bipi.tressence.crash.CrashlyticsLogTree
|
import fr.bipi.tressence.crash.CrashlyticsLogTree
|
||||||
import io.fabric.sdk.android.Fabric
|
import io.fabric.sdk.android.Fabric
|
||||||
|
import io.github.wulkanowy.sdk.exception.FeatureDisabledException
|
||||||
|
import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException
|
||||||
|
import java.net.UnknownHostException
|
||||||
|
|
||||||
fun initCrashlytics(context: Context, appInfo: AppInfo) {
|
fun initCrashlytics(context: Context, appInfo: AppInfo) {
|
||||||
Fabric.with(Fabric.Builder(context)
|
Fabric.with(Fabric.Builder(context)
|
||||||
@ -21,6 +24,13 @@ fun initCrashlytics(context: Context, appInfo: AppInfo) {
|
|||||||
.build())
|
.build())
|
||||||
}
|
}
|
||||||
|
|
||||||
class CrashlyticsTree : CrashlyticsLogTree(Log.VERBOSE)
|
class CrashlyticsTree : CrashlyticsLogTree(Log.VERBOSE) {
|
||||||
|
|
||||||
|
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
|
||||||
|
if (t is FeatureDisabledException || t is FeatureNotAvailableException || t is UnknownHostException) return
|
||||||
|
|
||||||
|
super.log(priority, tag, message, t)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class CrashlyticsExceptionTree : CrashlyticsLogExceptionTree()
|
class CrashlyticsExceptionTree : CrashlyticsLogExceptionTree()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user