: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(trends): break down autocapture trends by element tag, text, or href (#103394)
Paul D'Ambra928b728cd196
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsxindex 74940df641f9..608b6dde77ca 100644--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx@@ -1351,9 +1351,13 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([name: 'Autocapture elements',searchPlaceholder: 'autocapture elements',type: TaxonomicFilterGroupType.Elements,- options: ['tag_name', 'text', 'href', 'selector'].map((option) => ({- name: option,- })) as SimpleOption[],+ options: (['tag_name', 'text', 'href', 'selector'] as const)+ .filter(+ (option) => !excludedProperties[TaxonomicFilterGroupType.Elements]?.includes(option)+ )+ .map((option) => ({+ name: option,+ })) as SimpleOption[],getName: (option: SimpleOption) => option.name,getValue: (option: SimpleOption) => option.name,getPopoverHeader: () => 'Autocapture Element',@@ -2193,10 +2197,15 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([group: TaxonomicFilterGroupType.EventProperties,})),...(eventNames.includes('$autocapture')- ? (['text', 'selector'] as const).map((name) => ({- name,- group: TaxonomicFilterGroupType.Elements,- }))+ ? (['text', 'selector'] as const)+ .filter(+ (name) =>+ !excludedProperties[TaxonomicFilterGroupType.Elements]?.includes(name)+ )+ .map((name) => ({+ name,+ group: TaxonomicFilterGroupType.Elements,+ })): []),...(eventNames.includes(MCP_TOOL_CALL_EVENT)? MCP_TOOL_CALL_SUGGESTED_PROPERTIES.map((name) => ({diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx b/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsxindex 390a55e17b8f..ba345c42821f 100644--- a/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx@@ -335,9 +335,11 @@ export function buildTaxonomicGroups(ctx: BuildTaxonomicGroupsContext): Taxonominame: 'Autocapture elements',searchPlaceholder: 'autocapture elements',type: TaxonomicFilterGroupType.Elements,- options: ['tag_name', 'text', 'href', 'selector'].map((option) => ({- name: option,- })) as SimpleOption[],+ options: (['tag_name', 'text', 'href', 'selector'] as const)+ .filter((option) => !excludedProperties[TaxonomicFilterGroupType.Elements]?.includes(option))+ .map((option) => ({+ name: option,+ })) as SimpleOption[],getName: (option: SimpleOption) => option.name,getValue: (option: SimpleOption) => option.name,getPopoverHeader: () => 'Autocapture Element',@@ -1155,10 +1157,12 @@ export function buildTaxonomicGroups(ctx: BuildTaxonomicGroupsContext): Taxonomigroup: TaxonomicFilterGroupType.EventProperties,})),...(eventNames.includes('$autocapture')- ? (['text', 'selector'] as const).map((name) => ({- name,- group: TaxonomicFilterGroupType.Elements,- }))+ ? (['text', 'selector'] as const)+ .filter((name) => !excludedProperties[TaxonomicFilterGroupType.Elements]?.includes(name))+ .map((name) => ({+ name,+ group: TaxonomicFilterGroupType.Elements,+ })): []),...(eventNames.includes(MCP_TOOL_CALL_EVENT)? MCP_TOOL_CALL_SUGGESTED_PROPERTIES.map((name) => ({diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 2c953570b714..6cfee9064eae 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -2924,6 +2924,7 @@"person","event","event_metadata",+ "element","session","hogql","cohort",@@ -6767,6 +6768,7 @@"person","event","event_metadata",+ "element","group","session","hogql",@@ -39616,6 +39618,7 @@"person","event","event_metadata",+ "element","group","session","hogql",diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex 142e14303716..01f83c3bc653 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -6735,6 +6735,7 @@ export type MultipleBreakdownType =| 'person'| 'event'| 'event_metadata'+ | 'element'| 'group'| 'session'| 'hogql'diff --git a/frontend/src/queries/validators.js b/frontend/src/queries/validators.jsindex 57844085506b..88df0e31a84e 100644--- a/frontend/src/queries/validators.js+++ b/frontend/src/queries/validators.js@@ -7593,6 +7593,7 @@ const schema80 = {'person','event','event_metadata',+ 'element','group','session','hogql',@@ -7619,6 +7620,7 @@ const schema85 = {'person','event','event_metadata',+ 'element','group','session','hogql',@@ -7892,6 +7894,7 @@ function validate95(data, { instancePath = '', parentData, parentDataProperty, rdata4 === 'person' ||data4 === 'event' ||data4 === 'event_metadata' ||+ data4 === 'element' ||data4 === 'group' ||data4 === 'session' ||data4 === 'hogql' ||@@ -8410,6 +8413,7 @@ function validate94(data, { instancePath = '', parentData, parentDataProperty, rdata8 === 'person' ||data8 === 'event' ||data8 === 'event_metadata' ||+ data8 === 'element' ||data8 === 'group' ||data8 === 'session' ||data8 === 'hogql' ||diff --git a/frontend/src/scenes/insights/InsightNav/insightNavLogic.test.ts b/frontend/src/scenes/insights/InsightNav/insightNavLogic.test.tsindex d8b764b843ca..fd262fb49528 100644--- a/frontend/src/scenes/insights/InsightNav/insightNavLogic.test.ts+++ b/frontend/src/scenes/insights/InsightNav/insightNavLogic.test.ts@@ -12,6 +12,8 @@ import { examples } from '~/queries/examples'import { LATEST_VERSIONS } from '~/queries/latest-versions'import { nodeKindToDefaultQuery } from '~/queries/nodes/InsightQuery/defaults'import {+ Breakdown,+ BreakdownFilter,EventsQuery,FunnelsQuery,InsightVizNode,@@ -564,46 +566,59 @@ describe('insightNavLogic', () => {])})- it('gets rid of multiple breakdowns when switching from trends to funnels', async () => {- trendsQuery.source = {- ...trendsQuery.source,- breakdownFilter: {- breakdowns: [- { property: 'num', type: 'person', histogram_bin_count: 10 },- { property: '$device_type', type: 'event' },- ],- },- } as TrendsQuery+ it.each([+ {+ name: 'keeps the first breakdown',+ breakdowns: [+ { property: 'num', type: 'person', histogram_bin_count: 10 },+ { property: '$device_type', type: 'event' },+ ],+ expected: { breakdown: 'num', breakdown_type: 'person', breakdown_histogram_bin_count: 10 },+ },+ {+ name: 'skips element breakdowns, which funnels do not support',+ breakdowns: [+ { property: 'text', type: 'element' },+ { property: '$device_type', type: 'event' },+ ],+ expected: { breakdown: '$device_type', breakdown_type: 'event' },+ },+ {+ name: 'clears the breakdown when only element breakdowns remain',+ breakdowns: [{ property: 'text', type: 'element' }],+ expected: {},+ },+ ] as { name: string; breakdowns: Breakdown[]; expected: BreakdownFilter }[])(+ 'switching from trends to funnels with multiple breakdowns $name',+ async ({ breakdowns, expected }) => {+ trendsQuery.source = {+ ...trendsQuery.source,+ breakdownFilter: { breakdowns },+ } as TrendsQuery- await expectLogic(logic, () => {- builtInsightDataLogic.actions.setQuery(trendsQuery)- })+ await expectLogic(logic, () => {+ builtInsightDataLogic.actions.setQuery(trendsQuery)+ })- await expectLogic(builtInsightDataLogic, () => {- logic.actions.setActiveView(InsightType.FUNNELS)- }).toDispatchActions([- builtInsightDataLogic.actionCreators.setQuery({- kind: 'InsightVizNode',- source: {- kind: 'FunnelsQuery',- series: [{ kind: 'EventsNode', name: '$pageview', event: '$pageview' }],- funnelsFilter: { funnelVizType: 'steps', showValuesOnSeries: true },- filterTestAccounts: true,- version: LATEST_VERSIONS[NodeKind.FunnelsQuery],- interval: 'hour',- breakdownFilter: {- breakdowns: undefined,- breakdown: 'num',- breakdown_type: 'person',- breakdown_histogram_bin_count: 10,- breakdown_group_type_index: undefined,- breakdown_normalize_url: undefined,+ await expectLogic(builtInsightDataLogic, () => {+ logic.actions.setActiveView(InsightType.FUNNELS)+ }).toDispatchActions([+ builtInsightDataLogic.actionCreators.setQuery({+ kind: 'InsightVizNode',+ source: {+ kind: 'FunnelsQuery',+ series: [{ kind: 'EventsNode', name: '$pageview', event: '$pageview' }],+ funnelsFilter: { funnelVizType: 'steps', showValuesOnSeries: true },+ filterTestAccounts: true,+ version: LATEST_VERSIONS[NodeKind.FunnelsQuery],+ interval: 'hour',+ breakdownFilter: expected,+ tags: PRODUCT_ANALYTICS_DEFAULT_QUERY_TAGS,},- tags: PRODUCT_ANALYTICS_DEFAULT_QUERY_TAGS,- },- } as Node),- ])- })+ } as Node),+ ])+ }+ )it('keeps multiple breakdowns when switching from funnels to trends', async () => {funnelsQuery.source = {diff --git a/frontend/src/scenes/insights/InsightNav/insightNavLogic.tsx b/frontend/src/scenes/insights/InsightNav/insightNavLogic.tsxindex 2eb2bfc89738..3ea68a8b2e81 100644--- a/frontend/src/scenes/insights/InsightNav/insightNavLogic.tsx+++ b/frontend/src/scenes/insights/InsightNav/insightNavLogic.tsx@@ -259,9 +259,23 @@ interface InsightTypeCapabilities {const downgradeMinuteInterval = (interval: IntervalType): IntervalType => (interval === 'minute' ? 'hour' : interval)+const clearBreakdown = (bf: BreakdownFilter): BreakdownFilter => ({+ ...bf,+ breakdowns: undefined,+ breakdown: undefined,+ breakdown_type: undefined,+ breakdown_group_type_index: undefined,+ breakdown_histogram_bin_count: undefined,+ breakdown_normalize_url: undefined,+ breakdown_path_cleaning: undefined,+})+const truncateToSingleBreakdown = (bf: BreakdownFilter): BreakdownFilter => {if (bf.breakdowns?.length) {- const first = bf.breakdowns[0]+ const first = bf.breakdowns.find((b) => b.type !== 'element')+ if (!first) {+ return clearBreakdown(bf)+ }return {...bf,breakdowns: undefined,@@ -272,6 +286,9 @@ const truncateToSingleBreakdown = (bf: BreakdownFilter): BreakdownFilter => {breakdown_normalize_url: first.normalize_url,}}+ if (bf.breakdown_type === 'element') {+ return clearBreakdown(bf)+ }return { ...bf, breakdowns: undefined }}diff --git a/frontend/src/scenes/insights/filters/BreakdownFilter/TaxonomicBreakdownPopover.tsx b/frontend/src/scenes/insights/filters/BreakdownFilter/TaxonomicBreakdownPopover.tsxindex eb5e562303d2..dd0a53095ba5 100644--- a/frontend/src/scenes/insights/filters/BreakdownFilter/TaxonomicBreakdownPopover.tsx+++ b/frontend/src/scenes/insights/filters/BreakdownFilter/TaxonomicBreakdownPopover.tsx@@ -94,6 +94,9 @@ export const TaxonomicBreakdownPopover = ({TaxonomicFilterGroupType.PersonProperties,TaxonomicFilterGroupType.EventFeatureFlags,TaxonomicFilterGroupType.EventMetadata,+ // Element breakdowns read the autocapture elements chain, which only trends knows+ // how to break down. Funnels raise for breakdown types outside their own list.+ ...(isTrends ? [TaxonomicFilterGroupType.Elements] : []),...groupsTaxonomicTypes,TaxonomicFilterGroupType.CohortsWithAllUsers,...(includeSessions ? [TaxonomicFilterGroupType.SessionProperties] : []),@@ -103,6 +106,15 @@ export const TaxonomicBreakdownPopover = ({]}+ // A selector filter is a regex over the whole elements chain, so no per-event breakdown+ // value can agree with it. Hide it in breakdowns only; property filters still offer it.+ // Outside trends, element breakdowns are not supported at all, so hide every element+ // property, including the suggested rows, or the click applies a breakdown the backend+ // then rejects.+ const excludedElementBreakdownProperties = {+ [TaxonomicFilterGroupType.Elements]: isTrends ? ['selector'] : ['selector', 'text', 'href', 'tag_name'],+ }+return (<Popoverstyle={{ minHeight: '200px' }}@@ -131,6 +143,7 @@ export const TaxonomicBreakdownPopover = ({}}eventNames={allEventNames}taxonomicGroupTypes={taxonomicGroupTypes}+ excludedProperties={excludedElementBreakdownProperties}metadataSource={// Without this the SQL expression editor validates against the events table// and marks every warehouse column as unknown.diff --git a/frontend/src/scenes/insights/filters/BreakdownFilter/taxonomicBreakdownFilterLogic.test.ts b/frontend/src/scenes/insights/filters/BreakdownFilter/taxonomicBreakdownFilterLogic.test.tsindex 84aa4a0838b9..bbbd89e7133a 100644--- a/frontend/src/scenes/insights/filters/BreakdownFilter/taxonomicBreakdownFilterLogic.test.ts+++ b/frontend/src/scenes/insights/filters/BreakdownFilter/taxonomicBreakdownFilterLogic.test.ts@@ -1,9 +1,11 @@import { expectLogic } from 'kea-test-utils'import { TaxonomicFilterGroup, TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'+import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'+import { propertyDefinitionsModel } from '~/models/propertyDefinitionsModel'import { initKeaTests } from '~/test/init'-import { ChartDisplayType, InsightLogicProps } from '~/types'+import { ChartDisplayType, InsightLogicProps, PropertyType } from '~/types'import * as breakdownLogic from './taxonomicBreakdownFilterLogic'@@ -67,6 +69,34 @@ describe('taxonomicBreakdownFilterLogic', () => {})})+ it('sets breakdown for autocapture elements', async () => {+ logic = taxonomicBreakdownFilterLogic(makeProps({ breakdownFilter: {} }))+ logic.mount()+ propertyDefinitionsModel.actions.updatePropertyDefinitions({+ 'event/text': {+ id: 'text',+ name: 'text',+ property_type: PropertyType.Numeric,+ is_numerical: true,+ is_seen_on_filtered_events: false,+ },+ })+ const group: TaxonomicFilterGroup = taxonomicGroupFor(TaxonomicFilterGroupType.Elements, undefined)++ await expectLogic(logic, () => {+ logic.actions.addBreakdown('text', group)+ }).toFinishListeners()++ expect(updateBreakdownFilter).toHaveBeenCalledWith({+ breakdowns: [+ {+ property: 'text',+ type: 'element',+ },+ ],+ })+ })+it('sets breakdown for cohorts', async () => {logic = taxonomicBreakdownFilterLogic(makeProps({@@ -194,8 +224,10 @@ describe('taxonomicBreakdownFilterLogic', () => {it('rejects a taxonomic group that maps to a non-breakdown type', async () => {logic = taxonomicBreakdownFilterLogic(makeProps({ breakdownFilter: {} }))logic.mount()+ const errorToast = jest.spyOn(lemonToast, 'error')// Error tracking issues map to the `error_tracking_issue` property filter type, which is- // not a valid `BreakdownType`. It must not reach the query as a breakdown.+ // not a valid `BreakdownType`. It must not reach the query as a breakdown, and the user+ // must hear about the rejection instead of the picker closing without a word.const group: TaxonomicFilterGroup = taxonomicGroupFor(TaxonomicFilterGroupType.ErrorTrackingIssues,undefined@@ -206,6 +238,10 @@ describe('taxonomicBreakdownFilterLogic', () => {}).toFinishListeners()expect(updateBreakdownFilter).not.toHaveBeenCalled()+ expect(errorToast).toHaveBeenCalledWith(+ 'Breakdowns by unused in these tests are not supported here. Pick an event or person property instead.'+ )+ errorToast.mockRestore()})it('sets a hide other aggregation', async () => {@@ -571,8 +607,17 @@ describe('taxonomicBreakdownFilterLogic', () => {}))logic.mount()+ propertyDefinitionsModel.actions.updatePropertyDefinitions({+ 'event/text': {+ id: 'text',+ name: 'text',+ property_type: PropertyType.Numeric,+ is_numerical: true,+ is_seen_on_filtered_events: false,+ },+ })const changedBreakdown = 'c'- const group: TaxonomicFilterGroup = taxonomicGroupFor(TaxonomicFilterGroupType.EventProperties, undefined)+ const group: TaxonomicFilterGroup = taxonomicGroupFor(TaxonomicFilterGroupType.Elements, undefined)await expectLogic(logic, () => {logic.actions.replaceBreakdown(@@ -582,7 +627,7 @@ describe('taxonomicBreakdownFilterLogic', () => {},{group: group,- value: 'a',+ value: 'text',})}).toFinishListeners()@@ -591,8 +636,8 @@ describe('taxonomicBreakdownFilterLogic', () => {breakdown_type: undefined,breakdowns: [{- type: 'event',- property: 'a',+ type: 'element',+ property: 'text',},],breakdown_group_type_index: undefined,diff --git a/frontend/src/scenes/insights/filters/BreakdownFilter/taxonomicBreakdownFilterLogic.ts b/frontend/src/scenes/insights/filters/BreakdownFilter/taxonomicBreakdownFilterLogic.tsindex 334d5a923fdb..8695f0e5179f 100644--- a/frontend/src/scenes/insights/filters/BreakdownFilter/taxonomicBreakdownFilterLogic.ts+++ b/frontend/src/scenes/insights/filters/BreakdownFilter/taxonomicBreakdownFilterLogic.ts@@ -10,6 +10,7 @@ import {TaxonomicFilterGroupType,TaxonomicFilterValue,} from 'lib/components/TaxonomicFilter/types'+import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic'import { keyForInsightLogicProps } from 'scenes/insights/sharedUtils'@@ -562,18 +563,28 @@ export const taxonomicBreakdownFilterLogic = kea<taxonomicBreakdownFilterLogicTyconst propertyFilterType = taxonomicFilterTypeToPropertyFilterType(taxonomicGroup.type)const breakdownType = isBreakdownType(propertyFilterType) ? propertyFilterType : undefinedconst propertyDefinitionType = propertyFilterTypeToPropertyDefinitionType(breakdownType)- const isHistogramable =- !!values.getPropertyDefinition(breakdown, propertyDefinitionType)?.is_numerical && props.isTrends+ const propertyDefinition =+ breakdownType === 'element' ? null : values.getPropertyDefinition(breakdown, propertyDefinitionType)+ const isHistogramable = !!propertyDefinition?.is_numerical && props.isTrends- if (!props.updateBreakdownFilter || !breakdownType) {+ if (!props.updateBreakdownFilter) {+ return+ }++ if (!breakdownType) {+ // propertyFilterType resolving means the group is pickable elsewhere, so a quiet+ // return leaves the user with no feedback. Only report the case that used to drop silently.+ if (propertyFilterType) {+ lemonToast.error(+ `Breakdowns by ${taxonomicGroup.name.toLowerCase()} are not supported here. Pick an event or person property instead.`+ )+ }return}// If property definitions are not loaded when this runs then a normalizeable URL will not be normalized.// For now, it is safe to fall back to `breakdown` instead of the property definition.- const isNormalizeable = isURLNormalizeable(- values.getPropertyDefinition(breakdown, propertyDefinitionType)?.name || (breakdown as string)- )+ const isNormalizeable = isURLNormalizeable(propertyDefinition?.name || (breakdown as string))const { breakdownFilter } = values@@ -720,23 +731,33 @@ export const taxonomicBreakdownFilterLogic = kea<taxonomicBreakdownFilterLogicTyconst breakdownValue = newBreakdown.valueconst propertyDefinitionType = propertyFilterTypeToPropertyDefinitionType(breakdownType)- const isHistogramable =- !!values.getPropertyDefinition(breakdownValue, propertyDefinitionType)?.is_numerical && props.isTrends+ const propertyDefinition =+ breakdownType === 'element'+ ? null+ : values.getPropertyDefinition(breakdownValue, propertyDefinitionType)+ const isHistogramable = !!propertyDefinition?.is_numerical && props.isTrendsif (!props.updateBreakdownFilter ||- !breakdownType ||(breakdownType === previousBreakdown.type && breakdownValue === previousBreakdown.value) ||- checkBreakdownExists(values.breakdownFilter.breakdowns, breakdownValue, breakdownType)+ (breakdownType != null &&+ checkBreakdownExists(values.breakdownFilter.breakdowns, breakdownValue, breakdownType))) {return}+ if (!breakdownType) {+ if (newBreakdownPropertyFilterType) {+ lemonToast.error(+ `Breakdowns by ${newBreakdown.group.name.toLowerCase()} are not supported here. Pick an event or person property instead.`+ )+ }+ return+ }+// If property definitions are not loaded when this runs then a normalizeable URL will not be normalized.// For now, it is safe to fall back to `breakdown` instead of the property definition.- const isNormalizeable = isURLNormalizeable(- values.getPropertyDefinition(breakdownValue, propertyDefinitionType)?.name || (breakdownValue as string)- )+ const isNormalizeable = isURLNormalizeable(propertyDefinition?.name || (breakdownValue as string))if (values.isMultipleBreakdownsEnabled &&diff --git a/frontend/src/scenes/insights/filters/BreakdownFilter/taxonomicBreakdownFilterUtils.ts b/frontend/src/scenes/insights/filters/BreakdownFilter/taxonomicBreakdownFilterUtils.tsindex 29064f58b054..71648b13d873 100644--- a/frontend/src/scenes/insights/filters/BreakdownFilter/taxonomicBreakdownFilterUtils.ts+++ b/frontend/src/scenes/insights/filters/BreakdownFilter/taxonomicBreakdownFilterUtils.ts@@ -16,6 +16,7 @@ export function isMultipleBreakdownType(breakdownType?: BreakdownType | null): b'person','event','event_metadata',+ 'element','group','session','hogql',@@ -33,6 +34,7 @@ export function isBreakdownType(breakdownType?: string | null): breakdownType is'person','event','event_metadata',+ 'element','group','session','hogql',diff --git a/frontend/src/scenes/insights/utils.test.ts b/frontend/src/scenes/insights/utils.test.tsindex c57943657e71..b6c773a768eb 100644--- a/frontend/src/scenes/insights/utils.test.ts+++ b/frontend/src/scenes/insights/utils.test.ts@@ -316,6 +316,18 @@ describe('formatBreakdownLabel()', () => {expect(formatBreakdownLabel(42, breakdownFilter, [], identity)).toEqual('42')})+ it('skips property-definition formatting for digit-only element breakdown values', () => {+ // element breakdowns (tag_name/text/href) have no matching property definition, so+ // propertyFilterTypeToPropertyDefinitionType falls back to Event. A same-named+ // DateTime/Duration event property must not reformat a numeric-looking element value.+ const reformatsAsDate = (): any => '2020-01-01'+ const breakdownFilter: BreakdownFilter = {+ breakdown: 'text',+ breakdown_type: 'element',+ }+ expect(formatBreakdownLabel('123', breakdownFilter, [], reformatsAsDate)).toEqual('123')+ })+it('handles numeric breakdowns for "other" value', () => {const breakdownFilter: BreakdownFilter = {breakdown: 'coolness_factor',diff --git a/frontend/src/scenes/insights/utils.tsx b/frontend/src/scenes/insights/utils.tsxindex 1b8bbc2dc7be..ce670716bbdc 100644--- a/frontend/src/scenes/insights/utils.tsx+++ b/frontend/src/scenes/insights/utils.tsx@@ -310,7 +310,16 @@ function formatNumericBreakdownLabel(return BREAKDOWN_NULL_DISPLAY}- if (formatPropertyValueForDisplay) {+ const breakdownType = (+ typeof multipleBreakdownIndex === 'number'+ ? breakdownFilter?.breakdowns?.[multipleBreakdownIndex]?.type+ : breakdownFilter?.breakdown_type+ ) as string | undefined++ // Element breakdown values (tag_name, text, href) have no matching property definition — the type+ // falls back to Event, so a same-named DateTime/Duration event property would otherwise reformat+ // a numeric-looking element value into a date or duration.+ if (formatPropertyValueForDisplay && breakdownType !== 'element') {const nestedBreakdown =typeof multipleBreakdownIndex === 'number'? breakdownFilter?.breakdowns?.[multipleBreakdownIndex]diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex 316cc0af9039..7e74375ec9c8 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -3146,6 +3146,7 @@ export type BreakdownType =| 'person'| 'event'| 'event_metadata'+ | 'element'| 'group'| 'session'| 'hogql'diff --git a/posthog/hogql/property.py b/posthog/hogql/property.pyindex bb417a31b283..95cc9b9eb627 100644--- a/posthog/hogql/property.py+++ b/posthog/hogql/property.py@@ -1860,6 +1860,29 @@ def tag_name_to_expr(tag_name: str):return expr+def element_property_key_to_breakdown_expr(key: str) -> ast.Expr:+ """Map an element property filter key to the breakdown column expression for the same key.++ Keep this in sync with the element branch of `property_to_expr`: a breakdown value must be a+ value the same key's filter can match, or a broken-down series and its actors query disagree.+ """+ if key == "href":+ # elements_chain_href is the first href in the chain, which is the innermost element with an href.+ return ast.Field(chain=["elements_chain_href"])+ if key == "text":+ # elements_chain_texts holds one entry per chain element that has a text, innermost first.+ # The filter matches on any entry, so the first entry is the deterministic innermost pick.+ return parse_expr("arrayElement(elements_chain_texts, 1)")+ if key == "tag_name":+ # The materialized elements_chain_elements column contains only interactive tags, while the+ # tag_name filter matches every tag in the chain. Extract the innermost tag directly so the+ # breakdown uses the same set of values as the filter.+ return parse_expr("extract(elements_chain, '(?:^|;)([A-Za-z][A-Za-z0-9_-]*)(?:[.]|$|:|;)')")+ # A selector filter is a regex over the whole chain, so there is no per-event value that a+ # selector breakdown could return without disagreeing with the filter.+ raise QueryError(f"Breakdown by element property '{key}' is not supported. Use 'tag_name', 'text', or 'href'.")++def selector_to_expr(selector_string: str):selector = Selector(selector_string, escape_slashes=False)exprs = []diff --git a/posthog/hogql/test/test_property.py b/posthog/hogql/test/test_property.pyindex 81fdcd4add25..aadaf283757d 100644--- a/posthog/hogql/test/test_property.py+++ b/posthog/hogql/test/test_property.py@@ -6,7 +6,7 @@ from posthog.test.base import APIBaseTest, BaseTest, _create_event, cleanup_matefrom unittest.mock import MagicMock, patchfrom django.conf import settings-from django.test import override_settings+from django.test import SimpleTestCase, override_settingsfrom parameterized import parameterized@@ -30,6 +30,7 @@ from posthog.hogql.printer.utils import prepare_and_print_astfrom posthog.hogql.property import (BEHAVIORAL_PROPERTY_FILTER_FLAG,action_to_expr,+ element_property_key_to_breakdown_expr,entity_to_expr,has_aggregation,map_virtual_properties,@@ -77,6 +78,19 @@ def field_parts_read_by(expr: ast.Expr) -> set[str]:return collector.parts+class TestElementBreakdownExpression(SimpleTestCase):+ def test_tag_name_breakdown_matches_bare_inner_tag(self):+ self.assertEqual(+ clear_locations(element_property_key_to_breakdown_expr("tag_name")),+ clear_locations(parse_expr("extract(elements_chain, '(?:^|;)([A-Za-z][A-Za-z0-9_-]*)(?:[.]|$|:|;)')")),+ )++ @parameterized.expand(["selector", "id", "garbage"])+ def test_unsupported_key_raises_query_error(self, key: str):+ with self.assertRaises(QueryError):+ element_property_key_to_breakdown_expr(key)++class TestProperty(BaseTest):maxDiff = Nonediff --git a/posthog/schema_enums.py b/posthog/schema_enums.pyindex 4f243d7094a7..900902f01299 100644--- a/posthog/schema_enums.py+++ b/posthog/schema_enums.py@@ -286,6 +286,7 @@ class AssistantEventMultipleBreakdownFilterType(StrEnum):PERSON = "person"EVENT = "event"EVENT_METADATA = "event_metadata"+ ELEMENT = "element"SESSION = "session"HOGQL = "hogql"COHORT = "cohort"@@ -713,6 +714,7 @@ class BreakdownType(StrEnum):PERSON = "person"EVENT = "event"EVENT_METADATA = "event_metadata"+ ELEMENT = "element"GROUP = "group"SESSION = "session"HOGQL = "hogql"@@ -2166,6 +2168,7 @@ class MultipleBreakdownType(StrEnum):PERSON = "person"EVENT = "event"EVENT_METADATA = "event_metadata"+ ELEMENT = "element"GROUP = "group"SESSION = "session"HOGQL = "hogql"diff --git a/products/customer_analytics/frontend/generated/api.schemas.ts b/products/customer_analytics/frontend/generated/api.schemas.tsindex 2c77b878d4e1..e2656618c6bb 100644--- a/products/customer_analytics/frontend/generated/api.schemas.ts+++ b/products/customer_analytics/frontend/generated/api.schemas.ts@@ -2106,6 +2106,7 @@ export const BreakdownTypeApi = {Person: 'person',Event: 'event',EventMetadata: 'event_metadata',+ Element: 'element',Group: 'group',Session: 'session',Hogql: 'hogql',@@ -2120,6 +2121,7 @@ export const MultipleBreakdownTypeApi = {Person: 'person',Event: 'event',EventMetadata: 'event_metadata',+ Element: 'element',Group: 'group',Session: 'session',Hogql: 'hogql',diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex e1a9b62520e3..c34f8f8ea013 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -1225,6 +1225,7 @@ export const BreakdownTypeApi = {Person: 'person',Event: 'event',EventMetadata: 'event_metadata',+ Element: 'element',Group: 'group',Session: 'session',Hogql: 'hogql',@@ -1239,6 +1240,7 @@ export const MultipleBreakdownTypeApi = {Person: 'person',Event: 'event',EventMetadata: 'event_metadata',+ Element: 'element',Group: 'group',Session: 'session',Hogql: 'hogql',diff --git a/products/endpoints/frontend/generated/api.schemas.ts b/products/endpoints/frontend/generated/api.schemas.tsindex 21ef677aad09..132f08591cf1 100644--- a/products/endpoints/frontend/generated/api.schemas.ts+++ b/products/endpoints/frontend/generated/api.schemas.ts@@ -587,6 +587,7 @@ export const BreakdownTypeApi = {Person: 'person',Event: 'event',EventMetadata: 'event_metadata',+ Element: 'element',Group: 'group',Session: 'session',Hogql: 'hogql',@@ -601,6 +602,7 @@ export const MultipleBreakdownTypeApi = {Person: 'person',Event: 'event',EventMetadata: 'event_metadata',+ Element: 'element',Group: 'group',Session: 'session',Hogql: 'hogql',diff --git a/products/experiments/backend/hogql_queries/experiment_query_runner.py b/products/experiments/backend/hogql_queries/experiment_query_runner.pyindex 9ab5c300a01f..0001727dfe4a 100644--- a/products/experiments/backend/hogql_queries/experiment_query_runner.py+++ b/products/experiments/backend/hogql_queries/experiment_query_runner.py@@ -403,6 +403,13 @@ class ExperimentQueryRunner(ExperimentResultsCacheMixin, QueryRunner):if len(breakdowns) > 3:raise ValidationError("Maximum of 3 breakdowns are supported for experiment metrics")+ if any(breakdown.type == "element" for breakdown in breakdowns):+ # BreakdownInjector has no element-specific expression, so an element breakdown would+ # silently fall back to reading the same-named event property instead.+ raise ValidationError(+ "Element breakdowns are not supported for experiment metrics. Use an event or person property instead."+ )+return breakdownsdef _ensure_exposures_precomputed(self, builder: ExperimentQueryBuilder) -> LazyComputationResult:diff --git a/products/experiments/backend/hogql_queries/test/experiment_query_runner/test_breakdown.py b/products/experiments/backend/hogql_queries/test/experiment_query_runner/test_breakdown.pyindex 43dabd39b3dd..fa541c45951e 100644--- a/products/experiments/backend/hogql_queries/test/experiment_query_runner/test_breakdown.py+++ b/products/experiments/backend/hogql_queries/test/experiment_query_runner/test_breakdown.py@@ -5,6 +5,8 @@ from posthog.test.base import _create_event, _create_person, flush_persons_and_efrom django.test import override_settings+from rest_framework.exceptions import ValidationError+from posthog.schema import (Breakdown,BreakdownFilter,@@ -1122,6 +1124,26 @@ class TestExperimentBreakdown(ExperimentQueryRunnerBaseTest):# Verify error message mentions too many itemsself.assertIn("at most 3 items", str(context.exception))+ def test_breakdown_validation_rejects_element_type(self):+ feature_flag = self.create_feature_flag()+ experiment = self.create_experiment(feature_flag=feature_flag)++ metric = ExperimentMeanMetric(+ source=EventsNode(event="purchase", math=ExperimentMetricMathType.SUM, math_property="amount"),+ breakdownFilter=BreakdownFilter(breakdowns=[Breakdown(property="text", type="element")]),+ )+ experiment_query = ExperimentQuery(+ experiment_id=experiment.id,+ kind="ExperimentQuery",+ metric=metric,+ )++ query_runner = ExperimentQueryRunner(query=experiment_query, team=self.team)+ with self.assertRaises(ValidationError) as context:+ query_runner._get_breakdowns_for_builder()++ self.assertIn("Element breakdowns are not supported", str(context.exception))+@time_machine.travel("2020-01-01T12:00:00Z", tick=False)@snapshot_clickhouse_queriesdef test_missing_variants_across_breakdown_combinations(self):diff --git a/products/product_analytics/backend/hogql_queries/retention/retention_query_runner.py b/products/product_analytics/backend/hogql_queries/retention/retention_query_runner.pyindex 707df424a4eb..ebebbca12920 100644--- a/products/product_analytics/backend/hogql_queries/retention/retention_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/retention/retention_query_runner.py@@ -59,6 +59,7 @@ from products.product_analytics.backend.hogql_queries.retention.retention_base_qfrom products.product_analytics.backend.hogql_queries.retention.retention_validation_rules import (DisallowBreakdownsWithDataWarehouse24HourWindows,DisallowCumulativeWith24HourWindows,+ DisallowElementBreakdowns,DisallowExcessiveIntervals,DisallowGroupAggregationWithDataWarehouse24HourWindows,DisallowPropertyAggregationWith24HourWindows,@@ -149,6 +150,7 @@ class RetentionQueryRunner(AnalyticsQueryRunner[RetentionQueryResponse]):def validators(self) -> Sequence[QueryValidationRule[RetentionQuery]]:return (DisallowCumulativeWith24HourWindows(),+ DisallowElementBreakdowns(),DisallowExcessiveIntervals(),DisallowBreakdownsWithDataWarehouse24HourWindows(),DisallowGroupAggregationWithDataWarehouse24HourWindows(),diff --git a/products/product_analytics/backend/hogql_queries/retention/retention_validation_rules.py b/products/product_analytics/backend/hogql_queries/retention/retention_validation_rules.pyindex 8d39953d1d54..c92adce8d641 100644--- a/products/product_analytics/backend/hogql_queries/retention/retention_validation_rules.py+++ b/products/product_analytics/backend/hogql_queries/retention/retention_validation_rules.py@@ -2,7 +2,7 @@ from typing import Protocol, castfrom rest_framework.exceptions import ValidationError-from posthog.schema import AggregationType, EntityType, RetentionQuery+from posthog.schema import AggregationType, BreakdownType, EntityType, RetentionQueryfrom posthog.hogql.constants import LimitContext, get_breakdown_limit_for_contextfrom posthog.hogql.database.database import Database@@ -50,6 +50,22 @@ class DisallowCumulativeWith24HourWindows:raise ValidationError("Cumulative retention is not supported for 24 hour windows.", code=self.code)+class DisallowElementBreakdowns:+ code = "retention_element_breakdowns_unsupported"++ def validate(self, context: QueryValidationContext[RetentionQuery]) -> None:+ breakdown_filter = context.query.breakdownFilter+ if breakdown_filter is None:+ return+ if breakdown_filter.breakdown_type == BreakdownType.ELEMENT or any(+ breakdown.type == "element" for breakdown in breakdown_filter.breakdowns or []+ ):+ raise ValidationError(+ "Element breakdowns are not supported for retention insights. Use an event or person property instead.",+ code=self.code,+ )++class DisallowBreakdownsWithDataWarehouse24HourWindows:"""The 24-hour-window builder resolves a data warehouse series without an events scan in its outer query,so breakdown expressions (which read events / person columns) have nothing to resolve against."""diff --git a/products/product_analytics/backend/hogql_queries/retention/test/test_retention_validation_rules.py b/products/product_analytics/backend/hogql_queries/retention/test/test_retention_validation_rules.pyindex e4c3c359d4d1..3a63f4da36bd 100644--- a/products/product_analytics/backend/hogql_queries/retention/test/test_retention_validation_rules.py+++ b/products/product_analytics/backend/hogql_queries/retention/test/test_retention_validation_rules.py@@ -1,12 +1,16 @@from posthog.test.base import BaseTestfrom unittest.mock import MagicMock+from django.test import SimpleTestCase+from parameterized import parameterizedfrom rest_framework.exceptions import ValidationErrorfrom posthog.schema import (AggregationType,+ Breakdown,BreakdownFilter,+ BreakdownType,DateRange,EntityType,RetentionFilter,@@ -26,12 +30,33 @@ from products.product_analytics.backend.hogql_queries.retention.retention_validaMAX_RETENTION_RESPONSE_CELLS,DisallowBreakdownsWithDataWarehouse24HourWindows,DisallowCumulativeWith24HourWindows,+ DisallowElementBreakdowns,DisallowGroupAggregationWithDataWarehouse24HourWindows,DisallowPropertyAggregationWith24HourWindows,RequireRetentionDataWarehouseEntitiesForCustomAggregationTarget,)+class TestElementBreakdownValidation(SimpleTestCase):+ @parameterized.expand(["single", "multiple"])+ def test_disallow_element_breakdowns(self, breakdown_shape: str) -> None:+ query = RetentionQuery(+ retentionFilter=RetentionFilter(),+ breakdownFilter=(+ BreakdownFilter(breakdown="text", breakdown_type=BreakdownType.ELEMENT)+ if breakdown_shape == "single"+ else BreakdownFilter(breakdowns=[Breakdown(property="text", type=BreakdownType.ELEMENT)])+ ),+ )+ context = QueryValidationContext(query=query, team=MagicMock(), user=None, runner=MagicMock())++ with self.assertRaises(ValidationError) as error:+ DisallowElementBreakdowns().validate(context)++ self.assertIn("Element breakdowns are not supported for retention insights.", str(error.exception))+ self.assertEqual(error.exception.get_codes(), [DisallowElementBreakdowns.code])++class TestRetentionValidationRules(BaseTest):def _context(self, query: RetentionQuery) -> QueryValidationContext:runner = MagicMock(query=query, team=self.team, user=None)diff --git a/products/product_analytics/backend/hogql_queries/trends/breakdown.py b/products/product_analytics/backend/hogql_queries/trends/breakdown.pyindex 281257e1412b..b466b6c72b5a 100644--- a/products/product_analytics/backend/hogql_queries/trends/breakdown.py+++ b/products/product_analytics/backend/hogql_queries/trends/breakdown.py@@ -18,7 +18,7 @@ from posthog.schema import (from posthog.hogql import astfrom posthog.hogql.constants import BREAKDOWN_VALUE_MAX_LENGTH, LimitContextfrom posthog.hogql.parser import parse_expr-from posthog.hogql.property import apply_path_cleaning+from posthog.hogql.property import apply_path_cleaning, element_property_key_to_breakdown_exprfrom posthog.hogql.timings import HogQLTimingsfrom posthog.clickhouse.query_tagging import tag_contains_user_hogql@@ -313,6 +313,8 @@ class Breakdown:tag_contains_user_hogql()if breakdown_type == "hogql" or breakdown_type == "event_metadata":left = strip_user_aliases(parse_expr(breakdown_value))+ elif breakdown_type == "element":+ left = element_property_key_to_breakdown_expr(breakdown_value)else:left = ast.Field(chain=get_properties_chain(@@ -428,6 +430,16 @@ class Breakdown:inner = strip_user_aliases(parse_expr(cast(str, value)))return ast.Alias(alias=alias, expr=self._get_breakdown_values_transform(inner))+ if breakdown_type == "element":+ return ast.Alias(+ alias=alias,+ expr=self._get_breakdown_values_transform(+ element_property_key_to_breakdown_expr(str(value)),+ normalize_url=normalize_url,+ path_cleaning=path_cleaning,+ ),+ )+properties_chain = get_properties_chain(breakdown_type=breakdown_type,breakdown_field=str(value),diff --git a/products/product_analytics/backend/hogql_queries/trends/test/test_trends.py b/products/product_analytics/backend/hogql_queries/trends/test/test_trends.pyindex ff08c213f39e..d2567380af9f 100644--- a/products/product_analytics/backend/hogql_queries/trends/test/test_trends.py+++ b/products/product_analytics/backend/hogql_queries/trends/test/test_trends.py@@ -57,6 +57,7 @@ from posthog.schema import (from posthog.clickhouse.client import sync_executefrom posthog.constants import TREND_FILTER_TYPE_EVENTS+from posthog.hogql_queries.utils.breakdowns import BREAKDOWN_NULL_STRING_LABELfrom posthog.models import Entity, Organization, Personfrom posthog.models.event.util import events_only_in_active_schemafrom posthog.models.group.util import create_group@@ -4395,6 +4396,83 @@ class TestTrends(ClickhouseTestMixin, APIBaseTest):self.assertEqual(response[0]["count"], 2)self.assertEqual(response[1]["count"], 1)+ def test_breakdown_by_element_property(self):+ PropertyDefinition.objects.create(+ team=self.team,+ name="text",+ property_type="Boolean",+ type=PropertyDefinition.Type.EVENT,+ )+ # One button and one link, each nested in a div, so the chains hold more than one+ # element and the innermost pick is exercised. The button appears twice.+ button_chain = (+ 'button.btn-primary:nth-child="1"nth-of-type="1"text="1";div.container:nth-child="0"nth-of-type="0"'+ )+ link_chain = 'a.nav-link:href="/pricing"nth-child="2"nth-of-type="1"text="Pricing";div.container:nth-child="0"nth-of-type="0"'+ self._create_event(+ team=self.team,+ event="$autocapture",+ distinct_id="p1",+ timestamp="2020-01-04T12:00:00Z",+ elements_chain=button_chain,+ )+ self._create_event(+ team=self.team,+ event="$autocapture",+ distinct_id="p2",+ timestamp="2020-01-04T12:00:00Z",+ elements_chain=link_chain,+ )+ self._create_event(+ team=self.team,+ event="$autocapture",+ distinct_id="p1",+ timestamp="2020-01-04T12:00:00Z",+ elements_chain=button_chain,+ )+ # An autocapture on a plain div has no text or href, but its tag name still belongs in+ # the tag breakdown.+ self._create_event(+ team=self.team,+ event="$autocapture",+ distinct_id="p2",+ timestamp="2020-01-04T12:00:00Z",+ elements_chain='div.container:nth-child="0"nth-of-type="0"',+ )++ with time_machine.travel("2020-01-04T13:01:01Z", tick=False):+ for breakdown, expected in [+ ("text", [("1", 2), ("Pricing", 1)]),+ ("tag_name", [("button", 2), ("a", 1), ("div", 1)]),+ # the null bucket sorts after every valued series, whatever the counts+ ("href", [("/pricing", 1), (BREAKDOWN_NULL_STRING_LABEL, 3)]),+ ]:+ response = self._run_query(+ TrendsQuery(+ breakdownFilter=BreakdownFilter(+ breakdown=breakdown,+ breakdown_type=BreakdownType.ELEMENT,+ ),+ dateRange=DateRange(+ date_from="-7d",+ ),+ interval=IntervalType.HOUR,+ series=[+ EventsNode(+ event="$autocapture",+ name="$autocapture",+ ),+ ],+ ),+ self.team,+ )++ self.assertEqual(+ [(series["label"], series["count"]) for series in response[: len(expected)]],+ expected,+ f"breakdown by element {breakdown}",+ )+@also_test_with_materialized_columns(verify_no_jsonextract=False)def test_interval_filtering_breakdown(self):self._create_events(use_time=True)diff --git a/products/product_analytics/backend/hogql_queries/trends/test/test_trends_persons.py b/products/product_analytics/backend/hogql_queries/trends/test/test_trends_persons.pyindex 94f96dc771b5..80f494b618ce 100644--- a/products/product_analytics/backend/hogql_queries/trends/test/test_trends_persons.py+++ b/products/product_analytics/backend/hogql_queries/trends/test/test_trends_persons.py@@ -357,6 +357,39 @@ class TestTrendsPersons(ClickhouseTestMixin, APIBaseTest):self.assertEqual(len(result), 0)+ def test_trends_element_breakdown_persons(self):+ _create_person(team_id=self.team.pk, distinct_ids=["person1"])+ _create_person(team_id=self.team.pk, distinct_ids=["person2"])+ _create_event(+ event="$autocapture",+ distinct_id="person1",+ timestamp="2023-05-01 12:00",+ team=self.team,+ elements_chain='button.btn-primary:nth-child="1"nth-of-type="1"text="Sign up";div.container:nth-child="0"nth-of-type="0"',+ )+ _create_event(+ event="$autocapture",+ distinct_id="person2",+ timestamp="2023-05-01 12:00",+ team=self.team,+ elements_chain='a.nav-link:href="/pricing"nth-child="2"nth-of-type="1"text="Pricing";div.container:nth-child="0"nth-of-type="0"',+ )+ source_query = TrendsQuery(+ series=[EventsNode(event="$autocapture")],+ dateRange=DateRange(date_from="-7d"),+ breakdownFilter=BreakdownFilter(breakdown="text", breakdown_type=BreakdownType.ELEMENT),+ )++ result = self._get_actors(trends_query=source_query, day="2023-05-01", breakdown="Sign up")++ self.assertEqual(len(result), 1)+ self.assertEqual(get_distinct_id(result[0]), "person1")++ result = self._get_actors(trends_query=source_query, day="2023-05-01", breakdown="Pricing")++ self.assertEqual(len(result), 1)+ self.assertEqual(get_distinct_id(result[0]), "person2")+def test_trends_person_breakdown_persons(self):self._create_events()source_query = TrendsQuery(diff --git a/products/product_analytics/backend/hogql_queries/trends/trends_query_runner.py b/products/product_analytics/backend/hogql_queries/trends/trends_query_runner.pyindex 15243c342aa7..fde78190b0ab 100644--- a/products/product_analytics/backend/hogql_queries/trends/trends_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/trends/trends_query_runner.py@@ -1240,7 +1240,7 @@ class TrendsQueryRunner(AnalyticsQueryRunner[TrendsQueryResponse]):breakdown_type: BreakdownType | MultipleBreakdownType | None,breakdown_group_type_index: int | None = None,):- if breakdown_type == "hogql" or breakdown_type == "cohort" or breakdown_type == "session":+ if breakdown_type in ("hogql", "cohort", "session", "element"):return Falseif breakdown_type == "person":diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.tsindex 98693ff8f00e..84fb533f3618 100644--- a/products/product_analytics/frontend/generated/api.schemas.ts+++ b/products/product_analytics/frontend/generated/api.schemas.ts@@ -239,6 +239,7 @@ export const BreakdownTypeApi = {Person: 'person',Event: 'event',EventMetadata: 'event_metadata',+ Element: 'element',Group: 'group',Session: 'session',Hogql: 'hogql',@@ -253,6 +254,7 @@ export const MultipleBreakdownTypeApi = {Person: 'person',Event: 'event',EventMetadata: 'event_metadata',+ Element: 'element',Group: 'group',Session: 'session',Hogql: 'hogql',diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 13a88e595ac3..c2450bbf6924 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -3167,6 +3167,7 @@ export namespace Schemas {Person: 'person',Event: 'event',EventMetadata: 'event_metadata',+ Element: 'element',Group: 'group',Session: 'session',Hogql: 'hogql',@@ -3182,6 +3183,7 @@ export namespace Schemas {Person: 'person',Event: 'event',EventMetadata: 'event_metadata',+ Element: 'element',Group: 'group',Session: 'session',Hogql: 'hogql',diff --git a/services/mcp/src/generated/endpoints/api.ts b/services/mcp/src/generated/endpoints/api.tsindex ff2040fa15ac..3b8d34035aca 100644--- a/services/mcp/src/generated/endpoints/api.ts+++ b/services/mcp/src/generated/endpoints/api.ts@@ -374,6 +374,7 @@ export const EndpointsRunCreateBody = () => zod.object({'person','event','event_metadata',+ 'element','group','session','hogql',@@ -401,6 +402,7 @@ export const EndpointsRunCreateBody = () => zod.object({'person','event','event_metadata',+ 'element','group','session','hogql',diff --git a/services/mcp/src/tools/generated/query-wrappers.ts b/services/mcp/src/tools/generated/query-wrappers.tsindex c5c5c1b42da7..37edff1cd3d9 100644--- a/services/mcp/src/tools/generated/query-wrappers.ts+++ b/services/mcp/src/tools/generated/query-wrappers.ts@@ -21,6 +21,7 @@ const AssistantEventMultipleBreakdownFilterType = z.enum(['person','event','event_metadata',+ 'element','session','hogql','cohort',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 780d62400b9d..d990b4dfea32 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@@ -126,6 +126,7 @@"person","event","event_metadata",+ "element","session","hogql","cohort",diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.jsonindex 8c364559f493..87a18bb44a87 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.json@@ -71,6 +71,7 @@"person","event","event_metadata",+ "element","session","hogql","cohort",