Does Firebase Analytics Work Offline?

Sept 2019 source: Firebase offline: What works, what doesn't, and what you need to know (Firebase Summit 2019)

Performance Monitoring & Firebase Analytics discards data that is generally >72 hours old

Measurement tools (Perf, Analytics, Crashlytics) are suspicious of data that looks too old - Todd Kerpelman @ Firebase Summit 2019

Notably, this 72hr limit is not a hard limit like the cache size and event limits are, so there are times where more than 72hrs can be cached offline and reported back to the servers though this is not guaranteed.

Summary of Perf, Analytics, Crashlytics in above video:

  • Performance Monitoring
    • Android: 10MB cache across all apps
    • iOS: 10MB cache across each app
    • oldest data is purged if limit is reached
    • discards data that is generally >72 hours old
  • Analytics:
    • 100,000 events
    • most recent data gets eliminated
    • discards data that is generally >72 hours old if event limit is reached
  • Crashlytics:
    • 9 crashed (up to 150K each)
    • re-writes timestamp of older data that it doesn't recognize to today as you generally want crash data

All subject to change - Todd Kerpelman @ Firebase Summit 2019

Other information:

  • Data is uploaded using exponential backoff and retry methods
  • Android uploads data via Google Play Services and so can send the data even when the app is not running (data is uploaded on crash) vs iOS where data is uploaded on next app start

I still cannot find a source for this information in the official Firebase documentation.


It's possible to bypass the 72 hours time limit on analytics. First, you need to add the permission

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

in your manifest file. Before logging events, check if internet is available using this method:

private boolean isNetworkAvailable() {
        ConnectivityManager connectivityManager
                = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
        return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}

using the method above, check if the user is online if so, log events as usual, if not, don't log it right now but save the event name and its parameters as string, using SharedPreferences.

if(isNetworkAvailable()){
// the user is online, log the events
}else{
// Don't log the events, save the event name and its parameters using SharedPreferences
}

Register BroadcastReceiver listening connectivity change events, add the following in your manifest file:

<receiver
android:name="type your class directory extending BroadcastReceiver here"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            <action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
        </intent-filter>
</receiver>

In the class extending BroadcastReceiver, check if network is available and log the events saved by SharedPreferences

public class NetworkEnabledBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if(isNetworkAvailable(context)){
        //Check if there are saved events and parameters using the same named
        //SharedPreferences used for saving the events and parameters, log if 
        //so, then clear the data. 
        }
    }
    private boolean isNetworkAvailable(Context context) {
        ConnectivityManager connectivityManager
                = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
        return activeNetworkInfo != null && activeNetworkInfo.isConnected();
    }
}

Yes, events are stored locally and uploaded when the radio is turned on. Events which arrive more than 72 hours late will be ignored by our server.


Firebase Analytics will store logged evens locally on the device (online or offline). When its time to upload the data and the devices has network connection Firebase Analytics will batch the data in as fewer uploads as possible, compress it and attempt to upload the data.

When the upload is successful the data is deleted from the device. When the upload fails a new attempt is scheduled with progressive back-off. If the device is offline the app will wait for connectivity before attempting upload.

Data older than 72 hours will be ignored. There are safety limits on how much data can be stored on the device (to limit disk usage). Logging excessive data on device that is offline for long period of time might lead to data loss.