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');
}
}
@@ -1,6 +1,6 @@
<?php
namespace MattitjaAB\LaravelPlausibleProxy\Http\Controllers;
namespace Mattitja\LaravelPlausibleProxy\Http\Controllers;
use Illuminate\Http\Client\RequestException;
use Illuminate\Http\Response;
+10 -2
View File
@@ -1,6 +1,6 @@
<?php
namespace MattitjaAB\LaravelPlausibleProxy\Http\Requests;
namespace Mattitja\LaravelPlausibleProxy\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
@@ -19,7 +19,15 @@ class PlausibleEventRequest extends FormRequest
'd' => ['required', 'string'],
'r' => ['nullable', 'url'],
'm' => ['nullable', 'string'],
'p' => ['nullable', 'array'],
'p' => ['nullable', function (string $attribute, mixed $value, \Closure $fail) {
if (is_array($value)) {
return;
}
if (! is_string($value) || ! is_array(json_decode($value, true))) {
$fail("The {$attribute} field must be an object or a JSON-encoded object.");
}
}],
];
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
namespace MattitjaAB\LaravelPlausibleProxy;
namespace Mattitja\LaravelPlausibleProxy;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;