Skip to content

Commit

Permalink
[FEAT/#294] navigation amplitude
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeyubin committed Oct 21, 2024
1 parent 4d73b0c commit 9aca783
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion feature/src/main/java/com/terning/feature/main/MainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.compose.NavHost
import com.terning.core.analytics.EventType
import com.terning.core.analytics.LocalTracker
import com.terning.core.designsystem.component.snackbar.TerningBasicSnackBar
import com.terning.core.designsystem.theme.Grey300
import com.terning.core.designsystem.theme.TerningMain
Expand All @@ -55,6 +57,7 @@ import com.terning.feature.onboarding.splash.navigation.splashNavGraph
import com.terning.feature.search.search.navigation.searchNavGraph
import com.terning.feature.search.searchprocess.navigation.searchProcessNavGraph
import kotlinx.coroutines.launch
import org.openjdk.tools.javac.Main

@Composable
fun MainScreen(
Expand All @@ -67,6 +70,8 @@ fun MainScreen(
val snackBarHostState = remember { SnackbarHostState() }
val coroutineScope = rememberCoroutineScope()

val amplitudeTracker = LocalTracker.current

BackHandler(enabled = backPressedState) {
if (System.currentTimeMillis() - backPressedTime <= 3000) {
(context as Activity).finish()
Expand Down Expand Up @@ -101,7 +106,18 @@ fun MainScreen(
isVisible = navigator.showBottomBar(),
tabs = MainTab.entries.toList(),
currentTab = navigator.currentTab,
onTabSelected = navigator::navigate
onTabSelected = { navigation ->
amplitudeTracker.track(
type = EventType.CLICK,
name = when (navigation) {
MainTab.HOME -> "navigation_home"
MainTab.CALENDAR -> "navigation_calendar"
MainTab.SEARCH -> "navigation_search"
MainTab.MY_PAGE -> "navigation_mypage"
}
)
navigator.navigate(navigation)
}
)
},
) { paddingValues ->
Expand Down

0 comments on commit 9aca783

Please sign in to comment.