PostHog EvaluateFeatureFlag

PostHog EvaluateFeatureFlag

Certified

Evaluate a PostHog feature flag

Asks PostHog for the value of a feature flag for a given user. The result is the flag value: a boolean for a boolean flag, or the variant name for a multivariate flag. A flag that PostHog does not return gives a null value, which is not an error. The task fails if the evaluation request itself fails (invalid API key, unreachable host, server error...). Reading the flag also sends a $feature_flag_called event to PostHog, as the PostHog SDK does by default. Uses the project API key (phc_).

yaml
type: io.kestra.plugin.posthog.EvaluateFeatureFlag

Check a feature flag and use its value in a later task

yaml
id: feature_flag_gate
namespace: company.analytics

inputs:
  - id: user_id
    type: STRING

tasks:
  - id: check_flag
    type: io.kestra.plugin.posthog.EvaluateFeatureFlag
    apiKey: "{{ secret('POSTHOG_API_KEY') }}"
    host: "https://us.i.posthog.com"
    distinctId: "{{ inputs.user_id }}"
    flagKey: new-checkout

  - id: log_flag
    type: io.kestra.plugin.core.log.Log
    message: "new-checkout is {{ outputs.check_flag.enabled ? 'on' : 'off' }} for {{ inputs.user_id }} (value: {{ outputs.check_flag.value }})"
Properties

PostHog project API key

The project API key (starts with phc_). Use a Kestra secret, e.g. {{ secret('POSTHOG_API_KEY') }}.

Distinct ID

The distinct ID of the user to evaluate the feature flag for.

Flag key

The key of the feature flag to evaluate, e.g. new-checkout.

Assets this task consumes as inputs or produces as outputs, for lineage tracking and the asset graph (Enterprise Edition). A flow declaring this property on a task is rejected in the open-source edition.

Definitions
assetFailureBehaviorstring
Possible Values
IGNOREFAILWARN

Asset failure behavior

Behavior applied to the task state when a declared asset fails to render, emit, or be persisted (e.g. a lock conflict): FAIL escalates it to FAILED, WARN (default) warns it if it would otherwise succeed, IGNORE leaves the state untouched.

enableAutobooleanstring

Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.

inputsarray

The assets consumed as inputs.

id*string
Min length1
typestring
outputs

The assets produced as outputs.

id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*string
Min length1

Custom asset type

descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150

PostHog host

The PostHog ingestion host, e.g. https://us.i.posthog.com (US Cloud), https://eu.i.posthog.com (EU Cloud) or a self-hosted URL. Defaults to US Cloud when empty.

Whether the flag is enabled

True for an enabled boolean flag or a multivariate flag with a variant. False for a disabled flag, and for a flag that PostHog did not return.

Flag value

The value of the flag: a boolean for a boolean flag, the variant name for a multivariate flag, or null if PostHog did not return the flag.

Variant

The variant name of a multivariate flag, or null for a boolean flag or a flag that PostHog did not return.