Include datastore settings in crash reports

This commit is contained in:
Aleksandras Kostarevas 2024-05-15 16:18:30 -05:00
parent 02766b8014
commit eb65ad124d
3 changed files with 20 additions and 0 deletions

View File

@ -3,5 +3,9 @@ package org.futo.inputmethod.latin
import android.app.Application
class CrashLoggingApplication : Application() {
companion object {
fun logPreferences(preferences: Preferences) {
}
}
}

View File

@ -294,6 +294,12 @@ class LatinIME : InputMethodService(), LifecycleOwner, ViewModelStoreOwner, Save
onNewSubtype(it[ActiveSubtype.key] ?: ActiveSubtype.default)
}
}
lifecycleScope.launch {
dataStore.data.collect {
CrashLoggingApplication.logPreferences(it)
}
}
}
override fun onDestroy() {

View File

@ -2,6 +2,8 @@ package org.futo.inputmethod.latin
import android.app.Application
import android.content.Context
import androidx.datastore.preferences.core.Preferences
import org.acra.ACRA
import org.acra.config.dialog
import org.acra.config.httpSender
import org.acra.config.mailSender
@ -49,4 +51,12 @@ class CrashLoggingApplication : Application() {
}
}
}
companion object {
fun logPreferences(preferences: Preferences) {
preferences.asMap().forEach {
ACRA.errorReporter.putCustomData(it.key.name, it.value.toString())
}
}
}
}