-
Notifications
You must be signed in to change notification settings - Fork 18
Add tracking_token to Device request object #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -190,6 +190,9 @@ public function with(array $values): self | |
| * time since the start of the first visit. | ||
| * @param string|null $sessionId An ID that uniquely identifies a visitor's | ||
| * session on the site | ||
| * @param string|null $trackingToken The tracking token generated by the | ||
| * Device Tracking Add-on for explicit | ||
| * device linking | ||
| * | ||
| * @return MinFraud A new immutable MinFraud object. This object is a clone | ||
| * of the original with additional data. | ||
|
|
@@ -203,6 +206,7 @@ public function withDevice( | |
| ?string $ipAddress = null, | ||
| ?float $sessionAge = null, | ||
| ?string $sessionId = null, | ||
| ?string $trackingToken = null, | ||
| ?string $userAgent = null, | ||
| ): self { | ||
| if (\count($values) !== 0) { | ||
|
|
@@ -228,6 +232,7 @@ public function withDevice( | |
| $sessionId = (string) $v; | ||
| } | ||
|
|
||
| $trackingToken = $this->remove($values, 'tracking_token'); | ||
| $userAgent = $this->remove($values, 'user_agent'); | ||
|
|
||
| $this->verifyEmpty($values); | ||
|
|
@@ -261,6 +266,10 @@ public function withDevice( | |
| $values['session_id'] = $sessionId; | ||
| } | ||
|
|
||
| if ($trackingToken !== null) { | ||
| $values['tracking_token'] = $trackingToken; | ||
| } | ||
|
Comment on lines
+269
to
+271
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The if ($trackingToken !== null) {
if ($trackingToken === '' || \strlen($trackingToken) > 255) {
$this->maybeThrowInvalidInputException(
"Tracking token ($trackingToken) must be a string with length between 1 and 255",
);
}
$values['tracking_token'] = $trackingToken;
} |
||
|
|
||
| if ($userAgent !== null) { | ||
| $values['user_agent'] = $userAgent; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with other token-like fields such as
session_id, it is recommended to validate the type when extractingtracking_tokenfrom the$valuesarray and cast the result to a string. This ensures that the internal state remains consistent regardless of whether the method was called with named arguments or an associative array.