Hook
in package
Base class for extending SDK functionality via hooks.
Hook implementations MUST inherit from this class. Default no-op implementations are provided for every stage so the SDK can add new stages without breaking existing implementations.
Only getMetadata is abstract; subclasses override just the stages they need.
Table of Contents
- afterEvaluation() : array<string, mixed>
- Stage executed after the flag value has been determined.
- afterTrack() : void
- Handler executed after a custom event has been enqueued by a call to `track`.
- beforeEvaluation() : array<string, mixed>
- Stage executed before the flag value has been determined.
- getMetadata() : Metadata
- Get metadata about the hook implementation.
Methods
afterEvaluation()
Stage executed after the flag value has been determined.
public
afterEvaluation(EvaluationSeriesContext $seriesContext, array<string, mixed> $data, EvaluationDetail $detail) : array<string, mixed>
Called synchronously on the thread performing the variation call.
Parameters
- $seriesContext : EvaluationSeriesContext
- $data : array<string, mixed>
-
Data returned by the beforeEvaluation stage of this hook.
- $detail : EvaluationDetail
-
The result of the evaluation. This value should not be modified.
Return values
array<string, mixed> —Data to be passed to the next stage of this hook. The return is currently unused but future stages may consume it.
afterTrack()
Handler executed after a custom event has been enqueued by a call to `track`.
public
afterTrack(TrackSeriesContext $seriesContext) : void
Not invoked if the track call could not enqueue an event (e.g. invalid context).
Parameters
- $seriesContext : TrackSeriesContext
Return values
void —beforeEvaluation()
Stage executed before the flag value has been determined.
public
beforeEvaluation(EvaluationSeriesContext $seriesContext, array<string, mixed> $data) : array<string, mixed>
Called synchronously on the thread performing the variation call.
Parameters
- $seriesContext : EvaluationSeriesContext
- $data : array<string, mixed>
-
Data returned by the previous stage of this hook. For beforeEvaluation this will be an empty array.
Return values
array<string, mixed> —Data to be passed to the next stage of this hook. Implementations should return the input data (optionally augmented) unchanged if they do not need to pass additional information forward.
getMetadata()
Get metadata about the hook implementation.
public
abstract getMetadata() : Metadata