use of com.optimizely.ab.event.BatchEventProcessor in project android-sdk by optimizely.
the class APISamplesInJava method samplesForDoc_EventBatchingAdvanced.
public static void samplesForDoc_EventBatchingAdvanced(Context context) {
// -- sample starts here
EventHandler eventHandler = DefaultEventHandler.getInstance(context);
// Here we are using the builder options to set batch size
// to 5 events and flush interval to a minute.
BatchEventProcessor batchProcessor = BatchEventProcessor.builder().withBatchSize(5).withEventHandler(eventHandler).withFlushInterval(TimeUnit.MINUTES.toMillis(1L)).build();
OptimizelyManager optimizelyManager = OptimizelyManager.builder().withSDKKey("<Your_SDK_Key>").withEventHandler(eventHandler).withDatafileDownloadInterval(15, TimeUnit.MINUTES).withEventProcessor(batchProcessor).build(context);
OptimizelyClient optimizely = optimizelyManager.initialize(context, R.raw.datafile);
// log event
// -- sample starts here
optimizely.addLogEventNotificationHandler(logEvent -> {
Log.d("Optimizely", "event dispatched: " + logEvent);
});
}
Aggregations