diff --git a/.github/workflows/dokka.yml b/.github/workflows/dokka.yml
index da419da5..04484483 100644
--- a/.github/workflows/dokka.yml
+++ b/.github/workflows/dokka.yml
@@ -34,6 +34,8 @@ jobs:
RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
RELEASE_STORE_FILE: ${{ secrets.RELEASE_STORE_FILE }}
RELEASE_STORE_PASSWORD: ${{ secrets.RELEASE_STORE_PASSWORD }}
+ AMPLITUDE_DEV_KEY: ${{ secrets.AMPLITUDE_DEV_KEY }}
+ AMPLITUDE_PROD_KEY: ${{ secrets.AMPLITUDE_PROD_KEY }}
run: |
echo base.url=\"$BASE_URL\" >> local.properties
echo test.base.url=\"$TEST_BASE_URL\" >> local.properties
@@ -43,6 +45,8 @@ jobs:
echo release.keyPassword=\"$RELEASE_KEY_PASSWORD\" >> local.properties
echo release.storeFile=\"$RELEASE_STORE_FILE\" >> local.properties
echo release.storePassword=\"$RELEASE_STORE_PASSWORD\" >> local.properties
+ echo amplitudeDevKey=\"$AMPLITUDE_DEV_KEY\" >> local.properties
+ echo amplitudeProdKey=\"$AMPLITUDE_PROD_KEY\" >> local.properties
- name: Build Documentation
run: ./gradlew dokkaHtml
diff --git a/.github/workflows/pr_checker.yml b/.github/workflows/pr_checker.yml
index 985aadf1..f49afbd0 100644
--- a/.github/workflows/pr_checker.yml
+++ b/.github/workflows/pr_checker.yml
@@ -48,6 +48,8 @@ jobs:
RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
RELEASE_STORE_FILE: ${{ secrets.RELEASE_STORE_FILE }}
RELEASE_STORE_PASSWORD: ${{ secrets.RELEASE_STORE_PASSWORD }}
+ AMPLITUDE_DEV_KEY: ${{ secrets.AMPLITUDE_DEV_KEY }}
+ AMPLITUDE_PROD_KEY: ${{ secrets.AMPLITUDE_PROD_KEY }}
run: |
echo base.url=\"$BASE_URL\" >> local.properties
echo test.base.url=\"$TEST_BASE_URL\" >> local.properties
@@ -57,3 +59,5 @@ jobs:
echo release.keyPassword=\"$RELEASE_KEY_PASSWORD\" >> local.properties
echo release.storeFile=\"$RELEASE_STORE_FILE\" >> local.properties
echo release.storePassword=\"$RELEASE_STORE_PASSWORD\" >> local.properties
+ echo amplitudeDevKey=\"$AMPLITUDE_DEV_KEY\" >> local.properties
+ echo amplitudeProdKey=\"$AMPLITUDE_PROD_KEY\" >> local.properties
diff --git a/README.md b/README.md
index dff4a225..78d48c13 100644
--- a/README.md
+++ b/README.md
@@ -44,6 +44,7 @@
┗ 📂di
🗃️core
+ ┣ 📂analytics
┣ 📂designsystem
┃ ┣ 📂component
┃ ┣ 📂theme
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index d3be9d43..5b58c1df 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -4,6 +4,7 @@
+
{
+ error("No AmplitudeTracker provided")
+}
+
+class AmplitudeTracker @Inject constructor(
+ @ApplicationContext private val context: Context
+) {
+ private val amplitude = Amplitude(
+ Configuration(
+ apiKey = BuildConfig.AMPLITUDE_KEY,
+ context = context
+ )
+ )
+
+ fun track(type: EventType, name: String, properties: Map = emptyMap()) {
+ if (BuildConfig.DEBUG) {
+ Timber.d("Amplitude: ${type.prefix}_$name properties: $properties")
+ }
+ amplitude.track(eventType = "${type.prefix}_$name", eventProperties = properties)
+ }
+}
diff --git a/core/src/main/java/com/terning/core/analytics/EventType.kt b/core/src/main/java/com/terning/core/analytics/EventType.kt
new file mode 100644
index 00000000..ec270bc4
--- /dev/null
+++ b/core/src/main/java/com/terning/core/analytics/EventType.kt
@@ -0,0 +1,6 @@
+package com.terning.core.analytics
+
+enum class EventType(val prefix: String) {
+ VIEW("view"),
+ CLICK("click")
+}
diff --git a/feature/src/main/java/com/terning/feature/main/MainActivity.kt b/feature/src/main/java/com/terning/feature/main/MainActivity.kt
index 58b15268..7e6e4465 100644
--- a/feature/src/main/java/com/terning/feature/main/MainActivity.kt
+++ b/feature/src/main/java/com/terning/feature/main/MainActivity.kt
@@ -4,18 +4,28 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
+import androidx.compose.runtime.CompositionLocalProvider
+import com.terning.core.analytics.AmplitudeTracker
+import com.terning.core.analytics.LocalTracker
import com.terning.core.designsystem.theme.TerningPointTheme
import dagger.hilt.android.AndroidEntryPoint
+import javax.inject.Inject
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
+
+ @Inject
+ lateinit var tracker: AmplitudeTracker
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
val navigator: MainNavigator = rememberMainNavigator()
TerningPointTheme {
- MainScreen(navigator)
+ CompositionLocalProvider(LocalTracker provides tracker) {
+ MainScreen(navigator)
+ }
}
}
}
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 7b6f3679..314d6651 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -91,6 +91,9 @@ browser = "1.4.0"
## dokka
dokka = "1.9.0"
+## amplitude
+amplitude = "1.17.3"
+
[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCore" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompat" }
@@ -170,6 +173,7 @@ kakao-user = { group = "com.kakao.sdk", name = "v2-user", version.ref = "kakaoVe
process-phoenix = { group = "com.jakewharton", name = "process-phoenix", version.ref = "processPhoenix" }
accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanistSystemuicontroller" }
+amplitude = { group = "com.amplitude", name = "analytics-android", version.ref="amplitude" }
[plugins]
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }