Firebase Analytics events from iOS not showing up

57,732

Solution 1

Firebase events are batched together and uploaded once every hour in order to prevent excessive battery drain on the devices. On iOS when you background the app before the 1h upload target the events will be dispatched at this time in the background.

You can enable debug logging for iOS (https://firebase.google.com/docs/analytics/ios/events#view_events_in_the_xcode_debug_console) to see when events are uploaded in debug console.

Once the events are uploaded there is delay at about 3h before the data will show up in the Firebase Analytics dashboard. Also the default day range excludes "today" so you only see events from yesterday. You can switch the date picker to include Today if you like to see the latest events.

The main reason to delay/batch data uploading is to save battery. Each time the network is used the device mobile network modem is put in hi power mode and stay in this mode for a while. If network is used regularly it has sever impact on the battery life. By batching the uploads together and delaying the upload the impact on the battery is significantly reduced.

Solution 2

In Swift it should be like:

FIRAnalytics.logEvent(withName: "SignUp", parameters: ["user_id": userid, "user_name": username])

To view this event in Firebase:

  1. Go to Firebase console → Analytics tab
  2. Click on DebugView tab; your Events are shown there

To view this event in Xcode:

  1. In Xcode, select Product → Scheme → EditScheme
  2. Select Run from left Menu
  3. Select Arguments tab
  4. In the Arguments Passed on Launch, add -FIRAnalyticsDebugEnabled

One dash only!!

Note that -FIRAnalyticsDebugEnabled has only ONE dash in front of it.

Solution 3

If you are not receiving events in console, it may be because you are not following naming convention, as I experienced if there is a space in event name it will never show up in the console like following:

mFirebaseAnalytics.logEvent("Add Camera", bundle);

But when you remove the space like following:

mFirebaseAnalytics.logEvent("Add_Camera", bundle);

Now you will see events in console, after approximately 3 hours. Application will dispatch the data to console in following cases:

1- Data is more than an hours old
2- App goes into the background

You can watch this tutorial for more information: Getting Started with Firebase Analytics on iOS: Events - Firecasts

Solution 4

Another thing to check is making sure your logging entries in the Arguments Passed on Launch are correct. They should start with a - e.g

-FIRAnalyticsDebugEnabled

and not

FIRAnalyticsDebugEnabled

I wasted an hour the other day wondering why nothing gets logged.

Solution 5

React-Native App (IOS/Android)

I had the same problem, debugView wasn't working, and streamView glitches a few times, the best way ive found to test my events was to logEvents with my createPageEvent() and then

the important thing is to put the app into background after logging the events, they will show up almost in realtime on firebase events or in streamView (check this article to see when events are sent to firebase)

events are only sent after 1 hour since they have been logged or immediately if you put your app in background.

import firebase, { RNFirebase } from 'react-native-firebase';

export default class AnalyticsService  {

    static async initialize() {
        firebase.analytics().setAnalyticsCollectionEnabled(true);
    }

    static async createPageEvent(screen: string) {
        firebase.analytics().setCurrentScreen(screen)
        firebase.analytics().logEvent(`open_${screen}`)
    }

}

the result is this in streamView almost realtime ->

enter image description here

Now you can start building funnels and stuff

Share:
57,732
Daniel Saidi
Author by

Daniel Saidi

I am a system developer who lives in Stockholm Sweden, where I work at eBay / Tradera. I focus on web and mobility, but anything with code in it rocks my world.

Updated on December 03, 2020

Comments

  • Daniel Saidi
    Daniel Saidi over 3 years

    I am testing the new Google-powered Firebase, and have implemented remote notifications and crash reporting. I am, however, having massive problems with getting Analytics to work.

    I track events with FIRAnalytics.logEventWithName(...) and save user pproperties with FIRAnalytics.setUserPropertyString(...). However, no matter what I do, no data shows up in the Firebase Analytics Console.

    Well, I do receive some events, but those are not sent by me (like first_open and session_start). Also, this data seems to drop in after a very long time.

    Furthermore, when I track events and save user data, I receive the following:

    Upload task scheduled to be executed in approx. (s): 3102.294599890709

    This seems really strange - Firebase waiting almost an hour before trying to send the next batch of data must be a bug, or is it configurable? When I waited that extremely long delay out, data was sent...but does not show up.

  • Daniel Saidi
    Daniel Saidi about 8 years
    Thank you for clearing that up. As a Google Analytics user, I have become accustomed to real time analysis, to be able to see what people are doing in my apps right now...especially during development, to see that my actions trigger events correctly. I tried to find information about Firebase's intended behavior yesterday, but did not find any. If I had just had a small box with the info you just gave me, it would have saved me hours of trying to get it to work...when in fact it was already behaving as intended. I think they should consider real time upload when debugging.
  • djabi
    djabi about 8 years
    Yes, we are considering real time uploading in debug mode. I don't have time when this might be available.
  • Daniel Saidi
    Daniel Saidi about 8 years
    Man, reading my comment, I sound like a spoiled brat. I really meant that to be a constructive piece of advice, but it sounded like me really whining. Don't get me wrong - I am super excited about the Firebase service and really look forward to follow you and any future updates you may add!
  • DixieFlatline
    DixieFlatline about 8 years
    Any way to set this batch period/interval?
  • djabi
    djabi about 8 years
    No, not yet. As I mentioned in previous comment, we are considering adding support for real time but that is not available at the moment. What is the reason you are looking to control batching period/interval?
  • djabi
    djabi about 8 years
    The main reason to delay uploading is that once mobile modem is put in hi power mode it stay that way for some time (like 2 minutes). A simple way to think about it that every time the network is woken up its cost about 2 minutes shorter battery life on the device. So if you wake up the network every 2 minutes your device battery will last ~ 5 hours. Real time data has sever impact on the battery life. We are tying to balance the need for real time w/s draining the battery. Most of the time the batter life trumps real time. That's the main reason for the 1h upload batching. Not a bug.
  • Alix
    Alix about 8 years
    @djabi : what if user are not in the app for that long. They open app, fire those custom events and kills the app. are those value are being cached some where to upload later. I am trying to get these custom events to show up for 2 days now. No success yet
  • alivingston
    alivingston almost 8 years
    @djabi is there any way to manually trigger an upload of events? With the upload being triggered by app delegate methods, that makes it impossible to track analytics for something like a keyboard extension, where there is no app delegate, right?
  • djabi
    djabi almost 8 years
    alivingston, If the device has connectivity any event should be uploaded no later then an hour after capture. If you enable debug logging following firebase.google.com/docs/analytics/android/… you can see the scheduled upload time and the actual upload. If you don't see the data in 2 days there is likely something wrong with the setup or you powered off the device/emulator where the events were recorded.
  • loudmouth
    loudmouth almost 8 years
    @djabi just to clarify: if a user opens app, does some stuff that logs events, then kills, not backgrounds, the app before an hour is up and the events would be fired, what will happen to those events in the scenario that they don't open the app again for a month?
  • djabi
    djabi almost 8 years
    IOS doesn't allow for the app to run code after the process is terminated. The data will be uploaded the next time the app process is started by either the user or to handle other request like push notification. I need to verify this but I believe iOS will background the app before the process is terminated. That should upload any pending data assuming the device has connectivity.
  • Rich
    Rich over 7 years
    I'm just highlighting this for others: Also the default day range excludes "today" so you only see events from yesterday. You can switch the date picker to include Today if you like to see the latest events. I've just spent a few hours wondering where my events were only to be stung by this (somewhat annoying "feature")!
  • Fattie
    Fattie almost 6 years
    note that -FIRAnalyticsDebugEnabled has only ONE dash in front of it
  • Dhaval H. Nena
    Dhaval H. Nena almost 5 years
    Same here.. that ONE DASH was the issue in my case too. It took my whole day to figure out what was wrong.
  • crashoverride777
    crashoverride777 almost 5 years
    hehe, its so annoying, I have done it at least 3 times. :)
  • Dhaval H. Nena
    Dhaval H. Nena almost 5 years
    Truly it is.. however now onwards it will make me more attentive for such minor issues.
  • Shubham Ojha
    Shubham Ojha over 4 years
    is the analytics still not realtime?
  • Morgan
    Morgan over 4 years
    For anyone who has trouble finding the DebugView tab, you have to scroll down within the left sidebar. This wasn't obvious to me.
  • henrique
    henrique about 3 years
    To see events while debugging add -FIRAnalyticsDebugEnabled to launch arguments and see firebase.google.com/docs/analytics/debugview