Skip to main content

Experiment

Resource Experiment in pulumi-posthog.
7 min read

Resource Experiment in pulumi-posthog.

Pulumi type: posthog:index/experiment:Experiment.

name is the Pulumi resource name. Nested object fields are documented under that object. They are not arguments of this resource.

Example#

Only required arguments are set. A string in angle brackets stands in for that argument. Any other value is an option or example written in the SDK description.

Arguments#

PropertyTypeRequiredDescription
allowUnknownEventsbooleannoOpt-in bypass of the API validation that rejects metrics referencing not-yet-ingested events. Sent on every write (so a draft with such a metric can still be launched/edited); config-only, not read back from the API.
descriptionstringnoExperiment description.
exposureCriteriastringnoExposure criteria as a JSON object (this is where filterTestAccounts lives). Same semantic-compare handling as metrics.
featureFlagKeystringyesKey of the multivariate feature flag this experiment runs on. Reference a 'posthog.FeatureFlag' resource — e.g. 'featureFlagKey'= posthog_feature_flag.<name>.key'. The flag must already exist and be multivariate (2–20 variants, one keyed 'control'). Changing this forces a new experiment (a linked flag cannot be re-keyed in place).
holdoutIdnumbernoID of an existing holdout group to reference. Holdout management itself is out of scope.
metricsstringnoPrimary metrics as a JSON array. Compared semantically, so key ordering and whitespace differences from the PostHog API do not produce a diff. Only fields you declare are tracked; server-computed fields (e.g. metric fingerprints) are ignored.
metricsSecondarystringnoSecondary metrics as a JSON array. Same semantic-compare handling as metrics.
namestringnoExperiment name.
projectIdstringnoProject ID (environment) for this resource. Overrides the provider-level project_id.
statusExperimentStatus (input)noDesired lifecycle state. The status block and its state are required (the block is schema-optional only because Terraform has no required-block modifier; a plan without it errors). Declare it to drive the experiment through draft → running → paused → stopped; the provider maps the desired state (vs. the current state) to the matching launch/pause/resume/end/ship sub-action. The lifecycle is forward-only — backward transitions error. Note: a transition spanning two sub-actions in one apply (e.g. creating directly as paused = launch+pause, or stopped = launch+end) is not atomic — if the second action fails the experiment is left mid-transition; the error names its live state so you can reconcile. The server-only exposureFrozen state cannot be managed here; resume or end such an experiment in the PostHog UI first.

Outputs#

Computed outputs are produced by the provider. They are not constructor arguments.

PropertyTypeComputedDescription
allowUnknownEventsbooleannoOpt-in bypass of the API validation that rejects metrics referencing not-yet-ingested events. Sent on every write (so a draft with such a metric can still be launched/edited); config-only, not read back from the API.
descriptionstringnoExperiment description.
experimentIdnumberyesExperiment ID.
exposureCriteriastringnoExposure criteria as a JSON object (this is where filterTestAccounts lives). Same semantic-compare handling as metrics.
featureFlagKeystringnoKey of the multivariate feature flag this experiment runs on. Reference a 'posthog.FeatureFlag' resource — e.g. 'featureFlagKey'= posthog_feature_flag.<name>.key'. The flag must already exist and be multivariate (2–20 variants, one keyed 'control'). Changing this forces a new experiment (a linked flag cannot be re-keyed in place).
holdoutIdnumbernoID of an existing holdout group to reference. Holdout management itself is out of scope.
metricsstringnoPrimary metrics as a JSON array. Compared semantically, so key ordering and whitespace differences from the PostHog API do not produce a diff. Only fields you declare are tracked; server-computed fields (e.g. metric fingerprints) are ignored.
metricsSecondarystringnoSecondary metrics as a JSON array. Same semantic-compare handling as metrics.
namestringnoExperiment name.
projectIdstringnoProject ID (environment) for this resource. Overrides the provider-level project_id.
statusExperimentStatus (output)noDesired lifecycle state. The status block and its state are required (the block is schema-optional only because Terraform has no required-block modifier; a plan without it errors). Declare it to drive the experiment through draft → running → paused → stopped; the provider maps the desired state (vs. the current state) to the matching launch/pause/resume/end/ship sub-action. The lifecycle is forward-only — backward transitions error. Note: a transition spanning two sub-actions in one apply (e.g. creating directly as paused = launch+pause, or stopped = launch+end) is not atomic — if the second action fails the experiment is left mid-transition; the error names its live state so you can reconcile. The server-only exposureFrozen state cannot be managed here; resume or end such an experiment in the PostHog UI first.

ExperimentStatus (input)#

Input object ExperimentStatus. Fields below belong to this object, not to the parent.

PropertyTypeRequiredDescription
statestringnoDesired lifecycle state — one of draft, running, paused, or stopped (required; use draft for a not-yet-launched experiment). The lifecycle is forward-only.
stoppedExperimentStatusStopped (input)noMetadata applied when stopping the experiment (read only when state = "stopped", ignored otherwise).

ExperimentStatusStopped (input)#

Input object ExperimentStatusStopped. Fields below belong to this object, not to the parent.

PropertyTypeRequiredDescription
conclusionstringnoConclusion recorded when the experiment is stopped — one of won, lost, inconclusive, stoppedEarly, invalid. Fully managed: applied at stop time and editable afterwards (an edit on an already-stopped experiment is PATCHed and read back).
conclusionCommentstringnoFree-text note recorded alongside the conclusion. Fully managed (sent on stop/update and read back).
releaseToEveryonebooleannoWhen shipping, prepend a catch-all release condition (roll out to everyone) instead of only flipping the variant distribution. Defaults to false. Config-only.
shipVariantstringnoKey of the winning variant to ship. Rewrites the linked flag's distribution so this variant gets 100% and ends the experiment. If the flag is managed by a posthog.FeatureFlag resource, set lifecycle {ignoreChanges= [filters] } on it so it does not revert the shipped distribution. Config-only; re-ships only when this value changes; clearing it does not un-ship.

ExperimentStatus (output)#

Output object ExperimentStatus. Fields below belong to this object.

PropertyTypeAlways presentDescription
statestringnoDesired lifecycle state — one of draft, running, paused, or stopped (required; use draft for a not-yet-launched experiment). The lifecycle is forward-only.
stoppedExperimentStatusStopped (output)noMetadata applied when stopping the experiment (read only when state = "stopped", ignored otherwise).

ExperimentStatusStopped (output)#

Output object ExperimentStatusStopped. Fields below belong to this object.

PropertyTypeAlways presentDescription
conclusionstringnoConclusion recorded when the experiment is stopped — one of won, lost, inconclusive, stoppedEarly, invalid. Fully managed: applied at stop time and editable afterwards (an edit on an already-stopped experiment is PATCHed and read back).
conclusionCommentstringnoFree-text note recorded alongside the conclusion. Fully managed (sent on stop/update and read back).
releaseToEveryonebooleannoWhen shipping, prepend a catch-all release condition (roll out to everyone) instead of only flipping the variant distribution. Defaults to false. Config-only.
shipVariantstringnoKey of the winning variant to ship. Rewrites the linked flag's distribution so this variant gets 100% and ends the experiment. If the flag is managed by a posthog.FeatureFlag resource, set lifecycle {ignoreChanges= [filters] } on it so it does not revert the shipped distribution. Config-only; re-ships only when this value changes; clearing it does not un-ship.