Skip to content

Commit

Permalink
Modify autofill update credential pixel to include backfilled parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
CDRussell committed Dec 18, 2024
1 parent 469dfbf commit a6e3dd9
Showing 1 changed file with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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? {
Expand All @@ -209,6 +222,10 @@ class AutofillUpdatingExistingCredentialsDialogFragment : BottomSheetDialogFragm
}
}

private suspend fun paramsForUpdateLoginPixel(): Map<String, String> {
return mapOf(PIXEL_PARAM_WAS_USERNAME_BACKFILLED to wasUsernameBackFilled.await().toString())
}

private interface DialogEvent {
object Shown : DialogEvent
object Dismissed : DialogEvent
Expand Down Expand Up @@ -239,5 +256,7 @@ class AutofillUpdatingExistingCredentialsDialogFragment : BottomSheetDialogFragm
}
return fragment
}

private const val PIXEL_PARAM_WAS_USERNAME_BACKFILLED = "backfilled"
}
}

0 comments on commit a6e3dd9

Please sign in to comment.