@shware/analytics 8.13.1 → 8.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1146 @@
1
+ import { GENERIC_BOT } from "./generic.mjs";
2
+ //#region src/bot/index.ts
3
+ /**
4
+ * What kind of automated visitor a bot is, as the analytics tools that report bots separately
5
+ * group them (PostHog's traffic categories, Cloudflare's verified bot categories, Matomo's
6
+ * DeviceDetector). Stored next to the name so dashboards can group without re-deriving:
7
+ *
8
+ * - search_crawler: indexes pages for a search engine (Googlebot, Bingbot, Baiduspider)
9
+ * - ai_crawler: collects content to train models (GPTBot, ClaudeBot, Meta-ExternalAgent)
10
+ * - ai_search: indexes pages for an AI search product (OAI-SearchBot, PerplexityBot)
11
+ * - ai_assistant: fetches a page because a person asked an assistant to (ChatGPT-User)
12
+ * - advertising: works for an ad system — reviews landing pages, targets or verifies ads
13
+ * (Meta-ExternalAds, AdsBot-Google, Mediapartners-Google)
14
+ * - link_preview: renders the card of a link shared in a feed or a chat (facebookexternalhit)
15
+ * - seo_tool: SEO, marketing and page-speed tools (AhrefsBot, Lighthouse, HubSpot)
16
+ * - monitoring: uptime checks, synthetics and service callers (Pingdom, Stripe)
17
+ * - headless_browser: a scripted browser (HeadlessChrome, Playwright, a WebDriver session)
18
+ * - http_client: a library or command-line client (curl, python-requests)
19
+ * - no_user_agent: a request without a user agent, which no browser sends
20
+ * - other: automated by every sign, but none of the above
21
+ */
22
+ const BOT_CATEGORIES = [
23
+ "search_crawler",
24
+ "ai_crawler",
25
+ "ai_search",
26
+ "ai_assistant",
27
+ "advertising",
28
+ "link_preview",
29
+ "seo_tool",
30
+ "monitoring",
31
+ "headless_browser",
32
+ "http_client",
33
+ "no_user_agent",
34
+ "other"
35
+ ];
36
+ const NOT_A_BOT = {
37
+ is_bot: false,
38
+ bot_name: null,
39
+ bot_category: null
40
+ };
41
+ /**
42
+ * Bots we can name, as `[name, category, pattern]`, tried in order; the first match wins.
43
+ *
44
+ * Where the list comes from (checked 2026-09-30):
45
+ * - bowser's bot parsers (the ~25 named bots its `platform.type === 'bot'` reports), which this
46
+ * replaces.
47
+ * - PostHog's `bot_definitions.py` (web analytics traffic classification), for the bots and
48
+ * categories an analytics product sees most.
49
+ * - ai.robots.txt (`robots.json`), for AI crawlers, search bots, assistants and agents.
50
+ * - The operators' own docs for the big ones: Google's crawler list, OpenAI's and Anthropic's
51
+ * bot pages, Meta's web crawlers, Perplexity, Bing, Apple.
52
+ * - Bots seen in production (Meta-ExternalAds, HubSpot, Bytespider).
53
+ * Every entry was run against the real user agents in crawler-user-agents and PostHog's
54
+ * fixtures, and bowser's browser fixtures were run to check no browser is taken for a bot
55
+ * (Sogou's browser against its spider, Pinterest's in-app browser against its bot); see
56
+ * `index.test.ts` for where to get them.
57
+ *
58
+ * The link above each entry is the operator's page about the bot, else its product page, else
59
+ * its Known Agents profile (knownagents.com, formerly Dark Visitors) when the operator has none.
60
+ *
61
+ * Names are the operators' spelling of their user agent token. Order matters where one token
62
+ * contains another or borrows a name: advertising and SEO tools come before the search engines
63
+ * whose names they carry, and the more specific of Meta's, Anthropic's and Perplexity's tokens
64
+ * come first. The long tail is left to the generic pattern, filed as `other` and named by
65
+ * `nameOfUnknownBot`; add a bot here when it is worth its own category or name in a dashboard.
66
+ */
67
+ const NAMED_BOTS = [
68
+ [
69
+ "Meta-ExternalAds",
70
+ "advertising",
71
+ /meta-externalads/i
72
+ ],
73
+ [
74
+ "facebookcatalog",
75
+ "advertising",
76
+ /facebookcatalog/i
77
+ ],
78
+ [
79
+ "AdsBot-Google",
80
+ "advertising",
81
+ /adsbot-google/i
82
+ ],
83
+ [
84
+ "Mediapartners-Google",
85
+ "advertising",
86
+ /mediapartners-google/i
87
+ ],
88
+ [
89
+ "AdIdxBot",
90
+ "advertising",
91
+ /adidxbot/i
92
+ ],
93
+ [
94
+ "Google-AdWords",
95
+ "advertising",
96
+ /google-adwords/i
97
+ ],
98
+ [
99
+ "Google-Ads-Conversions",
100
+ "advertising",
101
+ /google-ads-conversions/i
102
+ ],
103
+ [
104
+ "OAI-AdsBot",
105
+ "advertising",
106
+ /oai-adsbot/i
107
+ ],
108
+ [
109
+ "SnapchatAds",
110
+ "advertising",
111
+ /snapchatads/i
112
+ ],
113
+ [
114
+ "Taboolabot",
115
+ "advertising",
116
+ /taboolabot/i
117
+ ],
118
+ [
119
+ "ChatGPT-User",
120
+ "ai_assistant",
121
+ /chatgpt-user/i
122
+ ],
123
+ [
124
+ "Claude-User",
125
+ "ai_assistant",
126
+ /claude-user/i
127
+ ],
128
+ [
129
+ "Claude-Web",
130
+ "ai_assistant",
131
+ /claude-web/i
132
+ ],
133
+ [
134
+ "Perplexity-User",
135
+ "ai_assistant",
136
+ /perplexity-user/i
137
+ ],
138
+ [
139
+ "DuckAssistBot",
140
+ "ai_assistant",
141
+ /duckassistbot/i
142
+ ],
143
+ [
144
+ "Meta-ExternalFetcher",
145
+ "ai_assistant",
146
+ /meta-externalfetcher/i
147
+ ],
148
+ [
149
+ "MistralAI-User",
150
+ "ai_assistant",
151
+ /mistralai-user/i
152
+ ],
153
+ [
154
+ "Manus-User",
155
+ "ai_assistant",
156
+ /manus-user/i
157
+ ],
158
+ [
159
+ "Amzn-User",
160
+ "ai_assistant",
161
+ /amzn-user/i
162
+ ],
163
+ [
164
+ "amazon-QBusiness",
165
+ "ai_assistant",
166
+ /amazon-qbusiness/i
167
+ ],
168
+ [
169
+ "Amazon-Bedrock-AgentCore-Browser",
170
+ "ai_assistant",
171
+ /amazon-bedrock-agentcore/i
172
+ ],
173
+ [
174
+ "Google-Agent",
175
+ "ai_assistant",
176
+ /google-?agent/i
177
+ ],
178
+ [
179
+ "Gemini-Deep-Research",
180
+ "ai_assistant",
181
+ /gemini-deep-research/i
182
+ ],
183
+ [
184
+ "Google-NotebookLM",
185
+ "ai_assistant",
186
+ /google-notebooklm/i
187
+ ],
188
+ [
189
+ "Kimi-User",
190
+ "ai_assistant",
191
+ /kimi-(?:user|agent)/i
192
+ ],
193
+ [
194
+ "TongyiBot",
195
+ "ai_assistant",
196
+ /tongyibot/i
197
+ ],
198
+ [
199
+ "YiyanBot",
200
+ "ai_assistant",
201
+ /yiyanbot/i
202
+ ],
203
+ [
204
+ "kagi-fetcher",
205
+ "ai_assistant",
206
+ /kagi-fetcher/i
207
+ ],
208
+ [
209
+ "Devin",
210
+ "ai_assistant",
211
+ /\bdevin\/\d/i
212
+ ],
213
+ [
214
+ "NovaAct",
215
+ "ai_assistant",
216
+ /novaact/i
217
+ ],
218
+ [
219
+ "OAI-SearchBot",
220
+ "ai_search",
221
+ /oai-searchbot/i
222
+ ],
223
+ [
224
+ "Claude-SearchBot",
225
+ "ai_search",
226
+ /claude-searchbot/i
227
+ ],
228
+ [
229
+ "PerplexityBot",
230
+ "ai_search",
231
+ /perplexitybot/i
232
+ ],
233
+ [
234
+ "Meta-WebIndexer",
235
+ "ai_search",
236
+ /meta-webindexer/i
237
+ ],
238
+ [
239
+ "Amazonbot",
240
+ "ai_search",
241
+ /amazonbot/i
242
+ ],
243
+ [
244
+ "YouBot",
245
+ "ai_search",
246
+ /youbot/i
247
+ ],
248
+ [
249
+ "PhindBot",
250
+ "ai_search",
251
+ /phindbot/i
252
+ ],
253
+ [
254
+ "Amzn-SearchBot",
255
+ "ai_search",
256
+ /amzn-searchbot/i
257
+ ],
258
+ [
259
+ "AzureAI-SearchBot",
260
+ "ai_search",
261
+ /azureai-searchbot/i
262
+ ],
263
+ [
264
+ "Kimi-SearchBot",
265
+ "ai_search",
266
+ /kimi-searchbot/i
267
+ ],
268
+ [
269
+ "MistralAI-Index",
270
+ "ai_search",
271
+ /mistralai-index/i
272
+ ],
273
+ [
274
+ "ExaSearchBot",
275
+ "ai_search",
276
+ /exasearchbot|\bexabot/i
277
+ ],
278
+ [
279
+ "TavilyBot",
280
+ "ai_search",
281
+ /tavilybot/i
282
+ ],
283
+ [
284
+ "LinkupBot",
285
+ "ai_search",
286
+ /linkupbot/i
287
+ ],
288
+ [
289
+ "iAskBot",
290
+ "ai_search",
291
+ /iask(?:bot|spider)/i
292
+ ],
293
+ [
294
+ "Andibot",
295
+ "ai_search",
296
+ /andibot/i
297
+ ],
298
+ [
299
+ "Cloudflare-AutoRAG",
300
+ "ai_search",
301
+ /cloudflare-autorag/i
302
+ ],
303
+ [
304
+ "GPTBot",
305
+ "ai_crawler",
306
+ /gptbot/i
307
+ ],
308
+ [
309
+ "ClaudeBot",
310
+ "ai_crawler",
311
+ /claudebot/i
312
+ ],
313
+ [
314
+ "anthropic-ai",
315
+ "ai_crawler",
316
+ /anthropic-ai/i
317
+ ],
318
+ [
319
+ "Meta-ExternalAgent",
320
+ "ai_crawler",
321
+ /meta-externalagent/i
322
+ ],
323
+ [
324
+ "FacebookBot",
325
+ "ai_crawler",
326
+ /facebookbot/i
327
+ ],
328
+ [
329
+ "Bytespider",
330
+ "ai_crawler",
331
+ /bytespider/i
332
+ ],
333
+ [
334
+ "CCBot",
335
+ "ai_crawler",
336
+ /ccbot/i
337
+ ],
338
+ [
339
+ "Google-CloudVertexBot",
340
+ "ai_crawler",
341
+ /google-cloudvertexbot/i
342
+ ],
343
+ [
344
+ "cohere-ai",
345
+ "ai_crawler",
346
+ /cohere-(?:ai|training-data-crawler)/i
347
+ ],
348
+ [
349
+ "Diffbot",
350
+ "ai_crawler",
351
+ /diffbot/i
352
+ ],
353
+ [
354
+ "Omgili",
355
+ "ai_crawler",
356
+ /omgili|webzio-extended/i
357
+ ],
358
+ [
359
+ "ImagesiftBot",
360
+ "ai_crawler",
361
+ /imagesiftbot/i
362
+ ],
363
+ [
364
+ "Timpibot",
365
+ "ai_crawler",
366
+ /timpibot/i
367
+ ],
368
+ [
369
+ "AI2Bot",
370
+ "ai_crawler",
371
+ /ai2bot/i
372
+ ],
373
+ [
374
+ "PanguBot",
375
+ "ai_crawler",
376
+ /pangubot/i
377
+ ],
378
+ [
379
+ "TikTokSpider",
380
+ "ai_crawler",
381
+ /tiktokspider/i
382
+ ],
383
+ [
384
+ "DeepSeekBot",
385
+ "ai_crawler",
386
+ /deepseekbot/i
387
+ ],
388
+ [
389
+ "DoubaoBot",
390
+ "ai_crawler",
391
+ /doubaobot/i
392
+ ],
393
+ [
394
+ "ERNIEBot",
395
+ "ai_crawler",
396
+ /erniebot/i
397
+ ],
398
+ [
399
+ "QwenBot",
400
+ "ai_crawler",
401
+ /qwenbot/i
402
+ ],
403
+ [
404
+ "KimiBot",
405
+ "ai_crawler",
406
+ /kimibot/i
407
+ ],
408
+ [
409
+ "ChatGLM-Spider",
410
+ "ai_crawler",
411
+ /chatglm-spider/i
412
+ ],
413
+ [
414
+ "MistralAI-Training",
415
+ "ai_crawler",
416
+ /mistralai-training/i
417
+ ],
418
+ [
419
+ "YandexAdditional",
420
+ "ai_crawler",
421
+ /yandexadditional/i
422
+ ],
423
+ [
424
+ "Google-Extended",
425
+ "ai_crawler",
426
+ /google-extended/i
427
+ ],
428
+ [
429
+ "Amazon Kendra",
430
+ "ai_crawler",
431
+ /amazon-kendra|kendrabot/i
432
+ ],
433
+ [
434
+ "bedrockbot",
435
+ "ai_crawler",
436
+ /bedrockbot/i
437
+ ],
438
+ [
439
+ "Brightbot",
440
+ "ai_crawler",
441
+ /brightbot/i
442
+ ],
443
+ [
444
+ "FirecrawlAgent",
445
+ "ai_crawler",
446
+ /firecrawl/i
447
+ ],
448
+ [
449
+ "Crawl4AI",
450
+ "ai_crawler",
451
+ /crawl4ai/i
452
+ ],
453
+ [
454
+ "ApifyBot",
455
+ "ai_crawler",
456
+ /apify/i
457
+ ],
458
+ [
459
+ "img2dataset",
460
+ "ai_crawler",
461
+ /img2dataset/i
462
+ ],
463
+ [
464
+ "LAION",
465
+ "ai_crawler",
466
+ /laion/i
467
+ ],
468
+ [
469
+ "Cloudflare Browser Rendering",
470
+ "ai_crawler",
471
+ /cloudflarebrowserrendering/i
472
+ ],
473
+ [
474
+ "facebookexternalhit",
475
+ "link_preview",
476
+ /facebookexternalhit/i
477
+ ],
478
+ [
479
+ "Facebot",
480
+ "link_preview",
481
+ /facebot/i
482
+ ],
483
+ [
484
+ "Twitterbot",
485
+ "link_preview",
486
+ /twitterbot/i
487
+ ],
488
+ [
489
+ "LinkedInBot",
490
+ "link_preview",
491
+ /linkedinbot/i
492
+ ],
493
+ [
494
+ "Slackbot",
495
+ "link_preview",
496
+ /slackbot|slack-imgproxy/i
497
+ ],
498
+ [
499
+ "Discordbot",
500
+ "link_preview",
501
+ /discordbot/i
502
+ ],
503
+ [
504
+ "TelegramBot",
505
+ "link_preview",
506
+ /telegrambot/i
507
+ ],
508
+ [
509
+ "WhatsApp",
510
+ "link_preview",
511
+ /^whatsapp\//i
512
+ ],
513
+ [
514
+ "Pinterestbot",
515
+ "link_preview",
516
+ /pinterestbot|^pinterest\/0\./i
517
+ ],
518
+ [
519
+ "redditbot",
520
+ "link_preview",
521
+ /redditbot/i
522
+ ],
523
+ [
524
+ "Snap URL Preview",
525
+ "link_preview",
526
+ /snap url preview/i
527
+ ],
528
+ [
529
+ "SkypeUriPreview",
530
+ "link_preview",
531
+ /skypeuripreview/i
532
+ ],
533
+ [
534
+ "BingPreview",
535
+ "link_preview",
536
+ /bingpreview|microsoftpreview/i
537
+ ],
538
+ [
539
+ "Iframely",
540
+ "link_preview",
541
+ /iframely/i
542
+ ],
543
+ [
544
+ "Embedly",
545
+ "link_preview",
546
+ /embedly/i
547
+ ],
548
+ [
549
+ "KakaoTalk-scrap",
550
+ "link_preview",
551
+ /kakaotalk-scrap/i
552
+ ],
553
+ [
554
+ "vkShare",
555
+ "link_preview",
556
+ /vkshare/i
557
+ ],
558
+ [
559
+ "Viber",
560
+ "link_preview",
561
+ /^viber\b|viber-crawler/i
562
+ ],
563
+ [
564
+ "Bluesky Cardyb",
565
+ "link_preview",
566
+ /cardyb/i
567
+ ],
568
+ [
569
+ "Google-PageRenderer",
570
+ "link_preview",
571
+ /google-pagerenderer/i
572
+ ],
573
+ [
574
+ "vercel-screenshot",
575
+ "link_preview",
576
+ /vercel-screenshot/i
577
+ ],
578
+ [
579
+ "Google-InspectionTool",
580
+ "seo_tool",
581
+ /google-inspectiontool/i
582
+ ],
583
+ [
584
+ "Lighthouse",
585
+ "seo_tool",
586
+ /chrome-lighthouse|google page speed insights/i
587
+ ],
588
+ [
589
+ "GTmetrix",
590
+ "seo_tool",
591
+ /gtmetrix/i
592
+ ],
593
+ [
594
+ "AhrefsBot",
595
+ "seo_tool",
596
+ /ahrefs(?:bot|siteaudit)/i
597
+ ],
598
+ [
599
+ "SemrushBot",
600
+ "seo_tool",
601
+ /semrush/i
602
+ ],
603
+ [
604
+ "MJ12bot",
605
+ "seo_tool",
606
+ /mj12bot/i
607
+ ],
608
+ [
609
+ "DotBot",
610
+ "seo_tool",
611
+ /dotbot/i
612
+ ],
613
+ [
614
+ "rogerbot",
615
+ "seo_tool",
616
+ /rogerbot/i
617
+ ],
618
+ [
619
+ "Screaming Frog",
620
+ "seo_tool",
621
+ /screaming frog/i
622
+ ],
623
+ [
624
+ "SerpstatBot",
625
+ "seo_tool",
626
+ /serpstatbot/i
627
+ ],
628
+ [
629
+ "BLEXBot",
630
+ "seo_tool",
631
+ /blexbot/i
632
+ ],
633
+ [
634
+ "DataForSeoBot",
635
+ "seo_tool",
636
+ /dataforseobot/i
637
+ ],
638
+ [
639
+ "HubSpot",
640
+ "seo_tool",
641
+ /hubspot/i
642
+ ],
643
+ [
644
+ "Google-Structured-Data-Testing-Tool",
645
+ "seo_tool",
646
+ /google-structured-data-testing-tool/i
647
+ ],
648
+ [
649
+ "WebPageTest",
650
+ "seo_tool",
651
+ /\bptst\/\d/i
652
+ ],
653
+ [
654
+ "DareBoost",
655
+ "seo_tool",
656
+ /dareboost/i
657
+ ],
658
+ [
659
+ "Barkrowler",
660
+ "seo_tool",
661
+ /barkrowler/i
662
+ ],
663
+ [
664
+ "SE Ranking",
665
+ "seo_tool",
666
+ /seranking|sebot-wa/i
667
+ ],
668
+ [
669
+ "BrightEdge",
670
+ "seo_tool",
671
+ /brightedge/i
672
+ ],
673
+ [
674
+ "SearchAtlas",
675
+ "seo_tool",
676
+ /searchatlas/i
677
+ ],
678
+ [
679
+ "Siteimprove",
680
+ "seo_tool",
681
+ /siteimprove/i
682
+ ],
683
+ [
684
+ "Dataprovider",
685
+ "seo_tool",
686
+ /dataprovider\.com/i
687
+ ],
688
+ [
689
+ "Meltwater",
690
+ "seo_tool",
691
+ /meltwater/i
692
+ ],
693
+ [
694
+ "Awario",
695
+ "seo_tool",
696
+ /awario/i
697
+ ],
698
+ [
699
+ "Googlebot",
700
+ "search_crawler",
701
+ /googlebot/i
702
+ ],
703
+ [
704
+ "Storebot-Google",
705
+ "search_crawler",
706
+ /storebot-google/i
707
+ ],
708
+ [
709
+ "GoogleOther",
710
+ "search_crawler",
711
+ /googleother/i
712
+ ],
713
+ [
714
+ "Bingbot",
715
+ "search_crawler",
716
+ /bingbot/i
717
+ ],
718
+ [
719
+ "Applebot",
720
+ "search_crawler",
721
+ /applebot/i
722
+ ],
723
+ [
724
+ "Baiduspider",
725
+ "search_crawler",
726
+ /baiduspider/i
727
+ ],
728
+ [
729
+ "YandexBot",
730
+ "search_crawler",
731
+ /yandex(?:\w*bot|images|metrika)/i
732
+ ],
733
+ [
734
+ "DuckDuckBot",
735
+ "search_crawler",
736
+ /duckduckbot/i
737
+ ],
738
+ [
739
+ "Yahoo Slurp",
740
+ "search_crawler",
741
+ /yahoo!?[\s/]*slurp/i
742
+ ],
743
+ [
744
+ "Sogou",
745
+ "search_crawler",
746
+ /sogou[\w\s-]*spider/i
747
+ ],
748
+ [
749
+ "360Spider",
750
+ "search_crawler",
751
+ /360spider|haosouspider/i
752
+ ],
753
+ [
754
+ "YisouSpider",
755
+ "search_crawler",
756
+ /yisouspider/i
757
+ ],
758
+ [
759
+ "PetalBot",
760
+ "search_crawler",
761
+ /petalbot/i
762
+ ],
763
+ [
764
+ "SeznamBot",
765
+ "search_crawler",
766
+ /seznambot/i
767
+ ],
768
+ [
769
+ "Yeti",
770
+ "search_crawler",
771
+ /\byeti\//i
772
+ ],
773
+ [
774
+ "Linespider",
775
+ "search_crawler",
776
+ /linespider/i
777
+ ],
778
+ [
779
+ "Qwantbot",
780
+ "search_crawler",
781
+ /qwant(?:bot|ify)/i
782
+ ],
783
+ [
784
+ "coccocbot",
785
+ "search_crawler",
786
+ /coccocbot/i
787
+ ],
788
+ [
789
+ "MojeekBot",
790
+ "search_crawler",
791
+ /mojeekbot/i
792
+ ],
793
+ [
794
+ "Bravebot",
795
+ "search_crawler",
796
+ /bravebot/i
797
+ ],
798
+ [
799
+ "SeekportBot",
800
+ "search_crawler",
801
+ /seekport/i
802
+ ],
803
+ [
804
+ "mwmbl",
805
+ "search_crawler",
806
+ /mwmbl/i
807
+ ],
808
+ [
809
+ "Internet Archive",
810
+ "search_crawler",
811
+ /archive\.org_bot|ia_archiver|archive-it|archiveteam/i
812
+ ],
813
+ [
814
+ "Pingdom",
815
+ "monitoring",
816
+ /pingdom/i
817
+ ],
818
+ [
819
+ "UptimeRobot",
820
+ "monitoring",
821
+ /uptimerobot/i
822
+ ],
823
+ [
824
+ "StatusCake",
825
+ "monitoring",
826
+ /statuscake/i
827
+ ],
828
+ [
829
+ "Site24x7",
830
+ "monitoring",
831
+ /site24x7/i
832
+ ],
833
+ [
834
+ "Better Stack",
835
+ "monitoring",
836
+ /better ?uptime|betterstack/i
837
+ ],
838
+ [
839
+ "Datadog",
840
+ "monitoring",
841
+ /datadog/i
842
+ ],
843
+ [
844
+ "Checkly",
845
+ "monitoring",
846
+ /checkly/i
847
+ ],
848
+ [
849
+ "NewRelicPinger",
850
+ "monitoring",
851
+ /newrelicpinger/i
852
+ ],
853
+ [
854
+ "Uptime-Kuma",
855
+ "monitoring",
856
+ /uptime-kuma/i
857
+ ],
858
+ [
859
+ "Grafana Synthetic Monitoring",
860
+ "monitoring",
861
+ /grafanasyntheticmonitoring/i
862
+ ],
863
+ [
864
+ "Dynatrace",
865
+ "monitoring",
866
+ /ruxitsynthetic|dynatrace/i
867
+ ],
868
+ [
869
+ "Splunk",
870
+ "monitoring",
871
+ /splunk/i
872
+ ],
873
+ [
874
+ "Catchpoint",
875
+ "monitoring",
876
+ /catchpoint/i
877
+ ],
878
+ [
879
+ "Ghost Inspector",
880
+ "monitoring",
881
+ /ghost inspector/i
882
+ ],
883
+ [
884
+ "DigitalOcean Uptime",
885
+ "monitoring",
886
+ /digitalocean uptime/i
887
+ ],
888
+ [
889
+ "OhDear",
890
+ "monitoring",
891
+ /ohdear/i
892
+ ],
893
+ [
894
+ "Google-Safety",
895
+ "monitoring",
896
+ /google-safety/i
897
+ ],
898
+ [
899
+ "Cookiebot",
900
+ "monitoring",
901
+ /cookiebot/i
902
+ ],
903
+ [
904
+ "OneTrust",
905
+ "monitoring",
906
+ /onetrust/i
907
+ ],
908
+ [
909
+ "CookieHub",
910
+ "monitoring",
911
+ /cookiehub/i
912
+ ],
913
+ [
914
+ "Detectify",
915
+ "monitoring",
916
+ /detectify/i
917
+ ],
918
+ [
919
+ "CensysInspect",
920
+ "monitoring",
921
+ /censysinspect/i
922
+ ],
923
+ [
924
+ "BitSightBot",
925
+ "monitoring",
926
+ /bitsightbot/i
927
+ ],
928
+ [
929
+ "zgrab",
930
+ "monitoring",
931
+ /zgrab/i
932
+ ],
933
+ [
934
+ "Nmap",
935
+ "monitoring",
936
+ /nmap scripting engine/i
937
+ ],
938
+ [
939
+ "Stripe",
940
+ "monitoring",
941
+ /stripe\/1\.0|stripebot|merchantsecurityscanner/i
942
+ ],
943
+ [
944
+ "HeadlessChrome",
945
+ "headless_browser",
946
+ /headlesschrome/i
947
+ ],
948
+ [
949
+ "PhantomJS",
950
+ "headless_browser",
951
+ /phantomjs/i
952
+ ],
953
+ [
954
+ "SlimerJS",
955
+ "headless_browser",
956
+ /slimerjs/i
957
+ ],
958
+ [
959
+ "Playwright",
960
+ "headless_browser",
961
+ /playwright/i
962
+ ],
963
+ [
964
+ "Puppeteer",
965
+ "headless_browser",
966
+ /puppeteer/i
967
+ ],
968
+ [
969
+ "Selenium",
970
+ "headless_browser",
971
+ /selenium/i
972
+ ],
973
+ [
974
+ "Cypress",
975
+ "headless_browser",
976
+ /cypress/i
977
+ ],
978
+ [
979
+ "Lightpanda",
980
+ "headless_browser",
981
+ /lightpanda/i
982
+ ],
983
+ [
984
+ "wkhtmltopdf",
985
+ "headless_browser",
986
+ /wkhtmltopdf/i
987
+ ],
988
+ [
989
+ "curl",
990
+ "http_client",
991
+ /^curl\//i
992
+ ],
993
+ [
994
+ "Wget",
995
+ "http_client",
996
+ /^wget\//i
997
+ ],
998
+ [
999
+ "python-requests",
1000
+ "http_client",
1001
+ /python-requests/i
1002
+ ],
1003
+ [
1004
+ "python-urllib",
1005
+ "http_client",
1006
+ /python-urllib/i
1007
+ ],
1008
+ [
1009
+ "aiohttp",
1010
+ "http_client",
1011
+ /aiohttp/i
1012
+ ],
1013
+ [
1014
+ "httpx",
1015
+ "http_client",
1016
+ /python-httpx|^httpx\//i
1017
+ ],
1018
+ [
1019
+ "Scrapy",
1020
+ "http_client",
1021
+ /scrapy/i
1022
+ ],
1023
+ [
1024
+ "Go-http-client",
1025
+ "http_client",
1026
+ /go-http-client/i
1027
+ ],
1028
+ [
1029
+ "okhttp",
1030
+ "http_client",
1031
+ /^okhttp\//i
1032
+ ],
1033
+ [
1034
+ "Java",
1035
+ "http_client",
1036
+ /^java\/|apache-httpclient/i
1037
+ ],
1038
+ [
1039
+ "axios",
1040
+ "http_client",
1041
+ /^axios\//i
1042
+ ],
1043
+ [
1044
+ "node-fetch",
1045
+ "http_client",
1046
+ /node-fetch/i
1047
+ ],
1048
+ [
1049
+ "undici",
1050
+ "http_client",
1051
+ /^undici/i
1052
+ ],
1053
+ [
1054
+ "PostmanRuntime",
1055
+ "http_client",
1056
+ /postmanruntime/i
1057
+ ],
1058
+ [
1059
+ "insomnia",
1060
+ "http_client",
1061
+ /^insomnia\//i
1062
+ ],
1063
+ [
1064
+ "libwww-perl",
1065
+ "http_client",
1066
+ /libwww-perl/i
1067
+ ],
1068
+ [
1069
+ "Guzzle",
1070
+ "http_client",
1071
+ /guzzlehttp/i
1072
+ ],
1073
+ [
1074
+ "Google-Apps-Script",
1075
+ "http_client",
1076
+ /google-apps-script/i
1077
+ ],
1078
+ [
1079
+ "GoogleDocs",
1080
+ "http_client",
1081
+ /googledocs/i
1082
+ ]
1083
+ ];
1084
+ const botishToken = /\b([\w.-]*?(?:bot|crawler|spider|scraper|fetcher|agent|preview|checker|monitor)[\w-]*)\b/i;
1085
+ const botishWord = /^(?:bot|crawler|spider|scraper|fetcher|agent|preview|checker|monitor)$/i;
1086
+ const compatibleToken = /compatible;\s*([a-z][\w.-]*(?: [a-z][\w.-]*)?)/i;
1087
+ const productTokens = /([a-z][\w.-]*)\/\d/gi;
1088
+ const browserToken = /^(?:mozilla|applewebkit|khtml|gecko|chrome|chromium|safari|version|mobile|firefox|edg|edge|opr|msie|trident)$/i;
1089
+ /**
1090
+ * A name for a bot that is not in the named table, from the first of: a token that sounds like
1091
+ * one (`Bytespider`, `ABEvalBot`), the name after `compatible;` (`Google-Read-Aloud`), a product
1092
+ * token that is not a browser's (`Barkrowler/0.5`), what the generic pattern matched. URLs and
1093
+ * email addresses are dropped first, as nearly every crawler links its docs.
1094
+ */
1095
+ function nameOfUnknownBot(userAgent, matched) {
1096
+ const text = userAgent.replace(/\+?https?:\/\/\S+/gi, " ").replace(/[\w.+-]+@[\w-]+(?:\.[\w-]+)+/g, " ");
1097
+ const botish = botishToken.exec(text)?.[1];
1098
+ if (botish && !botishWord.test(botish)) return botish.slice(0, 64);
1099
+ const compatible = compatibleToken.exec(text)?.[1];
1100
+ if (compatible && !browserToken.test(compatible)) return compatible.slice(0, 64);
1101
+ for (const [, product] of text.matchAll(productTokens)) if (!browserToken.test(product)) return product.slice(0, 64);
1102
+ return matched.replace(/^\W+|\W+$/g, "").slice(0, 64) || "unknown";
1103
+ }
1104
+ /**
1105
+ * Whether a web visitor is a bot, which one, and what kind. Run on the server when the visitor
1106
+ * is created, with the tags it was created with: the user agent is the request's header
1107
+ * (`tags.user_agent`, which the server writes), not anything the client says about itself, so
1108
+ * the verdict can be recomputed from stored tags when the rules change.
1109
+ *
1110
+ * Call it for web visitors only: a native app's requests carry an HTTP library's user agent
1111
+ * (CFNetwork, okhttp) that would read as a bot, and no crawler runs the app.
1112
+ *
1113
+ * In order: a bot we can name; a browser driven by WebDriver (`tags.webdriver`, which the SDK
1114
+ * sets from `navigator.webdriver`, the one sign a scripted browser with a normal user agent
1115
+ * gives); anything the generic pattern calls automated; no user agent at all.
1116
+ */
1117
+ function botOf(tags) {
1118
+ const userAgent = typeof tags.user_agent === "string" ? tags.user_agent.trim() : "";
1119
+ for (const [name, category, pattern] of NAMED_BOTS) if (pattern.test(userAgent)) return {
1120
+ is_bot: true,
1121
+ bot_name: name,
1122
+ bot_category: category
1123
+ };
1124
+ const generic = userAgent ? GENERIC_BOT.exec(userAgent) : null;
1125
+ const unknownName = generic ? nameOfUnknownBot(userAgent, generic[0]) : null;
1126
+ if (tags.webdriver === true) return {
1127
+ is_bot: true,
1128
+ bot_name: unknownName ?? "WebDriver",
1129
+ bot_category: "headless_browser"
1130
+ };
1131
+ if (unknownName) return {
1132
+ is_bot: true,
1133
+ bot_name: unknownName,
1134
+ bot_category: "other"
1135
+ };
1136
+ if (!userAgent) return {
1137
+ is_bot: true,
1138
+ bot_name: "(no user agent)",
1139
+ bot_category: "no_user_agent"
1140
+ };
1141
+ return NOT_A_BOT;
1142
+ }
1143
+ //#endregion
1144
+ export { BOT_CATEGORIES, NAMED_BOTS, NOT_A_BOT, botOf, nameOfUnknownBot };
1145
+
1146
+ //# sourceMappingURL=index.mjs.map