• HOME
  • INTEGRATIONS
  • SDKS
  • GUIDES
  • API DOCS
No results for ""
EXPAND ALL
launchdarkly.com

EDIT ON GITHUB

Flushing events

Read time: 5 minutes
Last edited: Jun 18, 2021

Overview

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

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.

Most customers do not need to use the flush feature because SDKs automatically flush their pending analytics events on a periodic frequency.

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:

Android

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 test out 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:

1ldClient.flush();

The flush interval is configurable.

C/C++ (client-side)

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 out the SDK in a simulator, you may want to manually call flush to process events immediately.

1LDClientFlush(client);

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

Flutter

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 test out 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.

1await LDClient.flush();

iOS

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 test out 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.

1LDClient.get()!.flush()

JavaScript

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 test out 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.

1ldclient.flush();

Node.js (client-side)

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.

1ldClient.flush();
2
3// or, with a callback:
4ldClient.flush(() => {
5 console.log('flush complete');
6});
7
8// or, with a Promise:
9ldClient.flush().then(() => {
10 console.log('flush complete');
11});

React Native

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 test out 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.

1client.flush();

Roku

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 test out 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.

1launchDarkly.flush()

Xamarin

Internally, the Xamarin SDK keeps an event buffer for Track and Identify calls. These are flushed periodically in a background thread. In some situations, such as if you're testing out 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.

1ldClient.Flush();

Server-side SDKs

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

.NET

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. In some situations, such as if you're testing out 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.

1ldClient.Flush();

C/C++ (server-side)

The LaunchDarkly SDK keeps an internal event buffer for analytics events. These are flushed periodically in a background thread. In some situations, such as if you're testing out 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.

1LDClientFlush(client);

Go

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.

1ldClient.Flush();

Haskell

The LaunchDarkly SDK keeps an internal event buffer for analytics events. These events are flushed periodically in a background thread. In some situations, such as if you're testing 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.

1flushEvents client

Java

Internally, the LaunchDarkly SDK keeps an event buffer for track and identify calls. These are flushed periodically in a background thread. In some situations, such as if you're testing out 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().

1ldClient.flush();

Lua

The LaunchDarkly SDK keeps an internal event buffer for analytics events. These are flushed periodically in a background thread. In some situations, such as if you're testing out 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.

1client:flush()

Node.js (server-side)

Internally, the LaunchDarkly SDK keeps an event buffer for track and identify calls. These are flushed periodically in a background thread. In some situations, such as if you're testing out 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.

1ldClient.flush();

Python

Internally, the LaunchDarkly SDK keeps an event buffer for variation, track, and identify calls. These are flushed periodically in a background thread. In some situations, such as if you're testing out 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.

1ldclient.get().flush()

Ruby

Internally, the LaunchDarkly SDK keeps an event buffer for track and identify calls. These are flushed periodically in a background thread. In some situations, such as if you're testing out 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.

1ld_client.flush