Refactor event forwarding and improve test coverage #1

Merged
mathiaspalmqvist merged 3 commits from v1.1 into main 2025-01-31 11:36:54 +00:00
2 changed files with 2 additions and 4 deletions
Showing only changes of commit 164c3ab5dd - Show all commits

No files matched your search

+1 -1
View File
@@ -26,7 +26,7 @@ Route::post('api/event', function (Request $request) {
} }
$headers = collect($request->headers->all()) $headers = collect($request->headers->all())
->mapWithKeys(fn($value, $key) => [$key => is_array($value) ? implode(', ', $value) : $value]) ->mapWithKeys(fn ($value, $key) => [$key => is_array($value) ? implode(', ', $value) : $value])
->all(); ->all();
Http::withHeaders($headers)->post(config('plausible-proxy.domain').'/api/event', $data); Http::withHeaders($headers)->post(config('plausible-proxy.domain').'/api/event', $data);
+1 -3
View File
@@ -56,11 +56,11 @@ it('accepts valid event data and forwards headers', function () {
'https://plausible.io/api/event' => function ($request) { 'https://plausible.io/api/event' => function ($request) {
dump($request->headers()); dump($request->headers());
dump($request->data()); dump($request->data());
return Http::response(['status' => 'queued'], 200); return Http::response(['status' => 'queued'], 200);
}, },
]); ]);
$headers = [ $headers = [
'User-Agent' => 'TestAgent', 'User-Agent' => 'TestAgent',
'Accept' => 'application/json', 'Accept' => 'application/json',
@@ -88,5 +88,3 @@ it('accepts valid event data and forwards headers', function () {
&& isset($request['d']) && $request['d'] === 'example.com'; && isset($request['d']) && $request['d'] === 'example.com';
}); });
}); });