Repository navigation
feat(analytics): add an early capture filter - #1010
Draft
sortafreel wants to merge 3 commits into
Draft
sortafreel wants to merge 3 commits into
sortafreel wants to merge 3 commits into
Conversation
Contributor
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
|
Contributor
|
[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..." |
Contributor
🦔 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 |
Contributor
|
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 <noreply@anthropic.com> 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 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: bdf93d58-c0c1-4a15-a1e6-78b6a3944b02
This branch has not been deployed
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.
💡 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.