@simivar opened this Issue on February 14th 2018 Contributor

Hello,

there's an error in Live.getLastVisitsDetails API. When you choose date by range and starting date lower than 1992-01-01 you get an error message:

{"result":"error","message":"Date format must be: YYYY-MM-DD, or 'today' or 'yesterday' or any keyword supported by the strtotime function (see http:\/\/php.net\/strtotime for more information): 662688000"}

when in fact that date is supported by strtotime function: https://3v4l.org/tmaBQ

URL to which I send a request, change [$AUTH] and [$USER_ID]:
https://aitnet.com.pl/analysis/?module=API&method=Live.getLastVisitsDetails&token_auth=[$AUTH]&idSite=4&period=range&format=json&language=en&segment=userId%3D%3D[$USER_ID]&date=1991-12-31,2018-02-14

@sgiehl commented on February 14th 2018 Member

This is expected behavior. As Matomo is meant for web analytics it doesn't really make sense to do analytics for a date before the first website was online. See https://github.com/matomo-org/matomo/blob/3.x-dev/core/Date.php#L144-L148

@simivar commented on February 14th 2018 Contributor

Well, it's not a very good feature in my opinion then. You make it harder to use an API.

It's super annoying when you want to get all visits from beggining. It's easier to set timestamp to lowest possible for strtotime function than to make another API request to get earliest date. Because of that I have to hardcode (like as you did) the timestamp of when first website was online and check from that date. Don't you think that's bad design?

Also, if you think that's good design or that's for optimization reasons could you change the error message for one that's not misguiding to not get issues like that in future?

@tsteur commented on February 14th 2018 Member

It checks up to 1991 as it is likely a user input error if date is older than that. The exception could be definitely improved for this case 👍

FYI: Updated the title

@sgiehl commented on February 27th 2018 Member

fixed in #12561

This Issue was closed on February 27th 2018
Powered by GitHub Issue Mirror