composer require errorstream/errorstream-laravel 3.*
Next, register the service provider in the config/app.php file.
'providers' => [
// ...
ErrorStream\ErrorStream\ErrorStreamServiceProvider::class,
]
Then add the Facade to the aliases array in the config/app.php file.
'aliases' => [
// ...
'ErrorStream' => ErrorStream\ErrorStream\Facades\ErrorStream::class,
]
Then hook into the App/Exceptions/Handler.php file to send errors to our service.
public function report(Exception $e)
{
if ($this->shouldReport($e)) {
ErrorStream::reportException($e);
}
parent::report($e);
}
Add the following two configuration entries into .env. You can find your API key and project token on the project settings page for the project you wish to integrate.
ERROR_STREAM_API_TOKEN=YOUR_API_TOKEN
ERROR_STREAM_PROJECT_TOKEN=YOUR_PROJECT_TOKEN
Finally, add the following to the services.php file.
'errorstream' => [
'api_token' => env('ERROR_STREAM_API_TOKEN'),
'project_token' => env('ERROR_STREAM_PROJECT_TOKEN'),
],
Anywhere within your application you can append tags on to the reports that you generate and send to errorstream.com. Tags are great for grouping code together. You can make a call to add a tag anywhere by calling addTag():
ErrorStream::addTag('tag text');
A good potential place for tags is in your handler class. Tags are great to represent releases, servers, or other static items. For example:
if ($this->shouldReport($e)) {
ErrorStream::addTag('v1.0.2');
ErrorStream::addTag(gethostname());
ErrorStream::reportException($e);
}
Context is great for adding more details- a User ID, build number, or even some variable values. You can set these up anywhere in your application. When an error occurs errorstream will send this data over with your error report. If no error occurs, then no event will be triggered.
ErrorStream::addContext('user 51222553');