Skip to content

Commit dd24c3c

Browse files
committed
added a method to get the latest event id
1 parent b60f544 commit dd24c3c

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ You can change the logs used by changing the log level in the config by modifyin
8484
RAVEN_LEVEL=error
8585
```
8686

87+
### Event Id
88+
89+
There is a method to get the **latest** event id so it can be used on things like the error page.
90+
91+
```php
92+
Raven::getLastEventId();
93+
```
94+
8795
### Context information
8896

8997
You can pass additional information as context like this:

src/Client.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ class Client extends Raven_Client
1818
*/
1919
protected $queue;
2020

21+
/**
22+
* Stores the latest event id
23+
*
24+
* @var string
25+
*/
26+
protected $eventId;
27+
2128
/**
2229
* @param array $config,
2330
* @param \Illuminate\Queue\QueueManager $queue
@@ -42,11 +49,23 @@ public function __construct(array $config, QueueManager $queue = null, $env = nu
4249
parent::__construct(array_get($config, 'dsn', ''), $options);
4350
}
4451

52+
/**
53+
* Get the last stored event id
54+
*
55+
* @return string
56+
*/
57+
public function getLastEventId()
58+
{
59+
return $this->eventId;
60+
}
61+
4562
/**
4663
* {@inheritdoc}
4764
*/
4865
public function send($data)
4966
{
67+
$this->eventId = array_get($data, 'event_id');
68+
5069
// send error now if queue not set
5170
if (is_null($this->queue)) {
5271
return $this->sendError($data);

src/Log.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Log extends Writer
2121
*/
2222
protected function writeLog($level, $message, $context)
2323
{
24-
if (is_a($message, 'Exception')) {
24+
if ($message instanceof Exception) {
2525
// Set context exception using exception
2626
$context = array_merge($context, ['exception' => $message]);
2727

0 commit comments

Comments
 (0)