Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thoughts on skipping open/click tracking for anti-virus/spam filters #255

Open
Khuthaily opened this issue Jan 18, 2025 · 0 comments
Open

Comments

@Khuthaily
Copy link
Contributor

I wonder if

if (in_array(request()->userAgent(), [
        'Mozilla/5.0',
        'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246 Mozilla/5.0'
    ]) {
        $event->skip = true;
}

is the right approach to skip open/click tracking for anti-virus/spam filters. Some user agents could belong to legitimate users, leading to incorrect skips or counts. Also, this approach may miss a significant number of bots or email clients that perform automated actions.

I was wondering if we could experiment with:

$botPatterns = [
    '/bot/i',
    '/crawl/i',
    '/spider/i',
    '/fetch/i',
    '/monitor/i',
    '/scanner/i',
    '/slurp/i',
    '/curl/i',
    '/wget/i',
    '/headless/i',
    // other?
];

$userAgent = request()->userAgent();

if (empty($userAgent)) {
    $event->skip = true;
} else {
    foreach ($botPatterns as $pattern) {
        if (preg_match($pattern, $userAgent)) {
            // Log::info('Bot detected', ['pattern' => $pattern, 'userAgent' => $userAgent]);
            $event->skip = true;
            break;
        }
    }
}

I am planning to experiment with this; however, I am open for feedback, suggestions, and recommendations.

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

No branches or pull requests

1 participant