-
-
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
Conversation
@@ -89,8 +89,11 @@ 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 Additional Informations for plugins to decide, if the visit is excluded |
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.
Can you please write more description ie The request object which contains all of the request's information
@@ -89,8 +89,11 @@ 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 Additional Informations for plugins to decide, if the visit is excluded | |||
* @param bool|string $userAgent Additional Informations for plugins to decide, if the visit is excluded |
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.
The User-agent of this visit
@@ -89,8 +89,11 @@ 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 Additional Informations for plugins to decide, if the visit is excluded | |||
* @param bool|string $userAgent Additional Informations for plugins to decide, if the visit is excluded | |||
* @param bool|string $ip Additional Informations for plugins to decide, if the visit is excluded |
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.
The IP address of the visitor
Please can you issue this pull request against 3.x-dev or 2.x-dev branch? |
I changed the descriptions, but how can change the pull request do the 2.x-dev branch? |
Should be changeable if you click edit in the top right. If you can't do that, I could do that as well. |
That was easy. Thanks |
@Thomas--F you haven't changed it - can you set it to 2.x-dev ? |
*/ | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit confusing here because the $this->request
contains a method to get the userAgent and the IP as well. So can maybe someone explain (and afterwards add to documentation) when the passed userAgent and the IP is different to the one in the 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.
$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.
This is the reason, why the IP and the user agent are parameters to the constructor:
public function __construct(Request $request, $ip = false, $userAgent = false)
How can I change it to to 2.x-dev? |
I've changed the base now |
It's only a four line change. Is there anything we can do to get that last minute into 2.16.3, or is there a strict policy? |
Guess the branch need to be rebased as it now contains some commits from master, that shouldn't be in this PR |
we'll merge it for 2.16.3 |
@mattab This is excellent news |
I don't know how to rebase without a local installed git. Is it possible within the webpage? |
As far as I know you cannot change the source branch of a PR, only the target branch. And rebase of a branch on the webpage is also not possible. So if there is no way to do that locally the only way I can imagine is a new PR (were we would unfortunately loose our discussion) |
I cloned the patch-3 to a local machine: How can I now rebase it? |
|
|
Command should be |
Success! Now only one file is changed an (hopefully) all comments are there. |
* @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. |
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:
public function __construct(Request $request, $ip = false, $userAgent = false)
{
$this->spamFilter = new ReferrerSpamFilter();
if (false === $ip) {
$ip = $request->getIp();
}
if (false === $userAgent) {
$userAgent = $request->getUserAgent();
}
$this->request = $request;
$this->idSite = $request->getIdSite();
$this->userAgent = $userAgent;
$this->ip = $ip;
}
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
Actually the two extra parameter in the constructor are not needed, so i've removed them here: https://github.com/piwik/piwik/pull/10593/files therefore we only need to add the |
* Fix depraction test: use assertDeprecatedMethodIsRemovedInPiwik3 * Fix Scheduled Reports sent one hour late in daylight saving timezones (#10443) * convert hour to send report to/from UTC, to ensure it isn't affected by daylight savings * adds update script to change existing scheduled reports to use utc time * code improvement * adds missing param * Added new event Archiving.makeNewArchiverObject to allow customising plugin archiving (#10366) * added hook to alllow plugin archiving prevention * cr code style notes * reworked PR to fit CR suggestions * added PHPDoc for hook * Event description more consistent * UI tests: minor changes * Comment out Visitor Log UI tests refs #10536 * Adds test checking if all screenshots are stored in lfs * removed screenshots not stored in lfs * readds screenshots to lfs * 2.16.3-b4 * Issue translation updates against 2.x-dev * language update * Fix bug in widget list remove where the JSON object becomes array * 2.16.3-rc1 * console command custom-piwik-js:update should work when directory is writable and file does not exist yet (#10576) * followup #10449 * Fix test (cherry picked from commit fac3d63) * Prevent chmod(): No such file or directory * Automatically update all marketplace plugins when updating Piwik (#10527) * update plugins and piwik at the same time * make sure plugins are updated with piwik * use only one try/catch * reload plugin information once it has been installed * make sure to clear caches after an update * fix ui tests * make sure to use correct php version without any extras * Additional informations passed in the hook "isExcludedVisit" (issue #10415) (#10564) * Additional informations passed in the hook "isExcludedVisit" (issue #10415) * Added better description to the new parameters * Update VisitExcluded.php * Remove two parameters not needed as better to use the Request object * Update VisitExcluded.php * remove extra two parameters in VisitExcluded constructor to prevent confusion (#10593) * Update our libs to latest #10526 * Update composer libraries to latest #10526 * Update log analytics to latest * When updating the config file failed (or when any other file is not writable...), the Updater (for core or plugins) will now automatically throw an error and cancel the update (#10423) * When updating the config file failed (or when any other file is not writable...), the Updater (for core or plugins) will now automatically throw an error and cancel the update * add integration test to check the correct exception is thrown when config not writabel * New integration test for updater * Make test better * When opening the visitor profile, do not apply the segment (#10533) * When opening the visitor profile, do not apply the segment * added ui test for profile but does work for me * next try to make ui test work * add expected screenshot * added missing doc
Thank you for cleaning up the code. I will shortly use the new parameter in the BotTracker-plugin and do some tests with the log-import. |
Please issue pull request against the
2.x-dev
branch