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/#129] 앰플리튜드 추가 #130

Merged
merged 14 commits into from
Sep 11, 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
10 changes: 10 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,23 @@ android {
"BASE_URL",
gradleLocalProperties(rootDir).getProperty("dev.base.url"),
)
buildConfigField(
"String",
"AMPLITUDE_KEY",
gradleLocalProperties(rootDir).getProperty("dev.amplitude.key"),
)
}
release {
buildConfigField(
"String",
"BASE_URL",
gradleLocalProperties(rootDir).getProperty("base.url"),
)
buildConfigField(
"String",
"AMPLITUDE_KEY",
gradleLocalProperties(rootDir).getProperty("amplitude.key"),
)

isMinifyEnabled = false
proguardFiles(
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

<application
android:name=".MyApp"
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/co/orange/ddanzi/MyApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package co.orange.ddanzi

import android.app.Application
import androidx.appcompat.app.AppCompatDelegate
import co.orange.core.amplitude.AmplitudeManager
import co.orange.ddanzi.BuildConfig.AMPLITUDE_KEY
import co.orange.ddanzi.BuildConfig.NATIVE_APP_KEY
import com.kakao.sdk.common.KakaoSdk
import dagger.hilt.android.HiltAndroidApp
Expand All @@ -14,6 +16,7 @@ class MyApp : Application() {

initTimber()
initKakaoSdk()
initAmplitude()
setDayMode()
}

Expand All @@ -25,6 +28,10 @@ class MyApp : Application() {
KakaoSdk.init(this, NATIVE_APP_KEY)
}

private fun initAmplitude() {
AmplitudeManager.init(this, AMPLITUDE_KEY)
}

private fun setDayMode() {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.Intent
import android.os.Handler
import android.os.Looper
import co.orange.auth.login.LoginActivity
import co.orange.core.amplitude.AmplitudeManager
import co.orange.core.extension.toast
import co.orange.domain.entity.request.ReissueRequestModel
import co.orange.domain.repository.AuthRepository
Expand Down Expand Up @@ -63,6 +64,7 @@ class AuthInterceptor
userRepository.clearInfo()

Handler(Looper.getMainLooper()).post {
AmplitudeManager.trackEvent("view_sign_up", mapOf("sign_up_from" to "token"))
context.toast(TOKEN_EXPIRED_ERROR)
Intent(context, LoginActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package co.orange.ddanzi.di.module

import co.orange.core.navigation.NavigationManager
import co.orange.ddanzi.di.navigate.NavigationManagerImpl
import co.orange.ddanzi.navigation.NavigationManagerImpl
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package co.orange.ddanzi.di.navigate
package co.orange.ddanzi.navigation

import android.content.Context
import android.content.Intent
import co.orange.auth.login.LoginActivity
import co.orange.buy.finished.BuyFinishedActivity
import co.orange.buy.info.BuyInfoActivity
import co.orange.buy.progress.BuyProgressActivity
import co.orange.core.amplitude.AmplitudeManager
import co.orange.core.navigation.NavigationManager
import co.orange.main.alarm.AlarmRequestActivity
import co.orange.main.detail.DetailActivity
Expand Down Expand Up @@ -63,7 +64,11 @@ class NavigationManagerImpl

/** To Auth Module**/

override fun toLoginView(context: Context) {
override fun toLoginView(
context: Context,
property: String,
) {
AmplitudeManager.trackEvent("view_sign_up", mapOf("sign_up_from" to property))
context.startActivity(Intent(context, LoginActivity::class.java))
}

Expand Down
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ buildscript {
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}

apply {
from("gradle/projectDependencyGraph.gradle")
}
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ object ThirdPartyDependencies {
const val timber = "com.jakewharton.timber:timber:${Versions.timberVersion}"
const val coil = "io.coil-kt:coil:${Versions.coilVersion}"
const val lottie = "com.airbnb.android:lottie:${Versions.lottieVersion}"
const val amplitude = "com.amplitude:analytics-android:${Versions.amplitudeVersion}"

const val progressView = "com.github.skydoves:progressview:${Versions.progressViewVersion}"
const val balloon = "com.github.skydoves:balloon:${Versions.balloonVersion}"
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ object Versions {
const val circleIndicatorVersion = "2.1.6"
const val mlkitVersion = "16.0.0"
const val appUpdateVersion = "2.1.0"
const val amplitudeVersion = "1.17.3"

const val iamportVersion = "v1.4.5"

Expand Down
36 changes: 23 additions & 13 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,31 @@ android {
}

dependencies {
// Kotlin
implementation(KotlinDependencies.kotlin)
KotlinDependencies.run {
implementation(kotlin)
}

// Lifecycle Ktx
implementation(AndroidXDependencies.lifeCycleKtx)
AndroidXDependencies.run {
implementation(lifeCycleKtx)
implementation(hilt)
}

// Material Design
implementation(GoogleDependencies.materialDesign)
GoogleDependencies.run {
implementation(materialDesign)
}

// Hilt
implementation(AndroidXDependencies.hilt)
kapt(KaptDependencies.hiltAndroidCompiler)
KaptDependencies.run {
kapt(hiltAndroidCompiler)
}

// Test Dependency
testImplementation(TestDependencies.jUnit)
androidTestImplementation(TestDependencies.androidTest)
androidTestImplementation(TestDependencies.espresso)
ThirdPartyDependencies.run {
implementation(timber)
implementation(amplitude)
}

TestDependencies.run {
testImplementation(jUnit)
androidTestImplementation(androidTest)
androidTestImplementation(espresso)
}
}
52 changes: 52 additions & 0 deletions core/src/main/java/co/orange/core/amplitude/AmplitudeManager.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package co.orange.core.amplitude

import android.content.Context
import com.amplitude.android.Amplitude
import com.amplitude.android.Configuration
import com.amplitude.android.events.Identify

object AmplitudeManager {
private lateinit var amplitude: Amplitude

fun init(
context: Context,
apiKey: String,
) {
amplitude =
Amplitude(
Configuration(
apiKey = apiKey,
context = context.applicationContext,
),
)
}

fun trackEvent(
eventName: String,
properties: Map<String, Any>? = null,
) {
if (properties == null) {
amplitude.track(eventName)
} else {
amplitude.track(eventName, properties)
}
}

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

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

fun plusIntProperties(propertyName: String) {
amplitude.identify(Identify().add(propertyName, 1))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ interface NavigationManager {

/** To Auth Module**/

fun toLoginView(context: Context)
fun toLoginView(
context: Context,
property: String,
)

/** To Setting Module**/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.lifecycle.lifecycleScope
import co.orange.auth.databinding.ActivityLoginBinding
import co.orange.auth.phone.PhoneActivity
import co.orange.core.R
import co.orange.core.amplitude.AmplitudeManager
import co.orange.core.base.BaseActivity
import co.orange.core.extension.setOnSingleClickListener
import co.orange.core.extension.stringOf
Expand All @@ -34,6 +35,7 @@ class LoginActivity : BaseActivity<ActivityLoginBinding>(featureR.layout.activit

private fun initLoginBtnListener() {
binding.btnLoginKakao.setOnSingleClickListener {
AmplitudeManager.trackEvent("click_sign_up_kakao")
viewModel.startLogInWithKakao(this)
}
}
Expand Down
15 changes: 10 additions & 5 deletions feature/auth/src/main/java/co/orange/auth/phone/PhoneActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import co.orange.auth.BuildConfig.MERCHANT_UID
import co.orange.auth.databinding.ActivityPhoneBinding
import co.orange.auth.submit.SubmitActivity
import co.orange.core.R
import co.orange.core.amplitude.AmplitudeManager
import co.orange.core.base.BaseActivity
import co.orange.core.extension.setOnSingleClickListener
import co.orange.core.extension.setStatusBarColorFromResource
Expand All @@ -34,16 +35,22 @@ class PhoneActivity : BaseActivity<ActivityPhoneBinding>(featureR.layout.activit
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Iamport.init(this)
initView()
initAuthBtnListener()
observeIsSubmitClicked()
observeIamportTokenResult()
observeIamportCertificationResult()
observeSignUpState()
}

private fun initView() {
Iamport.init(this)
AmplitudeManager.trackEvent("view_verification")
}

private fun initAuthBtnListener() {
binding.btnPhoneAuth.setOnSingleClickListener {
AmplitudeManager.trackEvent("click_verification_next")
termBottomSheet = TermBottomSheet()
termBottomSheet?.show(supportFragmentManager, BOTTOM_SHEET_TERM)
}
Expand Down Expand Up @@ -108,11 +115,9 @@ class PhoneActivity : BaseActivity<ActivityPhoneBinding>(featureR.layout.activit
.onEach { state ->
when (state) {
is UiState.Success -> {
AmplitudeManager.trackEvent("complete_sign_up")
setLoadingScreen(false)
SubmitActivity.createIntent(this, state.data).apply {
startActivity(this)
}
finish()
startActivity(SubmitActivity.createIntent(this, state.data))
}

is UiState.Failure -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package co.orange.auth.phone
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
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
Expand Down Expand Up @@ -47,6 +48,7 @@ class PhoneViewModel
val postSignUpState: StateFlow<UiState<String>> = _postSignUpState

fun checkAllTerm() {
AmplitudeManager.trackEvent("click_verification_terms_all")
isTermPrivateSelected.value = isTermAllSelected.value?.not()
isTermServiceSelected.value = isTermAllSelected.value?.not()
isTermMarketingSelected.value = isTermAllSelected.value?.not()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.view.View
import androidx.fragment.app.activityViewModels
import co.orange.auth.databinding.BottomSheetTermBinding
import co.orange.core.R
import co.orange.core.amplitude.AmplitudeManager
import co.orange.core.base.BaseBottomSheet
import co.orange.core.extension.setOnSingleClickListener
import co.orange.auth.R as featureR
Expand Down Expand Up @@ -48,6 +49,7 @@ class TermBottomSheet :

private fun initSubmitBtnListener() {
binding.btnSubmit.setOnSingleClickListener {
AmplitudeManager.trackEvent("click_verification_terms_next")
viewModel.clickSubmitBtn(true)
dismiss()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.lifecycle.lifecycleScope
import co.orange.buy.databinding.ActivityBuyFinishedBinding
import co.orange.buy.info.BuyInfoActivity
import co.orange.core.R
import co.orange.core.amplitude.AmplitudeManager
import co.orange.core.base.BaseActivity
import co.orange.core.extension.breakLines
import co.orange.core.extension.convertDateTime
Expand Down Expand Up @@ -38,15 +39,26 @@ class BuyFinishedActivity :
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

initView()
initReturnBtnListener()
initDetailBtnListener()
getIntentInfo()
observeGetOrderInfoState()
}

private fun initView() {
AmplitudeManager.trackEvent(
"complete_purchase_adjustment",
mapOf("order_id" to viewModel.orderId),
)
}

private fun initReturnBtnListener() {
binding.btnHome.setOnSingleClickListener { navigateToHome() }
binding.btnKeepShopping.setOnSingleClickListener { navigateToHome() }
binding.btnKeepShopping.setOnSingleClickListener {
AmplitudeManager.trackEvent("click_purchase_adjustment_add")
navigateToHome()
}
}

private fun navigateToHome() {
Expand All @@ -55,9 +67,8 @@ class BuyFinishedActivity :

private fun initDetailBtnListener() {
binding.btnShowDetail.setOnSingleClickListener {
BuyInfoActivity.createIntent(this, viewModel.orderId).apply {
startActivity(this)
}
AmplitudeManager.trackEvent("click_purchase_adjustment_check")
startActivity(BuyInfoActivity.createIntent(this, viewModel.orderId))
}
}

Expand Down
Loading
Loading