• Home
  • Integrations
  • SDKs
  • Guides
  • API docs
No results for ""
EXPAND ALL

EDIT ON GITHUB

Flushing events

Read time: 6 minutes
Last edited: May 13, 2022

Overview

This topic explains how to use the flush feature. The flush feature is available on both server-side and client-side SDKs.

All LaunchDarkly SDKs automatically flush pending analytics events to LaunchDarkly at regular intervals. This prevents the SDK from having to send constant network requests. The time between intervals varies by SDK, and is configurable. To learn how to configure your SDK's flush interval, read Configuration.

You can manually call flush to send events immediately without waiting for the next interval. Most customers do not need to use the flush feature because SDKs automatically flush their pending analytics events on a periodic frequency. However, it can be useful if you test the SDK in a simulator. To learn more, read Analytics events.

Using the flush feature

The flush feature tells the client to send all of an SDK's pending analytics events to LaunchDarkly as soon as possible. Flushing is asynchronous, so this method returns before it is complete.

Details about each SDK's configuration are available in the SDK-specific sections below.

  • Client-side SDKs
  • Server-side SDKs

Client-side SDKs

This feature is available in the following client-side SDKs:

.NET (client-side)

Expand .NET (client-side) code sample

Internally, the client-side .NET SDK keeps an event buffer for Track and Identify calls. These are flushed periodically in a background thread. If you test the SDK in a REPL, you may want to manually call Flush to process events immediately.

The flush interval is configurable. If you need to change the interval, you can do so with the Configuration class.

To call flush:

client.Flush();

Android

Expand Android code sample

The Android SDK keeps an internal event buffer for analytics calls. These are flushed periodically in a background thread. You can configure the flush interval if needed.

In some situations, such as when you're testing the SDK in a simulator, you may want to manually call flush to request any queued events to be sent immediately. This call is non-blocking, so it returns before the events are sent.

Here's how:

client.flush();

The flush interval is configurable.

C/C++ (client-side)

Expand C/C++ (server-side) code sample

The LaunchDarkly SDK keeps an internal event buffer for analytics events. These are flushed periodically in a background thread. In some situations, for example, if you're testing the SDK in a simulator, you may want to manually call flush to process events immediately.

LDClientFlush(client);

The flush interval is configurable. If you need to change the interval, you can do so via the configuration.

Flutter

Expand Flutter code sample

Internally, the Flutter SDK keeps an event buffer for track calls. These are flushed periodically in a background thread. You can configure the flush interval if needed.

In some situations, such as when you're testing the SDK in a simulator, you may want to manually call flush to request any queued events to be sent immediately. This call is non-blocking, so it returns before the events are sent.

To call flush:

await LDClient.flush();

iOS

Expand iOS code sample

Internally, the iOS SDK keeps an event buffer for track calls. These are flushed periodically in a background thread. You can configure the flush interval if needed.

In some situations, such as when you're testing the SDK in a simulator, you may want to manually call flush to request any queued events to be sent immediately. This call is non-blocking, so it returns before the events are sent.

To call flush:

LDClient.get()!.flush()

JavaScript

Expand JavaScript code sample

Internally, the JavaScript SDK keeps an event buffer for track calls. These are flushed periodically in a background thread. You can configure the flush interval if needed.

In some situations, such as when you're testing the SDK in a simulator, you may want to manually call flush to request any queued events to be sent immediately. This call is non-blocking, so it returns before the events are sent.

This method is asynchronous. You can pass a callback or wait for the returned Promise to determine when all events have been flushed.

To call flush:

client.flush();

Node.js (client-side)

Expand Node.js (client-side) code sample

Internally, the LaunchDarkly SDK keeps an analytics event buffer. These events are flushed periodically. In some situations, you may want to manually call flush to process events immediately.

This method is asynchronous. You can pass a callback or wait for the returned Promise to determine when all events have been flushed.

To call flush:

client.flush();
// or, with a callback:
client.flush(() => {
console.log('flush complete');
});
// or, with a Promise:
client.flush().then(() => {
console.log('flush complete');
});

React Native

Expand React Native code sample

Internally, the React Native SDK keeps an event buffer for track calls. These are flushed periodically in a background thread. You can configure the flush interval if needed.

In some situations, such as when you're testing the SDK in a simulator, you may want to manually call flush to request any queued events to be sent immediately. This call is non-blocking, so it returns before the events are sent.

To call flush:

client.flush();

Roku

Expand Roku code sample

Internally, the Roku SDK keeps an event buffer for track calls. These are flushed periodically in a background thread. You can configure the flush interval if needed.

In some situations, such as when you're testing the SDK in a simulator, you may want to manually call flush to request any queued events to be sent immediately. This call is non-blocking, so it returns before the events are sent.

To call flush:

launchDarkly.flush()

Server-side SDKs

This feature is available in the following server-side SDKs:

.NET (server-side)

Expand .NET (server-side) code sample

Internally, the LaunchDarkly SDK keeps an event buffer for events generated by evaluations, or by Track or Identify calls. These events are flushed periodically in a background thread. If you test the SDK in a REPL, you may want to manually call Flush to process events immediately.

The flush interval is configurable. If you need to change the interval, you can do so with the Configuration class.

To call flush:

client.Flush();

C/C++ (server-side)

Expand C/C++ (server-side) code sample

The LaunchDarkly SDK keeps an internal event buffer for analytics events. These are flushed periodically in a background thread. If you test the SDK in a simulator, you may want to manually call flush to process events immediately.

This function will not block, but instead initiate a flush operation in the background. The flush interval is configurable. If you need to change the interval, you can do so with the configuration.

Here's how:

LDClientFlush(client);

Go

Expand Go code sample

Internally, the LaunchDarkly SDK keeps an event buffer for the analytics events that are produced by calling the ...Variation or ...VariationDetail methods, the Track... methods, or Identify. These are flushed periodically in a background thread. In some situations, you may want to manually call Flush to process events immediately.

The flush interval is configurable. If you need to change the interval, you can do so by making a custom client configuration.

Here's how:

client.Flush();

Haskell

Expand Haskell code sample

The LaunchDarkly SDK keeps an internal event buffer for analytics events. These events are flushed periodically in a background thread. If you test the SDK in a simulator, you may want to manually call flush to process events immediately.

This function will not block, but instead initiate a flush operation in the background. The flush interval is configurable. If you need to change the interval, you can do so with the configuration.

Here's how:

flushEvents client

Java

Expand Java code sample

Internally, the LaunchDarkly SDK keeps an event buffer for track and identify calls. These are flushed periodically in a background thread. If you test the SDK in a REPL, you may want to manually call flush to process events immediately.

The flush interval is configurable. If you need to change the interval, you can do so with LDConfig.Builder and Components.sendEvents().

Here's how:

client.flush();

Lua

Expand Lua code sample

The LaunchDarkly SDK keeps an internal event buffer for analytics events. These are flushed periodically in a background thread. If you test the SDK in a simulator, you may want to manually call flush to process events immediately.

This function will not block, but instead initiate a flush operation in the background. The flush interval is configurable. If you need to change the interval, you can do so via the configuration.

Here's how:

client:flush()

Node.js (server-side)

Expand Node.js (server-side) code sample

Internally, the LaunchDarkly SDK keeps an event buffer for track and identify calls. These are flushed periodically in a background thread. If you test the SDK in a REPL, you may want to manually call flush to process events immediately.

The flush interval is configurable. If you need to change the interval, you can do so when configuring your client instance.

Here's how:

client.flush();

Python

Expand Python code sample

Internally, the LaunchDarkly SDK keeps an event buffer for variation, track, and identify calls. These are flushed periodically in a background thread. If you test the SDK in a REPL, you may want to manually call flush to process events immediately. Otherwise Python may close before flushing the event buffer and your user changes and tracks will not be lost.

The flush interval is configurable. If you need to change the interval, you can do so when you configure your client instance.

Here's how:

ldclient.get().flush()

Ruby

Expand Ruby code sample

Internally, the LaunchDarkly SDK keeps an event buffer for track and identify calls. These are flushed periodically in a background thread. If you test the SDK in a REPL, you may want to manually call flush to process events immediately.

The flush interval is configurable. If you need to change the interval, you can do so you configure your client instance.

Here's how:

client.flush

Rust

Expand Rust code sample

Internally, the LaunchDarkly SDK keeps an event buffer for the analytics events that are produced by calling the variation or variation_detail methods, the track methods, or identify. These are flushed periodically in a background thread. In some situations, you may want to manually call flush to process events immediately.

The flush interval is configurable. If you need to change the interval, you can do so by making a custom client configuration.

Here's how:

let result = client.flush();