package app.closer.di

import android.content.Context
import app.closer.core.analytics.AnalyticsTracker
import app.closer.core.analytics.FirebaseAnalyticsTracker
import app.closer.core.crash.CrashReporter
import app.closer.core.crash.FirebaseCrashReporter
import com.google.firebase.analytics.FirebaseAnalytics
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
abstract class ObservabilityModule {

    @Binds @Singleton
    abstract fun bindAnalyticsTracker(impl: FirebaseAnalyticsTracker): AnalyticsTracker

    @Binds @Singleton
    abstract fun bindCrashReporter(impl: FirebaseCrashReporter): CrashReporter

    companion object {
        @Provides @Singleton
        fun provideFirebaseAnalytics(@ApplicationContext context: Context): FirebaseAnalytics =
            FirebaseAnalytics.getInstance(context)
    }
}
