Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SplashScreen Animation: Add pixel #5595

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ object PixelInterceptorPixelsRequiringDataCleaning : PixelParamRemovalPlugin {
SITE_NOT_WORKING_SHOWN.pixelName to PixelParameter.removeAtb(),
SITE_NOT_WORKING_WEBSITE_BROKEN.pixelName to PixelParameter.removeAtb(),
AppPixelName.APP_VERSION_AT_SEARCH_TIME.pixelName to PixelParameter.removeAll(),
AppPixelName.SPLASHSCREEN_SHOWN.pixelName to PixelParameter.removeAll(),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class LaunchBridgeActivity : DuckDuckGoActivity() {
)

lifecycleScope.launch {
viewModel.sendWelcomeScreenPixel()
delay(delay)
viewModel.determineViewToShow()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import com.duckduckgo.anvil.annotations.ContributesViewModel
import com.duckduckgo.app.onboarding.store.UserStageStore
import com.duckduckgo.app.onboarding.store.isNewUser
import com.duckduckgo.app.onboarding.ui.page.extendedonboarding.HighlightsOnboardingExperimentManager
import com.duckduckgo.app.pixels.AppPixelName.SPLASHSCREEN_SHOWN
import com.duckduckgo.app.referral.AppInstallationReferrerStateListener
import com.duckduckgo.app.referral.AppInstallationReferrerStateListener.Companion.MAX_REFERRER_WAIT_TIME_MS
import com.duckduckgo.app.statistics.pixels.Pixel
import com.duckduckgo.common.utils.SingleLiveEvent
import com.duckduckgo.di.scopes.ActivityScope
import javax.inject.Inject
Expand All @@ -34,6 +36,7 @@ class LaunchViewModel @Inject constructor(
private val userStageStore: UserStageStore,
private val appReferrerStateListener: AppInstallationReferrerStateListener,
private val highlightsOnboardingExperimentManager: HighlightsOnboardingExperimentManager,
private val pixel: Pixel,
) :
ViewModel() {

Expand All @@ -44,6 +47,10 @@ class LaunchViewModel @Inject constructor(
data class Home(val replaceExistingSearch: Boolean = false) : Command()
}

fun sendWelcomeScreenPixel() {
pixel.fire(SPLASHSCREEN_SHOWN)
}

suspend fun determineViewToShow() {
waitForReferrerData()

Expand Down
2 changes: 2 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 @@ -37,6 +37,8 @@ enum class AppPixelName(override val pixelName: String) : Pixel.PixelName {
BROKEN_SITE_ALLOWLIST_REMOVE("m_broken_site_allowlist_remove"),
PROTECTION_TOGGLE_BROKEN_SITE_REPORT("m_protection-toggled-off-breakage-report"),

SPLASHSCREEN_SHOWN("m_splashscreen_shown"),

PREONBOARDING_INTRO_SHOWN_UNIQUE("m_preonboarding_intro_shown_unique"),
PREONBOARDING_COMPARISON_CHART_SHOWN_UNIQUE("m_preonboarding_comparison_chart_shown_unique"),
PREONBOARDING_CHOOSE_BROWSER_PRESSED("m_preonboarding_choose_browser_pressed"),
Expand Down
25 changes: 25 additions & 0 deletions app/src/test/java/com/duckduckgo/app/launch/LaunchViewModelTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ import com.duckduckgo.app.launch.LaunchViewModel.Command.Onboarding
import com.duckduckgo.app.onboarding.store.AppStage
import com.duckduckgo.app.onboarding.store.UserStageStore
import com.duckduckgo.app.onboarding.ui.page.extendedonboarding.HighlightsOnboardingExperimentManager
import com.duckduckgo.app.pixels.AppPixelName
import com.duckduckgo.app.referral.StubAppReferrerFoundStateListener
import com.duckduckgo.common.test.CoroutineTestRule
import com.duckduckgo.fakes.FakePixel
import kotlinx.coroutines.test.runTest
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Rule
import org.junit.Test
import org.mockito.kotlin.any
Expand All @@ -49,6 +52,7 @@ class LaunchViewModelTest {
private val mockHighlightsOnboardingExperimentManager: HighlightsOnboardingExperimentManager = mock {
on { it.isHighlightsEnabled() } doReturn false
}
private val fakePixel: FakePixel = FakePixel()

private lateinit var testee: LaunchViewModel

Expand All @@ -63,6 +67,7 @@ class LaunchViewModelTest {
userStageStore,
StubAppReferrerFoundStateListener("xx"),
mockHighlightsOnboardingExperimentManager,
fakePixel,
)
whenever(userStageStore.getUserAppStage()).thenReturn(AppStage.NEW)
testee.command.observeForever(mockCommandObserver)
Expand All @@ -78,6 +83,7 @@ class LaunchViewModelTest {
userStageStore,
StubAppReferrerFoundStateListener("xx", mockDelayMs = 1_000),
mockHighlightsOnboardingExperimentManager,
fakePixel,
)
whenever(userStageStore.getUserAppStage()).thenReturn(AppStage.NEW)
testee.command.observeForever(mockCommandObserver)
Expand All @@ -93,6 +99,7 @@ class LaunchViewModelTest {
userStageStore,
StubAppReferrerFoundStateListener("xx", mockDelayMs = Long.MAX_VALUE),
mockHighlightsOnboardingExperimentManager,
fakePixel,
)
whenever(userStageStore.getUserAppStage()).thenReturn(AppStage.NEW)
testee.command.observeForever(mockCommandObserver)
Expand All @@ -108,6 +115,7 @@ class LaunchViewModelTest {
userStageStore,
StubAppReferrerFoundStateListener("xx"),
mockHighlightsOnboardingExperimentManager,
fakePixel,
)
whenever(userStageStore.getUserAppStage()).thenReturn(AppStage.DAX_ONBOARDING)
testee.command.observeForever(mockCommandObserver)
Expand All @@ -121,6 +129,7 @@ class LaunchViewModelTest {
userStageStore,
StubAppReferrerFoundStateListener("xx", mockDelayMs = 1_000),
mockHighlightsOnboardingExperimentManager,
fakePixel,
)
whenever(userStageStore.getUserAppStage()).thenReturn(AppStage.DAX_ONBOARDING)
testee.command.observeForever(mockCommandObserver)
Expand All @@ -134,6 +143,7 @@ class LaunchViewModelTest {
userStageStore,
StubAppReferrerFoundStateListener("xx", mockDelayMs = Long.MAX_VALUE),
mockHighlightsOnboardingExperimentManager,
fakePixel,
)
whenever(userStageStore.getUserAppStage()).thenReturn(AppStage.DAX_ONBOARDING)
testee.command.observeForever(mockCommandObserver)
Expand All @@ -147,6 +157,7 @@ class LaunchViewModelTest {
userStageStore,
StubAppReferrerFoundStateListener("xx", mockDelayMs = Long.MAX_VALUE),
mockHighlightsOnboardingExperimentManager,
fakePixel,
)
whenever(mockHighlightsOnboardingExperimentManager.isHighlightsEnabled()).thenReturn(true)
whenever(userStageStore.getUserAppStage()).thenReturn(AppStage.NEW)
Expand All @@ -156,4 +167,18 @@ class LaunchViewModelTest {

verify(mockHighlightsOnboardingExperimentManager).setExperimentVariants()
}

@Test
fun whenSendingWelcomeScreenPixelThenSplashScreenShownPixelIsSent() = runTest {
testee = LaunchViewModel(
userStageStore,
StubAppReferrerFoundStateListener("xx", mockDelayMs = Long.MAX_VALUE),
mockHighlightsOnboardingExperimentManager,
fakePixel,
)

testee.sendWelcomeScreenPixel()

assertEquals(AppPixelName.SPLASHSCREEN_SHOWN.pixelName, fakePixel.firedPixels.first())
}
}
Loading