<commit_before>package chat.rocket.android.infrastructure

import android.app.Application
import chat.rocket.android.BuildConfig
import chat.rocket.android.server.domain.AccountsRepository
import chat.rocket.android.server.domain.GetCurrentServerInteractor
import chat.rocket.android.server.domain.GetSettingsInteractor
import chat.rocket.android.server.domain.SITE_URL
import com.crashlytics.android.Crashlytics
import kotlinx.coroutines.experimental.runBlocking

fun installCrashlyticsWrapper(context: Application,
                              currentServerInteractor: GetCurrentServerInteractor,
                              settingsInteractor: GetSettingsInteractor,
                              accountRepository: AccountsRepository,
                              localRepository: LocalRepository) {
    if (isCrashlyticsEnabled()) {
        Thread.setDefaultUncaughtExceptionHandler(RocketChatUncaughtExceptionHandler(currentServerInteractor,
                settingsInteractor, accountRepository, localRepository))
    }
}

private fun isCrashlyticsEnabled(): Boolean {
    return !BuildConfig.DEBUG
}


private class RocketChatUncaughtExceptionHandler(
        val currentServerInteractor: GetCurrentServerInteractor,
        val settingsInteractor: GetSettingsInteractor,
        val accountRepository: AccountsRepository,
        val localRepository: LocalRepository)
    : Thread.UncaughtExceptionHandler {

    val crashlyticsHandler: Thread.UncaughtExceptionHandler? = Thread.getDefaultUncaughtExceptionHandler()

    override fun uncaughtException(t: Thread, e: Throwable) {
        val currentServer = currentServerInteractor.get() ?: "<unknown>"
        Crashlytics.setString(KEY_CURRENT_SERVER, currentServer)
        runBlocking {
            val accounts = accountRepository.load()
            Crashlytics.setString(KEY_ACCOUNTS, accounts.toString())
        }

        val settings = settingsInteractor.get(currentServer)
        Crashlytics.setInt(KEY_SETTINGS_SIZE, settings.size)
        val baseUrl = settings[SITE_URL]?.toString()
        Crashlytics.setString(KEY_SETTINGS_BASE_URL, baseUrl)
<commit_msg>Remove empty line<commit_after>package chat.rocket.android.infrastructure

import android.app.Application
import chat.rocket.android.BuildConfig
import chat.rocket.android.server.domain.AccountsRepository
import chat.rocket.android.server.domain.GetCurrentServerInteractor
import chat.rocket.android.server.domain.GetSettingsInteractor
import chat.rocket.android.server.domain.SITE_URL
import com.crashlytics.android.Crashlytics
import kotlinx.coroutines.experimental.runBlocking

fun installCrashlyticsWrapper(context: Application,
                              currentServerInteractor: GetCurrentServerInteractor,
                              settingsInteractor: GetSettingsInteractor,
                              accountRepository: AccountsRepository,
                              localRepository: LocalRepository) {
    if (isCrashlyticsEnabled()) {
        Thread.setDefaultUncaughtExceptionHandler(RocketChatUncaughtExceptionHandler(currentServerInteractor,
                settingsInteractor, accountRepository, localRepository))
    }
}

private fun isCrashlyticsEnabled(): Boolean {
    return !BuildConfig.DEBUG
}

private class RocketChatUncaughtExceptionHandler(
        val currentServerInteractor: GetCurrentServerInteractor,
        val settingsInteractor: GetSettingsInteractor,
        val accountRepository: AccountsRepository,
        val localRepository: LocalRepository)
    : Thread.UncaughtExceptionHandler {

    val crashlyticsHandler: Thread.UncaughtExceptionHandler? = Thread.getDefaultUncaughtExceptionHandler()

    override fun uncaughtException(t: Thread, e: Throwable) {
        val currentServer = currentServerInteractor.get() ?: "<unknown>"
        Crashlytics.setString(KEY_CURRENT_SERVER, currentServer)
        runBlocking {
            val accounts = accountRepository.load()
            Crashlytics.setString(KEY_ACCOUNTS, accounts.toString())
        }

        val settings = settingsInteractor.get(currentServer)
        Crashlytics.setInt(KEY_SETTINGS_SIZE, settings.size)
        val baseUrl = settings[SITE_URL]?.toString()
        Crashlytics.setString(KEY_SETTINGS_BASE_URL, baseUrl)

{'fraction_non_alphanumeric': 0.06699461232138675, 'fraction_numerical': 0.0, 'mean_word_length': 3.7234513274336285, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '141323', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1082, 'n_words': 180}