Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(insights): add first_time_for_group trends math (#80404)

posthog[bot]a1f39dfbac06
diff --git a/frontend/src/generated/core/api.schemas.ts b/frontend/src/generated/core/api.schemas.ts
index 0de6459eb400..71ce7aca0630 100644
--- a/frontend/src/generated/core/api.schemas.ts
+++ b/frontend/src/generated/core/api.schemas.ts
@@ -1052,6 +1052,14 @@ export const CountPerActorMathTypeApi = {
P99CountPerActor: 'p99_count_per_actor',
} as const
+export type GroupMathTypeApi = (typeof GroupMathTypeApi)[keyof typeof GroupMathTypeApi]
+
+export const GroupMathTypeApi = {
+ UniqueGroup: 'unique_group',
+ FirstTimeForGroup: 'first_time_for_group',
+ FirstMatchingEventForGroup: 'first_matching_event_for_group',
+} as const
+
export type ExperimentMetricMathTypeApi = (typeof ExperimentMetricMathTypeApi)[keyof typeof ExperimentMetricMathTypeApi]
export const ExperimentMetricMathTypeApi = {
@@ -1371,9 +1379,9 @@ export interface MarketingAnalyticsEventConversionGoalApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -1424,9 +1432,9 @@ export interface MarketingAnalyticsActionConversionGoalApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -1478,9 +1486,9 @@ export interface MarketingAnalyticsWarehouseConversionGoalApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index b770cff46da8..a701784be429 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -27242,7 +27242,7 @@
"type": "string"
},
"GroupMathType": {
- "const": "unique_group",
+ "enum": ["unique_group", "first_time_for_group", "first_matching_event_for_group"],
"type": "string"
},
"GroupNode": {
diff --git a/frontend/src/queries/validators.js b/frontend/src/queries/validators.js
index 78fe884cce1b..23f9e67d7690 100644
--- a/frontend/src/queries/validators.js
+++ b/frontend/src/queries/validators.js
@@ -7977,7 +7977,7 @@ const schema91 = {
],
type: 'string',
}
-const schema92 = { const: 'unique_group', type: 'string' }
+const schema92 = { enum: ['unique_group', 'first_time_for_group', 'first_matching_event_for_group'], type: 'string' }
const schema93 = { const: 'hogql', type: 'string' }
const schema94 = {
enum: ['total', 'sum', 'unique_session', 'min', 'max', 'avg', 'dau', 'unique_group', 'hogql'],
@@ -8174,13 +8174,19 @@ function validate94(data, { instancePath = '', parentData, parentDataProperty, r
}
errors++
}
- if ('unique_group' !== data) {
+ if (
+ !(
+ data === 'unique_group' ||
+ data === 'first_time_for_group' ||
+ data === 'first_matching_event_for_group'
+ )
+ ) {
const err9 = {
instancePath,
- schemaPath: '#/definitions/GroupMathType/const',
- keyword: 'const',
- params: { allowedValue: 'unique_group' },
- message: 'must be equal to constant',
+ schemaPath: '#/definitions/GroupMathType/enum',
+ keyword: 'enum',
+ params: { allowedValues: schema92.enum },
+ message: 'must be equal to one of the allowed values',
}
if (vErrors === null) {
vErrors = [err9]
diff --git a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/useMathSelectorOptions.test.tsx b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/useMathSelectorOptions.test.tsx
index 2c46b20e280c..66feb0872c0e 100644
--- a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/useMathSelectorOptions.test.tsx
+++ b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/useMathSelectorOptions.test.tsx
@@ -6,6 +6,8 @@ import { cleanup, render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { Provider } from 'kea'
+import { apiValueToMathType } from 'scenes/trends/mathsLogic'
+
import { useAvailableFeatures } from '~/mocks/features'
import { useMocks } from '~/mocks/jest'
import { groupsModel } from '~/models/groupsModel'
@@ -35,6 +37,21 @@ function ActiveActorLabel({
return <div data-attr="actor-label">{label as React.ReactNode}</div>
}
+function OptionValues({ math, mathGroupTypeIndex }: { math: string; mathGroupTypeIndex: number }): JSX.Element {
+ const [section] = useMathSelectorOptions({
+ math,
+ index: 0,
+ mathAvailability: MathAvailability.All,
+ onMathSelect: jest.fn(),
+ trendsDisplayCategory: null,
+ mathGroupTypeIndex,
+ })
+ const values = ('options' in section ? section.options : [])
+ .filter((o): o is typeof o & { value: string } => 'value' in o)
+ .map((o) => o.value)
+ return <div data-attr="option-values">{values.join(' ')}</div>
+}
+
describe('useMathSelectorOptions – active actor select', () => {
afterEach(cleanup)
@@ -55,6 +72,46 @@ describe('useMathSelectorOptions – active actor select', () => {
groupsModel.mount()
})
+ it.each([
+ [BaseMathType.FirstTimeForUser, 'first_time_for_group'],
+ [BaseMathType.FirstMatchingEventForUser, 'first_matching_event_for_group'],
+ ])('scoping %s to a group emits the group-indexed math type', async (mathType, groupMath) => {
+ const onMathSelect = jest.fn()
+
+ render(
+ <Provider>
+ <ActiveActorLabel mathType={mathType} onMathSelect={onMathSelect} />
+ </Provider>
+ )
+
+ await waitFor(() => {
+ expect(screen.getByTestId('actor-label').querySelector('button')).toBeInTheDocument()
+ })
+
+ const selectButton = screen.getByTestId('actor-label').querySelector('button')!
+
+ await userEvent.click(selectButton)
+ await userEvent.click(await screen.findByText('organizations'))
+ expect(onMathSelect).toHaveBeenCalledWith(0, `${groupMath}::0`)
+ })
+
+ // MathSelector sets its value from apiValueToMathType, so that value has to exist among the
+ // options or a saved series reopens with nothing selected.
+ it.each(['first_time_for_group', 'first_matching_event_for_group'])(
+ 'offers an option matching a saved %s series',
+ async (groupMath) => {
+ render(
+ <Provider>
+ <OptionValues math={groupMath} mathGroupTypeIndex={0} />
+ </Provider>
+ )
+
+ await waitFor(() => {
+ expect(screen.getByTestId('option-values')).toHaveTextContent(apiValueToMathType(groupMath, 0))
+ })
+ }
+ )
+
it.each([
[BaseMathType.WeeklyActiveUsers, 'weekly_active'],
[BaseMathType.MonthlyActiveUsers, 'monthly_active'],
diff --git a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/useMathSelectorOptions.tsx b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/useMathSelectorOptions.tsx
index f4e69e6dd1cd..dec0cd595116 100644
--- a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/useMathSelectorOptions.tsx
+++ b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/useMathSelectorOptions.tsx
@@ -36,13 +36,14 @@ function getActiveActor(
selectedMath: string,
math: string | undefined,
mathGroupTypeIndex: number | null | undefined,
- groupsMathDefinitions: Record<string, MathDefinition | undefined>
+ groupMathPrefix: string,
+ groupDefinitions: Record<string, MathDefinition | undefined>
): string {
if (mathGroupTypeIndex === undefined || mathGroupTypeIndex === null || selectedMath !== math) {
return 'users'
}
- const groupKey = `unique_group::${mathGroupTypeIndex}`
- const groupDef = groupsMathDefinitions[groupKey]
+ const groupKey = `${groupMathPrefix}::${mathGroupTypeIndex}`
+ const groupDef = groupDefinitions[groupKey]
return groupDef ? groupKey : 'users'
}
@@ -79,6 +80,8 @@ export function useMathSelectorOptions({
aggregationLabel,
groupsMathDefinitions,
+ firstTimeForGroupMathDefinitions,
+ firstMatchingEventForGroupMathDefinitions,
} = useValues(mathsLogic)
const [propertyMathTypeShown, setPropertyMathTypeShown] = useState<PropertyMathType>(
@@ -95,13 +98,31 @@ export function useMathSelectorOptions({
)
const [uniqueActorsShown, setUniqueActorsShown] = useState<string>(
- getActiveActor('unique_group', math, mathGroupTypeIndex, groupsMathDefinitions)
+ getActiveActor('unique_group', math, mathGroupTypeIndex, 'unique_group', groupsMathDefinitions)
)
const [weeklyActiveActorsShown, setWeeklyActiveActorsShown] = useState<string>(
- getActiveActor('weekly_active', math, mathGroupTypeIndex, groupsMathDefinitions)
+ getActiveActor('weekly_active', math, mathGroupTypeIndex, 'unique_group', groupsMathDefinitions)
)
const [monthlyActiveActorsShown, setMonthlyActiveActorsShown] = useState<string>(
- getActiveActor('monthly_active', math, mathGroupTypeIndex, groupsMathDefinitions)
+ getActiveActor('monthly_active', math, mathGroupTypeIndex, 'unique_group', groupsMathDefinitions)
+ )
+ const [firstTimeActorsShown, setFirstTimeActorsShown] = useState<string>(
+ getActiveActor(
+ 'first_time_for_group',
+ math,
+ mathGroupTypeIndex,
+ 'first_time_for_group',
+ firstTimeForGroupMathDefinitions
+ )
+ )
+ const [firstMatchingActorsShown, setFirstMatchingActorsShown] = useState<string>(
+ getActiveActor(
+ 'first_matching_event_for_group',
+ math,
+ mathGroupTypeIndex,
+ 'first_matching_event_for_group',
+ firstMatchingEventForGroupMathDefinitions
+ )
)
let definitions = staticMathDefinitions
@@ -408,6 +429,76 @@ export function useMathSelectorOptions({
weeklyActiveUsersIndex
)
}
+
+ // "First-ever occurrence" and "First occurrence matching filters" become "... for [users / <group>]"
+ // pickers, so first-occurrence math can be scoped to a group instead of a person.
+ const addFirstOccurrenceActorPicker = (
+ baseMathType: BaseMathType,
+ groupDefinitions: Record<string, MathDefinition | undefined>,
+ actorShown: string,
+ setActorShown: (value: string) => void
+ ): void => {
+ const optionIndex = options.findIndex((option) => 'value' in option && option.value === baseMathType)
+ if (optionIndex === -1) {
+ return
+ }
+ const baseOption = options[optionIndex] as LemonSelectOption<string>
+ const baseName = staticMathDefinitions[baseMathType]?.name ?? ''
+ const actorOptions = [
+ {
+ value: 'users',
+ label: 'users',
+ 'data-attr': `math-users-${index}`,
+ },
+ ...Object.entries(groupDefinitions)
+ .filter((entry): entry is [string, MathDefinition] => !!entry[1])
+ .map(([key]) => ({
+ value: key,
+ // these definitions' shortName carries the math ("first time for organizations") so
+ // insight summaries stay unambiguous, so derive the bare noun the picker needs
+ label: aggregationLabel(mathTypeToApiValues(key).math_group_type_index).plural,
+ 'data-attr': `math-${key}-${index}`,
+ })),
+ ]
+ const isUsers = actorShown === 'users'
+ options[optionIndex] = {
+ ...baseOption,
+ value: isUsers ? baseMathType : actorShown,
+ label: isUsers ? baseOption.label : `${baseName} for ${aggregationLabel(mathGroupTypeIndex).plural}`,
+ tooltip: isUsers ? baseOption.tooltip : groupDefinitions[actorShown]?.description,
+ labelInMenu: (
+ <div className="flex items-center gap-2">
+ <span>{baseName} for</span>
+ <LemonSelect
+ value={actorShown}
+ onClick={(e) => e.stopPropagation()}
+ size="small"
+ dropdownMatchSelectWidth={false}
+ optionTooltipPlacement="right"
+ onSelect={(value) => {
+ setActorShown(value as string)
+ onMathSelect(index, value === 'users' ? baseMathType : value)
+ }}
+ options={actorOptions}
+ />
+ </div>
+ ),
+ 'data-attr': `math-node-first-occurrence-${baseMathType}-${index}`,
+ }
+ }
+
+ addFirstOccurrenceActorPicker(
+ BaseMathType.FirstTimeForUser,
+ firstTimeForGroupMathDefinitions,
+ firstTimeActorsShown,
+ setFirstTimeActorsShown
+ )
+ addFirstOccurrenceActorPicker(
+ BaseMathType.FirstMatchingEventForUser,
+ firstMatchingEventForGroupMathDefinitions,
+ firstMatchingActorsShown,
+ setFirstMatchingActorsShown
+ )
}
if (
diff --git a/frontend/src/scenes/insights/insightVizDataLogic.ts b/frontend/src/scenes/insights/insightVizDataLogic.ts
index e45e39ad2fa7..7ba065c05f86 100644
--- a/frontend/src/scenes/insights/insightVizDataLogic.ts
+++ b/frontend/src/scenes/insights/insightVizDataLogic.ts
@@ -2507,7 +2507,12 @@ export const insightVizDataLogic = kea<insightVizDataLogicType>([
return (
querySource?.kind === NodeKind.TrendsQuery &&
querySource?.series?.some((s: { math?: string }) =>
- ['first_matching_event_for_user', 'first_time_for_user'].includes(s.math || '')
+ [
+ 'first_matching_event_for_user',
+ 'first_time_for_user',
+ 'first_matching_event_for_group',
+ 'first_time_for_group',
+ ].includes(s.math || '')
)
)
},
diff --git a/frontend/src/scenes/trends/mathsLogic.tsx b/frontend/src/scenes/trends/mathsLogic.tsx
index 6c0c952393f9..23c546652146 100644
--- a/frontend/src/scenes/trends/mathsLogic.tsx
+++ b/frontend/src/scenes/trends/mathsLogic.tsx
@@ -10,6 +10,7 @@ import {
CalendarHeatmapMathType,
CountPerActorMathType,
FunnelMathType,
+ GroupMathType,
HogQLMathType,
PropertyMathType,
} from '~/types'
@@ -419,15 +420,40 @@ export function mathTypeToApiValues(mathType: string): {
const mathGroupTypeIndex = mathGroupTypeIndexRaw !== undefined ? parseInt(mathGroupTypeIndexRaw) : NaN
return !isNaN(mathGroupTypeIndex) ? { math, math_group_type_index: mathGroupTypeIndex } : { math }
}
+/** Math types that are scoped to a group type and carry a `::<group_type_index>` suffix. */
+const GROUP_INDEXED_MATH_TYPES = new Set<string>([
+ GroupMathType.UniqueGroup,
+ GroupMathType.FirstTimeForGroup,
+ GroupMathType.FirstMatchingEventForGroup,
+])
+
/** Serialize a math selector value. Inverse of mathTypeToApiValues. */
export function apiValueToMathType(math: string | undefined, groupTypeIndex: number | null | undefined): MathType {
const assembledMath = math || BaseMathType.TotalCount
- if (math === 'unique_group') {
+ if (math !== undefined && GROUP_INDEXED_MATH_TYPES.has(math)) {
return `${assembledMath}::${groupTypeIndex}` as MathType
}
return assembledMath as MathType
}
+/** Builds one MathDefinition per group type in the project, keyed by `<math>::<group_type_index>`. */
+function groupMathDefinitionsByType(
+ math: GroupMathType,
+ groupTypes: Map<GroupTypeIndex, GroupType>,
+ aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun,
+ describe: (label: Noun) => Pick<MathDefinition, 'name' | 'shortName' | 'description'>
+): Partial<Record<string, MathDefinition>> {
+ return Object.fromEntries(
+ Array.from(groupTypes.values()).map((groupType) => {
+ const label = aggregationLabel(groupType.group_type_index)
+ return [
+ apiValueToMathType(math, groupType.group_type_index),
+ { ...describe(label), category: MathCategory.ActorCount } as MathDefinition,
+ ]
+ })
+ )
+}
+
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface mathsLogicValues {
featureFlags: FeatureFlagsSet // featureFlagLogic
@@ -436,6 +462,8 @@ export interface mathsLogicValues {
aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun // groupsModel
groupTypes: Map<GroupTypeIndex, GroupType> // groupsModel
calendarHeatmapMathDefinitions: Partial<Record<string, MathDefinition>>
+ firstMatchingEventForGroupMathDefinitions: Partial<Record<string, MathDefinition>>
+ firstTimeForGroupMathDefinitions: Partial<Record<string, MathDefinition>>
funnelMathDefinitions: Partial<Record<string, MathDefinition>>
groupsMathDefinitions: Partial<Record<string, MathDefinition>>
mathDefinitions: Partial<Record<string, MathDefinition>>
@@ -447,14 +475,24 @@ export interface mathsLogicValues {
export interface mathsLogicMeta {
__keaTypeGenInternalSelectorTypes: {
mathDefinitions: (
- groupsMathDefinitions: Partial<Record<string, MathDefinition>>
+ groupsMathDefinitions: Partial<Record<string, MathDefinition>>,
+ firstTimeForGroupMathDefinitions: Partial<Record<string, MathDefinition>>,
+ firstMatchingEventForGroupMathDefinitions: Partial<Record<string, MathDefinition>>
) => Partial<Record<string, MathDefinition>>
staticActorsOnlyMathDefinitions: (
staticMathDefinitions: Partial<Record<string, MathDefinition>>
) => Partial<Record<string, MathDefinition>>
groupsMathDefinitions: (
groupTypes: Map<GroupTypeIndex, GroupType>,
- aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun
+ aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun // groupsModel
+ ) => Partial<Record<string, MathDefinition>>
+ firstTimeForGroupMathDefinitions: (
+ groupTypes: Map<GroupTypeIndex, GroupType>,
+ aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun // groupsModel
+ ) => Partial<Record<string, MathDefinition>>
+ firstMatchingEventForGroupMathDefinitions: (
+ groupTypes: Map<GroupTypeIndex, GroupType>,
+ aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun // groupsModel
) => Partial<Record<string, MathDefinition>>
}
}
@@ -475,13 +513,21 @@ export const mathsLogic = kea<mathsLogicType>([
})),
selectors({
mathDefinitions: [
- (s) => [s.groupsMathDefinitions],
+ (s) => [
+ s.groupsMathDefinitions,
+ s.firstTimeForGroupMathDefinitions,
+ s.firstMatchingEventForGroupMathDefinitions,
+ ],
(
- groupsMathDefinitions: Partial<Record<string, MathDefinition>>
+ groupsMathDefinitions: Partial<Record<string, MathDefinition>>,
+ firstTimeForGroupMathDefinitions: Partial<Record<string, MathDefinition>>,
+ firstMatchingEventForGroupMathDefinitions: Partial<Record<string, MathDefinition>>
): Partial<Record<string, MathDefinition>> => {
const allMathDefinitions: Partial<Record<string, MathDefinition>> = {
...BASE_MATH_DEFINITIONS,
...groupsMathDefinitions,
+ ...firstTimeForGroupMathDefinitions,
+ ...firstMatchingEventForGroupMathDefinitions,
...PROPERTY_MATH_DEFINITIONS,
...COUNT_PER_ACTOR_MATH_DEFINITIONS,
...HOGQL_MATH_DEFINITIONS,
@@ -521,36 +567,63 @@ export const mathsLogic = kea<mathsLogicType>([
groupsMathDefinitions: [
(s) => [s.groupTypes, s.aggregationLabel],
(
- groupTypes: Map<import('~/types').GroupTypeIndex, import('~/types').GroupType>,
- aggregationLabel: (
- groupTypeIndex: number | null | undefined,
- deferToUserWording?: boolean
- ) => import('~/models/groupsModel').Noun
+ groupTypes: Map<GroupTypeIndex, GroupType>,
+ aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun
+ ): Partial<Record<string, MathDefinition>> =>
+ groupMathDefinitionsByType(GroupMathType.UniqueGroup, groupTypes, aggregationLabel, (label) => ({
+ name: label.plural,
+ shortName: label.plural,
+ description: (
+ <>
+ Number of unique {label.plural} who performed the event in the specified period.
+ <br />
+ <br />
+ <i>
+ Example: If 7 users in a single ${label.singular} perform an event 9 times in the given
+ period, it counts only as 1.
+ </i>
+ </>
+ ),
+ })),
+ ],
+ firstTimeForGroupMathDefinitions: [
+ (s) => [s.groupTypes, s.aggregationLabel],
+ (
+ groupTypes: Map<GroupTypeIndex, GroupType>,
+ aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun
+ ): Partial<Record<string, MathDefinition>> =>
+ groupMathDefinitionsByType(GroupMathType.FirstTimeForGroup, groupTypes, aggregationLabel, (label) => ({
+ name: `First-ever occurrence for ${label.plural}`,
+ shortName: `first time for ${label.plural}`,
+ description: (
+ <>
+ Finds the {label.singular}'s very first occurrence of this event type, then checks if it
+ matches your filters. If the first-ever event doesn't match your filters, the{' '}
+ {label.singular} is excluded.
+ </>
+ ),
+ })),
+ ],
+ firstMatchingEventForGroupMathDefinitions: [
+ (s) => [s.groupTypes, s.aggregationLabel],
+ (
+ groupTypes: Map<GroupTypeIndex, GroupType>,
+ aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun
): Partial<Record<string, MathDefinition>> =>
- Object.fromEntries(
- Array.from(groupTypes.values())
- .map((groupType) => [
- apiValueToMathType('unique_group', groupType.group_type_index),
- {
- name: `${aggregationLabel(groupType.group_type_index).plural}`,
- shortName: `${aggregationLabel(groupType.group_type_index).plural}`,
- description: (
- <>
- Number of unique {aggregationLabel(groupType.group_type_index).plural} who
- performed the event in the specified period.
- <br />
- <br />
- <i>
- Example: If 7 users in a single $
- {aggregationLabel(groupType.group_type_index).singular} perform an event 9
- times in the given period, it counts only as 1.
- </i>
- </>
- ),
- category: MathCategory.ActorCount,
- } as MathDefinition,
- ])
- .filter(Boolean)
+ groupMathDefinitionsByType(
+ GroupMathType.FirstMatchingEventForGroup,
+ groupTypes,
+ aggregationLabel,
+ (label) => ({
+ name: `First occurrence matching filters for ${label.plural}`,
+ shortName: `first matching event for ${label.plural}`,
+ description: (
+ <>
+ Finds the first time the {label.singular} performed this event type that also matches
+ your filters. Previous events that don't match are ignored.
+ </>
+ ),
+ })
),
],
}),
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index d2290bb0655e..4f82bacdad1a 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -5321,6 +5321,8 @@ export enum HogQLMathType {
}
export enum GroupMathType {
UniqueGroup = 'unique_group',
+ FirstTimeForGroup = 'first_time_for_group',
+ FirstMatchingEventForGroup = 'first_matching_event_for_group',
}
export enum ExperimentMetricMathType {
diff --git a/posthog/hogql_queries/insights/trends/aggregation_operations.py b/posthog/hogql_queries/insights/trends/aggregation_operations.py
index 34ee9e8b24f8..9e491cd2adde 100644
--- a/posthog/hogql_queries/insights/trends/aggregation_operations.py
+++ b/posthog/hogql_queries/insights/trends/aggregation_operations.py
@@ -6,6 +6,7 @@ from posthog.schema import (
ChartDisplayType,
DataWarehouseNode,
EventsNode,
+ GroupMathType,
GroupNode,
PropertyMathType,
)
@@ -27,6 +28,18 @@ from posthog.models.team.team import Team
DEFAULT_CURRENCY_VALUE = "USD"
DEFAULT_REVENUE_PROPERTY = "$revenue"
+# First-occurrence math, scoped to a person or a group. The `_for_group` variants group by `$group_N`
+# instead of `person_id`; see FirstTimeForUserEventsQueryAlternator.
+FIRST_TIME_FOR_GROUP_MATH_TYPES = frozenset(
+ {GroupMathType.FIRST_TIME_FOR_GROUP, GroupMathType.FIRST_MATCHING_EVENT_FOR_GROUP}
+)
+FIRST_TIME_EVER_MATH_TYPES = frozenset(
+ {BaseMathType.FIRST_TIME_FOR_USER, BaseMathType.FIRST_MATCHING_EVENT_FOR_USER} | FIRST_TIME_FOR_GROUP_MATH_TYPES
+)
+FIRST_MATCHING_EVENT_MATH_TYPES = frozenset(
+ {BaseMathType.FIRST_MATCHING_EVENT_FOR_USER, GroupMathType.FIRST_MATCHING_EVENT_FOR_GROUP}
+)
+
ALLOWED_SESSION_MATH_PROPERTIES = frozenset(
[
"$session_duration",
@@ -92,7 +105,7 @@ class AggregationOperations(DataWarehouseInsightQueryMixin):
ast.Constant(value=0),
],
)
- elif self.series.math == "total" or self.series.math == "first_time_for_user":
+ elif self.series.math in ("total", BaseMathType.FIRST_TIME_FOR_USER, GroupMathType.FIRST_TIME_FOR_GROUP):
return parse_expr("count()")
elif self.series.math == "dau":
# `weekly_active` and `monthly_active` turn into `dau` for intervals longer than their period, hence the
@@ -159,14 +172,7 @@ class AggregationOperations(DataWarehouseInsightQueryMixin):
return parse_expr(self._get_person_field())
def requires_query_orchestration(self) -> bool:
- math_to_return_true = [
- "weekly_active",
- "monthly_active",
- "first_time_for_user",
- "first_matching_event_for_user",
- ]
-
- return self.is_count_per_actor_variant() or self.series.math in math_to_return_true
+ return self.is_count_per_actor_variant() or self.is_active_users_math() or self.is_first_time_ever_math()
def _validate_session_property(self) -> str:
if not self.series.math_property:
@@ -215,10 +221,17 @@ class AggregationOperations(DataWarehouseInsightQueryMixin):
return self.series.math in ["weekly_active", "monthly_active"]
def is_first_time_ever_math(self):
- return self.series.math in {"first_time_for_user", "first_matching_event_for_user"}
+ return self.series.math in FIRST_TIME_EVER_MATH_TYPES
def is_first_matching_event(self):
- return self.series.math == "first_matching_event_for_user"
+ return self.series.math in FIRST_MATCHING_EVENT_MATH_TYPES
+
+ def first_time_math_group_type_index(self) -> int | None:
+ """Group type index to group the first-time subquery by, or None for person-scoped first-time math."""
+ if self.series.math in FIRST_TIME_FOR_GROUP_MATH_TYPES:
+ index = self.series.math_group_type_index
+ return int(index) if index is not None else None
+ return None
def get_outer_aggregation(self, field: ast.Expr, is_histogram_breakdown: bool = False) -> ast.Expr:
"""
@@ -730,6 +743,7 @@ class AggregationOperations(DataWarehouseInsightQueryMixin):
events_query = ast.SelectQuery(select=[])
parent_select = self._first_time_parent_query()
is_first_matching_event = self.is_first_matching_event()
+ math_group_type_index = self.first_time_math_group_type_index()
class QueryOrchestrator:
events_query_builder: FirstTimeForUserEventsQueryAlternator
@@ -744,6 +758,7 @@ class AggregationOperations(DataWarehouseInsightQueryMixin):
event_or_action_filter=event_name_filter,
ratio=sample_value,
is_first_matching_event=is_first_matching_event,
+ math_group_type_index=math_group_type_index,
)
self.parent_query_builder = QueryAlternator(parent_select)
diff --git a/posthog/hogql_queries/insights/trends/test/test_aggregation_operations.py b/posthog/hogql_queries/insights/trends/test/test_aggregation_operations.py
index aa0f199813fd..ac8fc337f7e9 100644
--- a/posthog/hogql_queries/insights/trends/test/test_aggregation_operations.py
+++ b/posthog/hogql_queries/insights/trends/test/test_aggregation_operations.py
@@ -9,6 +9,7 @@ from posthog.schema import (
CountPerActorMathType,
DataWarehouseNode,
EventsNode,
+ GroupMathType,
MathGroupTypeIndex,
PropertyMathType,
)
@@ -78,6 +79,10 @@ def test_all_cases_return(
[BaseMathType.MONTHLY_ACTIVE, True],
[BaseMathType.UNIQUE_SESSION, False],
[BaseMathType.FIRST_TIME_FOR_USER, True],
+ [BaseMathType.FIRST_MATCHING_EVENT_FOR_USER, True],
+ [GroupMathType.UNIQUE_GROUP, False],
+ [GroupMathType.FIRST_TIME_FOR_GROUP, True],
+ [GroupMathType.FIRST_MATCHING_EVENT_FOR_GROUP, True],
[PropertyMathType.AVG, False],
[PropertyMathType.SUM, False],
[PropertyMathType.MIN, False],
@@ -103,7 +108,7 @@ def test_requiring_query_orchestration(
BaseMathType,
PropertyMathType,
CountPerActorMathType,
- Literal["unique_group"],
+ GroupMathType,
Literal["hogql"],
],
result: bool,
diff --git a/posthog/hogql_queries/insights/trends/test/test_trends_actors_query_builder.py b/posthog/hogql_queries/insights/trends/test/test_trends_actors_query_builder.py
index 3ec9f498bfab..3c44895f6f07 100644
--- a/posthog/hogql_queries/insights/trends/test/test_trends_actors_query_builder.py
+++ b/posthog/hogql_queries/insights/trends/test/test_trends_actors_query_builder.py
@@ -16,6 +16,7 @@ from posthog.schema import (
DateRange,
EventPropertyFilter,
EventsNode,
+ GroupMathType,
GroupNode,
IntervalType,
MathGroupTypeIndex,
@@ -424,7 +425,14 @@ class TestTrendsActorsQueryBuilder(BaseTest):
)
def test_actor_id_expr_for_groups_math(self):
- maths = [BaseMathType.DAU, UNIQUE_GROUPS, BaseMathType.WEEKLY_ACTIVE, BaseMathType.MONTHLY_ACTIVE]
+ maths = [
+ BaseMathType.DAU,
+ UNIQUE_GROUPS,
+ BaseMathType.WEEKLY_ACTIVE,
+ BaseMathType.MONTHLY_ACTIVE,
+ GroupMathType.FIRST_TIME_FOR_GROUP,
+ GroupMathType.FIRST_MATCHING_EVENT_FOR_GROUP,
+ ]
for math in maths:
with self.subTest(math=math):
trends_query = default_query.model_copy(
diff --git a/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py b/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py
index 2bc29a2e6172..ab3b913ea2a2 100644
--- a/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py
+++ b/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py
@@ -41,6 +41,7 @@ from posthog.schema import (
EventPropertyFilter,
EventsNode,
FilterLogicalOperator,
+ GroupMathType,
GroupNode,
HogQLQueryModifiers,
InCohortVia,
@@ -5804,6 +5805,127 @@ class TestTrendsQueryRunner(ClickhouseTestMixin, APIBaseTest):
assert response.results[0]["count"] == 0
assert response.results[0]["data"] == [0, 0, 0, 0, 0]
+ @parameterized.expand(
+ [
+ # Full range: each group counted on the day of its first-ever pageview
+ ("2020-01-09", 4, [1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0]),
+ # Narrowed start drops groups whose first-ever pageview predates the range
+ ("2020-01-12", 2, [1, 0, 0, 1, 0, 0, 0, 0, 0]),
+ ]
+ )
+ def test_trends_math_first_time_for_group(self, date_from, expected_count, expected_data):
+ create_group_type_mapping_without_created_at(
+ team=self.team,
+ project_id=self.team.project_id,
+ group_type="organization",
+ group_type_index=0,
+ )
+ self._create_test_events_for_groups()
+ flush_persons_and_events()
+
+ response = self._run_trends_query(
+ date_from,
+ "2020-01-20",
+ IntervalType.DAY,
+ [
+ EventsNode(
+ event="$pageview",
+ math=GroupMathType.FIRST_TIME_FOR_GROUP,
+ math_group_type_index=MathGroupTypeIndex.NUMBER_0,
+ )
+ ],
+ TrendsFilter(display=ChartDisplayType.ACTIONS_LINE_GRAPH),
+ )
+
+ assert len(response.results) == 1
+ assert response.results[0]["count"] == expected_count
+ assert response.results[0]["data"] == expected_data
+
+ def test_trends_math_first_matching_event_for_group_applies_filter(self):
+ create_group_type_mapping_without_created_at(
+ team=self.team,
+ project_id=self.team.project_id,
+ group_type="organization",
+ group_type_index=0,
+ )
+ self._create_test_events_for_groups()
+ flush_persons_and_events()
+
+ # Only the group on Chrome (org:5) matches; it is counted on its first matching pageview (2020-01-11)
+ response = self._run_trends_query(
+ "2020-01-09",
+ "2020-01-20",
+ IntervalType.DAY,
+ [
+ EventsNode(
+ event="$pageview",
+ math=GroupMathType.FIRST_MATCHING_EVENT_FOR_GROUP,
+ math_group_type_index=MathGroupTypeIndex.NUMBER_0,
+ properties=[EventPropertyFilter(key="$browser", value="Chrome", operator=PropertyOperator.EXACT)],
+ )
+ ],
+ TrendsFilter(display=ChartDisplayType.ACTIONS_LINE_GRAPH),
+ )
+
+ assert len(response.results) == 1
+ assert response.results[0]["count"] == 1
+ assert response.results[0]["data"] == [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
+
+ def test_trends_math_first_time_for_group_ignores_events_without_a_group(self):
+ create_group_type_mapping_without_created_at(
+ team=self.team, project_id=self.team.project_id, group_type="organization", group_type_index=0
+ )
+ self._create_test_events_for_groups()
+ # An event with no group key must not count as a group of its own, on any day
+ _create_person(team_id=self.team.pk, distinct_ids=["no_group"])
+ for timestamp in ["2020-01-10T12:00:00Z", "2020-01-14T12:00:00Z"]:
+ _create_event(team=self.team, event="$pageview", distinct_id="no_group", timestamp=timestamp)
+ flush_persons_and_events()
+
+ response = self._run_trends_query(
+ "2020-01-09",
+ "2020-01-20",
+ IntervalType.DAY,
+ [
+ EventsNode(
+ event="$pageview",
+ math=GroupMathType.FIRST_TIME_FOR_GROUP,
+ math_group_type_index=MathGroupTypeIndex.NUMBER_0,
+ )
+ ],
+ TrendsFilter(display=ChartDisplayType.ACTIONS_LINE_GRAPH),
+ )
+
+ assert response.results[0]["count"] == 4
+ assert response.results[0]["data"] == [1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0]
+
+ def test_trends_math_first_time_for_group_actors_are_groups(self):
+ create_group_type_mapping_without_created_at(
+ team=self.team, project_id=self.team.project_id, group_type="organization", group_type_index=0
+ )
+ self._create_test_events_for_groups()
+ flush_persons_and_events()
+
+ query_runner = self._create_query_runner(
+ "2020-01-09",
+ "2020-01-20",
+ IntervalType.DAY,
+ [
+ EventsNode(
+ event="$pageview",
+ math=GroupMathType.FIRST_TIME_FOR_GROUP,
+ math_group_type_index=MathGroupTypeIndex.NUMBER_0,
+ )
+ ],
+ TrendsFilter(display=ChartDisplayType.ACTIONS_LINE_GRAPH),
+ )
+
+ # org:5's first-ever pageview is on 2020-01-11, so it is the only actor behind that day's count
+ actors_query = query_runner.to_actors_query(time_frame="2020-01-11", series_index=0)
+ result = execute_hogql_query(query=actors_query, team=self.team)
+
+ assert [str(row[0]) for row in result.results] == ["org:5"]
+
def test_trends_math_first_time_for_user_breakdowns_basic(self):
self._create_test_events()
flush_persons_and_events()
diff --git a/posthog/hogql_queries/insights/trends/trends_actors_query_builder.py b/posthog/hogql_queries/insights/trends/trends_actors_query_builder.py
index 30501eb07e06..af2bea75db97 100644
--- a/posthog/hogql_queries/insights/trends/trends_actors_query_builder.py
+++ b/posthog/hogql_queries/insights/trends/trends_actors_query_builder.py
@@ -232,6 +232,7 @@ class TrendsActorsQueryBuilder:
event_or_action_filter=self._event_or_action_where_expr(),
ratio=self._ratio_expr(),
is_first_matching_event=self.trends_aggregation_operations.is_first_matching_event(),
+ math_group_type_index=self.trends_aggregation_operations.first_time_math_group_type_index(),
)
query_builder.append_select(actor_col)
query_builder.extend_select(columns, aggregate=True)
diff --git a/posthog/hogql_queries/insights/trends/utils.py b/posthog/hogql_queries/insights/trends/utils.py
index 295245c9bb0e..f6a5169513d6 100644
--- a/posthog/hogql_queries/insights/trends/utils.py
+++ b/posthog/hogql_queries/insights/trends/utils.py
@@ -11,6 +11,7 @@ from posthog.schema import (
DataWarehouseNode,
EventsNode,
FilterLogicalOperator,
+ GroupMathType,
GroupNode,
MultipleBreakdownType,
)
@@ -18,8 +19,6 @@ from posthog.schema import (
from posthog.hogql import ast
from posthog.hogql.property import action_to_expr, property_to_expr
-from posthog.constants import UNIQUE_GROUPS
-
if TYPE_CHECKING:
from posthog.models import Team
@@ -60,7 +59,13 @@ def get_properties_chain(
def is_groups_math(series: Union[EventsNode, ActionsNode, DataWarehouseNode | GroupNode]) -> bool:
return (
- series.math in {BaseMathType.DAU, UNIQUE_GROUPS, BaseMathType.WEEKLY_ACTIVE, BaseMathType.MONTHLY_ACTIVE}
+ series.math
+ in {
+ BaseMathType.DAU,
+ BaseMathType.WEEKLY_ACTIVE,
+ BaseMathType.MONTHLY_ACTIVE,
+ *GroupMathType,
+ }
and series.math_group_type_index is not None
)
diff --git a/posthog/hogql_queries/insights/utils/aggregations.py b/posthog/hogql_queries/insights/utils/aggregations.py
index d0e2b0f4727b..9015386d2b76 100644
--- a/posthog/hogql_queries/insights/utils/aggregations.py
+++ b/posthog/hogql_queries/insights/utils/aggregations.py
@@ -67,10 +67,13 @@ class QueryAlternator:
class FirstTimeForUserEventsQueryAlternator(QueryAlternator):
"""
- A specialized QueryAlternator for building queries that identify the first time an event or action occurs for each user.
+ A specialized QueryAlternator for building queries that identify the first time an event or action occurs for each actor.
+
+ The actor is a person by default. When `math_group_type_index` is set, the actor is a group and the query
+ groups by `$group_N` instead of `person_id`.
This class extends the base QueryAlternator to build a query that:
- - Finds the minimum timestamp for `person_id` filtered by the event/action and right date range.
+ - Finds the minimum timestamp for the actor filtered by the event/action and right date range.
- Compares it with the minimum timestamp that satisfies general conditions like event/person properties and the left date range.
- Selects only those events where these two timestamps match.
"""
@@ -86,11 +89,13 @@ class FirstTimeForUserEventsQueryAlternator(QueryAlternator):
is_first_matching_event: bool = False,
filters_with_breakdown: ast.Expr | None = None,
dwh_config: FirstTimeForUserDataWarehouseConfig | None = None,
+ math_group_type_index: int | None = None,
):
self._filters = filters
self._filters_with_breakdown = filters_with_breakdown
self._is_first_matching_event = is_first_matching_event
self._dwh_config = dwh_config
+ self._math_group_type_index = math_group_type_index
query.select = self._select_expr(date_from)
query.select_from = self._select_from_expr(ratio)
query.where = self._where_expr(date_to, event_or_action_filter, self._matching_event_prefilter())
@@ -167,6 +172,8 @@ class FirstTimeForUserEventsQueryAlternator(QueryAlternator):
def _group_by_expr(self) -> list[ast.Expr]:
if self._dwh_config is not None:
return [self._dwh_config.group_by_expr]
+ if self._math_group_type_index is not None:
+ return [ast.Field(chain=[f"$group_{int(self._math_group_type_index)}"])]
return [ast.Field(chain=["person_id"])]
def _having_expr(self) -> ast.Expr:
diff --git a/posthog/hogql_queries/insights/utils/test/test_aggregations.py b/posthog/hogql_queries/insights/utils/test/test_aggregations.py
index 3adff9af156c..c38383f04971 100644
--- a/posthog/hogql_queries/insights/utils/test/test_aggregations.py
+++ b/posthog/hogql_queries/insights/utils/test/test_aggregations.py
@@ -136,6 +136,26 @@ class TestFirstTimeForUserEventsQueryAlternator:
assert query.select[1].expr.name == "minIf"
assert query.select[1].expr.args == [ast.Field(chain=["timestamp"]), ast.And(exprs=[date_from, filters])]
+ def test_group_by_person_id_by_default(self):
+ query = ast.SelectQuery(select=[])
+ date_from, date_to = parse_expr("1 = 1"), parse_expr("2 = 2")
+
+ FirstTimeForUserEventsQueryAlternator(query, date_from, date_to).build()
+
+ assert isinstance(query.group_by, list)
+ assert isinstance(query.group_by[0], ast.Field)
+ assert query.group_by[0].chain == ["person_id"]
+
+ def test_group_by_group_field_when_group_type_index_set(self):
+ query = ast.SelectQuery(select=[])
+ date_from, date_to = parse_expr("1 = 1"), parse_expr("2 = 2")
+
+ FirstTimeForUserEventsQueryAlternator(query, date_from, date_to, math_group_type_index=2).build()
+
+ assert isinstance(query.group_by, list)
+ assert isinstance(query.group_by[0], ast.Field)
+ assert query.group_by[0].chain == ["$group_2"]
+
def test_query_with_event_or_action_filter(self):
query = ast.SelectQuery(select=[])
date_from, date_to, event_filter = parse_expr("1 = 1"), parse_expr("2 = 2"), parse_expr("3 = 3")
diff --git a/posthog/schema.py b/posthog/schema.py
index 7c182d04c780..1bf8e899f6a7 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -123,6 +123,7 @@ from posthog.schema_enums import (
Goal as Goal,
GoogleAdsDefaultSources as GoogleAdsDefaultSources,
GradientScaleMode as GradientScaleMode,
+ GroupMathType as GroupMathType,
HeatmapSortOrder as HeatmapSortOrder,
HedgehogActorAccessoryOption as HedgehogActorAccessoryOption,
HedgehogActorColorOption as HedgehogActorColorOption,
@@ -9619,9 +9620,9 @@ class AssistantStickinessActionsNode(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = None
@@ -9680,9 +9681,9 @@ class AssistantStickinessEventsNode(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = None
@@ -9849,9 +9850,9 @@ class AssistantTrendsActionsNode(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = None
@@ -9912,9 +9913,9 @@ class AssistantTrendsEventsNode(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = None
@@ -9974,9 +9975,9 @@ class AssistantTrendsGroupNode(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = Field(
@@ -14764,9 +14765,9 @@ class ConversionGoalFilter1(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = None
@@ -14827,9 +14828,9 @@ class ConversionGoalFilter2(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = None
@@ -14892,9 +14893,9 @@ class ConversionGoalFilter3(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = None
@@ -15905,9 +15906,9 @@ class DataWarehouseNode(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = None
@@ -16278,9 +16279,9 @@ class EntityNode(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = None
@@ -16579,9 +16580,9 @@ class EventsNode(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = None
@@ -16757,9 +16758,9 @@ class ExperimentDataWarehouseNode(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = None
@@ -16884,9 +16885,9 @@ class FunnelExclusionActionsNode(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = None
@@ -16924,9 +16925,9 @@ class FunnelExclusionEventsNode(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = None
@@ -16965,9 +16966,9 @@ class FunnelsDataWarehouseNode(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = None
@@ -17333,9 +17334,9 @@ class LifecycleDataWarehouseNode(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = None
@@ -24407,9 +24408,9 @@ class ActionsNode(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = None
@@ -27100,9 +27101,9 @@ class GroupNode(BaseModel):
| FunnelMathType
| PropertyMathType
| CountPerActorMathType
+ | GroupMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
| Literal["hogql"]
| None
) = None
diff --git a/posthog/schema_enums.py b/posthog/schema_enums.py
index b11926ac3ba4..62832d3931fc 100644
--- a/posthog/schema_enums.py
+++ b/posthog/schema_enums.py
@@ -2722,6 +2722,12 @@ class GoogleAdsDefaultSources(StrEnum):
WAZE = "waze"
+class GroupMathType(StrEnum):
+ UNIQUE_GROUP = "unique_group"
+ FIRST_TIME_FOR_GROUP = "first_time_for_group"
+ FIRST_MATCHING_EVENT_FOR_GROUP = "first_matching_event_for_group"
+
+
class GradientScaleMode(StrEnum):
ABSOLUTE = "absolute"
RELATIVE = "relative"
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index 9fdd0c4fb2f3..0c2d4a3b3530 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -1740,6 +1740,14 @@ export const CountPerActorMathTypeApi = {
P99CountPerActor: 'p99_count_per_actor',
} as const
+export type GroupMathTypeApi = (typeof GroupMathTypeApi)[keyof typeof GroupMathTypeApi]
+
+export const GroupMathTypeApi = {
+ UniqueGroup: 'unique_group',
+ FirstTimeForGroup: 'first_time_for_group',
+ FirstMatchingEventForGroup: 'first_matching_event_for_group',
+} as const
+
export type ExperimentMetricMathTypeApi = (typeof ExperimentMetricMathTypeApi)[keyof typeof ExperimentMetricMathTypeApi]
export const ExperimentMetricMathTypeApi = {
@@ -1974,9 +1982,9 @@ export interface EventsNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -2061,9 +2069,9 @@ export interface ActionsNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -2149,9 +2157,9 @@ export interface DataWarehouseNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -2236,9 +2244,9 @@ export interface GroupNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -2638,9 +2646,9 @@ export interface FunnelExclusionEventsNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -2727,9 +2735,9 @@ export interface FunnelExclusionActionsNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -2927,9 +2935,9 @@ export interface FunnelsDataWarehouseNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -3803,9 +3811,9 @@ export interface LifecycleDataWarehouseNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -5810,9 +5818,9 @@ export interface ExperimentDataWarehouseNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -6971,9 +6979,9 @@ export interface ConversionGoalFilter1Api {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -7067,9 +7075,9 @@ export interface ConversionGoalFilter2Api {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -7164,9 +7172,9 @@ export interface ConversionGoalFilter3Api {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
diff --git a/products/experiments/backend/hogql_queries/base_query_utils.py b/products/experiments/backend/hogql_queries/base_query_utils.py
index 7d54388665f2..06a6d4854402 100644
--- a/products/experiments/backend/hogql_queries/base_query_utils.py
+++ b/products/experiments/backend/hogql_queries/base_query_utils.py
@@ -17,6 +17,7 @@ from posthog.schema import (
ExperimentRatioMetric,
FunnelConversionWindowTimeUnit,
FunnelMathType,
+ GroupMathType,
PropertyMathType,
)
@@ -90,7 +91,7 @@ def is_continuous(
| CountPerActorMathType
| ExperimentMetricMathType
| CalendarHeatmapMathType
- | Literal["unique_group"]
+ | GroupMathType
| Literal["hogql"]
| None,
) -> bool:
diff --git a/products/marketing_analytics/frontend/generated/api.schemas.ts b/products/marketing_analytics/frontend/generated/api.schemas.ts
index 91854b025207..60988f06eefb 100644
--- a/products/marketing_analytics/frontend/generated/api.schemas.ts
+++ b/products/marketing_analytics/frontend/generated/api.schemas.ts
@@ -437,6 +437,14 @@ export const CountPerActorMathTypeApi = {
P99CountPerActor: 'p99_count_per_actor',
} as const
+export type GroupMathTypeApi = (typeof GroupMathTypeApi)[keyof typeof GroupMathTypeApi]
+
+export const GroupMathTypeApi = {
+ UniqueGroup: 'unique_group',
+ FirstTimeForGroup: 'first_time_for_group',
+ FirstMatchingEventForGroup: 'first_matching_event_for_group',
+} as const
+
export type ExperimentMetricMathTypeApi = (typeof ExperimentMetricMathTypeApi)[keyof typeof ExperimentMetricMathTypeApi]
export const ExperimentMetricMathTypeApi = {
@@ -679,9 +687,9 @@ export interface ConversionGoalFilter1Api {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -775,9 +783,9 @@ export interface ConversionGoalFilter2Api {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -872,9 +880,9 @@ export interface ConversionGoalFilter3Api {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -990,9 +998,9 @@ export interface PartialConversionGoalFilter1Api {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -1083,9 +1091,9 @@ export interface PartialConversionGoalFilter2Api {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -1178,9 +1186,9 @@ export interface PartialConversionGoalFilter3Api {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
diff --git a/products/product_analytics/backend/api/insight_metadata.py b/products/product_analytics/backend/api/insight_metadata.py
index c4188b5e0442..9d0d194974c8 100644
--- a/products/product_analytics/backend/api/insight_metadata.py
+++ b/products/product_analytics/backend/api/insight_metadata.py
@@ -54,6 +54,9 @@ _MATH_LABELS: dict[str, str] = {
"monthly_active": "monthly active users",
"unique_session": "unique sessions",
"first_time_for_user": "first time users",
+ "first_time_for_group": "first time groups",
+ "first_matching_event_for_user": "first matching event for users",
+ "first_matching_event_for_group": "first matching event for groups",
"avg_count_per_actor": "avg count per user",
"min_count_per_actor": "min count per user",
"max_count_per_actor": "max count per user",
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index 186a5ac5e58d..d8bc97451060 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -999,6 +999,14 @@ export const CountPerActorMathTypeApi = {
P99CountPerActor: 'p99_count_per_actor',
} as const
+export type GroupMathTypeApi = (typeof GroupMathTypeApi)[keyof typeof GroupMathTypeApi]
+
+export const GroupMathTypeApi = {
+ UniqueGroup: 'unique_group',
+ FirstTimeForGroup: 'first_time_for_group',
+ FirstMatchingEventForGroup: 'first_matching_event_for_group',
+} as const
+
export type ExperimentMetricMathTypeApi = (typeof ExperimentMetricMathTypeApi)[keyof typeof ExperimentMetricMathTypeApi]
export const ExperimentMetricMathTypeApi = {
@@ -1233,9 +1241,9 @@ export interface EventsNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -1320,9 +1328,9 @@ export interface ActionsNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -1408,9 +1416,9 @@ export interface DataWarehouseNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -1495,9 +1503,9 @@ export interface GroupNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -1897,9 +1905,9 @@ export interface FunnelExclusionEventsNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -1986,9 +1994,9 @@ export interface FunnelExclusionActionsNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -2186,9 +2194,9 @@ export interface FunnelsDataWarehouseNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -3062,9 +3070,9 @@ export interface LifecycleDataWarehouseNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -5069,9 +5077,9 @@ export interface ExperimentDataWarehouseNodeApi {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -6230,9 +6238,9 @@ export interface ConversionGoalFilter1Api {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -6326,9 +6334,9 @@ export interface ConversionGoalFilter2Api {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
@@ -6423,9 +6431,9 @@ export interface ConversionGoalFilter3Api {
| FunnelMathTypeApi
| PropertyMathTypeApi
| CountPerActorMathTypeApi
+ | GroupMathTypeApi
| ExperimentMetricMathTypeApi
| CalendarHeatmapMathTypeApi
- | 'unique_group'
| 'hogql'
| null
math_group_type_index?: MathGroupTypeIndexApi | null
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 2e9813fc63c1..c887d8484c7b 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -2027,6 +2027,15 @@ export namespace Schemas {
P99CountPerActor: 'p99_count_per_actor',
} as const;
+ export type GroupMathType = typeof GroupMathType[keyof typeof GroupMathType];
+
+
+ export const GroupMathType = {
+ UniqueGroup: 'unique_group',
+ FirstTimeForGroup: 'first_time_for_group',
+ FirstMatchingEventForGroup: 'first_matching_event_for_group',
+ } as const;
+
export type ExperimentMetricMathType = typeof ExperimentMetricMathType[keyof typeof ExperimentMetricMathType];
@@ -2230,7 +2239,7 @@ export namespace Schemas {
fixedProperties?: (EventPropertyFilter | PersonPropertyFilter | PersonMetadataPropertyFilter | ElementPropertyFilter | EventMetadataPropertyFilter | SessionPropertyFilter | CohortPropertyFilter | RecordingPropertyFilter | LogEntryPropertyFilter | GroupPropertyFilter | FeaturePropertyFilter | FlagPropertyFilter | HogQLPropertyFilter | EmptyPropertyFilter | DataWarehousePropertyFilter | DataWarehousePersonPropertyFilter | ErrorTrackingIssueFilter | LogPropertyFilter | MetricPropertyFilter | SpanPropertyFilter | RevenueAnalyticsPropertyFilter | AccountCustomPropertyFilter | WorkflowVariablePropertyFilter)[] | null;
id: number;
kind?: 'ActionsNode';
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
@@ -2911,7 +2920,7 @@ export namespace Schemas {
fixedProperties?: (EventPropertyFilter | PersonPropertyFilter | PersonMetadataPropertyFilter | ElementPropertyFilter | EventMetadataPropertyFilter | SessionPropertyFilter | CohortPropertyFilter | RecordingPropertyFilter | LogEntryPropertyFilter | GroupPropertyFilter | FeaturePropertyFilter | FlagPropertyFilter | HogQLPropertyFilter | EmptyPropertyFilter | DataWarehousePropertyFilter | DataWarehousePersonPropertyFilter | ErrorTrackingIssueFilter | LogPropertyFilter | MetricPropertyFilter | SpanPropertyFilter | RevenueAnalyticsPropertyFilter | AccountCustomPropertyFilter | WorkflowVariablePropertyFilter)[] | null;
kind?: 'EventsNode';
limit?: number | null;
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
@@ -2940,7 +2949,7 @@ export namespace Schemas {
id: string;
id_field: string;
kind?: 'DataWarehouseNode';
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
@@ -2966,7 +2975,7 @@ export namespace Schemas {
fixedProperties?: (EventPropertyFilter | PersonPropertyFilter | PersonMetadataPropertyFilter | ElementPropertyFilter | EventMetadataPropertyFilter | SessionPropertyFilter | CohortPropertyFilter | RecordingPropertyFilter | LogEntryPropertyFilter | GroupPropertyFilter | FeaturePropertyFilter | FlagPropertyFilter | HogQLPropertyFilter | EmptyPropertyFilter | DataWarehousePropertyFilter | DataWarehousePersonPropertyFilter | ErrorTrackingIssueFilter | LogPropertyFilter | MetricPropertyFilter | SpanPropertyFilter | RevenueAnalyticsPropertyFilter | AccountCustomPropertyFilter | WorkflowVariablePropertyFilter)[] | null;
kind?: 'GroupNode';
limit?: number | null;
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
@@ -3278,7 +3287,7 @@ export namespace Schemas {
funnelToStep: number;
kind?: 'EventsNode';
limit?: number | null;
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
@@ -3306,7 +3315,7 @@ export namespace Schemas {
funnelToStep: number;
id: number;
kind?: 'ActionsNode';
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
@@ -3449,7 +3458,7 @@ export namespace Schemas {
id: string;
id_field: string;
kind?: 'FunnelsDataWarehouseNode';
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
@@ -4114,7 +4123,7 @@ export namespace Schemas {
fixedProperties?: (EventPropertyFilter | PersonPropertyFilter | PersonMetadataPropertyFilter | ElementPropertyFilter | EventMetadataPropertyFilter | SessionPropertyFilter | CohortPropertyFilter | RecordingPropertyFilter | LogEntryPropertyFilter | GroupPropertyFilter | FeaturePropertyFilter | FlagPropertyFilter | HogQLPropertyFilter | EmptyPropertyFilter | DataWarehousePropertyFilter | DataWarehousePersonPropertyFilter | ErrorTrackingIssueFilter | LogPropertyFilter | MetricPropertyFilter | SpanPropertyFilter | RevenueAnalyticsPropertyFilter | AccountCustomPropertyFilter | WorkflowVariablePropertyFilter)[] | null;
id: string;
kind?: 'LifecycleDataWarehouseNode';
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
@@ -4562,7 +4571,7 @@ export namespace Schemas {
/** Fixed properties in the query, can't be edited in the interface (e.g. scoping down by person) */
fixedProperties?: (EventPropertyFilter | PersonPropertyFilter | PersonMetadataPropertyFilter | ElementPropertyFilter | EventMetadataPropertyFilter | SessionPropertyFilter | CohortPropertyFilter | RecordingPropertyFilter | LogEntryPropertyFilter | GroupPropertyFilter | FeaturePropertyFilter | FlagPropertyFilter | HogQLPropertyFilter | EmptyPropertyFilter | DataWarehousePropertyFilter | DataWarehousePersonPropertyFilter | ErrorTrackingIssueFilter | LogPropertyFilter | MetricPropertyFilter | SpanPropertyFilter | RevenueAnalyticsPropertyFilter | AccountCustomPropertyFilter | WorkflowVariablePropertyFilter)[] | null;
kind?: 'ExperimentDataWarehouseNode';
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
@@ -7201,7 +7210,7 @@ export namespace Schemas {
fixedProperties?: (EventPropertyFilter | PersonPropertyFilter | PersonMetadataPropertyFilter | ElementPropertyFilter | EventMetadataPropertyFilter | SessionPropertyFilter | CohortPropertyFilter | RecordingPropertyFilter | LogEntryPropertyFilter | GroupPropertyFilter | FeaturePropertyFilter | FlagPropertyFilter | HogQLPropertyFilter | EmptyPropertyFilter | DataWarehousePropertyFilter | DataWarehousePersonPropertyFilter | ErrorTrackingIssueFilter | LogPropertyFilter | MetricPropertyFilter | SpanPropertyFilter | RevenueAnalyticsPropertyFilter | AccountCustomPropertyFilter | WorkflowVariablePropertyFilter)[] | null;
kind?: 'EventsNode';
limit?: number | null;
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
@@ -7236,7 +7245,7 @@ export namespace Schemas {
fixedProperties?: (EventPropertyFilter | PersonPropertyFilter | PersonMetadataPropertyFilter | ElementPropertyFilter | EventMetadataPropertyFilter | SessionPropertyFilter | CohortPropertyFilter | RecordingPropertyFilter | LogEntryPropertyFilter | GroupPropertyFilter | FeaturePropertyFilter | FlagPropertyFilter | HogQLPropertyFilter | EmptyPropertyFilter | DataWarehousePropertyFilter | DataWarehousePersonPropertyFilter | ErrorTrackingIssueFilter | LogPropertyFilter | MetricPropertyFilter | SpanPropertyFilter | RevenueAnalyticsPropertyFilter | AccountCustomPropertyFilter | WorkflowVariablePropertyFilter)[] | null;
id: number;
kind?: 'ActionsNode';
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
@@ -7272,7 +7281,7 @@ export namespace Schemas {
id: string;
id_field: string;
kind?: 'DataWarehouseNode';
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
@@ -16990,7 +16999,7 @@ export namespace Schemas {
fixedProperties?: (EventPropertyFilter | PersonPropertyFilter | PersonMetadataPropertyFilter | ElementPropertyFilter | EventMetadataPropertyFilter | SessionPropertyFilter | CohortPropertyFilter | RecordingPropertyFilter | LogEntryPropertyFilter | GroupPropertyFilter | FeaturePropertyFilter | FlagPropertyFilter | HogQLPropertyFilter | EmptyPropertyFilter | DataWarehousePropertyFilter | DataWarehousePersonPropertyFilter | ErrorTrackingIssueFilter | LogPropertyFilter | MetricPropertyFilter | SpanPropertyFilter | RevenueAnalyticsPropertyFilter | AccountCustomPropertyFilter | WorkflowVariablePropertyFilter)[] | null;
kind?: 'EventsNode' | null;
limit?: number | null;
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
@@ -17022,7 +17031,7 @@ export namespace Schemas {
fixedProperties?: (EventPropertyFilter | PersonPropertyFilter | PersonMetadataPropertyFilter | ElementPropertyFilter | EventMetadataPropertyFilter | SessionPropertyFilter | CohortPropertyFilter | RecordingPropertyFilter | LogEntryPropertyFilter | GroupPropertyFilter | FeaturePropertyFilter | FlagPropertyFilter | HogQLPropertyFilter | EmptyPropertyFilter | DataWarehousePropertyFilter | DataWarehousePersonPropertyFilter | ErrorTrackingIssueFilter | LogPropertyFilter | MetricPropertyFilter | SpanPropertyFilter | RevenueAnalyticsPropertyFilter | AccountCustomPropertyFilter | WorkflowVariablePropertyFilter)[] | null;
id?: number | null;
kind?: 'ActionsNode' | null;
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
@@ -17056,7 +17065,7 @@ export namespace Schemas {
id?: string | null;
id_field?: string | null;
kind?: 'DataWarehouseNode' | null;
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
@@ -44834,7 +44843,7 @@ export namespace Schemas {
custom_name?: string | null;
id: number;
kind: 'ActionsNode';
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
@@ -44879,7 +44888,7 @@ export namespace Schemas {
event?: string | null;
kind: 'EventsNode';
limit?: number | null;
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
@@ -44917,7 +44926,7 @@ export namespace Schemas {
id: string;
id_field: string;
kind: 'DataWarehouseNode';
- math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'unique_group' | 'hogql' | null;
+ math?: BaseMathType | FunnelMathType | PropertyMathType | CountPerActorMathType | GroupMathType | ExperimentMetricMathType | CalendarHeatmapMathType | 'hogql' | null;
math_group_type_index?: MathGroupTypeIndex | null;
math_hogql?: string | null;
math_multiplier?: number | null;
diff --git a/services/mcp/src/generated/core/api.ts b/services/mcp/src/generated/core/api.ts
index 3fe456546848..34e263836268 100644
--- a/services/mcp/src/generated/core/api.ts
+++ b/services/mcp/src/generated/core/api.ts
@@ -521,6 +521,11 @@ export const OrganizationsProjectsPartialUpdateBody = /* @__PURE__ */ zod
'p95_count_per_actor',
'p99_count_per_actor',
]),
+ zod.enum([
+ 'unique_group',
+ 'first_time_for_group',
+ 'first_matching_event_for_group',
+ ]),
zod.enum([
'total',
'sum',
@@ -533,7 +538,6 @@ export const OrganizationsProjectsPartialUpdateBody = /* @__PURE__ */ zod
'hogql',
]),
zod.enum(['total', 'dau']),
- zod.literal('unique_group'),
zod.literal('hogql'),
zod.null(),
])
@@ -1153,6 +1157,11 @@ export const OrganizationsProjectsPartialUpdateBody = /* @__PURE__ */ zod
'p95_count_per_actor',
'p99_count_per_actor',
]),
+ zod.enum([
+ 'unique_group',
+ 'first_time_for_group',
+ 'first_matching_event_for_group',
+ ]),
zod.enum([
'total',
'sum',
@@ -1165,7 +1174,6 @@ export const OrganizationsProjectsPartialUpdateBody = /* @__PURE__ */ zod
'hogql',
]),
zod.enum(['total', 'dau']),
- zod.literal('unique_group'),
zod.literal('hogql'),
zod.null(),
])
@@ -1784,6 +1792,11 @@ export const OrganizationsProjectsPartialUpdateBody = /* @__PURE__ */ zod
'p95_count_per_actor',
'p99_count_per_actor',
]),
+ zod.enum([
+ 'unique_group',
+ 'first_time_for_group',
+ 'first_matching_event_for_group',
+ ]),
zod.enum([
'total',
'sum',
@@ -1796,7 +1809,6 @@ export const OrganizationsProjectsPartialUpdateBody = /* @__PURE__ */ zod
'hogql',
]),
zod.enum(['total', 'dau']),
- zod.literal('unique_group'),
zod.literal('hogql'),
zod.null(),
])
diff --git a/services/mcp/src/generated/marketing_analytics/api.ts b/services/mcp/src/generated/marketing_analytics/api.ts
index be36c8148238..0a648a529868 100644
--- a/services/mcp/src/generated/marketing_analytics/api.ts
+++ b/services/mcp/src/generated/marketing_analytics/api.ts
@@ -1473,6 +1473,7 @@ export const MarketingAnalyticsConversionGoalsUpdatePartialUpdateBody = /* @__PU
'p95_count_per_actor',
'p99_count_per_actor',
]),
+ zod.enum(['unique_group', 'first_time_for_group', 'first_matching_event_for_group']),
zod.enum([
'total',
'sum',
@@ -1485,7 +1486,6 @@ export const MarketingAnalyticsConversionGoalsUpdatePartialUpdateBody = /* @__PU
'hogql',
]),
zod.enum(['total', 'dau']),
- zod.literal('unique_group'),
zod.literal('hogql'),
zod.null(),
])
@@ -4187,6 +4187,7 @@ export const MarketingAnalyticsConversionGoalsUpdatePartialUpdateBody = /* @__PU
'p95_count_per_actor',
'p99_count_per_actor',
]),
+ zod.enum(['unique_group', 'first_time_for_group', 'first_matching_event_for_group']),
zod.enum([
'total',
'sum',
@@ -4199,7 +4200,6 @@ export const MarketingAnalyticsConversionGoalsUpdatePartialUpdateBody = /* @__PU
'hogql',
]),
zod.enum(['total', 'dau']),
- zod.literal('unique_group'),
zod.literal('hogql'),
zod.null(),
])
@@ -6903,6 +6903,7 @@ export const MarketingAnalyticsConversionGoalsUpdatePartialUpdateBody = /* @__PU
'p95_count_per_actor',
'p99_count_per_actor',
]),
+ zod.enum(['unique_group', 'first_time_for_group', 'first_matching_event_for_group']),
zod.enum([
'total',
'sum',
@@ -6915,7 +6916,6 @@ export const MarketingAnalyticsConversionGoalsUpdatePartialUpdateBody = /* @__PU
'hogql',
]),
zod.enum(['total', 'dau']),
- zod.literal('unique_group'),
zod.literal('hogql'),
zod.null(),
])
@@ -9806,6 +9806,7 @@ export const MarketingAnalyticsConversionGoalsCreateCreateBody = /* @__PURE__ */
'p95_count_per_actor',
'p99_count_per_actor',
]),
+ zod.enum(['unique_group', 'first_time_for_group', 'first_matching_event_for_group']),
zod.enum([
'total',
'sum',
@@ -9818,7 +9819,6 @@ export const MarketingAnalyticsConversionGoalsCreateCreateBody = /* @__PURE__ */
'hogql',
]),
zod.enum(['total', 'dau']),
- zod.literal('unique_group'),
zod.literal('hogql'),
zod.null(),
])
@@ -12524,6 +12524,7 @@ export const MarketingAnalyticsConversionGoalsCreateCreateBody = /* @__PURE__ */
'p95_count_per_actor',
'p99_count_per_actor',
]),
+ zod.enum(['unique_group', 'first_time_for_group', 'first_matching_event_for_group']),
zod.enum([
'total',
'sum',
@@ -12536,7 +12537,6 @@ export const MarketingAnalyticsConversionGoalsCreateCreateBody = /* @__PURE__ */
'hogql',
]),
zod.enum(['total', 'dau']),
- zod.literal('unique_group'),
zod.literal('hogql'),
zod.null(),
])
@@ -15241,6 +15241,7 @@ export const MarketingAnalyticsConversionGoalsCreateCreateBody = /* @__PURE__ */
'p95_count_per_actor',
'p99_count_per_actor',
]),
+ zod.enum(['unique_group', 'first_time_for_group', 'first_matching_event_for_group']),
zod.enum([
'total',
'sum',
@@ -15253,7 +15254,6 @@ export const MarketingAnalyticsConversionGoalsCreateCreateBody = /* @__PURE__ */
'hogql',
]),
zod.enum(['total', 'dau']),
- zod.literal('unique_group'),
zod.literal('hogql'),
zod.null(),
])
diff --git a/services/mcp/src/tools/generated/query-wrappers.ts b/services/mcp/src/tools/generated/query-wrappers.ts
index 0fe19c9ba582..36fe077aac5f 100644
--- a/services/mcp/src/tools/generated/query-wrappers.ts
+++ b/services/mcp/src/tools/generated/query-wrappers.ts
@@ -362,7 +362,7 @@ const CountPerActorMathType = z.enum([
'p99_count_per_actor',
])
-const GroupMathType = z.literal('unique_group')
+const GroupMathType = z.enum(['unique_group', 'first_time_for_group', 'first_matching_event_for_group'])
const HogQLMathType = z.literal('hogql')
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/project-settings-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/project-settings-update.json
index 5050b790fed0..c51239253256 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/project-settings-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/project-settings-update.json
@@ -617,6 +617,14 @@
],
"type": "string"
},
+ {
+ "enum": [
+ "unique_group",
+ "first_time_for_group",
+ "first_matching_event_for_group"
+ ],
+ "type": "string"
+ },
{
"enum": [
"total",
@@ -635,10 +643,6 @@
"enum": ["total", "dau"],
"type": "string"
},
- {
- "const": "unique_group",
- "type": "string"
- },
{
"const": "hogql",
"type": "string"
@@ -1645,6 +1649,14 @@
],
"type": "string"
},
+ {
+ "enum": [
+ "unique_group",
+ "first_time_for_group",
+ "first_matching_event_for_group"
+ ],
+ "type": "string"
+ },
{
"enum": [
"total",
@@ -1663,10 +1675,6 @@
"enum": ["total", "dau"],
"type": "string"
},
- {
- "const": "unique_group",
- "type": "string"
- },
{
"const": "hogql",
"type": "string"
@@ -2676,6 +2684,14 @@
],
"type": "string"
},
+ {
+ "enum": [
+ "unique_group",
+ "first_time_for_group",
+ "first_matching_event_for_group"
+ ],
+ "type": "string"
+ },
{
"enum": [
"total",
@@ -2694,10 +2710,6 @@
"enum": ["total", "dau"],
"type": "string"
},
- {
- "const": "unique_group",
- "type": "string"
- },
{
"const": "hogql",
"type": "string"
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness-actors.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness-actors.json
index 37b531b64c27..f7d9034a22e2 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness-actors.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness-actors.json
@@ -694,7 +694,11 @@
"type": "string"
},
{
- "const": "unique_group",
+ "enum": [
+ "unique_group",
+ "first_time_for_group",
+ "first_matching_event_for_group"
+ ],
"type": "string"
},
{
@@ -1360,7 +1364,11 @@
"type": "string"
},
{
- "const": "unique_group",
+ "enum": [
+ "unique_group",
+ "first_time_for_group",
+ "first_matching_event_for_group"
+ ],
"type": "string"
},
{
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness.json
index 730288df853d..766f6f652016 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness.json
@@ -633,7 +633,11 @@
"type": "string"
},
{
- "const": "unique_group",
+ "enum": [
+ "unique_group",
+ "first_time_for_group",
+ "first_matching_event_for_group"
+ ],
"type": "string"
},
{
@@ -1265,7 +1269,11 @@
"type": "string"
},
{
- "const": "unique_group",
+ "enum": [
+ "unique_group",
+ "first_time_for_group",
+ "first_matching_event_for_group"
+ ],
"type": "string"
},
{
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.json
index 4d0a87e386cd..5e4113ee5493 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
@@ -777,7 +777,11 @@
"type": "string"
},
{
- "const": "unique_group",
+ "enum": [
+ "unique_group",
+ "first_time_for_group",
+ "first_matching_event_for_group"
+ ],
"type": "string"
},
{
@@ -1450,7 +1454,11 @@
"type": "string"
},
{
- "const": "unique_group",
+ "enum": [
+ "unique_group",
+ "first_time_for_group",
+ "first_matching_event_for_group"
+ ],
"type": "string"
},
{
@@ -2120,7 +2128,11 @@
"type": "string"
},
{
- "const": "unique_group",
+ "enum": [
+ "unique_group",
+ "first_time_for_group",
+ "first_matching_event_for_group"
+ ],
"type": "string"
},
{
@@ -2264,7 +2276,11 @@
"type": "string"
},
{
- "const": "unique_group",
+ "enum": [
+ "unique_group",
+ "first_time_for_group",
+ "first_matching_event_for_group"
+ ],
"type": "string"
},
{
@@ -3036,7 +3052,11 @@
"type": "string"
},
{
- "const": "unique_group",
+ "enum": [
+ "unique_group",
+ "first_time_for_group",
+ "first_matching_event_for_group"
+ ],
"type": "string"
},
{
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.json
index 39e1b471ce63..e9322816ab6f 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.json
@@ -706,7 +706,11 @@
"type": "string"
},
{
- "const": "unique_group",
+ "enum": [
+ "unique_group",
+ "first_time_for_group",
+ "first_matching_event_for_group"
+ ],
"type": "string"
},
{
@@ -1345,7 +1349,11 @@
"type": "string"
},
{
- "const": "unique_group",
+ "enum": [
+ "unique_group",
+ "first_time_for_group",
+ "first_matching_event_for_group"
+ ],
"type": "string"
},
{
@@ -1981,7 +1989,11 @@
"type": "string"
},
{
- "const": "unique_group",
+ "enum": [
+ "unique_group",
+ "first_time_for_group",
+ "first_matching_event_for_group"
+ ],
"type": "string"
},
{
@@ -2125,7 +2137,11 @@
"type": "string"
},
{
- "const": "unique_group",
+ "enum": [
+ "unique_group",
+ "first_time_for_group",
+ "first_matching_event_for_group"
+ ],
"type": "string"
},
{
@@ -2872,7 +2888,11 @@
"type": "string"
},
{
- "const": "unique_group",
+ "enum": [
+ "unique_group",
+ "first_time_for_group",
+ "first_matching_event_for_group"
+ ],
"type": "string"
},
{