Skip to content

Commit

Permalink
Feat: Rollbar Reporter
Browse files Browse the repository at this point in the history
Include Rollbar as one of the reporter options
  • Loading branch information
edbizarro committed Apr 17, 2017
1 parent 7e4f09e commit c14786e
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,24 @@ To send Exceptions to Bugsnag add the following reporter configuration in `confi
]
```

### [Rollbar](https://rollbar.com)

To send Exceptions to Rollbar add the following reporter configuration in `config/optimus.heimdal.php`.

```
'reporters' => [
'rollbar' => [
'class' => \Optimus\Heimdal\Reporters\RollbarReporter::class,
'config' => [
'access_token' => '',
'environment' => 'production'
]
]
]
```

The complete list of config options can be found in [here](https://github.com/rollbar/rollbar-php#configuration-reference)

## Standards

This package is compliant with [PSR-1], [PSR-2] and [PSR-4]. If you notice compliance oversights,
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
},
"suggest": {
"asm89/stack-cors": "Needed to add CORS headers if add_cors_headers configuration is true",
"sentry/sentry": "Needed to report exceptions to Sentry.io"
"sentry/sentry": "Needed to report exceptions to Sentry.io",
"rollbar/rollbar": "Needed to report exceptions to Rollbar.com"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
35 changes: 35 additions & 0 deletions src/Reporters/RollbarReporter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Optimus\Heimdal\Reporters;

use Exception;
use Rollbar;
use InvalidArgumentException;

class RollbarReporter implements ReporterInterface
{
/**
* RollbarReporter constructor.
* @param array $config
* @throws \InvalidArgumentException
*/
public function __construct(array $config)
{
if (!class_exists(Rollbar::class)) {
throw new InvalidArgumentException('Rollbar client is not installed. Use composer require rollbar/rollbar');
}

Rollbar::init($config);
}

/**
* Report exception
*
* @param Exception $exception
* @return string|void
*/
public function report(Exception $exception)
{
return Rollbar::report_exception($exception);
}
}

0 comments on commit c14786e

Please sign in to comment.