Skip to content

Commit

Permalink
Analytics HTTP_REFERER fix by ETC (#1254)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanJelicSF committed Apr 2, 2024
1 parent c7680f1 commit e6e1999
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,16 @@ public function onKernelRequest(RequestEvent $event)
if (strpos($request->getPathInfo(), self::EVENT_ENDPOINT) &&
in_array($request->getMethod(), ['POST', 'GET'])
) {
$httpReferrer = $request->server->get('HTTP_REFERER', $request->query->get('host', $request->getHost()));
$httpReferrer = $request->server->get('HTTP_REFERER', null);
if ($httpReferrer) {
$parsed_url = parse_url($httpReferrer);
$host = $parsed_url['host'];
} else {
$host = $request->query->get('host', $request->getHost());
}

$this->messageBus->dispatch(new AnalyticsEvent(
$httpReferrer,
$host,
(int) $request->query->get('articleId', null),
$request->query->get('ref', null)
));
Expand Down

0 comments on commit e6e1999

Please sign in to comment.