: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
import { EventIngestionRestrictionManager, RestrictionType } from '~/common/utils/event-ingestion-restrictions'
import { ok } from '~/ingestion/framework/results'
import { ProcessingStep } from '~/ingestion/framework/steps'
import { EventHeaders, PipelineEvent, Team } from '~/types'
function applyPersonProcessingRestrictions(
event: PipelineEvent,
headers: EventHeaders,
restrictions: ReadonlySet<RestrictionType>,
team_person_processing_opt_out: boolean
): void {
const hasSkipRestriction = restrictions.has(RestrictionType.SKIP_PERSON_PROCESSING)
const shouldSkipPerson = hasSkipRestriction || team_person_processing_opt_out
if (shouldSkipPerson) {
if (event.properties) {
event.properties.$process_person_profile = false
} else {
event.properties = { $process_person_profile: false }
}
}
if (hasSkipRestriction) {
headers.force_disable_person_processing = true
}
}
export function createApplyPersonProcessingRestrictionsStep<
T extends { event: PipelineEvent; team: Team; headers: EventHeaders },
>(eventIngestionRestrictionManager: EventIngestionRestrictionManager): ProcessingStep<T, T> {
return async function applyPersonProcessingRestrictionsStep(input) {
const { event, team, headers } = input
const restrictions = eventIngestionRestrictionManager.getAppliedRestrictions(headers.token, headers)
applyPersonProcessingRestrictions(event, headers, restrictions, team.person_processing_opt_out ?? false)
return Promise.resolve(ok(input))
}
}