From a6e3dd93a9d141598d457a8666bf006a65000496 Mon Sep 17 00:00:00 2001 From: Craig Russell <1336281+CDRussell@users.noreply.github.com> Date: Fri, 13 Dec 2024 17:16:21 +0000 Subject: [PATCH] Modify autofill update credential pixel to include backfilled parameter --- ...datingExistingCredentialsDialogFragment.kt | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/ui/credential/updating/AutofillUpdatingExistingCredentialsDialogFragment.kt b/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/ui/credential/updating/AutofillUpdatingExistingCredentialsDialogFragment.kt index fb331120ba90..f4ead4426d71 100644 --- a/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/ui/credential/updating/AutofillUpdatingExistingCredentialsDialogFragment.kt +++ b/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/ui/credential/updating/AutofillUpdatingExistingCredentialsDialogFragment.kt @@ -52,6 +52,7 @@ import javax.inject.Inject import kotlinx.coroutines.CoroutineStart.LAZY import kotlinx.coroutines.Deferred import kotlinx.coroutines.async +import kotlinx.coroutines.launch import timber.log.Timber @InjectWith(FragmentScope::class) @@ -107,7 +108,11 @@ class AutofillUpdatingExistingCredentialsDialogFragment : BottomSheetDialogFragm container: ViewGroup?, savedInstanceState: Bundle?, ): View { - pixelNameDialogEvent(Shown)?.let { pixel.fire(it) } + pixelNameDialogEvent(Shown)?.let { + lifecycleScope.launch { + pixel.fire(it, paramsForUpdateLoginPixel()) + } + } autofillFireproofDialogSuppressor.autofillSaveOrUpdateDialogVisibilityChanged(visible = true) @@ -155,7 +160,11 @@ class AutofillUpdatingExistingCredentialsDialogFragment : BottomSheetDialogFragm } binding.updateCredentialsButton.setOnClickListener { - pixelNameDialogEvent(Updated)?.let { pixel.fire(it) } + pixelNameDialogEvent(Updated)?.let { + lifecycleScope.launch { + pixel.fire(it, paramsForUpdateLoginPixel()) + } + } val result = Bundle().also { it.putString(CredentialUpdateExistingCredentialsDialog.KEY_URL, originalUrl) @@ -197,7 +206,11 @@ class AutofillUpdatingExistingCredentialsDialogFragment : BottomSheetDialogFragm Timber.v("onCancel: AutofillUpdatingExistingCredentialsDialogFragment. User declined to update credentials") autofillFireproofDialogSuppressor.autofillSaveOrUpdateDialogVisibilityChanged(visible = false) - pixelNameDialogEvent(Dismissed)?.let { pixel.fire(it) } + pixelNameDialogEvent(Dismissed)?.let { + lifecycleScope.launch { + pixel.fire(it, paramsForUpdateLoginPixel()) + } + } } private fun pixelNameDialogEvent(dialogEvent: DialogEvent): AutofillPixelNames? { @@ -209,6 +222,10 @@ class AutofillUpdatingExistingCredentialsDialogFragment : BottomSheetDialogFragm } } + private suspend fun paramsForUpdateLoginPixel(): Map { + return mapOf(PIXEL_PARAM_WAS_USERNAME_BACKFILLED to wasUsernameBackFilled.await().toString()) + } + private interface DialogEvent { object Shown : DialogEvent object Dismissed : DialogEvent @@ -239,5 +256,7 @@ class AutofillUpdatingExistingCredentialsDialogFragment : BottomSheetDialogFragm } return fragment } + + private const val PIXEL_PARAM_WAS_USERNAME_BACKFILLED = "backfilled" } }