About 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. All SDKs support asynchronous flushing, which tells the SDK to start delivering events, but returns control to the application before delivery is complete. Some SDKs also support synchronous flushing, which tells the SDK to deliver the events and not return control until delivery is complete. Details about each SDK’s configuration are available in the SDK-specific sections below.Client-side SDKs
This feature is available in the following client-side SDKs:- .NET (client-side)
- Android
- C++ (client-side)
- Flutter
- iOS
- JavaScript
- Node.js (client-side)
- React Native
- Roku
- Vue: The Vue SDK relies on the JavaScript SDK for this functionality.
.NET (client-side)
Expand .NET (client-side) code sample
Expand .NET (client-side) code sample
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:Android
Expand Android code sample
Expand Android code sample
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:C++ (client-side)
Expand C++ (client-side) code sample
Expand C++ (client-side) code sample
FlushAsync and FlushInterval.Flutter
Expand Flutter code sample
Expand Flutter code sample
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:flush.iOS
Expand iOS code sample
Expand iOS code sample
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:JavaScript
Expand JavaScript code sample
Expand JavaScript code sample
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:Node.js (client-side)
Expand Node.js (client-side) code sample
Expand Node.js (client-side) code sample
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:React Native
Expand React Native code sample
Expand React Native code sample
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.To call flush:flush is asynchronous and can be awaited. It returns a promise that resolves to an object containing an error, if there is one, and a boolean result.To learn more, read flush.Roku
Expand Roku code sample
Expand Roku code sample
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:Vue
Expand Vue code sample
Expand Vue code sample
useLDClient() and call the flush() method.Here’s how:Server-side SDKs
This feature is available in the following server-side SDKs:.NET (server-side)
Expand .NET (server-side) code sample
Expand .NET (server-side) code sample
Flush method.To call flush:FlushAndWait method. In this example, the TimeSpan.FromSeconds(2) value means that the application is willing to wait no more than two seconds for event delivery.Configuration class.Here’s how:C++ (server-side)
Expand C++ (server-side) code sample
Expand C++ (server-side) code sample
FlushAsync() in Client and about FlushInterval() in EventsBuilder.Go
Expand Go code sample
Expand Go code sample
Flush method.FlushAndWait method. In this example, the time.Second*2 value means that the application is willing to wait no more than two seconds for event delivery.Haskell
Expand Haskell code sample
Expand Haskell code sample
Java
Expand Java code sample
Expand Java code sample
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.Here’s how:LDConfig.Builder and Components.sendEvents().Lua
Expand Lua code sample
Expand Lua code sample
flush.Node.js (server-side)
Expand Node.js (server-side) code sample
Expand Node.js (server-side) code sample
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:PHP
Expand PHP code sample
Expand PHP code sample
variation, track, and identify calls. These are automatically flushed when the LDClient is destroyed. PHP’s shared-nothing architecture means manual invocation of this method is typically not needed. Developers may do so if they wish to flush events prior to teardown.Here’s how:Python
Expand Python code sample
Expand Python code sample
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 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:Ruby
Expand Ruby code sample
Expand Ruby code sample
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 you configure your client instance.Here’s how:Rust
Expand Rust code sample
Expand Rust code sample
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 Rust SDK supports asynchronous flushing with the flush method:flush_blocking method. This method triggers a flush of events currently in the outbox and blocks until that flush completes or the specified timeout expires. It returns true if the flush completed, or false if the timeout was reached. In this example, the Duration::from_secs(5) value means that the application is willing to wait no more than five seconds for the flush to complete.Edge SDKs
Most edge SDKs support sending events directly. The Akamai SDK does not. When you configure an edge SDK to send events, you must also flush those events to ensure that they are sent back to LaunchDarkly. This feature is available in the following edge SDKs:Cloudflare
Expand Cloudflare code sample
Expand Cloudflare code sample
flush inside the waitUntil method, then flushing events will not impact the handler’s response time. To learn more, read the Cloudflare documentation on waitUntil.Here’s how:flush, the events will not be sent to LaunchDarkly servers, due to the ephemeral nature of edge workers.Fastly
Expand Fastly code sample
Expand Fastly code sample
flush inside the waitUntil method, then flushing events will not impact the handler’s response time. To learn more, read the Fastly Compute documentation on waitUntil.Here’s how:flush, the events will not be sent to LaunchDarkly servers, due to the ephemeral nature of edge workers.To learn more, read flush.Vercel
Expand Vercel code sample
Expand Vercel code sample
flush inside the waitUntil method, then flushing events will not impact the handler’s response time. To learn more, read the Vercel documentation on waitUntil.Here’s how:flush, the events will not be sent to LaunchDarkly servers, due to the ephemeral nature of edge workers.