Skip to content
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 @@ -32,11 +32,9 @@ import com.google.android.material.bottomnavigation.BottomNavigationView
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import java.text.SimpleDateFormat
import java.util.Locale
import javax.inject.Inject
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import javax.inject.Inject


@AndroidEntryPoint
Expand Down Expand Up @@ -95,6 +93,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(
}

R.id.anyone_but_me_menu -> {
mainViewModel.analyticsPlzNotMe()
anyoneButMeEventPopupController.openAnyoneButMePage()
false
}
Expand Down
33 changes: 33 additions & 0 deletions app/src/main/java/com/eatssu/android/presentation/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import com.eatssu.android.domain.usecase.user.SetUserCollegeDepartmentUseCase
import com.eatssu.common.UiEvent
import com.eatssu.common.UiState
import com.eatssu.common.UiText
import com.eatssu.common.analytics.AnalyticsTracker
import com.eatssu.common.analytics.ClickMyPageMenuEvent
import com.eatssu.common.analytics.ClickPlzNotMeEvent
import com.eatssu.common.enums.ToastType
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
Expand All @@ -38,6 +41,7 @@ class MainViewModel @Inject constructor(
private val getUserCollegeDepartmentUseCase: GetUserCollegeDepartmentUseCase,
private val getUserEmailUseCase: GetUserEmailUseCase,
private val analyticsIdentityManager: AnalyticsIdentityManager,
private val analyticsTracker: AnalyticsTracker,
private val settingDataStore: SettingDataStore,
) : ViewModel() {

Expand Down Expand Up @@ -67,6 +71,35 @@ class MainViewModel @Inject constructor(
}
}

fun analyticsPlzNotMe() {
viewModelScope.launch {
val userCollegeDepartment = getUserCollegeDepartmentUseCase()
val newDepartmentId = userCollegeDepartment.userDepartment.departmentId.toLong()
val newCollegeId = userCollegeDepartment.userCollege.collegeId.toLong()

analyticsTracker.track(
ClickPlzNotMeEvent(
college = newDepartmentId,
major = newCollegeId,
Comment on lines +77 to +83
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The parameters for ClickPlzNotMeEvent appear to be swapped. newDepartmentId is being passed to college and newCollegeId to major, which contradicts their names and the pattern used in trackMyPageMenu.

Suggested change
val newDepartmentId = userCollegeDepartment.userDepartment.departmentId.toLong()
val newCollegeId = userCollegeDepartment.userCollege.collegeId.toLong()
analyticsTracker.track(
ClickPlzNotMeEvent(
college = newDepartmentId,
major = newCollegeId,
val collegeId = userCollegeDepartment.userCollege.collegeId.toLong()
val departmentId = userCollegeDepartment.userDepartment.departmentId.toLong()
analyticsTracker.track(
ClickPlzNotMeEvent(
college = collegeId,
major = departmentId,
),
)

),
)

}
}

fun trackMyPageMenu(menu: String) {
viewModelScope.launch {
val userCollegeDepartment = getUserCollegeDepartmentUseCase()
analyticsTracker.track(
ClickMyPageMenuEvent(
college = userCollegeDepartment.userCollege.collegeId.toLong(),
major = userCollegeDepartment.userDepartment.departmentId.toLong(),
menu = menu,
),
)
}
}

fun refreshUserDepartmentFromServer() {
viewModelScope.launch {
loadUserDepartmentFromServer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class MenuSubAdapter(

val item = dataList[position]
val intent = Intent(binding.root.context, ReviewComposeActivity::class.java)
intent.putExtra("restaurant", restaurant.name)

when (restaurant.menuType) {
MenuType.FIXED -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.navigation.compose.rememberNavController
import com.eatssu.android.analytics.ProvideAnalyticsTracker
import com.eatssu.common.analytics.AnalyticsTracker
import com.eatssu.common.enums.MenuType
import com.eatssu.common.enums.Restaurant
import com.eatssu.design_system.theme.EatssuTheme
import com.google.firebase.crashlytics.FirebaseCrashlytics
import dagger.hilt.android.AndroidEntryPoint
Expand All @@ -36,6 +37,7 @@ class ReviewComposeActivity : ComponentActivity() {
lateinit var analyticsTracker: AnalyticsTracker

private var menuType: String? = null
private var restaurant: String? = null
private var itemId by Delegates.notNull<Long>()
private lateinit var itemName: String

Expand All @@ -48,17 +50,19 @@ class ReviewComposeActivity : ComponentActivity() {
EatssuTheme {
val navHostController = rememberNavController()
val parsedMenuType = MenuType.entries.find { it.name == menuType }
val parsedRestaurant = Restaurant.entries.find { it.name == restaurant }

parsedMenuType?.let { type ->
if (parsedMenuType != null && parsedRestaurant != null) {
ReviewNav(
navHostController = navHostController,
menuType = type,
menuType = parsedMenuType,
restaurant = parsedRestaurant,
menuName = itemName,
id = itemId,
onExit = { finish() }
)
} ?: run {
Timber.e("Invalid or null MenuType received: $menuType")
} else {
Timber.e("Invalid review parameters received: menuType=$menuType, restaurant=$restaurant")
ErrorScreen(
onBackClick = { finish() }
)
Expand All @@ -70,6 +74,7 @@ class ReviewComposeActivity : ComponentActivity() {

private fun getIntents() { //todo 추후 변경
menuType = intent.getStringExtra("menuType")
restaurant = intent.getStringExtra("restaurant")
itemId = intent.getLongExtra("itemId", 0)
itemName = intent.getStringExtra("itemName").toString().replace(Regex("[\\[\\]]"), "")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.eatssu.android.presentation.cafeteria.review.list.ReviewListScreen
import com.eatssu.android.presentation.cafeteria.review.modify.ModifyReviewScreen
import com.eatssu.android.presentation.cafeteria.review.write.WriteReviewScreen
import com.eatssu.common.enums.MenuType
import com.eatssu.common.enums.Restaurant

object ReviewNav {
const val List = "list"
Expand All @@ -27,6 +28,7 @@ fun ReviewNav(
navHostController: NavHostController = rememberNavController(),
menuName: String,
menuType: MenuType,
restaurant: Restaurant,
id: Long,
onExit: () -> Unit = {}
) {
Expand All @@ -44,6 +46,7 @@ fun ReviewNav(
ReviewListScreen(
menuName = menuName,
menuType = menuType,
restaurant = restaurant,
id = id,
refreshNonce = refreshNonce,
onBack = { onExit() },
Expand Down Expand Up @@ -76,6 +79,7 @@ fun ReviewNav(
composable(ReviewNav.Write) { backStackEntry ->
WriteReviewScreen(
menuType = menuType,
restaurant = restaurant,
menuName = menuName,
id = id,
onBack = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import com.eatssu.common.UiState
import com.eatssu.common.UiText
import com.eatssu.common.analytics.ReviewAnalyticsEvent
import com.eatssu.common.enums.MenuType
import com.eatssu.common.enums.Restaurant
import com.eatssu.common.enums.ScreenId
import com.eatssu.common.enums.ToastType
import com.eatssu.design_system.component.DelayedLoadingIndicator
Expand All @@ -76,6 +77,7 @@ fun ReviewListScreen(
modifier: Modifier = Modifier,
viewModel: ReviewListViewModel = hiltViewModel(),
menuType: MenuType,
restaurant: Restaurant,
menuName: String,
id: Long,
refreshNonce: Long = 0L,
Expand Down Expand Up @@ -125,6 +127,7 @@ fun ReviewListScreen(
reviewPagingItems = reviewPagingItems,
modifier = modifier,
menuName = menuName,
restaurant = restaurant,
onBack = onBack,
onReviewWriteButtonClick = onWriteButtonClick,
onModifyClick = onModifyClick,
Expand All @@ -138,6 +141,7 @@ internal fun ReviewListScreen(
reviewPagingItems: LazyPagingItems<Review>,
modifier: Modifier = Modifier,
menuName: String,
restaurant: Restaurant,
onBack: () -> Unit = {},
onReviewWriteButtonClick: () -> Unit,
onModifyClick: (Review) -> Unit,
Expand Down Expand Up @@ -192,7 +196,7 @@ internal fun ReviewListScreen(
text = stringResource(R.string.review_write),
onClick = {
onReviewWriteButtonClick()
analyticsTracker.track(ReviewAnalyticsEvent.WriteClicked)
analyticsTracker.track(ReviewAnalyticsEvent.WriteClicked(restaurant))
},
modifier = Modifier
.padding(24.dp)
Expand Down Expand Up @@ -628,6 +632,7 @@ fun ReviewListPreview() {
EatssuTheme {
ReviewListScreen(
menuName = "소고기+닭고기+돼지고기+양고기+오리고기",
restaurant = Restaurant.HAKSIK,
onReviewWriteButtonClick = {},
onModifyClick = {},
onDeleteClick = {},
Expand Down Expand Up @@ -663,6 +668,7 @@ fun ReviewListLoadingPreview() {
EatssuTheme {
ReviewListScreen(
menuName = "소고기+닭고기+돼지고기+양고기+오리고기",
restaurant = Restaurant.HAKSIK,
onReviewWriteButtonClick = {},
onModifyClick = {},
onDeleteClick = {},
Expand Down Expand Up @@ -698,6 +704,7 @@ fun ReviewListEmptyPreview() {
EatssuTheme {
ReviewListScreen(
menuName = "소고기+닭고기+돼지고기+양고기+오리고기+닭고기+돼지고기+양고기",
restaurant = Restaurant.HAKSIK,
onReviewWriteButtonClick = {},
onModifyClick = {},
onDeleteClick = {},
Expand Down Expand Up @@ -733,6 +740,7 @@ fun ReviewListErrorPreview() {
EatssuTheme {
ReviewListScreen(
menuName = "소고기+닭고기+돼지고기+양고기+오리고기",
restaurant = Restaurant.HAKSIK,
onReviewWriteButtonClick = {},
onModifyClick = {},
onDeleteClick = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import com.eatssu.android.presentation.util.showToast
import com.eatssu.common.UiEvent
import com.eatssu.common.UiState
import com.eatssu.common.enums.MenuType
import com.eatssu.common.enums.Restaurant
import com.eatssu.common.enums.ScreenId
import com.eatssu.design_system.component.CloseTopBar
import com.eatssu.design_system.component.EatSsuButton
Expand All @@ -72,6 +73,7 @@ fun WriteReviewScreen(
viewModel: WriteReviewViewModel = hiltViewModel(),
menuName: String,
menuType: MenuType,
restaurant: Restaurant,
id: Long,
onBack: () -> Unit,
) {
Expand Down Expand Up @@ -121,7 +123,7 @@ fun WriteReviewScreen(
onToggleLike = viewModel::toggleLike,
onImageSelect = { galleryLauncher.launch("image/*") },
onImageDelete = { viewModel.setSelectedImage(null) },
onSubmit = { viewModel.postReview(menuType, id, context) }
onSubmit = { viewModel.postReview(menuType, restaurant, id, context) }
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.eatssu.common.UiState
import com.eatssu.common.UiText
import com.eatssu.common.analytics.ReviewAnalyticsEvent
import com.eatssu.common.enums.MenuType
import com.eatssu.common.enums.Restaurant
import com.eatssu.common.enums.ToastType
import dagger.hilt.android.lifecycle.HiltViewModel
import id.zelory.compressor.Compressor
Expand Down Expand Up @@ -88,6 +89,7 @@ class WriteReviewViewModel @Inject constructor(

fun postReview(
menuType: MenuType,
restaurant: Restaurant,
itemId: Long,
context: Context,
) {
Expand Down Expand Up @@ -167,6 +169,7 @@ class WriteReviewViewModel @Inject constructor(
rating = editing.rating.toLong(),
likes = editing.likedMenuIds.size.toLong(),
photoAttached = editing.selectedImageUri != null,
restaurant = restaurant,
),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import com.eatssu.android.R
import com.eatssu.android.data.local.AppFeatureDataStore
import com.eatssu.android.presentation.mypage.terms.WebViewActivity
import com.eatssu.android.presentation.util.openInBrowser
import com.eatssu.common.analytics.AnalyticsTracker
import com.eatssu.common.analytics.PopupEvent
import com.eatssu.common.enums.ScreenId
import com.eatssu.design_system.theme.EatssuTheme
import dagger.hilt.android.qualifiers.ActivityContext
Expand All @@ -22,7 +24,16 @@ import javax.inject.Inject
class AnyoneButMeEventPopupController @Inject constructor(
@ActivityContext private val context: Context,
private val appFeatureDataStore: AppFeatureDataStore,
private val analyticsTracker: AnalyticsTracker,
) {
private companion object {
const val POPUP_NAME_PLZ_NOT_ME = "plz_not_me"
const val ACTION_CLICK_POPUP_IMAGE = "click_popup_image"
const val ACTION_GO_INSTA = "go_insta"
const val ACTION_NOT_SHOW_AGAIN = "not_show_again"
const val ACTION_CLOSE = "close"
}

private lateinit var composeView: ComposeView
private lateinit var lifecycleScope: LifecycleCoroutineScope
private var canAutoShowOnLaunch = false
Expand All @@ -49,10 +60,10 @@ class AnyoneButMeEventPopupController @Inject constructor(
EatssuTheme {
if (isPopupVisible.value) {
AnyoneButMeEventDialog(
onDismiss = ::hide,
onDismiss = ::closePopup,
onDismissForever = ::dismissForever,
onInstagramClick = ::openInstagram,
onAnyoneButMeClick = ::openAnyoneButMePage
onInstagramClick = ::openInstagramFromPopup,
onAnyoneButMeClick = ::openAnyoneButMePageFromPopup
)
}
}
Expand All @@ -71,12 +82,23 @@ class AnyoneButMeEventPopupController @Inject constructor(
}

private fun dismissForever() {
trackPopupAction(ACTION_NOT_SHOW_AGAIN)
hide()
lifecycleScope.launch {
appFeatureDataStore.setAnyoneButMeEventPopupDismissed(true)
}
}

private fun closePopup() {
trackPopupAction(ACTION_CLOSE)
hide()
}

private fun openAnyoneButMePageFromPopup() {
trackPopupAction(ACTION_CLICK_POPUP_IMAGE)
openAnyoneButMePage()
}

fun openAnyoneButMePage() {
hide()
context.startActivity(
Expand All @@ -92,11 +114,21 @@ class AnyoneButMeEventPopupController @Inject constructor(
)
}

private fun openInstagram() {
private fun openInstagramFromPopup() {
trackPopupAction(ACTION_GO_INSTA)
hide()
context.openInBrowser(context.getString(R.string.eatssu_event_instagram_url))
}

private fun trackPopupAction(action: String) {
analyticsTracker.track(
PopupEvent(
popupName = POPUP_NAME_PLZ_NOT_ME,
popupAction = action,
),
)
}

private fun hide() {
canAutoShowOnLaunch = false
isPopupVisible.value = false
Expand Down
Loading
Loading