Skip to content

Commit

Permalink
Ignore redirects in middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
zepfietje committed Jul 17, 2022
1 parent b43612b commit 8a083b5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [0.4.0] - 2022-07-17

### Changed

- Ignore redirects in middleware.

## [0.3.2] - 2022-07-17

### Fixed
Expand Down
12 changes: 10 additions & 2 deletions src/Http/Middleware/TrackPageview.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
namespace Pirsch\Http\Middleware;

use Closure;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Pirsch\Facades\Pirsch;

class TrackPageview
{
public function handle(Request $request, Closure $next): mixed
{
Pirsch::track();

return $next($request);
}

public function terminate(Request $request, mixed $response): void
{
if ($response instanceof RedirectResponse) {
return;
}

Pirsch::track();
}
}

0 comments on commit 8a083b5

Please sign in to comment.