3

I'm trying to disable the manual screen tracking in Firebase, replacing it with my own implementation of screen tracking.

With the automatic screen tracking, every event I send to firebase has two extra params: firebase_screen_class and firebase_screen_id with the value of the last ViewController presented in the app

So I modified the app's Info.plist file with :

FirebaseScreenReportingEnabled = NO

And I started calling the function when the screen of the app gets changed:

Analytics.setScreenName(screenName, screenClass: screenName)

The result after this change is that the DebugView of Firebase no longer registers screen_view events and no extra info (firebase_screen_class and firebase_screen_id) is attached to later events.

What do am I missing?

Edit: Those are the Google related pods in the podfile.lock

  - Firebase/AdMob (4.2.0):
    - Firebase/Core
    - Google-Mobile-Ads-SDK (= 7.24.0)
  - Firebase/Core (4.2.0):
    - FirebaseAnalytics (= 4.0.3)
    - FirebaseCore (= 4.0.7)
  - Firebase/RemoteConfig (4.2.0):
    - Firebase/Core
    - FirebaseRemoteConfig (= 2.0.3)
  - FirebaseAnalytics (4.0.3):
    - FirebaseCore (~> 4.0)
    - FirebaseInstanceID (~> 2.0)
    - GoogleToolboxForMac/NSData+zlib (~> 2.1)
    - nanopb (~> 0.3)
  - FirebaseCore (4.0.7):
    - GoogleToolboxForMac/NSData+zlib (~> 2.1)
    - nanopb (~> 0.3)
  - FirebaseInstanceID (2.0.3)
  - FirebaseRemoteConfig (2.0.3):
    - FirebaseAnalytics (~> 4.0)
    - FirebaseInstanceID (~> 2.0)
    - GoogleToolboxForMac/NSData+zlib (~> 2.1)
    - Protobuf (~> 3.1)
  - Google-Mobile-Ads-SDK (7.24.0)
  - GoogleAnalytics (3.17.0)
  - GoogleSignIn (4.1.0):
    - GoogleToolboxForMac/NSDictionary+URLArguments (~> 2.1)
    - GoogleToolboxForMac/NSString+URLArguments (~> 2.1)
    - GTMOAuth2 (~> 1.0)
    - GTMSessionFetcher/Core (~> 1.1)
  - GoogleToolboxForMac/DebugUtils (2.1.1):
    - GoogleToolboxForMac/Defines (= 2.1.1)
  - GoogleToolboxForMac/Defines (2.1.1)
  - GoogleToolboxForMac/NSData+zlib (2.1.1):
    - GoogleToolboxForMac/Defines (= 2.1.1)
  - GoogleToolboxForMac/NSDictionary+URLArguments (2.1.1):
    - GoogleToolboxForMac/DebugUtils (= 2.1.1)
    - GoogleToolboxForMac/Defines (= 2.1.1)
    - GoogleToolboxForMac/NSString+URLArguments (= 2.1.1)
  - GoogleToolboxForMac/NSString+URLArguments (2.1.1)
  - GTMOAuth2 (1.1.5):
    - GTMSessionFetcher (~> 1.1)
  - GTMSessionFetcher (1.1.12):
    - GTMSessionFetcher/Full (= 1.1.12)
  - GTMSessionFetcher/Core (1.1.12)
  - GTMSessionFetcher/Full (1.1.12):
    - GTMSessionFetcher/Core (= 1.1.12)
Addev
  • 31,819
  • 51
  • 183
  • 302

2 Answers2

4

I got the answer from Firebase that On iOS, they support automatic + manual screen reporting or no screen reporting at all. Google Analytics for Firebase does NOT support the case of manual-only screen reporting. The plist flag FirebaseAutomaticScreenReportingEnabled has been renamed to FirebaseScreenReportingEnabled to reduce that confusion. Note that the value must be a Boolean and not a String. If it doesn't work as you expected, you can disable screen reporting completely by adding to Info.plist the flag FirebaseScreenReportingEnabled with Boolean value of NO.

adbitx
  • 2,019
  • 8
  • 13
  • 4
    That's pathetic of Firebase for not allowing manual screen reporting! – Islam Dec 06 '17 at 11:16
  • They already provide the manual way to report manual screen view. I believe that there is a good reason they decided to do so. – adbitx Dec 06 '17 at 16:54
  • 1
    That manual works ONLY when automatic reporting is on which means that Firebase MUST be added to the main app target. If you add Firebase to a framework target - Firebase goes into an infinite loop and eventually crashes - a.k.a. stack overflow. Solution would be to disable auto screen reporting and have a way of manually logging the screen views. – Islam Dec 06 '17 at 22:31
  • @adbitx Is there any documentation supporting it. In this doc https://firebase.google.com/docs/analytics/screenviews they mentioned that we can manually log screen_view events whether or not automatic tracking is enabled. – MacDeveloper Mar 22 '22 at 15:15
1

This has now been fixed - although the answers have not flowed down to update the Stackoverflow questions yet.

I found the solution on this Firebase github ticket

Essentially this has recently been fixed to give developers more flexibility in their projects. As long as you update to use version 6.29.0 or greater then you should be able to report as you wish.

The latest changes have got rid of the setScreen functionality and now only use events.

Log event:

Firebase.Analytics.logEvent(name, parameters: parameters)

Log screen view

Firebase.Analytics.logEvent(AnalyticsEventScreenView, parameters:[AnalyticsParameterScreenName: screenName])
sam_smith
  • 6,023
  • 3
  • 43
  • 60