Skip to content

Filter bots before application listeners enrich the event - #43

Merged
loevgaard merged 1 commit into
masterfrom
fix/23-filters-early
Sep 7, 2026
Merged

Filter bots before application listeners enrich the event#43
loevgaard merged 1 commit into
masterfrom
fix/23-filters-early

Conversation

@loevgaard

Copy link
Copy Markdown
Member

Fixes #23

Stacked on #42.

Problem

The three request-based filters ran at -850, -875 and -900, i.e. after the application's own listeners at priority 0. Enrichment is normally the expensive part of the pipeline: loading the customer, the order, its lines and addresses. For bot traffic all of that work was done and then thrown away when a filter stopped propagation a moment later.

Change

PRIORITY_FILTER moves from -900 to 600, which puts the three filters between the request populators and PRIORITY_ENRICH. They only read userData->clientUserAgent, which is populated at PRIORITY_POPULATE, so they have everything they need. Their relative order is unchanged.

PopulatePixelsSubscriber moves from 700 to 500 so the filters sit between the request populators and it, which also means the pixel provider is not consulted for bot traffic.

StopPropagationIfNoPixelsHasBeenAddedSubscriber deliberately stays late at -950: an application listener may add pixels itself, so that check has to run after enrichment.

Tests

FilterBotsSubscriberTest covers the filter itself and, with a real EventDispatcher, asserts that a listener registered at PRIORITY_ENRICH is never invoked for a bot request. The pipeline order tests are updated to the new layout, and now also assert the filters still run after the request properties they filter on are populated.

@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 68.76%. Comparing base (3bc77c7) to head (04febac).

Additional details and impacted files
@@                       Coverage Diff                        @@
##             fix/22-pipeline-priorities      #43      +/-   ##
================================================================
+ Coverage                         67.79%   68.76%   +0.96%     
  Complexity                          135      135              
================================================================
  Files                                30       30              
  Lines                               413      413              
================================================================
+ Hits                                280      284       +4     
+ Misses                              133      129       -4     

☔ 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.

The filters ran after the application's listeners, so enrichment work
was done for bot traffic and then thrown away. Move the filter band
above PRIORITY_ENRICH, keeping the no-pixels check late because
application listeners may add pixels themselves.

Fixes #23
@loevgaard
loevgaard force-pushed the fix/22-pipeline-priorities branch from f495dfc to 3bc77c7 Compare September 7, 2026 12:18
@loevgaard
loevgaard force-pushed the fix/23-filters-early branch from f7c16ec to 04febac Compare September 7, 2026 12:18
Base automatically changed from fix/22-pipeline-priorities to master September 7, 2026 12:47
@loevgaard
loevgaard merged commit 58d87cf into master Sep 7, 2026
46 of 47 checks passed
@loevgaard
loevgaard deleted the fix/23-filters-early branch September 7, 2026 12:47
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.

Run bot and user agent filters before application enrichment listeners

1 participant