From 48eb246bd905f3356bb9eabbe0424e3531ceee46 Mon Sep 17 00:00:00 2001 From: Catalin Irimie Date: Sat, 28 Mar 2026 03:27:38 +0200 Subject: [PATCH] fix: increase batch payload size limit from 32KB to 5MB The 32KB limit was inherited from 6yo library and is far too restrictive. The PostHog /batch/ endpoint accepts up to 20MB, and the Python SDK already uses a 5MB limit. --- lib/Consumer/ForkCurl.php | 6 +++--- lib/Consumer/LibCurl.php | 6 +++--- lib/Consumer/Socket.php | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/Consumer/ForkCurl.php b/lib/Consumer/ForkCurl.php index 5a16779..dee0b1e 100644 --- a/lib/Consumer/ForkCurl.php +++ b/lib/Consumer/ForkCurl.php @@ -74,10 +74,10 @@ public function flushBatch($messages) $cmd .= " '" . $url . "'"; - // Verify message size is below than 32KB - if (strlen($payload) >= 32 * 1024) { + // Verify message size is below than 5MB + if (strlen($payload) >= 5 * 1024 * 1024) { if ($this->debug()) { - $msg = "Message size is larger than 32KB"; + $msg = "Message size is larger than 5MB"; error_log("[PostHog][" . $this->type . "] " . $msg); } diff --git a/lib/Consumer/LibCurl.php b/lib/Consumer/LibCurl.php index 973e960..7600843 100644 --- a/lib/Consumer/LibCurl.php +++ b/lib/Consumer/LibCurl.php @@ -56,10 +56,10 @@ public function flushBatch($messages) $body = $this->payload($messages); $payload = json_encode($body); - // Verify message size is below than 32KB - if (strlen($payload) >= 32 * 1024) { + // Verify message size is below than 5MB + if (strlen($payload) >= 5 * 1024 * 1024) { if ($this->debug()) { - $msg = "Message size is larger than 32KB"; + $msg = "Message size is larger than 5MB"; error_log("[PostHog][" . $this->type . "] " . $msg); } diff --git a/lib/Consumer/Socket.php b/lib/Consumer/Socket.php index 11e11c5..b7f56a4 100644 --- a/lib/Consumer/Socket.php +++ b/lib/Consumer/Socket.php @@ -200,10 +200,10 @@ private function createBody($host, $content) $req .= "\r\n"; $req .= $content; - // Verify message size is below than 32KB - if (strlen($req) >= 32 * 1024) { + // Verify message size is below than 5MB + if (strlen($req) >= 5 * 1024 * 1024) { if ($this->debug()) { - $msg = "Message size is larger than 32KB"; + $msg = "Message size is larger than 5MB"; error_log("[PostHog][" . $this->type . "] " . $msg); }