Offline Tracking

The following variables and functions let you store measurement calls when the application is offline.

Note: To enable offline tracking, your report suite must be timestamp-enabled. If timestamps are enabled on your report suite, your trackOffline configuration property must be true. if your report suite is not timestamp enabled, your trackOffline configuration property must be false. If this is not configured correctly, data will be lost. If you are not sure if a report suite is timestamp enabled, contact Customer Care.

When enabled, Offline AppMeasurement behaves in the following way:

At each subsequent hit, or at the interval defined by offlineThrottleDelay, AppMeasurement attempts to send the buffered hit data, maintaining the original hit order. If the data transmission fails, it continues to buffer the hit data (This continues while the device is offline).

Property or Method Description

trackOffline

Default: false

Enables or disables offline tracking for the measurement library.

Examples:

s.trackOffline=true;

offlineLimit

Default: no limit

Maximum number of offline hits stored in the queue.

Examples:

s.offlineHitLimit=100;

offlineThrottleDelay

Default: 0

Specifies a cadence (or delay), in milliseconds, for sending buffered hit data when AppMeasurement detects an active network connection. Doing so mitigates the performance impact of sending multiple hits on the application.

For example, if offlineThrottleDelay=1000, and it takes 300ms to send the hit data, AppMeasurement waits 700ms before sending the next buffered hit.

s.offlineThrottleDelay=1000;

forceOnline

forceOffline

Manually set the online or offline state of the measurement object. The library automatically detects when the device is offline or online, so these methods are needed only if you want to force measurement offline. forceOnline is used only to return to the online state after manually going offline.

When measurement is offline:

  • If trackOffline is true: hits are stored until measurement is online.
  • If trackOffline is false: hits are discarded.

Examples:

s.forceOffline();
s.forceOnline();