dpa99c / cordova-plugin-firebasex

Cordova plugin for Google Firebase
MIT License
571 stars 462 forks source link

(not set) on Firebase Analytics dashboard #416

Closed fgarcia5 closed 4 years ago

fgarcia5 commented 4 years ago

In the Analytics dashboard, the value "(not set)" is displayed as a visited screen and I haven't found the bug that is causing it.

Has this happened to someone else? Would you be so kind as to help me?

Thank you very much in advance. To continue, the details:

Current behavior:

I am tracking the display of my screens in Analytics, as indicated in the documentation: window.FirebasePlugin.setScreenName(pageName); making sure "pageName" is always a string.

In the Analytics dashboard, the "screen_firebase" parameter of the "screen_view" event is often set to "(not set)". As you can see below: scree_view firebase_screen image

I have inspected my code, even at the native level (Java) but couldn't detect why this value "(not set)" reaches Analytics.

Expected behavior: I would like the value "(not set)" not to be displayed on the dashboard as it could be confusing and also very messy.

Environment information

Other information: I have seen that different developers have had this bug with Analytics but I haven't been able to determine a possible solution. Here are some related links that might be useful:

Thank you very much again and sorry for my bad English.

dpa99c commented 4 years ago

TL;DR: the appearance of "(not set)" is a caveat of using the native Firebase Analytics SDK in a Cordova environment and is not something that can be "fixed".

The Firebase Analytics SDK (along with all the Firebase SDKs) are intended to be used in a purely native app so it makes assumptions about the how screen name relates to the native view lifecyle - see here.

In the case of iOS, it assumes each of your "screens" will have its own native UIViewController. However, in a Cordova app, you only have one native UIViewController which wraps the Cordova Webview in which your JS-based webapp runs. So until such time as the Cordova environment has been initialized and your JS is able to set a screen name such as "Home", then as far as Firebase is concerned, your native UIViewController (i.e. the Cordova app container) has "not set" the current screen name.

Similarly, for Android the assumption is that your Android app is purely native and therefore Firebase SDK is reliant on the Android Activity lifecycle. Therefore Firebase Analytics assumes you will set the screen name in a native Activity lifecycle method and of course the Cordova Android app container doesn't do this in the Activity which contains the Cordova WebView, so again it is "not set" until such time as you set it in the JS of you Cordova app via this plugin.

It's possible this plugin could enable you to set some default value at app startup other than "(not set)" such as "Cordova loading" or some such, but this is pointless as it means the same: your Cordova app hasn't loaded yet.

Therefore I'm closing this on the basis that there's nothing meaningful that the plugin can do and also if you understand that "(not set)" simply means "your app is still loading", then you can ignore/filter these entries from your screen views in Firebase Analytics.