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
Track seconds instead of days for "days since" dimensions #15774
Conversation
core/Updates/4.0.0-b1.php
Outdated
@@ -109,6 +111,18 @@ public function getMigrations(Updater $updater) | |||
// remove old options | |||
$migrations[] = $this->migration->db->sql('DELETE FROM `' . Common::prefixTable('option') . '` WHERE option_name IN ("geoip.updater_period", "geoip.loc_db_url", "geoip.isp_db_url", "geoip.org_db_url")'); | |||
|
|||
// replace days to ... dimensions w/ segments | |||
foreach (['log_visit', 'log_conversion'] as $table) { |
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.
btw we should do this all in one query and not in multiple queries so we group all log_visit and all log_conversion update queries.
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.
one UPDATE? sure, makes sense
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.
@diosmosis are these ones actually needed? I would assume Matomo installs the columns automatically (which is also why you didn't need to add it for new installs to the mysql schema)?
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.
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.
Is this the desired approach?
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.
actually I think the dimensions end up getting added after the main update, so we wouldn't be able to initialize the new dimension values
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.
yes that's what I figured too. It's needed to add them here already. Be just good to additionally record the component version so once the DB update completed it won't try to change the type of these columns but it might not be too important since it would get the same type anyway and therefore mysql wouldn't do anything.
Test case:
|
@mattab 👍 if possible will try to make it work in that case |
@mattab it looks like if one of those dimensions is used, it is ignored and effectively removed from the list. I was hoping to be able to add the dimension back as a view on the seconds one, but it doesn't seem like it's possible to have a dimension that is a "view" of another. I also noticed w/o it, the days dimension disappears and only the seconds one is there. This seems like it would be a problem for most users since seconds is harder to use when they want days. @tsteur can you think of a way around this? Is there a way to add a dimension class w/o it being added to a table but still having an associated column so customreports can aggregate on it? |
@diosmosis Custom reports uses as unique ID the dimension id from So it could help to recreate the old dimension classes. The SQL segment in that class would be something like
you could use the same class to add back the previous segments which you are currently adding in
I think this should the trick. The |
Btw if we could deal with this in general that'd be great. For example a couple of times before we had the same issue as here: a user/customer used to have a plugin (for example Provider) and some custom reports used the dimension in that plugin (eg. Provider name) and then the plugin is deactivated and the archiving then fails/errors. The fix then is to delete custom reports in the DB that contain the dimension (which is not best user experience and requires support assistance) |
@tsteur applied review comments. There's still a failing test for the 1.5 update change. Let me know if you think that's a mistake on the tests or not. |
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 see now what the problem was re the 1.5 updates @diosmosis . I reckon we could change the update script to simply not specify the third parameter in the addColumn/addColumns
methods where it currently sets visitor_days_since_last/visitor_days_since_first
. The order shouldn't matter so we can simply remove the parameter.
Alternatively, I was thinking we could make the AddColumns
smarter to automatically add it to the end if that specified column no longer exists because the order should never really matter but shouldn't be needed and maybe there are cases where for some reason the order does matter (although I can't imagine that). So for now could just remove the third parameter in those two places.
core/Tracker/VisitorRecognizer.php
Outdated
@@ -128,14 +127,13 @@ public function findKnownVisitor($configId, VisitProperties $visitProperties, Re | |||
} | |||
} | |||
|
|||
public function removeUnchangedValues(VisitProperties $visitProperties, $visit) | |||
public function removeUnchangedValues(VisitProperties $visitProperties, $visit, VisitProperties $originalVisit = null) |
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.
seems $visitProperties
is no longer used.
core/Updates/4.0.0-b1.php
Outdated
} | ||
|
||
// remove old days_to_... columns | ||
$migrations[] = $this->migration->db->dropColumn('log_visit', 'visitor_seconds_since_first'); |
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.
should visitor_seconds_since_first
really be removed?
@@ -3364,10 +3356,7 @@ if (typeof window.Piwik !== 'object') { | |||
|
|||
var cookieValue = visitorIdCookieValues.uuid + '.' + | |||
visitorIdCookieValues.createTs + '.' + | |||
visitorIdCookieValues.visitCount + '.' + |
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.
@diosmosis just checking whether you checked regarding https://github.com/matomo-org/matomo/pull/15774/files#r423417650 because now nowTs
is in third position vs before existing cookies would have stored the visitCount there? Not sure if we need to check in getValuesFromVisitorIdCookie
whether the value looks more like a timestamp?
Also I reckon in getValuesFromVisitorIdCookie()
the array indexes 4 and 6 might not always be defined?
The currentVisitTs
seems no longer used in general?
Forgot about this, added placeholder values back in, seems like the simplest approach. |
No it's not, looks like we can simplify things even more here. Don't need the old cookie values now since they are all unused. |
@diosmosis is there much left to do in this PR? |
@tsteur this was ready for another review. I must've forgotten to ping you. |
Looks good @diosmosis |
build js |
@tsteur / @sgiehl I updated OmniFixture.sql to have a lower version so the update would run on it fully. This, strangely, causes the ip addresses displayed in the visitor log to change to |
Fix #14094