Skip to content

Commit

Permalink
Merge branch 'hotfix/5.201.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
joshliebe committed May 20, 2024
2 parents 6d8acec + fa7740c commit 18d8eeb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/version/version.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=5.201.0
VERSION=5.201.1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ class EngagementPasswordAddedListener @Inject constructor(
private val pixel: Pixel,
) : PasswordStoreEventListener {

// keep in-memory state to avoid sending the pixel multiple times if called repeatedly in a short time
private var credentialAdded = false

@Synchronized
override fun onCredentialAdded(id: Long) {
if (credentialAdded) return

credentialAdded = true

appCoroutineScope.launch(dispatchers.io()) {
val daysInstalled = userBrowserProperties.daysSinceInstalled()
Timber.v("onCredentialAdded. daysInstalled: $daysInstalled")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class EngagementPasswordAddedListenerTest {
fun whenDaysInstalledLessThan7ThenPixelSent() {
whenever(userBrowserProperties.daysSinceInstalled()).thenReturn(0)
testee.onCredentialAdded(0)
verifyPixelSent()
verifyPixelSentOnce()
}

@Test
Expand All @@ -48,7 +48,16 @@ class EngagementPasswordAddedListenerTest {
verifyPixelNotSent()
}

private fun verifyPixelSent() {
@Test
fun whenCalledMultipleTimesThenOnlySendsPixelOnce() {
whenever(userBrowserProperties.daysSinceInstalled()).thenReturn(0)
repeat(10) {
testee.onCredentialAdded(0)
}
verifyPixelSentOnce()
}

private fun verifyPixelSentOnce() {
verify(pixel).fire(AUTOFILL_ENGAGEMENT_ONBOARDED_USER, type = UNIQUE)
}

Expand Down

0 comments on commit 18d8eeb

Please sign in to comment.