Skip to content

Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️

Add Sentry logging (#393)

Dave Earley5e88606e2800
diff --git a/backend/app/Exceptions/Handler.php b/backend/app/Exceptions/Handler.php
index dbcfbdca9..0c9ec8663 100644
--- a/backend/app/Exceptions/Handler.php
+++ b/backend/app/Exceptions/Handler.php
@@ -3,6 +3,7 @@
namespace HiEvents\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
+use Sentry\Laravel\Facade as Sentry;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Throwable;
@@ -14,7 +15,7 @@ class Handler extends ExceptionHandler
* @var array
*/
protected $dontReport = [
- //
+ // Add exceptions that shouldn't be reported
];
/**
@@ -30,11 +31,16 @@ class Handler extends ExceptionHandler
/**
* Report or log an exception.
*
- * @param \Exception $e
+ * @param Throwable $e
* @return void
+ * @throws Throwable
*/
public function report(Throwable $e)
{
+ if ($this->shouldReport($e)) {
+ Sentry::captureException($e);
+ }
+
parent::report($e);
}
@@ -42,8 +48,8 @@ class Handler extends ExceptionHandler
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
- * @param \Exception $exception
- * @return \Illuminate\Http\JsonResponse
+ * @param Throwable $exception
+ * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response
* @throws Throwable
*/
public function render($request, Throwable $exception)
diff --git a/backend/composer.json b/backend/composer.json
index 53d578b55..b510c419a 100644
--- a/backend/composer.json
+++ b/backend/composer.json
@@ -22,6 +22,7 @@
"maatwebsite/excel": "^3.1",
"nette/php-generator": "^4.0",
"php-open-source-saver/jwt-auth": "^2.1",
+ "sentry/sentry-laravel": "^4.13",
"spatie/icalendar-generator": "^2.8",
"spatie/laravel-data": "^4.11",
"spatie/laravel-webhook-server": "^3.8",
diff --git a/backend/composer.lock b/backend/composer.lock
index 122441a01..3fbda137e 100644
--- a/backend/composer.lock
+++ b/backend/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "029aa5c375f82fe7cf955fcc80e5222b",
+ "content-hash": "62f38e147541b5968f5fe0e08abb6c57",
"packages": [
{
"name": "amphp/amp",
@@ -2940,6 +2940,65 @@
},
"time": "2021-12-07T10:10:20+00:00"
},
+ {
+ "name": "jean85/pretty-package-versions",
+ "version": "2.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Jean85/pretty-package-versions.git",
+ "reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/3c4e5f62ba8d7de1734312e4fff32f67a8daaf10",
+ "reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10",
+ "shasum": ""
+ },
+ "require": {
+ "composer-runtime-api": "^2.1.0",
+ "php": "^7.4|^8.0"
+ },
+ "require-dev": {
+ "friendsofphp/php-cs-fixer": "^3.2",
+ "jean85/composer-provided-replaced-stub-package": "^1.0",
+ "phpstan/phpstan": "^1.4",
+ "phpunit/phpunit": "^7.5|^8.5|^9.6",
+ "vimeo/psalm": "^4.3 || ^5.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Jean85\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Alessandro Lai",
+ "email": "[email protected]"
+ }
+ ],
+ "description": "A library to get pretty versions strings of installed dependencies",
+ "keywords": [
+ "composer",
+ "package",
+ "release",
+ "versions"
+ ],
+ "support": {
+ "issues": "https://github.com/Jean85/pretty-package-versions/issues",
+ "source": "https://github.com/Jean85/pretty-package-versions/tree/2.1.0"
+ },
+ "time": "2024-11-18T16:19:46+00:00"
+ },
{
"name": "kelunik/certificate",
"version": "v1.1.3",
@@ -6936,6 +6995,184 @@
},
"time": "2024-10-27T17:38:32+00:00"
},
+ {
+ "name": "sentry/sentry",
+ "version": "4.10.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/getsentry/sentry-php.git",
+ "reference": "2af937d47d8aadb8dab0b1d7b9557e495dd12856"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/2af937d47d8aadb8dab0b1d7b9557e495dd12856",
+ "reference": "2af937d47d8aadb8dab0b1d7b9557e495dd12856",
+ "shasum": ""
+ },
+ "require": {
+ "ext-curl": "*",
+ "ext-json": "*",
+ "ext-mbstring": "*",
+ "guzzlehttp/psr7": "^1.8.4|^2.1.1",
+ "jean85/pretty-package-versions": "^1.5|^2.0.4",
+ "php": "^7.2|^8.0",
+ "psr/log": "^1.0|^2.0|^3.0",
+ "symfony/options-resolver": "^4.4.30|^5.0.11|^6.0|^7.0"
+ },
+ "conflict": {
+ "raven/raven": "*"
+ },
+ "require-dev": {
+ "friendsofphp/php-cs-fixer": "^3.4",
+ "guzzlehttp/promises": "^2.0.3",
+ "guzzlehttp/psr7": "^1.8.4|^2.1.1",
+ "monolog/monolog": "^1.6|^2.0|^3.0",
+ "phpbench/phpbench": "^1.0",
+ "phpstan/phpstan": "^1.3",
+ "phpunit/phpunit": "^8.5|^9.6",
+ "symfony/phpunit-bridge": "^5.2|^6.0|^7.0",
+ "vimeo/psalm": "^4.17"
+ },
+ "suggest": {
+ "monolog/monolog": "Allow sending log messages to Sentry by using the included Monolog handler."
+ },
+ "type": "library",
+ "autoload": {
+ "files": [
+ "src/functions.php"
+ ],
+ "psr-4": {
+ "Sentry\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Sentry",
+ "email": "[email protected]"
+ }
+ ],
+ "description": "PHP SDK for Sentry (http://sentry.io)",
+ "homepage": "http://sentry.io",
+ "keywords": [
+ "crash-reporting",
+ "crash-reports",
+ "error-handler",
+ "error-monitoring",
+ "log",
+ "logging",
+ "profiling",
+ "sentry",
+ "tracing"
+ ],
+ "support": {
+ "issues": "https://github.com/getsentry/sentry-php/issues",
+ "source": "https://github.com/getsentry/sentry-php/tree/4.10.0"
+ },
+ "funding": [
+ {
+ "url": "https://sentry.io/",
+ "type": "custom"
+ },
+ {
+ "url": "https://sentry.io/pricing/",
+ "type": "custom"
+ }
+ ],
+ "time": "2024-11-06T07:44:19+00:00"
+ },
+ {
+ "name": "sentry/sentry-laravel",
+ "version": "4.13.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/getsentry/sentry-laravel.git",
+ "reference": "d232ac494258e0d50a77c575a5af5f1a426d3f87"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/getsentry/sentry-laravel/zipball/d232ac494258e0d50a77c575a5af5f1a426d3f87",
+ "reference": "d232ac494258e0d50a77c575a5af5f1a426d3f87",
+ "shasum": ""
+ },
+ "require": {
+ "illuminate/support": "^6.0 | ^7.0 | ^8.0 | ^9.0 | ^10.0 | ^11.0 | ^12.0",
+ "nyholm/psr7": "^1.0",
+ "php": "^7.2 | ^8.0",
+ "sentry/sentry": "^4.10",
+ "symfony/psr-http-message-bridge": "^1.0 | ^2.0 | ^6.0 | ^7.0"
+ },
+ "require-dev": {
+ "friendsofphp/php-cs-fixer": "^3.11",
+ "guzzlehttp/guzzle": "^7.2",
+ "laravel/folio": "^1.1",
+ "laravel/framework": "^6.0 | ^7.0 | ^8.0 | ^9.0 | ^10.0 | ^11.0 | ^12.0",
+ "livewire/livewire": "^2.0 | ^3.0",
+ "mockery/mockery": "^1.3",
+ "orchestra/testbench": "^4.7 | ^5.1 | ^6.0 | ^7.0 | ^8.0 | ^9.0 | ^10.0",
+ "phpstan/phpstan": "^1.10",
+ "phpunit/phpunit": "^8.4 | ^9.3 | ^10.4 | ^11.5"
+ },
+ "type": "library",
+ "extra": {
+ "laravel": {
+ "aliases": {
+ "Sentry": "Sentry\\Laravel\\Facade"
+ },
+ "providers": [
+ "Sentry\\Laravel\\ServiceProvider",
+ "Sentry\\Laravel\\Tracing\\ServiceProvider"
+ ]
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Sentry\\Laravel\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Sentry",
+ "email": "[email protected]"
+ }
+ ],
+ "description": "Laravel SDK for Sentry (https://sentry.io)",
+ "homepage": "https://sentry.io",
+ "keywords": [
+ "crash-reporting",
+ "crash-reports",
+ "error-handler",
+ "error-monitoring",
+ "laravel",
+ "log",
+ "logging",
+ "profiling",
+ "sentry",
+ "tracing"
+ ],
+ "support": {
+ "issues": "https://github.com/getsentry/sentry-laravel/issues",
+ "source": "https://github.com/getsentry/sentry-laravel/tree/4.13.0"
+ },
+ "funding": [
+ {
+ "url": "https://sentry.io/",
+ "type": "custom"
+ },
+ {
+ "url": "https://sentry.io/pricing/",
+ "type": "custom"
+ }
+ ],
+ "time": "2025-02-18T10:09:29+00:00"
+ },
{
"name": "spatie/enum",
"version": "3.13.0",
@@ -8377,6 +8614,73 @@
],
"time": "2024-01-30T08:34:29+00:00"
},
+ {
+ "name": "symfony/options-resolver",
+ "version": "v7.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/options-resolver.git",
+ "reference": "7da8fbac9dcfef75ffc212235d76b2754ce0cf50"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/options-resolver/zipball/7da8fbac9dcfef75ffc212235d76b2754ce0cf50",
+ "reference": "7da8fbac9dcfef75ffc212235d76b2754ce0cf50",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.2",
+ "symfony/deprecation-contracts": "^2.5|^3"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\OptionsResolver\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "[email protected]"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Provides an improved replacement for the array_replace PHP function",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "config",
+ "configuration",
+ "options"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/options-resolver/tree/v7.2.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-11-20T11:17:29+00:00"
+ },
{
"name": "symfony/polyfill-ctype",
"version": "v1.29.0",