Skip to content

: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.

6.0 KB
Raw Blame
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "properties": {
        "display": {
            "default": "number",
            "description": "Visual representation in the UI. One of `number` or `sparkline`.\n\n* `number` - number\n* `sparkline` - sparkline",
            "enum": ["number", "sparkline"],
            "type": "string"
        },
        "filters": {
            "anyOf": [
                {
                    "description": "Data-warehouse-source filter shape.",
                    "properties": {
                        "key_field": {
                            "description": "Column on the row whose value matches the entity key. v1 supports group profiles only — the column value is compared to the group_key.",
                            "type": "string"
                        },
                        "source": {
                            "const": "data_warehouse",
                            "type": "string"
                        },
                        "table_name": {
                            "description": "Name of a synced data warehouse table. Use `external-data-schemas-list` to discover available tables.",
                            "type": "string"
                        },
                        "timestamp_field": {
                            "description": "Timestamp column or HogQL expression on the row (e.g. \"created\" or \"toDateTime(created_at)\"). Use `execute-sql` (`SELECT * FROM <table> LIMIT 1`) to inspect available columns.",
                            "type": "string"
                        }
                    },
                    "required": ["source", "table_name", "timestamp_field", "key_field"],
                    "type": "object"
                },
                {
                    "description": "Events-source filter shape (default).",
                    "properties": {
                        "actions": {
                            "items": {},
                            "type": "array"
                        },
                        "events": {
                            "description": "Events to count or sum over.",
                            "items": {
                                "properties": {
                                    "id": {
                                        "description": "Event name (e.g. \"$pageview\").",
                                        "type": "string"
                                    },
                                    "name": {
                                        "type": "string"
                                    },
                                    "order": {
                                        "maximum": 9007199254740991,
                                        "minimum": -9007199254740991,
                                        "type": "integer"
                                    },
                                    "properties": {
                                        "items": {},
                                        "type": "array"
                                    },
                                    "type": {
                                        "const": "events",
                                        "type": "string"
                                    }
                                },
                                "required": ["id"],
                                "type": "object"
                            },
                            "type": "array"
                        },
                        "filter_test_accounts": {
                            "type": "boolean"
                        },
                        "properties": {
                            "items": {},
                            "type": "array"
                        }
                    },
                    "required": ["events"],
                    "type": "object"
                }
            ],
            "description": "Filter definition. Pick exactly one branch: `data_warehouse` (set `source: \"data_warehouse\"` plus `table_name`/`timestamp_field`/`key_field`) or `events` (HogFunction filter shape with an `events` array)."
        },
        "format": {
            "default": "numeric",
            "description": "How the metric value is formatted in the UI. One of `numeric` or `currency`.\n\n* `numeric` - numeric\n* `currency` - currency",
            "enum": ["numeric", "currency"],
            "type": "string"
        },
        "group_type_index": {
            "description": "Legacy URL parameter retained for backward compatibility. Pass `0`. The stored value does not scope the metric — usage metrics apply to both groups and persons regardless of this value.",
            "maximum": 2147483647,
            "minimum": -2147483648,
            "type": "number"
        },
        "interval": {
            "default": 7,
            "description": "Rolling time window in days used to compute the metric. Defaults to 7.",
            "type": "number"
        },
        "math": {
            "default": "count",
            "description": "Aggregation function. `count` counts matching events; `sum` sums the value of `math_property` on matching events.\n\n* `count` - count\n* `sum` - sum",
            "enum": ["count", "sum"],
            "type": "string"
        },
        "math_property": {
            "anyOf": [
                {
                    "maxLength": 255,
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "description": "Required when `math` is `sum`; must be empty when `math` is `count`. For events metrics this is an event property name. For data warehouse metrics this is the column name (or HogQL expression) to sum on the DW table."
        },
        "name": {
            "description": "Name of the usage metric. Must be unique per group type within the project.",
            "maxLength": 255,
            "type": "string"
        }
    },
    "required": ["group_type_index", "name", "filters"],
    "type": "object"
}