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.

1.0 KB
Raw Blame
import { ok } from '~/ingestion/framework/results'
import { ProcessingStep } from '~/ingestion/framework/steps'
import { PluginEvent } from '~/plugin-scaffold'

export interface StripPersonUpdatePropertiesStepInput {
    normalizedEvent: PluginEvent
}

/**
 * Strips `$set` / `$set_once` from the normalized event for read-only pipelines
 * (e.g. AI). These pipelines never write the person, so createEvent merging
 * `$set` into person_properties (when processPerson is true) would put values on
 * the emitted event that were never persisted. Mutation is safe — the event is
 * consumed downstream.
 */
export function createStripPersonUpdatePropertiesStep<T extends StripPersonUpdatePropertiesStepInput>(): ProcessingStep<
    T,
    T
> {
    return function stripPersonUpdatePropertiesStep(input) {
        const properties = input.normalizedEvent.properties
        if (properties) {
            delete properties.$set
            delete properties.$set_once
        }
        return Promise.resolve(ok(input))
    }
}