-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Feature] 앰플리튜드를 도입합니다. #140
Changes from all commits
8b3848e
df84b52
27631db
eabf64b
1e661e5
1b2364a
62dca5f
6b1960f
529e7ff
5e41b85
cb58181
fb381cd
41e3540
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ android { | |
|
||
dependencies { | ||
implementation(libs.androidx.appcompat) | ||
implementation(projects.core.tracker) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.teamhy2.designsystem.util.compositionlocal | ||
|
||
import androidx.compose.runtime.compositionLocalOf | ||
import com.teamhy2.tracker.Tracker | ||
|
||
val LocalTracker = | ||
compositionLocalOf<Tracker> { | ||
object : Tracker { | ||
override fun trackEvent( | ||
eventName: String, | ||
properties: Map<String, Any?>, | ||
) { | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties | ||
|
||
plugins { | ||
id("hongikyeolgong2.android.library") | ||
} | ||
|
||
android { | ||
namespace = "com.teamhy2.hongikyeolgong2.tracker" | ||
|
||
defaultConfig { | ||
buildConfigField("String", "AMPLITUDE_KEY", getApiKey("AMPLITUDE_KEY")) | ||
} | ||
|
||
buildFeatures { | ||
buildConfig = true | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(libs.amplitude) | ||
} | ||
|
||
fun getApiKey(propertyKey: String): String { | ||
return gradleLocalProperties(rootDir, providers).getProperty(propertyKey) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.teamhy2.tracker | ||
|
||
interface Tracker { | ||
fun trackEvent( | ||
eventName: String, | ||
properties: Map<String, Any?> = emptyMap(), | ||
) | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.teamhy2.tracker.amplitude | ||
|
||
import android.content.Context | ||
import com.amplitude.android.Amplitude | ||
import com.amplitude.android.Configuration | ||
import com.amplitude.android.autocaptureOptions | ||
import com.teamhy2.tracker.Tracker | ||
|
||
class AmplitudeTracker(context: Context, apiKey: String) : Tracker { | ||
private val amplitude = | ||
Amplitude( | ||
Configuration( | ||
apiKey = apiKey, | ||
context = context, | ||
autocapture = | ||
autocaptureOptions { | ||
+sessions | ||
+appLifecycles | ||
+screenViews | ||
}, | ||
), | ||
) | ||
|
||
override fun trackEvent( | ||
eventName: String, | ||
properties: Map<String, Any?>, | ||
) { | ||
amplitude.track(eventName, properties) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.teamhy2.tracker.di | ||
|
||
import android.content.Context | ||
import com.teamhy2.hongikyeolgong2.tracker.BuildConfig | ||
import com.teamhy2.tracker.Tracker | ||
import com.teamhy2.tracker.amplitude.AmplitudeTracker | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object TrackerModule { | ||
@Provides | ||
@Singleton | ||
fun provideTracker( | ||
@ApplicationContext context: Context, | ||
): Tracker { | ||
return AmplitudeTracker(context, BuildConfig.AMPLITUDE_KEY) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ googleFirebaseCrashlytics = "3.0.2" | |
datastore = "1.0.0" | ||
firebaseFirestoreKtx = "25.0.0" | ||
coil = "2.3.0" | ||
amplitude = "1.+" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +는 뭔가요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 앰플리튜드 공식문서에 이렇게 적혀있어서 그대로 사용했는데 알아서 최신버전을 찾는거 같아요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +가 |
||
|
||
# HTTP | ||
okhttp = "4.11.0" | ||
|
@@ -136,6 +137,9 @@ androidx-credentials = { module = "androidx.credentials:credentials", version.re | |
androidx-credentials-play-services-auth = { module = "androidx.credentials:credentials-play-services-auth", version.ref = "credentials" } | ||
googleid = { module = "com.google.android.libraries.identity.googleid:googleid", version.ref = "googleid" } | ||
|
||
# Amplitude | ||
amplitude = { module = "com.amplitude:analytics-android", version.ref = "amplitude" } | ||
|
||
[plugins] | ||
android-application = { id = "com.android.application", version.ref = "agp" } | ||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
추상화 좋습니다.
하지만
properties
가 다른 tracker를 연결할 때 걸림돌이 되진 않을까여?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기본값을 명시해서 다른 tracker들은 선택적으로 사용할 수 있도록 설계하였는데 다른 tracker들이 어떤 형태를 가지는지 모르겠어서 예상이 잘 가지 않네요 일단 이 부분은 knownIssue로 가져가는 것을 제안드립니다!