Skip to content

Commit

Permalink
Check for Firebase usage in some places
Browse files Browse the repository at this point in the history
  • Loading branch information
Ixam97 committed Aug 17, 2024
1 parent c3f5d13 commit 1488dae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,11 @@ class DataProcessor {
CarStatsViewer.tripDataSource.updateDrivingSession(localSession)
}
} catch (e: Exception) {
Firebase.crashlytics.recordException(e)
InAppLogger.e("FATAL ERROR! Writing trips was not successful: ${e.stackTraceToString()}")
if (CarStatsViewer.appContext.getString(R.string.useFirebase) == "true") {
Firebase.crashlytics.log("FATAL ERROR! Writing trips was not successful")
Firebase.crashlytics.recordException(e)
}
}
}

Expand Down Expand Up @@ -700,8 +703,13 @@ class DataProcessor {
TripType.MANUAL, TripType.MONTH, TripType.AUTO, TripType.SINCE_CHARGE -> TripType.tripTypesNameMap[tripType]
else -> "Unknown Trip Type!"
}
Firebase.crashlytics.log("Error switching trip type! It appears there is no \"$type\".\n${e.message}")
Firebase.crashlytics.recordException(e)
if (CarStatsViewer.appContext.getString(R.string.useFirebase) == "true") {
Firebase.crashlytics.log("Error switching trip type! It appears there is no \"$type\".\n${e.message}")
Firebase.crashlytics.recordException(e)
} else {
InAppLogger.e("Error switching trip type! It appears there is no \"$type\".\n${e.message}")
InAppLogger.e(e.stackTraceToString())
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase
import com.google.gson.GsonBuilder
import com.ixam97.carStatsViewer.BuildConfig
import com.ixam97.carStatsViewer.CarStatsViewer
Expand Down Expand Up @@ -288,7 +290,16 @@ class DebugActivity : FragmentActivity() {
}

debugKill.setOnClickListener {
throw RuntimeException("Debug Exception")
try {
throw RuntimeException("Debug Exception")
} catch (e: Exception) {
if (getString(R.string.useFirebase) == "true") {
Firebase.crashlytics.log("This is a logging test")
Firebase.crashlytics.recordException(e)
} else {
InAppLogger.e(e.toString())
}
}
}

debugSettings.setOnClickListener {
Expand Down

0 comments on commit 1488dae

Please sign in to comment.