Skip to content

Commit

Permalink
Unset the last error and return null if the event was never sent
Browse files Browse the repository at this point in the history
  • Loading branch information
stayallive committed Oct 12, 2018
1 parent 79d7252 commit 07dd350
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,11 @@ public function capture(array $payload)
$payload
);

$this->send($event);
if (false === $this->send($event)) {
$this->lastEvent = null;

return null;
}

$this->lastEvent = $event;

Expand All @@ -356,15 +360,15 @@ public function capture(array $payload)
public function send(Event $event)
{
if (!$this->config->shouldCapture($event)) {
return;
return false;
}

// should this event be sampled?
if (mt_rand(1, 100) / 100.0 > $this->config->getSampleRate()) {
return;
return false;
}

$this->transport->send($event);
return $this->transport->send($event);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function captureLastError(array $payload = []);
* Gets the last event that was captured by the client. However, it could
* have been sent or still sit in the queue of pending events.
*
* @return Event
* @return Event|null
*/
public function getLastEvent();

Expand All @@ -127,14 +127,16 @@ public function getLastEventId();
*
* @param array $payload The data of the event being captured
*
* @return string
* @return string|null
*/
public function capture(array $payload);

/**
* Sends the given event to the Sentry server.
*
* @param Event $event The event to send
*
* @return bool|null
*/
public function send(Event $event);

Expand Down

0 comments on commit 07dd350

Please sign in to comment.