9

I just launched a new app and I am using Firebase Analytics. However, every time I upload a new release to the play store, it is automatically tested by Google on 11 devices. Which is great!

  1. Is there a way to prevent those tests from impacting the analytics? I am starting with a small user base, so it can affect it greatly.

  2. I also created an anonymous Auth. Is there a way to prevent it from creating anonymous accounts for those pre-release tests? Can I identify them so I can delete them on Firebase?

Kamy
  • 586
  • 4
  • 18

2 Answers2

10

After lots of research, trials and error, I found something that finally works. I added this code at the beginning of onCreat() in my MainActicity (launch activity). I hope that helps others!

    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

    String testLabSetting =
            Settings.System.getString(getContentResolver(), "firebase.test.lab");
    if ("true".equals(testLabSetting)) {
        //You are running in Test Lab

        mFirebaseAnalytics.setAnalyticsCollectionEnabled(false);  //Disable Analytics Collection
        Toast.makeText(getApplicationContext(), "Disabling Analytics Collection ", Toast.LENGTH_LONG).show();
    }

Reference code in Firebase docs

Kamy
  • 586
  • 4
  • 18
1

For the first question: What you could do is have a user property for these test like "environement" and set the value to "alpha"/"beta"/"prod" whatever you like. You setup x audience for "alpha user", "beta users", etc, and the first thing you do when you launch the app is to set that user property to the right value. For instance you could get the Android ID of all your test device, and if you are on one of these device you set the value to "alpha" or "test", else you set it to "prod". When you'll look at all your user in the prod audience you'll not see your test users.

Question 2: Right after you set the user property to "alpha" you can store a value in the user account information like "test_account: true" and lter you can either write a script to delete them, or delete them manually depending on how many account you have.

Sistr
  • 1,175
  • 10
  • 26
  • 2
    I already did something similar to what you said for our user testing. however what wasn't clear in my question, is that I am talking about the play store automatic testing. It is the testing that google makes when I upload a new release. The app gets tested on 11 devices @ google. – Kamy Sep 09 '16 at 13:24