Skip to content

feat: add beforeSend hook#255

Merged
ioannisj merged 11 commits intomainfrom
feat/before_send
Jan 29, 2026
Merged

feat: add beforeSend hook#255
ioannisj merged 11 commits intomainfrom
feat/before_send

Conversation

@ioannisj
Copy link
Collaborator

💡 Motivation and Context

Closes #155

Docs: PostHog/posthog.com#14482

Adds a beforeSend callback to PostHogConfig that lets you drop or modify events before they're sent to PostHog.

  • Added to capture(), screen() and captureException()
  • For $screen you can modify the screen name via the $screen_name property

Initially tried implementing this on the native side with method channels calling back to Dart in an attempt to also capture native initiated events, but hit timing issues since method channels are async but the beforeSend hook is called synchronously from native side. Also explored FFI but it added way too much complexity for the benefit.

For now, decided to keep it dart only so that it stays fast, synchronous and reliable. Should be good for the majority of the use cases.

Limitations in changelog

💚 How did you test it?

  • Manual testing + modified sample project

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

@ioannisj ioannisj requested review from a team and removed request for a team January 20, 2026 21:25
Copy link
Member

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a few comments otherwise LGTM

@ioannisj ioannisj merged commit 299e3f8 into main Jan 29, 2026
16 checks passed
@ioannisj ioannisj deleted the feat/before_send branch January 29, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

before_send support

2 participants