Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add $process_person property
Browse files Browse the repository at this point in the history
robbie-c committed Apr 3, 2024
1 parent ca24fc4 commit e91ba02
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/posthog-core.ts
Original file line number Diff line number Diff line change
@@ -900,6 +900,27 @@ export class PostHog {
properties = sanitize_properties(properties, event_name)
}

// add person processing flag as very last step, so it cannot be overridden
const process_person =
this.config.process_person === 'always' ||
(this.config.process_person === 'identified_only' && this.persistence.get_user_state() === 'identified')
properties['$process_person'] = process_person

if (!process_person) {
if (properties['$set']) {
logger.error(
'Invalid property $set for event where person processing is disabled. This property will not be set.'
)
delete properties['$set']
}
if (properties['$set_once']) {
logger.error(
'Invalid property $set_once for event where person processing is disabled. This property will not be set.'
)
delete properties['$set_once']
}
}

return properties
}

0 comments on commit e91ba02

Please sign in to comment.