1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
//! Implements filtering for events originating from legacy browsers.

use std::collections::BTreeSet;

use relay_ua::UserAgent;

use crate::{FilterStatKey, Filterable, LegacyBrowser, LegacyBrowsersFilterConfig};

/// Checks if the event originates from legacy browsers.
fn matches(user_agent: &str, browsers: &BTreeSet<LegacyBrowser>) -> bool {
    let user_agent = relay_ua::parse_user_agent(user_agent);

    // remap IE Mobile to IE (sentry python, filter compatibility)
    let family = match user_agent.family.as_ref() {
        "IE Mobile" => "IE",
        other => other,
    };

    if browsers.contains(&LegacyBrowser::Default) {
        return default_filter(family, &user_agent);
    }

    for browser_type in browsers {
        let should_filter = match browser_type {
            LegacyBrowser::IePre9 => filter_browser(family, &user_agent, "IE", |x| x <= 8),
            LegacyBrowser::Ie9 => filter_browser(family, &user_agent, "IE", |x| x == 9),
            LegacyBrowser::Ie10 => filter_browser(family, &user_agent, "IE", |x| x == 10),
            LegacyBrowser::Ie11 => filter_browser(family, &user_agent, "IE", |x| x == 11),
            LegacyBrowser::OperaMiniPre8 => {
                filter_browser(family, &user_agent, "Opera Mini", |x| x < 8)
            }
            LegacyBrowser::OperaPre15 => filter_browser(family, &user_agent, "Opera", |x| x < 15),
            LegacyBrowser::AndroidPre4 => filter_browser(family, &user_agent, "Android", |x| x < 4),
            LegacyBrowser::SafariPre6 => filter_browser(family, &user_agent, "Safari", |x| x < 6),
            LegacyBrowser::EdgePre79 => filter_browser(family, &user_agent, "Edge", |x| x < 79),
            LegacyBrowser::Ie => filter_browser(family, &user_agent, "IE", |x| x < 12),
            LegacyBrowser::OperaMini => {
                filter_browser(family, &user_agent, "Opera Mini", |x| x < 35)
            }
            LegacyBrowser::Opera => filter_browser(family, &user_agent, "Opera", |x| x < 51),
            LegacyBrowser::Android => filter_browser(family, &user_agent, "Android", |x| x < 4),
            LegacyBrowser::Safari => filter_browser(family, &user_agent, "Safari", |x| x < 12),
            LegacyBrowser::Edge => filter_browser(family, &user_agent, "Edge", |x| x < 79),
            LegacyBrowser::Chrome => filter_browser(family, &user_agent, "Chrome", |x| x < 63),
            LegacyBrowser::Firefox => filter_browser(family, &user_agent, "Firefox", |x| x < 67),
            LegacyBrowser::Unknown(_) => {
                // unknown browsers should not be filtered
                false
            }
            LegacyBrowser::Default => unreachable!(),
        };
        if should_filter {
            return true;
        }
    }
    false
}

/// Filters events originating from legacy browsers.
pub fn should_filter<F: Filterable>(
    item: &F,
    config: &LegacyBrowsersFilterConfig,
) -> Result<(), FilterStatKey> {
    if !config.is_enabled || config.browsers.is_empty() {
        return Ok(()); // globally disabled or no individual browser enabled
    }

    let browsers = &config.browsers;
    if item.user_agent().map_or(false, |ua| matches(ua, browsers)) {
        Err(FilterStatKey::LegacyBrowsers)
    } else {
        Ok(())
    }
}

fn get_browser_major_version(user_agent: &UserAgent) -> Option<i32> {
    if let Some(browser_major_version_str) = &user_agent.major {
        if let Ok(browser_major_version) = browser_major_version_str.parse::<i32>() {
            return Some(browser_major_version);
        }
    }

    None
}

fn min_version(family: &str) -> Option<i32> {
    match family {
        "Chrome" => Some(0),
        "IE" => Some(10),
        "Firefox" => Some(0),
        "Safari" => Some(6),
        "Edge" => Some(0),
        "Opera" => Some(15),
        "Android" => Some(4),
        "Opera Mini" => Some(8),
        _ => None,
    }
}

fn default_filter(mapped_family: &str, user_agent: &UserAgent) -> bool {
    if let Some(browser_major_version) = get_browser_major_version(user_agent) {
        if let Some(min_version) = min_version(mapped_family) {
            if min_version > browser_major_version {
                return true;
            }
        }
    }
    false
}

fn filter_browser<F>(
    mapped_family: &str,
    user_agent: &UserAgent,
    family: &str,
    should_filter: F,
) -> bool
where
    F: FnOnce(i32) -> bool,
{
    if mapped_family == family {
        if let Some(browser_major_version) = get_browser_major_version(user_agent) {
            if should_filter(browser_major_version) {
                return true;
            }
        }
    }
    false
}

#[cfg(test)]
mod tests {
    const IE8_UA: &str = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)";
    const IE_MOBILE9_UA: &str =
        "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; NOKIA; Lumia 710)";
    const IE9_UA: &str = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)";
    const IE10_UA: &str = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)";
    const IE11_UA: &str = "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko";
    const OPERA_MINI_PRE8_UA: &str =
        "Opera/9.80 (J2ME/MIDP; Opera Mini/7.0.32796/59.323; U; fr) Presto/2.12.423 Version/12.16";
    const OPERA_MINI_8_UA: &str =
        "Opera/9.80 (J2ME/MIDP; Opera Mini/8.0.35158/36.2534; U; en) Presto/2.12.423 Version/12.16";
    const OPERA_PRE15_UA: &str =
        "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.12 Safari/537.36 OPR/14.0.1116.4";
    const OPERA_15_UA: &str =
        "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.45 Safari/537.36 OPR/15.0.1147.61 (Edition Next)";
    const ANDROID_PRE4_UA: &str =
        "Mozilla/5.0 (Linux; U; Android 3.2; nl-nl; GT-P6800 Build/HTJ85B) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13";
    const ANDROID_4_UA: &str =
        "Mozilla/5.0 (Linux; U; Android 4.1.1; en-gb; Build/KLP) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30";
    const SAFARI_PRE6_UA: &str =
        "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 1063; tr-DE) AppleWebKit/533.16 (KHTML like Gecko) Version/5.0 Safari/533.16";
    const SAFARI_6_UA: &str =
        "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.17.4; en-GB) AppleWebKit/605.1.5 (KHTML, like Gecko) Version/6.0 Safari/605.1.5";
    const EDGE_ANDROID_118_UA: &str =
        "Mozilla/5.0 (Linux; Android 10; Pixel 3 XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.80 Mobile Safari/537.36 EdgA/118.0.2088.58";
    const EDGE_79_UA: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3919.0 Safari/537.36 Edg/79.0.294.1";
    const EDGE_18_UA: &str =
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19582";
    const EDGE_12_UA: &str =
        "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";
    const OPERA_UA : &str = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.45 Safari/537.36 OPR/49.0.1147.61";
    const OPERA_MINI_UA: &str = "Opera/20.80 (J2ME/MIDP; Opera Mini/16.0.35158/36.2534; U; en) Presto/2.12.423 Version/12.16";
    const CHROME_UA: &str = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.2228.0 Safari/537.36";
    const FIREFOX_UA: &str = "Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0";
    const IE_UA: &str = "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko";
    const EDGE_UA: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19582";
    const SAFARI_UA: &str = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.17.4; en-GB) AppleWebKit/605.1.5 (KHTML, like Gecko) Version/6.0 Safari/605.1.5";
    const ANDROID_UA: &str = "Mozilla/5.0 (Linux; U; Android 3.2; nl-nl; GT-P6800 Build/HTJ85B) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13";

    use super::*;
    use crate::testutils;

    fn get_legacy_browsers_config(
        is_enabled: bool,
        legacy_browsers: &[LegacyBrowser],
    ) -> LegacyBrowsersFilterConfig {
        LegacyBrowsersFilterConfig {
            is_enabled,
            browsers: {
                let mut browsers = BTreeSet::<LegacyBrowser>::new();
                for elm in legacy_browsers {
                    browsers.insert(elm.clone());
                }
                browsers
            },
        }
    }

    #[test]
    fn test_dont_filter_when_disabled() {
        let evt = testutils::get_event_with_user_agent(IE8_UA);
        let filter_result = should_filter(
            &evt,
            &get_legacy_browsers_config(false, &[LegacyBrowser::Default]),
        );
        assert_eq!(
            filter_result,
            Ok(()),
            "Event filtered although filter should have been disabled"
        )
    }

    #[test]
    fn test_filter_default_browsers() {
        for old_user_agent in &[
            IE9_UA,
            IE_MOBILE9_UA,
            SAFARI_PRE6_UA,
            OPERA_PRE15_UA,
            ANDROID_PRE4_UA,
            OPERA_MINI_PRE8_UA,
        ] {
            let evt = testutils::get_event_with_user_agent(old_user_agent);
            let filter_result = should_filter(
                &evt,
                &get_legacy_browsers_config(true, &[LegacyBrowser::Default]),
            );
            assert_ne!(
                filter_result,
                Ok(()),
                "Default filter should have filtered User Agent\n{old_user_agent}"
            )
        }
    }

    #[test]
    fn test_dont_filter_default_above_minimum_versions() {
        for old_user_agent in &[
            IE10_UA,
            SAFARI_6_UA,
            OPERA_15_UA,
            ANDROID_4_UA,
            OPERA_MINI_8_UA,
        ] {
            let evt = testutils::get_event_with_user_agent(old_user_agent);
            let filter_result = should_filter(
                &evt,
                &get_legacy_browsers_config(true, &[LegacyBrowser::Default]),
            );
            assert_eq!(
                filter_result,
                Ok(()),
                "Default filter shouldn't have filtered User Agent\n{old_user_agent}"
            )
        }
    }

    #[test]
    fn test_filter_configured_browsers() {
        let test_configs = [
            (
                IE10_UA,
                &[LegacyBrowser::AndroidPre4, LegacyBrowser::Ie10][..],
            ),
            (IE11_UA, &[LegacyBrowser::Ie11][..]),
            (IE10_UA, &[LegacyBrowser::Ie10][..]),
            (IE9_UA, &[LegacyBrowser::Ie9][..]),
            (IE_MOBILE9_UA, &[LegacyBrowser::Ie9][..]),
            (
                IE9_UA,
                &[LegacyBrowser::AndroidPre4, LegacyBrowser::Ie9][..],
            ),
            (IE8_UA, &[LegacyBrowser::IePre9][..]),
            (
                IE8_UA,
                &[LegacyBrowser::OperaPre15, LegacyBrowser::IePre9][..],
            ),
            (OPERA_PRE15_UA, &[LegacyBrowser::OperaPre15][..]),
            (
                OPERA_PRE15_UA,
                &[LegacyBrowser::Ie10, LegacyBrowser::OperaPre15][..],
            ),
            (OPERA_MINI_PRE8_UA, &[LegacyBrowser::OperaMiniPre8][..]),
            (
                OPERA_MINI_PRE8_UA,
                &[LegacyBrowser::Ie10, LegacyBrowser::OperaMiniPre8][..],
            ),
            (ANDROID_PRE4_UA, &[LegacyBrowser::AndroidPre4][..]),
            (
                ANDROID_PRE4_UA,
                &[LegacyBrowser::Ie10, LegacyBrowser::AndroidPre4][..],
            ),
            (SAFARI_PRE6_UA, &[LegacyBrowser::SafariPre6][..]),
            (
                SAFARI_PRE6_UA,
                &[LegacyBrowser::OperaPre15, LegacyBrowser::SafariPre6][..],
            ),
            (EDGE_12_UA, &[LegacyBrowser::EdgePre79][..]),
            (
                EDGE_18_UA,
                &[LegacyBrowser::OperaPre15, LegacyBrowser::EdgePre79][..],
            ),
            (OPERA_UA, &[LegacyBrowser::Opera][..]),
            (OPERA_MINI_UA, &[LegacyBrowser::OperaMini][..]),
            (CHROME_UA, &[LegacyBrowser::Chrome][..]),
            (FIREFOX_UA, &[LegacyBrowser::Firefox][..]),
            (IE_UA, &[LegacyBrowser::Ie][..]),
            (EDGE_UA, &[LegacyBrowser::Edge][..]),
            (SAFARI_UA, &[LegacyBrowser::Safari][..]),
            (ANDROID_UA, &[LegacyBrowser::Android][..]),
        ];

        for (ref user_agent, ref active_filters) in &test_configs {
            let evt = testutils::get_event_with_user_agent(user_agent);
            let filter_result =
                should_filter(&evt, &get_legacy_browsers_config(true, active_filters));
            assert_ne!(
                filter_result,
                Ok(()),
                "Filters {active_filters:?} should have filtered User Agent\n{user_agent} for "
            )
        }
    }

    #[test]
    fn test_dont_filter_unconfigured_browsers() {
        let test_configs = [
            (IE11_UA, LegacyBrowser::Ie10),
            (IE10_UA, LegacyBrowser::Ie9),
            (IE10_UA, LegacyBrowser::Ie11),
            (IE9_UA, LegacyBrowser::IePre9),
            (OPERA_15_UA, LegacyBrowser::OperaPre15),
            (OPERA_MINI_8_UA, LegacyBrowser::OperaMiniPre8),
            (ANDROID_4_UA, LegacyBrowser::AndroidPre4),
            (SAFARI_6_UA, LegacyBrowser::SafariPre6),
            (EDGE_12_UA, LegacyBrowser::Ie10),
            (EDGE_18_UA, LegacyBrowser::Ie10),
            (EDGE_79_UA, LegacyBrowser::EdgePre79),
            (EDGE_ANDROID_118_UA, LegacyBrowser::EdgePre79),
        ];

        for (user_agent, active_filter) in &test_configs {
            let evt = testutils::get_event_with_user_agent(user_agent);
            let filter_result = should_filter(
                &evt,
                &get_legacy_browsers_config(true, &[active_filter.clone()]),
            );
            assert_eq!(
                filter_result,
                Ok(()),
                "Filter {active_filter:?} shouldn't have filtered User Agent\n{user_agent} for "
            )
        }
    }

    /// Test to ensure Sentry filter compatibility.
    ///
    /// To be remove if/when Sentry backward compatibility is no longer required.
    mod sentry_compatibility {
        use super::*;

        // User agents used by Sentry tests
        const ANDROID2_S_UA: &str =
            "Mozilla/5.0 (Linux; U; Android 2.3.5; en-us; HTC Vision Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1";
        const ANDROID4_S_UA: &str =
            "Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19";
        const IE5_S_UA: &str =
            "Mozilla/4.0 (compatible; MSIE 5.50; Windows NT; SiteKiosk 4.9; SiteCoach 1.0)";
        const IE8_S_UA: &str =
            "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MDDC; Tablet PC 2.0)";
        const IE9_S_UA: &str = "Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))";
        const IE_MOBILE9_S_UA: &str =
            "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; NOKIA; Lumia 710)";
        const IE10_S_UA: &str =
            "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 7.0; InfoPath.3; .NET CLR 3.1.40767; Trident/6.0; en-IN)";
        const IE_MOBILE10_S_UA: &str =
            "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 520)";
        const OPERA11_S_UA: &str = "Opera/9.80 (Windows NT 5.1; U; it) Presto/2.7.62 Version/11.00";
        const OPERA_12_S_UA: &str =
            "Opera/9.80 (X11; Linux i686; Ubuntu/14.10) Presto/2.12.388 Version/12.16";
        const OPERA_15_S_UA: &str =
            "Mozilla/5.0 (X11; Linux x86_64; Debian) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36 OPR/15.0.1147.100";
        const CHROME_S_UA: &str =
            "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36";
        const EDGE_S_UA: &str =
            "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10136";
        const SAFARI5_S_UA: &str =
            "Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-HK) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5";
        const SAFARI7_S_UA: &str =
            "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A";
        const OPERA_MINI8_S_UA: &str =
            "Opera/9.80 (J2ME/MIDP; Opera Mini/8.0.35158/36.2534; U; en) Presto/2.12.423 Version/12.16";
        const OPERA_MINI7_S_UA: &str =
            "Opera/9.80 (J2ME/MIDP; Opera Mini/7.0.32796/59.323; U; fr) Presto/2.12.423 Version/12.16";

        #[test]
        fn test_filter_sentry_user_agents() {
            let test_configs = [
                (ANDROID2_S_UA, LegacyBrowser::Default),
                (IE9_S_UA, LegacyBrowser::Default),
                (IE_MOBILE9_S_UA, LegacyBrowser::Default),
                (IE5_S_UA, LegacyBrowser::Default),
                (OPERA11_S_UA, LegacyBrowser::Default),
                (OPERA_12_S_UA, LegacyBrowser::Default),
                (OPERA_MINI7_S_UA, LegacyBrowser::Default),
                (OPERA_12_S_UA, LegacyBrowser::OperaPre15),
                (OPERA_MINI7_S_UA, LegacyBrowser::OperaMiniPre8),
                (OPERA_MINI7_S_UA, LegacyBrowser::Default),
                (OPERA_MINI7_S_UA, LegacyBrowser::Default),
                (IE8_S_UA, LegacyBrowser::IePre9),
                (IE8_S_UA, LegacyBrowser::Default),
                (IE9_S_UA, LegacyBrowser::Ie9),
                (IE_MOBILE9_S_UA, LegacyBrowser::Ie9),
                (IE10_S_UA, LegacyBrowser::Ie10),
                (IE_MOBILE10_S_UA, LegacyBrowser::Ie10),
                (SAFARI5_S_UA, LegacyBrowser::SafariPre6),
                (SAFARI5_S_UA, LegacyBrowser::Default),
                (ANDROID2_S_UA, LegacyBrowser::AndroidPre4),
            ];

            for (ref user_agent, ref active_filter) in &test_configs {
                let evt = testutils::get_event_with_user_agent(user_agent);
                let filter_result = should_filter(
                    &evt,
                    &get_legacy_browsers_config(true, &[active_filter.clone()]),
                );
                assert_ne!(
                    filter_result,
                    Ok(()),
                    "Filter <{active_filter:?}> should have filtered User Agent\n{user_agent} for "
                )
            }
        }

        #[test]
        fn test_dont_filter_sentry_allowed_user_agents() {
            let test_configs = [
                (ANDROID4_S_UA, LegacyBrowser::Default),
                (IE10_S_UA, LegacyBrowser::Default),
                (IE_MOBILE10_S_UA, LegacyBrowser::Default),
                (CHROME_S_UA, LegacyBrowser::Default),
                (EDGE_S_UA, LegacyBrowser::Default),
                (OPERA_15_S_UA, LegacyBrowser::Default),
                (OPERA_MINI8_S_UA, LegacyBrowser::Default),
                (IE10_S_UA, LegacyBrowser::Default),
                (IE_MOBILE10_S_UA, LegacyBrowser::Default),
                (SAFARI7_S_UA, LegacyBrowser::Default),
            ];

            for (ref user_agent, ref active_filter) in &test_configs {
                let evt = testutils::get_event_with_user_agent(user_agent);
                let filter_result = should_filter(
                    &evt,
                    &get_legacy_browsers_config(true, &[active_filter.clone()]),
                );
                assert_eq!(
                    filter_result,
                    Ok(()),
                    "Filter {active_filter:?} shouldn't have filtered User Agent\n{user_agent} for "
                )
            }
        }
    }
}