<?php
/*
https://docs.sentry.io/clients/php/
*/
//creation of the raven client
$sentryClient = $client = new Raven_Client('https://16f49115dc5845f89a3f5481e985971a@sentry.io/179825');
//enable the automatic error
$error_handler = new Raven_ErrorHandler($client);
$error_handler->registerExceptionHandler();
$error_handler->registerErrorHandler();
$error_handler->registerShutdownFunction();
//adding context
# about the current user
$client->user_context(array(
'email' => $USER->getEmail()
));
// Basic Reporting
try{
}
catch(Exception $e){
$event_id = $sentryClient->captureException($ex); //return event id capture
//or
$sentryClient->getLastEventID();
}
// Provide some additional data with an exception
$sentryClient->captureException($ex, array(
'extra' => array(
'php_version' => phpversion()
),
));
//don’t have an actual exception object? Capture a message
$sentryClient->captureMessage('my log message');
# support parameterized formatting:
$sentryClient->captureMessage('my %s message', array('log'), array(
'extra' => array(
'foo' => 'bar',
),
));
/**
Attributes
*/
array(
//Additional context for event
'extra' => array('key' => 'value'),
//grouping this event.
'fingerprint' => ['{{ default }}', 'other value'],
//level of the event: debug,info,warning,error,fatal
'level' => 'warning',
//name for the event
'logger' => 'default'
//Tags to index with this event
'tags' => array('key' => 'value'),
//user
'user' => array(
'id' => 42,
'email' => 'clever-girl'
)
);
//know when an event fails to record?
if ($sentryClient->getLastError() !== null) {
echo "Something went very, very wrong";
// $sentryClient->getLastError() contains the error that occurred
}
#https://docs.sentry.io/clients/php/usage/