: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
refactor(settings): edit settings and config series as query nodes (#115946)
Thomas Obermüller55ff2009ab2f
diff --git a/frontend/src/scenes/settings/environment/CoreEventsSettings.tsx b/frontend/src/scenes/settings/environment/CoreEventsSettings.tsxindex 1135c0b554af..bcf20db50279 100644--- a/frontend/src/scenes/settings/environment/CoreEventsSettings.tsx+++ b/frontend/src/scenes/settings/environment/CoreEventsSettings.tsx@@ -7,10 +7,11 @@ import { LemonButton, LemonInput, LemonLabel, LemonModal, LemonSelect, LemonTextimport { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'import { LemonTable } from 'lib/lemon-ui/LemonTable'import { uuid } from 'lib/utils/dom'-import { ActionFilter as ActionFilterComponent } from 'scenes/insights/filters/ActionFilter/ActionFilter'+import { SeriesActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter'import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'+import { cleanSeriesNodes } from 'scenes/insights/filters/ActionFilter/cleanSeriesNodes'+import { SeriesNode } from 'scenes/insights/filters/ActionFilter/seriesNode'-import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'import {ActionsNode,CoreEvent,@@ -19,14 +20,7 @@ import {EventsNode,NodeKind,} from '~/queries/schema/schema-general'-import {- ActionFilter,- BaseMathType,- AnyDataWarehouseFilter,- FilterType,- GroupMathType,- PropertyMathType,-} from '~/types'+import { BaseMathType, ChartDisplayCategory, GroupMathType, PropertyMathType } from '~/types'import { coreEventsLogic } from './coreEventsLogic'@@ -79,83 +73,6 @@ function getFilterSummary(filter: EventsNode | ActionsNode | DataWarehouseNode):}}-// Convert ActionFilter format to our filter node format-function actionFilterToNode(filters: FilterType): EventsNode | ActionsNode | DataWarehouseNode | null {- const series = actionsAndEventsToSeries(- {- actions: filters.actions as ActionFilter[] | undefined,- events: filters.events as ActionFilter[] | undefined,- data_warehouse: filters.data_warehouse as AnyDataWarehouseFilter[] | undefined,- },- true,- MathAvailability.All- )-- if (series.length > 0) {- return series[0] as EventsNode | ActionsNode | DataWarehouseNode- }- return null-}--// Convert our filter node to ActionFilter format for the picker-function nodeToActionFilter(filter: EventsNode | ActionsNode | DataWarehouseNode | null): Partial<FilterType> {- if (!filter) {- return { events: [], actions: [], data_warehouse: [] }- }-- switch (filter.kind) {- case NodeKind.EventsNode:- return {- events: [- {- id: filter.event || null,- name: filter.name,- type: 'events',- math: filter.math || BaseMathType.TotalCount,- math_property: filter.math_property,- properties: filter.properties,- } as ActionFilter,- ],- actions: [],- data_warehouse: [],- }- case NodeKind.ActionsNode:- return {- events: [],- actions: [- {- id: filter.id,- name: filter.name,- type: 'actions',- math: filter.math || BaseMathType.TotalCount,- math_property: filter.math_property,- properties: filter.properties,- } as ActionFilter,- ],- data_warehouse: [],- }- case NodeKind.DataWarehouseNode:- return {- events: [],- actions: [],- data_warehouse: [- {- id: filter.table_name,- name: filter.name || filter.table_name,- type: 'data_warehouse',- math: filter.math || BaseMathType.TotalCount,- math_property: filter.math_property,- id_field: filter.id_field,- timestamp_field: filter.timestamp_field,- distinct_id_field: filter.distinct_id_field,- } as ActionFilter,- ],- }- default:- return { events: [], actions: [], data_warehouse: [] }- }-}-const defaultFilter: EventsNode = {kind: NodeKind.EventsNode,event: 'Please select an event, action, or data warehouse table',@@ -209,8 +126,9 @@ export function CoreEventsSettings(): JSX.Element {setFormState(createEmptyFormState())}- const handleFilterChange = (filters: Partial<FilterType>): void => {- const node = actionFilterToNode(filters as FilterType)+ const handleSeriesChange = (series: SeriesNode[]): void => {+ // The picker offers events, actions and data warehouse tables only, and cannot combine them.+ const [node] = cleanSeriesNodes(series, MathAvailability.All) as CoreEvent['filter'][]if (node) {setFormState((prev) => ({...prev,@@ -265,9 +183,6 @@ export function CoreEventsSettings(): JSX.Element {const disabledReason = getDisabledReason()- // Build filter for ActionFilterComponent- const currentFilter = nodeToActionFilter(formState.filter)-return (<div className="space-y-4"><div className="flex justify-between items-center">@@ -371,10 +286,11 @@ export function CoreEventsSettings(): JSX.Element {<div className="space-y-1"><LemonLabel>Event, action, or data warehouse table</LemonLabel>- <ActionFilterComponent+ <SeriesActionFilterbordered- filters={currentFilter}- setFilters={handleFilterChange}+ series={[formState.filter]}+ onChange={handleSeriesChange}+ trendsDisplayCategory={ChartDisplayCategory.TimeSeries}typeKey="core-events-settings"mathAvailability={MathAvailability.All}allowedMathTypes={ALLOWED_MATH_TYPES}diff --git a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/common/ConversionGoalDropdown.tsx b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/common/ConversionGoalDropdown.tsxindex 81d4c0a7f47f..f08494ffa213 100644--- a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/common/ConversionGoalDropdown.tsx+++ b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/common/ConversionGoalDropdown.tsx@@ -1,27 +1,15 @@import { useState } from 'react'import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'-import { ActionFilter as ActionFilterComponent } from 'scenes/insights/filters/ActionFilter/ActionFilter'+import { SeriesActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter'import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'+import { isEventsSeriesNode } from 'scenes/insights/filters/ActionFilter/seriesNode'-import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'-import {- ActionsNode,- ConversionGoalFilter,- DataWarehouseNode,- EventsNode,- NodeKind,-} from '~/queries/schema/schema-general'-import { isDataWarehouseNode } from '~/queries/utils'-import {- ConversionGoalSchema,- DISTINCT_ID_FIELD_SCHEMA_FIELD,- TIMESTAMP_FIELD_SCHEMA_FIELD,- UTM_CAMPAIGN_NAME_SCHEMA_FIELD,- UTM_SOURCE_NAME_SCHEMA_FIELD,-} from '~/taxonomy/marketingAnalytics'+import { ConversionGoalFilter } from '~/queries/schema/schema-general'import { conversionGoalPopoverFields } from '~/taxonomy/taxonomy'-import { ActionFilter, BaseMathType, AnyDataWarehouseFilter, EntityTypes, FilterType, PropertyMathType } from '~/types'+import { BaseMathType, ChartDisplayCategory, PropertyMathType } from '~/types'++import { conversionGoalToSeries, seriesToConversionGoal } from '../../logic/utils'interface ConversionGoalDropdownProps {value: ConversionGoalFilter@@ -38,53 +26,17 @@ export function ConversionGoalDropdown({}: ConversionGoalDropdownProps): JSX.Element {const [error, setError] = useState<string | null>(null)- // Create a proper ActionFilter-compatible filter object- const currentFilter = {- events:- value.kind === NodeKind.EventsNode && !hasDataWarehouseType(value)- ? [- {- ...value,- type: 'events',- id: (value as EventsNode).event || '',- math: value.math || BaseMathType.TotalCount,- },- ]- : [],- actions:- value.kind === NodeKind.ActionsNode- ? [- {- ...value,- type: 'actions',- id: (value as ActionsNode).id || '',- math: value.math || BaseMathType.TotalCount,- },- ]- : [],- data_warehouse:- value.kind === NodeKind.DataWarehouseNode || hasDataWarehouseType(value)- ? [- {- ...value,- type: 'data_warehouse',- id: isDataWarehouseNode(value) ? value.table_name : (value as any).table_name || '',- math: value.math || BaseMathType.TotalCount,- },- ]- : [],- }-return (<div>- <ActionFilterComponent+ <SeriesActionFilterborderedallowedMathTypes={[BaseMathType.TotalCount, BaseMathType.UniqueUsers, PropertyMathType.Sum]}- filters={currentFilter}+ series={conversionGoalToSeries(value)}+ trendsDisplayCategory={ChartDisplayCategory.TimeSeries}mathAvailability={MathAvailability.All}- setFilters={({ actions, events, data_warehouse }: Partial<FilterType>): void => {+ onChange={(series) => {// Check if user is trying to select "All Events"- if (events?.[0]?.id === null || events?.[0]?.id === '') {+ if (isEventsSeriesNode(series[0]) && !series[0].event) {setError('`All events` cannot be used as a conversion goal. Please select a specific event.')return}@@ -92,83 +44,10 @@ export function ConversionGoalDropdown({// Clear any previous errorssetError(null)- const series = actionsAndEventsToSeries(- {- actions: actions as ActionFilter[] | undefined,- events: events as ActionFilter[] | undefined,- data_warehouse: data_warehouse as AnyDataWarehouseFilter[] | undefined,- },- true,- MathAvailability.All- )-- const firstSerie = series[0] || value-- const newFilter: ConversionGoalFilter = {- ...value,- ...firstSerie,- // Preserve the existing schema to keep UTM mappings- schema_map: {- ...value.schema_map,- },- properties: firstSerie?.properties || [], // if we clear the filter we need the properties to be set to an empty array- }-- // Clean up ActionsNode: remove event field and ensure id is a number- if (newFilter.kind === NodeKind.ActionsNode) {- if ('event' in newFilter) {- delete (newFilter as any).event- }- // Ensure id is a number for ActionsNode (actions always have numeric IDs)- if ('id' in newFilter) {- const numId = parseInt(String((newFilter as any).id), 10)- if (!isNaN(numId)) {- ;(newFilter as any).id = numId- }- }- }-- // Clean up EventsNode: remove id field (EventsNode uses event, not id)- if (newFilter.kind === NodeKind.EventsNode) {- if ('id' in newFilter) {- delete (newFilter as any).id- }+ const goal = seriesToConversionGoal(value, series)+ if (goal) {+ onChange(goal)}-- // Override the schema with the schema from the data warehouse- if (data_warehouse?.[0]?.type === EntityTypes.DATA_WAREHOUSE) {- const dwNode = data_warehouse[0] as AnyDataWarehouseFilter &- Record<ConversionGoalSchema, string> &- Partial<Pick<DataWarehouseNode, 'id_field' | 'dw_source_type'>>- const schema = dwNode- const overrideSchema: Record<ConversionGoalSchema, string> = {- utm_campaign_name: schema[UTM_CAMPAIGN_NAME_SCHEMA_FIELD],- utm_source_name: schema[UTM_SOURCE_NAME_SCHEMA_FIELD],- timestamp_field: schema[TIMESTAMP_FIELD_SCHEMA_FIELD],- distinct_id_field: schema[DISTINCT_ID_FIELD_SCHEMA_FIELD],- }- newFilter.schema_map = overrideSchema-- // Cast to DataWarehouseNode for type safety- const dwFilter = newFilter as DataWarehouseNode & ConversionGoalFilter- // Remove the event field that causes validation to fail- if ('event' in dwFilter) {- delete (dwFilter as any).event- }-- dwFilter.kind = NodeKind.DataWarehouseNode-- // Set all required ConversionGoalFilter3 fields- dwFilter.id = dwNode.table_name || String(dwNode.id) || ''- dwFilter.id_field = dwNode.id_field || schema[DISTINCT_ID_FIELD_SCHEMA_FIELD] || 'id'- dwFilter.distinct_id_field =- dwNode.distinct_id_field || schema[DISTINCT_ID_FIELD_SCHEMA_FIELD] || 'distinct_id'- dwFilter.table_name = dwNode.table_name || ''- dwFilter.timestamp_field =- dwNode.timestamp_field || schema[TIMESTAMP_FIELD_SCHEMA_FIELD] || 'timestamp'- dwFilter.dw_source_type = dwNode.dw_source_type- }- onChange(newFilter)}}typeKey={typeKey}showSeriesIndicator={false}@@ -190,8 +69,3 @@ export function ConversionGoalDropdown({</div>)}--// Helper function to check if value has data warehouse type field-function hasDataWarehouseType(val: ConversionGoalFilter): boolean {- return 'type' in val && (val as any).type === 'data_warehouse'-}diff --git a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/utils.test.ts b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/utils.test.tsindex ef08e4f8d4ac..035a883c5179 100644--- a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/utils.test.ts+++ b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/utils.test.ts@@ -1,4 +1,5 @@import { FEATURE_FLAGS } from 'lib/constants'+import { SeriesNode } from 'scenes/insights/filters/ActionFilter/seriesNode'import {ConversionGoalFilter,@@ -21,6 +22,7 @@ import {import { NativeSource } from './marketingAnalyticsLogic'import {+ conversionGoalToSeries,createMarketingTile,findSchemaByFieldName,getEnabledNativeMarketingSources,@@ -32,6 +34,7 @@ import {NEEDED_FIELDS_FOR_NATIVE_MARKETING_ANALYTICS,rowMatchesSearch,sanitizeIntegrationFilter,+ seriesToConversionGoal,validColumnsForTiles,} from './utils'@@ -755,4 +758,104 @@ describe('marketing analytics utils', () => {expect(sanitizeIntegrationFilter(stored)).toEqual({ integrationSourceIds: expected })})})++ describe('conversion goal series', () => {+ const goalFields = {+ conversion_goal_id: 'goal-1',+ conversion_goal_name: 'Purchases',+ counts_as_customer: true,+ }+ const schemaMap = {+ utm_campaign_name: 'utm_campaign',+ utm_source_name: 'utm_source',+ timestamp_field: 'timestamp',+ distinct_id_field: 'distinct_id',+ }+ const warehouseGoal: ConversionGoalFilter = {+ ...goalFields,+ kind: NodeKind.DataWarehouseNode,+ id: 'charges',+ table_name: 'charges',+ name: 'charges',+ timestamp_field: 'created',+ id_field: 'id',+ distinct_id_field: 'email',+ dw_source_type: 'Stripe',+ math: BaseMathType.TotalCount,+ schema_map: { ...schemaMap, timestamp_field: 'created', distinct_id_field: 'email' },+ }++ it.each([+ {+ name: 'moves the picked UTM columns from the table into the schema map',+ goal: {+ ...goalFields,+ kind: NodeKind.EventsNode,+ event: 'purchase',+ schema_map: schemaMap,+ } as ConversionGoalFilter,+ series: [+ {+ kind: NodeKind.DataWarehouseNode,+ id: 'invoices',+ table_name: 'invoices',+ name: 'invoices',+ timestamp_field: 'paid_at',+ distinct_id_field: 'customer',+ utm_campaign_name: 'campaign',+ utm_source_name: 'source',+ },+ ],+ expected: {+ ...goalFields,+ kind: NodeKind.DataWarehouseNode,+ id: 'invoices',+ table_name: 'invoices',+ name: 'invoices',+ timestamp_field: 'paid_at',+ id_field: 'customer',+ distinct_id_field: 'customer',+ math: BaseMathType.TotalCount,+ properties: [],+ schema_map: {+ utm_campaign_name: 'campaign',+ utm_source_name: 'source',+ timestamp_field: 'paid_at',+ distinct_id_field: 'customer',+ },+ },+ },+ {+ name: 'keeps no table column when a table goal becomes an event',+ goal: warehouseGoal,+ series: [{ kind: NodeKind.EventsNode, event: 'purchase', name: 'purchase' }],+ expected: {+ ...goalFields,+ kind: NodeKind.EventsNode,+ event: 'purchase',+ name: 'purchase',+ math: BaseMathType.TotalCount,+ properties: [],+ schema_map: warehouseGoal.schema_map,+ },+ },+ ])('$name', ({ goal, series, expected }) => {+ expect(seriesToConversionGoal(goal, series as SeriesNode[])).toStrictEqual(expected)+ })++ it('reads a goal stored with the legacy warehouse type as a table', () => {+ const legacyGoal = {+ ...goalFields,+ kind: NodeKind.EventsNode,+ type: 'data_warehouse',+ table_name: 'charges',+ timestamp_field: 'created',+ schema_map: schemaMap,+ } as unknown as ConversionGoalFilter++ expect(conversionGoalToSeries(legacyGoal)).toStrictEqual([+ { kind: NodeKind.DataWarehouseNode, id: 'charges', table_name: 'charges', timestamp_field: 'created' },+ ])+ })+ })})diff --git a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/utils.ts b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/utils.tsindex 36aa17cdbbb8..ff4c4759b1f9 100644--- a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/utils.ts+++ b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/utils.ts@@ -1,4 +1,8 @@import { FEATURE_FLAGS, type FeatureFlagKey } from 'lib/constants'+import { objectClean } from 'lib/utils/objects'+import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'+import { cleanSeriesNodes } from 'scenes/insights/filters/ActionFilter/cleanSeriesNodes'+import { SeriesNode, isWarehouseSeriesNode } from 'scenes/insights/filters/ActionFilter/seriesNode'import {AttributionMode,@@ -14,6 +18,12 @@ import {NodeKind,VALID_NATIVE_MARKETING_SOURCES,} from '~/queries/schema/schema-general'+import {+ DISTINCT_ID_FIELD_SCHEMA_FIELD,+ TIMESTAMP_FIELD_SCHEMA_FIELD,+ UTM_CAMPAIGN_NAME_SCHEMA_FIELD,+ UTM_SOURCE_NAME_SCHEMA_FIELD,+} from '~/taxonomy/marketingAnalytics'import { ExternalDataSource, HogQLMathType, ManualLinkSourceType, PropertyMathType } from '~/types'import type { ExternalDataSourceTypeEnumApi } from 'products/warehouse_sources/frontend/generated/api.schemas'@@ -252,6 +262,82 @@ export function isDraftConversionGoalColumn(column: string, draftConversionGoal:)}+type ConversionGoalFields = Pick<+ ConversionGoalFilter,+ 'conversion_goal_id' | 'conversion_goal_name' | 'schema_map' | 'counts_as_customer' | 'counts_as_revenue'+>++function splitConversionGoal(goal: ConversionGoalFilter): { fields: ConversionGoalFields; node: SeriesNode } {+ const { conversion_goal_id, conversion_goal_name, schema_map, counts_as_customer, counts_as_revenue, ...node } =+ goal+ return {+ fields: objectClean({+ conversion_goal_id,+ conversion_goal_name,+ schema_map,+ counts_as_customer,+ counts_as_revenue,+ }),+ node,+ }+}++export function conversionGoalToSeries(goal: ConversionGoalFilter): SeriesNode[] {+ const { node } = splitConversionGoal(goal)+ // An older goal shape marks a warehouse table with a `type` field on an events node.+ if ('type' in node && node.type === 'data_warehouse') {+ const { type, event, ...warehouse } = node as SeriesNode & { type: string; event?: string | null }+ const tableName = (warehouse as Partial<DataWarehouseNode>).table_name ?? ''+ return [{ ...warehouse, kind: NodeKind.DataWarehouseNode, table_name: tableName, id: tableName } as SeriesNode]+ }+ return [node]+}++/**+ * Writes the series a conversion goal picker emits back onto the goal, or returns null when the+ * picker emits none. Node fields come only from the series, so a field the picker drops on an+ * entity switch, such as a table column or a stale `math_property`, does not come back from the+ * previous goal.+ */+export function seriesToConversionGoal(goal: ConversionGoalFilter, series: SeriesNode[]): ConversionGoalFilter | null {+ const [node] = cleanSeriesNodes(series, MathAvailability.All)+ if (!node) {+ return null+ }+ const { fields } = splitConversionGoal(goal)++ if (!isWarehouseSeriesNode(node)) {+ // Stored goals always carry a properties list, even an empty one.+ return { ...fields, ...node, properties: node.properties ?? [] } as ConversionGoalFilter+ }++ // The warehouse picker puts the UTM columns on the node, but the goal schema keeps them in+ // `schema_map` only and rejects them on the node.+ const {+ [UTM_CAMPAIGN_NAME_SCHEMA_FIELD]: utmCampaignName,+ [UTM_SOURCE_NAME_SCHEMA_FIELD]: utmSourceName,+ ...warehouse+ } = node as DataWarehouseNode & Partial<Record<string, string>>+ const tableName = warehouse.table_name || ''+ return {+ ...fields,+ ...warehouse,+ kind: NodeKind.DataWarehouseNode,+ id: tableName,+ table_name: tableName,+ id_field: warehouse.id_field || warehouse.distinct_id_field || 'id',+ distinct_id_field: warehouse.distinct_id_field || 'distinct_id',+ timestamp_field: warehouse.timestamp_field || 'timestamp',+ properties: warehouse.properties ?? [],+ schema_map: {+ [UTM_CAMPAIGN_NAME_SCHEMA_FIELD]: utmCampaignName,+ [UTM_SOURCE_NAME_SCHEMA_FIELD]: utmSourceName,+ [TIMESTAMP_FIELD_SCHEMA_FIELD]: warehouse.timestamp_field,+ [DISTINCT_ID_FIELD_SCHEMA_FIELD]: warehouse.distinct_id_field,+ },+ }+}+/*** Get the order by for the query and ensure that the order by is in the columns* @param query - The query to get the order by fordiff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/CustomerAnalyticsDashboardEvents.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/CustomerAnalyticsDashboardEvents.tsxindex baa6b4e36239..c398ef85decf 100644--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/CustomerAnalyticsDashboardEvents.tsx+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/CustomerAnalyticsDashboardEvents.tsx@@ -10,14 +10,14 @@ import { FEATURE_FLAGS, TeamMembershipLevel } from 'lib/constants'import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { eventUsageLogic } from 'lib/utils/eventUsageLogic'-import { ActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter'+import { SeriesActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter'import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'+import { SeriesNode } from 'scenes/insights/filters/ActionFilter/seriesNode'import { teamLogic } from 'scenes/teamLogic'import { urls } from 'scenes/urls'-import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'-import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'-import { EntityTypes, FilterType } from '~/types'+import { NodeKind, ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'+import { ChartDisplayCategory, InsightType } from '~/types'import { ConfigureWithAIButton } from 'products/customer_analytics/frontend/components/ConfigureWithAIButton'import { isPageviewWithoutFilters } from 'products/customer_analytics/frontend/utils'@@ -30,14 +30,14 @@ function reportCustomerAnalyticsDashboardEventPickerClicked({ event }: { event:export interface EventSelectorProps {caption?: string- filters: FilterType | null- setFilters: (filters: FilterType) => void+ series: SeriesNode[] | null+ setSeries: (series: SeriesNode[]) => voidtitle: stringprompt: stringrelatedSeries: string[]}-function EventSelector({ filters, setFilters, title, caption, prompt }: EventSelectorProps): JSX.Element {+function EventSelector({ series, setSeries, title, caption, prompt }: EventSelectorProps): JSX.Element {const { eventsToHighlight } = useValues(customerAnalyticsDashboardEventsLogic)const highlight = eventsToHighlight.includes(title) ? 'border rounded border-dashed border-danger' : ''@@ -46,8 +46,7 @@ function EventSelector({ filters, setFilters, title, caption, prompt }: EventSelminimumAccessLevel: TeamMembershipLevel.Admin,})- const shouldShowAIButton =- !filters || isPageviewWithoutFilters(actionsAndEventsToSeries(filters as any, true, MathAvailability.None)[0])+ const shouldShowAIButton = !series?.[0] || isPageviewWithoutFilters(series[0])return (<div className={`py-2 ${highlight}`}>@@ -60,18 +59,20 @@ function EventSelector({ filters, setFilters, title, caption, prompt }: EventSel</div><p className="text-xs text-muted-alt">{caption}</p></div>- {filters ? (+ {series ? (<div className="flex">- <ActionFilter+ <SeriesActionFilterhideRenamehideDuplicatehideFilter={false}propertyFiltersPopover- filters={filters}- setFilters={(filters) => {- setFilters(filters)+ series={series}+ onChange={(nextSeries) => {+ setSeries(nextSeries)reportCustomerAnalyticsDashboardEventPickerClicked({ event: title })}}+ insightType={InsightType.TRENDS}+ trendsDisplayCategory={ChartDisplayCategory.TimeSeries}typeKey={`customer-analytics-${title.toLowerCase()}`}mathAvailability={MathAvailability.None}actionsTaxonomicGroupTypes={[TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions]}@@ -86,15 +87,7 @@ function EventSelector({ filters, setFilters, title, caption, prompt }: EventSeltype="tertiary"icon={<IconPlusSmall />}onClick={() => {- setFilters({- events: [- {- id: '$pageview',- name: '$pageview',- type: EntityTypes.EVENTS,- },- ],- })+ setSeries([{ kind: NodeKind.EventsNode, event: '$pageview', name: '$pageview' }])reportCustomerAnalyticsDashboardEventPickerClicked({ event: title })}}disabledReason={restrictedReason}diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/customerAnalyticsDashboardEventsLogic.test.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/customerAnalyticsDashboardEventsLogic.test.tsnew file mode 100644index 000000000000..76f5283d3d7e--- /dev/null+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/customerAnalyticsDashboardEventsLogic.test.ts@@ -0,0 +1,65 @@+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'++import { expectLogic } from 'kea-test-utils'++import { useMocks } from '~/mocks/jest'+import { ActionsNode, CustomerAnalyticsConfig, EventsNode, NodeKind } from '~/queries/schema/schema-general'+import { initKeaTests } from '~/test/init'+import { BaseMathType, PropertyFilterType, PropertyOperator } from '~/types'++import { customerAnalyticsConfigLogic } from 'products/customer_analytics/frontend/customerAnalyticsConfigLogic'++import { customerAnalyticsDashboardEventsLogic } from './customerAnalyticsDashboardEventsLogic'++const pageview: EventsNode = { kind: NodeKind.EventsNode, event: '$pageview', name: '$pageview' }+const paid: ActionsNode = { kind: NodeKind.ActionsNode, id: 7, name: 'Paid', custom_name: 'Payments' }+const browserFilter = {+ key: '$browser',+ value: ['Chrome'],+ operator: PropertyOperator.Exact,+ type: PropertyFilterType.Event as const,+}++describe('customerAnalyticsDashboardEventsLogic', () => {+ let logic: ReturnType<typeof customerAnalyticsDashboardEventsLogic.build>++ beforeEach(() => {+ useMocks({ patch: { '/api/projects/:id': () => [200, MOCK_DEFAULT_TEAM] } })+ initKeaTests(true, {+ ...MOCK_DEFAULT_TEAM,+ customer_analytics_config: {+ ...MOCK_DEFAULT_TEAM.customer_analytics_config,+ activity_event: {},+ signup_event: pageview,+ } as CustomerAnalyticsConfig,+ })+ logic = customerAnalyticsDashboardEventsLogic()+ logic.mount()+ })++ afterEach(() => {+ logic.unmount()+ })++ it('offers an event the config leaves out as a button rather than an empty picker', () => {+ expectLogic(logic).toMatchValues({+ activityEventSeries: null,+ signupEventSeries: [{ ...pageview, custom_name: 'Signups' }],+ })+ })++ it('saves only the edited events, as config nodes without math', async () => {+ await expectLogic(logic, () => {+ logic.actions.setActivityEventSelection([+ { ...pageview, math: BaseMathType.UniqueUsers, properties: [browserFilter] },+ ])+ logic.actions.setPaymentEventSelection([paid])+ logic.actions.saveEvents()+ }).toDispatchActions([+ customerAnalyticsConfigLogic.actionCreators.updateEvents({+ activity_event: { ...pageview, properties: [browserFilter] },+ payment_event: paid,+ }),+ ])+ })+})diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/customerAnalyticsDashboardEventsLogic.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/customerAnalyticsDashboardEventsLogic.tsindex aff09db263ad..a0259a80c82b 100644--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/customerAnalyticsDashboardEventsLogic.ts+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/customerAnalyticsDashboardEventsLogic.ts@@ -1,14 +1,11 @@import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'-import type { ActionForPayloadBuilder } from 'kea'import { urlToAction } from 'kea-router'-import { isEmptyObject } from 'lib/utils/guards'import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'+import { cleanSeriesNodes } from 'scenes/insights/filters/ActionFilter/cleanSeriesNodes'+import { SeriesNode } from 'scenes/insights/filters/ActionFilter/seriesNode'-import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'-import { seriesToActionsAndEvents } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter'import { ActionsNode, DataWarehouseNode, EventsNode, GroupNode } from '~/queries/schema/schema-general'-import { FilterType, InsightType } from '~/types'import { customerAnalyticsConfigLogic } from 'products/customer_analytics/frontend/customerAnalyticsConfigLogic'@@ -22,46 +19,24 @@ export interface customerAnalyticsDashboardEventsLogicValues {signupEvent: AnyEntityNode // customerAnalyticsConfigLogicsignupPageviewEvent: AnyEntityNode // customerAnalyticsConfigLogicsubscriptionEvent: AnyEntityNode // customerAnalyticsConfigLogic- activityEventFilters: FilterType- activityEventSelection: FilterType | null+ activityEventSelection: SeriesNode[] | nullactivityEventSelector: EventSelectorProps+ activityEventSeries: SeriesNode[] | nulleventSelectors: EventSelectorProps[]eventsToHighlight: string[]hasChanges: boolean- paymentEventFilters: FilterType | null- paymentEventSelection: FilterType | null- paymentEventSelector: {- caption: string- filters: FilterType | null- prompt: string- relatedSeries: string[]- setFilters: ActionForPayloadBuilder<- (filters: FilterType | null) => {- filters: FilterType | null- }- >- title: string- }- signupEventFilters: FilterType | null- signupEventSelection: FilterType | null+ paymentEventSelection: SeriesNode[] | null+ paymentEventSelector: EventSelectorProps+ paymentEventSeries: SeriesNode[] | null+ signupEventSelection: SeriesNode[] | nullsignupEventSelector: EventSelectorProps- signupPageviewEventFilters: FilterType | null- signupPageviewEventSelection: FilterType | null+ signupEventSeries: SeriesNode[] | null+ signupPageviewEventSelection: SeriesNode[] | nullsignupPageviewEventSelector: EventSelectorProps- subscriptionEventFilters: FilterType | null- subscriptionEventSelection: FilterType | null- subscriptionEventSelector: {- caption: string- filters: FilterType | null- prompt: string- relatedSeries: string[]- setFilters: ActionForPayloadBuilder<- (filters: FilterType | null) => {- filters: FilterType | null- }- >- title: string- }+ signupPageviewEventSeries: SeriesNode[] | null+ subscriptionEventSelection: SeriesNode[] | null+ subscriptionEventSelector: EventSelectorProps+ subscriptionEventSeries: SeriesNode[] | null}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -83,102 +58,64 @@ export interface customerAnalyticsDashboardEventsLogicActions {saveEvents: () => {value: true}- setActivityEventSelection: (filters: FilterType | null) => {- filters: FilterType | null+ setActivityEventSelection: (series: SeriesNode[] | null) => {+ series: SeriesNode[] | null}- setPaymentEventSelection: (filters: FilterType | null) => {- filters: FilterType | null+ setPaymentEventSelection: (series: SeriesNode[] | null) => {+ series: SeriesNode[] | null}- setSignupEventSelection: (filters: FilterType | null) => {- filters: FilterType | null+ setSignupEventSelection: (series: SeriesNode[] | null) => {+ series: SeriesNode[] | null}- setSignupPageviewEventSelection: (filters: FilterType | null) => {- filters: FilterType | null+ setSignupPageviewEventSelection: (series: SeriesNode[] | null) => {+ series: SeriesNode[] | null}- setSubscriptionEventSelection: (filters: FilterType | null) => {- filters: FilterType | null+ setSubscriptionEventSelection: (series: SeriesNode[] | null) => {+ series: SeriesNode[] | null}}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface customerAnalyticsDashboardEventsLogicMeta {__keaTypeGenInternalSelectorTypes: {- activityEventFilters: (activityEvent: AnyEntityNode, activityEventSelection: FilterType | null) => FilterType- signupEventFilters: (signupEvent: AnyEntityNode, signupEventSelection: FilterType | null) => FilterType | null- signupPageviewEventFilters: (+ activityEventSeries: (+ activityEvent: AnyEntityNode,+ activityEventSelection: SeriesNode[] | null+ ) => SeriesNode[] | null+ signupEventSeries: (+ signupEvent: AnyEntityNode,+ signupEventSelection: SeriesNode[] | null+ ) => SeriesNode[] | null+ signupPageviewEventSeries: (signupPageviewEvent: AnyEntityNode,- signupPageviewEventSelection: FilterType | null- ) => FilterType | null- paymentEventFilters: (+ signupPageviewEventSelection: SeriesNode[] | null+ ) => SeriesNode[] | null+ paymentEventSeries: (paymentEvent: AnyEntityNode,- paymentEventSelection: FilterType | null- ) => FilterType | null- subscriptionEventFilters: (+ paymentEventSelection: SeriesNode[] | null+ ) => SeriesNode[] | null+ subscriptionEventSeries: (subscriptionEvent: AnyEntityNode,- subscriptionEventSelection: FilterType | null- ) => FilterType | null+ subscriptionEventSelection: SeriesNode[] | null+ ) => SeriesNode[] | nullhasChanges: (- activityEventSelection: FilterType | null,- signupEventSelection: FilterType | null,- signupPageviewEventSelection: FilterType | null,- paymentEventSelection: FilterType | null,- subscriptionEventSelection: FilterType | null+ activityEventSelection: SeriesNode[] | null,+ signupEventSelection: SeriesNode[] | null,+ signupPageviewEventSelection: SeriesNode[] | null,+ paymentEventSelection: SeriesNode[] | null,+ subscriptionEventSelection: SeriesNode[] | null) => boolean- activityEventSelector: (activityEventFilters: FilterType) => EventSelectorProps- signupPageviewEventSelector: (signupPageviewEventFilters: FilterType | null) => EventSelectorProps- signupEventSelector: (signupEventFilters: FilterType | null) => EventSelectorProps- subscriptionEventSelector: (subscriptionEventFilters: FilterType | null) => {- caption: string- filters: FilterType | null- prompt: string- relatedSeries: string[]- setFilters: ActionForPayloadBuilder<- (filters: FilterType | null) => {- filters: FilterType | null- }- >- title: string- }- paymentEventSelector: (paymentEventFilters: FilterType | null) => {- caption: string- filters: FilterType | null- prompt: string- relatedSeries: string[]- setFilters: ActionForPayloadBuilder<- (filters: FilterType | null) => {- filters: FilterType | null- }- >- title: string- }+ activityEventSelector: (activityEventSeries: SeriesNode[] | null) => EventSelectorProps+ signupPageviewEventSelector: (signupPageviewEventSeries: SeriesNode[] | null) => EventSelectorProps+ signupEventSelector: (signupEventSeries: SeriesNode[] | null) => EventSelectorProps+ subscriptionEventSelector: (subscriptionEventSeries: SeriesNode[] | null) => EventSelectorProps+ paymentEventSelector: (paymentEventSeries: SeriesNode[] | null) => EventSelectorPropseventSelectors: (activityEventSelector: EventSelectorProps,signupPageviewEventSelector: EventSelectorProps,signupEventSelector: EventSelectorProps,- subscriptionEventSelector: {- caption: string- filters: FilterType | null- prompt: string- relatedSeries: string[]- setFilters: ActionForPayloadBuilder<- (filters: FilterType | null) => {- filters: FilterType | null- }- >- title: string- },- paymentEventSelector: {- caption: string- filters: FilterType | null- prompt: string- relatedSeries: string[]- setFilters: ActionForPayloadBuilder<- (filters: FilterType | null) => {- filters: FilterType | null- }- >- title: string- }+ subscriptionEventSelector: EventSelectorProps,+ paymentEventSelector: EventSelectorProps) => EventSelectorProps[]}}@@ -190,6 +127,19 @@ export type customerAnalyticsDashboardEventsLogicType = MakeLogicType<customerAnalyticsDashboardEventsLogicMeta>+/**+ * An event the config leaves unset reaches this logic without a `kind`, sometimes with only a+ * `custom_name`. Its selector shows a button rather than a picker row that queries nothing.+ */+function configuredEventSeries(event: AnyEntityNode): SeriesNode[] | null {+ return event.kind ? [event] : null+}++// The pickers offer events and actions only, and edit one event each.+function toConfiguredEvent(series: SeriesNode[]): ActionsNode | EventsNode {+ return cleanSeriesNodes(series, MathAvailability.None)[0] as ActionsNode | EventsNode+}+export const customerAnalyticsDashboardEventsLogic = kea<customerAnalyticsDashboardEventsLogicType>([path(['products', 'customerAnalytics', 'components', 'insights', 'eventConfigModal']),connect(() => ({@@ -203,56 +153,46 @@ export const customerAnalyticsDashboardEventsLogic = kea<customerAnalyticsDashboaddEventToHighlight: (event: string) => ({ event }),clearEventsToHighlight: true,clearFilterSelections: true,- setActivityEventSelection: (filters: FilterType | null) => ({- filters,- }),- setSignupEventSelection: (filters: FilterType | null) => ({- filters,- }),- setSignupPageviewEventSelection: (filters: FilterType | null) => ({- filters,- }),- setPaymentEventSelection: (filters: FilterType | null) => ({- filters,- }),- setSubscriptionEventSelection: (filters: FilterType | null) => ({- filters,- }),+ setActivityEventSelection: (series: SeriesNode[] | null) => ({ series }),+ setSignupEventSelection: (series: SeriesNode[] | null) => ({ series }),+ setSignupPageviewEventSelection: (series: SeriesNode[] | null) => ({ series }),+ setPaymentEventSelection: (series: SeriesNode[] | null) => ({ series }),+ setSubscriptionEventSelection: (series: SeriesNode[] | null) => ({ series }),saveEvents: true,}),reducers({activityEventSelection: [- null as FilterType | null,+ null as SeriesNode[] | null,{- setActivityEventSelection: (_, { filters }) => filters,+ setActivityEventSelection: (_, { series }) => series,clearFilterSelections: () => null,},],signupEventSelection: [- null as FilterType | null,+ null as SeriesNode[] | null,{- setSignupEventSelection: (_, { filters }) => filters,+ setSignupEventSelection: (_, { series }) => series,clearFilterSelections: () => null,},],signupPageviewEventSelection: [- null as FilterType | null,+ null as SeriesNode[] | null,{- setSignupPageviewEventSelection: (_, { filters }) => filters,+ setSignupPageviewEventSelection: (_, { series }) => series,clearFilterSelections: () => null,},],paymentEventSelection: [- null as FilterType | null,+ null as SeriesNode[] | null,{- setPaymentEventSelection: (_, { filters }) => filters,+ setPaymentEventSelection: (_, { series }) => series,clearFilterSelections: () => null,},],subscriptionEventSelection: [- null as FilterType | null,+ null as SeriesNode[] | null,{- setSubscriptionEventSelection: (_, { filters }) => filters,+ setSubscriptionEventSelection: (_, { series }) => series,clearFilterSelections: () => null,},],@@ -265,92 +205,32 @@ export const customerAnalyticsDashboardEventsLogic = kea<customerAnalyticsDashbo],}),selectors(({ actions }) => ({- activityEventFilters: [+ activityEventSeries: [(s) => [s.activityEvent, s.activityEventSelection],- (- activityEvent: import('~/queries/schema').AnyEntityNode,- activityEventSelection: FilterType | null- ): FilterType => {- if (activityEventSelection) {- return activityEventSelection- }- return {- insight: InsightType.TRENDS,- ...seriesToActionsAndEvents(activityEvent ? [activityEvent] : []),- }- },+ (activityEvent: AnyEntityNode, activityEventSelection: SeriesNode[] | null): SeriesNode[] | null =>+ activityEventSelection ?? configuredEventSeries(activityEvent),],- signupEventFilters: [+ signupEventSeries: [(s) => [s.signupEvent, s.signupEventSelection],- (- signupEvent: import('~/queries/schema').AnyEntityNode,- signupEventSelection: FilterType | null- ): FilterType | null => {- if (signupEventSelection) {- return signupEventSelection- }- if (isEmptyObject(signupEvent)) {- return null- }- return {- insight: InsightType.TRENDS,- ...seriesToActionsAndEvents([signupEvent]),- }- },+ (signupEvent: AnyEntityNode, signupEventSelection: SeriesNode[] | null): SeriesNode[] | null =>+ signupEventSelection ?? configuredEventSeries(signupEvent),],- signupPageviewEventFilters: [+ signupPageviewEventSeries: [(s) => [s.signupPageviewEvent, s.signupPageviewEventSelection],(- signupPageviewEvent: import('~/queries/schema').AnyEntityNode,- signupPageviewEventSelection: FilterType | null- ): FilterType | null => {- if (signupPageviewEventSelection) {- return signupPageviewEventSelection- }- if (isEmptyObject(signupPageviewEvent as object)) {- return null- }- return {- insight: InsightType.TRENDS,- ...seriesToActionsAndEvents([signupPageviewEvent]),- }- },+ signupPageviewEvent: AnyEntityNode,+ signupPageviewEventSelection: SeriesNode[] | null+ ): SeriesNode[] | null => signupPageviewEventSelection ?? configuredEventSeries(signupPageviewEvent),],- paymentEventFilters: [+ paymentEventSeries: [(s) => [s.paymentEvent, s.paymentEventSelection],- (- paymentEvent: import('~/queries/schema').AnyEntityNode,- paymentEventSelection: FilterType | null- ): FilterType | null => {- if (paymentEventSelection) {- return paymentEventSelection- }- if (isEmptyObject(paymentEvent as object)) {- return null- }- return {- insight: InsightType.TRENDS,- ...seriesToActionsAndEvents([paymentEvent]),- }- },+ (paymentEvent: AnyEntityNode, paymentEventSelection: SeriesNode[] | null): SeriesNode[] | null =>+ paymentEventSelection ?? configuredEventSeries(paymentEvent),],- subscriptionEventFilters: [+ subscriptionEventSeries: [(s) => [s.subscriptionEvent, s.subscriptionEventSelection],- (- subscriptionEvent: import('~/queries/schema').AnyEntityNode,- subscriptionEventSelection: FilterType | null- ): FilterType | null => {- if (subscriptionEventSelection) {- return subscriptionEventSelection- }- if (isEmptyObject(subscriptionEvent as object)) {- return null- }- return {- insight: InsightType.TRENDS,- ...seriesToActionsAndEvents([subscriptionEvent]),- }- },+ (subscriptionEvent: AnyEntityNode, subscriptionEventSelection: SeriesNode[] | null): SeriesNode[] | null =>+ subscriptionEventSelection ?? configuredEventSeries(subscriptionEvent),],hasChanges: [(s) => [@@ -361,11 +241,11 @@ export const customerAnalyticsDashboardEventsLogic = kea<customerAnalyticsDashbos.subscriptionEventSelection,],(- activityEventSelection: FilterType | null,- signupEventSelection: FilterType | null,- signupPageviewEventSelection: FilterType | null,- paymentEventSelection: FilterType | null,- subscriptionEventSelection: FilterType | null+ activityEventSelection: SeriesNode[] | null,+ signupEventSelection: SeriesNode[] | null,+ signupPageviewEventSelection: SeriesNode[] | null,+ paymentEventSelection: SeriesNode[] | null,+ subscriptionEventSelection: SeriesNode[] | null): boolean => {return (activityEventSelection !== null ||@@ -377,56 +257,56 @@ export const customerAnalyticsDashboardEventsLogic = kea<customerAnalyticsDashbo},],activityEventSelector: [- (s) => [s.activityEventFilters],- (activityEventFilters: FilterType): EventSelectorProps => ({+ (s) => [s.activityEventSeries],+ (activityEventSeries: SeriesNode[] | null): EventSelectorProps => ({title: 'Activity event',caption: 'Defines what is considered user activity for active users and engagement calculations',- filters: activityEventFilters,- setFilters: actions.setActivityEventSelection,+ series: activityEventSeries,+ setSeries: actions.setActivityEventSelection,prompt: 'What custom events or actions can be used to define active product usage?',relatedSeries: ['dauSeries', 'mauSeries', 'wauSeries'],}),],signupPageviewEventSelector: [- (s) => [s.signupPageviewEventFilters],- (signupPageviewEventFilters: FilterType | null): EventSelectorProps => ({+ (s) => [s.signupPageviewEventSeries],+ (signupPageviewEventSeries: SeriesNode[] | null): EventSelectorProps => ({title: 'Signup pageview event',caption: 'Tracks when users view the signup page. Used to calculate signup conversion',- filters: signupPageviewEventFilters,- setFilters: actions.setSignupPageviewEventSelection,+ series: signupPageviewEventSeries,+ setSeries: actions.setSignupPageviewEventSelection,prompt: 'What pageview pathnames can be used to define signup pageviews based on my events?',relatedSeries: ['signupPageviewSeries'],}),],signupEventSelector: [- (s) => [s.signupEventFilters],- (signupEventFilters: FilterType | null): EventSelectorProps => ({+ (s) => [s.signupEventSeries],+ (signupEventSeries: SeriesNode[] | null): EventSelectorProps => ({title: 'Signup event',caption: 'Tracks when users complete registration or account creation',- filters: signupEventFilters,- setFilters: actions.setSignupEventSelection,+ series: signupEventSeries,+ setSeries: actions.setSignupEventSelection,prompt: 'What events or actions can be used to define user signup?',relatedSeries: ['signupSeries'],}),],subscriptionEventSelector: [- (s) => [s.subscriptionEventFilters],- (subscriptionEventFilters: FilterType | null) => ({+ (s) => [s.subscriptionEventSeries],+ (subscriptionEventSeries: SeriesNode[] | null): EventSelectorProps => ({title: 'Subscription event',caption: 'Tracks when users subscribe to a plan. May or may not be associated with a payment',- filters: subscriptionEventFilters,- setFilters: actions.setSubscriptionEventSelection,+ series: subscriptionEventSeries,+ setSeries: actions.setSubscriptionEventSelection,prompt: 'What events or actions can be used to define user subscription?',relatedSeries: ['subscriptionSeries'],}),],paymentEventSelector: [- (s) => [s.paymentEventFilters],- (paymentEventFilters: FilterType | null) => ({+ (s) => [s.paymentEventSeries],+ (paymentEventSeries: SeriesNode[] | null): EventSelectorProps => ({title: 'Payment event',caption: 'Tracks when users complete a payment. Used to calculate free-to-paid conversion',- filters: paymentEventFilters,- setFilters: actions.setPaymentEventSelection,+ series: paymentEventSeries,+ setSeries: actions.setPaymentEventSelection,prompt: 'What events or actions can be used to define user payment?',relatedSeries: ['paymentSeries'],}),@@ -443,22 +323,8 @@ export const customerAnalyticsDashboardEventsLogic = kea<customerAnalyticsDashboactivityEventSelector: EventSelectorProps,signupPageviewEventSelector: EventSelectorProps,signupEventSelector: EventSelectorProps,- subscriptionEventSelector: {- caption: string- filters: FilterType | null- prompt: string- relatedSeries: string[]- setFilters: (filters: FilterType | null) => void- title: string- },- paymentEventSelector: {- caption: string- filters: FilterType | null- prompt: string- relatedSeries: string[]- setFilters: (filters: FilterType | null) => void- title: string- }+ subscriptionEventSelector: EventSelectorProps,+ paymentEventSelector: EventSelectorProps): EventSelectorProps[] => [activityEventSelector,signupPageviewEventSelector,@@ -472,44 +338,19 @@ export const customerAnalyticsDashboardEventsLogic = kea<customerAnalyticsDashbosaveEvents: () => {const events: Record<string, ActionsNode | EventsNode | DataWarehouseNode | GroupNode> = {}if (values.activityEventSelection) {- const activityEvents = actionsAndEventsToSeries(- values.activityEventSelection as any,- true,- MathAvailability.None- )- events['activity_event'] = activityEvents[0]+ events['activity_event'] = toConfiguredEvent(values.activityEventSelection)}if (values.signupEventSelection) {- const signupEvents = actionsAndEventsToSeries(- values.signupEventSelection as any,- true,- MathAvailability.None- )- events['signup_event'] = signupEvents[0]+ events['signup_event'] = toConfiguredEvent(values.signupEventSelection)}if (values.signupPageviewEventSelection) {- const signupPageviewEvents = actionsAndEventsToSeries(- values.signupPageviewEventSelection as any,- true,- MathAvailability.None- )- events['signup_pageview_event'] = signupPageviewEvents[0]+ events['signup_pageview_event'] = toConfiguredEvent(values.signupPageviewEventSelection)}if (values.paymentEventSelection) {- const paymentEvents = actionsAndEventsToSeries(- values.paymentEventSelection as any,- true,- MathAvailability.None- )- events['payment_event'] = paymentEvents[0]+ events['payment_event'] = toConfiguredEvent(values.paymentEventSelection)}if (values.subscriptionEventSelection) {- const subscriptionEvents = actionsAndEventsToSeries(- values.subscriptionEventSelection as any,- true,- MathAvailability.None- )- events['subscription_event'] = subscriptionEvents[0]+ events['subscription_event'] = toConfiguredEvent(values.subscriptionEventSelection)}actions.updateEvents(events)},diff --git a/products/customer_analytics/frontend/utils.ts b/products/customer_analytics/frontend/utils.tsindex 9915cfbc617c..ed1dc1698730 100644--- a/products/customer_analytics/frontend/utils.ts+++ b/products/customer_analytics/frontend/utils.ts@@ -1,4 +1,5 @@-import { AnyEntityNode, GroupNode } from '~/queries/schema/schema-general'+import type { SeriesNode } from 'scenes/insights/filters/ActionFilter/seriesNode'+import { isEventsNode } from '~/queries/utils'import { InsightLogicProps } from '~/types'@@ -8,6 +9,6 @@ export const buildDashboardItemId = (uniqueKey: string): InsightLogicProps['dashreturn `new-AdHoc.customer-analytics.${uniqueKey}`}-export function isPageviewWithoutFilters(event: AnyEntityNode | GroupNode): boolean {+export function isPageviewWithoutFilters(event: SeriesNode): boolean {return isEventsNode(event) && event.event === '$pageview' && (!event.properties || event.properties.length === 0)}