Skip to content

Commit

Permalink
Merge pull request #520 from BCSDLab/feature/bus-logging
Browse files Browse the repository at this point in the history
[Feature] GA 로깅 모듈 분리 및 버스 로깅
  • Loading branch information
ThirFir authored Jan 6, 2025
2 parents e5d6893 + 1824d7a commit bb2330d
Show file tree
Hide file tree
Showing 54 changed files with 497 additions and 198 deletions.
1 change: 1 addition & 0 deletions core/analytics/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
29 changes: 29 additions & 0 deletions core/analytics/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
plugins {
alias(libs.plugins.koin.library)
}

android {
namespace = "in.koreatech.koin.core.analytics"

buildTypes {
getByName("debug") {
buildConfigField("Boolean", "IS_DEBUG", "true")
}

getByName("release") {
buildConfigField("Boolean", "IS_DEBUG", "false")
}
}
}

dependencies {

implementation(libs.core.ktx)
implementation(libs.appcompat)
implementation(libs.material)
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.analytics)
testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
}
Empty file.
21 changes: 21 additions & 0 deletions core/analytics/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package `in`.koreatech.koin.core.analytics

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("in.koreatech.koin.core.analytics.test", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions core/analytics/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package `in`.koreatech.koin.core.constant
package `in`.koreatech.koin.core.analytics

object AnalyticsConstant {

Expand All @@ -18,8 +18,8 @@ object AnalyticsConstant {
const val CAFETERIA_INFO = "cafeteria_info"
const val HAMBURGER = "hamburger"
const val HAMBURGER_SHOP = HAMBURGER
const val HAMBURGER_DINING = "${HAMBURGER}"
const val HAMBURGER_BUS = "${HAMBURGER}"
const val HAMBURGER_DINING = "$HAMBURGER"
const val HAMBURGER_BUS = "$HAMBURGER"
const val MAIN_MENU_MOVEDETAILVIEW = "main_menu_moveDetailView"
const val MAIN_MENU_CORNER = "main_menu_corner"
const val MENU_TIME = "menu_time"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package `in`.koreatech.koin.core.analytics

import android.util.Log
import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.analytics.ktx.logEvent
import com.google.firebase.ktx.Firebase
import `in`.koreatech.koin.core.BuildConfig
import `in`.koreatech.koin.core.analytics.EventLogger.logEvent
import com.google.firebase.analytics.analytics
import com.google.firebase.analytics.logEvent
import com.google.firebase.Firebase

object EventLogger {

Expand All @@ -15,66 +12,77 @@ object EventLogger {

/**
* 클릭 이벤트 로깅
* @param action: 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
* @param label: 이벤트 소분류
* @param value: 이벤트 값
* @param extras: 추가 이벤트 값
* @param action 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
* @param label 이벤트 소분류
* @param value 이벤트 값
* @param extras 추가 이벤트 값
*/
fun logClickEvent(action: EventAction, label: String, value: String, vararg extras: EventExtra) {
logEvent(action, EventCategory.CLICK, label, value, *extras)
}


/**
* CAPMUS 클릭 이벤트 로깅
* @param label 이벤트 소분류
* @param value 이벤트 값
* @param extras 추가 이벤트 값
*/
fun logCampusClickEvent(label: String, value: String, vararg extras: EventExtra) {
logClickEvent(EventAction.CAMPUS, label, value, *extras)
}

/**
* 스크롤 이벤트 로깅
* @param action: 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
* @param label: 이벤트 소분류
* @param value: 이벤트 값
* @param extras: 추가 이벤트 값
* @param action 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
* @param label 이벤트 소분류
* @param value 이벤트 값
* @param extras 추가 이벤트 값
*/
fun logScrollEvent(action: EventAction, label: String, value: String, vararg extras: EventExtra) {
logEvent(action, EventCategory.SCROLL, label, value, *extras)
}

/**
* 하단 뒤로가기 이벤트 로깅
* @param action: 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
* @param label: 이벤트 소분류
* @param value: 이벤트 값
* @param extras: 추가 이벤트 값
* @param action 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
* @param label 이벤트 소분류
* @param value 이벤트 값
* @param extras 추가 이벤트 값
*/
fun logSwipeEvent(action: EventAction, label: String, value: String, vararg extras: EventExtra) {
logEvent(action, EventCategory.SWIPE, label, value, *extras)
}

/**
* 푸시알림 접속 이벤트 로깅
* @param action: 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
* @param label: 이벤트 소분류
* @param value: 이벤트 값
* @param extras: 추가 이벤트 값
* @param action 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
* @param label 이벤트 소분류
* @param value 이벤트 값
* @param extras 추가 이벤트 값
*/
fun logNotificationEvent(action: EventAction, label: String, value: String, vararg extras: EventExtra) {
logEvent(action, EventCategory.NOTIFICATION, label, value, *extras)
}

/**
* AB테스트 이벤트 로깅
* @param category: 이벤트 종류
* @param label: 이벤트 소분류
* @param value: 이벤트 값
* @param category 이벤트 종류
* @param label 이벤트 소분류
* @param value 이벤트 값
*/
fun logABTestEvent(category: String, label: String, value: String) {
logCustomEvent(EventAction.ABTEST.value, category, label, value)
}

/**
* @param action: 커스텀 이벤트 발생(EventAction 이외에 action)
* @param category: 커스텀 이벤트 종류(EventCategory 이외에 category)
* @param label: 이벤트 소분류
* @param value: 이벤트 값
* @sample logEvent("force_update", "page_view", "forced_update_page_view", "v4.0.0")
* @param action 커스텀 이벤트 발생(EventAction 이외에 action)
* @param category 커스텀 이벤트 종류(EventCategory 이외에 category)
* @param label 이벤트 소분류
* @param value 이벤트 값
*
* ```
* logEvent("force_update", "page_view", "forced_update_page_view", "v4.0.0")
* ```
*/
fun logCustomEvent(action: String, category: String, label: String, value: String) {
if (BuildConfig.IS_DEBUG) {
Expand All @@ -94,11 +102,15 @@ object EventLogger {
}
}
/**
* @param action: 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
* @param category: 이벤트 종류(click, scroll, ...)
* @param label: 이벤트 소분류
* @param value: 이벤트 값
* @sample logEvent("BUSINESS", "click", "main_shop_categories", "전체보기")
* @param action 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
* @param category 이벤트 종류(click, scroll, ...)
* @param label 이벤트 소분류
* @param value 이벤트 값
* @param extras 추가 이벤트 값
*
* ```
* logEvent(EventAction.CAMPUS, EventCategory.CLICK, "main_shop_categories", "전체보기")
* ```
*/
private fun logEvent(action: EventAction, category: EventCategory, label: String, value: String, vararg extras: EventExtra) {
if (BuildConfig.IS_DEBUG) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package `in`.koreatech.koin.core.analytics

import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@
import android.view.View;
import android.widget.TextView;


import android.util.AttributeSet;


import in.koreatech.koin.core.R;
import in.koreatech.koin.core.analytics.EventAction;
import in.koreatech.koin.core.analytics.EventLogger;
import in.koreatech.koin.core.constant.AnalyticsConstant;
import in.koreatech.koin.core.util.FontManager;


public class AppBarBase extends AppBarLayout {
public AppBarLayout background;
public TextView leftButton;
Expand Down
1 change: 1 addition & 0 deletions feature/bus/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies {
implementation(project(":domain"))
implementation(project(":core:onboarding"))
implementation(project(":core:designsystem"))
implementation(project(":core:analytics"))

implementation(libs.core.ktx)
implementation(libs.appcompat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,27 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import `in`.koreatech.bus.type.BusType
import `in`.koreatech.bus.util.LocalSelectedTimetableTab
import `in`.koreatech.koin.core.analytics.EventLogger
import `in`.koreatech.koin.core.designsystem.component.text.LeadingIconText
import `in`.koreatech.koin.core.designsystem.noRippleClickable
import `in`.koreatech.koin.core.designsystem.theme.KoinTheme
import `in`.koreatech.koin.feature.bus.R

@Composable
internal fun WrongInformationText(
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
loggingEventValue: String = ""
) {
val context = LocalContext.current

LeadingIconText(
modifier = modifier.noRippleClickable {
EventLogger.logCampusClickEvent(
"error_feedback_button",
loggingEventValue
)
val url = GOOGLE_FORM_URL
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
context.startActivity(intent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import `in`.koreatech.bus.screen.search.composable.BusSearchScreen
import `in`.koreatech.bus.screen.searchresult.composable.BusSearchResultScreen
import `in`.koreatech.bus.type.PlaceType
import `in`.koreatech.bus.util.findActivity
import `in`.koreatech.koin.core.analytics.EventLogger
import kotlin.reflect.typeOf

@Composable
Expand Down Expand Up @@ -49,7 +50,9 @@ fun BusSearchNavigation(
)
) {
BusSearchScreen(
modifier = Modifier.fillMaxSize().background(Color.White),
modifier = Modifier
.fillMaxSize()
.background(Color.White),
onNavigationIconClick = { context.findActivity()?.finish() },
onSearch = { departure, arrival ->
navController.navigate(Routes.BusSearchResult(departure, arrival))
Expand All @@ -59,8 +62,16 @@ fun BusSearchNavigation(

composable<Routes.BusSearchResult> {
BusSearchResultScreen(
modifier = Modifier.fillMaxSize().background(Color.White),
onNavigationIconClick = navController::popBackStack
modifier = Modifier
.fillMaxSize()
.background(Color.White),
onNavigationIconClick = {
EventLogger.logCampusClickEvent(
"search_result_back",
"뒤로가기"
)
navController.popBackStack()
}
)
}
}
Expand Down
Loading

0 comments on commit bb2330d

Please sign in to comment.