Repository navigation
feat(analytics): add an early capture filter - #1010
sortafreel wants to merge 3 commits into
Conversation
posthog-python Compliance ReportDate: 2026-10-06T09:03:29.229263+00:00 ✅ All Tests Passed!121/121 tests passed Capture_V1 Tests✅ 95/95 tests passed View Details
Capture_Ai Tests✅ 5/5 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
Feature_Flags_Local_Evaluation Tests✅ 4/4 tests passed View Details
|
|
[Medium risk] Adds optional event filtering callback to analytics client. The PR should not merge until rejected captures avoid feature-flag requests. Reviews (1) · Last reviewed commit: "feat(analytics): add an early capture fi..." |
🦔 PostHog Review reviewed this pull requestFound 0 must fix, 1 should fix, 0 consider. Published 1 finding (view the review). Resolved comments: 2 fixed, 1 declined |
|
PostHog Review alpha 🦔 If you find any issues helpful - please reply "valid", "invalid", etc., for evaluation purposes 🙏 |
Only mark a $feature_flag_called event as reported when capture() returns an event UUID. A should_capture rejection no longer suppresses the same exposure from a later allowed context on the shared client. Co-Authored-By: Claude Opus 5.5 <[email protected]> Generated-By: PostHog Desktop Task-Id: bdf93d58-c0c1-4a15-a1e6-78b6a3944b02
capture() and capture_ai() now check the should_capture callback before they build the event or evaluate send_feature_flags. A rejected event no longer makes a /flags request. set, set_once, alias, and group_identify still apply the callback in _enqueue, and it runs once per event. Co-Authored-By: Claude Opus 5.5 <[email protected]> Generated-By: PostHog Desktop Task-Id: bdf93d58-c0c1-4a15-a1e6-78b6a3944b02
|
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
|
This PR was closed due to lack of activity. Feel free to reopen if it's still relevant. |
💡 Motivation and Context
Context-based event filtering currently uses
before_send, which cleans every allowed event twice even when the filter leaves its payload unchanged.should_capture, a synchronous callback that receives no payload and returnsTrueto allow an event.before_sendbehavior, including support for callbacks that modify events in place.This adds a public option to
Client/Posthogand module configuration. It covers analytics and AI events;AsyncClient, metrics, and tracing spans remain outside its scope. The existing before-send specification stays unchanged; no published spec defines this new option.💚 How did you test it?
Local synthetic benchmark using the same candidate SDK, sending disabled, median of seven alternating batches:
before_sendfilterThese measure synchronous event preparation, not production throughput. PostHog adoption is prepared and tested locally; it needs a published SDK version before deployment.
📝 Checklist
If releasing new changes
.sampo/changesets/.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Agent: Codex, GPT-6. Skills: writing-tests, writing-pr-descriptions. CodeRabbit local review skipped because the CLI is signed out and setup was deferred.
No matching open PR found. All test and benchmark inputs are synthetic; no production traffic or private data was used.