When submitting to the Google Play Store, analytics events are being sent while the app is being tested in TestLab (as part of the pre-launch reports).
There's a simple way to exclude those events:
https://firebase.google.com/docs/test-lab/android/android-studio#modify_instrumented_test_behavior_for
Hey @corradio this is planned to be added, please follow along over at: https://boards.invertase.io/react-native-firebase/p/detect-firebase-pre-launch-report-in-analytics
Thanks!
so just to get this right:
I need to manually add the code:
import analytics from '@react-native-firebase/analytics';
import utils from '@react-native-firebase/utils';
if (utils().isRunningInTestLab) {
  analytics().setAnalyticsCollectionEnabled(false)
}
                    The link above is outdated since it points to the old Utils package. Now you actually have to do this instead:
import firebase from '@react-native-firebase/app';
import '@react-native-firebase/analytics';
if (firebase.app().utils().isRunningInTestLab) {
    firebase.analytics().setAnalyticsCollectionEnabled(false);
}
I hope this helps someone until the documentation is ready.
@tobiaseisenschenk "until the documentation is ready" -> there is an edit button at the top right of each page, and the workflow via github makes it possible to propose documentation edits almost automatically (they handle the fork/branch/PR creation work for you) :muscle:
The link above is outdated since it points to the old
Utilspackage. Now you actually have to do this instead:import firebase from '@react-native-firebase/app'; import '@react-native-firebase/analytics'; if (firebase.app().utils().isRunningInTestLab) { firebase.analytics().setAnalyticsCollectionEnabled(false); }I hope this helps someone until the documentation is ready.
Hey men! Where do you place that code?
I have put it inside a useEffect in my root component but doesn't work :(
The link above is outdated since it points to the old
Utilspackage. Now you actually have to do this instead:import firebase from '@react-native-firebase/app'; import '@react-native-firebase/analytics'; if (firebase.app().utils().isRunningInTestLab) { firebase.analytics().setAnalyticsCollectionEnabled(false); }I hope this helps someone until the documentation is ready.
Hey men! Where do you place that code?
I have put it inside auseEffectin my root component but doesn't work :(
It does not work for me either :(
The link above is outdated since it points to the old
Utilspackage. Now you actually have to do this instead:import firebase from '@react-native-firebase/app'; import '@react-native-firebase/analytics'; if (firebase.app().utils().isRunningInTestLab) { firebase.analytics().setAnalyticsCollectionEnabled(false); }I hope this helps someone until the documentation is ready.
Hey men! Where do you place that code?
I have put it inside auseEffectin my root component but doesn't work :(
We stopped using Google Analytics alltogether, but we had this setup code in our root component App.tsx along with other setup code, but not inside a React hook.