Skip to content

Commit

Permalink
fix: configure Firebase Analytics on init
Browse files Browse the repository at this point in the history
  • Loading branch information
ianatha committed Nov 10, 2023
1 parent ef2aa1a commit 9392cb9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions app/src/main/java/io/atha/bababasic/ActivityMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,23 @@ import java.util.stream.Collectors


class ActivityMain : AppCompatActivity() {
init {
val testLabSetting = Settings.System.getString(contentResolver, "firebase.test.lab")
if ("true" == testLabSetting) {
val bundle = Bundle().apply {
putString("traffic_type", "testlab")
}
Firebase.analytics.setDefaultEventParameters(bundle)
}
}

lateinit var firebaseAnalytics: FirebaseAnalytics
lateinit var binding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
firebaseAnalytics = Firebase.analytics
CrashHandler.INSTANCE.init(this)
val testLabSetting = Settings.System.getString(contentResolver, "firebase.test.lab")
if ("true" == testLabSetting) {
firebaseAnalytics.setAnalyticsCollectionEnabled(false)
}
binding = ActivityMainBinding.inflate(layoutInflater)
prepareView()
setContentView(binding.root)
Expand Down

0 comments on commit 9392cb9

Please sign in to comment.