Interface GrowthBookPlugin

All Known Implementing Classes:
GrowthBookTrackingPlugin

public interface GrowthBookPlugin
A plugin that can observe experiment and feature evaluations on a GrowthBook instance. Mirrors the plugin contracts in the GrowthBook Python and Go SDKs.

Implementations MUST be thread-safe. All methods default to no-ops so custom plugins only override what they need. Methods should return quickly (enqueue work, don't block evaluation). Exceptions thrown by these methods are caught by PluginRegistry so one failing plugin can't break evaluation or other plugins.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Invoked when the owning GrowthBook instance is closed.
    default void
    Called once when the plugin is registered with a GrowthBook instance.
    default <V> void
    onExperimentViewed(Experiment<V> experiment, ExperimentResult<V> result)
    Invoked after a user is bucketed into an experiment (once per unique hashAttribute/hashValue/experiment.key/variation combination).
    default <V> void
    onFeatureEvaluated(String featureKey, FeatureResult<V> result)
    Invoked every time a feature is evaluated.
  • Method Details

    • init

      default void init()
      Called once when the plugin is registered with a GrowthBook instance. If this throws, the plugin is treated as failed and receives no further events (see PluginRegistry).
    • onExperimentViewed

      default <V> void onExperimentViewed(Experiment<V> experiment, ExperimentResult<V> result)
      Invoked after a user is bucketed into an experiment (once per unique hashAttribute/hashValue/experiment.key/variation combination).
    • onFeatureEvaluated

      default <V> void onFeatureEvaluated(String featureKey, FeatureResult<V> result)
      Invoked every time a feature is evaluated.
    • close

      default void close()
      Invoked when the owning GrowthBook instance is closed. Implementations should flush any buffered work synchronously. MUST be safe to call multiple times and even if init() failed.