/** * {@inheritdoc} */ public function register() { $app = $this->app; // Register config $this->app->config->package('rcrowe/raven', __DIR__ . '/config'); // Bind laravel handler $this->app->bindIf('log.sentry.handler', function () use($app) { return new Laravel(null, $app['queue']); }); // Bind raven client $this->app->bind('log.sentry', function () use($app) { $client = new Client($app->config->get('raven::dsn')); $client->addHandler($app->make('log.sentry.handler')); return $client; }); }
/** * {@inheritdoc} */ public function process(Client $client, array $data) { $message = $this->encodeMessage($data); foreach ($client->servers as $url) { $this->getTransport()->send($url, $message, Client::getHeaders($client)); } }
public function testProcessParams() { $client = new Client('https://*****:*****@app.getsentry.com/789'); $data = array('foo' => 'bar'); $message = Raven_Compat::json_encode($data); if (function_exists("gzcompress")) { $message = base64_encode(gzcompress($message)); } $handler = m::mock('rcrowe\\Raven\\Handler\\HandlerInterface'); $handler->shouldReceive('process')->once()->with('https://app.getsentry.com/api/store/', $message, m::on(function ($param) { if (!array_key_exists('User-Agent', $param)) { return false; } if ($param['User-Agent'] !== 'rcrowe-raven/' . Client::VERSION) { return false; } if (!array_key_exists('X-Sentry-Auth', $param)) { return false; } if (!array_key_exists('Content-Type', $param)) { return false; } if ($param['Content-Type'] !== 'application/octet-stream') { return false; } return true; })); $client->setHandler($handler); $client->send($data); }
public function fire(IlluminateJob $job, $data) { $client = new Client($data['client']); $transport = new $data['transport']['class'](); foreach ($client->servers as $url) { $transport->send($url, $data['message'], Client::getHeaders($client)); } $job->delete(); }
/** * {@inheritdoc} */ public function register() { $this->app->config->package('rcrowe/raven', realpath(__DIR__ . '/../../config'), 'raven'); $this->app->bindIf('log.raven.dsn', function () { return $this->app->config->get('services.raven.dsn') ?: $this->app->config->get('raven::dsn'); }); $this->app->bindIf('log.raven.transport', function () { return new Transport(); }); $this->app->bindIf('log.raven.handler', function () { return new Handler($this->app['log.raven.transport'], $this->app->queue); }); $this->app->bindIf('log.raven.processors', function () { return $this->app->config->get('raven::monolog.processors', []); }); $this->app->singleton('log.raven', function () { $client = new Client($this->app['log.raven.dsn']); $client->tags_context(['laravel_environment' => $this->app->environment(), 'laravel_version' => Application::VERSION]); $client->setHandler($this->app['log.raven.handler']); return $client; }); }
/** * {@inheritdoc} */ public function process(Client $client, array $message) { $data = array('message' => $this->encodeMessage($message), 'client' => Client::getClientOptions($client), 'transport' => $this->getTransport()->toArray()); $this->queue->push('rcrowe\\Raven\\Handler\\Laravel\\Job', $data); }
/** * Return the headers needed for the Sentry API. * * @param \rcrowe\Raven\Client $client * * @return array */ public static function getHeaders(Client $client) { $client_string = 'rcrowe-raven/' . static::VERSION; $timestamp = microtime(true); return array('User-Agent' => $client_string, 'X-Sentry-Auth' => $client->getAuthHeader($timestamp, $client_string, $client->public_key, $client->secret_key), 'Content-Type' => 'application/octet-stream'); }