Skip to content

Commit

Permalink
[feature/#368] Amplitude 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
kimdahyee authored and l2hyunwoo committed Oct 2, 2023
1 parent bb07758 commit 920dbf5
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 19 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ dependencies {
implementation(libs.sentry.compose)
implementation(libs.process.phoenix)

implementation(libs.amplitude.android)

implementation(libs.compose.destination.core)
ksp(libs.compose.destination.ksp)

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

<queries>
<package android:name="com.android.chrome" />
<package android:name="com.chrome.beta" />
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/org/sopt/official/feature/home/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,30 @@ import org.sopt.official.util.setOnSingleClickListener
import org.sopt.official.util.stringOf
import org.sopt.official.util.ui.setVisible
import org.sopt.official.util.viewBinding
import com.amplitude.android.Amplitude
import com.amplitude.android.Configuration
import org.sopt.official.BuildConfig

@AndroidEntryPoint
class HomeActivity : AppCompatActivity() {
private val binding by viewBinding(ActivitySoptMainBinding::inflate)
private val viewModel by viewModels<HomeViewModel>()
private val args by serializableExtra(UserStatus.UNAUTHENTICATED)

private val amplitude by lazy {
val apiKey = if (BuildConfig.DEBUG) {
BuildConfig.devAmplitudeKey
} else {
BuildConfig.amplitudeKey
}
Amplitude(
Configuration(
apiKey = apiKey,
context = applicationContext
)
)
}

private val smallBlockAdapter: SmallBlockAdapter?
get() = binding.smallBlockList.adapter as? SmallBlockAdapter

Expand Down Expand Up @@ -85,6 +102,7 @@ class HomeActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
amplitude.track(eventType = "view_apphome", eventProperties = mapOf("view_type" to args?.value))

requestNotificationPermission()
initToolbar()
Expand All @@ -100,6 +118,7 @@ class HomeActivity : AppCompatActivity() {

private fun initToolbar() {
binding.mypage.setOnClickListener {
amplitude.track(eventType = "click_mypage", eventProperties = mapOf("view_type" to args?.value))
lifecycleScope.launch {
startActivity(
MyPageActivity.getIntent(this@HomeActivity, MyPageActivity.StartArgs(viewModel.userActiveState.value))
Expand Down Expand Up @@ -140,6 +159,7 @@ class HomeActivity : AppCompatActivity() {
if (isClickable) {
val intent = Intent(this@HomeActivity, SoptampActivity::class.java)
binding.contentSoptamp.root.setOnSingleClickListener {
amplitude.track(eventType = "click_soptamp", eventProperties = mapOf("view_type" to args?.value))
this@HomeActivity.startActivity(intent)
}
}
Expand Down Expand Up @@ -224,6 +244,7 @@ class HomeActivity : AppCompatActivity() {
Intent(Intent.ACTION_VIEW, Uri.parse(item.url))
}
largeBlock.root.setOnSingleClickListener {
amplitude.track(eventType = item.clickEventType, eventProperties = mapOf("view_type" to args?.value))
startActivity(intent)
}
}
Expand All @@ -236,6 +257,7 @@ class HomeActivity : AppCompatActivity() {
descriptionSmall.isVisible = item.description != null
descriptionSmall.text = item.description?.let { stringOf(it) }
root.setOnSingleClickListener {
amplitude.track(eventType = item.clickEventType, eventProperties = mapOf("view_type" to args?.value))
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(item.url))
startActivity(intent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,28 @@ enum class HomeCTAType(
@StringRes val title: Int,
@StringRes val description: Int?,
val url: String?,
@DrawableRes val icon: Int
@DrawableRes val icon: Int,
val clickEventType: String
) {
SOPT_OFFICIAL_PAGE_URL(
R.string.main_unauthenticated_large_block_official_page,
null,
WebUrlConstant.SOPT_OFFICIAL_PAGE_URL,
R.drawable.ic_homepage_orange
R.drawable.ic_homepage_orange,
"click_homepage"
),
SOPT_ATTENDANCE(
R.string.main_active_large_block_attendance,
R.string.main_active_large_block_attendance_description,
null,
R.drawable.ic_attendance_orange
R.drawable.ic_attendance_orange,
"click_attendance"
),
SOPT_CREW_URL(
R.string.main_inactive_large_block_crew,
R.string.main_inactive_large_block_crew_description,
WebUrlConstant.PLAYGROUNG_CREW_URL,
R.drawable.ic_crew_orange
R.drawable.ic_crew_orange,
"click_group"
),
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,95 +9,110 @@ enum class HomeMenuType(
@StringRes val title: Int,
@StringRes val description: Int?,
val url: String,
@DrawableRes val icon: Int
@DrawableRes val icon: Int,
val clickEventType: String
) {
// 비회원
SOPT_REVIEW_AUTHENTICATED_URL(
R.string.main_unauthenticated_small_block_review,
R.string.main_unauthenticated_small_block_review_description,
WebUrlConstant.SOPT_REVIEW_URL,
R.drawable.ic_review
R.drawable.ic_review,
"click_review"
),
SOPT_PROJECT_AUTHENTICATED_URL(
R.string.main_unauthenticated_small_block_project,
R.string.main_unauthenticated_small_block_project_description,
WebUrlConstant.SOPT_PROJECT_URL,
R.drawable.ic_project
R.drawable.ic_project,
"click_project"
),
SOPT_INSTAGRAM_AUTHENTICATED_URL(
R.string.main_unauthenticated_small_block_instagram,
R.string.main_unauthenticated_small_block_instagram_description,
WebUrlConstant.SOPT_INSTAGRAM,
R.drawable.ic_instagram
R.drawable.ic_instagram,
"click_instagram"
),
SOPT_YOUTUBE_AUTHENTICATED_URL(
R.string.main_unauthenticated_small_block_youtube,
R.string.main_unauthenticated_small_block_youtube_description,
WebUrlConstant.SOPT_OFFICIAL_YOUTUBE,
R.drawable.ic_youtube
R.drawable.ic_youtube,
"click_youtube"
),
SOPT_FAQ_AUTHENTICATED_URL(
R.string.main_unauthenticated_small_block_faq,
R.string.main_unauthenticated_small_block_faq_description,
WebUrlConstant.SOPT_FAQ_URL,
R.drawable.ic_faq
R.drawable.ic_faq,
"click_faq"
),

// 활동
SOPT_CREW_ACTIVE_URL(
R.string.main_active_small_block_crew,
R.string.main_active_small_block_crew_description,
WebUrlConstant.PLAYGROUNG_CREW_URL,
R.drawable.ic_crew_white100
R.drawable.ic_crew_white100,
"click_group"
),
SOPT_MEMBER_ACTIVE_URL(
R.string.main_active_small_block_member,
R.string.main_active_small_block_member_description,
WebUrlConstant.PLAYGROUNG_MEMBER_URL,
R.drawable.ic_member_white100
R.drawable.ic_member_white100,
"click_member"
),
SOPT_PROJECT_ACTIVE_URL(
R.string.main_active_small_block_project,
R.string.main_active_small_block_project_description,
WebUrlConstant.PLAYGROUNG_PROJECT_URL,
R.drawable.ic_project
R.drawable.ic_project,
"click_project"
),
SOPT_OFFICIAL_PAGE_ACTIVE_URL(
R.string.main_active_small_block_official_page,
R.string.main_active_small_block_official_page_description,
WebUrlConstant.SOPT_OFFICIAL_PAGE_URL,
R.drawable.ic_homepage_white100
R.drawable.ic_homepage_white100,
"click_homepage"
),

// 비활동
SOPT_MEMBER_INACTIVE_URL(
R.string.main_inactive_small_block_member,
R.string.main_inactive_small_block_member_description,
WebUrlConstant.PLAYGROUNG_MEMBER_URL,
R.drawable.ic_member_white100
R.drawable.ic_member_white100,
"click_member"
),
SOPT_PROJECT_INACTIVE_URL(
R.string.main_inactive_small_block_project,
R.string.main_inactive_small_block_project_description,
WebUrlConstant.PLAYGROUNG_PROJECT_URL,
R.drawable.ic_project
R.drawable.ic_project,
"click_project"
),
SOPT_OFFICIAL_PAGE_INACTIVE_URL(
R.string.main_inactive_small_block_official_page,
null,
WebUrlConstant.SOPT_OFFICIAL_PAGE_URL,
R.drawable.ic_homepage_white100
R.drawable.ic_homepage_white100,
"click_homepage"
),
SOPT_INSTAGRAM_INACTIVE_URL(
R.string.main_inactive_small_block_instagram,
null,
WebUrlConstant.SOPT_INSTAGRAM,
R.drawable.ic_instagram
R.drawable.ic_instagram,
"click_instagram"
),
SOPT_YOUTUBE_INACTIVE_URL(
R.string.main_inactive_small_block_youtube,
null,
WebUrlConstant.SOPT_OFFICIAL_YOUTUBE,
R.drawable.ic_youtube
R.drawable.ic_youtube,
"click_youtube"
);
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ ktlint = "11.6.0"
sentry = "3.13.0"
sentry-android = "6.30.0"
process-pheonix = "2.1.2"
amplitude = "1.11.1"

[libraries]
agp = { module = "com.android.tools.build:gradle", version.ref = "gradleplugin" }
Expand Down Expand Up @@ -172,6 +173,7 @@ rxandroid = { module = "io.reactivex.rxjava3:rxandroid", version.ref = "rxandroi
rxjava = { module = "io.reactivex.rxjava3:rxjava", version.ref = "rxjava" }
rxkotlin = { module = "io.reactivex.rxjava3:rxkotlin", version.ref = "rxkotlin" }
rxbinding = { module = "com.jakewharton.rxbinding4:rxbinding", version.ref = "rxbinding" }
amplitude-android = { module = "com.amplitude:analytics-android", version.ref = "amplitude" }

[bundles]
compose = [
Expand Down

0 comments on commit 920dbf5

Please sign in to comment.