Skip to content

Commit bb2330d

Browse files
authored
Merge pull request #520 from BCSDLab/feature/bus-logging
[Feature] GA 로깅 모듈 분리 및 버스 로깅
2 parents e5d6893 + 1824d7a commit bb2330d

File tree

54 files changed

+497
-198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+497
-198
lines changed

core/analytics/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

core/analytics/build.gradle.kts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
plugins {
2+
alias(libs.plugins.koin.library)
3+
}
4+
5+
android {
6+
namespace = "in.koreatech.koin.core.analytics"
7+
8+
buildTypes {
9+
getByName("debug") {
10+
buildConfigField("Boolean", "IS_DEBUG", "true")
11+
}
12+
13+
getByName("release") {
14+
buildConfigField("Boolean", "IS_DEBUG", "false")
15+
}
16+
}
17+
}
18+
19+
dependencies {
20+
21+
implementation(libs.core.ktx)
22+
implementation(libs.appcompat)
23+
implementation(libs.material)
24+
implementation(platform(libs.firebase.bom))
25+
implementation(libs.firebase.analytics)
26+
testImplementation(libs.junit)
27+
androidTestImplementation(libs.ext.junit)
28+
androidTestImplementation(libs.espresso.core)
29+
}

core/analytics/consumer-rules.pro

Whitespace-only changes.

core/analytics/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package `in`.koreatech.koin.core.analytics
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("in.koreatech.koin.core.analytics.test", appContext.packageName)
23+
}
24+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
</manifest>

core/src/main/java/in/koreatech/koin/core/constant/AnalyticsConstant.kt renamed to core/analytics/src/main/java/in/koreatech/koin/core/analytics/AnalyticsConstant.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package `in`.koreatech.koin.core.constant
1+
package `in`.koreatech.koin.core.analytics
22

33
object AnalyticsConstant {
44

@@ -18,8 +18,8 @@ object AnalyticsConstant {
1818
const val CAFETERIA_INFO = "cafeteria_info"
1919
const val HAMBURGER = "hamburger"
2020
const val HAMBURGER_SHOP = HAMBURGER
21-
const val HAMBURGER_DINING = "${HAMBURGER}"
22-
const val HAMBURGER_BUS = "${HAMBURGER}"
21+
const val HAMBURGER_DINING = "$HAMBURGER"
22+
const val HAMBURGER_BUS = "$HAMBURGER"
2323
const val MAIN_MENU_MOVEDETAILVIEW = "main_menu_moveDetailView"
2424
const val MAIN_MENU_CORNER = "main_menu_corner"
2525
const val MENU_TIME = "menu_time"

core/src/main/java/in/koreatech/koin/core/analytics/EventLogger.kt renamed to core/analytics/src/main/java/in/koreatech/koin/core/analytics/EventLogger.kt

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package `in`.koreatech.koin.core.analytics
22

3-
import android.util.Log
4-
import com.google.firebase.analytics.ktx.analytics
5-
import com.google.firebase.analytics.ktx.logEvent
6-
import com.google.firebase.ktx.Firebase
7-
import `in`.koreatech.koin.core.BuildConfig
8-
import `in`.koreatech.koin.core.analytics.EventLogger.logEvent
3+
import com.google.firebase.analytics.analytics
4+
import com.google.firebase.analytics.logEvent
5+
import com.google.firebase.Firebase
96

107
object EventLogger {
118

@@ -15,66 +12,77 @@ object EventLogger {
1512

1613
/**
1714
* 클릭 이벤트 로깅
18-
* @param action: 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
19-
* @param label: 이벤트 소분류
20-
* @param value: 이벤트 값
21-
* @param extras: 추가 이벤트 값
15+
* @param action 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
16+
* @param label 이벤트 소분류
17+
* @param value 이벤트 값
18+
* @param extras 추가 이벤트 값
2219
*/
2320
fun logClickEvent(action: EventAction, label: String, value: String, vararg extras: EventExtra) {
2421
logEvent(action, EventCategory.CLICK, label, value, *extras)
2522
}
2623

27-
24+
/**
25+
* CAPMUS 클릭 이벤트 로깅
26+
* @param label 이벤트 소분류
27+
* @param value 이벤트 값
28+
* @param extras 추가 이벤트 값
29+
*/
30+
fun logCampusClickEvent(label: String, value: String, vararg extras: EventExtra) {
31+
logClickEvent(EventAction.CAMPUS, label, value, *extras)
32+
}
2833

2934
/**
3035
* 스크롤 이벤트 로깅
31-
* @param action: 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
32-
* @param label: 이벤트 소분류
33-
* @param value: 이벤트 값
34-
* @param extras: 추가 이벤트 값
36+
* @param action 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
37+
* @param label 이벤트 소분류
38+
* @param value 이벤트 값
39+
* @param extras 추가 이벤트 값
3540
*/
3641
fun logScrollEvent(action: EventAction, label: String, value: String, vararg extras: EventExtra) {
3742
logEvent(action, EventCategory.SCROLL, label, value, *extras)
3843
}
3944

4045
/**
4146
* 하단 뒤로가기 이벤트 로깅
42-
* @param action: 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
43-
* @param label: 이벤트 소분류
44-
* @param value: 이벤트 값
45-
* @param extras: 추가 이벤트 값
47+
* @param action 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
48+
* @param label 이벤트 소분류
49+
* @param value 이벤트 값
50+
* @param extras 추가 이벤트 값
4651
*/
4752
fun logSwipeEvent(action: EventAction, label: String, value: String, vararg extras: EventExtra) {
4853
logEvent(action, EventCategory.SWIPE, label, value, *extras)
4954
}
5055

5156
/**
5257
* 푸시알림 접속 이벤트 로깅
53-
* @param action: 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
54-
* @param label: 이벤트 소분류
55-
* @param value: 이벤트 값
56-
* @param extras: 추가 이벤트 값
58+
* @param action 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
59+
* @param label 이벤트 소분류
60+
* @param value 이벤트 값
61+
* @param extras 추가 이벤트 값
5762
*/
5863
fun logNotificationEvent(action: EventAction, label: String, value: String, vararg extras: EventExtra) {
5964
logEvent(action, EventCategory.NOTIFICATION, label, value, *extras)
6065
}
6166

6267
/**
6368
* AB테스트 이벤트 로깅
64-
* @param category: 이벤트 종류
65-
* @param label: 이벤트 소분류
66-
* @param value: 이벤트 값
69+
* @param category 이벤트 종류
70+
* @param label 이벤트 소분류
71+
* @param value 이벤트 값
6772
*/
6873
fun logABTestEvent(category: String, label: String, value: String) {
6974
logCustomEvent(EventAction.ABTEST.value, category, label, value)
7075
}
7176

7277
/**
73-
* @param action: 커스텀 이벤트 발생(EventAction 이외에 action)
74-
* @param category: 커스텀 이벤트 종류(EventCategory 이외에 category)
75-
* @param label: 이벤트 소분류
76-
* @param value: 이벤트 값
77-
* @sample logEvent("force_update", "page_view", "forced_update_page_view", "v4.0.0")
78+
* @param action 커스텀 이벤트 발생(EventAction 이외에 action)
79+
* @param category 커스텀 이벤트 종류(EventCategory 이외에 category)
80+
* @param label 이벤트 소분류
81+
* @param value 이벤트 값
82+
*
83+
* ```
84+
* logEvent("force_update", "page_view", "forced_update_page_view", "v4.0.0")
85+
* ```
7886
*/
7987
fun logCustomEvent(action: String, category: String, label: String, value: String) {
8088
if (BuildConfig.IS_DEBUG) {
@@ -94,11 +102,15 @@ object EventLogger {
94102
}
95103
}
96104
/**
97-
* @param action: 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
98-
* @param category: 이벤트 종류(click, scroll, ...)
99-
* @param label: 이벤트 소분류
100-
* @param value: 이벤트 값
101-
* @sample logEvent("BUSINESS", "click", "main_shop_categories", "전체보기")
105+
* @param action 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
106+
* @param category 이벤트 종류(click, scroll, ...)
107+
* @param label 이벤트 소분류
108+
* @param value 이벤트 값
109+
* @param extras 추가 이벤트 값
110+
*
111+
* ```
112+
* logEvent(EventAction.CAMPUS, EventCategory.CLICK, "main_shop_categories", "전체보기")
113+
* ```
102114
*/
103115
private fun logEvent(action: EventAction, category: EventCategory, label: String, value: String, vararg extras: EventExtra) {
104116
if (BuildConfig.IS_DEBUG) {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package `in`.koreatech.koin.core.analytics
2+
3+
import org.junit.Test
4+
5+
import org.junit.Assert.*
6+
7+
/**
8+
* Example local unit test, which will execute on the development machine (host).
9+
*
10+
* See [testing documentation](http://d.android.com/tools/testing).
11+
*/
12+
class ExampleUnitTest {
13+
@Test
14+
fun addition_isCorrect() {
15+
assertEquals(4, 2 + 2)
16+
}
17+
}

core/src/main/java/in/koreatech/koin/core/appbar/AppBarBase.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,11 @@
1212
import android.view.View;
1313
import android.widget.TextView;
1414

15-
1615
import android.util.AttributeSet;
1716

18-
1917
import in.koreatech.koin.core.R;
20-
import in.koreatech.koin.core.analytics.EventAction;
21-
import in.koreatech.koin.core.analytics.EventLogger;
22-
import in.koreatech.koin.core.constant.AnalyticsConstant;
2318
import in.koreatech.koin.core.util.FontManager;
2419

25-
2620
public class AppBarBase extends AppBarLayout {
2721
public AppBarLayout background;
2822
public TextView leftButton;

feature/bus/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ dependencies {
2323
implementation(project(":domain"))
2424
implementation(project(":core:onboarding"))
2525
implementation(project(":core:designsystem"))
26+
implementation(project(":core:analytics"))
2627

2728
implementation(libs.core.ktx)
2829
implementation(libs.appcompat)

feature/bus/src/main/java/in/koreatech/bus/component/WrongInformationText.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,27 @@ import androidx.compose.ui.Modifier
88
import androidx.compose.ui.platform.LocalContext
99
import androidx.compose.ui.res.stringResource
1010
import androidx.compose.ui.unit.dp
11+
import `in`.koreatech.bus.type.BusType
12+
import `in`.koreatech.bus.util.LocalSelectedTimetableTab
13+
import `in`.koreatech.koin.core.analytics.EventLogger
1114
import `in`.koreatech.koin.core.designsystem.component.text.LeadingIconText
1215
import `in`.koreatech.koin.core.designsystem.noRippleClickable
1316
import `in`.koreatech.koin.core.designsystem.theme.KoinTheme
1417
import `in`.koreatech.koin.feature.bus.R
1518

1619
@Composable
1720
internal fun WrongInformationText(
18-
modifier: Modifier = Modifier
21+
modifier: Modifier = Modifier,
22+
loggingEventValue: String = ""
1923
) {
2024
val context = LocalContext.current
25+
2126
LeadingIconText(
2227
modifier = modifier.noRippleClickable {
28+
EventLogger.logCampusClickEvent(
29+
"error_feedback_button",
30+
loggingEventValue
31+
)
2332
val url = GOOGLE_FORM_URL
2433
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
2534
context.startActivity(intent)

feature/bus/src/main/java/in/koreatech/bus/navigation/BusSearchNavigation.kt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import `in`.koreatech.bus.screen.search.composable.BusSearchScreen
1919
import `in`.koreatech.bus.screen.searchresult.composable.BusSearchResultScreen
2020
import `in`.koreatech.bus.type.PlaceType
2121
import `in`.koreatech.bus.util.findActivity
22+
import `in`.koreatech.koin.core.analytics.EventLogger
2223
import kotlin.reflect.typeOf
2324

2425
@Composable
@@ -49,7 +50,9 @@ fun BusSearchNavigation(
4950
)
5051
) {
5152
BusSearchScreen(
52-
modifier = Modifier.fillMaxSize().background(Color.White),
53+
modifier = Modifier
54+
.fillMaxSize()
55+
.background(Color.White),
5356
onNavigationIconClick = { context.findActivity()?.finish() },
5457
onSearch = { departure, arrival ->
5558
navController.navigate(Routes.BusSearchResult(departure, arrival))
@@ -59,8 +62,16 @@ fun BusSearchNavigation(
5962

6063
composable<Routes.BusSearchResult> {
6164
BusSearchResultScreen(
62-
modifier = Modifier.fillMaxSize().background(Color.White),
63-
onNavigationIconClick = navController::popBackStack
65+
modifier = Modifier
66+
.fillMaxSize()
67+
.background(Color.White),
68+
onNavigationIconClick = {
69+
EventLogger.logCampusClickEvent(
70+
"search_result_back",
71+
"뒤로가기"
72+
)
73+
navController.popBackStack()
74+
}
6475
)
6576
}
6677
}

0 commit comments

Comments
 (0)