Skip to content

Commit

Permalink
Ignore Telescope requests in middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
zepfietje committed Sep 6, 2022
1 parent 6afb7f2 commit e07e586
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 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.2] - 2022-09-06

### Fixed

- Ignore Telescope requests in middleware.

## [0.4.1] - 2022-08-06

### Fixed
Expand Down Expand Up @@ -74,6 +80,7 @@

- TrackPageview middleware.

[0.4.2]: https://github.com/pirsch-analytics/laravel-pirsch/releases/tag/0.4.2
[0.4.1]: https://github.com/pirsch-analytics/laravel-pirsch/releases/tag/0.4.1
[0.4.0]: https://github.com/pirsch-analytics/laravel-pirsch/releases/tag/0.4.0
[0.3.2]: https://github.com/pirsch-analytics/laravel-pirsch/releases/tag/0.3.2
Expand Down
4 changes: 4 additions & 0 deletions src/Http/Middleware/TrackPageview.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public function terminate(Request $request, mixed $response): void
return;
}

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

Pirsch::track();
}
}
4 changes: 2 additions & 2 deletions src/Pirsch.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public static function track(
'url' => request()->fullUrl(),
'ip' => request()->ip(),
'user_agent' => request()->userAgent(),
'accept_language' => request()->headers->get('Accept-Language'),
'referrer' => request()->headers->get('Referer'),
'accept_language' => request()->header('Accept-Language'),
'referrer' => request()->header('Referer'),
...$name === null
? []
: [
Expand Down

0 comments on commit e07e586

Please sign in to comment.