1. Go to this page and download the library: Download usesorane/sorane-laravel 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/ */
usesorane / sorane-laravel example snippets
return [
'key' => env('SORANE_KEY'),
'events' => [
'enabled' => env('SORANE_EVENTS_ENABLED', true),
'queue' => env('SORANE_EVENTS_QUEUE', true),
'queue_name' => env('SORANE_EVENTS_QUEUE_NAME', 'default'),
],
'logging' => [
'enabled' => env('SORANE_LOGGING_ENABLED', false),
'queue' => env('SORANE_LOGGING_QUEUE', true),
'queue_name' => env('SORANE_LOGGING_QUEUE_NAME', 'default'),
'excluded_channels' => [
// Add channels here that should never be sent to Sorane
// Note: The handler uses 'single' channel for its own error logging to prevent loops
],
],
'website_analytics' => [
'enabled' => env('SORANE_WEBSITE_ANALYTICS_ENABLED', false),
'queue' => env('SORANE_WEBSITE_ANALYTICS_QUEUE', 'default'),
'excluded_paths' => [
'horizon',
'nova',
'telescope',
'admin',
'filament',
'api',
'debugbar',
'storage',
'livewire',
'_debugbar',
],
'request_filter' => null,
],
];
use Sorane\ErrorReporting\Facades\Sorane;
use Sorane\ErrorReporting\Events\EventTracker;
// Track a simple event (names must be snake_case)
Sorane::trackEvent('button_clicked', [
'button_id' => 'header-cta',
'page' => 'homepage'
]);
// Track an event with user ID
Sorane::trackEvent('feature_used', [
'feature_name' => 'export_data',
'export_type' => 'csv'
], $userId);
// Use predefined constants to prevent typos
Sorane::trackEvent(EventTracker::USER_REGISTERED, [
'registration_source' => 'website'
], $userId);
// ✅ Valid - uses snake_case format
Sorane::trackEvent('newsletter_signup', ['source' => 'footer']);
// ❌ Invalid - will throw InvalidArgumentException
Sorane::trackEvent('Newsletter Signup', ['source' => 'footer']);
// ✅ Use constants to avoid validation issues
use Sorane\ErrorReporting\Events\EventTracker;
Sorane::trackEvent(EventTracker::NEWSLETTER_SIGNUP, ['source' => 'footer']);
// ✅ Bypass validation if needed (advanced usage)
Sorane::trackEvent('Legacy Event Name', [], null, false);
'channels' => [
'sorane' => [
'driver' => 'sorane',
'level' => 'error', // Control which levels are sent to Sorane
],
// Recommended: Create a stack for production
'production' => [
'driver' => 'stack',
'channels' => array_merge(explode(',', env('LOG_STACK', 'single')), ['sorane']),
'ignore_exceptions' => false,
],
],
use Illuminate\Support\Facades\Log;
// These automatically go to both file and Sorane
Log::error('Database connection failed', [
'database' => 'mysql',
'error_code' => 1045,
]);
Log::critical('System overload detected', [
'cpu_usage' => '98%',
'memory_usage' => '95%',
]);
// Use specific channels when needed
Log::channel('sorane')->error('This goes only to Sorane');