Skip to content
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

[1.1.0/AN_REFACTOR] APP 단의 FIrebase 초기화 코드 analytics 모듈로 이동 #318

Merged
merged 1 commit into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package poke.rogue.helper.analytics

import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase

object AnalyticsInitializer {
fun init() {
when (BuildConfig.BUILD_TYPE) {
DEBUG_MODE -> {
Firebase.analytics.setAnalyticsCollectionEnabled(false)
Firebase.crashlytics.setCrashlyticsCollectionEnabled(false)
}

ALPHA_MODE -> {
Firebase.analytics.setAnalyticsCollectionEnabled(false)
Firebase.crashlytics.setCrashlyticsCollectionEnabled(true)
}

BETA_MODE, RELEASE_MODE -> {
Firebase.analytics.setAnalyticsCollectionEnabled(true)
Firebase.crashlytics.setCrashlyticsCollectionEnabled(true)
}

else -> error("Unknown build type")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package poke.rogue.helper.analytics

private const val DEBUG_MODE = "debug"
private const val ALPHA_MODE = "alpha"
private const val BETA_MODE = "beta"
private const val RELEASE_MODE = "release"
internal const val DEBUG_MODE = "debug"
internal const val ALPHA_MODE = "alpha"
internal const val BETA_MODE = "beta"
internal const val RELEASE_MODE = "release"

/** Analytics API surface */
interface AnalyticsLogger {
Expand Down
34 changes: 2 additions & 32 deletions android/app/src/main/java/poke/rogue/helper/PokeRogueHelperApp.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package poke.rogue.helper

import android.app.Application
import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase
import poke.rogue.helper.analytics.AnalyticsInitializer
import poke.rogue.helper.data.repository.DefaultDexRepository
import timber.log.Timber

class PokeRogueHelperApp : Application() {
override fun onCreate() {
super.onCreate()
initTimber()
initFirebase()
AnalyticsInitializer.init()
DefaultDexRepository.init(this)
}

Expand All @@ -26,32 +24,4 @@ class PokeRogueHelperApp : Application() {
)
}
}

private fun initFirebase() {
when (BuildConfig.BUILD_TYPE) {
DEBUG_MODE -> {
Firebase.analytics.setAnalyticsCollectionEnabled(false)
Firebase.crashlytics.setCrashlyticsCollectionEnabled(false)
}

ALPHA_MODE -> {
Firebase.analytics.setAnalyticsCollectionEnabled(false)
Firebase.crashlytics.setCrashlyticsCollectionEnabled(true)
}

BETA_MODE, RELEASE_MODE -> {
Firebase.analytics.setAnalyticsCollectionEnabled(true)
Firebase.crashlytics.setCrashlyticsCollectionEnabled(true)
}

else -> error("Unknown build type")
}
}

companion object {
private const val DEBUG_MODE = "debug"
private const val ALPHA_MODE = "alpha"
private const val BETA_MODE = "beta"
private const val RELEASE_MODE = "release"
}
}
Loading