Each time upon uploading a new release to the google play store, I get about 8 new users logged in my Firebase analytics console within around 10 minutes. I have not released my app publicly yet, it's on a closed test track with nobody else opted in. The only possible cause seems to be internal testing by google, such as Pre-launch reports. These numbers will really mess up my analytics data, so I'd like to exclude this testing traffic from Firebase analytics.
After following the suggestions in these previous questions, unfortunately none of the solutions mentioned successfully exclude the testing activity
- How to prevent Play Store testing from affecting Firebase Analytics
- Disable Google Analytics from Android pre-launch reports
- Exclude testing device from Firebase Analytics logging
In my AndroidManifest.xml after the first line in the application tag I have:
<meta-data android:name="firebase_analytics_collection_enabled" android:value="false" />
At the beginning of onCreate() in my MainActicity I have:
if(!isTestDevice(this))
{
FirebaseAnalytics.getInstance(this).setAnalyticsCollectionEnabled(true);
}
And I have the following function:
public static boolean isTestDevice(Context context) {
String testLabSetting = Settings.System.getString(context.getContentResolver(), "firebase.test.lab");
return "true".equals(testLabSetting);
}
At first I thought that the isTestDevice function may not be working properly, so I added the following debugging code to my home screen:
if(isTestDevice(linearLayout.getContext())) {
TextView testText = new TextView(linearLayout.getContext());
testText.setText("TEST DEVICE");
testText.setId(linearLayout.generateViewId());
linearLayout.addView(testText, 0, params);
TextView disabledText = new TextView(linearLayout.getContext());
disabledText.setText("Analytics disabled");
disabledText.setId(linearLayout.generateViewId());
linearLayout.addView(disabledText, 0, params);
}
And in the pre-launch reports screenshots I can see that the isTestDevice function is working:
Also, If I comment out the setAnalyticsCollectionEnabled(true);
line, then no activity gets logged to the Firebase analytics console, which shows that the line in AndroidManifest.xml is correctly disabling the analytics until the setAnalyticsCollectionEnabled(true);
line gets run.
Also, even if I disable pre-launch reports, the same activity gets logged, around 8 users within minutes of uploading the release.
It seems like the activity being logged is coming from some source other than the pre-launch reports, since I can see from the pre-launch screenshots that the pre-launch devices are correctly being detected as test devices, and furthermore, the activity still gets logged even if I turn off pre-launch reports. But even still, the activity is logged within 10 minutes of uploading a release.
How can I prevent this testing activity from being logged in firebase analytics? It seems like the solutions in the linked posts are no longer working.
EDIT: A main feature of my app is a game. I've been able to essentially work around the problem for now by only setting analytics to enabled if the user scores more than one point in the game. This effectively removes all traffic being logged by bots, since they just aimlessly click on anything and lack any intelligence required to score more than one point. But this is a really bad hack that I'd like to remove.