: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
feat(mcp): funnels inline events support (#57667)
Georgis Andonisfd88bb5f2653
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex d538e33d937b..9a8d3e284358 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -1791,6 +1791,45 @@},"type": "object"},+ "AssistantFunnelsGroupNode": {+ "additionalProperties": false,+ "description": "Defines a funnel step that combines multiple events or actions with OR (e.g. \"Pageview OR Pageleave\" counted as a single step). Filters live on the inner nodes — set per-node `properties` to give each event its own filter. Step-wide group filters, funnel math, and `optionalInFunnel` are not supported on grouped steps.",+ "properties": {+ "custom_name": {+ "type": "string"+ },+ "kind": {+ "const": "GroupNode",+ "type": "string"+ },+ "name": {+ "description": "Display name for the combined step.",+ "type": "string"+ },+ "nodes": {+ "description": "Events and actions combined into the step. Use per-node `properties` to filter each event; there is no step-wide filter on a grouped step.",+ "items": {+ "anyOf": [+ {+ "$ref": "#/definitions/AssistantFunnelsEventsNode"+ },+ {+ "$ref": "#/definitions/AssistantFunnelsActionsNode"+ }+ ]+ },+ "minItems": 2,+ "type": "array"+ },+ "operator": {+ "const": "OR",+ "description": "Only `OR` is supported.",+ "type": "string"+ }+ },+ "required": ["kind", "operator", "nodes"],+ "type": "object"+ },"AssistantFunnelsMath": {"enum": ["first_time_for_user", "first_time_for_user_with_filters"],"type": "string"@@ -1802,6 +1841,9 @@},{"$ref": "#/definitions/AssistantFunnelsActionsNode"+ },+ {+ "$ref": "#/definitions/AssistantFunnelsGroupNode"}]},diff --git a/frontend/src/queries/schema/schema-assistant-queries.ts b/frontend/src/queries/schema/schema-assistant-queries.tsindex 4db7f2e81e56..1f9bf421c2d6 100644--- a/frontend/src/queries/schema/schema-assistant-queries.ts+++ b/frontend/src/queries/schema/schema-assistant-queries.ts@@ -634,7 +634,28 @@ export interface AssistantFunnelsActionsNode extends Omit<Node, 'response'>, Assname: string}-export type AssistantFunnelsNode = AssistantFunnelsEventsNode | AssistantFunnelsActionsNode+/**+ * Defines a funnel step that combines multiple events or actions with OR (e.g. "Pageview OR Pageleave"+ * counted as a single step). Filters live on the inner nodes — set per-node `properties` to give each+ * event its own filter. Step-wide group filters, funnel math, and `optionalInFunnel` are not supported+ * on grouped steps.+ */+export interface AssistantFunnelsGroupNode {+ kind: NodeKind.GroupNode+ /** Only `OR` is supported. */+ operator: FilterLogicalOperator.Or+ /**+ * Events and actions combined into the step. Use per-node `properties` to filter each event;+ * there is no step-wide filter on a grouped step.+ * @minItems 2+ */+ nodes: (AssistantFunnelsEventsNode | AssistantFunnelsActionsNode)[]+ /** Display name for the combined step. */+ name?: string+ custom_name?: string+}++export type AssistantFunnelsNode = AssistantFunnelsEventsNode | AssistantFunnelsActionsNode | AssistantFunnelsGroupNode/*** Exclustion steps for funnels. The "from" and "to" steps must not exceed the funnel's series length.diff --git a/posthog/schema.py b/posthog/schema.pyindex 49df68ad6a97..0535efdb7a8a 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -9405,6 +9405,24 @@ class AssistantFunnelsEventsNode(BaseModel):version: float | None = Field(default=None, description="version of the node, used for schema migrations")+class AssistantFunnelsGroupNode(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ custom_name: str | None = None+ kind: Literal["GroupNode"] = "GroupNode"+ name: str | None = Field(default=None, description="Display name for the combined step.")+ nodes: list[AssistantFunnelsEventsNode | AssistantFunnelsActionsNode] = Field(+ ...,+ description=(+ "Events and actions combined into the step. Use per-node `properties` to"+ " filter each event; there is no step-wide filter on a grouped step."+ ),+ min_length=2,+ )+ operator: Literal["OR"] = Field(default="OR", description="Only `OR` is supported.")++class AssistantFunnelsQuery(BaseModel):model_config = ConfigDict(extra="forbid",@@ -9477,7 +9495,7 @@ class AssistantFunnelsQuery(BaseModel):default=None,description="Sampling rate from 0 to 1 where 1 is 100% of the data.",)- series: list[AssistantFunnelsEventsNode | AssistantFunnelsActionsNode] = Field(+ series: list[AssistantFunnelsEventsNode | AssistantFunnelsActionsNode | AssistantFunnelsGroupNode] = Field(...,description=("Events or actions to include. Prioritize the more popular and fresh events and actions."),)diff --git a/services/mcp/definitions/prompts/query-funnel.md b/services/mcp/definitions/prompts/query-funnel.mdindex 0deeb6cf98da..7c1c836d1a58 100644--- a/services/mcp/definitions/prompts/query-funnel.md+++ b/services/mcp/definitions/prompts/query-funnel.md@@ -111,6 +111,51 @@ Examples of using a breakdown:- page views to sign up funnel by country: you need to find a property such as `$geoip_country_code` and set it as a breakdown.- conversion rate of users who have completed onboarding after signing up by an organization: you need to find a property such as `organization name` and set it as a breakdown.+## Combining multiple events into a single step (`GroupNode`)++**Use a `GroupNode`** when the user wants a single funnel step to match any of several events — e.g. "Pageview OR Pageleave counts as one step", or "the user signed up via any of these channels". Different filters per event are fine — put them on the inner nodes. Use separate steps instead when the user wants the events to occur in sequence. Only `OR` is supported.++Funnel math (`first_time_for_user` etc.), `optionalInFunnel`, and step-wide property filters are not supported on a grouped step — filters must live on the inner nodes, and any math / optional handling must use a regular non-grouped step.++**Where things live:**++- On the group: only `name` (display label).+- On each inner node: `event` (or action `id`), `properties`, `name` — all respected normally; per-node `properties` apply only to that node.++### Example — funnel with a grouped step++A 3-step funnel where the middle step matches either `$pageview` on Safari or `$pageleave` on Chrome:++```json+{+ "kind": "FunnelsQuery",+ "series": [+ { "kind": "EventsNode", "event": "sign up" },+ {+ "kind": "GroupNode",+ "operator": "OR",+ "name": "Pageview on Safari, Pageleave on Chrome",+ "nodes": [+ {+ "kind": "EventsNode",+ "event": "$pageview",+ "name": "Pageview",+ "properties": [{ "key": "$browser", "operator": "exact", "type": "event", "value": ["Safari"] }]+ },+ {+ "kind": "EventsNode",+ "event": "$pageleave",+ "name": "Pageleave",+ "properties": [{ "key": "$browser", "operator": "exact", "type": "event", "value": ["Chrome"] }]+ }+ ]+ },+ { "kind": "EventsNode", "event": "purchase" }+ ],+ "dateRange": { "date_from": "-30d" }+}+```+# Examples## Conversion from first event ingested to insight saved for organizations over 6 monthsdiff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 37ba62047573..9b543b6e87fc 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -3458,7 +3458,7 @@"system_prompt_hint": "Error filtering and aggregation (error-tracking category)"},"query-funnel": {- "description": "Run a funnel query to analyze conversion rates through a sequence of steps. Funnel insights help understand user behavior as users navigate through a product. A funnel consists of a sequence of at least two events or actions, where some users progress to the next step while others drop off. Funnels use percentages as the primary aggregation type.\n\nUse 'read-data-schema' to discover available events, actions, and properties for filters and breakdowns.\n\nIMPORTANT: Funnels REQUIRE AT LEAST TWO series (events or actions).\n\nThe funnel insights have the following features:\n\n- Various visualization types (steps, time-to-convert, historical trends).\n- Filter data and apply exclusion steps (events only, not actions).\n- Break down data using a single property.\n- Specify conversion windows (default 14 days), step order (strict/ordered/unordered), and attribution settings.\n- Aggregate by users, sessions, or specific group types.\n- Track first-time conversions with special math aggregations.\n\nExamples of use cases include:\n\n- Conversion rates between steps.\n- Drop off steps (which step loses most users).\n- Steps with the highest friction and time to convert.\n- If product changes are improving their funnel over time.\n- Average/median/histogram of time to convert.\n- Conversion trends over time (using trends visualization type).\n- First-time user conversions (using first_time_for_user math).\n\nCRITICAL: Be minimalist. Only include filters, breakdowns, and settings that are essential to answer the user's specific question. Default settings are usually sufficient unless the user explicitly requests customization.\n\n# Data narrowing\n\n## Property filters\n\nUse property filters to narrow results. Only include property filters when they are essential to directly answer the user's question. Avoid adding them if the question can be addressed without additional segmentation and always use the minimum set of property filters needed.\n\nIMPORTANT: Do not check if a property is set unless the user explicitly asks for it.\n\nWhen using a property filter, you should:\n\n- **Prioritize properties directly related to the context or objective of the user's query.** Avoid using properties for identification like IDs. Instead, prioritize filtering based on general properties like `paidCustomer` or `icp_score`.\n- **Ensure that you find both the property group and name.** Property groups should be one of the following: event, person, session, group.\n- After selecting a property, **validate that the property value accurately reflects the intended criteria**.\n- **Find the suitable operator for type** (e.g., `contains`, `is set`).\n- If the operator requires a value, use the `read-data-schema` tool to find the property values.\n- You set logical operators to combine multiple properties of a single series: AND or OR.\n\nInfer the property groups from the user's request. If your first guess doesn't yield any results, try to adjust the property group.\n\nSupported operators for the String type are:\n\n- equals (exact)\n- doesn't equal (is_not)\n- contains (icontains)\n- doesn't contain (not_icontains)\n- matches regex (regex)\n- doesn't match regex (not_regex)\n- is set\n- is not set\n\nSupported operators for the Numeric type are:\n\n- equals (exact)\n- doesn't equal (is_not)\n- greater than (gt)\n- less than (lt)\n- is set\n- is not set\n\nSupported operators for the DateTime type are:\n\n- equals (is_date_exact)\n- doesn't equal (is_not for existence check)\n- before (is_date_before)\n- after (is_date_after)\n- is set\n- is not set\n\nSupported operators for the Boolean type are:\n\n- equals\n- doesn't equal\n- is set\n- is not set\n\nAll operators take a single value except for `equals` and `doesn't equal` which can take one or more values (as an array).\n\n## Time period\n\nYou should not filter events by time using property filters. Instead, use the `dateRange` field. If the question doesn't mention time, use last 30 days as a default time period.\n\n# Funnel guidelines\n\n## Exclusion steps\n\nUsers may want to use exclusion events to filter out conversions in which a particular event occurred between specific steps. These events should not be included in the main sequence. You should include start and end indexes (0-based) for each exclusion where the minimum `funnelFromStep` is 0 (first step) and the maximum `funnelToStep` is the number of steps minus one. Exclusion events cannot be actions, only events.\n\nIMPORTANT: Exclusion steps filter out conversions where the exclusion event occurred BETWEEN the specified steps. This does NOT exclude users who completed the event before the funnel started or after it ended.\n\nFor example, there is a sequence with three steps: sign up (step 0), finish onboarding (step 1), purchase (step 2). If the user wants to exclude all conversions in which users navigated away between sign up and finishing onboarding, the exclusion step will be `$pageleave` with `funnelFromStep: 0` and `funnelToStep: 1`.\n\n## Breakdown\n\nA breakdown is used to segment data by a single property value. They divide all defined funnel series into multiple subseries based on the values of the property. Include a breakdown **only when it is essential to directly answer the user's question**. You should not add a breakdown if the question can be addressed without additional segmentation.\n\nWhen using breakdowns, you should:\n\n- **Identify the property group** and name for a breakdown.\n- **Provide the property name** for a breakdown.\n- **Validate that the property value accurately reflects the intended criteria**.\n\nExamples of using a breakdown:\n\n- page views to sign up funnel by country: you need to find a property such as `$geoip_country_code` and set it as a breakdown.\n- conversion rate of users who have completed onboarding after signing up by an organization: you need to find a property such as `organization name` and set it as a breakdown.\n\n# Examples\n\n## Conversion from first event ingested to insight saved for organizations over 6 months\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n { \"kind\": \"EventsNode\", \"event\": \"first team event ingested\" },\n { \"kind\": \"EventsNode\", \"event\": \"insight saved\" }\n ],\n \"dateRange\": { \"date_from\": \"-6m\" },\n \"interval\": \"month\",\n \"aggregation_group_type_index\": 0,\n \"funnelsFilter\": {\n \"funnelOrderType\": \"ordered\",\n \"funnelVizType\": \"trends\",\n \"funnelWindowInterval\": 14,\n \"funnelWindowIntervalUnit\": \"day\"\n },\n \"filterTestAccounts\": true\n}\n```\n\n## Signup page CTA click rate within one hour, excluding page leaves, broken down by OS\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n {\n \"kind\": \"EventsNode\",\n \"event\": \"$pageview\",\n \"properties\": [{ \"key\": \"$current_url\", \"type\": \"event\", \"value\": \"signup\", \"operator\": \"icontains\" }]\n },\n {\n \"kind\": \"EventsNode\",\n \"event\": \"click subscribe button\",\n \"properties\": [{ \"key\": \"$current_url\", \"type\": \"event\", \"value\": \"signup\", \"operator\": \"icontains\" }]\n }\n ],\n \"dateRange\": { \"date_from\": \"-180d\" },\n \"interval\": \"week\",\n \"funnelsFilter\": {\n \"funnelWindowInterval\": 1,\n \"funnelWindowIntervalUnit\": \"hour\",\n \"funnelOrderType\": \"ordered\",\n \"exclusions\": [{ \"kind\": \"EventsNode\", \"event\": \"$pageleave\", \"funnelFromStep\": 0, \"funnelToStep\": 1 }]\n },\n \"breakdownFilter\": { \"breakdown_type\": \"event\", \"breakdown\": \"$os\" },\n \"filterTestAccounts\": true\n}\n```\n\n## Credit card purchase rate from viewing a product with strict ordering (no events in between)\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n { \"kind\": \"EventsNode\", \"event\": \"view product\" },\n {\n \"kind\": \"EventsNode\",\n \"event\": \"purchase\",\n \"properties\": [{ \"key\": \"paymentMethod\", \"type\": \"event\", \"value\": \"credit_card\", \"operator\": \"exact\" }]\n }\n ],\n \"dateRange\": { \"date_from\": \"-30d\" },\n \"funnelsFilter\": {\n \"funnelOrderType\": \"strict\",\n \"funnelWindowInterval\": 14,\n \"funnelWindowIntervalUnit\": \"day\"\n },\n \"filterTestAccounts\": true\n}\n```\n\n## View product to buy button to purchase, using actions and events\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n { \"kind\": \"ActionsNode\", \"id\": 8882, \"name\": \"view product\" },\n { \"kind\": \"EventsNode\", \"event\": \"click buy button\" },\n {\n \"kind\": \"ActionsNode\",\n \"id\": 573,\n \"name\": \"purchase\",\n \"properties\": [\n { \"key\": \"shipping_method\", \"value\": \"express_delivery\", \"operator\": \"icontains\", \"type\": \"event\" }\n ]\n }\n ],\n \"funnelsFilter\": { \"funnelVizType\": \"steps\" },\n \"filterTestAccounts\": true\n}\n```\n\n# Reminders\n\n- You MUST ALWAYS use AT LEAST TWO series (events or actions) in the funnel.\n- Ensure that any properties included are directly relevant to the context and objectives of the user's question. Avoid unnecessary or unrelated details.\n- Avoid overcomplicating the response with excessive property filters. Focus on the simplest solution.\n- The default funnel step order is `ordered` (events in sequence but with other events allowed in between). Use `strict` when events should happen consecutively with no events in between. Use `unordered` when order doesn't matter.\n- Exclusion events in funnels only exclude conversions where the event happened between the specified steps, not before or after the funnel.",+ "description": "Run a funnel query to analyze conversion rates through a sequence of steps. Funnel insights help understand user behavior as users navigate through a product. A funnel consists of a sequence of at least two events or actions, where some users progress to the next step while others drop off. Funnels use percentages as the primary aggregation type.\n\nUse 'read-data-schema' to discover available events, actions, and properties for filters and breakdowns.\n\nIMPORTANT: Funnels REQUIRE AT LEAST TWO series (events or actions).\n\nThe funnel insights have the following features:\n\n- Various visualization types (steps, time-to-convert, historical trends).\n- Filter data and apply exclusion steps (events only, not actions).\n- Break down data using a single property.\n- Specify conversion windows (default 14 days), step order (strict/ordered/unordered), and attribution settings.\n- Aggregate by users, sessions, or specific group types.\n- Track first-time conversions with special math aggregations.\n\nExamples of use cases include:\n\n- Conversion rates between steps.\n- Drop off steps (which step loses most users).\n- Steps with the highest friction and time to convert.\n- If product changes are improving their funnel over time.\n- Average/median/histogram of time to convert.\n- Conversion trends over time (using trends visualization type).\n- First-time user conversions (using first_time_for_user math).\n\nCRITICAL: Be minimalist. Only include filters, breakdowns, and settings that are essential to answer the user's specific question. Default settings are usually sufficient unless the user explicitly requests customization.\n\n# Data narrowing\n\n## Property filters\n\nUse property filters to narrow results. Only include property filters when they are essential to directly answer the user's question. Avoid adding them if the question can be addressed without additional segmentation and always use the minimum set of property filters needed.\n\nIMPORTANT: Do not check if a property is set unless the user explicitly asks for it.\n\nWhen using a property filter, you should:\n\n- **Prioritize properties directly related to the context or objective of the user's query.** Avoid using properties for identification like IDs. Instead, prioritize filtering based on general properties like `paidCustomer` or `icp_score`.\n- **Ensure that you find both the property group and name.** Property groups should be one of the following: event, person, session, group.\n- After selecting a property, **validate that the property value accurately reflects the intended criteria**.\n- **Find the suitable operator for type** (e.g., `contains`, `is set`).\n- If the operator requires a value, use the `read-data-schema` tool to find the property values.\n- You set logical operators to combine multiple properties of a single series: AND or OR.\n\nInfer the property groups from the user's request. If your first guess doesn't yield any results, try to adjust the property group.\n\nSupported operators for the String type are:\n\n- equals (exact)\n- doesn't equal (is_not)\n- contains (icontains)\n- doesn't contain (not_icontains)\n- matches regex (regex)\n- doesn't match regex (not_regex)\n- is set\n- is not set\n\nSupported operators for the Numeric type are:\n\n- equals (exact)\n- doesn't equal (is_not)\n- greater than (gt)\n- less than (lt)\n- is set\n- is not set\n\nSupported operators for the DateTime type are:\n\n- equals (is_date_exact)\n- doesn't equal (is_not for existence check)\n- before (is_date_before)\n- after (is_date_after)\n- is set\n- is not set\n\nSupported operators for the Boolean type are:\n\n- equals\n- doesn't equal\n- is set\n- is not set\n\nAll operators take a single value except for `equals` and `doesn't equal` which can take one or more values (as an array).\n\n## Time period\n\nYou should not filter events by time using property filters. Instead, use the `dateRange` field. If the question doesn't mention time, use last 30 days as a default time period.\n\n# Funnel guidelines\n\n## Exclusion steps\n\nUsers may want to use exclusion events to filter out conversions in which a particular event occurred between specific steps. These events should not be included in the main sequence. You should include start and end indexes (0-based) for each exclusion where the minimum `funnelFromStep` is 0 (first step) and the maximum `funnelToStep` is the number of steps minus one. Exclusion events cannot be actions, only events.\n\nIMPORTANT: Exclusion steps filter out conversions where the exclusion event occurred BETWEEN the specified steps. This does NOT exclude users who completed the event before the funnel started or after it ended.\n\nFor example, there is a sequence with three steps: sign up (step 0), finish onboarding (step 1), purchase (step 2). If the user wants to exclude all conversions in which users navigated away between sign up and finishing onboarding, the exclusion step will be `$pageleave` with `funnelFromStep: 0` and `funnelToStep: 1`.\n\n## Breakdown\n\nA breakdown is used to segment data by a single property value. They divide all defined funnel series into multiple subseries based on the values of the property. Include a breakdown **only when it is essential to directly answer the user's question**. You should not add a breakdown if the question can be addressed without additional segmentation.\n\nWhen using breakdowns, you should:\n\n- **Identify the property group** and name for a breakdown.\n- **Provide the property name** for a breakdown.\n- **Validate that the property value accurately reflects the intended criteria**.\n\nExamples of using a breakdown:\n\n- page views to sign up funnel by country: you need to find a property such as `$geoip_country_code` and set it as a breakdown.\n- conversion rate of users who have completed onboarding after signing up by an organization: you need to find a property such as `organization name` and set it as a breakdown.\n\n## Combining multiple events into a single step (`GroupNode`)\n\n**Use a `GroupNode`** when the user wants a single funnel step to match any of several events — e.g. \"Pageview OR Pageleave counts as one step\", or \"the user signed up via any of these channels\". Different filters per event are fine — put them on the inner nodes. Use separate steps instead when the user wants the events to occur in sequence. Only `OR` is supported.\n\nFunnel math (`first_time_for_user` etc.), `optionalInFunnel`, and step-wide property filters are not supported on a grouped step — filters must live on the inner nodes, and any math / optional handling must use a regular non-grouped step.\n\n**Where things live:**\n\n- On the group: only `name` (display label).\n- On each inner node: `event` (or action `id`), `properties`, `name` — all respected normally; per-node `properties` apply only to that node.\n\n### Example — funnel with a grouped step\n\nA 3-step funnel where the middle step matches either `$pageview` on Safari or `$pageleave` on Chrome:\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n { \"kind\": \"EventsNode\", \"event\": \"sign up\" },\n {\n \"kind\": \"GroupNode\",\n \"operator\": \"OR\",\n \"name\": \"Pageview on Safari, Pageleave on Chrome\",\n \"nodes\": [\n {\n \"kind\": \"EventsNode\",\n \"event\": \"$pageview\",\n \"name\": \"Pageview\",\n \"properties\": [{ \"key\": \"$browser\", \"operator\": \"exact\", \"type\": \"event\", \"value\": [\"Safari\"] }]\n },\n {\n \"kind\": \"EventsNode\",\n \"event\": \"$pageleave\",\n \"name\": \"Pageleave\",\n \"properties\": [{ \"key\": \"$browser\", \"operator\": \"exact\", \"type\": \"event\", \"value\": [\"Chrome\"] }]\n }\n ]\n },\n { \"kind\": \"EventsNode\", \"event\": \"purchase\" }\n ],\n \"dateRange\": { \"date_from\": \"-30d\" }\n}\n```\n\n# Examples\n\n## Conversion from first event ingested to insight saved for organizations over 6 months\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n { \"kind\": \"EventsNode\", \"event\": \"first team event ingested\" },\n { \"kind\": \"EventsNode\", \"event\": \"insight saved\" }\n ],\n \"dateRange\": { \"date_from\": \"-6m\" },\n \"interval\": \"month\",\n \"aggregation_group_type_index\": 0,\n \"funnelsFilter\": {\n \"funnelOrderType\": \"ordered\",\n \"funnelVizType\": \"trends\",\n \"funnelWindowInterval\": 14,\n \"funnelWindowIntervalUnit\": \"day\"\n },\n \"filterTestAccounts\": true\n}\n```\n\n## Signup page CTA click rate within one hour, excluding page leaves, broken down by OS\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n {\n \"kind\": \"EventsNode\",\n \"event\": \"$pageview\",\n \"properties\": [{ \"key\": \"$current_url\", \"type\": \"event\", \"value\": \"signup\", \"operator\": \"icontains\" }]\n },\n {\n \"kind\": \"EventsNode\",\n \"event\": \"click subscribe button\",\n \"properties\": [{ \"key\": \"$current_url\", \"type\": \"event\", \"value\": \"signup\", \"operator\": \"icontains\" }]\n }\n ],\n \"dateRange\": { \"date_from\": \"-180d\" },\n \"interval\": \"week\",\n \"funnelsFilter\": {\n \"funnelWindowInterval\": 1,\n \"funnelWindowIntervalUnit\": \"hour\",\n \"funnelOrderType\": \"ordered\",\n \"exclusions\": [{ \"kind\": \"EventsNode\", \"event\": \"$pageleave\", \"funnelFromStep\": 0, \"funnelToStep\": 1 }]\n },\n \"breakdownFilter\": { \"breakdown_type\": \"event\", \"breakdown\": \"$os\" },\n \"filterTestAccounts\": true\n}\n```\n\n## Credit card purchase rate from viewing a product with strict ordering (no events in between)\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n { \"kind\": \"EventsNode\", \"event\": \"view product\" },\n {\n \"kind\": \"EventsNode\",\n \"event\": \"purchase\",\n \"properties\": [{ \"key\": \"paymentMethod\", \"type\": \"event\", \"value\": \"credit_card\", \"operator\": \"exact\" }]\n }\n ],\n \"dateRange\": { \"date_from\": \"-30d\" },\n \"funnelsFilter\": {\n \"funnelOrderType\": \"strict\",\n \"funnelWindowInterval\": 14,\n \"funnelWindowIntervalUnit\": \"day\"\n },\n \"filterTestAccounts\": true\n}\n```\n\n## View product to buy button to purchase, using actions and events\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n { \"kind\": \"ActionsNode\", \"id\": 8882, \"name\": \"view product\" },\n { \"kind\": \"EventsNode\", \"event\": \"click buy button\" },\n {\n \"kind\": \"ActionsNode\",\n \"id\": 573,\n \"name\": \"purchase\",\n \"properties\": [\n { \"key\": \"shipping_method\", \"value\": \"express_delivery\", \"operator\": \"icontains\", \"type\": \"event\" }\n ]\n }\n ],\n \"funnelsFilter\": { \"funnelVizType\": \"steps\" },\n \"filterTestAccounts\": true\n}\n```\n\n# Reminders\n\n- You MUST ALWAYS use AT LEAST TWO series (events or actions) in the funnel.\n- Ensure that any properties included are directly relevant to the context and objectives of the user's question. Avoid unnecessary or unrelated details.\n- Avoid overcomplicating the response with excessive property filters. Focus on the simplest solution.\n- The default funnel step order is `ordered` (events in sequence but with other events allowed in between). Use `strict` when events should happen consecutively with no events in between. Use `unordered` when order doesn't matter.\n- Exclusion events in funnels only exclude conversions where the event happened between the specified steps, not before or after the funnel.","category": "Query wrappers","feature": "insights","summary": "Run a funnel query",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 8456d6017020..3922027a2748 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -3816,7 +3816,7 @@"system_prompt_hint": "Error filtering and aggregation (error-tracking category)"},"query-funnel": {- "description": "Run a funnel query to analyze conversion rates through a sequence of steps. Funnel insights help understand user behavior as users navigate through a product. A funnel consists of a sequence of at least two events or actions, where some users progress to the next step while others drop off. Funnels use percentages as the primary aggregation type.\n\nUse 'read-data-schema' to discover available events, actions, and properties for filters and breakdowns.\n\nIMPORTANT: Funnels REQUIRE AT LEAST TWO series (events or actions).\n\nThe funnel insights have the following features:\n\n- Various visualization types (steps, time-to-convert, historical trends).\n- Filter data and apply exclusion steps (events only, not actions).\n- Break down data using a single property.\n- Specify conversion windows (default 14 days), step order (strict/ordered/unordered), and attribution settings.\n- Aggregate by users, sessions, or specific group types.\n- Track first-time conversions with special math aggregations.\n\nExamples of use cases include:\n\n- Conversion rates between steps.\n- Drop off steps (which step loses most users).\n- Steps with the highest friction and time to convert.\n- If product changes are improving their funnel over time.\n- Average/median/histogram of time to convert.\n- Conversion trends over time (using trends visualization type).\n- First-time user conversions (using first_time_for_user math).\n\nCRITICAL: Be minimalist. Only include filters, breakdowns, and settings that are essential to answer the user's specific question. Default settings are usually sufficient unless the user explicitly requests customization.\n\n# Data narrowing\n\n## Property filters\n\nUse property filters to narrow results. Only include property filters when they are essential to directly answer the user's question. Avoid adding them if the question can be addressed without additional segmentation and always use the minimum set of property filters needed.\n\nIMPORTANT: Do not check if a property is set unless the user explicitly asks for it.\n\nWhen using a property filter, you should:\n\n- **Prioritize properties directly related to the context or objective of the user's query.** Avoid using properties for identification like IDs. Instead, prioritize filtering based on general properties like `paidCustomer` or `icp_score`.\n- **Ensure that you find both the property group and name.** Property groups should be one of the following: event, person, session, group.\n- After selecting a property, **validate that the property value accurately reflects the intended criteria**.\n- **Find the suitable operator for type** (e.g., `contains`, `is set`).\n- If the operator requires a value, use the `read-data-schema` tool to find the property values.\n- You set logical operators to combine multiple properties of a single series: AND or OR.\n\nInfer the property groups from the user's request. If your first guess doesn't yield any results, try to adjust the property group.\n\nSupported operators for the String type are:\n\n- equals (exact)\n- doesn't equal (is_not)\n- contains (icontains)\n- doesn't contain (not_icontains)\n- matches regex (regex)\n- doesn't match regex (not_regex)\n- is set\n- is not set\n\nSupported operators for the Numeric type are:\n\n- equals (exact)\n- doesn't equal (is_not)\n- greater than (gt)\n- less than (lt)\n- is set\n- is not set\n\nSupported operators for the DateTime type are:\n\n- equals (is_date_exact)\n- doesn't equal (is_not for existence check)\n- before (is_date_before)\n- after (is_date_after)\n- is set\n- is not set\n\nSupported operators for the Boolean type are:\n\n- equals\n- doesn't equal\n- is set\n- is not set\n\nAll operators take a single value except for `equals` and `doesn't equal` which can take one or more values (as an array).\n\n## Time period\n\nYou should not filter events by time using property filters. Instead, use the `dateRange` field. If the question doesn't mention time, use last 30 days as a default time period.\n\n# Funnel guidelines\n\n## Exclusion steps\n\nUsers may want to use exclusion events to filter out conversions in which a particular event occurred between specific steps. These events should not be included in the main sequence. You should include start and end indexes (0-based) for each exclusion where the minimum `funnelFromStep` is 0 (first step) and the maximum `funnelToStep` is the number of steps minus one. Exclusion events cannot be actions, only events.\n\nIMPORTANT: Exclusion steps filter out conversions where the exclusion event occurred BETWEEN the specified steps. This does NOT exclude users who completed the event before the funnel started or after it ended.\n\nFor example, there is a sequence with three steps: sign up (step 0), finish onboarding (step 1), purchase (step 2). If the user wants to exclude all conversions in which users navigated away between sign up and finishing onboarding, the exclusion step will be `$pageleave` with `funnelFromStep: 0` and `funnelToStep: 1`.\n\n## Breakdown\n\nA breakdown is used to segment data by a single property value. They divide all defined funnel series into multiple subseries based on the values of the property. Include a breakdown **only when it is essential to directly answer the user's question**. You should not add a breakdown if the question can be addressed without additional segmentation.\n\nWhen using breakdowns, you should:\n\n- **Identify the property group** and name for a breakdown.\n- **Provide the property name** for a breakdown.\n- **Validate that the property value accurately reflects the intended criteria**.\n\nExamples of using a breakdown:\n\n- page views to sign up funnel by country: you need to find a property such as `$geoip_country_code` and set it as a breakdown.\n- conversion rate of users who have completed onboarding after signing up by an organization: you need to find a property such as `organization name` and set it as a breakdown.\n\n# Examples\n\n## Conversion from first event ingested to insight saved for organizations over 6 months\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n { \"kind\": \"EventsNode\", \"event\": \"first team event ingested\" },\n { \"kind\": \"EventsNode\", \"event\": \"insight saved\" }\n ],\n \"dateRange\": { \"date_from\": \"-6m\" },\n \"interval\": \"month\",\n \"aggregation_group_type_index\": 0,\n \"funnelsFilter\": {\n \"funnelOrderType\": \"ordered\",\n \"funnelVizType\": \"trends\",\n \"funnelWindowInterval\": 14,\n \"funnelWindowIntervalUnit\": \"day\"\n },\n \"filterTestAccounts\": true\n}\n```\n\n## Signup page CTA click rate within one hour, excluding page leaves, broken down by OS\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n {\n \"kind\": \"EventsNode\",\n \"event\": \"$pageview\",\n \"properties\": [{ \"key\": \"$current_url\", \"type\": \"event\", \"value\": \"signup\", \"operator\": \"icontains\" }]\n },\n {\n \"kind\": \"EventsNode\",\n \"event\": \"click subscribe button\",\n \"properties\": [{ \"key\": \"$current_url\", \"type\": \"event\", \"value\": \"signup\", \"operator\": \"icontains\" }]\n }\n ],\n \"dateRange\": { \"date_from\": \"-180d\" },\n \"interval\": \"week\",\n \"funnelsFilter\": {\n \"funnelWindowInterval\": 1,\n \"funnelWindowIntervalUnit\": \"hour\",\n \"funnelOrderType\": \"ordered\",\n \"exclusions\": [{ \"kind\": \"EventsNode\", \"event\": \"$pageleave\", \"funnelFromStep\": 0, \"funnelToStep\": 1 }]\n },\n \"breakdownFilter\": { \"breakdown_type\": \"event\", \"breakdown\": \"$os\" },\n \"filterTestAccounts\": true\n}\n```\n\n## Credit card purchase rate from viewing a product with strict ordering (no events in between)\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n { \"kind\": \"EventsNode\", \"event\": \"view product\" },\n {\n \"kind\": \"EventsNode\",\n \"event\": \"purchase\",\n \"properties\": [{ \"key\": \"paymentMethod\", \"type\": \"event\", \"value\": \"credit_card\", \"operator\": \"exact\" }]\n }\n ],\n \"dateRange\": { \"date_from\": \"-30d\" },\n \"funnelsFilter\": {\n \"funnelOrderType\": \"strict\",\n \"funnelWindowInterval\": 14,\n \"funnelWindowIntervalUnit\": \"day\"\n },\n \"filterTestAccounts\": true\n}\n```\n\n## View product to buy button to purchase, using actions and events\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n { \"kind\": \"ActionsNode\", \"id\": 8882, \"name\": \"view product\" },\n { \"kind\": \"EventsNode\", \"event\": \"click buy button\" },\n {\n \"kind\": \"ActionsNode\",\n \"id\": 573,\n \"name\": \"purchase\",\n \"properties\": [\n { \"key\": \"shipping_method\", \"value\": \"express_delivery\", \"operator\": \"icontains\", \"type\": \"event\" }\n ]\n }\n ],\n \"funnelsFilter\": { \"funnelVizType\": \"steps\" },\n \"filterTestAccounts\": true\n}\n```\n\n# Reminders\n\n- You MUST ALWAYS use AT LEAST TWO series (events or actions) in the funnel.\n- Ensure that any properties included are directly relevant to the context and objectives of the user's question. Avoid unnecessary or unrelated details.\n- Avoid overcomplicating the response with excessive property filters. Focus on the simplest solution.\n- The default funnel step order is `ordered` (events in sequence but with other events allowed in between). Use `strict` when events should happen consecutively with no events in between. Use `unordered` when order doesn't matter.\n- Exclusion events in funnels only exclude conversions where the event happened between the specified steps, not before or after the funnel.",+ "description": "Run a funnel query to analyze conversion rates through a sequence of steps. Funnel insights help understand user behavior as users navigate through a product. A funnel consists of a sequence of at least two events or actions, where some users progress to the next step while others drop off. Funnels use percentages as the primary aggregation type.\n\nUse 'read-data-schema' to discover available events, actions, and properties for filters and breakdowns.\n\nIMPORTANT: Funnels REQUIRE AT LEAST TWO series (events or actions).\n\nThe funnel insights have the following features:\n\n- Various visualization types (steps, time-to-convert, historical trends).\n- Filter data and apply exclusion steps (events only, not actions).\n- Break down data using a single property.\n- Specify conversion windows (default 14 days), step order (strict/ordered/unordered), and attribution settings.\n- Aggregate by users, sessions, or specific group types.\n- Track first-time conversions with special math aggregations.\n\nExamples of use cases include:\n\n- Conversion rates between steps.\n- Drop off steps (which step loses most users).\n- Steps with the highest friction and time to convert.\n- If product changes are improving their funnel over time.\n- Average/median/histogram of time to convert.\n- Conversion trends over time (using trends visualization type).\n- First-time user conversions (using first_time_for_user math).\n\nCRITICAL: Be minimalist. Only include filters, breakdowns, and settings that are essential to answer the user's specific question. Default settings are usually sufficient unless the user explicitly requests customization.\n\n# Data narrowing\n\n## Property filters\n\nUse property filters to narrow results. Only include property filters when they are essential to directly answer the user's question. Avoid adding them if the question can be addressed without additional segmentation and always use the minimum set of property filters needed.\n\nIMPORTANT: Do not check if a property is set unless the user explicitly asks for it.\n\nWhen using a property filter, you should:\n\n- **Prioritize properties directly related to the context or objective of the user's query.** Avoid using properties for identification like IDs. Instead, prioritize filtering based on general properties like `paidCustomer` or `icp_score`.\n- **Ensure that you find both the property group and name.** Property groups should be one of the following: event, person, session, group.\n- After selecting a property, **validate that the property value accurately reflects the intended criteria**.\n- **Find the suitable operator for type** (e.g., `contains`, `is set`).\n- If the operator requires a value, use the `read-data-schema` tool to find the property values.\n- You set logical operators to combine multiple properties of a single series: AND or OR.\n\nInfer the property groups from the user's request. If your first guess doesn't yield any results, try to adjust the property group.\n\nSupported operators for the String type are:\n\n- equals (exact)\n- doesn't equal (is_not)\n- contains (icontains)\n- doesn't contain (not_icontains)\n- matches regex (regex)\n- doesn't match regex (not_regex)\n- is set\n- is not set\n\nSupported operators for the Numeric type are:\n\n- equals (exact)\n- doesn't equal (is_not)\n- greater than (gt)\n- less than (lt)\n- is set\n- is not set\n\nSupported operators for the DateTime type are:\n\n- equals (is_date_exact)\n- doesn't equal (is_not for existence check)\n- before (is_date_before)\n- after (is_date_after)\n- is set\n- is not set\n\nSupported operators for the Boolean type are:\n\n- equals\n- doesn't equal\n- is set\n- is not set\n\nAll operators take a single value except for `equals` and `doesn't equal` which can take one or more values (as an array).\n\n## Time period\n\nYou should not filter events by time using property filters. Instead, use the `dateRange` field. If the question doesn't mention time, use last 30 days as a default time period.\n\n# Funnel guidelines\n\n## Exclusion steps\n\nUsers may want to use exclusion events to filter out conversions in which a particular event occurred between specific steps. These events should not be included in the main sequence. You should include start and end indexes (0-based) for each exclusion where the minimum `funnelFromStep` is 0 (first step) and the maximum `funnelToStep` is the number of steps minus one. Exclusion events cannot be actions, only events.\n\nIMPORTANT: Exclusion steps filter out conversions where the exclusion event occurred BETWEEN the specified steps. This does NOT exclude users who completed the event before the funnel started or after it ended.\n\nFor example, there is a sequence with three steps: sign up (step 0), finish onboarding (step 1), purchase (step 2). If the user wants to exclude all conversions in which users navigated away between sign up and finishing onboarding, the exclusion step will be `$pageleave` with `funnelFromStep: 0` and `funnelToStep: 1`.\n\n## Breakdown\n\nA breakdown is used to segment data by a single property value. They divide all defined funnel series into multiple subseries based on the values of the property. Include a breakdown **only when it is essential to directly answer the user's question**. You should not add a breakdown if the question can be addressed without additional segmentation.\n\nWhen using breakdowns, you should:\n\n- **Identify the property group** and name for a breakdown.\n- **Provide the property name** for a breakdown.\n- **Validate that the property value accurately reflects the intended criteria**.\n\nExamples of using a breakdown:\n\n- page views to sign up funnel by country: you need to find a property such as `$geoip_country_code` and set it as a breakdown.\n- conversion rate of users who have completed onboarding after signing up by an organization: you need to find a property such as `organization name` and set it as a breakdown.\n\n## Combining multiple events into a single step (`GroupNode`)\n\n**Use a `GroupNode`** when the user wants a single funnel step to match any of several events — e.g. \"Pageview OR Pageleave counts as one step\", or \"the user signed up via any of these channels\". Different filters per event are fine — put them on the inner nodes. Use separate steps instead when the user wants the events to occur in sequence. Only `OR` is supported.\n\nFunnel math (`first_time_for_user` etc.), `optionalInFunnel`, and step-wide property filters are not supported on a grouped step — filters must live on the inner nodes, and any math / optional handling must use a regular non-grouped step.\n\n**Where things live:**\n\n- On the group: only `name` (display label).\n- On each inner node: `event` (or action `id`), `properties`, `name` — all respected normally; per-node `properties` apply only to that node.\n\n### Example — funnel with a grouped step\n\nA 3-step funnel where the middle step matches either `$pageview` on Safari or `$pageleave` on Chrome:\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n { \"kind\": \"EventsNode\", \"event\": \"sign up\" },\n {\n \"kind\": \"GroupNode\",\n \"operator\": \"OR\",\n \"name\": \"Pageview on Safari, Pageleave on Chrome\",\n \"nodes\": [\n {\n \"kind\": \"EventsNode\",\n \"event\": \"$pageview\",\n \"name\": \"Pageview\",\n \"properties\": [{ \"key\": \"$browser\", \"operator\": \"exact\", \"type\": \"event\", \"value\": [\"Safari\"] }]\n },\n {\n \"kind\": \"EventsNode\",\n \"event\": \"$pageleave\",\n \"name\": \"Pageleave\",\n \"properties\": [{ \"key\": \"$browser\", \"operator\": \"exact\", \"type\": \"event\", \"value\": [\"Chrome\"] }]\n }\n ]\n },\n { \"kind\": \"EventsNode\", \"event\": \"purchase\" }\n ],\n \"dateRange\": { \"date_from\": \"-30d\" }\n}\n```\n\n# Examples\n\n## Conversion from first event ingested to insight saved for organizations over 6 months\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n { \"kind\": \"EventsNode\", \"event\": \"first team event ingested\" },\n { \"kind\": \"EventsNode\", \"event\": \"insight saved\" }\n ],\n \"dateRange\": { \"date_from\": \"-6m\" },\n \"interval\": \"month\",\n \"aggregation_group_type_index\": 0,\n \"funnelsFilter\": {\n \"funnelOrderType\": \"ordered\",\n \"funnelVizType\": \"trends\",\n \"funnelWindowInterval\": 14,\n \"funnelWindowIntervalUnit\": \"day\"\n },\n \"filterTestAccounts\": true\n}\n```\n\n## Signup page CTA click rate within one hour, excluding page leaves, broken down by OS\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n {\n \"kind\": \"EventsNode\",\n \"event\": \"$pageview\",\n \"properties\": [{ \"key\": \"$current_url\", \"type\": \"event\", \"value\": \"signup\", \"operator\": \"icontains\" }]\n },\n {\n \"kind\": \"EventsNode\",\n \"event\": \"click subscribe button\",\n \"properties\": [{ \"key\": \"$current_url\", \"type\": \"event\", \"value\": \"signup\", \"operator\": \"icontains\" }]\n }\n ],\n \"dateRange\": { \"date_from\": \"-180d\" },\n \"interval\": \"week\",\n \"funnelsFilter\": {\n \"funnelWindowInterval\": 1,\n \"funnelWindowIntervalUnit\": \"hour\",\n \"funnelOrderType\": \"ordered\",\n \"exclusions\": [{ \"kind\": \"EventsNode\", \"event\": \"$pageleave\", \"funnelFromStep\": 0, \"funnelToStep\": 1 }]\n },\n \"breakdownFilter\": { \"breakdown_type\": \"event\", \"breakdown\": \"$os\" },\n \"filterTestAccounts\": true\n}\n```\n\n## Credit card purchase rate from viewing a product with strict ordering (no events in between)\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n { \"kind\": \"EventsNode\", \"event\": \"view product\" },\n {\n \"kind\": \"EventsNode\",\n \"event\": \"purchase\",\n \"properties\": [{ \"key\": \"paymentMethod\", \"type\": \"event\", \"value\": \"credit_card\", \"operator\": \"exact\" }]\n }\n ],\n \"dateRange\": { \"date_from\": \"-30d\" },\n \"funnelsFilter\": {\n \"funnelOrderType\": \"strict\",\n \"funnelWindowInterval\": 14,\n \"funnelWindowIntervalUnit\": \"day\"\n },\n \"filterTestAccounts\": true\n}\n```\n\n## View product to buy button to purchase, using actions and events\n\n```json\n{\n \"kind\": \"FunnelsQuery\",\n \"series\": [\n { \"kind\": \"ActionsNode\", \"id\": 8882, \"name\": \"view product\" },\n { \"kind\": \"EventsNode\", \"event\": \"click buy button\" },\n {\n \"kind\": \"ActionsNode\",\n \"id\": 573,\n \"name\": \"purchase\",\n \"properties\": [\n { \"key\": \"shipping_method\", \"value\": \"express_delivery\", \"operator\": \"icontains\", \"type\": \"event\" }\n ]\n }\n ],\n \"funnelsFilter\": { \"funnelVizType\": \"steps\" },\n \"filterTestAccounts\": true\n}\n```\n\n# Reminders\n\n- You MUST ALWAYS use AT LEAST TWO series (events or actions) in the funnel.\n- Ensure that any properties included are directly relevant to the context and objectives of the user's question. Avoid unnecessary or unrelated details.\n- Avoid overcomplicating the response with excessive property filters. Focus on the simplest solution.\n- The default funnel step order is `ordered` (events in sequence but with other events allowed in between). Use `strict` when events should happen consecutively with no events in between. Use `unordered` when order doesn't matter.\n- Exclusion events in funnels only exclude conversions where the event happened between the specified steps, not before or after the funnel.","category": "Query wrappers","feature": "insights","summary": "Run a funnel query",diff --git a/services/mcp/src/tools/generated/query-wrappers.ts b/services/mcp/src/tools/generated/query-wrappers.tsindex 65fb0aef1fd5..630c3e139921 100644--- a/services/mcp/src/tools/generated/query-wrappers.ts+++ b/services/mcp/src/tools/generated/query-wrappers.ts@@ -705,7 +705,23 @@ const AssistantFunnelsActionsNode = z.object({version: z.coerce.number().describe('version of the node, used for schema migrations').optional(),})-const AssistantFunnelsNode = z.union([AssistantFunnelsEventsNode, AssistantFunnelsActionsNode])+const AssistantFunnelsGroupNode = z.object({+ custom_name: z.string().optional(),+ kind: z.literal('GroupNode').default('GroupNode'),+ name: z.string().describe('Display name for the combined step.').optional(),+ nodes: z+ .array(z.union([AssistantFunnelsEventsNode, AssistantFunnelsActionsNode]))+ .describe(+ 'Events and actions combined into the step. Use per-node `properties` to filter each event; there is no step-wide filter on a grouped step.'+ ),+ operator: z.literal('OR').describe('Only `OR` is supported.').default('OR'),+})++const AssistantFunnelsNode = z.union([+ AssistantFunnelsEventsNode,+ AssistantFunnelsActionsNode,+ AssistantFunnelsGroupNode,+])const AssistantFunnelsQuery = z.object({aggregation_group_type_index: integerdiff --git a/services/mcp/tests/tools/query-wrappers.integration.test.ts b/services/mcp/tests/tools/query-wrappers.integration.test.tsindex 5c1998f67275..2a56d45d4388 100644--- a/services/mcp/tests/tools/query-wrappers.integration.test.ts+++ b/services/mcp/tests/tools/query-wrappers.integration.test.ts@@ -124,6 +124,40 @@ describe('Query Wrapper Integration Tests', { concurrent: false }, () => {expect(typeof result[POSTHOG_FORMATTED_RESULTS_OVERRIDE_KEY]).toBe('string')expect(result[POSTHOG_FORMATTED_RESULTS_OVERRIDE_KEY]).toContain('|')})++ it('should execute a funnel with a GroupNode step using per-node property filters', async () => {+ const tool = getToolByName(GENERATED_TOOLS, 'query-funnel')+ const result = (await tool.handler(context, {+ series: [+ { kind: 'EventsNode', event: '$pageview' },+ {+ kind: 'GroupNode',+ operator: 'OR',+ name: 'Pageview on Safari, Pageleave on Chrome',+ nodes: [+ {+ kind: 'EventsNode',+ event: '$pageview',+ name: 'Pageview',+ properties: [{ key: '$browser', operator: 'exact', type: 'event', value: ['Safari'] }],+ },+ {+ kind: 'EventsNode',+ event: '$pageleave',+ name: 'Pageleave',+ properties: [{ key: '$browser', operator: 'exact', type: 'event', value: ['Chrome'] }],+ },+ ],+ },+ ],+ dateRange: { date_from: '-7d' },+ })) as any++ expect(result).toHaveProperty('results')+ expect(result).toHaveProperty('_posthogUrl')+ expect(typeof result[POSTHOG_FORMATTED_RESULTS_OVERRIDE_KEY]).toBe('string')+ expect(result[POSTHOG_FORMATTED_RESULTS_OVERRIDE_KEY]).toContain('|')+ })})describe('query-retention', () => {diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/query-funnel.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/query-funnel.jsonindex 7b040b00c44f..60b416ac3b99 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/query-funnel.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/query-funnel.json@@ -1776,6 +1776,1314 @@},"required": ["id", "name"],"type": "object"+ },+ {+ "properties": {+ "custom_name": {+ "type": "string"+ },+ "kind": {+ "const": "GroupNode",+ "default": "GroupNode",+ "type": "string"+ },+ "name": {+ "description": "Display name for the combined step.",+ "type": "string"+ },+ "nodes": {+ "description": "Events and actions combined into the step. Use per-node `properties` to filter each event; there is no step-wide filter on a grouped step.",+ "items": {+ "anyOf": [+ {+ "properties": {+ "custom_name": {+ "description": "Optional custom name for the event if it is needed to be renamed.",+ "type": "string"+ },+ "event": {+ "description": "Name of the event.",+ "type": "string"+ },+ "kind": {+ "const": "EventsNode",+ "default": "EventsNode",+ "type": "string"+ },+ "math": {+ "description": "Optional math aggregation type for the series. Only specify this math type if the user wants one of these. `first_time_for_user` - counts the number of users who have completed the event for the first time ever. `first_time_for_user_with_filters` - counts the number of users who have completed the event with specified filters for the first time.",+ "enum": ["first_time_for_user", "first_time_for_user_with_filters"],+ "type": "string"+ },+ "optionalInFunnel": {+ "default": false,+ "description": "If true, this step can be skipped without breaking the funnel — conversion between the surrounding required steps still counts even if this step didn't happen. Set this when the user asks for a non-required, skippable, or optional step in the funnel. Do not set it on the first or last step (those must be required).",+ "type": "boolean"+ },+ "properties": {+ "items": {+ "anyOf": [+ {+ "anyOf": [+ {+ "properties": {+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "description": "`icontains` - case insensitive contains. `not_icontains` - case insensitive does not contain. `regex` - matches the regex pattern. `not_regex` - does not match the regex pattern.",+ "enum": [+ "exact",+ "is_not",+ "icontains",+ "not_icontains",+ "regex",+ "not_regex"+ ],+ "type": "string"+ },+ "type": {+ "enum": [+ "event",+ "person",+ "session",+ "feature"+ ],+ "type": "string"+ },+ "value": {+ "description": "Only use property values from the plan. If the operator is `regex` or `not_regex`, the value must be a valid ClickHouse regex pattern to match against. Otherwise, the value must be a substring that will be matched against the property value. Use the string values `true` or `false` for boolean properties.",+ "type": "string"+ }+ },+ "required": [+ "key",+ "operator",+ "type",+ "value"+ ],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "enum": ["exact", "gt", "lt"],+ "type": "string"+ },+ "type": {+ "enum": [+ "event",+ "person",+ "session",+ "feature"+ ],+ "type": "string"+ },+ "value": {+ "type": "number"+ }+ },+ "required": [+ "key",+ "operator",+ "type",+ "value"+ ],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "description": "`exact` - exact match of any of the values. `is_not` - does not match any of the values.",+ "enum": ["exact", "is_not"],+ "type": "string"+ },+ "type": {+ "enum": [+ "event",+ "person",+ "session",+ "feature"+ ],+ "type": "string"+ },+ "value": {+ "description": "Only use property values from the plan. Always use strings as values. If you have a number, convert it to a string first. If you have a boolean, convert it to a string \"true\" or \"false\".",+ "items": {+ "type": "string"+ },+ "type": "array"+ }+ },+ "required": [+ "key",+ "operator",+ "type",+ "value"+ ],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "enum": [+ "is_date_exact",+ "is_date_before",+ "is_date_after"+ ],+ "type": "string"+ },+ "type": {+ "enum": [+ "event",+ "person",+ "session",+ "feature"+ ],+ "type": "string"+ },+ "value": {+ "description": "Value must be a date in ISO 8601 format.",+ "type": "string"+ }+ },+ "required": [+ "key",+ "operator",+ "type",+ "value"+ ],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "description": "`is_set` - the property has any value. `is_not_set` - the property doesn't have a value or wasn't collected.",+ "enum": ["is_set", "is_not_set"],+ "type": "string"+ },+ "type": {+ "enum": [+ "event",+ "person",+ "session",+ "feature"+ ],+ "type": "string"+ }+ },+ "required": ["key", "operator", "type"],+ "type": "object"+ }+ ]+ },+ {+ "anyOf": [+ {+ "properties": {+ "group_type_index": {+ "description": "Index of the group type from the group mapping.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "description": "`icontains` - case insensitive contains. `not_icontains` - case insensitive does not contain. `regex` - matches the regex pattern. `not_regex` - does not match the regex pattern.",+ "enum": [+ "exact",+ "is_not",+ "icontains",+ "not_icontains",+ "regex",+ "not_regex"+ ],+ "type": "string"+ },+ "type": {+ "const": "group",+ "default": "group",+ "type": "string"+ },+ "value": {+ "description": "Only use property values from the plan. If the operator is `regex` or `not_regex`, the value must be a valid ClickHouse regex pattern to match against. Otherwise, the value must be a substring that will be matched against the property value. Use the string values `true` or `false` for boolean properties.",+ "type": "string"+ }+ },+ "required": [+ "group_type_index",+ "key",+ "operator",+ "value"+ ],+ "type": "object"+ },+ {+ "properties": {+ "group_type_index": {+ "description": "Index of the group type from the group mapping.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "enum": ["exact", "gt", "lt"],+ "type": "string"+ },+ "type": {+ "const": "group",+ "default": "group",+ "type": "string"+ },+ "value": {+ "type": "number"+ }+ },+ "required": [+ "group_type_index",+ "key",+ "operator",+ "value"+ ],+ "type": "object"+ },+ {+ "properties": {+ "group_type_index": {+ "description": "Index of the group type from the group mapping.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "description": "`exact` - exact match of any of the values. `is_not` - does not match any of the values.",+ "enum": ["exact", "is_not"],+ "type": "string"+ },+ "type": {+ "const": "group",+ "default": "group",+ "type": "string"+ },+ "value": {+ "description": "Only use property values from the plan. Always use strings as values. If you have a number, convert it to a string first. If you have a boolean, convert it to a string \"true\" or \"false\".",+ "items": {+ "type": "string"+ },+ "type": "array"+ }+ },+ "required": [+ "group_type_index",+ "key",+ "operator",+ "value"+ ],+ "type": "object"+ },+ {+ "properties": {+ "group_type_index": {+ "description": "Index of the group type from the group mapping.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "enum": [+ "is_date_exact",+ "is_date_before",+ "is_date_after"+ ],+ "type": "string"+ },+ "type": {+ "const": "group",+ "default": "group",+ "type": "string"+ },+ "value": {+ "description": "Value must be a date in ISO 8601 format.",+ "type": "string"+ }+ },+ "required": [+ "group_type_index",+ "key",+ "operator",+ "value"+ ],+ "type": "object"+ },+ {+ "properties": {+ "group_type_index": {+ "description": "Index of the group type from the group mapping.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "description": "`is_set` - the property has any value. `is_not_set` - the property doesn't have a value or wasn't collected.",+ "enum": ["is_set", "is_not_set"],+ "type": "string"+ },+ "type": {+ "const": "group",+ "default": "group",+ "type": "string"+ }+ },+ "required": [+ "group_type_index",+ "key",+ "operator"+ ],+ "type": "object"+ }+ ]+ },+ {+ "properties": {+ "key": {+ "const": "id",+ "default": "id",+ "type": "string"+ },+ "operator": {+ "const": "in",+ "default": "in",+ "type": "string"+ },+ "type": {+ "const": "cohort",+ "default": "cohort",+ "description": "Filter events by cohort membership. Use this to narrow down results to persons belonging to a specific cohort. Example: `{ type: \"cohort\", key: \"id\", value: 42, operator: \"in\" }`",+ "type": "string"+ },+ "value": {+ "description": "The cohort ID to filter by.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ }+ },+ "required": ["value"],+ "type": "object"+ },+ {+ "anyOf": [+ {+ "properties": {+ "key": {+ "description": "The element property to filter on. `tag_name` — HTML tag (e.g., `button`, `a`, `input`). `text` — visible text content of the element. `href` — the `href` attribute for links. `selector` — a CSS selector matching the element (e.g., `div.main > button.cta`).",+ "enum": [+ "tag_name",+ "text",+ "href",+ "selector"+ ],+ "type": "string"+ },+ "operator": {+ "description": "`icontains` - case insensitive contains. `not_icontains` - case insensitive does not contain. `regex` - matches the regex pattern. `not_regex` - does not match the regex pattern.",+ "enum": [+ "exact",+ "is_not",+ "icontains",+ "not_icontains",+ "regex",+ "not_regex"+ ],+ "type": "string"+ },+ "type": {+ "const": "element",+ "default": "element",+ "description": "Filter by autocaptured HTML element properties (`$autocapture`, `$rageclick`). Example: `{ type: \"element\", key: \"text\", value: \"Sign Up\", operator: \"exact\" }`",+ "type": "string"+ },+ "value": {+ "description": "Only use property values from the plan. If the operator is `regex` or `not_regex`, the value must be a valid ClickHouse regex pattern to match against. Otherwise, the value must be a substring that will be matched against the property value. Use the string values `true` or `false` for boolean properties.",+ "type": "string"+ }+ },+ "required": ["key", "operator", "value"],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "The element property to filter on. `tag_name` — HTML tag (e.g., `button`, `a`, `input`). `text` — visible text content of the element. `href` — the `href` attribute for links. `selector` — a CSS selector matching the element (e.g., `div.main > button.cta`).",+ "enum": [+ "tag_name",+ "text",+ "href",+ "selector"+ ],+ "type": "string"+ },+ "operator": {+ "enum": ["exact", "gt", "lt"],+ "type": "string"+ },+ "type": {+ "const": "element",+ "default": "element",+ "description": "Filter by autocaptured HTML element properties (`$autocapture`, `$rageclick`). Example: `{ type: \"element\", key: \"text\", value: \"Sign Up\", operator: \"exact\" }`",+ "type": "string"+ },+ "value": {+ "type": "number"+ }+ },+ "required": ["key", "operator", "value"],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "The element property to filter on. `tag_name` — HTML tag (e.g., `button`, `a`, `input`). `text` — visible text content of the element. `href` — the `href` attribute for links. `selector` — a CSS selector matching the element (e.g., `div.main > button.cta`).",+ "enum": [+ "tag_name",+ "text",+ "href",+ "selector"+ ],+ "type": "string"+ },+ "operator": {+ "description": "`exact` - exact match of any of the values. `is_not` - does not match any of the values.",+ "enum": ["exact", "is_not"],+ "type": "string"+ },+ "type": {+ "const": "element",+ "default": "element",+ "description": "Filter by autocaptured HTML element properties (`$autocapture`, `$rageclick`). Example: `{ type: \"element\", key: \"text\", value: \"Sign Up\", operator: \"exact\" }`",+ "type": "string"+ },+ "value": {+ "description": "Only use property values from the plan. Always use strings as values. If you have a number, convert it to a string first. If you have a boolean, convert it to a string \"true\" or \"false\".",+ "items": {+ "type": "string"+ },+ "type": "array"+ }+ },+ "required": ["key", "operator", "value"],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "The element property to filter on. `tag_name` — HTML tag (e.g., `button`, `a`, `input`). `text` — visible text content of the element. `href` — the `href` attribute for links. `selector` — a CSS selector matching the element (e.g., `div.main > button.cta`).",+ "enum": [+ "tag_name",+ "text",+ "href",+ "selector"+ ],+ "type": "string"+ },+ "operator": {+ "enum": [+ "is_date_exact",+ "is_date_before",+ "is_date_after"+ ],+ "type": "string"+ },+ "type": {+ "const": "element",+ "default": "element",+ "description": "Filter by autocaptured HTML element properties (`$autocapture`, `$rageclick`). Example: `{ type: \"element\", key: \"text\", value: \"Sign Up\", operator: \"exact\" }`",+ "type": "string"+ },+ "value": {+ "description": "Value must be a date in ISO 8601 format.",+ "type": "string"+ }+ },+ "required": ["key", "operator", "value"],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "The element property to filter on. `tag_name` — HTML tag (e.g., `button`, `a`, `input`). `text` — visible text content of the element. `href` — the `href` attribute for links. `selector` — a CSS selector matching the element (e.g., `div.main > button.cta`).",+ "enum": [+ "tag_name",+ "text",+ "href",+ "selector"+ ],+ "type": "string"+ },+ "operator": {+ "description": "`is_set` - the property has any value. `is_not_set` - the property doesn't have a value or wasn't collected.",+ "enum": ["is_set", "is_not_set"],+ "type": "string"+ },+ "type": {+ "const": "element",+ "default": "element",+ "description": "Filter by autocaptured HTML element properties (`$autocapture`, `$rageclick`). Example: `{ type: \"element\", key: \"text\", value: \"Sign Up\", operator: \"exact\" }`",+ "type": "string"+ }+ },+ "required": ["key", "operator"],+ "type": "object"+ }+ ]+ },+ {+ "properties": {+ "key": {+ "description": "A HogQL boolean expression used as a filter condition.\n\nExamples:\n- Filter where a property exceeds a threshold: `toFloat(properties.load_time) > 5.0`\n- Filter with string matching: `properties.$current_url LIKE '%/pricing%'`\n- Filter with multiple conditions: `properties.$browser = 'Chrome' AND toFloat(properties.duration) > 30`",+ "type": "string"+ },+ "type": {+ "const": "hogql",+ "default": "hogql",+ "description": "Filter by a HogQL boolean expression for advanced filtering that can't be expressed with standard property filters.",+ "type": "string"+ }+ },+ "required": ["key"],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "The feature flag key.",+ "type": "string"+ },+ "operator": {+ "const": "flag_evaluates_to",+ "default": "flag_evaluates_to",+ "type": "string"+ },+ "type": {+ "const": "flag",+ "default": "flag",+ "description": "Filter events by feature flag state — only include events where a specific flag evaluated to a given value. Examples:\n- Flag enabled: `{ type: \"flag\", key: \"new-onboarding\", operator: \"flag_evaluates_to\", value: true }`\n- Specific variant: `{ type: \"flag\", key: \"checkout-experiment\", operator: \"flag_evaluates_to\", value: \"variant-a\" }`",+ "type": "string"+ },+ "value": {+ "anyOf": [+ {+ "type": "boolean"+ },+ {+ "type": "string"+ }+ ],+ "description": "`true`/`false` for boolean flags, or a variant name string for multivariate flags."+ }+ },+ "required": ["key", "value"],+ "type": "object"+ }+ ]+ },+ "type": "array"+ },+ "version": {+ "description": "version of the node, used for schema migrations",+ "type": "number"+ }+ },+ "required": ["event"],+ "type": "object"+ },+ {+ "properties": {+ "id": {+ "description": "Action ID from the plan.",+ "type": "number"+ },+ "kind": {+ "const": "ActionsNode",+ "default": "ActionsNode",+ "type": "string"+ },+ "math": {+ "description": "Optional math aggregation type for the series. Only specify this math type if the user wants one of these. `first_time_for_user` - counts the number of users who have completed the event for the first time ever. `first_time_for_user_with_filters` - counts the number of users who have completed the event with specified filters for the first time.",+ "enum": ["first_time_for_user", "first_time_for_user_with_filters"],+ "type": "string"+ },+ "name": {+ "description": "Action name from the plan.",+ "type": "string"+ },+ "optionalInFunnel": {+ "default": false,+ "description": "If true, this step can be skipped without breaking the funnel — conversion between the surrounding required steps still counts even if this step didn't happen. Set this when the user asks for a non-required, skippable, or optional step in the funnel. Do not set it on the first or last step (those must be required).",+ "type": "boolean"+ },+ "properties": {+ "items": {+ "anyOf": [+ {+ "anyOf": [+ {+ "properties": {+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "description": "`icontains` - case insensitive contains. `not_icontains` - case insensitive does not contain. `regex` - matches the regex pattern. `not_regex` - does not match the regex pattern.",+ "enum": [+ "exact",+ "is_not",+ "icontains",+ "not_icontains",+ "regex",+ "not_regex"+ ],+ "type": "string"+ },+ "type": {+ "enum": [+ "event",+ "person",+ "session",+ "feature"+ ],+ "type": "string"+ },+ "value": {+ "description": "Only use property values from the plan. If the operator is `regex` or `not_regex`, the value must be a valid ClickHouse regex pattern to match against. Otherwise, the value must be a substring that will be matched against the property value. Use the string values `true` or `false` for boolean properties.",+ "type": "string"+ }+ },+ "required": [+ "key",+ "operator",+ "type",+ "value"+ ],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "enum": ["exact", "gt", "lt"],+ "type": "string"+ },+ "type": {+ "enum": [+ "event",+ "person",+ "session",+ "feature"+ ],+ "type": "string"+ },+ "value": {+ "type": "number"+ }+ },+ "required": [+ "key",+ "operator",+ "type",+ "value"+ ],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "description": "`exact` - exact match of any of the values. `is_not` - does not match any of the values.",+ "enum": ["exact", "is_not"],+ "type": "string"+ },+ "type": {+ "enum": [+ "event",+ "person",+ "session",+ "feature"+ ],+ "type": "string"+ },+ "value": {+ "description": "Only use property values from the plan. Always use strings as values. If you have a number, convert it to a string first. If you have a boolean, convert it to a string \"true\" or \"false\".",+ "items": {+ "type": "string"+ },+ "type": "array"+ }+ },+ "required": [+ "key",+ "operator",+ "type",+ "value"+ ],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "enum": [+ "is_date_exact",+ "is_date_before",+ "is_date_after"+ ],+ "type": "string"+ },+ "type": {+ "enum": [+ "event",+ "person",+ "session",+ "feature"+ ],+ "type": "string"+ },+ "value": {+ "description": "Value must be a date in ISO 8601 format.",+ "type": "string"+ }+ },+ "required": [+ "key",+ "operator",+ "type",+ "value"+ ],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "description": "`is_set` - the property has any value. `is_not_set` - the property doesn't have a value or wasn't collected.",+ "enum": ["is_set", "is_not_set"],+ "type": "string"+ },+ "type": {+ "enum": [+ "event",+ "person",+ "session",+ "feature"+ ],+ "type": "string"+ }+ },+ "required": ["key", "operator", "type"],+ "type": "object"+ }+ ]+ },+ {+ "anyOf": [+ {+ "properties": {+ "group_type_index": {+ "description": "Index of the group type from the group mapping.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "description": "`icontains` - case insensitive contains. `not_icontains` - case insensitive does not contain. `regex` - matches the regex pattern. `not_regex` - does not match the regex pattern.",+ "enum": [+ "exact",+ "is_not",+ "icontains",+ "not_icontains",+ "regex",+ "not_regex"+ ],+ "type": "string"+ },+ "type": {+ "const": "group",+ "default": "group",+ "type": "string"+ },+ "value": {+ "description": "Only use property values from the plan. If the operator is `regex` or `not_regex`, the value must be a valid ClickHouse regex pattern to match against. Otherwise, the value must be a substring that will be matched against the property value. Use the string values `true` or `false` for boolean properties.",+ "type": "string"+ }+ },+ "required": [+ "group_type_index",+ "key",+ "operator",+ "value"+ ],+ "type": "object"+ },+ {+ "properties": {+ "group_type_index": {+ "description": "Index of the group type from the group mapping.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "enum": ["exact", "gt", "lt"],+ "type": "string"+ },+ "type": {+ "const": "group",+ "default": "group",+ "type": "string"+ },+ "value": {+ "type": "number"+ }+ },+ "required": [+ "group_type_index",+ "key",+ "operator",+ "value"+ ],+ "type": "object"+ },+ {+ "properties": {+ "group_type_index": {+ "description": "Index of the group type from the group mapping.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "description": "`exact` - exact match of any of the values. `is_not` - does not match any of the values.",+ "enum": ["exact", "is_not"],+ "type": "string"+ },+ "type": {+ "const": "group",+ "default": "group",+ "type": "string"+ },+ "value": {+ "description": "Only use property values from the plan. Always use strings as values. If you have a number, convert it to a string first. If you have a boolean, convert it to a string \"true\" or \"false\".",+ "items": {+ "type": "string"+ },+ "type": "array"+ }+ },+ "required": [+ "group_type_index",+ "key",+ "operator",+ "value"+ ],+ "type": "object"+ },+ {+ "properties": {+ "group_type_index": {+ "description": "Index of the group type from the group mapping.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "enum": [+ "is_date_exact",+ "is_date_before",+ "is_date_after"+ ],+ "type": "string"+ },+ "type": {+ "const": "group",+ "default": "group",+ "type": "string"+ },+ "value": {+ "description": "Value must be a date in ISO 8601 format.",+ "type": "string"+ }+ },+ "required": [+ "group_type_index",+ "key",+ "operator",+ "value"+ ],+ "type": "object"+ },+ {+ "properties": {+ "group_type_index": {+ "description": "Index of the group type from the group mapping.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ },+ "key": {+ "description": "Use one of the properties the user has provided in the plan.",+ "type": "string"+ },+ "operator": {+ "description": "`is_set` - the property has any value. `is_not_set` - the property doesn't have a value or wasn't collected.",+ "enum": ["is_set", "is_not_set"],+ "type": "string"+ },+ "type": {+ "const": "group",+ "default": "group",+ "type": "string"+ }+ },+ "required": [+ "group_type_index",+ "key",+ "operator"+ ],+ "type": "object"+ }+ ]+ },+ {+ "properties": {+ "key": {+ "const": "id",+ "default": "id",+ "type": "string"+ },+ "operator": {+ "const": "in",+ "default": "in",+ "type": "string"+ },+ "type": {+ "const": "cohort",+ "default": "cohort",+ "description": "Filter events by cohort membership. Use this to narrow down results to persons belonging to a specific cohort. Example: `{ type: \"cohort\", key: \"id\", value: 42, operator: \"in\" }`",+ "type": "string"+ },+ "value": {+ "description": "The cohort ID to filter by.",+ "maximum": 9007199254740991,+ "minimum": -9007199254740991,+ "type": "integer"+ }+ },+ "required": ["value"],+ "type": "object"+ },+ {+ "anyOf": [+ {+ "properties": {+ "key": {+ "description": "The element property to filter on. `tag_name` — HTML tag (e.g., `button`, `a`, `input`). `text` — visible text content of the element. `href` — the `href` attribute for links. `selector` — a CSS selector matching the element (e.g., `div.main > button.cta`).",+ "enum": [+ "tag_name",+ "text",+ "href",+ "selector"+ ],+ "type": "string"+ },+ "operator": {+ "description": "`icontains` - case insensitive contains. `not_icontains` - case insensitive does not contain. `regex` - matches the regex pattern. `not_regex` - does not match the regex pattern.",+ "enum": [+ "exact",+ "is_not",+ "icontains",+ "not_icontains",+ "regex",+ "not_regex"+ ],+ "type": "string"+ },+ "type": {+ "const": "element",+ "default": "element",+ "description": "Filter by autocaptured HTML element properties (`$autocapture`, `$rageclick`). Example: `{ type: \"element\", key: \"text\", value: \"Sign Up\", operator: \"exact\" }`",+ "type": "string"+ },+ "value": {+ "description": "Only use property values from the plan. If the operator is `regex` or `not_regex`, the value must be a valid ClickHouse regex pattern to match against. Otherwise, the value must be a substring that will be matched against the property value. Use the string values `true` or `false` for boolean properties.",+ "type": "string"+ }+ },+ "required": ["key", "operator", "value"],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "The element property to filter on. `tag_name` — HTML tag (e.g., `button`, `a`, `input`). `text` — visible text content of the element. `href` — the `href` attribute for links. `selector` — a CSS selector matching the element (e.g., `div.main > button.cta`).",+ "enum": [+ "tag_name",+ "text",+ "href",+ "selector"+ ],+ "type": "string"+ },+ "operator": {+ "enum": ["exact", "gt", "lt"],+ "type": "string"+ },+ "type": {+ "const": "element",+ "default": "element",+ "description": "Filter by autocaptured HTML element properties (`$autocapture`, `$rageclick`). Example: `{ type: \"element\", key: \"text\", value: \"Sign Up\", operator: \"exact\" }`",+ "type": "string"+ },+ "value": {+ "type": "number"+ }+ },+ "required": ["key", "operator", "value"],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "The element property to filter on. `tag_name` — HTML tag (e.g., `button`, `a`, `input`). `text` — visible text content of the element. `href` — the `href` attribute for links. `selector` — a CSS selector matching the element (e.g., `div.main > button.cta`).",+ "enum": [+ "tag_name",+ "text",+ "href",+ "selector"+ ],+ "type": "string"+ },+ "operator": {+ "description": "`exact` - exact match of any of the values. `is_not` - does not match any of the values.",+ "enum": ["exact", "is_not"],+ "type": "string"+ },+ "type": {+ "const": "element",+ "default": "element",+ "description": "Filter by autocaptured HTML element properties (`$autocapture`, `$rageclick`). Example: `{ type: \"element\", key: \"text\", value: \"Sign Up\", operator: \"exact\" }`",+ "type": "string"+ },+ "value": {+ "description": "Only use property values from the plan. Always use strings as values. If you have a number, convert it to a string first. If you have a boolean, convert it to a string \"true\" or \"false\".",+ "items": {+ "type": "string"+ },+ "type": "array"+ }+ },+ "required": ["key", "operator", "value"],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "The element property to filter on. `tag_name` — HTML tag (e.g., `button`, `a`, `input`). `text` — visible text content of the element. `href` — the `href` attribute for links. `selector` — a CSS selector matching the element (e.g., `div.main > button.cta`).",+ "enum": [+ "tag_name",+ "text",+ "href",+ "selector"+ ],+ "type": "string"+ },+ "operator": {+ "enum": [+ "is_date_exact",+ "is_date_before",+ "is_date_after"+ ],+ "type": "string"+ },+ "type": {+ "const": "element",+ "default": "element",+ "description": "Filter by autocaptured HTML element properties (`$autocapture`, `$rageclick`). Example: `{ type: \"element\", key: \"text\", value: \"Sign Up\", operator: \"exact\" }`",+ "type": "string"+ },+ "value": {+ "description": "Value must be a date in ISO 8601 format.",+ "type": "string"+ }+ },+ "required": ["key", "operator", "value"],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "The element property to filter on. `tag_name` — HTML tag (e.g., `button`, `a`, `input`). `text` — visible text content of the element. `href` — the `href` attribute for links. `selector` — a CSS selector matching the element (e.g., `div.main > button.cta`).",+ "enum": [+ "tag_name",+ "text",+ "href",+ "selector"+ ],+ "type": "string"+ },+ "operator": {+ "description": "`is_set` - the property has any value. `is_not_set` - the property doesn't have a value or wasn't collected.",+ "enum": ["is_set", "is_not_set"],+ "type": "string"+ },+ "type": {+ "const": "element",+ "default": "element",+ "description": "Filter by autocaptured HTML element properties (`$autocapture`, `$rageclick`). Example: `{ type: \"element\", key: \"text\", value: \"Sign Up\", operator: \"exact\" }`",+ "type": "string"+ }+ },+ "required": ["key", "operator"],+ "type": "object"+ }+ ]+ },+ {+ "properties": {+ "key": {+ "description": "A HogQL boolean expression used as a filter condition.\n\nExamples:\n- Filter where a property exceeds a threshold: `toFloat(properties.load_time) > 5.0`\n- Filter with string matching: `properties.$current_url LIKE '%/pricing%'`\n- Filter with multiple conditions: `properties.$browser = 'Chrome' AND toFloat(properties.duration) > 30`",+ "type": "string"+ },+ "type": {+ "const": "hogql",+ "default": "hogql",+ "description": "Filter by a HogQL boolean expression for advanced filtering that can't be expressed with standard property filters.",+ "type": "string"+ }+ },+ "required": ["key"],+ "type": "object"+ },+ {+ "properties": {+ "key": {+ "description": "The feature flag key.",+ "type": "string"+ },+ "operator": {+ "const": "flag_evaluates_to",+ "default": "flag_evaluates_to",+ "type": "string"+ },+ "type": {+ "const": "flag",+ "default": "flag",+ "description": "Filter events by feature flag state — only include events where a specific flag evaluated to a given value. Examples:\n- Flag enabled: `{ type: \"flag\", key: \"new-onboarding\", operator: \"flag_evaluates_to\", value: true }`\n- Specific variant: `{ type: \"flag\", key: \"checkout-experiment\", operator: \"flag_evaluates_to\", value: \"variant-a\" }`",+ "type": "string"+ },+ "value": {+ "anyOf": [+ {+ "type": "boolean"+ },+ {+ "type": "string"+ }+ ],+ "description": "`true`/`false` for boolean flags, or a variant name string for multivariate flags."+ }+ },+ "required": ["key", "value"],+ "type": "object"+ }+ ]+ },+ "type": "array"+ },+ "version": {+ "description": "version of the node, used for schema migrations",+ "type": "number"+ }+ },+ "required": ["id", "name"],+ "type": "object"+ }+ ]+ },+ "type": "array"+ },+ "operator": {+ "const": "OR",+ "default": "OR",+ "description": "Only `OR` is supported.",+ "type": "string"+ }+ },+ "required": ["nodes"],+ "type": "object"}]},