Skip to content

Commit

Permalink
Use regular middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
zepfietje committed Aug 2, 2023
1 parent 4c2433b commit 0a0eef5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [0.4.7] - 2023-08-02

### Changed

- Use regular middleware.

## [0.4.6] - 2023-04-08

### Changed
Expand Down Expand Up @@ -104,6 +110,7 @@

- TrackPageview middleware.

[0.4.7]: https://github.com/pirsch-analytics/laravel-pirsch/releases/tag/0.4.7
[0.4.6]: https://github.com/pirsch-analytics/laravel-pirsch/releases/tag/0.4.6
[0.4.5]: https://github.com/pirsch-analytics/laravel-pirsch/releases/tag/0.4.5
[0.4.4]: https://github.com/pirsch-analytics/laravel-pirsch/releases/tag/0.4.4
Expand Down
13 changes: 6 additions & 7 deletions src/Http/Middleware/TrackPageview.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,22 @@ class TrackPageview
{
public function handle(Request $request, Closure $next): mixed
{
return $next($request);
}
$response = $next($request);

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

if ($request->hasHeader('X-Livewire')) {
return;
return $response;
}

if (str_starts_with($request->route()->uri, 'telescope/')) {
return;
return $response;
}

Pirsch::track();

return $response;
}
}

0 comments on commit 0a0eef5

Please sign in to comment.