Skip to content

Commit

Permalink
Added 2 pixels.
Browse files Browse the repository at this point in the history
  • Loading branch information
anikiki committed Jan 27, 2025
1 parent d21d12b commit 8ef6b1e
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,8 @@ class OmnibarLayout @JvmOverloads constructor(
omnibarViews = omnibarViews(),
entities = events,
)

viewModel.onTrackersAnimationStarted()
}

private fun startExperimentTrackersAnimation(events: List<Entity>?) {
Expand All @@ -696,6 +698,8 @@ class OmnibarLayout @JvmOverloads constructor(
omnibarViews = omnibarViews(),
entities = events,
)

viewModel.onExperimentTrackersAnimationStarted()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ import com.duckduckgo.app.browser.viewstate.HighlightableButton
import com.duckduckgo.app.browser.viewstate.LoadingViewState
import com.duckduckgo.app.browser.viewstate.OmnibarViewState
import com.duckduckgo.app.global.model.PrivacyShield
import com.duckduckgo.app.onboarding.store.AppStage
import com.duckduckgo.app.onboarding.store.UserStageStore
import com.duckduckgo.app.pixels.AppPixelName
import com.duckduckgo.app.statistics.pixels.Pixel
import com.duckduckgo.app.statistics.pixels.Pixel.PixelParameter
import com.duckduckgo.app.statistics.pixels.Pixel.PixelParameter.FIRE_BUTTON_STATE
import com.duckduckgo.app.statistics.pixels.Pixel.PixelType.Unique
import com.duckduckgo.app.tabs.model.TabEntity
Expand Down Expand Up @@ -80,6 +83,7 @@ class OmnibarLayoutViewModel @Inject constructor(
private val userBrowserProperties: UserBrowserProperties,
private val dispatcherProvider: DispatcherProvider,
private val appPersonalityFeature: AppPersonalityFeature,
private val userStageStore: UserStageStore,
) : ViewModel() {

private val _viewState = MutableStateFlow(ViewState())
Expand Down Expand Up @@ -636,4 +640,22 @@ class OmnibarLayoutViewModel @Inject constructor(
)
}
}

fun onTrackersAnimationStarted() {
viewModelScope.launch {
pixel.fire(
AppPixelName.TRACKERS_CIRCLES_ANIMATION_SHOWN,
mapOf(PixelParameter.TRACKERS_ANIMATION_SHOWN_DURING_ONBOARDING to "${userStageStore.getUserAppStage() != AppStage.ESTABLISHED}"),
)
}
}

fun onExperimentTrackersAnimationStarted() {
viewModelScope.launch {
pixel.fire(
AppPixelName.TRACKERS_BURST_ANIMATION_SHOWN,
mapOf(PixelParameter.TRACKERS_ANIMATION_SHOWN_DURING_ONBOARDING to "${userStageStore.getUserAppStage() != AppStage.ESTABLISHED}"),
)
}
}
}
3 changes: 3 additions & 0 deletions app/src/main/java/com/duckduckgo/app/pixels/AppPixelName.kt
Original file line number Diff line number Diff line change
Expand Up @@ -383,4 +383,7 @@ enum class AppPixelName(override val pixelName: String) : Pixel.PixelName {
DEDICATED_WEBVIEW_URL_EXTRACTION_FAILED("m_dedicated_webview_url_extraction_failed"),

BLOCKLIST_TDS_FAILURE("blocklist_experiment_tds_download_failure"),

TRACKERS_CIRCLES_ANIMATION_SHOWN("m_trackers_circles_animation_shown"),
TRACKERS_BURST_ANIMATION_SHOWN("m_trackers_burst_animation_shown"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ import com.duckduckgo.app.browser.viewstate.OmnibarViewState
import com.duckduckgo.app.global.model.PrivacyShield
import com.duckduckgo.app.global.model.PrivacyShield.PROTECTED
import com.duckduckgo.app.global.model.PrivacyShield.UNPROTECTED
import com.duckduckgo.app.onboarding.store.AppStage
import com.duckduckgo.app.onboarding.store.UserStageStore
import com.duckduckgo.app.pixels.AppPixelName
import com.duckduckgo.app.privacy.model.TestingEntity
import com.duckduckgo.app.statistics.pixels.Pixel
import com.duckduckgo.app.statistics.pixels.Pixel.PixelParameter
import com.duckduckgo.app.statistics.pixels.Pixel.PixelParameter.FIRE_BUTTON_STATE
import com.duckduckgo.app.statistics.pixels.Pixel.PixelType.Unique
import com.duckduckgo.app.tabs.model.TabEntity
Expand Down Expand Up @@ -60,6 +63,7 @@ class OmnibarLayoutViewModelTest {
private val pixel: Pixel = mock()
private val userBrowserProperties: UserBrowserProperties = mock()
private val fakeAppPersonalityFeature = FakeFeatureToggleFactory.create(AppPersonalityFeature::class.java)
private val mockUserStageStore: UserStageStore = mock()

private lateinit var testee: OmnibarLayoutViewModel

Expand All @@ -81,6 +85,7 @@ class OmnibarLayoutViewModelTest {
userBrowserProperties = userBrowserProperties,
dispatcherProvider = coroutineTestRule.testDispatcherProvider,
appPersonalityFeature = fakeAppPersonalityFeature,
userStageStore = mockUserStageStore,
)

whenever(tabRepository.flowTabs).thenReturn(flowOf(emptyList()))
Expand Down Expand Up @@ -909,6 +914,54 @@ class OmnibarLayoutViewModelTest {
}
}

@Test
fun whenOnTrackersAnimationStartedCalledAfterOnboardingThenPixelSentWithParamFalse() = runTest {
whenever(mockUserStageStore.getUserAppStage()).thenReturn(AppStage.ESTABLISHED)

testee.onTrackersAnimationStarted()

verify(pixel).fire(
AppPixelName.TRACKERS_CIRCLES_ANIMATION_SHOWN,
mapOf(PixelParameter.TRACKERS_ANIMATION_SHOWN_DURING_ONBOARDING to "false"),
)
}

@Test
fun whenOnTrackersAnimationStartedCalledDuringOnboardingThenPixelSentWithParamTrue() = runTest {
whenever(mockUserStageStore.getUserAppStage()).thenReturn(AppStage.NEW)

testee.onTrackersAnimationStarted()

verify(pixel).fire(
AppPixelName.TRACKERS_CIRCLES_ANIMATION_SHOWN,
mapOf(PixelParameter.TRACKERS_ANIMATION_SHOWN_DURING_ONBOARDING to "true"),
)
}

@Test
fun whenOnExperimentTrackersAnimationStartedCalledAfterOnboardingThenPixelSentWithParamFalse() = runTest {
whenever(mockUserStageStore.getUserAppStage()).thenReturn(AppStage.ESTABLISHED)

testee.onExperimentTrackersAnimationStarted()

verify(pixel).fire(
AppPixelName.TRACKERS_BURST_ANIMATION_SHOWN,
mapOf(PixelParameter.TRACKERS_ANIMATION_SHOWN_DURING_ONBOARDING to "false"),
)
}

@Test
fun whenOnExperimentTrackersAnimationStartedCalledDuringOnboardingThenPixelSentWithParamTrue() = runTest {
whenever(mockUserStageStore.getUserAppStage()).thenReturn(AppStage.NEW)

testee.onExperimentTrackersAnimationStarted()

verify(pixel).fire(
AppPixelName.TRACKERS_BURST_ANIMATION_SHOWN,
mapOf(PixelParameter.TRACKERS_ANIMATION_SHOWN_DURING_ONBOARDING to "true"),
)
}

private fun givenSiteLoaded(loadedUrl: String) {
testee.onViewModeChanged(ViewMode.Browser(loadedUrl))
testee.onExternalStateChange(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ interface Pixel {
const val TAB_INACTIVE_1W = "tab_inactive_1w"
const val TAB_INACTIVE_2W = "tab_inactive_2w"
const val TAB_INACTIVE_3W = "tab_inactive_3w"
const val TRACKERS_ANIMATION_SHOWN_DURING_ONBOARDING = "duringOnboarding"
}

object PixelValues {
Expand Down

0 comments on commit 8ef6b1e

Please sign in to comment.