: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(insights): filter chart annotations by scope (#101466)
Sam Penningtonf8ec77c8619f
diff --git a/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.test.ts b/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.test.tsindex cd6b860c302f..07a1ed5d7bc2 100644--- a/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.test.ts+++ b/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.test.ts@@ -3,6 +3,7 @@ import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'import { expectLogic } from 'kea-test-utils'import { insightLogic } from 'scenes/insights/insightLogic'+import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic'import { useMocks } from '~/mocks/jest'import { annotationsModel, deserializeAnnotation } from '~/models/annotationsModel'@@ -378,6 +379,48 @@ describe('annotationsOverlayLogic', () => {})})+ it.each([+ {+ annotationsScope: AnnotationScope.Organization,+ expected: [+ MOCK_ANNOTATION_ORG_SCOPED,+ MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_3,+ MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_1,+ ],+ },+ {+ annotationsScope: AnnotationScope.Project,+ expected: [+ MOCK_ANNOTATION_PROJECT_SCOPED,+ MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_1,+ MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_3,+ ],+ },+ ])('narrows to annotations with the $annotationsScope scope', async ({ annotationsScope, expected }) => {+ useInsightMocks()++ logic = annotationsOverlayLogic({+ dashboardItemId: MOCK_INSIGHT_SHORT_ID,+ insightNumericId: MOCK_INSIGHT_NUMERIC_ID,+ dashboardId: MOCK_DASHBOARD_ID,+ dates: ['2022-01-01', '2023-01-01'],+ ticks: [{ value: 0 }, { value: 1 }],+ })+ logic.mount()+ await expectLogic(annotationsModel).toDispatchActions(['loadAnnotationsSuccess'])+ const vizLogic = insightVizDataLogic({+ dashboardItemId: MOCK_INSIGHT_SHORT_ID,+ dashboardId: MOCK_DASHBOARD_ID,+ })+ await expectLogic(vizLogic, () => {+ vizLogic.actions.updateInsightFilter({ annotationsScope })+ }).toDispatchActions(['updateQuerySource'])++ await expectLogic(logic).toMatchValues({+ relevantAnnotations: expected.map((annotation) => deserializeAnnotation(annotation, 'UTC')),+ })+ })+it('excludes annotations that are outside of insight date range', async () => {useInsightMocks()diff --git a/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.ts b/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.tsindex 03a79c701cfc..5ae80057de78 100644--- a/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.ts+++ b/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.ts@@ -82,6 +82,7 @@ export interface annotationsOverlayLogicValues {featureFlags: FeatureFlagsSet // featureFlagLogicinsightId: number | null // insightLogicsavedInsight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> // insightLogic+ annotationsScope: AnnotationScope | null | undefined // insightVizDataLogicbreakdownFilter: BreakdownFilter | null | undefined // insightVizDataLogicinterval: IntervalType | null | undefined // insightVizDataLogicproperties: PropertyGroupFilter | AnyPropertyFilter[] | null | undefined // insightVizDataLogic@@ -160,7 +161,8 @@ export interface annotationsOverlayLogicMeta {dashboardId: number | undefined,savedInsight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>,properties: PropertyGroupFilter | AnyPropertyFilter[] | null | undefined,- breakdownFilter: BreakdownFilter | null | undefined+ breakdownFilter: BreakdownFilter | null | undefined,+ annotationsScope: AnnotationScope | null | undefined) => DatedAnnotationType[]groupedAnnotations: (relevantAnnotations: DatedAnnotationType[],@@ -195,7 +197,7 @@ export const annotationsOverlayLogic = kea<annotationsOverlayLogicType>([insightLogic,['insightId', 'savedInsight'],insightVizDataLogic,- ['interval', 'properties', 'breakdownFilter'],+ ['interval', 'properties', 'breakdownFilter', 'annotationsScope'],annotationsModel,['annotations', 'annotationsLoading'],teamLogic,@@ -290,6 +292,7 @@ export const annotationsOverlayLogic = kea<annotationsOverlayLogicType>([s.savedInsight,s.properties,s.breakdownFilter,+ s.annotationsScope,],(annotations: AnnotationType[],@@ -302,7 +305,8 @@ export const annotationsOverlayLogic = kea<annotationsOverlayLogicType>([QueryBasedInsightModel<import('~/queries/schema/schema-general').Node<Record<string, any>>>>,properties: PropertyGroupFilter | AnyPropertyFilter[] | null | undefined,- breakdownFilter: BreakdownFilter | null | undefined+ breakdownFilter: BreakdownFilter | null | undefined,+ annotationsScope: AnnotationScope | null | undefined) => {// This assumes that there are no more annotations in the project than AnnotationsViewSet// pagination class's default_limit of 100. As of June 2023, this is not true on Cloud US,@@ -325,7 +329,8 @@ export const annotationsOverlayLogic = kea<annotationsOverlayLogicType>([))) &&annotation.date_marker &&annotation.date_marker >= dateRange[0] &&- annotation.date_marker < dateRange[1]+ annotation.date_marker < dateRange[1] &&+ (!annotationsScope || annotation.scope === annotationsScope)): []diff --git a/frontend/src/queries/nodes/InsightViz/DisplayOptions.tsx b/frontend/src/queries/nodes/InsightViz/DisplayOptions.tsxindex 4532ca2107fc..545b95efdb66 100644--- a/frontend/src/queries/nodes/InsightViz/DisplayOptions.tsx+++ b/frontend/src/queries/nodes/InsightViz/DisplayOptions.tsx@@ -9,6 +9,7 @@ import { LemonCheckbox, LemonInput, Tooltip } from '@posthog/lemon-ui'import { SmoothingFilter } from 'lib/components/SmoothingFilter/SmoothingFilter'import { UnitPicker } from 'lib/components/UnitPicker/UnitPicker'import { DEFAULT_DECIMAL_PLACES } from 'lib/utils/numbers'+import { AnnotationsPicker } from 'scenes/insights/EditorFilters/AnnotationsPicker'import { AxisLabelFilter } from 'scenes/insights/EditorFilters/AxisLabelFilter'import { HideIncompleteConversionWindowPeriodsFilter } from 'scenes/insights/EditorFilters/HideIncompleteConversionWindowPeriodsFilter'import { LegendOptionsFilter } from 'scenes/insights/EditorFilters/LegendOptionsFilter'@@ -25,7 +26,6 @@ import { ResultCustomizationByPicker } from 'scenes/insights/EditorFilters/Resulimport { ScalePicker } from 'scenes/insights/EditorFilters/ScalePicker'import { ShowAlertAnomalyPointsFilter } from 'scenes/insights/EditorFilters/ShowAlertAnomalyPointsFilter'import { ShowAlertThresholdLinesFilter } from 'scenes/insights/EditorFilters/ShowAlertThresholdLinesFilter'-import { ShowAnnotationsFilter } from 'scenes/insights/EditorFilters/ShowAnnotationsFilter'import { ShowLegendFilter } from 'scenes/insights/EditorFilters/ShowLegendFilter'import { ShowMultipleYAxesFilter } from 'scenes/insights/EditorFilters/ShowMultipleYAxesFilter'import { ShowPieTotalFilter } from 'scenes/insights/EditorFilters/ShowPieTotalFilter'@@ -233,7 +233,7 @@ export const DisplayOptions = {MultipleYAxes: ShowMultipleYAxesFilter,TrendLines: ShowTrendLinesFilter,HideIncompleteFunnelPeriods: HideIncompleteConversionWindowPeriodsFilter,- Annotations: ShowAnnotationsFilter,+ Annotations: AnnotationsPicker,ResultCustomizationBy: ResultCustomizationByPicker,Unit: UnitPicker,Scale: ScalePicker,diff --git a/frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.test.tsx b/frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.test.tsxindex 040d22ef1d8a..35bf485d7407 100644--- a/frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.test.tsx+++ b/frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.test.tsx@@ -165,11 +165,11 @@ describe('InsightDisplayConfig', () => {{tabs: ['General', 'Axes', 'Lines'],sections: {- General: ['Unit', 'Color customization by'],+ General: ['Annotations', 'Unit', 'Color customization by'],Axes: ['X-axis', 'Y-axis'],Lines: ['Style', 'Overlays'],},- displayItems: ['Show values on series', 'Show annotations', 'Show legendBottom'],+ displayItems: ['Show values on series', 'Show legendBottom'],overlayItems: lineOverlays,},],@@ -179,16 +179,11 @@ describe('InsightDisplayConfig', () => {{tabs: ['General', 'Axes', 'Lines'],sections: {- General: ['Unit'],+ General: ['Annotations', 'Unit'],Axes: ['X-axis', 'Y-axis'],Lines: ['Overlays'],},- displayItems: [- 'Show values on series',- 'Show as % of total',- 'Show annotations',- 'Show legendBottom',- ],+ displayItems: ['Show values on series', 'Show as % of total', 'Show legendBottom'],overlayItems: lineOverlays,},],@@ -198,16 +193,11 @@ describe('InsightDisplayConfig', () => {{tabs: ['General', 'Axes', 'Lines'],sections: {- General: ['Unit'],+ General: ['Annotations', 'Unit'],Axes: ['X-axis', 'Y-axis'],Lines: ['Style', 'Overlays'],},- displayItems: [- 'Show values on series',- 'Show as % of total',- 'Show annotations',- 'Show legendBottom',- ],+ displayItems: ['Show values on series', 'Show as % of total', 'Show legendBottom'],},],[diff --git a/frontend/src/queries/nodes/InsightViz/insightDisplayOptions.tsx b/frontend/src/queries/nodes/InsightViz/insightDisplayOptions.tsxindex d5ae2b992566..de5d5968be23 100644--- a/frontend/src/queries/nodes/InsightViz/insightDisplayOptions.tsx+++ b/frontend/src/queries/nodes/InsightViz/insightDisplayOptions.tsx@@ -62,6 +62,7 @@ export function useInsightDisplayOptions(): { tabs: DisplayOptionTab[]; count: nshowMultipleYAxes,showAlertThresholdLines,showAnnotations,+ annotationsScope,isNonTimeSeriesDisplay,interval,usesInChartLegend,@@ -90,7 +91,7 @@ export function useInsightDisplayOptions(): { tabs: DisplayOptionTab[]; count: n(smoothingOptions[interval]?.length ?? 0) > 0const showMultipleYAxesConfig = (isTrends || isStickiness) && !hideContinuousChartOptions && !isBoxPlotconst showAlertThresholdLinesConfig = isTrends && !hideContinuousChartOptions- const showAnnotationsConfig = (isTrends && !hideContinuousChartOptions) || isTrendsFunnel+ const showAnnotationsConfig = ((isTrends && !hideContinuousChartOptions) || isTrendsFunnel) && !isBoxPlotconst showTrendLinesConfig = (isTrends || isRetention || isTrendsFunnel) && !hideContinuousChartOptions// Stickiness defaults to its line chart when display is unset, same as trends does — but// isDefaultTrendsLineDisplay only matches TrendsQuery, so we handle the stickiness case here.@@ -176,9 +177,6 @@ export function useInsightDisplayOptions(): { tabs: DisplayOptionTab[]; count: nif (isTrendsFunnel && !hideContinuousChartOptions) {displayItems.push(DisplayOptions.HideIncompleteFunnelPeriods)}- if (showAnnotationsConfig) {- displayItems.push(DisplayOptions.Annotations)- }if (showAlertThresholdLinesConfig) {displayItems.push(DisplayOptions.AlertAnomalyPoints)}@@ -193,6 +191,15 @@ export function useInsightDisplayOptions(): { tabs: DisplayOptionTab[]; count: nif (showDisplaySection && displayItems.length > 0) {displaySections.push({ key: 'display', dataAttr: 'options-display-section', items: displayItems })}+ if (showAnnotationsConfig) {+ displaySections.push({+ key: 'annotations',+ title: 'Annotations',+ tooltip:+ 'Annotations are saved on an insight, a dashboard, the project, or the organization. Choose which of those to show here.',+ items: [DisplayOptions.Annotations],+ })+ }if (showUnit) {displaySections.push({ key: 'unit', title: 'Unit', items: [DisplayOptions.Unit] })}@@ -295,7 +302,7 @@ export function useInsightDisplayOptions(): { tabs: DisplayOptionTab[]; count: nisPie && trendsFilter?.showLabelsOnSeries,unitIsSet,(hasLegend || showFunnelLegendConfig) && showLegend,- showAnnotationsConfig && showAnnotations === false,+ showAnnotationsConfig && (showAnnotations === false || !!annotationsScope),isMetric && trendsFilter?.metricShowChange === false,isMetric && trendsFilter?.metricColorByDirection,isMetric && !!trendsFilter?.metricSummary && trendsFilter.metricSummary !== 'total'diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 5d928264b1b0..b478c4b77c0e 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -1549,6 +1549,10 @@"required": ["results"],"type": "object"},+ "AnnotationScope": {+ "enum": ["dashboard_item", "dashboard", "project", "organization"],+ "type": "string"+ },"AnyAssistantGeneratedQuery": {"anyOf": [{@@ -27466,6 +27470,10 @@"FunnelsFilter": {"additionalProperties": false,"properties": {+ "annotationsScope": {+ "$ref": "#/definitions/AnnotationScope",+ "description": "Render only annotations with this scope. Only applies to historical-trends funnels."+ },"binCount": {"type": "integer"},@@ -53666,6 +53674,10 @@"description": "Literal prefix applied to every value (e.g. `$`). Use to pin a unit or currency symbol that does not depend on `aggregationAxisFormat` — for example, when values are denominated in a fixed currency regardless of the project's base currency. Include any trailing space yourself.","type": "string"},+ "annotationsScope": {+ "$ref": "#/definitions/AnnotationScope",+ "description": "Render only annotations with this scope. Unset renders every scope."+ },"breakdown_histogram_bin_count": {"type": "number"},diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex fddf91ca193e..491fdfc92f4b 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -4,6 +4,7 @@ import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'import { ConversionGoalSchema } from '~/taxonomy/marketingAnalytics'import {+ AnnotationScope,AnyFilterLike,AnyGroupScopeFilter,AnyPersonScopeFilter,@@ -1812,6 +1813,8 @@ export type TrendsFilter = {hideWeekends?: boolean/** @default true */showAnnotations?: boolean+ /** Render only annotations with this scope. Unset renders every scope. */+ annotationsScope?: AnnotationScope/** Show the period-over-period change pill on the Metric display.* @default true */metricShowChange?: boolean@@ -1870,6 +1873,7 @@ export const TRENDS_FILTER_PROPERTIES = new Set<keyof TrendsFilter>(['excludeBoxPlotOutliers','hideWeekends','showAnnotations',+ 'annotationsScope','metricShowChange','metricChangeIncreaseColor','metricChangeDecreaseColor',@@ -2083,6 +2087,8 @@ export type FunnelsFilter = {* @default true*/showAnnotations?: boolean+ /** Render only annotations with this scope. Only applies to historical-trends funnels. */+ annotationsScope?: AnnotationScope/*** Trends only: hide periods whose conversion window has not fully elapsed yet, so the recent* tail of the trend isn't dragged down by entrants who still have time to convert.diff --git a/frontend/src/queries/utils.ts b/frontend/src/queries/utils.tsindex 318132d417d0..d3f75ead7aa0 100644--- a/frontend/src/queries/utils.ts+++ b/frontend/src/queries/utils.ts@@ -75,7 +75,7 @@ import {WebVitalsPathBreakdownQuery,WebVitalsQuery,} from '~/queries/schema/schema-general'-import { BaseMathType, ChartDisplayType, FunnelVizType, GroupTypeIndex, IntervalType } from '~/types'+import { AnnotationScope, BaseMathType, ChartDisplayType, FunnelVizType, GroupTypeIndex, IntervalType } from '~/types'import { LATEST_VERSIONS } from './latest-versions'@@ -680,6 +680,15 @@ export const getShowAnnotations = (query: InsightQueryNode): boolean | undefinedreturn undefined}+export const getAnnotationsScope = (query: InsightQueryNode): AnnotationScope | undefined => {+ if (isTrendsQuery(query)) {+ return query.trendsFilter?.annotationsScope+ } else if (isFunnelsQuery(query)) {+ return query.funnelsFilter?.annotationsScope+ }+ return undefined+}+export const getShowLabelsOnSeries = (query: InsightQueryNode): boolean | undefined => {if (isTrendsQuery(query)) {return query.trendsFilter?.showLabelsOnSeriesdiff --git a/frontend/src/scenes/insights/EditorFilters/AnnotationsPicker.tsx b/frontend/src/scenes/insights/EditorFilters/AnnotationsPicker.tsxnew file mode 100644index 000000000000..0f0dbdd35524--- /dev/null+++ b/frontend/src/scenes/insights/EditorFilters/AnnotationsPicker.tsx@@ -0,0 +1,46 @@+import { useActions, useValues } from 'kea'++import { LemonSelect, LemonSelectOptions } from '@posthog/lemon-ui'++import { insightLogic } from 'scenes/insights/insightLogic'++import { AnnotationScope } from '~/types'++import { annotationScopeToName } from 'products/annotations/frontend/logics/annotationModalLogic'++import { insightVizDataLogic } from '../insightVizDataLogic'++type AnnotationsSelection = AnnotationScope | 'all' | 'none'++const OPTIONS: LemonSelectOptions<AnnotationsSelection> = [+ { value: 'all', label: 'All' },+ { value: 'none', label: 'None' },+ ...Object.values(AnnotationScope).map((scope) => ({+ value: scope,+ label: annotationScopeToName[scope],+ })),+]++export function AnnotationsPicker(): JSX.Element {+ const { insightProps } = useValues(insightLogic)+ const { showAnnotations, annotationsScope } = useValues(insightVizDataLogic(insightProps))+ const { updateInsightFilter } = useActions(insightVizDataLogic(insightProps))++ return (+ <div className="mb-2.5 mx-2">+ <LemonSelect+ size="small"+ fullWidth+ value={showAnnotations === false ? 'none' : (annotationsScope ?? 'all')}+ options={OPTIONS}+ onChange={(selection) =>+ updateInsightFilter({+ showAnnotations: selection === 'none' ? false : undefined,+ annotationsScope: selection === 'all' || selection === 'none' ? undefined : selection,+ })+ }+ data-attr="insight-annotations-picker"+ />+ </div>+ )+}diff --git a/frontend/src/scenes/insights/EditorFilters/ShowAnnotationsFilter.tsx b/frontend/src/scenes/insights/EditorFilters/ShowAnnotationsFilter.tsxdeleted file mode 100644index 15ddb6a760a2..000000000000--- a/frontend/src/scenes/insights/EditorFilters/ShowAnnotationsFilter.tsx+++ /dev/null@@ -1,25 +0,0 @@-import { useActions, useValues } from 'kea'--import { LemonCheckbox } from '@posthog/lemon-ui'--import { insightLogic } from 'scenes/insights/insightLogic'--import { insightVizDataLogic } from '../insightVizDataLogic'--export function ShowAnnotationsFilter(): JSX.Element | null {- const { insightProps } = useValues(insightLogic)- const { showAnnotations } = useValues(insightVizDataLogic(insightProps))- const { updateInsightFilter } = useActions(insightVizDataLogic(insightProps))-- const checked = showAnnotations !== false-- return (- <LemonCheckbox- className="p-1 px-2"- onChange={(value) => updateInsightFilter({ showAnnotations: value })}- checked={checked}- label={<span className="font-normal">Show annotations</span>}- size="small"- />- )-}diff --git a/frontend/src/scenes/insights/insightVizDataLogic.ts b/frontend/src/scenes/insights/insightVizDataLogic.tsindex 726be79c2d32..7dc4d5880455 100644--- a/frontend/src/scenes/insights/insightVizDataLogic.ts+++ b/frontend/src/scenes/insights/insightVizDataLogic.ts@@ -74,6 +74,7 @@ import {getResultCustomizationBy,getSeries,getShowAlertThresholdLines,+ getAnnotationsScope,getShowAnnotations,getShowLabelsOnSeries,getShowLegend,@@ -112,6 +113,7 @@ import {IntervalType,LabelGroupType,SlowQueryPossibilities,+ AnnotationScope,} from '~/types'import { getClampedFunnelStepRange } from 'products/product_analytics/frontend/insights/funnels/funnelUtils'@@ -193,6 +195,7 @@ export interface insightVizDataLogicValues {activeUsersMath: BaseMathType.MonthlyActiveUsers | BaseMathType.WeeklyActiveUsers | nullaggregationGroupTypeIndex: GroupTypeIndex | null | undefinedallEventNames: string[]+ annotationsScope: AnnotationScope | null | undefinedbreakdownFilter: BreakdownFilter | null | undefinedcompareFilter: CompareFilter | null | undefinedcurrentDataWarehouseSchemaColumns: DatabaseSchemaField[]@@ -857,6 +860,19 @@ export interface insightVizDataLogicMeta {| WebStatsTableQuery| null) => boolean | null | undefined+ annotationsScope: (+ querySource:+ | FunnelsQuery+ | LifecycleQuery+ | PathsQuery+ | PathsV2Query+ | RetentionQuery+ | StickinessQuery+ | TrendsQuery+ | WebOverviewQuery+ | WebStatsTableQuery+ | null+ ) => AnnotationScope | null | undefinedshowLegend: (querySource:| FunnelsQuery@@ -1819,6 +1835,10 @@ export const insightVizDataLogic = kea<insightVizDataLogicType>([| import('~/queries/schema/schema-general').WebStatsTableQuery) => (q ? getShowAnnotations(q) : null),],+ annotationsScope: [+ (s) => [s.querySource],+ (querySource: InsightQueryNode | null) => (querySource ? getAnnotationsScope(querySource) : null),+ ],showLegend: [(s) => [s.querySource],(diff --git a/frontend/src/scenes/insights/utils/queryUtils.ts b/frontend/src/scenes/insights/utils/queryUtils.tsindex 9c688a341c53..aa93b7b70aa7 100644--- a/frontend/src/scenes/insights/utils/queryUtils.ts+++ b/frontend/src/scenes/insights/utils/queryUtils.ts@@ -327,6 +327,7 @@ export const cleanInsightQuery = (query: InsightQueryNode, opts?: CompareQueryOpdetailedResultsAggregationType: undefined,excludeBoxPlotOutliers: undefined,showAnnotations: undefined,+ annotationsScope: undefined,showFullUrls: undefined,selectedInterval: undefined,funnelStepReference: undefined,diff --git a/posthog/schema.py b/posthog/schema.pyindex de83e5409c1c..e74c724d2b0f 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -29,6 +29,7 @@ from posthog.schema_enums import (AlertCalculationInterval as AlertCalculationInterval,AlertConditionType as AlertConditionType,AlertState as AlertState,+ AnnotationScope as AnnotationScope,ApprovalDecisionStatus as ApprovalDecisionStatus,ArtifactContentType as ArtifactContentType,ArtifactSource as ArtifactSource,@@ -8361,6 +8362,10 @@ class TrendsFilter(BaseModel):" the project's base currency. Include any trailing space yourself."),)+ annotationsScope: AnnotationScope | None = Field(+ default=None,+ description=("Render only annotations with this scope. Unset renders every scope."),+ )breakdown_histogram_bin_count: float | None = NonechartStyle: ChartStyle | None = Field(default=None, description="Chart rendering style overrides (line shape).")confidenceLevel: float | None = None@@ -28937,6 +28942,10 @@ class FunnelsFilter(BaseModel):model_config = ConfigDict(extra="forbid",)+ annotationsScope: AnnotationScope | None = Field(+ default=None,+ description=("Render only annotations with this scope. Only applies to historical-trends funnels."),+ )binCount: int | None = NonebreakdownAttributionType: BreakdownAttributionType | None = BreakdownAttributionType.FIRST_TOUCHbreakdownAttributionValue: int | None = Nonediff --git a/posthog/schema_enums.py b/posthog/schema_enums.pyindex c17099a4a20e..d05a4ec24a12 100644--- a/posthog/schema_enums.py+++ b/posthog/schema_enums.py@@ -167,6 +167,13 @@ class AlertState(StrEnum):SNOOZED = "Snoozed"+class AnnotationScope(StrEnum):+ DASHBOARD_ITEM = "dashboard_item"+ DASHBOARD = "dashboard"+ PROJECT = "project"+ ORGANIZATION = "organization"++class ApprovalDecisionStatus(StrEnum):PENDING = "pending"APPROVED = "approved"diff --git a/posthog/schema_helpers.py b/posthog/schema_helpers.pyindex 654d6e8c9205..40cce79ab08f 100644--- a/posthog/schema_helpers.py+++ b/posthog/schema_helpers.py@@ -118,6 +118,7 @@ def to_dict(query: BaseModel) -> dict:"detailedResultsAggregationType","excludeBoxPlotOutliers","showAnnotations",+ "annotationsScope","showFullUrls","selectedInterval","funnelStepReference",diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex bc66c413f87a..98c222735066 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -2762,6 +2762,15 @@ export const AggregationAxisFormatApi = {Short: 'short',} as const+export type AnnotationScopeApi = (typeof AnnotationScopeApi)[keyof typeof AnnotationScopeApi]++export const AnnotationScopeApi = {+ DashboardItem: 'dashboard_item',+ Dashboard: 'dashboard',+ Project: 'project',+ Organization: 'organization',+} as const+export type CurveApi = (typeof CurveApi)[keyof typeof CurveApi]export const CurveApi = {@@ -2915,6 +2924,8 @@ export interface TrendsFilterApi {aggregationAxisPostfix?: string | null/** Literal prefix applied to every value (e.g. `$`). Use to pin a unit or currency symbol that does not depend on `aggregationAxisFormat` — for example, when values are denominated in a fixed currency regardless of the project's base currency. Include any trailing space yourself. */aggregationAxisPrefix?: string | null+ /** Render only annotations with this scope. Unset renders every scope. */+ annotationsScope?: AnnotationScopeApi | nullbreakdown_histogram_bin_count?: number | null/** Chart rendering style overrides (line shape). */chartStyle?: ChartStyleApi | null@@ -3287,6 +3298,8 @@ export const FunnelLayoutApi = {export type FunnelsFilterApiResultCustomizations = { [key: string]: ResultCustomizationByValueApi } | nullexport interface FunnelsFilterApi {+ /** Render only annotations with this scope. Only applies to historical-trends funnels. */+ annotationsScope?: AnnotationScopeApi | nullbinCount?: number | nullbreakdownAttributionType?: BreakdownAttributionTypeApi | nullbreakdownAttributionValue?: number | nulldiff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.tsindex 205846fc4a87..4c72ab969175 100644--- a/products/product_analytics/frontend/generated/api.schemas.ts+++ b/products/product_analytics/frontend/generated/api.schemas.ts@@ -1756,6 +1756,15 @@ export const AggregationAxisFormatApi = {Short: 'short',} as const+export type AnnotationScopeApi = (typeof AnnotationScopeApi)[keyof typeof AnnotationScopeApi]++export const AnnotationScopeApi = {+ DashboardItem: 'dashboard_item',+ Dashboard: 'dashboard',+ Project: 'project',+ Organization: 'organization',+} as const+export type CurveApi = (typeof CurveApi)[keyof typeof CurveApi]export const CurveApi = {@@ -1909,6 +1918,8 @@ export interface TrendsFilterApi {aggregationAxisPostfix?: string | null/** Literal prefix applied to every value (e.g. `$`). Use to pin a unit or currency symbol that does not depend on `aggregationAxisFormat` — for example, when values are denominated in a fixed currency regardless of the project's base currency. Include any trailing space yourself. */aggregationAxisPrefix?: string | null+ /** Render only annotations with this scope. Unset renders every scope. */+ annotationsScope?: AnnotationScopeApi | nullbreakdown_histogram_bin_count?: number | null/** Chart rendering style overrides (line shape). */chartStyle?: ChartStyleApi | null@@ -2281,6 +2292,8 @@ export const FunnelLayoutApi = {export type FunnelsFilterApiResultCustomizations = { [key: string]: ResultCustomizationByValueApi } | nullexport interface FunnelsFilterApi {+ /** Render only annotations with this scope. Only applies to historical-trends funnels. */+ annotationsScope?: AnnotationScopeApi | nullbinCount?: number | nullbreakdownAttributionType?: BreakdownAttributionTypeApi | nullbreakdownAttributionValue?: number | nulldiff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 7368bc7a4ff9..9486d159e30b 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -3903,6 +3903,16 @@ export namespace Schemas {Short: 'short',} as const;+ export type AnnotationScope = typeof AnnotationScope[keyof typeof AnnotationScope];+++ export const AnnotationScope = {+ DashboardItem: 'dashboard_item',+ Dashboard: 'dashboard',+ Project: 'project',+ Organization: 'organization',+ } as const;+export type Curve = typeof Curve[keyof typeof Curve];@@ -4061,6 +4071,8 @@ export namespace Schemas {aggregationAxisPostfix?: string | null;/** Literal prefix applied to every value (e.g. `$`). Use to pin a unit or currency symbol that does not depend on `aggregationAxisFormat` — for example, when values are denominated in a fixed currency regardless of the project's base currency. Include any trailing space yourself. */aggregationAxisPrefix?: string | null;+ /** Render only annotations with this scope. Unset renders every scope. */+ annotationsScope?: AnnotationScope | null;breakdown_histogram_bin_count?: number | null;/** Chart rendering style overrides (line shape). */chartStyle?: ChartStyle | null;@@ -4284,6 +4296,8 @@ export namespace Schemas {export type FunnelsFilterResultCustomizations = {[key: string]: ResultCustomizationByValue} | null;export interface FunnelsFilter {+ /** Render only annotations with this scope. Only applies to historical-trends funnels. */+ annotationsScope?: AnnotationScope | null;binCount?: number | null;breakdownAttributionType?: BreakdownAttributionType | null;breakdownAttributionValue?: number | null;