Skip to Content
Octopus Energy Packages

Experiment Reporting

Export reference for React experiment-exposure reporting

import {
  type ExperimentExposure,
  ExperimentExposureReporter,
  ExperimentsProvider,
  useExperimentExposure,
  useExperimentsContext,
} from "@octopus-energy/flags/reporting";

This entry point requires the React peer dependency. For setup and usage, see the experiment-exposure reporting guide.

ExperimentsProvider

React client component that provides a reporting emitter to descendants. emit(exposure) receives an ExperimentExposure. Each experiment/variant pair is emitted at most once for the provider's lifetime.

ExperimentsProvider

Prop

Type

ExperimentsProviderProps

Prop

Type

useExperimentExposure

React client hook that reports a readonly array of ExperimentExposure values through the nearest ExperimentsProvider.

useExperimentExposure

Prop

Type

ExperimentExposureReporter

React client component for exposures derived in a Server Component. It accepts a readonly ExperimentExposure array and emits nothing when the array is empty.

ExperimentExposureReporter

Prop

Type

ExperimentExposureReporterProps

Prop

Type

useExperimentsContext

React client hook that returns the nearest reporting context. It throws when called outside ExperimentsProvider.

useExperimentsContext

Prop

Type

ExperimentsContextValue

Prop

Type

ExperimentExposure

The exposure object passed to the reporting APIs.

ExperimentExposure

Prop

Type

On this page