Add option to opt out of Analytics and Crashlytics (#1237)

This commit is contained in:
Roshan Varughese
2024-10-12 13:46:28 +13:00
committed by GitHub
parent c8bb78d91a
commit 7c7af72f8c
9 changed files with 200 additions and 45 deletions

View File

@@ -20,6 +20,15 @@
tools:node="remove" />
<application>
<!-- Disable for manual opt-in -->
<meta-data
android:name="firebase_analytics_collection_enabled"
android:value="false" />
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
<!-- Disable unnecessary stuff from Firebase -->
<meta-data
android:name="google_analytics_adid_collection_enabled"

View File

@@ -0,0 +1,20 @@
package mihon.core.firebase
import android.content.Context
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
import eu.kanade.tachiyomi.core.security.PrivacyPreferences
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
object Firebase {
fun setup(context: Context, preference: PrivacyPreferences, scope: CoroutineScope) {
preference.analytics().changes().onEach { enabled ->
FirebaseAnalytics.getInstance(context).setAnalyticsCollectionEnabled(enabled)
}.launchIn(scope)
preference.crashlytics().changes().onEach { enabled ->
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(enabled)
}.launchIn(scope)
}
}