mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-12 10:01:27 +08:00
Add redirect_url field to track where a visitor is redirected for a visit
This commit is contained in:
@@ -28,6 +28,7 @@ class Visit extends AbstractEntity implements JsonSerializable
|
||||
public readonly bool $potentialBot,
|
||||
public readonly string|null $remoteAddr = null,
|
||||
public readonly string|null $visitedUrl = null,
|
||||
public readonly string|null $redirectUrl = null,
|
||||
private VisitLocation|null $visitLocation = null,
|
||||
public readonly Chronos $date = new Chronos(),
|
||||
) {
|
||||
@@ -68,6 +69,7 @@ class Visit extends AbstractEntity implements JsonSerializable
|
||||
potentialBot: $visitor->potentialBot,
|
||||
remoteAddr: self::processAddress($visitor->remoteAddress, $anonymize),
|
||||
visitedUrl: $visitor->visitedUrl,
|
||||
redirectUrl: null, // TODO
|
||||
visitLocation: $geolocation !== null ? VisitLocation::fromGeolocation($geolocation) : null,
|
||||
);
|
||||
}
|
||||
@@ -156,6 +158,7 @@ class Visit extends AbstractEntity implements JsonSerializable
|
||||
'visitLocation' => $this->visitLocation,
|
||||
'potentialBot' => $this->potentialBot,
|
||||
'visitedUrl' => $this->visitedUrl,
|
||||
'redirectUrl' => $this->redirectUrl,
|
||||
];
|
||||
if (! $this->isOrphan()) {
|
||||
return $base;
|
||||
|
||||
@@ -19,6 +19,7 @@ final readonly class Visitor
|
||||
public const REFERER_MAX_LENGTH = 1024;
|
||||
public const REMOTE_ADDRESS_MAX_LENGTH = 256;
|
||||
public const VISITED_URL_MAX_LENGTH = 2048;
|
||||
public const REDIRECT_URL_MAX_LENGTH = 2048;
|
||||
|
||||
private function __construct(
|
||||
public string $userAgent,
|
||||
@@ -27,6 +28,7 @@ final readonly class Visitor
|
||||
public string $visitedUrl,
|
||||
public bool $potentialBot,
|
||||
public Location|null $geolocation,
|
||||
public string $redirectUrl,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -36,6 +38,7 @@ final readonly class Visitor
|
||||
string|null $remoteAddress = null,
|
||||
string $visitedUrl = '',
|
||||
Location|null $geolocation = null,
|
||||
string $redirectUrl = '',
|
||||
): self {
|
||||
return new self(
|
||||
userAgent: self::cropToLength($userAgent, self::USER_AGENT_MAX_LENGTH),
|
||||
@@ -46,6 +49,7 @@ final readonly class Visitor
|
||||
visitedUrl: self::cropToLength($visitedUrl, self::VISITED_URL_MAX_LENGTH),
|
||||
potentialBot: isCrawler($userAgent),
|
||||
geolocation: $geolocation,
|
||||
redirectUrl: self::cropToLength($redirectUrl, self::REDIRECT_URL_MAX_LENGTH),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -62,6 +66,8 @@ final readonly class Visitor
|
||||
remoteAddress: ipAddressFromRequest($request),
|
||||
visitedUrl: $request->getUri()->__toString(),
|
||||
geolocation: geolocationFromRequest($request),
|
||||
// TODO
|
||||
redirectUrl: '',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -85,6 +91,7 @@ final readonly class Visitor
|
||||
// Keep the fact that the visit was a potential bot, even if we no longer save the user agent
|
||||
potentialBot: $this->potentialBot,
|
||||
geolocation: $this->geolocation,
|
||||
redirectUrl: $this->redirectUrl,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user