diff --git a/simple-glitchtip.php b/simple-glitchtip.php index 8101b2d..2200165 100644 --- a/simple-glitchtip.php +++ b/simple-glitchtip.php @@ -45,15 +45,21 @@ add_action('admin_init', 'sg_register_settings'); // Initialize error handler function sg_initialize_error_handler($dsn) { - if (!class_exists('Raven_Client')) { - require_once plugin_dir_path(__FILE__) . 'raven-client.phar'; + if (!class_exists('Sentry\State\Hub')) { + require_once plugin_dir_path(__FILE__) . 'sentry.phar'; } - $client = new Raven_Client($dsn); - $error_handler = new Raven_ErrorHandler($client); - $error_handler->registerExceptionHandler(); - $error_handler->registerErrorHandler(); - $error_handler->registerShutdownFunction(); + Sentry\init(['dsn' => $dsn]); + + function handle_exception($exception) { + Sentry\captureException($exception); + } + set_exception_handler('handle_exception'); + + function handle_error($errno, $errstr, $errfile, $errline) { + Sentry\captureMessage("$errstr in $errfile on line $errline"); + } + set_error_handler('handle_error'); } // Initialize the plugin