Skip to content

Commit

Permalink
Fix analytics for non-existent URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
NFarrington committed Aug 23, 2019
1 parent 78defd3 commit 79de57b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/Http/Middleware/LogRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ public function terminate(Request $request, Response $response)
{
/** @var Url $url */
$url = $request->session()->pull('short.url');
$analyticsDisabled = $url && $url->analytics_disabled;

if (!$url->analytics_disabled) {
if (!$analyticsDisabled) {
$serverData = $this->filterFillable($_SERVER);
UrlAnalytics::create([
'user_id' => Auth::check() ? Auth::user()->id : null,
'url_id' => $url->id,
'url_id' => $url ? $url->id : null,
'request_time' => $_SERVER['REQUEST_TIME'],
'http_host' => $request->root(),
'http_referer' => $request->headers->get('referer'),
Expand Down

0 comments on commit 79de57b

Please sign in to comment.