-
Notifications
You must be signed in to change notification settings - Fork 53
feat: add before_send callback #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
Adds a before_send callback feature to the Python SDK, enabling event modification or filtering before transmission to PostHog, aligning with existing JS and Ruby SDK implementations.
- Implements new
BeforeSendCallbacktype intypes.pyallowing events to be modified or dropped with type-safe handling - Adds robust error handling in
client.pyto maintain original event data if callback fails - Includes comprehensive documentation in
BEFORE_SEND.mdwith examples for PII filtering and event transformation - Adds thorough test coverage in
test_client.pyvalidating event modification, dropping, and error cases
4 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
09a399e to
b8eeb9c
Compare
| exception_autocapture_integrations=None, | ||
| project_root=None, | ||
| privacy_mode=False, | ||
| before_send=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interestingly adding a type to this parameter kicked mypy into being strict about the other parameters and we got ~14 errors
i'm going to punt on that for now since this PR doesn't introduce them
robbie-c
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't you on vacation today?
contributing to open source while you're on vacation is totally standard, right? (will probably cancel day off since I've ended up working 🤣) |
we've got this in posthog-js and posthog-ruby
let's add it here
ultimate power to edit/drop/fix events as you see fit