mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-22 08:56:42 -06:00
Set referrer when sending visits to Matomo
This commit is contained in:
parent
316b88cea6
commit
e783bdc456
@ -47,7 +47,8 @@ class SendVisitToMatomo
|
|||||||
$tracker
|
$tracker
|
||||||
->setUrl($this->resolveUrlToTrack($visit))
|
->setUrl($this->resolveUrlToTrack($visit))
|
||||||
->setCustomTrackingParameter('type', $visit->type()->value)
|
->setCustomTrackingParameter('type', $visit->type()->value)
|
||||||
->setUserAgent($visit->userAgent());
|
->setUserAgent($visit->userAgent())
|
||||||
|
->setUrlReferrer($visit->referer());
|
||||||
|
|
||||||
$location = $visit->getVisitLocation();
|
$location = $visit->getVisitLocation();
|
||||||
if ($location !== null) {
|
if ($location !== null) {
|
||||||
|
@ -36,9 +36,12 @@ class MatomoTrackerBuilder implements MatomoTrackerBuilderInterface
|
|||||||
->setRequestMethodNonBulk('POST')
|
->setRequestMethodNonBulk('POST')
|
||||||
// Set a reasonable timeout
|
// Set a reasonable timeout
|
||||||
->setRequestTimeout(self::MATOMO_DEFAULT_TIMEOUT)
|
->setRequestTimeout(self::MATOMO_DEFAULT_TIMEOUT)
|
||||||
->setRequestConnectTimeout(self::MATOMO_DEFAULT_TIMEOUT)
|
->setRequestConnectTimeout(self::MATOMO_DEFAULT_TIMEOUT);
|
||||||
// We don't want to bulk send, as every request to Shlink will create a new tracker
|
|
||||||
->disableBulkTracking();
|
// We don't want to bulk send, as every request to Shlink will create a new tracker
|
||||||
|
$tracker->disableBulkTracking();
|
||||||
|
// Disable cookies, as they are ignored anyway
|
||||||
|
$tracker->disableCookieSupport();
|
||||||
|
|
||||||
return $tracker;
|
return $tracker;
|
||||||
}
|
}
|
||||||
|
@ -193,6 +193,11 @@ class Visit extends AbstractEntity implements JsonSerializable
|
|||||||
return $this->userAgent;
|
return $this->userAgent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function referer(): string
|
||||||
|
{
|
||||||
|
return $this->referer;
|
||||||
|
}
|
||||||
|
|
||||||
public function jsonSerialize(): array
|
public function jsonSerialize(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -71,6 +71,7 @@ class SendVisitToMatomoTest extends TestCase
|
|||||||
$tracker = $this->createMock(MatomoTracker::class);
|
$tracker = $this->createMock(MatomoTracker::class);
|
||||||
$tracker->expects($this->once())->method('setUrl')->willReturn($tracker);
|
$tracker->expects($this->once())->method('setUrl')->willReturn($tracker);
|
||||||
$tracker->expects($this->once())->method('setUserAgent')->willReturn($tracker);
|
$tracker->expects($this->once())->method('setUserAgent')->willReturn($tracker);
|
||||||
|
$tracker->expects($this->once())->method('setUrlReferrer')->willReturn($tracker);
|
||||||
$tracker->expects($this->once())->method('doTrackPageView')->with('');
|
$tracker->expects($this->once())->method('doTrackPageView')->with('');
|
||||||
|
|
||||||
if ($visit->isOrphan()) {
|
if ($visit->isOrphan()) {
|
||||||
@ -125,6 +126,7 @@ class SendVisitToMatomoTest extends TestCase
|
|||||||
$tracker = $this->createMock(MatomoTracker::class);
|
$tracker = $this->createMock(MatomoTracker::class);
|
||||||
$tracker->expects($this->once())->method('setUrl')->with($expectedTrackedUrl)->willReturn($tracker);
|
$tracker->expects($this->once())->method('setUrl')->with($expectedTrackedUrl)->willReturn($tracker);
|
||||||
$tracker->expects($this->once())->method('setUserAgent')->willReturn($tracker);
|
$tracker->expects($this->once())->method('setUserAgent')->willReturn($tracker);
|
||||||
|
$tracker->expects($this->once())->method('setUrlReferrer')->willReturn($tracker);
|
||||||
$tracker->expects($this->any())->method('setCustomTrackingParameter')->willReturn($tracker);
|
$tracker->expects($this->any())->method('setCustomTrackingParameter')->willReturn($tracker);
|
||||||
$tracker->expects($this->once())->method('doTrackPageView');
|
$tracker->expects($this->once())->method('doTrackPageView');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user