fix: send pageviews to the analytics API correctly

- 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
This commit is contained in:
mathiaspalmqvist committed 2026-11-12 09:08:27 +01:00
1 parent e3911ca12c
commit 19f632d652
11 files changed
+298 -26

No files matched your search

+2 -1
View File
@@ -45,7 +45,8 @@ it('adds env variable if .env exists and key is missing', function () {
$envContent = File::get($this->envPath);
expect($envContent)->toContain('MATTITJA_ANALYTICS_SITE_KEY=');
expect($envContent)->toContain('MATTITJA_ANALYTICS_SITE_KEY=')
->toContain('MATTITJA_ANALYTICS_INGEST_SECRET=');
File::put($this->envPath, $originalContent);
});