Skip to content

Conversation

@Tehnix
Copy link
Contributor

@Tehnix Tehnix commented Oct 28, 2025

Problem

It seems only some of the API calls had added the sanitazion method for removing base64 encoded images from the input sent to PostHog (see #2134).

This would currently result in the payload sent to PostHog being too large, giving an error like this:

Error while flushing PostHog: message=HTTP error while fetching PostHog: status=413, reqByteLength=868722, response body=maximum event size exceeded: Event rejected by kafka during send PostHogFetchHttpError: HTTP error while fetching PostHog: status=413, reqByteLength=868722
    at retriable (file:///node_modules/@posthog/core/dist/posthog-core-stateless.mjs:593:77)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at retriable (file:///node_modules/@posthog/core/dist/utils/index.mjs:22:25)
    at PostHog.fetchWithRetry (file:///node_modules/@posthog/core/dist/posthog-core-stateless.mjs:582:16)
    at PostHog._flush (file:///node_modules/@posthog/core/dist/posthog-core-stateless.mjs:549:17) {
  response: Response {
    status: 413,
    statusText: 'Payload Too Large',
    headers: Headers {
      date: 'Wed, 22 Oct 2025 11:03:35 GMT',
      'content-type': 'text/plain; charset=utf-8',
      'transfer-encoding': 'chunked',
      connection: 'keep-alive',
      vary: 'origin, access-control-request-method, access-control-request-headers, Accept-Encoding',
      'access-control-allow-credentials': 'true',
      'x-envoy-upstream-service-time': '17',
      'content-encoding': 'gzip',
      server: 'envoy',
      'strict-transport-security': 'max-age=31536000; includeSubDomains'
    },
    body: ReadableStream { locked: true, state: 'closed', supportsBYOB: true },
    bodyUsed: true,
    ok: false,
    redirected: false,
    type: 'basic',
    url: 'https://us.i.posthog.com/batch/'
  },
  reqByteLength: 868722
}

Most of the work was already done in #2217, it was just missing the responses API, which this PR adds.

Changes

  • Wrapped the input sent to PostHog for the Responses API with sanitizeOpenAI

Release info Sub-libraries affected

Libraries affected

  • All of them
  • posthog-js (web)
  • posthog-js-lite (web lite)
  • posthog-node
  • posthog-react-native
  • @posthog/react
  • @posthog/ai
  • @posthog/nextjs-config

Checklist

  • Tests for new code
  • Accounted for the impact of any changes across different platforms
  • Accounted for backwards compatibility of any changes (no breaking changes!)
  • Took care not to unnecessarily increase the bundle size

If releasing new changes

  • Ran pnpm changeset to generate a changeset file
  • Added the "release" label to the PR to indicate we're publishing new versions for the affected packages

@vercel
Copy link

vercel bot commented Oct 28, 2025

@Tehnix is attempting to deploy a commit to the PostHog Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 6 comments

Edit Code Review Agent Settings | Greptile

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@pedsm
Copy link

pedsm commented Nov 5, 2025

Would love to see this one merged

@posthog-bot posthog-bot removed the stale label Nov 6, 2025
@Tehnix
Copy link
Contributor Author

Tehnix commented Nov 10, 2025

@posthog-bot This is still very much relevant, I'm running a locally patched version of @posthog/ai currently that adds this.

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@Tehnix
Copy link
Contributor Author

Tehnix commented Nov 23, 2025

@posthog-bot This is still very much relevant, I'm running a locally patched version of @posthog/ai currently that adds this.

I'll update the PR to resolve the conflicts tomorrow though

@posthog-bot posthog-bot removed the stale label Nov 24, 2025
@Tehnix
Copy link
Contributor Author

Tehnix commented Nov 24, 2025

@PostHog/team-llm-analytics are you the right team to loop in here? Apologize if I shouldn't tag anyone directly, if that's the case lemme know and I'll just keep the PRs open and let your internal triage handle when you have time for it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants