Skip to content

Commit 7a77ed3

Browse files
authored
Update bot detection list and add support for oxygen-do-not-stream-response header (#2514)
* Update bot detection list and add support for oxygen-do-not-stream-response header * Fix tests
1 parent 3b3903b commit 7a77ed3

File tree

4 files changed

+43
-34
lines changed

4 files changed

+43
-34
lines changed

.changeset/happy-snails-pay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/hydrogen': patch
3+
---
4+
5+
Update bot detection list and add support for oxygen-do-not-stream-response header

packages/hydrogen/src/entry-server.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,10 @@ async function processRequest(
323323
});
324324
}
325325

326-
if (isBotUA(url, request.headers.get('user-agent'))) {
326+
if (
327+
request.headers.get('oxygen-do-not-stream-response') === 'true' ||
328+
isBotUA(url, request.headers.get('user-agent'))
329+
) {
327330
response.doNotStream();
328331
}
329332

packages/hydrogen/src/foundation/Analytics/tests/Analytics.client.utm.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {ClientAnalytics} from '../ClientAnalytics.js';
99
// window.location more than once
1010
describe('Analytics.client utm', () => {
1111
it('should process utm search parameters', async (done) => {
12-
global.window = Object.create(window);
12+
// global.window = Object.create(window);
1313
Object.defineProperty(window, 'location', {
1414
value: {
1515
search:

packages/hydrogen/src/utilities/bot-ua.ts

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,56 @@
44
* https://github.com/GoogleChrome/rendertron/blob/6f681688737846b28754fbfdf5db173846a826df/middleware/src/middleware.ts#L24-L41
55
*/
66
const botUserAgents = [
7-
'AdsBot-Google',
8-
'AdsBot-Google-Mobile',
7+
'360spider',
8+
'adsbot-google',
9+
'adsbot-google-mobile',
910
'applebot',
10-
'Baiduspider',
1111
'baiduspider',
12-
'Bytespider',
13-
'360Spider',
14-
'PetalBot',
15-
'Yisouspider',
12+
'baiduspider',
13+
'bingbot',
1614
'bingbot',
17-
'Bingbot',
18-
'BingPreview',
15+
'bingpreview',
1916
'bitlybot',
20-
'Discordbot',
21-
'DuckDuckBot',
22-
'Embedly',
17+
'bytespider',
18+
'discordbot',
19+
'duckduckbot',
20+
'embedly',
2321
'facebookcatalog',
2422
'facebookexternalhit',
25-
'Google-PageRenderer',
26-
'Googlebot',
27-
'Googlebot-Image',
28-
'Googlebot-News',
29-
'Googlebot-Video',
23+
'google-inspectiontool',
24+
'google-pagerenderer',
25+
'googlebot',
26+
'googlebot-image',
27+
'googlebot-news',
28+
'googlebot-video',
29+
'googleother',
3030
'googleweblight',
3131
'ia_archive',
32-
'LinkedInBot',
33-
'Mediapartners-Google',
32+
'ia_archiver',
33+
'linkedinbot',
34+
'mediapartners-google',
3435
'outbrain',
36+
'petalbot',
3537
'pinterest',
3638
'quora link preview',
3739
'redditbot',
3840
'rogerbot',
41+
'seoradar',
3942
'showyoubot',
40-
'SkypeUriPreview',
41-
'Slackbot',
42-
'Slurp',
43+
'skypeuripreview',
44+
'slackbot',
45+
'slurp',
4346
'sogou',
44-
'Storebot-Google',
45-
'TelegramBot',
47+
'storebot-google',
48+
'telegrambot',
4649
'tumblr',
47-
'Twitterbot',
48-
'vkShare',
49-
'W3C_Validator',
50-
'WhatsApp',
50+
'twitterbot',
51+
'vkshare',
52+
'w3c html2txt',
53+
'w3c_validator',
54+
'whatsapp',
5155
'yandex',
52-
53-
// SEO Tools
54-
'Seoradar',
55-
'W3C html2txt',
56+
'yisouspider',
5657
];
5758

5859
/**

0 commit comments

Comments
 (0)