-
Notifications
You must be signed in to change notification settings - Fork 52
Description
[REQUIRED] Please fill in the following fields:
- Unity editor version: 2022.3.151f1
- Firebase Unity SDK version: 11.6.0
- Source you installed the SDK: .unitypackage (.unitypackage or Unity Package Manager)
- Problematic Firebase Component: Analytics (Auth, Database, etc.)
- Other Firebase Components in use: RemoteConfig (Auth, Database, etc.)
- Additional SDKs you are using: Admob (Facebook, AdMob, etc.)
- Platform you are using the Unity editor on: Mac (Mac, Windows, or Linux)
- Platform you are targeting: iOS and Android (iOS, Android, and/or desktop)
- Scripting Runtime: IL2CPP (Mono, and/or IL2CPP)
- Pre-built SDK from the website or open-source from this repo: Pre-built SDK
[REQUIRED] Please describe the question here:
I am following this publishing flow to send updates to the Android Play Store. I upload a new build to the Internal testing track and after testing that all's well, I'll promote it to Production. The problem that I'm seeing is that since every build is auto-tested by Play Store's Pre-Launch Report, it immediately brings on 5+ users on to my app which start sending analytics events. This is ending up inflating my analytics data unnecessarily. How can I eliminate this? I do want the automated testing, it helps me overall, but ideally I want zero impact from the bots on my Analytics tracking.
I tried making a checking function to look for "firebase.test.lab" in the system contentResolver, but testing this is super-hard because it requires me to make a test release every time and then wait for like an hour to let the bots finish hammering to get to the next sane test cycle. So far I've not been able to skip turning on the analytics, here's the function I'm trying to build:
using (var actClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
var context = actClass.GetStatic<AndroidJavaObject>("currentActivity");
if (context == null) {copOut(); return;}
AndroidJavaClass system = new AndroidJavaClass("android.provider.Settings$Global");
if (system == null) {copOut(); return;}
string inTestLab = system.CallStatic<string>("getString", context.Call<AndroidJavaObject>("getContentResolver"), "firebase.test.lab");
if (inTestLab == null) {copOut(); return;}
Debug.Log($"In TestLab:{inTestLab}");
FirebaseAnalytics.SetAnalyticsCollectionEnabled(inTestLab != "true");
}
There must be a recommended way to do this, it affects all Unity Firebase developers, right? Please feedback / suggest, thanks!