B4A Library FirebaseAnalytics - Analytics & Crash Reports

Erel

Administrator
Staff member
Licensed User
This library requires B4A v6+.

Adding support for Firebase analytics and crash reports is very simple.

1. Follow the Firebase integration tutorial: https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/#content
Make sure to add the analytics and crash reports manifest snippet.

2. In Starter service:
B4X:
Sub Process_Globals
   Public analytics As FirebaseAnalytics
End Sub

Sub Service_Create
   analytics.Initialize
End Sub
That's it.

You can manually send events with:
B4X:
Starter.analytics.SendEvent("login", CreateMap ("additional parameter": 100))
Note that it can take several hours until the data is available in Firebase console:



 

Attachments

moster67

Expert
Licensed User
Nice addition!
Is Firebase free?

Edit: just read the other thread. Seems like most services are free
 

MarcoRome

Expert
Licensed User
I read: "Firebase depends on B4A v6+ which was not yet released."
So we could only use this with B4A 6, if i understand.
When version 6 is released ?
Thank you
Marco
 

tufanv

Expert
Licensed User
Do we have to send manual data to make it work or it is optional ?

This library requires B4A v6+.

Adding support for Firebase analytics and crash reports is very simple.

1. Follow the Firebase integration tutorial: https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/#content
Make sure to add the analytics and crash reports manifest snippet.

2. In Starter service:
B4X:
Sub Process_Globals
   Public analytics As FirebaseAnalytics
End Sub

Sub Service_Create
   analytics.Initialize
End Sub
That's it.

You can manually send events with:
B4X:
Starter.analytics.SendEvent("login", CreateMap ("additional parameter": 100))
Note that it can take several hours until the data is available in Firebase console:



 

Erel

Administrator
Staff member
Licensed User
It is optional. It tracks all kinds of events automatically.
 

Luiz Fernando Orlandini

Active Member
Licensed User
Very good! I already put this in place in a PROD version of my APP.

One interesting thing though, we can't see any crash in the last week (since we delivered the new version), and looking on the analytics reports, looks like we have more than a hundred occurrences app_exception. This is a known issue for the Android platform, at least this is what they said on Firebase page (https://firebase.google.com/docs/crash/android).

Any thoughts about it? It there any way to log important data that will help the debuging with the crash tools?

Thanks.
 

freedom2000

Well-Known Member
Licensed User
Very good! I already put this in place in a PROD version of my APP.

One interesting thing though, we can't see any crash in the last week (since we delivered the new version), and looking on the analytics reports, looks like we have more than a hundred occurrences app_exception. This is a known issue for the Android platform, at least this is what they said on Firebase page (https://firebase.google.com/docs/crash/android).

Any thoughts about it? It there any way to log important data that will help the debuging with the crash tools?

Thanks.
I encountered the same "trouble" : much more "firebase crashes" than android developper console ones.

It seems to me that frebase captures every exception even the one that are into "try catch end try" blocks... (but not sure of that)

Analytics app_exception events

Crash Reporting automatically exports captured errors to Firebase Analytics as app_exception events. Currently on Android, you may see a significant discrepancy between the number of Crash Reporting errors and Analyticsapp_exception events.
 

shashkiranr

Active Member
Licensed User
Starter.analytics.SendEvent("login", CreateMap ("additional parameter": 100))
Hi All,

If i have to send a parameter to log an event say name of the item then the above line is not working. I cant find any name in the firebase console when I filter for that perticular event. I am using the below line

B4X:
Starter.analytics.SendEvent("item", CreateMap ("additional parameter": itemname))
Any idea the format I need to use to send strings for an event?

Best,
SK
 

Erel

Administrator
Staff member
Licensed User
It seems to me that frebase captures every exception even the one that are into "try catch end try" blocks...
It cannot catch such errors.

Any idea the format I need to use to send strings for an event?
You can use custom keys. Just make sure that there are no spaces in the keys.

The built-in constant values are listed here: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Param.html#ITEM_NAME
You need to use the constant values not the field names. "item_name" for example.
 

fransvlaarhoven

Active Member
Licensed User
Hello,

I've a strange problem when I want to include analytics in an app:

- firebase notifications are working
- firebase storage is working

when I include this code snippet in the manifest:


'************ Firebase Analytics ************
AddApplicationText(
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.measurement.UPLOAD"/>
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.measurement.AppMeasurementService"
android:enabled="true"
android:exported="false"/>
<service android:name="com.google.firebase.crash.internal.service.FirebaseCrashReceiverService"
android:process=":background_crash"/>
<service android:name="com.google.firebase.crash.internal.service.FirebaseCrashSenderService"
android:process=":background_crash"/>
)
'************ Firebase Analytics (end) ************


compiling the app gives this result:

B4A version: 6.30
Parsing code. (0.27s)
Compiling code. (0.62s)
Compiling layouts code. (0.04s)
Organizing libraries. (0.00s)
Generating R file. Error
AndroidManifest.xml:106: error: Error parsing XML: not well-formed (invalid token)

I've noticed that the same is also defined in the manifest section

'************ Firebase Base ************

When I don't include the code snippet section

'************ Firebase Analytics ************

compiling works and all seems to work but when I cause a crash in the app, nothing is seen in the firebase console, even not after waiting for 48 hours.

I assume I do something wrong but I've no clue what I'm doing wrong.

Please help me out...
 

Erel

Administrator
Staff member
Licensed User
Can you upload the generated Objects\AndroidManifest.xml file?
 

Erel

Administrator
Staff member
Licensed User
Have you used MS Edge to copy the snippets? There is an issue where Edge adds a special unicode space instead of the standard space. This issue is fixed for the next update. For now remove this snippet and copy it again with a different browser.
 
Top