diff --git a/.changeset/narrow-pinterest-bot.md b/.changeset/narrow-pinterest-bot.md new file mode 100644 index 0000000000..6714c68b0c --- /dev/null +++ b/.changeset/narrow-pinterest-bot.md @@ -0,0 +1,8 @@ +--- +'@posthog/core': patch +'@posthog/browser-common': patch +'posthog-js': patch +'posthog-node': patch +--- + +Narrow the `pinterest` entry in the bot-detection blocklist to `pinterestbot`, so real users on Pinterest's in-app browser (whose UA also contains the substring `pinterest`) are no longer misclassified as bots and silently excluded from analytics. The crawler's other UA variant remains covered by the existing generic `bot.htm` entry, so no bot-detection coverage is lost. diff --git a/packages/browser/src/__tests__/utils.test.ts b/packages/browser/src/__tests__/utils.test.ts index 202ef9b016..03b9867c6e 100644 --- a/packages/browser/src/__tests__/utils.test.ts +++ b/packages/browser/src/__tests__/utils.test.ts @@ -174,6 +174,7 @@ describe('utils', () => { 'Mozilla/5.0 (compatible; SeznamBot/4.0; +https://o-seznam.cz/napoveda/vyhledavani/en/seznambot-crawler/)', ], ['BrightEdge Crawler/1.0 (crawler@brightedge.com)'], + ['Mozilla/5.0 (compatible; Pinterestbot/1.0; +http://www.pinterest.com/bot.html)'], ])('blocks based on user agent', (botString) => { expect(isBlockedUA(botString, [])).toBe(true) expect(isBlockedUA(botString.toLowerCase(), [])).toBe(true) @@ -194,6 +195,10 @@ describe('utils', () => { [ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) elec/1.0.0 Chrome/126.0.6478.127 Electron/31.2.1 Safari/537.36', ], + [ + // Pinterest app's own in-app browser -- a real user, not the Pinterestbot crawler + 'Mozilla/5.0 (iPad; CPU OS 11_2_6 like Mac OS X) AppleWebKit/604.5.6 (KHTML, like Gecko) Mobile/15D100 [Pinterest/iOS]', + ], ])('does not block based on non-bot user agent', (userAgent) => { expect(isBlockedUA(userAgent, [])).toBe(false) expect(isBlockedUA(userAgent.toLowerCase(), [])).toBe(false) diff --git a/packages/core/src/utils/bot-detection.ts b/packages/core/src/utils/bot-detection.ts index 3e7850369f..f30f7cd196 100644 --- a/packages/core/src/utils/bot-detection.ts +++ b/packages/core/src/utils/bot-detection.ts @@ -28,7 +28,11 @@ export const DEFAULT_BLOCKED_UA_STRS = [ 'msnbot', 'nessus', 'petalbot', - 'pinterest', + // not the bare 'pinterest' -- that also matches the Pinterest app's own in-app + // browser UA (e.g. "...Mobile/15D100 [Pinterest/iOS]"), which is a real user, + // not the crawler. The crawler's other UA variant ("...pinterest.com/bot.html") + // is still covered by the generic 'bot.htm' entry below. + 'pinterestbot', 'prerender', 'rogerbot', 'screaming frog',