Floating-Dartists / matomo-tracker

A fully cross-platform wrap of the Matomo tracking client for Flutter, using the Matomo API.
https://pub.dev/packages/matomo_tracker
MIT License
26 stars 28 forks source link

Invalid requests to self-hosted Matomo 5.0.1 #155

Closed kuhnroyal closed 4 months ago

kuhnroyal commented 5 months ago

Describe the bug I am trying to migrate from matomo_forever package which doesn't seem to be forever.

When the request is sent, the received response for the batch is a success but the individual request are invalid. I understand that the main issue is probably me doing something wrong or the instance being miss-configured.

{
    "status": "success",
    "tracked: 0,
    "invalid": 3
}

Should this case actually be an error or at least a warning log?

To Reproduce No idea

Expected behavior

{
    "status": "success",
    "tracked: 3,
    "invalid": 0
}

Smartphone (please complete the following information):

TesteurManiak commented 5 months ago

Have you tried with a simpler project to check with more basic events to see if they are handled properly? Are you using a self hosted instance of matomo? Despite the response do you have the event send displayed?

kuhnroyal commented 5 months ago

They are pretty basic, just navigation, I removed all dimensions. This is a self-hosted 5.0.1 instance, don't have access to logs atm. The events are not being displayed.

{"requests":["?idsite=14&rec=1&action_name=%2Festate%2Fdetail&url=https%3A%2F%2Fcom.example&_id=b7ca616466d6429e&rand=276822898&apiv=1&_idvc=8&_viewts=1718054103&_idts=1718027887&res=1290x2796&h=21&m=37&s=53&cookie=1&ua=iOS+17.5.1%2C+iPhone&lang=de_DE&country=DE&pv_id=YtxItI&cdt=2024-06-10T21%3A37%3A53.454787Z&token_auth=414698188cd1882e05089ceeb87a88a1"]}

This is the request.

kuhnroyal commented 5 months ago

The country=DE causes this. If I remove it, the request works in Postman.

Can't find anything about this parameter in the API docs.

TesteurManiak commented 5 months ago

It could be because the language code is not in lowercase, can you try with country=de. If it is because of that we'll have to make a quick fix on the package.

kuhnroyal commented 5 months ago

lowercase doesn't change anything, I wonder if the country parameter only works with some plugin?

kuhnroyal commented 5 months ago

This is probably related to some auth problem on the backend side, the country parameter is only allowed when token_auth is actually on. I am sending a token but it doesn't seems to matter. https://developer.matomo.org/api-reference/tracking-api#other-parameters-require-authentication-via-token_auth

TesteurManiak commented 5 months ago

Docs says that the token_auth can only be used with a super user or a user with write or admin permission.

[...] the token_auth value of the Super User, or a user with write or admin permission to the website visits are being tracked for.

Maybe it is an issue with your user configuration.

kuhnroyal commented 5 months ago

Yeah, that is very likely. Let's assume that this is a backend problem on my side.

I think the library should still handle the error in this case. Check for the success code and verify that the tracked amount is equal to the batch size. At least some logging should be provided if it doesn't match.

TesteurManiak commented 5 months ago

Yeah I think we should be able to implement such behavior 👍

Johannes-Schiel commented 4 months ago

Is there something new on this ? I have the same error on my app.

TesteurManiak commented 4 months ago

@Johannes-Schiel as said above, if your issue is related to the country query parameters, check if there's some configuration you have to do on your Matomo instance.

Johannes-Schiel commented 4 months ago

What kind of config do i have to update there ?

TesteurManiak commented 4 months ago

What kind of config do i have to update there ?

https://github.com/Floating-Dartists/matomo-tracker/issues/155#issuecomment-2162181032

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 20 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 4 months ago

This issue was closed because it has been stalled for 5 days with no activity.