:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
"""The metric vocabulary the self-optimising loop reads.
Kept in one place because the two sides of a suggestion have to agree: whatever writes the evidence
- a Scout, over the API - and the outcome endpoint that reports what the change did. If they name
different metrics, a proposal's "before" and "after" stop being comparable.
"""
# Every hog flow metric is mirrored under this app source with the version appended to the flow id,
# which is what makes a per-version read possible at all. See "Metrics and version attribution" in
# products/workflows/CONTRIBUTING.md.
HOG_FLOW_VERSION_APP_SOURCE = "hog_flow_version"
TARGET_SEND_METRIC = "email_sent"
TARGET_OPEN_METRIC = "email_opened"
# Both rates count what the window recorded, not what a cohort went on to do.
# Clicks read against the same denominator as opens; the two move for different reasons.
TARGET_CLICK_METRIC = "email_link_clicked"
# Sends with tracking off can never record an open, so the open rate reads against
# (email_sent - email_untracked); guardrail rates keep the raw send count.
TARGET_UNTRACKED_METRIC = "email_untracked"
# Counter-metrics read over the same window, step and version as the target.
GUARDRAIL_METRICS = ("email_blocked", "email_bounced")
GUARDRAIL_LABELS = {"email_blocked": "complaint rate", "email_bounced": "bounce rate"}
# What a suggestion can aim at, and how each one is read: the metric counted, whether it divides by
# tracked sends (an untracked send can record neither an open nor a click) or by every send, and the
# name a person reads. A suggestion that names anything else is measured on opens, the default.
TARGET_METRICS: dict[str, tuple[str, bool, str]] = {
TARGET_OPEN_METRIC: (TARGET_OPEN_METRIC, True, "email open rate"),
TARGET_CLICK_METRIC: (TARGET_CLICK_METRIC, True, "click rate"),
"email_bounced": ("email_bounced", False, "bounce rate"),
"email_blocked": ("email_blocked", False, "complaint rate"),
}
# `email_unsubscribed` exists only as a name in the worker's metric union with no producer. Named so
# the surfaces can say the number is missing rather than imply a zero.
UNAVAILABLE_GUARDRAILS = ("unsubscribe rate",)
# Below this many observations a rate is noise.
MIN_EVIDENCE_SAMPLE = 20