Repository navigation
feat: persons v2 ($set semantics, search, detail, merge, delete) + complete GDPR coverage - #14
Merged
Merged
Conversation
…e) and complete GDPR coverage
- identify accepts set_once / unset; any event's $set / $set_once / $unset
properties update (or create) the person: traits = ((set_once || traits) || set) - unset
- /api/v2/persons/query: search (visitor id, user id, property values),
person-property and cohort filters, ordering, total count
- /api/v2/persons/{id}: profile, aliases, merged ids, event/pageview/session
counts, cohort memberships; /events (newest first, event filter);
/sessions (with recording flag); PATCH /properties
- POST /persons/{id}/merge: move every visitor table's rows to the target,
resolve unique conflicts (exposures, memberships, aliases, cohorts), fill
gaps in the target's properties, and record redirects so events that keep
arriving under merged ids are ingested as the target (Redis hash, warmed
from person_redirects at startup)
- DELETE /persons/{id} (profile only, or ?delete_events=true for GDPR)
- privacy: one VISITOR_TABLES list for delete and merge; GDPR delete/export
now also cover feature_flag_evaluations, guide_events,
event_quality_violations, llm_traces, account_memberships and cohort
memberships (previously left behind)
- migration 034: visitor indexes on pageviews/events, person_redirects
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 411e4c8694
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…rts access
- Bind $3 only for the UPDATE statements in the merge loop.
- Resolve experiment_exposures/account_memberships conflicts between
sources as well as against the target (first-listed source wins).
- GET /api/v2/persons/{id} returns cohorts: null unless the key can read cohorts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and Why
Pulse's persons were a paged list with no search, no filters and no detail tabs. Identify could only overwrite traits;
$set_once,$unsetand person updates from events weren't supported. There was also no way to merge two people.This adds PostHog-style persons: property-update semantics, a searchable and filterable people list, person detail with events and sessions, property editing, merge (with redirects for ids that keep sending events) and delete. It also fixes GDPR delete and export, which were missing six visitor tables.
Stacked on #13 (base
ayush/cohorts-v2); retarget tomainonce the stack below merges.Reference followed:
$setoverwrites,$set_oncesets only if absent,$unsetremoves, applied from identify and from any event's properties.posthog/api/person.py): list/search with property and cohort filters, person events and sessions, property updates,merge, and delete with optional event deletion.person_redirects.Changes
identifynow acceptsset_onceandunset, and events may carry$set,$set_onceand$unsetin their data. Both use one SQL upsert,traits = ((set_once || traits) || set) - unset, which creates the person if needed.POST /api/v2/persons/query:cohortsmodule)last_seen,first_seenoridentified, and a total countGET /api/v2/persons/{id}: profile, aliases, merged ids, pageview/event/session counts, and cohort memberships./events: newest first, filterable by event./sessions: includes a recording flag.PATCH /properties: set, set_once and unset.POST /api/v2/persons/{id}/merge(up to 100 people):person_redirectsat startup.DELETE /api/v2/persons/{id}deletes the profile only, or everything with?delete_events=true(GDPR).VISITOR_TABLESlist now drives both delete and merge. GDPR delete and export previously left behindfeature_flag_evaluations,guide_events,event_quality_violations,llm_traces,account_membershipsand cohort memberships; they're now included.(project_id, visitor_id, created_at)indexes on pageviews and events, plus theperson_redirectstable.identitymodule.Reviews and Follow-up
identityandcohortsmodule gating, merge in a single transactionFiles Changed
migrations/034_persons.{up,down}.sqlservices/persons.rs,routes/persons.rs(new)services/identity.rs:PersonUpdate,apply_person_updateservices/privacy.rs:VISITOR_TABLES, complete delete and exportroutes/ingest.rs: event-level person updates, merge redirectspulse-common/src/types.rs: identifyset_once/unsetroutes/mod.rs,services/mod.rs,main.rsScope and Non-scope
In scope: persons and the privacy completeness fix. Out of scope: groups (next PR), UI, and the excluded LLM/account features.
Validation
I ran this end to end against Postgres 18, sending events through
/api/collectexactly as clients do. The checks cover:$set,$set_onceand$unseton identify and on eventsOne check initially counted a cohort row belonging to a different project. It was corrected to be project-scoped and re-run, and the evidence notes this.
Testing
cargo test: 131 passed, including new tests for$set/$set_once/$unsetextraction.Size and Notes
About 950 changed lines.
CONCURRENTLYon each partition first.Review fixes (beac2a5)
$3is bound only for the UPDATE statements, so merges between people with no aliases no longer fail.experiment_exposuresandaccount_membershipsare resolved between sources as well as against the target. The first-listed source wins.cohortsisnullunless the key can read the cohorts module.🤖 Generated with Claude Code