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

[init] Amplitude 기초 세팅 #219

Merged
merged 6 commits into from
Mar 4, 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: 5 additions & 5 deletions .github/workflows/pr_builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ jobs:
HFM_BASE_URL: ${{ secrets.BASE_URL }}
run: echo "base.url=\"$BASE_URL\"" >> local.properties

- name: Access ACCESS_TOKEN
Copy link
Collaborator

Choose a reason for hiding this comment

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

오잉 이건 왜 지우는 거에요??

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

액세스 토큰 이제 로컬에 저장할 필요 없어서용

env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: echo "access.token=\"$ACCESS_TOKEN\"" >> local.properties

- name: Access IO_SENTRY_DSN
env:
IO_SENTRY_TOKEN: ${{ secrets.IO_SENTRY_DSN }}
Expand All @@ -67,6 +62,11 @@ jobs:
KAKAO_NATIVE_APP_KEY: ${{ secrets.KAKAO_NATIVE_APP_KEY }}
run: echo "kakao.native.app.key=\"$KAKAO_NATIVE_APP_KEY\"" >> local.properties

- name: Access AMPLITUDE_API_KEY
env:
KAKAO_NATIVE_APP_KEY: ${{ secrets.AMPLITUDE_API_KEY }}
run: echo "amplitude.api.key=\"AMPLITUDE_API_KEY\"" >> local.properties

- name: Access DEFAULTS_ORG
env:
DEFAULTS_ORG: ${{ secrets.DEFAULTS_ORG }}
Expand Down
4 changes: 4 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ android {
"KAKAO_NATIVE_APP_KEY",
properties["kakao.native.app.key"].toString()
)
buildConfigField("String", "AMPLITUDE_API_KEY", properties["amplitude.api.key"].toString())

manifestPlaceholders["IO_SENTRY_DSN"] = properties["io.sentry.dsn"] as String
manifestPlaceholders["KAKAO_NATIVE_APP_KEY_MANIFEST"] = properties["kakao.native.app.key.manifest"] as String
Expand Down Expand Up @@ -115,6 +116,9 @@ dependencies {

// Kakao
implementation(libs.kakao)

// Amplitude
implementation(libs.amplitude)
}

ktlint {
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_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

<application
android:name=".PingleApp"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/org/sopt/pingle/PingleApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.naver.maps.map.NaverMapSdk
import dagger.hilt.android.HiltAndroidApp
import org.sopt.pingle.BuildConfig.KAKAO_NATIVE_APP_KEY
import org.sopt.pingle.BuildConfig.NAVER_MAP_CLIENT_ID
import org.sopt.pingle.util.AmplitudeUtils.initAmplitude
import org.sopt.pingle.util.PingleDebugTree
import timber.log.Timber

Expand All @@ -19,6 +20,7 @@ class PingleApp : Application() {
setDarkMode()
setNaverMap()
setKakao()
initAmplitude(applicationContext)
}

private fun setTimber() {
Expand Down
33 changes: 33 additions & 0 deletions app/src/main/java/org/sopt/pingle/util/AmplitudeUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.sopt.pingle.util

import android.content.Context
import com.amplitude.android.Amplitude
import com.amplitude.android.Configuration
import org.sopt.pingle.BuildConfig

object AmplitudeUtils {
private lateinit var amplitude: Amplitude
fun initAmplitude(context: Context) {
amplitude = Amplitude(
Configuration(
apiKey = BuildConfig.AMPLITUDE_API_KEY,
context = context
)
)
}

fun trackEvent(eventName: String) {
amplitude.track(eventType = eventName)
}

fun <T> trackEventWithProperty(eventName: String, propertyName: String, propertyValue: T) {
amplitude.track(
eventType = eventName,
eventProperties = mapOf(propertyName to propertyValue)
)
}

fun trackEventWithProperties(eventName: String, properties: Map<String, Any>) {
amplitude.track(eventType = eventName, eventProperties = properties)
}
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ naver-maps = "3.17.0"
play-services-location = "21.0.1"
progress-bar = "1.1.3"
kakao = "2.15.0"
amplitude = "1.+"

[libraries]
# AndroidX
Expand Down Expand Up @@ -83,6 +84,7 @@ naver-maps = { group = "com.naver.maps", name = "map-sdk", version.ref = "naver-
play-services-location = { group = "com.google.android.gms", name = "play-services-location", version.ref = "play-services-location" }
progress-bar = { group = "com.github.skydoves", name = "progressview", version.ref = "progress-bar" }
kakao = { group = "com.kakao.sdk", name = "v2-user", version.ref = "kakao" }
amplitude = { group = "com.amplitude", name = "analytics-android", version.ref = "amplitude" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
Expand Down
Loading