Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/narrow-pinterest-bot.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions packages/browser/src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/utils/bot-detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down