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
6 changes: 3 additions & 3 deletions lib/Consumer/ForkCurl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

2 things to consider

  • move 5 * 1024 * 1024 to a const so its computed at compile time instead of runtime for every call
  • maybe the payload is small because PHP is single threaded and will block the request until its finished (is that the case?), and 5MB takes much longer to upload than 32KB, we might consider something smaller?

if ($this->debug()) {
$msg = "Message size is larger than 32KB";
$msg = "Message size is larger than 5MB";
error_log("[PostHog][" . $this->type . "] " . $msg);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Consumer/LibCurl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Consumer/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Loading