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

[feat] 홈 뷰 앰플리튜드 트래킹 이벤트 코드 심기 #260

Merged
merged 7 commits into from
Sep 27, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ import org.sopt.dateroad.presentation.ui.home.component.DateRoadHomeTopBar
import org.sopt.dateroad.presentation.ui.home.component.HomeAdvertisement
import org.sopt.dateroad.presentation.ui.home.component.HomeHotCourseCard
import org.sopt.dateroad.presentation.ui.home.component.HomeTimeLineCard
import org.sopt.dateroad.presentation.util.HomeAmplitude.COURSE_LIST_COST
import org.sopt.dateroad.presentation.util.HomeAmplitude.COURSE_LIST_ID
import org.sopt.dateroad.presentation.util.HomeAmplitude.COURSE_LIST_LOCATION
import org.sopt.dateroad.presentation.util.HomeAmplitude.COURSE_LIST_TITLE
import org.sopt.dateroad.presentation.util.HomeAmplitude.HOT
import org.sopt.dateroad.presentation.util.HomeAmplitude.NEW
import org.sopt.dateroad.presentation.util.HomeAmplitude.USER_NAME
import org.sopt.dateroad.presentation.util.HomeAmplitude.USER_POINT
import org.sopt.dateroad.presentation.util.HomeAmplitude.VIEW_MAIN
import org.sopt.dateroad.presentation.util.amplitude.AmplitudeUtils
import org.sopt.dateroad.presentation.util.view.LoadState
import org.sopt.dateroad.ui.theme.DateRoadTheme

Expand Down Expand Up @@ -107,6 +117,26 @@ fun HomeRoute(
}
}

LaunchedEffect(uiState.loadState, lifecycleOwner) {
if (uiState.loadState == LoadState.Success) {
AmplitudeUtils.trackEventWithProperties(
eventName = VIEW_MAIN,
mapOf(
USER_NAME to uiState.userPoint.name,
USER_POINT to uiState.userPoint.point,
COURSE_LIST_ID to
HOT + uiState.topLikedCourses.map { it.courseId }.joinToString() + NEW + uiState.latestCourses.map { it.courseId }.joinToString(),
COURSE_LIST_TITLE to
HOT + uiState.topLikedCourses.joinToString { it.title } + NEW + uiState.latestCourses.joinToString { it.title },
COURSE_LIST_LOCATION to
HOT + uiState.topLikedCourses.joinToString { it.city } + NEW + uiState.latestCourses.joinToString { it.city },
COURSE_LIST_COST to
HOT + uiState.topLikedCourses.joinToString { it.cost } + NEW + uiState.latestCourses.joinToString { it.cost }
)
)
}
}

when (uiState.loadState) {
LoadState.Idle -> DateRoadIdleView()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,15 @@ object Pattern {
private const val NICKNAME_PATTERN = "^[ㄱ-ㅎ가-힣a-zA-Z0-9]*$"
val NICKNAME_REGEX = Regex(NICKNAME_PATTERN)
}

object HomeAmplitude {
const val VIEW_MAIN = "view_main"
const val USER_NAME = "user_name"
const val USER_POINT = "user_point"
t1nm1ksun marked this conversation as resolved.
Show resolved Hide resolved
const val COURSE_LIST_ID = "course_list_id"
const val COURSE_LIST_TITLE = "course_list_title"
const val COURSE_LIST_LOCATION = "course_list_location"
const val COURSE_LIST_COST = "course_list_cost"
const val HOT = "Hot: "
const val NEW = " / New: "
}
Loading