Class GrowthBookTrackingPlugin

java.lang.Object
growthbook.sdk.java.plugin.tracking.GrowthBookTrackingPlugin
All Implemented Interfaces:
GrowthBookPlugin

public final class GrowthBookTrackingPlugin extends Object implements GrowthBookPlugin
Batches experiment/feature evaluation events and POSTs them to the GrowthBook data-warehouse ingest endpoint. Wire contract mirrors the Go SDK: POST {ingestorHost}/events with JSON body {"client_key": ..., "events": [...]}.

Resources (HTTP client, scheduler, flush executor) are created in init(), not the constructor, so an unregistered plugin never leaks threads. A flush is triggered when either the buffer reaches TrackingPluginConfig.resolvedBatchSize() or a timer fires after TrackingPluginConfig.resolvedBatchTimeout(). close() performs a final synchronous flush.

Delivery is best-effort: the owned flush executor uses a bounded queue and drops the newest batch (with a warning) under sustained backpressure, and failed POSTs are logged but not retried. If the configured clientKey is blank the plugin is disabled: no resources are created, event methods are no-ops, and close() still completes cleanly.

Create one instance per SDK client. A plugin instance owns a single buffer, scheduler, executor, and lifecycle flag, so sharing one instance across multiple GrowthBook/GrowthBookClient instances means the first close()/shutdown() disables tracking for all of them. Evaluations still running while the owning instance is shutting down may lose their telemetry event; stop evaluating before shutdown for complete delivery.