Search code examples
androidfirebasereact-nativefirebase-analytics

User consent for Firebase Analytics


Using React Native and setting collection disabled by default in the firebase.json app:

{
  "react-native": {
    "analytics_auto_collection_enabled": false,
    "crashlytics_auto_collection_enabled": false
  }
}

After user give consent to analytics collection I store his choice in preferences and since this happens in native code I run :

FirebaseAnalytics.getInstance(this).setAnalyticsCollectionEnabled(choice)

Then, should I retrieve user choice from storage and run again setAnalyticsCollectionEnabledon each startup or should I run this only when the preference changes again ? In other words, does FirebaseAnalytics remember last status of analyticsCollectionEnabled or does it read the default disabled value from the manifest on each startup ?

Thank you in advance for your help


Solution

  • For those who may wonder about this after running some tests I can confirm that the preference is stored internally by both Firebase Analytics and Crashlytics. Therefore there is no need in running a new initialization upon every start up of the app.