Skip to content

Commit

Permalink
[MERGE] #288 -> develop
Browse files Browse the repository at this point in the history
[FEAT/#288] μ— ν”Œλ¦¬νŠœλ“œ μ„€μΉ˜
  • Loading branch information
leeeyubin authored Oct 21, 2024
2 parents b8508cf + 40086a4 commit d3801de
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/dokka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pr_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
β”— πŸ“‚di
πŸ—ƒοΈcore
┣ πŸ“‚analytics
┣ πŸ“‚designsystem
┃ ┣ πŸ“‚component
┃ ┣ πŸ“‚theme
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 @@ -4,6 +4,7 @@

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

<application
android:name=".MyApp"
Expand Down
17 changes: 16 additions & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import java.util.Properties

plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.dokka)
}

val properties = Properties().apply {
load(rootProject.file("local.properties").inputStream())
}

android {
namespace = "com.terning.core"
compileSdk = libs.versions.compileSdk.get().toInt()
Expand All @@ -16,18 +22,25 @@ android {
}

buildTypes {
debug {
val devAmplitude = properties["amplitudeDevKey"] as? String ?: ""
buildConfigField("String", "AMPLITUDE_KEY", devAmplitude)
}

release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
val prodAmplitude = properties["amplitudeProdKey"] as? String ?: ""
buildConfigField("String", "AMPLITUDE_KEY", prodAmplitude)
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

}
kotlinOptions {
jvmTarget = libs.versions.jvmTarget.get()
Expand Down Expand Up @@ -81,4 +94,6 @@ dependencies {
implementation(libs.coil.network.okhttp)
implementation(libs.okhttp)
implementation(libs.lottie)
implementation(libs.amplitude)
implementation(libs.timber)
}
32 changes: 32 additions & 0 deletions core/src/main/java/com/terning/core/analytics/AmplitudeTracker.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.terning.core.analytics

import android.content.Context
import androidx.compose.runtime.staticCompositionLocalOf
import com.amplitude.android.Amplitude
import com.amplitude.android.Configuration
import com.terning.core.BuildConfig
import dagger.hilt.android.qualifiers.ApplicationContext
import timber.log.Timber
import javax.inject.Inject

val LocalTracker = staticCompositionLocalOf<AmplitudeTracker> {
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<String, Any?> = emptyMap()) {
if (BuildConfig.DEBUG) {
Timber.d("Amplitude: ${type.prefix}_$name properties: $properties")
}
amplitude.track(eventType = "${type.prefix}_$name", eventProperties = properties)
}
}
6 changes: 6 additions & 0 deletions core/src/main/java/com/terning/core/analytics/EventType.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.terning.core.analytics

enum class EventType(val prefix: String) {
VIEW("view"),
CLICK("click")
}
12 changes: 11 additions & 1 deletion feature/src/main/java/com/terning/feature/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -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" }
Expand Down

0 comments on commit d3801de

Please sign in to comment.