Add Firebase Crashlytics diagnostics
This commit is contained in:
@@ -17,6 +17,7 @@ import okhttp3.WebSocket
|
||||
import okhttp3.WebSocketListener
|
||||
import pl.firmatpp.kierowca.data.DriverRepository
|
||||
import pl.firmatpp.kierowca.data.model.RealtimeConfigDto
|
||||
import pl.firmatpp.kierowca.diagnostics.AppDiagnostics
|
||||
|
||||
class DriverLiveSyncClient(
|
||||
private val repository: DriverRepository,
|
||||
@@ -66,6 +67,7 @@ class DriverLiveSyncClient(
|
||||
|
||||
override fun onFailure(webSocket: WebSocket, t: Throwable, response: okhttp3.Response?) {
|
||||
stopHeartbeat()
|
||||
AppDiagnostics.log("realtime_error: ${t.message ?: response?.message ?: "unknown"}")
|
||||
reportRealtimeStatus("error", t.message ?: response?.message)
|
||||
started.set(false)
|
||||
scheduleReconnect()
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.concurrent.TimeUnit
|
||||
import pl.firmatpp.kierowca.data.ApiErrorKind
|
||||
import pl.firmatpp.kierowca.data.ApiErrorMapper
|
||||
import pl.firmatpp.kierowca.data.sync.DriverSyncRepository
|
||||
import pl.firmatpp.kierowca.diagnostics.AppDiagnostics
|
||||
|
||||
class DriverSyncWorker(
|
||||
appContext: Context,
|
||||
@@ -62,6 +63,18 @@ class DriverSyncWorker(
|
||||
Result.success()
|
||||
}.getOrElse { throwable ->
|
||||
val error = ApiErrorMapper.map(throwable)
|
||||
AppDiagnostics.reportNonFatal(
|
||||
throwable = throwable,
|
||||
operation = "driver_sync_worker",
|
||||
keys = mapOf(
|
||||
"date" to inputData.getString(KEY_DATE),
|
||||
"route_id" to inputData.getString(KEY_ROUTE_ID),
|
||||
"api_error_kind" to error.kind.name,
|
||||
"api_error_code" to error.code,
|
||||
"api_status_code" to error.statusCode,
|
||||
"retryable" to error.retryable,
|
||||
),
|
||||
)
|
||||
if (error.retryable && error.kind != ApiErrorKind.Auth) Result.retry() else Result.failure()
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import pl.firmatpp.kierowca.R
|
||||
import pl.firmatpp.kierowca.data.ApiErrorKind
|
||||
import pl.firmatpp.kierowca.data.ApiErrorMapper
|
||||
import pl.firmatpp.kierowca.data.DriverRepository
|
||||
import pl.firmatpp.kierowca.diagnostics.AppDiagnostics
|
||||
import retrofit2.HttpException
|
||||
|
||||
class NewRouteNotificationWorker(
|
||||
@@ -76,6 +77,17 @@ class NewRouteNotificationWorker(
|
||||
Result.success()
|
||||
} else {
|
||||
val error = ApiErrorMapper.map(throwable)
|
||||
AppDiagnostics.reportNonFatal(
|
||||
throwable = throwable,
|
||||
operation = "new_route_notification_worker",
|
||||
keys = mapOf(
|
||||
"route_id" to routeId,
|
||||
"api_error_kind" to error.kind.name,
|
||||
"api_error_code" to error.code,
|
||||
"api_status_code" to error.statusCode,
|
||||
"retryable" to error.retryable,
|
||||
),
|
||||
)
|
||||
if (error.retryable && error.kind != ApiErrorKind.Auth) Result.retry() else Result.success()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user