The Optimizely Feature Experimentation Flutter SDK uses the event processor to batch decisions and conversion events into a single payload before sending it to Optimizely Feature Experimentation.
The Flutter SDK lets you batch events and includes options to set an event batch size, event time interval and event flush interval. The benefit of event batching is less network traffic for the same number of impression and conversion events tracked.
Configure event batching
There are three options to configure event batching:
eventMaxQueueSize. You can pass in both options during client creation. The system holds events in a queue until either:
- The number of events reaches the defined
- The oldest event has been in the queue for longer than the defined
eventTimeInterval, which is specified in seconds. The system then flushes the queue and sends all queued events to Optimizely Feature Experimentation in a single network request.
- The system receives a new datafile revision. This occurs only when you enable live datafile updates.
var flutterSDK = OptimizelyFlutterSdk("<Your_SDK_Key>", eventOptions: const EventOptions( batchSize: 1, timeInterval: 60, maxQueueSize: 10000)); var response = await flutterSDK.initializeClient();
The table below defines these options and lists the default settings.
Please contact support for recommendations for your specific implementation.
|eventBatchSize||The maximum number of events to hold in the queue. Once you reach this number, the system flushes all queued events and sends them to Optimizely Feature Experimentation.|
|eventTimeInterval||The maximum duration in milliseconds that an event can exist in the queue before flushing.|
Default: 1 minute
|eventMaxQueueSize||The maximum queue size in kilobytes.|
The maximum payload size is 3.5 MB. If the resulting batch payload exceeds this limit, the system rejects requests with a 400 response code,
Bad Request Error.
The most common cause of a large payload size is a high batch size. If your payloads exceed the size limit, try configuring a smaller batch size.
Close Optimizely Feature Experimentation on application exit
If you enable event batching, you must call the Close method (
flutterSDK.close) before exiting. This ensures that the system flushes queued events as soon as possible to avoid data loss.
Because the Optimizely client maintains a buffer of queued events, we recommend you call
close()on the Optimizely Feature Experimentation Flutter SDK instance before shutting down your application or whenever dereferencing the instance.
|close()||Stops all timers and flushes the event queue. This method also stops any timers that are happening for the datafile manager.|
Note: We recommend connecting this method to a kill signal for the running process.
You can hook into the
SIGTERM event to ensure that
close() is invoked, guaranteeing the system sends all events in the queue.
Updated 4 months ago