feat(cohorts): add automatic backfill for person property changes#53800
feat(cohorts): add automatic backfill for person property changes#53800gustavohstrassburger wants to merge 7 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds automatic triggering of person-property backfill workflows when realtime cohort person-property filter conditions change, to avoid inconsistent cohort membership until a manual backfill is run.
Changes:
- Added pre-save + post-save signal flow to detect person-property filter changes and trigger backfill behind a feature flag.
- Implemented structural hashing of person-property filter trees to detect logical-structure changes.
- Added extensive unit test coverage for triggering/skipping scenarios and structural change detection.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| posthog/models/cohort/dependencies.py | Adds change detection + backfill triggering signals and filter-tree hashing helpers. |
| posthog/models/cohort/test/test_dependencies.py | Adds tests covering person-property detection, hashing/change detection, and backfill trigger gating. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
- Add early return in pre_save to skip DB query for non-realtime cohorts - Replace synchronous management command with async Celery task - Simplify _has_person_property_filters using _extract_person_property_filters - Update tests to mock Celery task instead of management command
|
🎭 Playwright report · View test results →
These issues are not necessarily caused by your changes. |
Query snapshots: Backend query snapshots updatedChanges: 1 snapshots (1 modified, 0 added, 0 deleted) What this means:
Next steps:
|
…m/PostHog/posthog into gustavo/cohort-backfill-on-change
Problem
When realtime cohorts with person property filters are updated, the person property data isn't automatically backfilled. This can lead to inconsistent data until backfill is manually triggered.
Changes
How did you test this code?