Rename package to mattitja/laravel-plausible-proxy
dependabot-auto-merge / dependabot (pull_request_target) Skipped
Fix PHP code style issues / php-code-styling (push) Successful in 6s
PHPStan / phpstan (push) Successful in 2m32s
run-tests / P8.3 - L11.* - prefer-lowest - ubuntu-latest (push) Failing after 34s
run-tests / P8.4 - L11.* - prefer-lowest - ubuntu-latest (push) Canceled after 0s
run-tests / P8.4 - L11.* - prefer-stable - ubuntu-latest (push) Canceled after 0s
run-tests / P8.3 - L12.* - prefer-lowest - ubuntu-latest (push) Canceled after 0s
run-tests / P8.3 - L12.* - prefer-stable - ubuntu-latest (push) Canceled after 0s
run-tests / P8.4 - L12.* - prefer-lowest - ubuntu-latest (push) Canceled after 0s
run-tests / P8.4 - L12.* - prefer-stable - ubuntu-latest (push) Canceled after 0s
run-tests / P8.3 - L11.* - prefer-stable - ubuntu-latest (push) Canceled after 2s

- Rename Composer package to mattitja/laravel-plausible-proxy and
  namespace to Mattitja\LaravelPlausibleProxy
- Point homepage and links to git.mattitja.se
- Forward only User-Agent and visitor IP (X-Forwarded-For) to Plausible
  instead of all request headers
- Forward all event fields and return Plausible's upstream response
- Accept props as array or JSON string
- Drop Laravel 10, upgrade Larastan to 3 and PHPStan plugins to 2
- Remove broken facade alias and dead autoload paths
- Clean up README, issue template and remove invalid FUNDING.yml
This commit is contained in:
mathiaspalmqvist committed 2026-11-12 08:24:45 +01:00
1 parent 7f8eff628f
commit a60e4cbdcf
16 files changed
+141 -112

No files matched your search

@@ -1,22 +1,21 @@
<?php
namespace MattitjaAB\LaravelPlausibleProxy\Http\Controllers;
namespace Mattitja\LaravelPlausibleProxy\Http\Controllers;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Http;
use MattitjaAB\LaravelPlausibleProxy\Http\Requests\PlausibleEventRequest;
use Mattitja\LaravelPlausibleProxy\Http\Requests\PlausibleEventRequest;
class PlausibleEventApiController
{
public function __invoke(PlausibleEventRequest $request): JsonResponse
public function __invoke(PlausibleEventRequest $request): Response
{
$headers = collect($request->headers->all())
->mapWithKeys(fn ($value, $key) => [$key => implode(', ', $value)])
->all();
$upstream = Http::withHeaders([
'User-Agent' => (string) $request->userAgent(),
'X-Forwarded-For' => (string) $request->ip(),
])->post(config('plausible-proxy.domain').'/api/event', $request->all());
Http::withHeaders($headers)
->post(config('plausible-proxy.domain').'/api/event', $request->validated());
return response()->json(['status' => 'queued']);
return response($upstream->body(), $upstream->status())
->header('Content-Type', $upstream->header('Content-Type') ?: 'text/plain');
}
}