diff --git a/composer.json b/composer.json index 726e973..4b34702 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,8 @@ "require": { "league/oauth2-client": "^2.2", "joshcam/mysqli-database-class": "^2.7", - "curl/curl": "^1.6" + "curl/curl": "^1.6", + "sentry/sentry": "^1.7" }, "license": "MIT", "authors": [ diff --git a/composer.lock b/composer.lock index 5254728..1756c74 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "a6abecc8d6b362ddb857afb00fc9c55f", + "content-hash": "5310f13f957f21213d4cc5873a80cbd1", "packages": [ { "name": "curl/curl", @@ -451,6 +451,71 @@ "response" ], "time": "2016-08-06T14:39:51+00:00" + }, + { + "name": "sentry/sentry", + "version": "1.7.0", + "source": { + "type": "git", + "url": "https://github.com/getsentry/sentry-php.git", + "reference": "f92d30467d9696606352aa06afeac0a60c4458ef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/f92d30467d9696606352aa06afeac0a60c4458ef", + "reference": "f92d30467d9696606352aa06afeac0a60c4458ef", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": "^5.3|^7.0" + }, + "conflict": { + "raven/raven": "*" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^1.8.0", + "monolog/monolog": "*", + "phpunit/phpunit": "^4.8 || ^5.0" + }, + "suggest": { + "ext-hash": "*", + "ext-json": "*", + "ext-mbstring": "*", + "immobiliare/sentry-php": "Fork that fixes support for PHP 5.2", + "monolog/monolog": "Automatically capture Monolog events as breadcrumbs" + }, + "bin": [ + "bin/sentry" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7.x-dev" + } + }, + "autoload": { + "psr-0": { + "Raven_": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "David Cramer", + "email": "dcramer@gmail.com" + } + ], + "description": "A PHP client for Sentry (http://getsentry.com)", + "homepage": "http://getsentry.com", + "keywords": [ + "log", + "logging" + ], + "time": "2017-06-07T18:13:17+00:00" } ], "packages-dev": [], diff --git a/config.sample.php b/config.sample.php index d654396..e9c9503 100644 --- a/config.sample.php +++ b/config.sample.php @@ -12,6 +12,9 @@ "client_secret" => "", "redirect_uri" => "https://localhost/api/oauth_flow_finish" ], + "sentry" => [ + "dsn" => "", + ], ]; define("DATABASE_HOST", $config["db"]["host"]); diff --git a/include.php b/include.php index 30b6c69..071a07d 100644 --- a/include.php +++ b/include.php @@ -2,6 +2,13 @@ require_once(__DIR__ . "/vendor/autoload.php"); require_once(__DIR__ . "/config.php"); + +// Set up sentry +if (!empty($config["sentry"]["dsn"])) { + $sentry = new Raven_Client($config["sentry"]["dsn"]); + $sentry->install(); +} + require_once(__DIR__ . "/classes/DBPDO.php"); require_once(__DIR__ . "/classes/State.php"); diff --git a/router.php b/router.php index b629b4a..3dc2eff 100644 --- a/router.php +++ b/router.php @@ -27,6 +27,8 @@ run_method($state); } catch (Exception $e) { - // TODO: Log to sentry + if (isset($sentry)) { + $sentry->captureException($e); + } error_message("server-side error", 500); }