How to remove MainActivity and UIViewController from screen tracking in React Native Firebase Analytics?
Asked Answered
H

2

10

I have successfully implemented screen tracking for a react native project that uses react-navigation with react-native-firebase/analytics.

Looking at the dashboard under events I see the following events (image below). As you can see the top 2 events are automatically tracked 1. MainActivity, 2. UIViewController and they take up most of the total. I would like to remove those screens from the tracking to only show the screens of the JS side of the app (react-navigation).

Is this possible? How can I achieve this?

Thank you in advance πŸ™ŒπŸ»β€οΈπŸ€ΈπŸ»β€β™‚οΈ

Screenshot of screen tracking

Holofernes answered 6/4, 2020 at 9:20 Comment(2)
Did you find any solution? – Monah
See my answer below, I hope it is of some help – Holofernes
H
5

Analytics.setCurrentScreen(, ) will override the Screen class of the native MainActivity and UIViewController.

I recommend setting this as soon as possible when your app starts up, perhaps even on the splash screen. This way it will minimize the Avg. time spent on the native screens and over time they will go down to the bottom of the list.

There is currently no option to disable those screens from being tracked

Holofernes answered 1/5, 2020 at 14:11 Comment(2)
Analytics.setCurrentScreen(, ) do you suggest to set something specific there? Or keep it empty? – Expurgatory
Analytics.setCurrentScreen(screenName, screenClassOverride) is marked as Deprecated and will be removed in Expo SDK 45. How should we go about this issue in the future? – Abnormal
T
8

You can now stop automatic screen tracking through the firebase.json file.

// <project-root>/firebase.json
{
  "react-native": {
    "google_analytics_automatic_screen_reporting_enabled": false
  }
}

Please refer to the official documentation for more information.

Toastmaster answered 4/11, 2022 at 7:13 Comment(1)
This should be the updated accepted answer. – Inexact
H
5

Analytics.setCurrentScreen(, ) will override the Screen class of the native MainActivity and UIViewController.

I recommend setting this as soon as possible when your app starts up, perhaps even on the splash screen. This way it will minimize the Avg. time spent on the native screens and over time they will go down to the bottom of the list.

There is currently no option to disable those screens from being tracked

Holofernes answered 1/5, 2020 at 14:11 Comment(2)
Analytics.setCurrentScreen(, ) do you suggest to set something specific there? Or keep it empty? – Expurgatory
Analytics.setCurrentScreen(screenName, screenClassOverride) is marked as Deprecated and will be removed in Expo SDK 45. How should we go about this issue in the future? – Abnormal

© 2022 - 2025 β€” McMap. All rights reserved.