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,14 @@ 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.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 +115,22 @@ 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 uiState.topLikedCourses.map { it.courseId }.joinToString() + "," + uiState.latestCourses.map { it.courseId }.joinToString(),
COURSE_LIST_TITLE to uiState.topLikedCourses.joinToString { it.title } + "," + uiState.latestCourses.joinToString { it.title },
COURSE_LIST_LOCATION to uiState.topLikedCourses.joinToString { it.city } + "," + uiState.latestCourses.joinToString { it.city },
COURSE_LIST_COST to uiState.topLikedCourses.joinToString { it.cost } + "," + uiState.latestCourses.joinToString { it.cost }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추출 해줘잉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다른 스트링으로 바꾸긴 했는데 그거 추출했어요

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

근데 궁금한게 string value에 해줘야할 지 Constaints에 해줘야할 지 고민하다 Constraints에 했는데 차이가 뭐야??

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

주로 로직적인 부분에 사용되는 상수들을 관리할 때는 companion object 또는 object로 관리하고, UI와 관련된 문자열들을 관리할 때는 string value를 통해 관리합니당!

)
)
}
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,13 @@ 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"
}
Loading