Class GrowthBookTrackingPlugin
- All Implemented Interfaces:
GrowthBookPlugin
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.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Invoked when the owning GrowthBook instance is closed.voidinit()Called once when the plugin is registered with a GrowthBook instance.static GrowthBookTrackingPluginof(TrackingPluginConfig config) <V> voidonExperimentViewed(Experiment<V> experiment, ExperimentResult<V> result) Invoked after a user is bucketed into an experiment (once per unique hashAttribute/hashValue/experiment.key/variation combination).<V> voidonFeatureEvaluated(String featureKey, FeatureResult<V> result) Invoked every time a feature is evaluated.
-
Method Details
-
of
-
init
public void init()Description copied from interface:GrowthBookPluginCalled once when the plugin is registered with a GrowthBook instance. If this throws, the plugin is treated as failed and receives no further events (seePluginRegistry).- Specified by:
initin interfaceGrowthBookPlugin
-
onExperimentViewed
Description copied from interface:GrowthBookPluginInvoked after a user is bucketed into an experiment (once per unique hashAttribute/hashValue/experiment.key/variation combination).- Specified by:
onExperimentViewedin interfaceGrowthBookPlugin
-
onFeatureEvaluated
Description copied from interface:GrowthBookPluginInvoked every time a feature is evaluated.- Specified by:
onFeatureEvaluatedin interfaceGrowthBookPlugin
-
close
public void close()Description copied from interface:GrowthBookPluginInvoked when the owning GrowthBook instance is closed. Implementations should flush any buffered work synchronously. MUST be safe to call multiple times and even ifGrowthBookPlugin.init()failed.- Specified by:
closein interfaceGrowthBookPlugin
-