PHP code example of pstoute / jarvis-error-reporter
1. Go to this page and download the library: Download pstoute/jarvis-error-reporter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pstoute / jarvis-error-reporter example snippets
use Pstoute\JarvisErrorReporter\Facades\Jarvis;
try {
// risky operation
} catch (Exception $e) {
Jarvis::capture($e, ['operation' => 'import', 'batch_id' => $batchId]);
throw $e; // or handle it
}
// In middleware or service provider
Jarvis::setUser(auth()->id(), auth()->user()->email)
->setContext([
'tenant_id' => $tenant->id,
'subscription_tier' => $tenant->plan,
]);
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use StouteWebSolutions\JarvisErrorReporter\Facades\Jarvis;
class JarvisContext
{
public function handle(Request $request, Closure $next)
{
// Set user if authenticated
if ($user = $request->user()) {
Jarvis::setUser($user->id, $user->email, $user->name);
}
// Set tenant context for multi-tenant apps
if ($tenant = $request->tenant) {
Jarvis::setContext([
'tenant_id' => $tenant->id,
'tenant_name' => $tenant->name,
'plan' => $tenant->plan,
'subscription_status' => $tenant->subscription_status,
]);
}
// Add request-specific context
Jarvis::setContext([
'route_name' => $request->route()?->getName(),
'api_version' => $request->header('X-API-Version'),
]);
return $next($request);
}
}