Skip to content

Commit

Permalink
[#1009] 기존 코드 AmplitudeTracker -> Tracker로 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
l2hyunwoo committed Dec 31, 2024
1 parent 5639544 commit 0389e2e
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.sopt.official.R
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.analytics.EventType
import org.sopt.official.analytics.Tracker
import org.sopt.official.auth.model.UserActiveState
import org.sopt.official.auth.model.UserStatus
import org.sopt.official.common.navigator.DeepLinkType
Expand Down Expand Up @@ -90,7 +90,7 @@ class HomeActivity : AppCompatActivity() {
private val args by serializableExtra(StartArgs(UserStatus.UNAUTHENTICATED))

@Inject
lateinit var tracker: AmplitudeTracker
lateinit var tracker: Tracker
private val smallBlockAdapter: SmallBlockAdapter?
get() = binding.smallBlockList.adapter as? SmallBlockAdapter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ import android.content.Intent
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.staticCompositionLocalOf
import com.airbnb.deeplinkdispatch.DeepLink
import dagger.hilt.android.AndroidEntryPoint
import dagger.hilt.android.EntryPointAccessors
import org.sopt.official.analytics.compose.ProvideTracker
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.common.context.appContext
import org.sopt.official.common.navigator.NavigatorEntryPoint
Expand All @@ -47,10 +46,6 @@ private val navigator by lazy {
).navigatorProvider()
}

internal val LocalAmplitudeTracker = staticCompositionLocalOf<AmplitudeTracker> {
error("No AmplitudeTracker provided")
}

@AndroidEntryPoint
@DeepLink("sopt://fortune")
class FortuneActivity : AppCompatActivity() {
Expand All @@ -62,7 +57,7 @@ class FortuneActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContent {
SoptTheme {
CompositionLocalProvider(LocalAmplitudeTracker provides amplitudeTracker) {
ProvideTracker(amplitudeTracker) {
FoundationScreen(
onClickLeadingIcon = ::finish,
navigateToHome = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import org.sopt.official.analytics.EventType
import org.sopt.official.analytics.compose.LocalTracker
import org.sopt.official.designsystem.SoptTheme
import org.sopt.official.designsystem.SoptTheme.colors
import org.sopt.official.feature.fortune.LocalAmplitudeTracker

@Composable
fun FortuneTopBar(
onClickNavigationIcon: () -> Unit,
modifier: Modifier = Modifier,
isEnabled: Boolean = true,
) {
val amplitudeTracker = LocalAmplitudeTracker.current
val amplitudeTracker = LocalTracker.current

Box(modifier = modifier.fillMaxWidth()) {
Icon(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import org.sopt.official.analytics.EventType
import org.sopt.official.analytics.compose.LocalTracker
import org.sopt.official.designsystem.SoptTheme
import org.sopt.official.feature.fortune.LocalAmplitudeTracker
import org.sopt.official.feature.fortune.component.CircleShapeBorderButton
import org.sopt.official.feature.fortune.component.UrlImage

Expand All @@ -56,7 +56,7 @@ internal fun FortuneAmuletRoute(
onHomeClick: () -> Unit,
viewModel: FortuneAmuletViewModel = hiltViewModel(),
) {
val amplitudeTracker = LocalAmplitudeTracker.current
val amplitudeTracker = LocalTracker.current
val state by viewModel.state.collectAsStateWithLifecycle()

when {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import kotlinx.coroutines.launch
import org.sopt.official.analytics.EventType.CLICK
import org.sopt.official.analytics.EventType.VIEW
import org.sopt.official.analytics.compose.LocalTracker
import org.sopt.official.designsystem.SoptTheme.colors
import org.sopt.official.feature.fortune.LocalAmplitudeTracker
import org.sopt.official.feature.fortune.feature.fortuneDetail.component.PokeMessageBottomSheetScreen
import org.sopt.official.feature.fortune.feature.fortuneDetail.model.FortuneDetailUiState.Success
import org.sopt.official.feature.fortune.feature.fortuneDetail.model.SnackBarUiState
Expand All @@ -73,7 +73,7 @@ internal fun FortuneDetailRoute(
var selectedIndex by remember { mutableIntStateOf(DEFAULT_ID) }
val bottomSheetState = rememberModalBottomSheetState(initialValue = Hidden)
val scope = rememberCoroutineScope()
val amplitudeTracker = LocalAmplitudeTracker.current
val amplitudeTracker = LocalTracker.current

LaunchedEffect(key1 = uiState) {
if (uiState is Success) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import org.sopt.official.analytics.EventType
import org.sopt.official.analytics.compose.LocalTracker
import org.sopt.official.designsystem.SoptTheme
import org.sopt.official.feature.fortune.LocalAmplitudeTracker
import org.sopt.official.feature.fortune.R
import org.sopt.official.feature.fortune.component.FortuneButton
import java.time.LocalDate
Expand All @@ -55,7 +55,7 @@ internal fun HomeRoute(
onFortuneDetailClick: (String) -> Unit,
) {
val date = rememberSaveable { getToday() }
val amplitudeTracker = LocalAmplitudeTracker.current.also {
val amplitudeTracker = LocalTracker.current.also {
it.track(
type = EventType.VIEW,
name = "view_soptmadi_title",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.analytics.EventType
import org.sopt.official.analytics.Tracker
import org.sopt.official.common.util.colorOf
import org.sopt.official.common.util.dp
import org.sopt.official.common.util.ui.setVisible
Expand All @@ -66,14 +65,15 @@ import org.sopt.official.feature.poke.user.PokeUserListItemViewType
import org.sopt.official.feature.poke.util.addOnAnimationEndListener
import org.sopt.official.feature.poke.util.setRelationStrokeColor
import org.sopt.official.feature.poke.util.showPokeToast
import javax.inject.Inject

@AndroidEntryPoint
class FriendListDetailBottomSheetFragment : BottomSheetDialogFragment() {
private val binding by viewBinding(FragmentFriendListDetailBottomSheetBinding::bind)
private lateinit var viewModel: FriendListDetailViewModel

@Inject
lateinit var tracker: AmplitudeTracker
lateinit var tracker: Tracker

private var messageListBottomSheet: MessageListBottomSheetFragment? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ import androidx.lifecycle.lifecycleScope
import coil.load
import coil.transform.CircleCropTransformation
import dagger.hilt.android.AndroidEntryPoint
import java.io.Serializable
import javax.inject.Inject
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.analytics.EventType
import org.sopt.official.analytics.Tracker
import org.sopt.official.auth.model.UserStatus
import org.sopt.official.common.util.colorOf
import org.sopt.official.common.util.dp
Expand All @@ -66,6 +64,8 @@ import org.sopt.official.feature.poke.user.PokeUserListItemViewType
import org.sopt.official.feature.poke.util.addOnAnimationEndListener
import org.sopt.official.feature.poke.util.setRelationStrokeColor
import org.sopt.official.feature.poke.util.showPokeToast
import java.io.Serializable
import javax.inject.Inject

@AndroidEntryPoint
class FriendListSummaryActivity : AppCompatActivity() {
Expand All @@ -76,7 +76,7 @@ class FriendListSummaryActivity : AppCompatActivity() {
private var messageListBottomSheet: MessageListBottomSheetFragment? = null

@Inject
lateinit var tracker: AmplitudeTracker
lateinit var tracker: Tracker

private val newFriendListAdapter
get() = binding.includeFriendListBlockNewFriend.recyclerView.adapter as PokeUserListAdapter?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.analytics.EventType
import org.sopt.official.analytics.Tracker
import org.sopt.official.auth.model.UserStatus
import org.sopt.official.common.util.serializableExtra
import org.sopt.official.common.util.ui.setVisible
Expand Down Expand Up @@ -74,7 +74,7 @@ class PokeMainActivity : AppCompatActivity() {
get() = binding.recyclerViewPokeMain.adapter as PokeMainListAdapter?

@Inject
lateinit var tracker: AmplitudeTracker
lateinit var tracker: Tracker

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.analytics.EventType
import org.sopt.official.analytics.Tracker
import org.sopt.official.common.util.serializableExtra
import org.sopt.official.common.util.viewBinding
import org.sopt.official.domain.poke.entity.PokeUser
Expand All @@ -68,7 +68,7 @@ class PokeNotificationActivity : AppCompatActivity() {
private val args by serializableExtra(Argument(""))

@Inject
lateinit var tracker: AmplitudeTracker
lateinit var tracker: Tracker
private val pokeNotificationAdapter
get() = binding.recyclerviewPokeNotification.adapter as PokeNotificationAdapter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
import java.io.Serializable
import javax.inject.Inject
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.analytics.EventType
import org.sopt.official.analytics.Tracker
import org.sopt.official.common.util.serializableExtra
import org.sopt.official.common.util.viewBinding
import org.sopt.official.domain.poke.entity.PokeRandomUserList
Expand All @@ -48,6 +46,8 @@ import org.sopt.official.feature.poke.databinding.ActivityOnboardingBinding
import org.sopt.official.feature.poke.main.PokeMainActivity
import org.sopt.official.feature.poke.util.addOnAnimationEndListener
import org.sopt.official.feature.poke.util.showPokeToast
import java.io.Serializable
import javax.inject.Inject

@AndroidEntryPoint
class OnboardingActivity : AppCompatActivity() {
Expand All @@ -59,7 +59,7 @@ class OnboardingActivity : AppCompatActivity() {
private var onboardingBottomSheet: OnboardingBottomSheetFragment? = null

@Inject
lateinit var tracker: AmplitudeTracker
lateinit var tracker: Tracker

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.analytics.EventType
import org.sopt.official.analytics.Tracker
import org.sopt.official.common.util.serializableArgs
import org.sopt.official.domain.poke.entity.PokeRandomUserList
import org.sopt.official.domain.poke.entity.PokeUser
Expand All @@ -54,6 +53,7 @@ import org.sopt.official.feature.poke.user.PokeUserListAdapter
import org.sopt.official.feature.poke.user.PokeUserListClickListener
import org.sopt.official.feature.poke.user.PokeUserListItemViewType
import org.sopt.official.feature.poke.util.showPokeToast
import javax.inject.Inject

@AndroidEntryPoint
class OnboardingPokeUserFragment : Fragment() {
Expand All @@ -66,7 +66,7 @@ class OnboardingPokeUserFragment : Fragment() {
private val args by serializableArgs<OnboardingActivity.StartArgs>()

@Inject
lateinit var tracker: AmplitudeTracker
lateinit var tracker: Tracker

private var messageListBottomSheet: MessageListBottomSheetFragment? = null
private val pokeUserListAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,46 +30,40 @@ import android.graphics.Color
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat
import com.ramcosta.composedestinations.DestinationsNavHost
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import org.sopt.official.analytics.impl.AmplitudeTracker
import org.sopt.official.analytics.Tracker
import org.sopt.official.analytics.compose.ProvideTracker
import org.sopt.official.stamp.feature.NavGraphs

val LocalTracker = staticCompositionLocalOf<AmplitudeTracker> {
error("No AmplitudeTracker provided")
}
import javax.inject.Inject

@AndroidEntryPoint
class SoptampActivity : AppCompatActivity() {
@Inject
lateinit var tracker: AmplitudeTracker
@Inject
lateinit var tracker: Tracker

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
window.statusBarColor = Color.WHITE
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = true
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
window.statusBarColor = Color.WHITE
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = true
}
}
ProvideTracker(tracker) {
DestinationsNavHost(navGraph = NavGraphs.root)
}
}
}

CompositionLocalProvider(LocalTracker provides tracker) {
DestinationsNavHost(navGraph = NavGraphs.root)
}
}
}

companion object {
fun getIntent(context: Context): Intent {
return Intent(context, SoptampActivity::class.java)
companion object {
fun getIntent(context: Context): Intent {
return Intent(context, SoptampActivity::class.java)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -61,7 +60,7 @@ import com.ramcosta.composedestinations.result.ResultBackNavigator
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import org.sopt.official.analytics.EventType
import org.sopt.official.stamp.LocalTracker
import org.sopt.official.analytics.compose.LocalTracker
import org.sopt.official.stamp.config.navigation.MissionNavGraph
import org.sopt.official.stamp.designsystem.component.dialog.SingleOptionDialog
import org.sopt.official.stamp.designsystem.component.layout.LoadingScreen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
Expand All @@ -59,7 +58,7 @@ import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import com.ramcosta.composedestinations.result.ResultBackNavigator
import kotlinx.coroutines.launch
import org.sopt.official.analytics.EventType
import org.sopt.official.stamp.LocalTracker
import org.sopt.official.analytics.compose.LocalTracker
import org.sopt.official.stamp.R
import org.sopt.official.stamp.config.navigation.MissionNavGraph
import org.sopt.official.stamp.designsystem.component.button.SoptampFloatingButton
Expand Down

0 comments on commit 0389e2e

Please sign in to comment.