feat: add propertiesExtractor to PosthogObserver#352
feat: add propertiesExtractor to PosthogObserver#352didyk wants to merge 1 commit intoPostHog:mainfrom
Conversation
Made-with: Cursor
|
Hi @didyk, thank you for the contribution! Could you share a concrete use case for this? Specifically, I'd like to understand when you'd use What kind of per-route data would you extract? |
Hi @dustinbyrne, thanks for reviewing! The main use case is filtering out "ghost" screen events caused by background widget rebuilds. In Flutter, when the app is in the background (e.g. AppLifecycleState.paused or inactive), the OS or certain plugins can trigger a rebuild of the widget tree. When this happens, the router reconstructs the current route, and This leads to fake screen view counts in PostHog, because the user isn't actually looking at the app - it's just a background refresh. By adding propertiesExtractor, we can tag every automatic screen event with the current app lifecycle state: Then, in PostHog queries, we can easily filter out events where Why not call Why not use r Let me know if you need any changes to the PR! |
How can we reproduce this behavior? can you provide an MRE? If that's the case, we should implement this built-in in |
|
@marandaneto I created a small repo - https://github.com/didyk/posthog-mre, you will need to paste your API key for check logs from posthog. |
|
@didyk, what steps should I take to reproduce the issue? Put the app in the background and wait? |
|
@marandaneto yes,
|
|
closed by #355 |


💡 Motivation and Context
Enable users to enrich $screen events with custom properties (e.g. app lifecycle state) without replacing PosthogObserver
💚 How did you test it?
Unit tests added for propertiesExtractor across didPush, didPop, didReplace
📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset filereleaselabel to the PR