Skip to content

Log why an event was dropped - #46

Merged
loevgaard merged 1 commit into
masterfrom
fix/25-log-dropped-events
Sep 7, 2026
Merged

Log why an event was dropped#46
loevgaard merged 1 commit into
masterfrom
fix/25-log-dropped-events

Conversation

@loevgaard

Copy link
Copy Markdown
Member

Fixes #25

Stacked on #44.

Problem

Four subscribers stopped propagation and three returned early on consent, and not one of them logged anything. "My events do not show up in Events Manager" is the first thing every integrator hits, and the only way to answer it was to step through the event dispatcher with a debugger.

Change

Each of these now logs at debug level with the event name and event id in the context:

Listener Reason logged
FilterBotsSubscriber request comes from a bot, with the user agent
FilterConfiguredUserAgentsSubscriber user agent matches filters.user_agent
FilterEmptyUserAgentSubscriber request has no user agent
StopPropagationIfNoPixelsHasBeenAddedSubscriber no pixels are associated with the event
AddEventToTagBagSubscriber consent not granted
AddLibraryToTagBagSubscriber consent not granted, or no pixels available
DispatchOnCommandBusSubscriber consent not granted

The logger is optional in every constructor and falls back to NullLogger, and each service is wired with on-invalid="null" plus <tag name="monolog.logger" channel="setono_meta_conversions_api"/>, so the channel can be turned up on its own without touching the application log. README.md shows the Monolog handler for it.

Drive-by in the same file: AddLibraryToTagBagSubscriber had on-invalid="null" on its ConsentCheckerInterface argument while the constructor requires a non-null value. That service always exists, so it never bit, but it would have been a TypeError rather than a clear container error if it ever went missing.

Tests

A SpyLogger test double records what was logged. Each filter asserts it logs exactly one debug record naming the reason, and the bot filter also asserts nothing is logged when the event passes. StopPropagationIfNoPixelsHasBeenAddedSubscriber gets its first tests.

@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.70%. Comparing base (ee77aa5) to head (919b3dd).

Additional details and impacted files
@@                       Coverage Diff                       @@
##             fix/24-non-website-events      #46      +/-   ##
===============================================================
+ Coverage                        69.85%   76.70%   +6.84%     
- Complexity                         137      139       +2     
===============================================================
  Files                               30       30              
  Lines                              418      455      +37     
===============================================================
+ Hits                               292      349      +57     
+ Misses                             126      106      -20     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@loevgaard
loevgaard force-pushed the fix/24-non-website-events branch from adf67ff to 3437c5c Compare September 7, 2026 12:03
@loevgaard
loevgaard force-pushed the fix/25-log-dropped-events branch from a0c147e to 324e9e7 Compare September 7, 2026 12:03
@loevgaard
loevgaard force-pushed the fix/24-non-website-events branch from 3437c5c to ee77aa5 Compare September 7, 2026 12:18
@loevgaard
loevgaard force-pushed the fix/25-log-dropped-events branch 2 times, most recently from 1ed2b29 to 37e9af9 Compare September 7, 2026 12:46
Four filters and three consent gates discarded events silently, which
made 'my events do not show up' impossible to answer without a debugger.

Each now logs the reason at debug level on a dedicated Monolog channel.

Fixes #25
@loevgaard
loevgaard force-pushed the fix/25-log-dropped-events branch from 37e9af9 to 919b3dd Compare September 7, 2026 12:51
Base automatically changed from fix/24-non-website-events to master September 7, 2026 12:54
@loevgaard
loevgaard merged commit 38e96bf into master Sep 7, 2026
47 checks passed
@loevgaard
loevgaard deleted the fix/25-log-dropped-events branch September 7, 2026 12:54
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.

Log why an event was dropped

1 participant