feat: bot filtering for click statistics - #58
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
DGINXREAL
added a commit
that referenced
this pull request
Jul 31, 2026
- Memoize the CrawlerDetect instance in a static property so Octane long-lived workers don't rebuild its regex pattern lists per click. - Add bot-exclusion test guards for the two read sites that lacked one: DashboardController::clicksByDay and ReportDataService::topLinks, so a future edit can't silently re-leak bot clicks into those views. Follow-up to #58. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Click statistics previously counted every request, including crawlers and link-preview bots (
facebookexternalhit,Slackbot, search engines, …), inflating totals and breakdowns. This detects bots at recording time, tags each click withis_bot, and excludes bot clicks from every statistic and counter — while still redirecting bots normally so link previews keep working.What changed (4 commits)
CrawlerDetector— thinApp\Support\CrawlerDetector::isBot()wrapper overjaybizzle/crawler-detect(empty UA → false).statistics.is_bot— boolean column (default false) + model boolean cast + factorybot()state.RecordClickStatisticJob— stores every click withis_bot, but only incrementsurls.clicks/urls.unique_clicksfor non-bots (so headline counters stay bot-free and consistent with breakdowns).where('is_bot', false)added toStatisticsAggregator::base()(all 7 aggregator methods),StatisticsControllertopLinks,DashboardController::clicksByDay, andReportDataService::topLinks. Dashboard totals read the denormalized (already bot-free) counters, so no change there.Bot rows are retained (for possible later inspection), just never counted. Redirect hot-path is untouched.
Verification
Optional follow-ups (not in this PR)
DashboardClicksChartTest+ReportDataServiceTest(spec scoped to one representative raw-query test).CrawlerDetectinstance statically for Octane long-lived workers.Spec & plan:
docs/superpowers/specs/2026-07-31-bot-filtering-design.md,docs/superpowers/plans/2026-07-31-bot-filtering.md.🤖 Generated with Claude Code