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

doTrackPageView() return value unclear #85

Open
NicoHood opened this issue Dec 22, 2020 · 5 comments
Open

doTrackPageView() return value unclear #85

NicoHood opened this issue Dec 22, 2020 · 5 comments

Comments

@NicoHood
Copy link

https://developer.matomo.org/api-reference/PHP-Matomo-Tracker#dotrackpageview

Returns: mixed — Response string or true if using bulk requests

To me it is not clear what the return value can be used for. It is just garbage for me and I have no option to tell if the call was successfull or not. There is no exception thrown or a good return value when the API key or site id is invalid. Any ideas how to get more feedback or clarify the docs?

@tsteur
Copy link
Member

tsteur commented Dec 22, 2020

@NicoHood Seems to be the case indeed. Feel free to add a PR to optionally throw an exception if an unexpected HTTP response code is returned. We'd be happy to merge that.

@NicoHood
Copy link
Author

Maybe it would make sense to implement #34 ?

@tsteur
Copy link
Member

tsteur commented Dec 22, 2020

@NicoHood it might. Not sure an exception would be thrown in that case (haven't checked).

@NicoHood
Copy link
Author

What is the reason behind returning the response message? Is there anything useful to it? I am not sure what would be the best option (exception vs return type). However I think it should be handled equal for bulk requests. You should know best what to do.

@tsteur
Copy link
Member

tsteur commented Dec 23, 2020

@NicoHood not sure what the reason behind it is (the project exists for a very long time). I know we can't simply start throwing exceptions by default (since it would break things for many users) but we can have an opt in for this to call a method like $tracker->throwExceptionOnError() or something and then we can change behaviour compared to usual and with a new major release eventually we can make it default (that be in a couple years or so as we only just had a major release).

I can definitely see a benefit of an exception when a request fails compared to always the same response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants