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.

fix(customer-analytics): treat already-deleted custom property (404) as a successful delete (#68774)

posthog[bot]19b286d526f4
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.test.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.test.ts
index b1d4446bfb3b..5bc7df79ec15 100644
--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.test.ts
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.test.ts
@@ -214,6 +214,20 @@ describe('customPropertyDefinitionsLogic', () => {
.toMatchValues({ definitions: [] })
})
+ it('treats an already-deleted definition (404) as a successful delete', async () => {
+ useMocks({
+ ...defaultMocks(),
+ delete: { ...defaultMocks().delete, [DEFINITION_URL]: () => [404, { detail: 'Not found.' }] },
+ })
+ mountLogic()
+ await expectLogic(logic).toDispatchActions(['loadDefinitionsSuccess'])
+ // A 404 refreshes the table instead of surfacing a failure toast/exception.
+ await expectLogic(logic, () => logic.actions.deleteDefinition({ id: 'def-1' })).toDispatchActions([
+ 'deleteDefinitionFailure',
+ 'loadDefinitions',
+ ])
+ })
+
it('exposes the selected view columns for the pickers', 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.ts
index 8b6b9d4f624a..22132575d3f6 100644
--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.ts
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.ts
@@ -319,8 +319,15 @@ export const customPropertyDefinitionsLogic = kea<customPropertyDefinitionsLogic
deleteDefinitionSuccess: () => {
lemonToast.success('Custom property deleted')
},
- deleteDefinitionFailure: ({ error }) => {
- posthog.captureException(error, { scope: 'customPropertyDefinitionsLogic.delete' })
+ deleteDefinitionFailure: ({ errorObject }) => {
+ // An already-deleted definition (double-click, stale table, concurrent delete) 404s.
+ // The delete effectively succeeded, so refresh the table without capturing an exception.
+ if ((errorObject as { status?: number })?.status === 404) {
+ actions.loadDefinitions()
+ lemonToast.success('Custom property deleted')
+ return
+ }
+ posthog.captureException(errorObject, { scope: 'customPropertyDefinitionsLogic.delete' })
lemonToast.error('Failed to delete custom property')
},
loadDefinitionsFailure: ({ error }) => {