Only apply the request filters to website events - #44
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## fix/23-filters-early #44 +/- ##
==========================================================
+ Coverage 68.76% 69.85% +1.09%
- Complexity 135 137 +2
==========================================================
Files 30 30
Lines 413 418 +5
==========================================================
+ Hits 284 292 +8
+ Misses 129 126 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
loevgaard
force-pushed
the
fix/23-filters-early
branch
from
September 7, 2026 12:03
939221d to
f7c16ec
Compare
loevgaard
force-pushed
the
fix/24-non-website-events
branch
from
September 7, 2026 12:03
adf67ff to
3437c5c
Compare
FilterEmptyUserAgentSubscriber dropped every event without a user agent, which silently discarded events raised from console commands, message handlers and webhooks. The bot filter had the same problem: it asks about the current request, which such an event has no relation to. Both now only apply to events whose action source is website. Fixes #24
loevgaard
force-pushed
the
fix/23-filters-early
branch
from
September 7, 2026 12:18
f7c16ec to
04febac
Compare
loevgaard
force-pushed
the
fix/24-non-website-events
branch
from
September 7, 2026 12:18
3437c5c to
ee77aa5
Compare
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.
Fixes #24
Problem
FilterEmptyUserAgentSubscriberstopped propagation wheneveruserData->clientUserAgentwas empty. The user agent is only populated when there is a main request, so every event raised outside a browser request was silently discarded: imports and cron jobs, aPurchaseraised while handling a payment webhook asynchronously, and anything server-to-server.The SDK explicitly supports those cases through
Event::ACTION_SOURCE_*, and Meta only expectsclient_user_agentfor website events, so the filter was making six of the seven action sources unusable.FilterBotsSubscriberhad the same shape of problem: it asks whether the current request comes from a bot, which says nothing about an event raised from a console command.Change
Both filters return early unless
actionSourceiswebsite, which is the default, so ordinary browser tracking is unaffected.FilterConfiguredUserAgentsSubscriberneeds no change: it only acts when a user agent is present and matches.A note on request properties
PopulateRequestPropertiesSubscriberstill fills in the source url, client ip and user agent of the current request for every event. When a non-website event is raised while handling an HTTP request, for instance a payment provider's webhook, those describe the sender and not the customer. Changing that silently would reduce match quality for anyone relying on the current behaviour, so this PR documents the assumption in the README and points at overriding it in a listener abovePRIORITY_POPULATEinstead.Tests
Nine unit tests for the empty user agent filter, covering both stopping cases, the passing case, and all six non-website action sources, plus one for the bot filter with a system generated event.