- Use the correct endpoint (analytics.mattitja.se instead of the non-existent .cloud domain) - Authenticate with the site ingest secret as a Bearer token so the API trusts the forwarded visitor IP and user agent - Forward the visitor Accept-Language header (required by bot detection) - Only track successful GET requests rendering HTML - Short timeouts and a file-based circuit breaker that pauses sending after connection failures or 5xx responses, so no queue, worker or cache is needed and a down API never slows the host site - Log rejected requests instead of failing silently
73 lines
2.3 KiB
PHP
73 lines
2.3 KiB
PHP
<?php
|
|
|
|
return [
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Analytics Configuration
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Configuration for sending analytics data to Mattitja Analytics API
|
|
|
|
|
*/
|
|
|
|
'site_key' => env('MATTITJA_ANALYTICS_SITE_KEY'),
|
|
|
|
// Site ingest secret (Site -> Install in Mattitja Analytics). Sent as a
|
|
// Bearer token so the API trusts the visitor IP and user agent we forward.
|
|
'ingest_secret' => env('MATTITJA_ANALYTICS_INGEST_SECRET'),
|
|
|
|
// HTTP timeouts in seconds. Sending runs after the response is sent, but
|
|
// still occupies the PHP worker, so keep these short.
|
|
'timeout' => env('MATTITJA_ANALYTICS_TIMEOUT', 1),
|
|
'connect_timeout' => env('MATTITJA_ANALYTICS_CONNECT_TIMEOUT', 0.5),
|
|
|
|
// When the API is unreachable or returns 5xx, pause sending for this many
|
|
// seconds (tracked with a file in storage/framework, no cache needed).
|
|
'pause_on_failure' => env('MATTITJA_ANALYTICS_PAUSE_ON_FAILURE', 60),
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Capture Configuration
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Configure when analytics tracking should be enabled
|
|
|
|
|
*/
|
|
|
|
'enabled' => env('MATTITJA_ANALYTICS_ENABLED', true),
|
|
'capture_bots' => env('MATTITJA_ANALYTICS_BOTS', false),
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Filtering Configuration
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Configure which requests should be ignored
|
|
|
|
|
*/
|
|
|
|
'ignore_paths' => [
|
|
'horizon',
|
|
'horizon/*',
|
|
'telescope',
|
|
'telescope/*',
|
|
'_debugbar/*',
|
|
'livewire/*',
|
|
],
|
|
|
|
'ignore_ips' => [
|
|
// Add IP addresses to ignore (e.g., your own IP for development)
|
|
],
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Privacy Configuration
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Configure privacy settings for analytics data
|
|
|
|
|
*/
|
|
|
|
'respect_dnt' => env('MATTITJA_ANALYTICS_RESPECT_DNT', true),
|
|
];
|