Skip to content
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

Update error message in API/UI if date is before 1992 #12559

Closed
simivar opened this issue Feb 14, 2018 · 4 comments
Closed

Update error message in API/UI if date is before 1992 #12559

simivar opened this issue Feb 14, 2018 · 4 comments
Labels
c: Usability For issues that let users achieve a defined goal more effectively or efficiently. Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Milestone

Comments

@simivar
Copy link
Contributor

simivar commented Feb 14, 2018

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
Copy link
Member

sgiehl commented Feb 14, 2018

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
Copy link
Contributor Author

simivar commented Feb 14, 2018

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
Copy link
Member

tsteur commented Feb 14, 2018

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

@tsteur tsteur added Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement. c: Usability For issues that let users achieve a defined goal more effectively or efficiently. labels Feb 14, 2018
@tsteur tsteur changed the title Live.getLastVisitsDetails API strtotime() error Update error message in API/UI if date is before 1992 Feb 14, 2018
sgiehl pushed a commit that referenced this issue Feb 26, 2018
* Update error message in API/UI if date is before 1992 (#12559)

* Fix test for dates

* Fix test for dates

* Move creation of $dateOfFirstWebsite object to if block
@sgiehl sgiehl added this to the 3.3.1 milestone Feb 27, 2018
@sgiehl
Copy link
Member

sgiehl commented Feb 27, 2018

fixed in #12561

@sgiehl sgiehl closed this as completed Feb 27, 2018
@mattab mattab added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Mar 27, 2018
InfinityVoid pushed a commit to InfinityVoid/matomo that referenced this issue Oct 11, 2018
…) (matomo-org#12561)

* Update error message in API/UI if date is before 1992 (matomo-org#12559)

* Fix test for dates

* Fix test for dates

* Move creation of $dateOfFirstWebsite object to if block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Usability For issues that let users achieve a defined goal more effectively or efficiently. Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

No branches or pull requests

4 participants