diff --git a/src/Ray.php b/src/Ray.php index b673f5d..f79e72e 100644 --- a/src/Ray.php +++ b/src/Ray.php @@ -817,7 +817,7 @@ public function sendRequest($payloads, array $meta = []): self ], $meta); if ($closure = static::$beforeSendRequest) { - $closure($payloads, $meta); + $closure($payloads, $allMeta); } foreach ($payloads as $payload) { diff --git a/tests/RayTest.php b/tests/RayTest.php index c700e26..bfff3fd 100644 --- a/tests/RayTest.php +++ b/tests/RayTest.php @@ -1176,3 +1176,17 @@ function (InvalidArgumentException $e, $ray) { expect($sentRequests[0]['payloads'][0]['content']['level'])->toBe(999); }); + +it('can add a closure for before send and actually calls it', function () { + $this->closureCalled = false; + + $this->ray::beforeSendRequest(function () { + $this->closureCalled = true; + }); + + $this->ray->send(function ($ray) { + $ray->text('Hello world'); + }); + + expect($this->closureCalled)->toBeTrue(); +});