Search in sources :

Example 1 with BatchEventProcessor

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);
    });
}
Also used : EventHandler(com.optimizely.ab.event.EventHandler) DefaultEventHandler(com.optimizely.ab.android.event_handler.DefaultEventHandler) BatchEventProcessor(com.optimizely.ab.event.BatchEventProcessor) OptimizelyClient(com.optimizely.ab.android.sdk.OptimizelyClient) OptimizelyManager(com.optimizely.ab.android.sdk.OptimizelyManager)

Aggregations

DefaultEventHandler (com.optimizely.ab.android.event_handler.DefaultEventHandler)1 OptimizelyClient (com.optimizely.ab.android.sdk.OptimizelyClient)1 OptimizelyManager (com.optimizely.ab.android.sdk.OptimizelyManager)1 BatchEventProcessor (com.optimizely.ab.event.BatchEventProcessor)1 EventHandler (com.optimizely.ab.event.EventHandler)1