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.

chore(cdp): stop writing $transformations_* event properties (#87659)

Ben White63f2650d0f6f
diff --git a/frontend/src/scenes/hog-functions/configuration/hogFunctionTestLogic.tsx b/frontend/src/scenes/hog-functions/configuration/hogFunctionTestLogic.tsx
index 283d88bd40a4..9cb922fa54c6 100644
--- a/frontend/src/scenes/hog-functions/configuration/hogFunctionTestLogic.tsx
+++ b/frontend/src/scenes/hog-functions/configuration/hogFunctionTestLogic.tsx
@@ -41,10 +41,6 @@ export type HogTransformationEvent = {
const convertToTransformationEvent = (result: any): HogTransformationEvent => {
const properties = result.properties ?? {}
- // We don't want to use these values given they will change in the test invocation
- delete properties.$transformations_failed
- delete properties.$transformations_succeeded
- delete properties.$transformations_skipped
return {
event: result.event,
uuid: result.uuid,
@@ -55,9 +51,6 @@ const convertToTransformationEvent = (result: any): HogTransformationEvent => {
}
const convertFromTransformationEvent = (result: HogTransformationEvent): Record<string, any> => {
- delete result.properties.$transformations_failed
- delete result.properties.$transformations_succeeded
- delete result.properties.$transformations_skipped
return {
event: result.event,
uuid: result.uuid,
diff --git a/frontend/src/taxonomy/core-filter-definitions-by-group.json b/frontend/src/taxonomy/core-filter-definitions-by-group.json
index d07d7c716d41..86ccd94ed8b6 100644
--- a/frontend/src/taxonomy/core-filter-definitions-by-group.json
+++ b/frontend/src/taxonomy/core-filter-definitions-by-group.json
@@ -3386,22 +3386,6 @@
"description": "The location of a Touch event on the Y axis",
"label": "Touch Y"
},
- "$transformations_failed": {
- "description": "The transformations that failed to run on this event during ingestion.",
- "ignored_in_assistant": true,
- "label": "Transformations failed",
- "type": "String"
- },
- "$transformations_skipped": {
- "description": "Array of transformations skipped during ingestion.",
- "label": "Transformations skipped",
- "used_for_debug": true
- },
- "$transformations_succeeded": {
- "description": "Array of transformations that succeeded during ingestion.",
- "label": "Transformations succeeded",
- "used_for_debug": true
- },
"$update_person_last_seen_at": {
"description": "When set to false, the event will not update the person's last_seen_at timestamp",
"label": "Update last seen at",
@@ -8332,22 +8316,6 @@
"description": "The location of a Touch event on the Y axis",
"label": "Touch Y"
},
- "$transformations_failed": {
- "description": "The transformations that failed to run on this event during ingestion.",
- "ignored_in_assistant": true,
- "label": "Transformations failed",
- "type": "String"
- },
- "$transformations_skipped": {
- "description": "Array of transformations skipped during ingestion.",
- "label": "Transformations skipped",
- "used_for_debug": true
- },
- "$transformations_succeeded": {
- "description": "Array of transformations that succeeded during ingestion.",
- "label": "Transformations succeeded",
- "used_for_debug": true
- },
"$update_person_last_seen_at": {
"description": "When set to false, the event will not update the person's last_seen_at timestamp",
"label": "Update last seen at",
diff --git a/nodejs/src/cdp/cdp-api.test.ts b/nodejs/src/cdp/cdp-api.test.ts
index deeb468da1a9..c8c878566686 100644
--- a/nodejs/src/cdp/cdp-api.test.ts
+++ b/nodejs/src/cdp/cdp-api.test.ts
@@ -607,9 +607,6 @@ describe('CDP API', () => {
"now": "",
"properties": {
"$lib_version": "1.0.0",
- "$transformations_succeeded": [
- "Filter Out Plugin (<REPLACED-UUID-1>)",
- ],
},
"site_url": "http://localhost:8000/project/2",
"team_id": 2,
diff --git a/nodejs/src/cdp/hog-transformations/hog-transformer.service.test.ts b/nodejs/src/cdp/hog-transformations/hog-transformer.service.test.ts
index 270a712cbc7e..c7e97e448672 100644
--- a/nodejs/src/cdp/hog-transformations/hog-transformer.service.test.ts
+++ b/nodejs/src/cdp/hog-transformations/hog-transformer.service.test.ts
@@ -161,9 +161,6 @@ describe('HogTransformer', () => {
"$initial_geoip_subdivision_2_name": null,
"$initial_geoip_time_zone": "America/Los_Angeles",
},
- "$transformations_succeeded": [
- "GeoIP (d77e792e-0f35-431b-a983-097534aa4767)",
- ],
}
`)
})
@@ -239,9 +236,6 @@ describe('HogTransformer', () => {
"properties": {
"$current_url": "https://example.com",
"$ip": "216.160.83.56",
- "$transformations_succeeded": [
- "Modifier (d77e792e-0f35-431b-a983-097534aa4767)",
- ],
"test_property": "modified-test-value",
},
"site_url": "http://localhost",
@@ -625,7 +619,7 @@ describe('HogTransformer', () => {
expect(executeHogFunctionSpy.mock.calls[2][0]).toMatchObject({ execution_order: null })
})
- it('should track successful and failed transformations', async () => {
+ it('should keep applying transformations after one returns an invalid result', async () => {
// Create a successful transformation
const successTemplate: HogFunctionTemplate = {
free: true,
@@ -699,11 +693,9 @@ describe('HogTransformer', () => {
const result = await hogTransformer.transformEventAndProduceMessages(event)
- // Verify the event has both success and failure tracking
+ // The failing transformation's invalid result is discarded, the successful one still applies
expect(result.event?.properties).toEqual({
- success: true, // From successful transformation
- $transformations_succeeded: [`Success Template (${successFunction.id})`],
- $transformations_failed: [`Failing Template (${failFunction.id})`],
+ success: true,
})
})
@@ -783,7 +775,7 @@ describe('HogTransformer', () => {
})
})
- it('should not add transformation tracking properties if no transformations run', async () => {
+ it('should leave the event untouched if no transformations run', async () => {
const event = createPluginEvent(
{
event: 'test',
@@ -794,15 +786,12 @@ describe('HogTransformer', () => {
const result = await hogTransformer.transformEventAndProduceMessages(event)
- // Verify the event properties are unchanged
expect(result.event?.properties).toEqual({
original: true,
})
- expect(result.event?.properties).not.toHaveProperty('$transformations_succeeded')
- expect(result.event?.properties).not.toHaveProperty('$transformations_failed')
})
- it('should ignore existing transformation results when adding new ones', async () => {
+ it('should strip incoming transformation tracking properties', async () => {
const successTemplate: HogFunctionTemplate = {
free: true,
status: 'beta',
@@ -840,6 +829,7 @@ describe('HogTransformer', () => {
properties: {
$transformations_succeeded: ['Previous Success (prev-id)'],
$transformations_failed: {}, // malformed value
+ $transformations_skipped: ['Previous Skip (prev-id)'],
},
},
teamId
@@ -847,70 +837,13 @@ describe('HogTransformer', () => {
const result = await hogTransformer.transformEventAndProduceMessages(event)
- // Verify new results are appended to existing ones
- expect(result?.event?.properties?.$transformations_succeeded).toEqual([
- `Success Template (${successFunction.id})`,
- ])
- expect(result?.event?.properties?.$transformations_failed).toEqual(undefined)
- })
-
- it('should track skipped transformations when filter does not match', async () => {
- const filterTemplate = {
- free: true,
- status: 'beta',
- type: 'transformation',
- id: 'template-test',
- name: 'Filter Template',
- description: 'A template that should be skipped when filter does not match',
- category: ['Custom'],
- hog: `
- let returnEvent := event
- returnEvent.properties.should_not_be_set := true
- return returnEvent
- `,
- inputs_schema: [],
- }
-
- const hogFunction = createHogFunction({
- type: 'transformation',
- name: filterTemplate.name,
- team_id: teamId,
- enabled: true,
- bytecode: await compileHog(filterTemplate.hog),
- filters: {
- bytecode: await compileHog(`
- return event = 'match-me'
- `),
- events: [{ id: 'match-me', name: 'match-me', type: 'events', order: 0 }],
- },
+ // A client cannot inject these retired properties, and nothing re-adds them
+ expect(result?.event?.properties).toEqual({
+ success: true,
})
-
- await insertHogFunction(hub.postgres, teamId, hogFunction)
- hogTransformer['hogFunctionManager']['onHogFunctionsReloaded'](teamId, [hogFunction.id])
-
- const event = createPluginEvent(
- {
- event: 'does-not-match-me',
- properties: {
- original: true,
- },
- },
- teamId
- )
-
- const result = await hogTransformer.transformEventAndProduceMessages(event)
-
- // Verify transformation was skipped and tracked
- expect(result.event?.properties?.should_not_be_set).toBeUndefined()
- expect(result.event?.properties?.$transformations_skipped).toEqual([
- `${hogFunction.name} (${hogFunction.id})`,
- ])
- expect(result.event?.properties?.original).toBe(true)
- expect(result.event?.properties?.$transformations_succeeded).toBeUndefined()
- expect(result.event?.properties?.$transformations_failed).toBeUndefined()
})
- it('should catch thrown executeHogFunction errors without crashing, track failure, and queue app metric', async () => {
+ it('should catch thrown executeHogFunction errors without crashing and queue app metric', async () => {
const successTemplate: HogFunctionTemplate = {
free: true,
status: 'beta',
@@ -964,12 +897,7 @@ describe('HogTransformer', () => {
const event = createPluginEvent({ event: 'test', properties: {} }, teamId)
const result = await hogTransformer.transformEventAndProduceMessages(event)
- expect(result.event?.properties?.$transformations_failed).toEqual([
- `Broken Template (${brokenFunction.id})`,
- ])
- expect(result.event?.properties?.$transformations_succeeded).toEqual([
- `Success Template (${successFunction.id})`,
- ])
+ // The thrown error is swallowed and the next transformation still runs
expect(result.event?.properties?.success).toBe(true)
expect(queueAppMetricSpy).toHaveBeenCalledWith(
@@ -987,7 +915,7 @@ describe('HogTransformer', () => {
queueAppMetricSpy.mockRestore()
})
- it('should track both successful and skipped transformations in sequence', async () => {
+ it('should apply a matching transformation and skip a filtered one in sequence', async () => {
const successTemplate = {
free: true,
status: 'beta',
@@ -1055,20 +983,9 @@ describe('HogTransformer', () => {
const event = createPluginEvent({ event: 'does-not-match' }, teamId)
const result = await hogTransformer.transformEventAndProduceMessages(event)
- // Verify that:
- // 1. First transformation succeeded (property was set)
- // 2. Second transformation was skipped (property was NOT set)
- // 3. We have correct tracking properties
+ // First transformation ran, second was filtered out
expect(result.event?.properties?.success).toBe(true)
expect(result.event?.properties?.should_not_be_set).toBeUndefined()
-
- // Check that transformations_succeeded and transformations_skipped arrays contain the right functions
- expect(result.event?.properties?.$transformations_succeeded).toContain(
- `Success Template (${successFunction.id})`
- )
- expect(result.event?.properties?.$transformations_skipped).toContain(
- `Skipped Template (${skippedFunction.id})`
- )
})
})
@@ -1123,9 +1040,6 @@ describe('HogTransformer', () => {
"properties": {
"$current_url": "https://example.com",
"$ip": "216.160.83.56",
- "$transformations_succeeded": [
- "Filter Out Plugin (c342e9ae-9f76-4379-a465-d33b4826bc05)",
- ],
},
"site_url": "http://localhost",
"team_id": 2,
@@ -1223,10 +1137,6 @@ describe('HogTransformer', () => {
"$initial_geoip_subdivision_2_name": null,
"$initial_geoip_time_zone": "America/Los_Angeles",
},
- "$transformations_succeeded": [
- "GeoIP (<REPLACED-UUID-0>)",
- "Property Filter (<REPLACED-UUID-1>)",
- ],
},
"site_url": "http://localhost",
"team_id": 2,
@@ -1272,16 +1182,11 @@ describe('HogTransformer', () => {
await insertHogFunction(hub.postgres, teamId, hogFunction)
hogTransformer['hogFunctionManager']['onHogFunctionsReloaded'](teamId, [hogFunction.id])
- const event = createPluginEvent({ event: 'does-not-match-me' }, teamId)
+ const event = createPluginEvent({ event: 'does-not-match-me', properties: { original: true } }, teamId)
const result = await hogTransformer.transformEventAndProduceMessages(event)
- // Verify transformation was skipped
- expect(result.event?.properties?.should_not_be_set).toBeUndefined()
- expect(result.event?.properties?.$transformations_succeeded).toBeUndefined()
- expect(result.event?.properties?.$transformations_failed).toBeUndefined()
- expect(result.event?.properties?.$transformations_skipped).toEqual([
- `${hogFunction.name} (${hogFunction.id})`,
- ])
+ // The transformation never ran, and the event is passed through untouched
+ expect(result.event?.properties).toEqual({ original: true })
})
it('should apply transformation when filter matches', async () => {
@@ -1325,9 +1230,6 @@ describe('HogTransformer', () => {
// Verify transformation was applied
expect(matchResult.event?.properties?.test_property).toBe('test_value')
- expect(matchResult.event?.properties?.$transformations_succeeded).toContain(
- `${hogFunction.name} (${hogFunction.id})`
- )
// Test event that shouldn't match the filter
const nonMatchingEvent = createPluginEvent({ event: 'dont-match-me' }, teamId)
@@ -1335,11 +1237,6 @@ describe('HogTransformer', () => {
// Verify transformation was skipped
expect(nonMatchResult.event?.properties?.test_property).toBeUndefined()
- expect(nonMatchResult.event?.properties?.$transformations_succeeded).toBeUndefined()
- expect(nonMatchResult.event?.properties?.$transformations_failed).toBeUndefined()
- expect(nonMatchResult.event?.properties?.$transformations_skipped).toEqual([
- `${hogFunction.name} (${hogFunction.id})`,
- ])
})
it('should apply transformation when no filters are defined', async () => {
@@ -1376,9 +1273,6 @@ describe('HogTransformer', () => {
// Verify transformation was applied
expect(result.event?.properties?.no_filter_property).toBe('applied')
- expect(result.event?.properties?.$transformations_succeeded).toContain(
- `${hogFunction.name} (${hogFunction.id})`
- )
})
it('should skip transformation when filter errors and not continue processing', async () => {
@@ -1451,10 +1345,8 @@ describe('HogTransformer', () => {
const event = createPluginEvent({ event: 'test-event' }, teamId)
const result = await hogTransformer.transformEventAndProduceMessages(event)
- // Verify one transformation was applied and the other was skipped
- expect(result.event?.properties?.$transformations_skipped).toContain(
- `${errorFunction.name} (${errorFunction.id})`
- )
+ // The erroring filter skips its transformation without setting its property
+ expect(result.event?.properties?.error_filter_property).toBeUndefined()
expect(queueAppMetricsSpy).toHaveBeenCalledWith(
expect.arrayContaining([
expect.objectContaining({
@@ -1473,9 +1365,6 @@ describe('HogTransformer', () => {
)
expect(result.event?.properties?.working_property).toBe('working')
- expect(result.event?.properties?.$transformations_succeeded).toContain(
- `${workingFunction.name} (${workingFunction.id})`
- )
queueAppMetricsSpy.mockRestore()
queueLogsSpy.mockRestore()
@@ -1528,11 +1417,6 @@ describe('HogTransformer', () => {
// Verify transformation was skipped since no filters matched
expect(result.event?.properties?.should_not_be_set).toBeUndefined()
- expect(result.event?.properties?.$transformations_succeeded).toBeUndefined()
- expect(result.event?.properties?.$transformations_failed).toBeUndefined()
- expect(result.event?.properties?.$transformations_skipped).toEqual([
- `${hogFunction.name} (${hogFunction.id})`,
- ])
})
it('should apply transformation when at least one of multiple filters match', async () => {
@@ -1578,9 +1462,6 @@ describe('HogTransformer', () => {
// Verify transformation was applied since one filter matched
expect(result.event?.properties?.should_be_set).toBe(true)
- expect(result.event?.properties?.$transformations_succeeded).toContain(
- `${hogFunction.name} (${hogFunction.id})`
- )
})
})
@@ -1673,7 +1554,6 @@ describe('HogTransformer', () => {
expect(mockHogvmNode.executeSync.mock.calls[0][0]).toEqual(bytecode)
expect(result.event?.properties).toEqual({
from_rust: true,
- $transformations_succeeded: ['Rust routed (bbbbbbbb-bbbb-4bbb-bbbb-bbbbbbbbbbbb)'],
})
})
@@ -1688,10 +1568,12 @@ describe('HogTransformer', () => {
const result = await hogTransformer.transformEventAndProduceMessages(createPluginEvent({}, teamId))
expect(mockHogvmNode.executeSync).toHaveBeenCalledTimes(1)
- // The node vm ran the real bytecode: the event survives with its original properties.
+ // The node vm ran the real bytecode: the invocation succeeded and the event survives
+ // with its original properties, rather than carrying the rust vm's error.
+ expect(result.invocationResults).toHaveLength(1)
+ expect(result.invocationResults[0].error).toBeFalsy()
expect(result.event?.properties).toMatchObject({
$current_url: 'https://example.com',
- $transformations_succeeded: ['Rust routed (bbbbbbbb-bbbb-4bbb-bbbb-bbbbbbbbbbbb)'],
})
})
})
diff --git a/nodejs/src/cdp/hog-transformations/hog-transformer.service.ts b/nodejs/src/cdp/hog-transformations/hog-transformer.service.ts
index 16e379f8e196..b6cd338b17d6 100644
--- a/nodejs/src/cdp/hog-transformations/hog-transformer.service.ts
+++ b/nodejs/src/cdp/hog-transformations/hog-transformer.service.ts
@@ -168,16 +168,11 @@ export class HogTransformerService implements HogTransformer {
}
const results: CyclotronJobInvocationResult[] = []
- const transformationsSucceeded: string[] = []
- const transformationsFailed: string[] = []
- const transformationsSkipped: string[] = []
// Create globals once and update the event properties after each transformation
const globals = this.createInvocationGlobals(event)
for (const hogFunction of teamHogFunctions) {
- const transformationIdentifier = `${hogFunction.name} (${hogFunction.id})`
-
// Create filterGlobals for each iteration - it references globals.event.properties
// which gets updated after each successful transformation
const filterGlobals = convertToHogFunctionFilterGlobal(globals)
@@ -195,7 +190,6 @@ export class HogTransformerService implements HogTransformer {
this.hogFunctionMonitoringService.queueLogs(filterResults.logs, 'hog_function')
if (!filterResults.match) {
- transformationsSkipped.push(transformationIdentifier)
continue
}
}
@@ -220,14 +214,12 @@ export class HogTransformerService implements HogTransformer {
},
'hog_function'
)
- transformationsFailed.push(transformationIdentifier)
continue
}
results.push(result)
if (result.error) {
- transformationsFailed.push(transformationIdentifier)
continue
}
@@ -243,7 +235,6 @@ export class HogTransformerService implements HogTransformer {
},
'hog_function'
)
- transformationsFailed.push(transformationIdentifier)
return {
event: null,
invocationResults: results,
@@ -263,7 +254,6 @@ export class HogTransformerService implements HogTransformer {
logger.error('⚠️', 'Invalid transformation result - missing or invalid properties', {
function_id: hogFunction.id,
})
- transformationsFailed.push(transformationIdentifier)
continue
}
@@ -276,7 +266,6 @@ export class HogTransformerService implements HogTransformer {
function_id: hogFunction.id,
event: transformedEvent.event,
})
- transformationsFailed.push(transformationIdentifier)
continue
}
event.event = transformedEvent.event
@@ -288,7 +277,6 @@ export class HogTransformerService implements HogTransformer {
function_id: hogFunction.id,
distinct_id: transformedEvent.distinct_id,
})
- transformationsFailed.push(transformationIdentifier)
continue
}
event.distinct_id = transformedEvent.distinct_id
@@ -298,26 +286,6 @@ export class HogTransformerService implements HogTransformer {
globals.event.properties = event.properties
globals.event.event = event.event
globals.event.distinct_id = event.distinct_id
-
- transformationsSucceeded.push(transformationIdentifier)
- }
-
- // Use direct property assignment instead of spreading to avoid copying the entire object
- if (
- transformationsFailed.length > 0 ||
- transformationsSkipped.length > 0 ||
- transformationsSucceeded.length > 0
- ) {
- event.properties = event.properties || {}
- if (transformationsFailed.length > 0) {
- event.properties.$transformations_failed = transformationsFailed
- }
- if (transformationsSkipped.length > 0) {
- event.properties.$transformations_skipped = transformationsSkipped
- }
- if (transformationsSucceeded.length > 0) {
- event.properties.$transformations_succeeded = transformationsSucceeded
- }
}
return {
@@ -327,7 +295,7 @@ export class HogTransformerService implements HogTransformer {
}
public transformEvent(event: PluginEvent, teamHogFunctions: HogFunctionType[]): Promise<TransformationResult> {
- // Sanitize transform event properties
+ // These properties are retired, so drop any a client sends rather than letting them through
if (event.properties) {
for (const key of ['$transformations_failed', '$transformations_skipped', '$transformations_succeeded']) {
if (key in event.properties) {
diff --git a/posthog/taxonomy/taxonomy.py b/posthog/taxonomy/taxonomy.py
index 1a5c632232f2..0d7947daa273 100644
--- a/posthog/taxonomy/taxonomy.py
+++ b/posthog/taxonomy/taxonomy.py
@@ -694,16 +694,6 @@ CORE_FILTER_DEFINITIONS_BY_GROUP: dict[str, dict[str, CoreFilterDefinition]] = {
"type": "String",
"used_for_debug": True,
},
- "$transformations_skipped": {
- "label": "Transformations skipped",
- "description": "Array of transformations skipped during ingestion.",
- "used_for_debug": True,
- },
- "$transformations_succeeded": {
- "label": "Transformations succeeded",
- "description": "Array of transformations that succeeded during ingestion.",
- "used_for_debug": True,
- },
"$config_defaults": {
"label": "Config defaults",
"description": "The version of the PostHog config defaults that were used when capturing the event.",
@@ -3433,12 +3423,6 @@ CORE_FILTER_DEFINITIONS_BY_GROUP: dict[str, dict[str, CoreFilterDefinition]] = {
"examples": [9.99],
"type": "Numeric",
},
- "$transformations_failed": {
- "label": "Transformations failed",
- "description": "The transformations that failed to run on this event during ingestion.",
- "type": "String",
- "ignored_in_assistant": True,
- },
"$override_feature_flag_payloads": {
"label": "Override feature flag payloads",
"description": "Feature flag payloads attached to the event, overriding the evaluated payloads.",