Disable Google Analytics from Android pre-launch reports
Asked Answered
M

5

17

I have tested new pre-launch report on Google Play developer console. While it is great and goes trough your all screens and test them it also affects your statistics on Google Analytics.

Is it possible to exclude those testings from Google Analytics and how?

I know that I can upload APK just for testing with disabled GA, but than every time I should upload another APK with enabled GA and switch on and off pre-launch report testing and that is not what I want.

Mohenjodaro answered 28/5, 2016 at 6:32 Comment(0)
I
19

Pre-launch reports run in the Firebase Test Lab.

According to their documentation, here is how you could detect that you're being run in the Firebase Test Lab.

String testLabSetting = Settings.System.getString(context.getContentResolver(), "firebase.test.lab");
if ("true".equals(testLabSetting)) {
  // Do something when running in Test Lab
}

source: https://firebase.google.com/docs/test-lab/android-studio

Important answered 6/12, 2016 at 21:58 Comment(1)
How is this not the most accepted and upvoted answer in the history of SO?Commination
U
1

One can exclude stats using filters (Administration ›Global Filters› Edit Filter). As I found one can use IP, domain or subdomain that will be excluded by Google Analytics stats.

In my project I have excluded my IP, so my development and test are excluded from Google Analytics. As I can notice, the same filters are applied at Firebase Analytics.

Undersell answered 2/9, 2016 at 8:22 Comment(1)
According to the docs at firebase.google.com/docs/test-lab/…, the current IP range used by test devices is 108.177.6.0/23. Filtering all IPs that start with 108.177.6. or 108.177.7. worked for me.Maudiemaudlin
R
1

To expand on @bleuf1shi answer, the following worked for me in Xamarin.

var testLabSettings = Android.Provider.Settings.System.GetString(this.ContentResolver, "firebase.test.lab");
if ("true".Equals(testLabSettings, StringComparison.OrdinalIgnoreCase))
{
    // Do something when running in Test Lab
}
Release answered 12/7, 2017 at 16:52 Comment(0)
F
1

In case anyone lands here looking for how to do this with React Native, you can determine whether the app is running in Test Lab via the react-native-firebase package utils().isRunningInTestLab: https://rnfirebase.io/app/utils#test-lab.

Freedwoman answered 12/4, 2021 at 20:31 Comment(1)
This was exactly what I was looking for. Thank you so much!Corporeity
I
0

I had a similar problem. Wanted to change the welcome screen so all buttons behave like "Terms of Use accepted", otherwise in my case about 66% of the tests end in closing the app. Found nothing in environment which identifies pre-launch report.

The only possible way I found is to determine the time frame when the tests will run. Of course, this is not reliable, but the last submits to Google Play always took at least 25 minutes until update was live.

Pre-Launch tests typically start soon after submitting the new version. So when you are able and willing to schedule the time of submitting the new version, you can use current time to detect whether app is tested or used in production. After Submit-Time + 20 minutes, enable production mode.

Hopefully Google provides us a reliable way to detect this environment. The service is great. Unfortunately I cannot see any screenshots due to permission issues, but the service is still in BETA, so it will be fixed.

Implicit answered 1/7, 2016 at 21:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.