FeatureFlagBehavior
Defined in: packages/pipeline-feature-flags/src/feature-flag.behavior.ts:142
Pipeline behavior that gates a handler behind an OpenFeature boolean flag.
Provider-agnostic by design: it talks only to the OpenFeature Client,
so the backing provider (Unleash, Flagsmith, LaunchDarkly, a local file, …) is
a drop-in swap of the client passed to the constructor (see createFeatureFlagClient).
OpenFeature remains the feature-flag abstraction; this behavior adds only the
pipeline-specific semantics that an application repeatedly needs.
Resolution of the effective options for a handler:
- Application-wide defaults, the second constructor argument.
- Per-operation options from the
featureFlag({ ... })entry, shallow-merged on top of the defaults (handler keys win).
Behavior:
- No
flagconfigured → transparent pass-through. - Flag evaluates
trueand optionalallowedVariantsaccepts the provider variant → run the handler. - Final gate disabled → return
fallback(context)when provided, otherwise throw FeatureDisabledError. - Provider evaluation error → use the configured
defaultValueby default, or throw FeatureFlagEvaluationError witherrorPolicy: 'throw'.
Stable rollout identity
Section titled “Stable rollout identity”Percentage/gradual rollouts should use a stable user/account/device/tenant
identity through targetingKeyFactory.
Examples
Section titled “Examples”Simple gate
Sticky user rollout with graceful fallback
Run only for one experiment variant
Make flag-provider failure visible instead of using the default
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new FeatureFlagBehavior(
client,defaults?,logger?):FeatureFlagBehavior
Defined in: packages/pipeline-feature-flags/src/feature-flag.behavior.ts:193
Parameters
Section titled “Parameters”client
Section titled “client”defaults?
Section titled “defaults?”logger?
Section titled “logger?”Returns
Section titled “Returns”FeatureFlagBehavior
Properties
Section titled “Properties”[PIPELINE_BEHAVIOR_CONTRACT]
Section titled “[PIPELINE_BEHAVIOR_CONTRACT]”
readonlystatic[PIPELINE_BEHAVIOR_CONTRACT]:IPipelineBehaviorContract
Defined in: packages/pipeline-feature-flags/src/feature-flag.behavior.ts:147
Methods
Section titled “Methods”handle()
Section titled “handle()”handle(
context,next):Promise<unknown>
Defined in: packages/pipeline-feature-flags/src/feature-flag.behavior.ts:207
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”Promise<unknown>
Implementation of
Section titled “Implementation of”resolveEffectiveOptions()
Section titled “resolveEffectiveOptions()”resolveEffectiveOptions(
options?):FeatureFlagBehaviorOptions
Defined in: packages/pipeline-feature-flags/src/feature-flag.behavior.ts:352
Shallow-merges pipeline-level options over the application defaults.