Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(ai-research): rename the image fetcher bot (#85308)

Robbie58cc134772dc
diff --git a/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror-image-fetch/image-fetcher.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror-image-fetch/image-fetcher.test.ts
index cfb97f27df3b..d121b3bd4032 100644
--- a/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror-image-fetch/image-fetcher.test.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror-image-fetch/image-fetcher.test.ts
@@ -51,6 +51,22 @@ describe('HttpImageFetcher', () => {
fetchStreamedMock.mockReset()
})
+ it('identifies every request as PostHogImageFetcherBot', async () => {
+ fetchStreamedMock.mockResolvedValue(image(PNG, 'image/png'))
+
+ await fetcher().fetch('https://cdn.example.com/a.png', OPTIONS)
+
+ expect(fetchStreamedMock).toHaveBeenCalledWith(
+ 'https://cdn.example.com/a.png',
+ expect.objectContaining({
+ headers: expect.objectContaining({
+ 'user-agent':
+ 'PostHogImageFetcherBot/1.0 (+https://posthog.com/docs/ai-research/image-fetcher-bot)',
+ }),
+ })
+ )
+ })
+
it('returns the bytes of an image whose payload matches its declared type', async () => {
fetchStreamedMock.mockResolvedValue(image(PNG, 'image/png; charset=binary'))
diff --git a/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror-image-fetch/image-fetcher.ts b/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror-image-fetch/image-fetcher.ts
index c6412fb293e2..8b8f4b88f485 100644
--- a/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror-image-fetch/image-fetcher.ts
+++ b/nodejs/src/ingestion/pipelines/sessionreplay/ml-mirror-image-fetch/image-fetcher.ts
@@ -77,7 +77,7 @@ export interface ImageFetcher {
fetch(url: string, options: ImageFetchOptions): Promise<ImageFetchResult>
}
-const USER_AGENT = 'PostHogSessionReplayBot/1.0 (+https://posthog.com/docs/session-replay/image-bot)'
+const USER_AGENT = 'PostHogImageFetcherBot/1.0 (+https://posthog.com/docs/ai-research/image-fetcher-bot)'
const REQUEST_HEADERS: Record<string, string> = {
'user-agent': USER_AGENT,