: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): expose Metric display color params in trends query schema (#64681)
Sam Penningtond963db1d81e5
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex fa03805704cf..3704407d78ce 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -4301,7 +4301,7 @@},"display": {"default": "ActionsLineGraph",- "description": "Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time. `ActionsBar` - time-series bar chart. `ActionsAreaGraph` - time-series area chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics. `BoldNumber` - total value single large number. Use when user explicitly asks for a single output number. You CANNOT use this with breakdown or if the insight has more than one series. `ActionsBarValue` - total value (NOT time-series) bar chart; good for categorical data. `ActionsPie` - total value pie chart; good for visualizing proportions. `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap` - total value world map; use when breaking down by country name using property `$geoip_country_name`, and only then.",+ "description": "Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time. `ActionsBar` - time-series bar chart. `ActionsAreaGraph` - time-series area chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics. `BoldNumber` - total value single large number. Use when user explicitly asks for a single output number. You CANNOT use this with breakdown or if the insight has more than one series. `Metric` - single large number with a period-over-period change pill and a sparkline. Like `BoldNumber` but trend-aware; configure it with the `metric*` fields below. Single series, no breakdown. `ActionsBarValue` - total value (NOT time-series) bar chart; good for categorical data. `ActionsPie` - total value pie chart; good for visualizing proportions. `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap` - total value world map; use when breaking down by country name using property `$geoip_country_name`, and only then.","enum": ["Auto","ActionsLineGraph",@@ -4329,6 +4329,32 @@},"type": "array"},+ "metricChangeDecreaseColor": {+ "description": "Only applies when `display` is `Metric`. Hex color (e.g. `#db3707`) for the change pill when the metric went DOWN. Defaults to red (`#db3707`). For a \"lower is better\" metric (latency, error rate, cost), set this to a green (e.g. `#388600`) so a decrease reads as good.",+ "type": "string"+ },+ "metricChangeIncreaseColor": {+ "description": "Only applies when `display` is `Metric`. Hex color (e.g. `#388600`) for the change pill when the metric went UP. Defaults to green (`#388600`). For a \"lower is better\" metric (latency, error rate, cost), set this to a red (e.g. `#db3707`) so an increase reads as bad.",+ "type": "string"+ },+ "metricColorByDirection": {+ "default": false,+ "description": "Only applies when `display` is `Metric`. Color the sparkline under the big number by whether the metric increased or decreased over the period (using the increase/decrease line colors).",+ "type": "boolean"+ },+ "metricLineDecreaseColor": {+ "description": "Only applies when `display` is `Metric` and `metricColorByDirection` is `true`. Hex color for the sparkline when the metric went DOWN. Defaults to red (`#db3707`). Flip to a green for a \"lower is better\" metric.",+ "type": "string"+ },+ "metricLineIncreaseColor": {+ "description": "Only applies when `display` is `Metric` and `metricColorByDirection` is `true`. Hex color for the sparkline when the metric went UP. Defaults to green (`#388600`). Flip to a red for a \"lower is better\" metric.",+ "type": "string"+ },+ "metricShowChange": {+ "default": true,+ "description": "Only applies when `display` is `Metric`. Show the change pill next to the big number — the percentage change from the first to the last point of the series over the selected date range.",+ "type": "boolean"+ },"showAlertThresholdLines": {"default": false,"description": "Whether to show alert threshold lines on the chart.",diff --git a/frontend/src/queries/schema/schema-assistant-queries.ts b/frontend/src/queries/schema/schema-assistant-queries.tsindex e9ea4c490afb..88be3ecca5c5 100644--- a/frontend/src/queries/schema/schema-assistant-queries.ts+++ b/frontend/src/queries/schema/schema-assistant-queries.ts@@ -476,6 +476,7 @@ export interface AssistantTrendsFilter {* `ActionsAreaGraph` - time-series area chart.* `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics.* `BoldNumber` - total value single large number. Use when user explicitly asks for a single output number. You CANNOT use this with breakdown or if the insight has more than one series.+ * `Metric` - single large number with a period-over-period change pill and a sparkline. Like `BoldNumber` but trend-aware; configure it with the `metric*` fields below. Single series, no breakdown.* `ActionsBarValue` - total value (NOT time-series) bar chart; good for categorical data.* `ActionsPie` - total value pie chart; good for visualizing proportions.* `ActionsTable` - total value table; good when using breakdown to list users or other entities.@@ -559,6 +560,48 @@ export interface AssistantTrendsFilter {* @default false*/showMultipleYAxes?: TrendsFilterLegacy['show_multiple_y_axes']++ /**+ * Only applies when `display` is `Metric`. Show the change pill next to the big number — the+ * percentage change from the first to the last point of the series over the selected date range.+ * @default true+ */+ metricShowChange?: boolean++ /**+ * Only applies when `display` is `Metric`. Hex color (e.g. `#388600`) for the change pill when+ * the metric went UP. Defaults to green (`#388600`). For a "lower is better" metric (latency,+ * error rate, cost), set this to a red (e.g. `#db3707`) so an increase reads as bad.+ */+ metricChangeIncreaseColor?: string++ /**+ * Only applies when `display` is `Metric`. Hex color (e.g. `#db3707`) for the change pill when+ * the metric went DOWN. Defaults to red (`#db3707`). For a "lower is better" metric (latency,+ * error rate, cost), set this to a green (e.g. `#388600`) so a decrease reads as good.+ */+ metricChangeDecreaseColor?: string++ /**+ * Only applies when `display` is `Metric`. Color the sparkline under the big number by whether+ * the metric increased or decreased over the period (using the increase/decrease line colors).+ * @default false+ */+ metricColorByDirection?: boolean++ /**+ * Only applies when `display` is `Metric` and `metricColorByDirection` is `true`. Hex color for+ * the sparkline when the metric went UP. Defaults to green (`#388600`). Flip to a red for a+ * "lower is better" metric.+ */+ metricLineIncreaseColor?: string++ /**+ * Only applies when `display` is `Metric` and `metricColorByDirection` is `true`. Hex color for+ * the sparkline when the metric went DOWN. Defaults to red (`#db3707`). Flip to a green for a+ * "lower is better" metric.+ */+ metricLineDecreaseColor?: string}export interface AssistantTrendsQuery extends AssistantInsightsQueryBase {diff --git a/posthog/schema.py b/posthog/schema.pyindex 83efa13dda03..957885e3ddc2 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -4215,8 +4215,11 @@ class AssistantTrendsFilter(BaseModel):" chart; good for cumulative metrics. `BoldNumber` - total value single"" large number. Use when user explicitly asks for a single output number."" You CANNOT use this with breakdown or if the insight has more than one"- " series. `ActionsBarValue` - total value (NOT time-series) bar chart; good"- " for categorical data. `ActionsPie` - total value pie chart; good for"+ " series. `Metric` - single large number with a period-over-period change"+ " pill and a sparkline. Like `BoldNumber` but trend-aware; configure it"+ " with the `metric*` fields below. Single series, no breakdown."+ " `ActionsBarValue` - total value (NOT time-series) bar chart; good for"+ " categorical data. `ActionsPie` - total value pie chart; good for"" visualizing proportions. `ActionsTable` - total value table; good when"" using breakdown to list users or other entities. `WorldMap` - total value"" world map; use when breaking down by country name using property"@@ -4241,6 +4244,56 @@ class AssistantTrendsFilter(BaseModel):" complete` (unique users) and `B` is `$identify` (unique users)."),)+ metricChangeDecreaseColor: str | None = Field(+ default=None,+ description=(+ "Only applies when `display` is `Metric`. Hex color (e.g. `#db3707`) for"+ " the change pill when the metric went DOWN. Defaults to red (`#db3707`)."+ ' For a "lower is better" metric (latency, error rate, cost), set this to a'+ " green (e.g. `#388600`) so a decrease reads as good."+ ),+ )+ metricChangeIncreaseColor: str | None = Field(+ default=None,+ description=(+ "Only applies when `display` is `Metric`. Hex color (e.g. `#388600`) for"+ " the change pill when the metric went UP. Defaults to green (`#388600`)."+ ' For a "lower is better" metric (latency, error rate, cost), set this to a'+ " red (e.g. `#db3707`) so an increase reads as bad."+ ),+ )+ metricColorByDirection: bool | None = Field(+ default=False,+ description=(+ "Only applies when `display` is `Metric`. Color the sparkline under the big"+ " number by whether the metric increased or decreased over the period"+ " (using the increase/decrease line colors)."+ ),+ )+ metricLineDecreaseColor: str | None = Field(+ default=None,+ description=(+ "Only applies when `display` is `Metric` and `metricColorByDirection` is"+ " `true`. Hex color for the sparkline when the metric went DOWN. Defaults"+ ' to red (`#db3707`). Flip to a green for a "lower is better" metric.'+ ),+ )+ metricLineIncreaseColor: str | None = Field(+ default=None,+ description=(+ "Only applies when `display` is `Metric` and `metricColorByDirection` is"+ " `true`. Hex color for the sparkline when the metric went UP. Defaults to"+ ' green (`#388600`). Flip to a red for a "lower is better" metric.'+ ),+ )+ metricShowChange: bool | None = Field(+ default=True,+ description=(+ "Only applies when `display` is `Metric`. Show the change pill next to the"+ " big number — the percentage change from the first to the last point of"+ " the series over the selected date range."+ ),+ )showAlertThresholdLines: bool | None = Field(default=False, description="Whether to show alert threshold lines on the chart.")diff --git a/services/mcp/src/tools/generated/query-wrappers.ts b/services/mcp/src/tools/generated/query-wrappers.tsindex 4acf4e34fdfc..03449d4c31fa 100644--- a/services/mcp/src/tools/generated/query-wrappers.ts+++ b/services/mcp/src/tools/generated/query-wrappers.ts@@ -513,7 +513,7 @@ const AssistantTrendsFilter = z.object({'SlopeGraph',]).describe(- 'Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time. `ActionsBar` - time-series bar chart. `ActionsAreaGraph` - time-series area chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics. `BoldNumber` - total value single large number. Use when user explicitly asks for a single output number. You CANNOT use this with breakdown or if the insight has more than one series. `ActionsBarValue` - total value (NOT time-series) bar chart; good for categorical data. `ActionsPie` - total value pie chart; good for visualizing proportions. `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap` - total value world map; use when breaking down by country name using property `$geoip_country_name`, and only then.'+ 'Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time. `ActionsBar` - time-series bar chart. `ActionsAreaGraph` - time-series area chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics. `BoldNumber` - total value single large number. Use when user explicitly asks for a single output number. You CANNOT use this with breakdown or if the insight has more than one series. `Metric` - single large number with a period-over-period change pill and a sparkline. Like `BoldNumber` but trend-aware; configure it with the `metric*` fields below. Single series, no breakdown. `ActionsBarValue` - total value (NOT time-series) bar chart; good for categorical data. `ActionsPie` - total value pie chart; good for visualizing proportions. `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap` - total value world map; use when breaking down by country name using property `$geoip_country_name`, and only then.').default('ActionsLineGraph').optional(),@@ -523,6 +523,44 @@ const AssistantTrendsFilter = z.object({'Use custom formulas to perform mathematical operations like calculating percentages or metrics. Use the following syntax: `A/B`, where `A` and `B` are the names of the series. You can combine math aggregations and formulas. When using a formula, you must:\n- Identify and specify **all** events and actions needed to solve the formula.\n- Carefully review the list of available events and actions to find appropriate entities for each part of the formula.\n- Ensure that you find events and actions corresponding to both the numerator and denominator in ratio calculations. Examples of using math formulas:\n- If you want to calculate the percentage of users who have completed onboarding, you need to find and use events or actions similar to `$identify` and `onboarding complete`, so the formula will be `A / B`, where `A` is `onboarding complete` (unique users) and `B` is `$identify` (unique users).').optional(),+ metricChangeDecreaseColor: z+ .string()+ .describe(+ 'Only applies when `display` is `Metric`. Hex color (e.g. `#db3707`) for the change pill when the metric went DOWN. Defaults to red (`#db3707`). For a "lower is better" metric (latency, error rate, cost), set this to a green (e.g. `#388600`) so a decrease reads as good.'+ )+ .optional(),+ metricChangeIncreaseColor: z+ .string()+ .describe(+ 'Only applies when `display` is `Metric`. Hex color (e.g. `#388600`) for the change pill when the metric went UP. Defaults to green (`#388600`). For a "lower is better" metric (latency, error rate, cost), set this to a red (e.g. `#db3707`) so an increase reads as bad.'+ )+ .optional(),+ metricColorByDirection: z.coerce+ .boolean()+ .describe(+ 'Only applies when `display` is `Metric`. Color the sparkline under the big number by whether the metric increased or decreased over the period (using the increase/decrease line colors).'+ )+ .default(false)+ .optional(),+ metricLineDecreaseColor: z+ .string()+ .describe(+ 'Only applies when `display` is `Metric` and `metricColorByDirection` is `true`. Hex color for the sparkline when the metric went DOWN. Defaults to red (`#db3707`). Flip to a green for a "lower is better" metric.'+ )+ .optional(),+ metricLineIncreaseColor: z+ .string()+ .describe(+ 'Only applies when `display` is `Metric` and `metricColorByDirection` is `true`. Hex color for the sparkline when the metric went UP. Defaults to green (`#388600`). Flip to a red for a "lower is better" metric.'+ )+ .optional(),+ metricShowChange: z.coerce+ .boolean()+ .describe(+ 'Only applies when `display` is `Metric`. Show the change pill next to the big number — the percentage change from the first to the last point of the series over the selected date range.'+ )+ .default(true)+ .optional(),showAlertThresholdLines: z.coerce.boolean().describe('Whether to show alert threshold lines on the chart.')diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends-actors.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends-actors.jsonindex 482418c74750..f3327f8199df 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends-actors.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends-actors.json@@ -3795,7 +3795,7 @@},"display": {"default": "ActionsLineGraph",- "description": "Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time. `ActionsBar` - time-series bar chart. `ActionsAreaGraph` - time-series area chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics. `BoldNumber` - total value single large number. Use when user explicitly asks for a single output number. You CANNOT use this with breakdown or if the insight has more than one series. `ActionsBarValue` - total value (NOT time-series) bar chart; good for categorical data. `ActionsPie` - total value pie chart; good for visualizing proportions. `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap` - total value world map; use when breaking down by country name using property `$geoip_country_name`, and only then.",+ "description": "Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time. `ActionsBar` - time-series bar chart. `ActionsAreaGraph` - time-series area chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics. `BoldNumber` - total value single large number. Use when user explicitly asks for a single output number. You CANNOT use this with breakdown or if the insight has more than one series. `Metric` - single large number with a period-over-period change pill and a sparkline. Like `BoldNumber` but trend-aware; configure it with the `metric*` fields below. Single series, no breakdown. `ActionsBarValue` - total value (NOT time-series) bar chart; good for categorical data. `ActionsPie` - total value pie chart; good for visualizing proportions. `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap` - total value world map; use when breaking down by country name using property `$geoip_country_name`, and only then.","enum": ["Auto","ActionsLineGraph",@@ -3833,6 +3833,32 @@},"type": "array"},+ "metricChangeDecreaseColor": {+ "description": "Only applies when `display` is `Metric`. Hex color (e.g. `#db3707`) for the change pill when the metric went DOWN. Defaults to red (`#db3707`). For a \"lower is better\" metric (latency, error rate, cost), set this to a green (e.g. `#388600`) so a decrease reads as good.",+ "type": "string"+ },+ "metricChangeIncreaseColor": {+ "description": "Only applies when `display` is `Metric`. Hex color (e.g. `#388600`) for the change pill when the metric went UP. Defaults to green (`#388600`). For a \"lower is better\" metric (latency, error rate, cost), set this to a red (e.g. `#db3707`) so an increase reads as bad.",+ "type": "string"+ },+ "metricColorByDirection": {+ "default": false,+ "description": "Only applies when `display` is `Metric`. Color the sparkline under the big number by whether the metric increased or decreased over the period (using the increase/decrease line colors).",+ "type": "boolean"+ },+ "metricLineDecreaseColor": {+ "description": "Only applies when `display` is `Metric` and `metricColorByDirection` is `true`. Hex color for the sparkline when the metric went DOWN. Defaults to red (`#db3707`). Flip to a green for a \"lower is better\" metric.",+ "type": "string"+ },+ "metricLineIncreaseColor": {+ "description": "Only applies when `display` is `Metric` and `metricColorByDirection` is `true`. Hex color for the sparkline when the metric went UP. Defaults to green (`#388600`). Flip to a red for a \"lower is better\" metric.",+ "type": "string"+ },+ "metricShowChange": {+ "default": true,+ "description": "Only applies when `display` is `Metric`. Show the change pill next to the big number — the percentage change from the first to the last point of the series over the selected date range.",+ "type": "boolean"+ },"showAlertThresholdLines": {"default": false,"description": "Whether to show alert threshold lines on the chart.",diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.jsonindex b94a15ef3eaa..8ddcc486228f 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.json@@ -3607,7 +3607,7 @@},"display": {"default": "ActionsLineGraph",- "description": "Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time. `ActionsBar` - time-series bar chart. `ActionsAreaGraph` - time-series area chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics. `BoldNumber` - total value single large number. Use when user explicitly asks for a single output number. You CANNOT use this with breakdown or if the insight has more than one series. `ActionsBarValue` - total value (NOT time-series) bar chart; good for categorical data. `ActionsPie` - total value pie chart; good for visualizing proportions. `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap` - total value world map; use when breaking down by country name using property `$geoip_country_name`, and only then.",+ "description": "Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time. `ActionsBar` - time-series bar chart. `ActionsAreaGraph` - time-series area chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics. `BoldNumber` - total value single large number. Use when user explicitly asks for a single output number. You CANNOT use this with breakdown or if the insight has more than one series. `Metric` - single large number with a period-over-period change pill and a sparkline. Like `BoldNumber` but trend-aware; configure it with the `metric*` fields below. Single series, no breakdown. `ActionsBarValue` - total value (NOT time-series) bar chart; good for categorical data. `ActionsPie` - total value pie chart; good for visualizing proportions. `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap` - total value world map; use when breaking down by country name using property `$geoip_country_name`, and only then.","enum": ["Auto","ActionsLineGraph",@@ -3645,6 +3645,32 @@},"type": "array"},+ "metricChangeDecreaseColor": {+ "description": "Only applies when `display` is `Metric`. Hex color (e.g. `#db3707`) for the change pill when the metric went DOWN. Defaults to red (`#db3707`). For a \"lower is better\" metric (latency, error rate, cost), set this to a green (e.g. `#388600`) so a decrease reads as good.",+ "type": "string"+ },+ "metricChangeIncreaseColor": {+ "description": "Only applies when `display` is `Metric`. Hex color (e.g. `#388600`) for the change pill when the metric went UP. Defaults to green (`#388600`). For a \"lower is better\" metric (latency, error rate, cost), set this to a red (e.g. `#db3707`) so an increase reads as bad.",+ "type": "string"+ },+ "metricColorByDirection": {+ "default": false,+ "description": "Only applies when `display` is `Metric`. Color the sparkline under the big number by whether the metric increased or decreased over the period (using the increase/decrease line colors).",+ "type": "boolean"+ },+ "metricLineDecreaseColor": {+ "description": "Only applies when `display` is `Metric` and `metricColorByDirection` is `true`. Hex color for the sparkline when the metric went DOWN. Defaults to red (`#db3707`). Flip to a green for a \"lower is better\" metric.",+ "type": "string"+ },+ "metricLineIncreaseColor": {+ "description": "Only applies when `display` is `Metric` and `metricColorByDirection` is `true`. Hex color for the sparkline when the metric went UP. Defaults to green (`#388600`). Flip to a red for a \"lower is better\" metric.",+ "type": "string"+ },+ "metricShowChange": {+ "default": true,+ "description": "Only applies when `display` is `Metric`. Show the change pill next to the big number — the percentage change from the first to the last point of the series over the selected date range.",+ "type": "boolean"+ },"showAlertThresholdLines": {"default": false,"description": "Whether to show alert threshold lines on the chart.",