From f4102bcd30718172c25a1edd7ba1439bbd7048b1 Mon Sep 17 00:00:00 2001 From: David Perez Date: Thu, 14 Aug 2025 17:09:49 -0500 Subject: [PATCH] Update Autofill logging (#5697) --- .../bitwarden/AutofillTotpCopyViewModel.kt | 27 ++++++++++++++++--- .../builder/FillResponseBuilderImpl.kt | 2 +- .../manager/AutofillCompletionManagerImpl.kt | 5 ++++ .../autofill/parser/AutofillParserImpl.kt | 2 +- .../FlightRecorderManagerImpl.kt | 2 +- 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/x8bit/bitwarden/AutofillTotpCopyViewModel.kt b/app/src/main/kotlin/com/x8bit/bitwarden/AutofillTotpCopyViewModel.kt index 23b4615f5f..3b6e74f16e 100644 --- a/app/src/main/kotlin/com/x8bit/bitwarden/AutofillTotpCopyViewModel.kt +++ b/app/src/main/kotlin/com/x8bit/bitwarden/AutofillTotpCopyViewModel.kt @@ -13,6 +13,7 @@ import com.x8bit.bitwarden.data.vault.repository.model.VaultUnlockData import com.x8bit.bitwarden.data.vault.repository.util.statusFor import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.first +import timber.log.Timber import javax.inject.Inject /** @@ -40,7 +41,10 @@ class AutofillTotpCopyViewModel @Inject constructor( private fun handleIntentReceived(action: AutofillTotpCopyAction.IntentReceived) { viewModelScope .launchWithTimeout( - timeoutBlock = { finishActivity() }, + timeoutBlock = { + Timber.w("Autofill -- Timeout") + finishActivity() + }, timeoutDuration = CIPHER_WAIT_TIMEOUT_MILLIS, ) { // Extract TOTP copy data from the intent. @@ -49,16 +53,31 @@ class AutofillTotpCopyViewModel @Inject constructor( .getTotpCopyIntentOrNull() ?.cipherId - if (cipherId == null || isVaultLocked()) { + if (cipherId == null) { + Timber.w("Autofill -- Cipher was not provided") + finishActivity() + return@launchWithTimeout + } + if (isVaultLocked()) { + Timber.w("Autofill -- Vault is locked") finishActivity() return@launchWithTimeout } // Try and find the matching cipher. when (val result = vaultRepository.getCipher(cipherId = cipherId)) { - GetCipherResult.CipherNotFound -> finishActivity() - is GetCipherResult.Failure -> finishActivity() + GetCipherResult.CipherNotFound -> { + Timber.w("Autofill -- Cipher not found") + finishActivity() + } + + is GetCipherResult.Failure -> { + Timber.w(result.error, "Autofill -- Get cipher failure") + finishActivity() + } + is GetCipherResult.Success -> { + Timber.d("Autofill -- Cipher found") sendEvent(AutofillTotpCopyEvent.CompleteAutofill(result.cipherView)) } } diff --git a/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/builder/FillResponseBuilderImpl.kt b/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/builder/FillResponseBuilderImpl.kt index 826677ffee..3cc10947b4 100644 --- a/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/builder/FillResponseBuilderImpl.kt +++ b/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/builder/FillResponseBuilderImpl.kt @@ -23,7 +23,7 @@ class FillResponseBuilderImpl : FillResponseBuilder { saveInfo: SaveInfo?, ): FillResponse? = if (filledData.fillableAutofillIds.isNotEmpty()) { - Timber.w("Autofill request constructing FillResponse") + Timber.d("Autofill request constructing FillResponse") val fillResponseBuilder = FillResponse.Builder() saveInfo?.let { nonNullSaveInfo -> fillResponseBuilder.setSaveInfo(nonNullSaveInfo) } diff --git a/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/manager/AutofillCompletionManagerImpl.kt b/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/manager/AutofillCompletionManagerImpl.kt index 3ffadd9814..23b2d63932 100644 --- a/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/manager/AutofillCompletionManagerImpl.kt +++ b/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/manager/AutofillCompletionManagerImpl.kt @@ -17,6 +17,7 @@ import com.x8bit.bitwarden.data.platform.manager.event.OrganizationEventManager import com.x8bit.bitwarden.data.platform.manager.model.OrganizationEvent import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch +import timber.log.Timber /** * Primary implementation of [AutofillCompletionManager]. @@ -41,6 +42,7 @@ class AutofillCompletionManagerImpl( .intent ?.getAutofillAssistStructureOrNull() ?: run { + Timber.w("Assist structure not found") activity.cancelAndFinish() return } @@ -51,6 +53,7 @@ class AutofillCompletionManagerImpl( assistStructure = assistStructure, ) if (autofillRequest !is AutofillRequest.Fillable) { + Timber.w("Request is not fillable") activity.cancelAndFinish() return } @@ -68,11 +71,13 @@ class AutofillCompletionManagerImpl( authIntentSender = null, ) ?: run { + Timber.w("Dataset not found") activity.cancelAndFinish() return@launch } totpManager.tryCopyTotpToClipboard(cipherView = cipherView) val resultIntent = createAutofillSelectionResultIntent(dataset) + Timber.d("Autofill success") activity.setResultAndFinish(resultIntent = resultIntent) cipherView.id?.let { organizationEventManager.trackEvent( diff --git a/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/parser/AutofillParserImpl.kt b/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/parser/AutofillParserImpl.kt index 0df6ece591..524a5dfa63 100644 --- a/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/parser/AutofillParserImpl.kt +++ b/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/parser/AutofillParserImpl.kt @@ -135,7 +135,7 @@ class AutofillParserImpl( // Get inline information if available val isInlineAutofillEnabled = settingsRepository.isInlineAutofillEnabled - Timber.e("Autofill request isInlineEnabled=$isInlineAutofillEnabled -- ${fillRequest?.id}") + Timber.d("Autofill request isInlineEnabled=$isInlineAutofillEnabled -- ${fillRequest?.id}") val maxInlineSuggestionsCount = fillRequest.getMaxInlineSuggestionsCount( autofillAppInfo = autofillAppInfo, isInlineAutofillEnabled = isInlineAutofillEnabled, diff --git a/app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/flightrecorder/FlightRecorderManagerImpl.kt b/app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/flightrecorder/FlightRecorderManagerImpl.kt index 0f3158b55b..4b601ce9fd 100644 --- a/app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/flightrecorder/FlightRecorderManagerImpl.kt +++ b/app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/flightrecorder/FlightRecorderManagerImpl.kt @@ -190,7 +190,7 @@ internal class FlightRecorderManagerImpl( } } - private inner class FlightRecorderTree : Timber.Tree() { + private inner class FlightRecorderTree : Timber.DebugTree() { var flightRecorderData: FlightRecorderDataSet.FlightRecorderData? = null set(value) { value?.let {