9
votes

We mirgrated from GCM to FCM without any problems. The notification service is running very well. However, we have to disable the app measurement part of the Firebase Analytics service for legal reasons.

We used this guide to disable the analytics part https://firebase.google.com/support/guides/disable-analytics

So we put this flag to the manifest file:

<meta-data android:name="firebase_analytics_collection_enabled" android:value=false />

and we also disabled the collection programmatically:

FirebaseAnalytics.getInstance(this).setAnalyticsCollectionEnabled(false);

Unfortunately, data is still collected and we can see new events in the Firebase Analytics Console. Is there any possibility to turn off the analytics services completely?

Thanks for your help.

Edit: I also have the deactivation meta-data in the application tag:

<meta-data android:name="firebase_analytics_collection_deactivated" android:value=true />
5
have you tried this? <meta-data android:name="firebase_analytics_collection_deactivated" android:value=true /> - lal
Do you only have an app for Android? If so, have you also tried what @lal mentioned? If you've tried everything that was already mentioned in the docs, I suggest you contact Firebase Support directly. They are very good when it comes to providing support with developers. - AL.
Yes - sorry; forgot to mention - I have this in the application tag <meta-data android:name="firebase_analytics_collection_deactivated" android:value="true"/> - goon
I wrote the Firebase Support team. Thanks @AL. for that suggestion. - goon
No worries. If ever they provided you with a solution and it's not that sensitive info, do post your answer here and accept it. It might help a random user someday. :) - AL.

5 Answers

8
votes

As of Oct 2017, deactivated value must be "true". "false" won't work anymore.

<meta-data
        android:name="firebase_analytics_collection_deactivated"
        android:value="true" />

The log shows correctly that it's working.

10-11 16:29:32.755 27857-27857/? I/FA: Collection disabled with firebase_analytics_collection_deactivated=1
5
votes

This is a Firebase bug or an error in the documentation for disabling Analytics collection. To permanently disable collection set firebase_analytics_collection_deactivated to false (not true):

    <meta-data
        android:name="firebase_analytics_collection_deactivated"
        android:value="false" />

You can confirm that collection is disabled by enabling Analytics logging:

adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
adb logcat -v time -s FA FA-SVC

and observing output such as this:

I/FA: Collection disabled with firebase_analytics_collection_deactivated=1
D/FA: Event not sent since app measurement is disabled
3
votes

In order to fully disable Analytics from the Firebase Messaging you need to exclude the analytics packages in gradle:

implementation('com.google.firebase:firebase-messaging:18.0.0') {
    exclude group: 'com.google.firebase', module: 'firebase-core'
    exclude group: 'com.google.firebase', module: 'firebase-analytics'
    exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'
}

And also deactivate tracking in the AndroidManifest file:

<meta-data android:name="firebase_analytics_collection_deactivated" android:value="true" />
    <meta-data android:name="google_analytics_adid_collection_enabled" android:value="false" />
    <meta-data android:name="firebase_messaging_auto_init_enabled" android:value="false" />

If you are using proguard then you have to also add this line to the configuration file

-dontwarn com.google.firebase.analytics.connector.AnalyticsConnector

I hope this helps everyone else that does not want to include any form of tracking in their app but still use Firebase Cloud Messaging.

2
votes

Just received feedback from the Firebase support team.

The code for manifest file won't compile if you don't add a double quote in the android:value attribute, good job if you've already added that.

Temporarily disabling the analytics collection should work, could you please try to enable the verbose debug option and check the logs?

On the other hand, we are aware that there's an issue with disabling the analytics collection permanently, there's already a bug filed for this and being prioritized by our engineers appropriately. Please keep updated with our release notes for further notice regarding this issue.

We apologise for any inconvenience that this may have caused you, and we appreciate your understanding as we continue to improve our services, moving forward.

1
votes

I tried putting that line in my manifest, inside the application tag, as the first line under the application tag :

 <application
    android:icon="@mipmap/ic_launcher"
    android:name="your.package.name">
    <meta-data android:name="firebase_analytics_collection_enabled" android:value="false" />

When doing so, during the init, Firebase display in the logs:

I/FA: Collection disabled with firebase_analytics_collection_enabled=0

And it seems not to report anything to firebase afterwards.