B4A Library FirebaseAnalytics - Analytics & Crash Reports

Discussion in 'Additional libraries, classes and official updates' started by Erel, Jun 9, 2016.

  1. Erel

    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:
    Code:
    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:
    Code:
    Starter.analytics.SendEvent("login", CreateMap ("additional parameter"100))
    Note that it can take several hours until the data is available in Firebase console:

    [​IMG]

    [​IMG]
     

    Attached Files:

    JohnCody, Siam, dealsmonkey and 4 others like this.
  2. moster67

    moster67 Well-Known Member Licensed User

    Nice addition!
    Is Firebase free?

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

    Erel Administrator Staff Member Licensed User

  4. MarcoRome

    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
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    The first beta will be soon released.
     
    MarcoRome likes this.
  6. tufanv

    tufanv Expert Licensed User

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

     
  7. Erel

    Erel Administrator Staff Member Licensed User

    It is optional. It tracks all kinds of events automatically.
     
  8. chefe82

    chefe82 Member Licensed User

    it works nice, great job erel. You are the best
     
  9. dealsmonkey

    dealsmonkey Active Member Licensed User

    Just installed on new app and work flawless. Many thanks Erel :)
     
  10. Luiz Fernando Orlandini

    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.
     
  11. freedom2000

    freedom2000 Well-Known Member Licensed User

    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.
     
  12. shashkiranr

    shashkiranr Active Member Licensed User

    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

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

    Best,
    SK
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    It cannot catch such errors.

    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/re...lytics/FirebaseAnalytics.Param.html#ITEM_NAME
    You need to use the constant values not the field names. "item_name" for example.
     
  14. freedom2000

    freedom2000 Well-Known Member Licensed User

    Thank you.
    So it means that I have much more fatal errors than those reported in the developper console... (quite a bad news...)
     
  15. Erel

    Erel Administrator Staff Member Licensed User

    In the developer console you only see crashes that the user allowed sending.
     
    freedom2000 likes this.
  16. fransvlaarhoven

    fransvlaarhoven 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...
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    Can you upload the generated Objects\AndroidManifest.xml file?
     
  18. fransvlaarhoven

    fransvlaarhoven Member Licensed User

    This is the generated manifest
     

    Attached Files:

  19. Erel

    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.
     
  20. fransvlaarhoven

    fransvlaarhoven Member Licensed User

    Indeed, I've used MS Edge to copy the code snippets.

    Using Chrome seems to work.

    Thank You for your assistance.
     
Loading...