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

[FIX/#133] 3차 QA 이슈 수정 및 반영 #134

Merged
merged 15 commits into from
Sep 13, 2024
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 @@ -11,7 +11,6 @@ import co.orange.core.navigation.NavigationManager
import co.orange.main.alarm.AlarmRequestActivity
import co.orange.main.detail.DetailActivity
import co.orange.main.main.MainActivity
import co.orange.sell.confirm.SellConfirmActivity
import co.orange.sell.finished.SellFinishedActivity
import co.orange.sell.info.SellInfoActivity
import co.orange.sell.onboarding.SellOnboardingActivity
Expand Down Expand Up @@ -147,11 +146,4 @@ class NavigationManagerImpl
) {
context.startActivity(SellInfoActivity.createIntent(context, itemId))
}

override fun toSellConfirmView(
context: Context,
orderId: String,
) {
context.startActivity(SellConfirmActivity.createIntent(context, orderId))
}
}
26 changes: 18 additions & 8 deletions core/src/main/java/co/orange/core/amplitude/AmplitudeManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,31 @@ object AmplitudeManager {
}
}

fun updateProperties(
fun updateProperty(
propertyName: String,
values: String,
value: String,
) {
amplitude.identify(Identify().set(propertyName, values))
amplitude.identify(Identify().set(propertyName, value))
}

fun updateIntProperties(
fun updatePropertyOnce(
propertyName: String,
intValues: Int,
value: String,
) {
amplitude.identify(Identify().set(propertyName, intValues))
amplitude.identify(Identify().setOnce(propertyName, value))
}

fun plusIntProperties(propertyName: String) {
amplitude.identify(Identify().add(propertyName, 1))
fun updateIntProperty(
propertyName: String,
intValue: Int,
) {
amplitude.identify(Identify().set(propertyName, intValue))
}

fun plusIntProperty(
propertyName: String,
addedValue: Int,
) {
amplitude.identify(Identify().add(propertyName, addedValue))
}
}
10 changes: 3 additions & 7 deletions core/src/main/java/co/orange/core/extension/StringExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,11 @@ fun String.toPhoneFrom(): String? {
}
}

fun String.convertDateTime(
oldPattern: String,
newPattern: String,
): String =
fun String.convertDateFormat(): String =
LocalDateTime.parse(
this.replace(Regex("\\.\\d{1,6}"), ""),
DateTimeFormatter.ofPattern(oldPattern),
)
.format(DateTimeFormatter.ofPattern(newPattern))
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"),
).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))

fun String.maskName(): String =
when (this.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,4 @@ interface NavigationManager {
context: Context,
itemId: String,
)

fun toSellConfirmView(
context: Context,
orderId: String,
)
}
43 changes: 43 additions & 0 deletions core/src/main/java/co/orange/core/util/InfiniteScrollListener.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package co.orange.core.util

import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView

class LinearInfiniteScrollListener(
private val loadMore: () -> Unit,
) : RecyclerView.OnScrollListener() {
override fun onScrolled(
recyclerView: RecyclerView,
dx: Int,
dy: Int,
) {
super.onScrolled(recyclerView, dx, dy)
if (dy > 0 && !recyclerView.canScrollVertically(1)) {
(recyclerView.layoutManager as? LinearLayoutManager)?.let { layoutManager ->
if (layoutManager.findLastVisibleItemPosition() == recyclerView.adapter?.itemCount?.minus(1)) {
loadMore()
}
}
}
}
}

class GridInfiniteScrollListener(
private val loadMore: () -> Unit,
) : RecyclerView.OnScrollListener() {
override fun onScrolled(
recyclerView: RecyclerView,
dx: Int,
dy: Int,
) {
super.onScrolled(recyclerView, dx, dy)
if (dy > 0 && !recyclerView.canScrollVertically(1)) {
(recyclerView.layoutManager as? GridLayoutManager)?.let { layoutManager ->
if (layoutManager.findLastVisibleItemPosition() == recyclerView.adapter?.itemCount?.minus(1)) {
loadMore()
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import co.orange.data.dto.response.HomeDto
import co.orange.data.dto.response.SearchResultDto

interface HomeDataSource {
suspend fun getHomeData(): BaseResponse<HomeDto>
suspend fun getHomeData(page: Int): BaseResponse<HomeDto>

suspend fun getSearchResult(keyword: String): BaseResponse<SearchResultDto>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data class HomeDataSourceImpl
constructor(
private val homeService: HomeService,
) : HomeDataSource {
override suspend fun getHomeData(): BaseResponse<HomeDto> = homeService.getHomeData()
override suspend fun getHomeData(page: Int): BaseResponse<HomeDto> = homeService.getHomeData(page)

override suspend fun getSearchResult(keyword: String): BaseResponse<SearchResultDto> = homeService.getSearchResult(keyword)

Expand Down
4 changes: 3 additions & 1 deletion data/src/main/java/co/orange/data/dto/response/HomeDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ data class HomeDto(
val homeImgUrl: String,
@SerialName("productList")
val productList: List<ProductDto>,
@SerialName("pageInfo")
val pageInfo: PageInfoDto,
) {
fun toModel() = HomeModel(homeImgUrl, productList.map { it.toModel() })
fun toModel() = HomeModel(homeImgUrl, productList.map { it.toModel() }, pageInfo.toModel())
}
15 changes: 15 additions & 0 deletions data/src/main/java/co/orange/data/dto/response/PageInfoDto.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package co.orange.data.dto.response

import co.orange.domain.entity.response.PageInfoModel
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class PageInfoDto(
@SerialName("totalElements")
val totalElements: Long,
@SerialName("numberOfElements")
val numberOfElements: Int,
) {
fun toModel() = PageInfoModel(totalElements, numberOfElements)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class HomeRepositoryImpl
constructor(
private val homeDataSource: HomeDataSource,
) : HomeRepository {
override suspend fun getHomeData(): Result<HomeModel> = runCatching { homeDataSource.getHomeData().data.toModel() }
override suspend fun getHomeData(page: Int): Result<HomeModel> = runCatching { homeDataSource.getHomeData(page).data.toModel() }

override suspend fun getSearchResult(keyword: String): Result<SearchResultModel> =
runCatching {
Expand Down
4 changes: 3 additions & 1 deletion data/src/main/java/co/orange/data/service/HomeService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import retrofit2.http.Query

interface HomeService {
@GET("/api/v1/home")
suspend fun getHomeData(): BaseResponse<HomeDto>
suspend fun getHomeData(
@Query("page") page: Int,
): BaseResponse<HomeDto>

@GET("/api/v1/search")
suspend fun getSearchResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ package co.orange.domain.entity.response
data class HomeModel(
val homeImgUrl: String,
val productList: List<ProductModel>,
val pageInfo: PageInfoModel,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package co.orange.domain.entity.response

data class PageInfoModel(
val totalElements: Long,
val numberOfElements: Int,
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import co.orange.domain.entity.response.HomeModel
import co.orange.domain.entity.response.SearchResultModel

interface HomeRepository {
suspend fun getHomeData(): Result<HomeModel>
suspend fun getHomeData(page: Int): Result<HomeModel>

suspend fun getSearchResult(keyword: String): Result<SearchResultModel>

Expand Down
17 changes: 0 additions & 17 deletions feature/auth/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,6 @@ android {
)
}

buildTypes {
debug {
buildConfigField(
"String",
"MERCHANT_UID",
gradleLocalProperties(rootDir).getProperty("merchant.test.uid"),
)
}
release {
buildConfigField(
"String",
"MERCHANT_UID",
gradleLocalProperties(rootDir).getProperty("merchant.uid"),
)
}
}

compileOptions {
sourceCompatibility = Versions.javaVersion
targetCompatibility = Versions.javaVersion
Expand Down
10 changes: 7 additions & 3 deletions feature/auth/src/main/java/co/orange/auth/phone/PhoneActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.core.view.isVisible
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import co.orange.auth.BuildConfig.IAMPORT_CODE
import co.orange.auth.BuildConfig.MERCHANT_UID
import co.orange.auth.databinding.ActivityPhoneBinding
import co.orange.auth.submit.SubmitActivity
import co.orange.core.R
Expand All @@ -24,6 +23,7 @@ import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import timber.log.Timber
import java.util.Date
import co.orange.auth.R as featureR

@AndroidEntryPoint
Expand Down Expand Up @@ -73,7 +73,7 @@ class PhoneActivity : BaseActivity<ActivityPhoneBinding>(featureR.layout.activit
userCode = IAMPORT_CODE,
iamPortCertification =
IamPortCertification(
merchant_uid = MERCHANT_UID,
merchant_uid = "mid_ddanzi_android_${Date().time}",
company = stringOf(R.string.company_name),
),
) { response ->
Expand Down Expand Up @@ -115,9 +115,13 @@ class PhoneActivity : BaseActivity<ActivityPhoneBinding>(featureR.layout.activit
.onEach { state ->
when (state) {
is UiState.Success -> {
AmplitudeManager.trackEvent("complete_sign_up")
AmplitudeManager.apply {
trackEvent("complete_sign_up")
updateProperty("user_id", state.data)
}
setLoadingScreen(false)
startActivity(SubmitActivity.createIntent(this, state.data))
finish()
}

is UiState.Failure -> {
Expand Down
54 changes: 45 additions & 9 deletions feature/auth/src/main/java/co/orange/auth/phone/PhoneViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import co.orange.core.amplitude.AmplitudeManager
import co.orange.core.extension.toPhoneFrom
import co.orange.core.state.UiState
import co.orange.domain.entity.request.SignUpRequestModel
import co.orange.domain.entity.response.IamportCertificationModel
import co.orange.domain.repository.AuthRepository
import co.orange.domain.repository.IamportRepository
import co.orange.domain.repository.UserRepository
Expand All @@ -17,6 +18,10 @@ import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import timber.log.Timber
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.Period
import java.time.format.DateTimeFormatter
import javax.inject.Inject

@HiltViewModel
Expand Down Expand Up @@ -104,23 +109,24 @@ class PhoneViewModel
private fun getCertificationDataFromServer(accessToken: String) {
viewModelScope.launch {
iamportRepository.getIamportCertificationData(accessToken, certificatedUid)
.onSuccess {
if (it != null) {
.onSuccess { response ->
if (response != null) {
_getIamportCertificationResult.emit(true)
postToSignUpFromServer(
SignUpRequestModel(
name = it.name.orEmpty(),
phone = it.phone.orEmpty(),
birth = it.birthday.orEmpty(),
sex = it.gender?.uppercase().orEmpty(),
name = response.name.orEmpty(),
phone = response.phone.orEmpty(),
birth = response.birthday.orEmpty(),
sex = response.gender?.uppercase().orEmpty(),
isAgreedMarketingTerm = isTermMarketingSelected.value ?: false,
ci = it.uniqueKey.orEmpty(),
ci = response.uniqueKey.orEmpty(),
),
)
userRepository.setUserInfo(
userName = it.name.orEmpty(),
userPhone = it.phone?.toPhoneFrom().orEmpty(),
userName = response.name.orEmpty(),
userPhone = response.phone?.toPhoneFrom().orEmpty(),
)
setAmplitudeUserProperty(response)
} else {
_getIamportCertificationResult.emit(false)
}
Expand All @@ -144,4 +150,34 @@ class PhoneViewModel
}
}
}

private fun setAmplitudeUserProperty(item: IamportCertificationModel) {
AmplitudeManager.apply {
updateProperty("user_sex", item.gender?.uppercase().orEmpty())
updateProperty("user_name", item.name.orEmpty())
item.birthday?.let { birthday ->
updateProperty("user_birthday", birthday.convertOnlyDate())
updateIntProperty("user_age", birthday.convertToAge())
}
updateProperty(
"user_signup_date",
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
)
updateIntProperty("user_purchase_count", 0)
updateIntProperty("user_purchase_total", 0)
updateIntProperty("user_selling_try", 0)
updateIntProperty("user_selling_count", 0)
updateIntProperty("user_selling_total", 0)
}
}

private fun String.convertOnlyDate(): String =
LocalDate.parse(this, DateTimeFormatter.ofPattern("yyyy-MM-dd"))
.format(DateTimeFormatter.ofPattern("MMdd"))

private fun String.convertToAge(): Int =
Period.between(
LocalDate.parse(this, DateTimeFormatter.ofPattern("yyyy-MM-dd")),
LocalDate.now(),
).years + 1
}
Loading
Loading