Skip to content
SDKProductBuild and shipFlag

Flag methods: evaluate

The Flag Verbs evaluate as typed SDK methods, with inputs, result, refusals and an example.

Reference for Flag, one group of Flag methods.

Flag.evaluate

Evaluate returns the Variant a Flag assigns one unit, the same one every time, and records the Exposure with every option and its propensity. Verb page.

TypeScript
interface FlagVerbs {
  evaluate(input: FlagEvaluateInput, options?: SB.CallOptions): SB.Call<FlagEvaluateOutput>
}

Emits Flag.evaluated.

Inputs

InputTypeRequiredDescription
flagFlagrequiredThe Flag to evaluate, by key.
unitstringrequiredThe id of the Visitor, Customer, Contact, Conversation or request being assigned.
defaultstringThe Variant key returned when the Flag is off or the value may not be varied.

Returns

OutputTypeRequiredDescription
variantVariantrequiredThe Variant assigned to the unit.
exposureExposureThe Exposure recorded; none in Mode try.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.

Example

TypeScript
import { $ } from 'startup-builder'

const { variant, exposure } = await $.Flag.evaluate({ flag: 'flag_1YJLhjTlfx', unit: 'Example unit' })