:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(customer-analytics): drop the legacy custom property source modal (#67925)
Arthur Moreira de Deus44bb221b3676
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomPropertiesConfig.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomPropertiesConfig.tsxindex 0b9b93dd7bfd..e26fdf37b09b 100644--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomPropertiesConfig.tsx+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomPropertiesConfig.tsx@@ -1,7 +1,7 @@import { useActions, useValues } from 'kea'import { useState } from 'react'-import { IconDatabase, IconInfo, IconPencil, IconTrash } from '@posthog/icons'+import { IconInfo, IconPencil, IconTrash } from '@posthog/icons'import { LemonButton, LemonTable, LemonTableColumns, Tooltip } from '@posthog/lemon-ui'import { RestrictionScope, useRestrictedArea } from 'lib/components/RestrictedArea'@@ -20,7 +20,6 @@ import type {import { customPropertyDefinitionsLogic } from './customPropertyDefinitionsLogic'import { CustomPropertyModal } from './CustomPropertyModal'-import { CustomPropertySourceModal } from './CustomPropertySourceModal'import { labelForDisplayType, type SourceSyncStatusLevel, sourceSyncStatus } from './customPropertyTypes'const TAG_TYPE_BY_SYNC_LEVEL: Record<SourceSyncStatusLevel, LemonTagType> = {@@ -32,8 +31,7 @@ const TAG_TYPE_BY_SYNC_LEVEL: Record<SourceSyncStatusLevel, LemonTagType> = {export function CustomPropertiesConfig(): JSX.Element {const { definitions, definitionsLoading } = useValues(customPropertyDefinitionsLogic)- const { openCreateModal, openEditModal, openSourceModal, deleteDefinition } =- useActions(customPropertyDefinitionsLogic)+ const { openCreateModal, openEditModal, deleteDefinition } = useActions(customPropertyDefinitionsLogic)const restrictionReason = useRestrictedArea({scope: RestrictionScope.Project,minimumAccessLevel: TeamMembershipLevel.Admin,@@ -112,14 +110,6 @@ export function CustomPropertiesConfig(): JSX.Element {width: 0,render: (_, definition) => (<div className="flex gap-1 justify-end">- <LemonButton- size="small"- icon={<IconDatabase />}- tooltip={definition.source ? 'Configure sync' : 'Sync from a view'}- active={!!definition.source}- onClick={() => openSourceModal(definition)}- disabledReason={restrictionReason}- /><LemonButtonsize="small"icon={<IconPencil />}@@ -159,7 +149,6 @@ export function CustomPropertiesConfig(): JSX.Element {emptyState="No custom properties yet. Create one to get started."/><CustomPropertyModal />- <CustomPropertySourceModal /></div>)}diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomPropertySourceModal.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomPropertySourceModal.tsxdeleted file mode 100644index c441112528e3..000000000000--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomPropertySourceModal.tsx+++ /dev/null@@ -1,140 +0,0 @@-import { useActions, useValues } from 'kea'-import { Form } from 'kea-forms'--import { LemonBanner, LemonButton, LemonModal, LemonSearchableSelect, LemonSwitch } from '@posthog/lemon-ui'--import { LemonField } from 'lib/lemon-ui/LemonField'--import { customPropertyDefinitionsLogic } from './customPropertyDefinitionsLogic'--export function CustomPropertySourceModal(): JSX.Element {- const {- sourceModalVisible,- sourceDefinition,- customPropertySourceForm,- isCustomPropertySourceFormSubmitting,- materializedViews,- sourceModalColumns,- savedQueriesLoading,- definitionsLoading,- } = useValues(customPropertyDefinitionsLogic)- const { closeSourceModal, submitCustomPropertySourceForm, removeSource, setCustomPropertySourceFormValue } =- useActions(customPropertyDefinitionsLogic)-- const editing = !!sourceDefinition?.source- const noViews = !savedQueriesLoading && materializedViews.length === 0-- return (- <LemonModal- isOpen={sourceModalVisible}- onClose={closeSourceModal}- title={`Sync “${sourceDefinition?.name ?? ''}” from a view`}- description="Pull this property's values from a materialized view column on each materialization, matched to accounts by external ID."- footer={- <div className="flex justify-between items-center w-full">- <div>- {editing && sourceDefinition && (- <LemonButton- type="secondary"- status="danger"- onClick={() => removeSource({ definition: sourceDefinition })}- loading={definitionsLoading}- >- Remove sync- </LemonButton>- )}- </div>- <div className="flex gap-2">- <LemonButton type="secondary" onClick={closeSourceModal}>- Cancel- </LemonButton>- <LemonButton- type="primary"- onClick={submitCustomPropertySourceForm}- loading={isCustomPropertySourceFormSubmitting}- disabledReason={noViews ? 'No materialized views are available' : undefined}- >- {editing ? 'Save' : 'Configure sync'}- </LemonButton>- </div>- </div>- }- >- {noViews ? (- <LemonBanner type="info">- No materialized views found. Create and materialize a view in the data warehouse first, then it can- feed this property.- </LemonBanner>- ) : (- <Form- logic={customPropertyDefinitionsLogic}- formKey="customPropertySourceForm"- enableFormOnSubmit- className="flex flex-col gap-4"- >- <LemonField name="savedQuery" label="View">- {({ value, onChange }) => (- <LemonSearchableSelect- value={value}- onChange={(newValue) => {- onChange(newValue)- // Columns are view-specific, so a view change invalidates the picks.- setCustomPropertySourceFormValue('sourceColumn', null)- setCustomPropertySourceFormValue('keyColumn', null)- }}- options={materializedViews.map((view) => ({ value: view.id, label: view.name }))}- loading={savedQueriesLoading}- disabledReason={editing ? 'The view is fixed once a sync is created' : undefined}- placeholder="Select a materialized view"- fullWidth- />- )}- </LemonField>- <LemonField- name="sourceColumn"- label="Value column"- help="The column whose value is written to this property."- >- {({ value, onChange }) => (- <LemonSearchableSelect- value={value}- onChange={onChange}- options={sourceModalColumns.map((column) => ({ value: column, label: column }))}- loading={savedQueriesLoading}- disabledReason={- !customPropertySourceForm.savedQuery ? 'Select a view first' : undefined- }- placeholder="Column to read the value from"- fullWidth- />- )}- </LemonField>- <LemonField- name="keyColumn"- label="Key column"- help="The column matched against each account's external ID."- >- {({ value, onChange }) => (- <LemonSearchableSelect- value={value}- onChange={onChange}- options={sourceModalColumns.map((column) => ({ value: column, label: column }))}- loading={savedQueriesLoading}- disabledReason={- !customPropertySourceForm.savedQuery ? 'Select a view first' : undefined- }- placeholder="Column matching the account external ID"- fullWidth- />- )}- </LemonField>- <LemonField name="isEnabled">- {({ value, onChange }) => (- <LemonSwitch checked={value} onChange={onChange} label="Sync enabled" bordered />- )}- </LemonField>- </Form>- )}- </LemonModal>- )-}diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.test.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.test.tsindex 204ff1675ce8..3f520aa9d35c 100644--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.test.ts+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.test.ts@@ -302,99 +302,6 @@ describe('customPropertyDefinitionsLogic', () => {expect(sourceDeleted).toBe(true)})- it('hydrates the source modal form when configuring an existing source', async () => {- useMocks(defaultMocks())- mountLogic()- await expectLogic(logic, () => logic.actions.openSourceModal(buildDefinition({ source: buildSource() })))- .toDispatchActions(['loadSavedQueries', 'loadSavedQueriesSuccess'])- .toFinishAllListeners()-- expect(logic.values.sourceModalVisible).toBe(true)- expect(logic.values.customPropertySourceForm).toEqual({- savedQuery: 'view-1',- sourceColumn: 'mrr',- keyColumn: 'org_id',- isEnabled: true,- })- })-- it('exposes the selected view columns for the source modal pickers', async () => {- useMocks(defaultMocks())- mountLogic()- await expectLogic(logic, () => logic.actions.openSourceModal(buildDefinition())).toDispatchActions([- 'loadSavedQueriesSuccess',- ])- logic.actions.setCustomPropertySourceFormValue('savedQuery', 'view-1')- expect(logic.values.sourceModalColumns).toEqual(['org_id', 'mrr'])- })-- it('creates a source from the source modal', async () => {- let postedBody: Record<string, any> | null = null- useMocks({- ...defaultMocks(),- post: {- ...defaultMocks().post,- [SOURCES_URL]: async ({ request }) => {- postedBody = (await request.json()) as Record<string, any>- return buildSource()- },- },- })- mountLogic()- logic.actions.openSourceModal(buildDefinition())- logic.actions.setCustomPropertySourceFormValues({- savedQuery: 'view-1',- sourceColumn: 'mrr',- keyColumn: 'org_id',- isEnabled: true,- })-- await expectLogic(logic, () => logic.actions.submitCustomPropertySourceForm()).toDispatchActions([- 'submitCustomPropertySourceFormSuccess',- 'loadDefinitions',- 'closeSourceModal',- ])- expect(postedBody).toEqual({- definition: 'def-1',- saved_query: 'view-1',- source_column: 'mrr',- key_column: 'org_id',- is_enabled: true,- })- })-- it('updates an existing source from the source modal without the create-only fields', async () => {- let patchedBody: Record<string, any> | null = null- useMocks({- ...defaultMocks(),- patch: {- ...defaultMocks().patch,- [SOURCE_URL]: async ({ request }) => {- patchedBody = (await request.json()) as Record<string, any>- return buildSource()- },- },- })- mountLogic()- logic.actions.openSourceModal(buildDefinition({ source: buildSource() }))- logic.actions.setCustomPropertySourceFormValue('isEnabled', false)-- await expectLogic(logic, () => logic.actions.submitCustomPropertySourceForm()).toDispatchActions([- 'submitCustomPropertySourceFormSuccess',- ])- expect(patchedBody).toEqual({ source_column: 'mrr', key_column: 'org_id', is_enabled: false })- })-- it('removes a source and closes the source modal', async () => {- useMocks(defaultMocks())- mountLogic()- const definition = buildDefinition({ source: buildSource() })- await expectLogic(logic, () => logic.actions.removeSource({ definition })).toDispatchActions([- 'removeSourceSuccess',- 'closeSourceModal',- ])- })-it('fails the workflow CTA with a field error when the name is missing', async () => {useMocks(defaultMocks())mountLogic()diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.tsindex 33f8be159a31..7425eabff6cf 100644--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.ts+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.ts@@ -54,20 +54,6 @@ const DEFAULT_FORM_VALUES: CustomPropertyFormValues = {isEnabled: true,}-export interface CustomPropertySourceFormValues {- savedQuery: string | null- sourceColumn: string | null- keyColumn: string | null- isEnabled: boolean-}--const DEFAULT_SOURCE_FORM_VALUES: CustomPropertySourceFormValues = {- savedQuery: null,- sourceColumn: null,- keyColumn: null,- isEnabled: true,-}-const serializeDefinition = ({name,description,@@ -114,8 +100,6 @@ export const customPropertyDefinitionsLogic = kea<customPropertyDefinitionsLogicopenEditModal: (definition: CustomPropertyDefinitionApi) => ({ definition }),closeModal: true,setEditingDefinition: (definition: CustomPropertyDefinitionApi) => ({ definition }),- openSourceModal: (definition: CustomPropertyDefinitionApi) => ({ definition }),- closeSourceModal: true,}),reducers({modalVisible: [@@ -135,20 +119,6 @@ export const customPropertyDefinitionsLogic = kea<customPropertyDefinitionsLogiccloseModal: () => null,},],- sourceModalVisible: [- false,- {- openSourceModal: () => true,- closeSourceModal: () => false,- },- ],- sourceDefinition: [- null as CustomPropertyDefinitionApi | null,- {- openSourceModal: (_, { definition }) => definition,- closeSourceModal: () => null,- },- ],}),loaders(({ actions, values }) => ({definitions: [@@ -162,18 +132,6 @@ export const customPropertyDefinitionsLogic = kea<customPropertyDefinitionsLogicawait customPropertyDefinitionsDestroy(String(values.currentProjectId), id)return values.definitions.filter((definition) => definition.id !== id)},- removeSource: async ({- definition,- }: {- definition: CustomPropertyDefinitionApi- }): Promise<CustomPropertyDefinitionApi[]> => {- if (definition.source) {- await customPropertySourcesDestroy(String(values.currentProjectId), definition.source.id)- }- // Re-fetch so the cleared `source` is reflected — it can't be derived locally.- const response = await customPropertyDefinitionsList(String(values.currentProjectId))- return response.results- },},],savedQueries: [@@ -259,36 +217,6 @@ export const customPropertyDefinitionsLogic = kea<customPropertyDefinitionsLogic}},},- customPropertySourceForm: {- defaults: DEFAULT_SOURCE_FORM_VALUES,- errors: ({ savedQuery, sourceColumn, keyColumn }: CustomPropertySourceFormValues) => ({- savedQuery: !savedQuery ? 'Select a view' : undefined,- sourceColumn: !sourceColumn ? 'Select the value column' : undefined,- keyColumn: !keyColumn ? 'Select the key column' : undefined,- }),- submit: async ({ savedQuery, sourceColumn, keyColumn, isEnabled }: CustomPropertySourceFormValues) => {- const definition = values.sourceDefinition- if (!definition || !savedQuery || !sourceColumn || !keyColumn) {- return- }- if (definition.source) {- // saved_query is create-only — only the mutable fields are sent on update.- await customPropertySourcesPartialUpdate(String(values.currentProjectId), definition.source.id, {- source_column: sourceColumn,- key_column: keyColumn,- is_enabled: isEnabled,- })- } else {- await customPropertySourcesCreate(String(values.currentProjectId), {- definition: definition.id,- saved_query: savedQuery,- source_column: sourceColumn,- key_column: keyColumn,- is_enabled: isEnabled,- })- }- },- },})),selectors({materializedViews: [@@ -303,13 +231,6 @@ export const customPropertyDefinitionsLogic = kea<customPropertyDefinitionsLogicreturn (view?.columns ?? []).map((column) => column.name)},],- sourceModalColumns: [- (s) => [s.savedQueries, s.customPropertySourceForm],- (savedQueries: DataWarehouseSavedQuery[], form: CustomPropertySourceFormValues): string[] => {- const view = savedQueries.find((query) => query.id === form.savedQuery)- return (view?.columns ?? []).map((column) => column.name)- },- ],editingReferences: [(s) => [s.definitions, s.editingDefinition],(@@ -324,7 +245,7 @@ export const customPropertyDefinitionsLogic = kea<customPropertyDefinitionsLogic},],}),- listeners(({ actions, values }) => ({+ listeners(({ actions }) => ({openCreateModal: () => {actions.resetCustomPropertyForm()actions.loadSavedQueries()@@ -378,36 +299,6 @@ export const customPropertyDefinitionsLogic = kea<customPropertyDefinitionsLogicposthog.captureException(error, { scope: 'customPropertyDefinitionsLogic.load' })lemonToast.error('Failed to load custom properties')},- openSourceModal: ({ definition }) => {- actions.loadSavedQueries()- if (definition.source) {- actions.setCustomPropertySourceFormValues({- savedQuery: definition.source.saved_query,- sourceColumn: definition.source.source_column,- keyColumn: definition.source.key_column,- isEnabled: definition.source.is_enabled ?? true,- })- } else {- actions.resetCustomPropertySourceForm()- }- },- submitCustomPropertySourceFormSuccess: () => {- lemonToast.success(values.sourceDefinition?.source ? 'Sync updated' : 'Sync configured')- actions.loadDefinitions()- actions.closeSourceModal()- },- submitCustomPropertySourceFormFailure: ({ error }) => {- posthog.captureException(error, { scope: 'customPropertyDefinitionsLogic.submitSource' })- lemonToast.error((error as { detail?: string })?.detail ?? 'Failed to save sync configuration')- },- removeSourceSuccess: () => {- lemonToast.success('Sync removed')- actions.closeSourceModal()- },- removeSourceFailure: ({ error }) => {- posthog.captureException(error, { scope: 'customPropertyDefinitionsLogic.removeSource' })- lemonToast.error('Failed to remove sync')- },createWorkflowForPropertySuccess: ({ newWorkflowUrl }) => {if (newWorkflowUrl && window.open(newWorkflowUrl, '_blank')) {lemonToast.success('Workflow editor opened in a new tab — save the workflow there, then refresh')