kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
in support of #212 log messages before analytics enabled
rodzic
2dd2a9ddbb
commit
43999e3d72
|
@ -27,20 +27,27 @@ class MeshUtilApplication : GeeksvilleApplication() {
|
||||||
val pref = AppPrefs(this)
|
val pref = AppPrefs(this)
|
||||||
crashlytics.setUserId(pref.getInstallId()) // be able to group all bugs per anonymous user
|
crashlytics.setUserId(pref.getInstallId()) // be able to group all bugs per anonymous user
|
||||||
|
|
||||||
// Attach to our exception wrapper
|
// We always send our log messages to the crashlytics lib, but they only get sent to the server if we report an exception
|
||||||
Exceptions.reporter = { exception, _, _ ->
|
// This makes log messages work properly if someone turns on analytics just before they click report bug.
|
||||||
crashlytics.recordException(exception)
|
|
||||||
crashlytics.sendUnsentReports()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isAnalyticsAllowed) {
|
|
||||||
val standardLogger = Logging.printlog
|
|
||||||
|
|
||||||
// send all log messages through crashyltics, so if we do crash we'll have those in the report
|
// send all log messages through crashyltics, so if we do crash we'll have those in the report
|
||||||
|
val standardLogger = Logging.printlog
|
||||||
Logging.printlog = { level, tag, message ->
|
Logging.printlog = { level, tag, message ->
|
||||||
crashlytics.log("$tag: $message")
|
crashlytics.log("$tag: $message")
|
||||||
standardLogger(level, tag, message)
|
standardLogger(level, tag, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun sendCrashReports() {
|
||||||
|
if(isAnalyticsAllowed)
|
||||||
|
crashlytics.sendUnsentReports()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send any old reports if user approves
|
||||||
|
sendCrashReports()
|
||||||
|
|
||||||
|
// Attach to our exception wrapper
|
||||||
|
Exceptions.reporter = { exception, _, _ ->
|
||||||
|
crashlytics.recordException(exception)
|
||||||
|
sendCrashReports() // Send the new report
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import androidx.work.OneTimeWorkRequestBuilder
|
||||||
import androidx.work.WorkManager
|
import androidx.work.WorkManager
|
||||||
import androidx.work.Worker
|
import androidx.work.Worker
|
||||||
import androidx.work.WorkerParameters
|
import androidx.work.WorkerParameters
|
||||||
|
import com.geeksville.andlib.BuildConfig
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,6 +66,6 @@ fun MeshService.Companion.startService(context: Context) {
|
||||||
// Before binding we want to explicitly create - so the service stays alive forever (so it can keep
|
// Before binding we want to explicitly create - so the service stays alive forever (so it can keep
|
||||||
// listening for the bluetooth packets arriving from the radio. And when they arrive forward them
|
// listening for the bluetooth packets arriving from the radio. And when they arrive forward them
|
||||||
// to Signal or whatever.
|
// to Signal or whatever.
|
||||||
info("Trying to start service")
|
info("Trying to start service debug=${BuildConfig.DEBUG}")
|
||||||
requireNotNull(context.startMeshService()) { "Failed to start service" }
|
requireNotNull(context.startMeshService()) { "Failed to start service" }
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue