feat: add before send callback#260
Merged
Merged
Conversation
Contributor
posthog-dotnet Compliance ReportDate: 2026-07-06 07:06:37 UTC ✅ All Tests Passed!17/17 tests passed Feature_Flags Tests✅ 17/17 tests passed View Details
|
Contributor
|
Reviews (1): Last reviewed commit: "feat: add before send callback" | Re-trigger Greptile |
marandaneto
marked this pull request as ready for review
July 5, 2026 12:30
Contributor
|
Reviews (2): Last reviewed commit: "chore: fix before send changeset package..." | Re-trigger Greptile |
ioannisj
approved these changes
Jul 6, 2026
ioannisj
left a comment
Contributor
There was a problem hiding this comment.
LG, left a small comment
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
Customers need a configuration hook to inspect, modify, or drop events before upload, matching the before-send behavior available in other PostHog SDKs.
This adds
PostHogOptions.BeforeSend, invoked after event enrichment (SDK properties, super properties,$is_server, groups, and feature flags) and before batch serialization. Returningnulldrops the event.💚 How did you test it?
dotnet test tests/UnitTests/UnitTests.csproj --filter 'FullyQualifiedName~PostHogClientTests.TheCaptureMethod'dotnet build src/PostHog/PostHog.csproj📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented with the pi coding agent. The hook runs after the event is fully enriched by moving before-send processing into the batch resolution path, so feature flag enrichment is visible to the callback before serialization. A dropped event is filtered out of the outgoing batch.