Raygun’s offline crash report queuing feature

| 5 min. (935 words)

With the meteoric rise of mobile applications, the need to support users operating in various states of network connectivity is vital. Being able to capture crash data even while a device isn’t connected to the Internet enables your team to keep an eye on those events that might otherwise go undetected without a user submitted report.

To help make the offline tracking of errors easier, Raygun offers offline crash report queuing in many providers serving mobile and desktop applications.

The offline crash report queuing feature allows for more comprehensive exception reporting without relying on users to submit the reports manually after network connection is regained.  While the end result is similar, each provider has its own methods and capabilities, which are explained below.

Providers:

iOS

Need assistance installing our iOS provider?

When a crash occurs in an iOS application with raygun4ios installed, the crash report is created immediately. However, due to the unpredictable nature of device memory during a crash, the crash report is saved locally as a safety precaution. Once the application is restarted the raygun4ios provider will attempt to send any reports that have been saved locally.

Sending a crash report immediately after a crash would potentially be unsafe due to the unpredictable nature of the device memory. This makes saving the report or reports locally and then having the reports sent the next time the app starts up the better option. If there is no Internet connection when the app restarts, the locally saved crash reports remain intact until the app is restarted and has an active Internet connection.

There is currently no set limit on the number of crash reports that can be queued up/saved locally to the device.

Android

Need help installing our Android provider?

When an exception occurs in an app utilizing raygun4android with no Internet connection, the crash report it saved to disk. The next time the provider is asked to send another message it will check if an Internet connection is available. If a connection is available the provider will send all the cached messages.  Each message will include the device’s network connectivity state at the time of the exception’s occurrence. This state information is visible under the Request tab in the Raygun Crash Reporting dashboard.

There is a maximum of 64 saved messages that can be saved locally, after which they will be overwritten using a LRU strategy.

**JavaScript **

Need help installing our JavaScript provider?

With the raygun4js provider, if an exception is caught when there is no network connectivity (or if the request times out after 10 seconds) the crash report can be saved to Local Storage. The next time an exception occurs the provider will also send all previously saved errors. This is especially useful in environments like WinJS where a mobile device’s connection is not constant.

Offline saving of crash reports is disabled by default. To set this option, call the following after your init() call:

// v2
rg4js(saveIfOffline, true);

// v1
Raygun.saveIfOffline(true);

This behavior is confirmed to work on Chrome, Firefox, IE 10/11, and WinJS. Limited support is available for IE 8 and 9; errors will only be saved if the request times out.

For more information regarding the offline crash report queuing feature of raygun4js, check out this blog post.

Node.js

Need help installing our Node.js provider?

The raygun4node provider can cache errors thrown by your Node application when it’s running in ‘offline’ mode. By default the offline cache is disabled. The raygun4node provider doesn’t detect network state change, that is up to the application using the library.

Raygun includes an on-disk cache provider out of the box, which required write permissions to the folder you wish to use. You cal also pass in your own cache storage.

To get started with the default offline provider you’ll need to pass through a cache path when creating your Raygun client:

var raygunClient = new raygun.Client().init(
    {
        apiKey: 'API-KEY',
        isOffline: false,
        offlineStorageOptions: {
          cachePath: 'raygunCache/',
          cacheLimit: 1000 // defaults to 100 errors if you don't set this
        }
    }
);

To change the online/offline state of the provider you can use the following methods:

//online
raygunClient.online();

//offline
raygunClient.offline();

When set to online, any cached errors will be sent to Raygun.

If you can’t or do not wish to access the disk, you can set your own custom cache provider via the offlineStorage property:

var sqlStorageProvider = new SQLStorageProvider();

 var raygunClient = new raygun.Client().init(
        {
            apiKey: 'API-KEY',
            isOffline: false,
            offlineStorage: sqlStorageProvider,
            offlineStorageOptions: {
                table: 'RaygunCache'
            }
        }
    );

We recommend that you limit the number of errors that you are caching so that you don’t swamp the clients internet connection sending errors.

For more information regarding the offline crash report queuing for the raygun4node provider, check out this blog post.

.NET

*Note –  This section applies to the following: Windows Phone, Windows Store, Xamarin.iOS, Xamarin.android, and any .NET desktop application that has access to isolated storage (WinRT, WPF, WinForms, and console apps for example.)

Need help installing our .NET provider?

Many applications using the raygun4net provider can also save crash reports locally. The provider will attempt to send these saved reports once a new exception occurs or if the application is restarted.

There is a limit of 10 reports that can be saved locally.

For more information regarding the offline crash report queuing feature for the raygun4net provider, please take a look at the following blog post.

Final Thoughts

There are several options available for your mobile and desktop application needs. If you need more information or assistance with the offline queuing options get in touch with a friendly team member at support@raygun.com.