PostHog Capture

PostHog Capture

Certified

Capture a PostHog event

Sends a custom analytics event for a distinctId, with optional properties and timestamp. Uses the project API key (phc_).

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

Capture a custom event when a pipeline completes

yaml
id: pipeline_completed_event
namespace: company.analytics

inputs:
  - id: user_id
    type: STRING
  - id: pipeline_name
    type: STRING

tasks:
  - id: capture_completion
    type: io.kestra.plugin.posthog.Capture
    apiKey: "{{ secret('POSTHOG_API_KEY') }}"
    host: "https://us.i.posthog.com"
    distinctId: "{{ inputs.user_id }}"
    event: pipeline_completed
    properties:
      pipeline_name: "{{ inputs.pipeline_name }}"
      kestra_execution_id: "{{ execution.id }}"
      environment: production
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 performing the event.

Event name

The name of the event to capture, e.g. pipeline_completed.

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.

Event properties

Optional properties to attach to the event.

Event timestamp

Optional time at which the event happened, as an ISO-8601 instant (e.g. 2026-01-01T00: 00: 00Z). Defaults to the time the event is captured.