-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Additional informations passed in the hook "isExcludedVisit" (issue #10415) #10564
Changes from 3 commits
3ef45d8
44c8776
9878dc1
f50a1d0
d5c6e11
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 |
---|---|---|
|
@@ -89,8 +89,14 @@ public function isExcluded() | |
* @param bool &$excluded Whether the request should be excluded or not. Initialized | ||
* to `false`. Event subscribers should set it to `true` in | ||
* order to exclude the request. | ||
* @param Request $request The request object which contains all of the request's information | ||
* @param bool|string $userAgent The user-agent used by the visitor | ||
* @param bool|string $ip The IP-address of the visitor | ||
* | ||
* The additional parameters $userAgent and $ip are needed, because the values in the | ||
* object $request are empty when the constructor is called from the log-import. | ||
*/ | ||
Piwik::postEvent('Tracker.isExcludedVisit', array(&$excluded)); | ||
Piwik::postEvent('Tracker.isExcludedVisit', array(&$excluded, $this->request, $this->userAgent, $this->ip)); | ||
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. This is a bit confusing here because the 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. $this->request contains only the IP and user agent, when the hook is called during the real visit. When I use the log-import, the values are empty.
|
||
|
||
/* | ||
* Following exclude operations happen after the hook. | ||
|
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.
Sorry for being a bit annoying here. I understand they are empty when there is a log-import but I don't really understand why? Are they supposed to be ignored when doing a log-import? Do I need to treat them differently when they are set / not set? Is it ok to fallback to
$this->request
? Can I maybe instead always use the ones from$this->request
? When IP and user agent is set, are they the same ones as in$this->request
? :)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.
I don't know how the request-object is build, but look at the constructor of VisitExcluded:
You can see, that ip and user agent are taken from the given paramters when provided. So I think these values are more trustworthy than the content of the request-object.
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.
OK thank you. We had a look and noticed the userAgent is actually never passed and always the same as userAgent from the request. Also the IP seems to be always the same and the Can you remove the userAgent and IP from the postEvent as it is not needed and rather confusing?
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.
Sorry for that. We will likely clean up the code there and remove it from VisitExcluded shortly so it's more clear next time