Batching events with the iOS SDK

Last Updated: Jan 17, 2016 10:29PM PST

At a glance

The Apsalar SDK by default sends all session and event data in real-time, ensuring minimal data loss and data recency in real-time reports. There are cases however that an application developer would prefer to batch Apsalar event calls to optimize data bandwidth and application performance. The Apsalar iOS SDK provides a number of methods to enable and control batching of events.

Enabling event batching

Event batching is disabled by default and all events are sent in real-time. To enable or disable event batching, use the following method:
[Apsalar setBatchesEvents:(BOOL)boolean]; 

Modifying event batching settings

The SDK batches all events within a specified time interval, to be sent at the end of the time interval before starting a new batch for the next time interval.

The default time interval for the batch is 30 seconds. To modify this time interval, use the following method:
[Apsalar setBatchInterval:(int)interval]; 
Where interval is an integer in the range of 0 to 3600. An interval of 0 will send data in real-time.

In addition to the regular batching of events with the specified time interval,
  • To ensure timely reporting for critical data points, the following API calls are excluded from the batch and are sent in real-time: start session, restart session, end session, In-app purchase events.
  • Upon ending a session, the SDK will send all remaining batches before the application exits.
  • If a batch cannot be sent before the session terminates, it will be sent immediately after the next session is started.
  • Each event call includes a timestamp and a session ID and as such will be attributed to the date and session when the event occurred.

Manually send a batch

In the event a batch needs to be sent immediately, use the following method to send all outstanding batches and start a new batch:
[Apsalar sendAllBatches];
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
Invalid characters found