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

Fix Matomo country logging by sending country code instead of country #2392

Merged
merged 4 commits into from
Mar 14, 2025

Conversation

wuuei
Copy link
Contributor

@wuuei wuuei commented Mar 13, 2025

Sending the country code is not enough, to display the country flag Matomo expects the code in lowercase. With only the code the flag in Matomo is still the question mark.
I hope it's okay to manipulate the capitalization at this location.
This fixes #2391

From the Tracking API documentation:

country — An override value for the country. Should be set to the two letter country code of the visitor (lowercase), eg fr, de, us.

… name

Matomo expects the country code in lowercase for accurate logging and proper flag display
@acelaya
Copy link
Member

acelaya commented Mar 13, 2025

Sending the country code is not enough, to display the country flag Matomo expects the code in lowercase.

Can you point to the documentation where this is explained?

EDIT: Ugh, sorry, I just realized it was a couple lines later 😅. I should have just continued reading.

Copy link
Member

@acelaya acelaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good to me. Thanks for linking to the docs where it is explained what's the expected value.

You'll probably have to apply a coding style fix (global functions need to be explicitly imported, so you'll have to add use function strtolower).

Additionally, the MatomoVisitSenderTest will probably need to be fixed. If it isn't because this case was not covered, then it would be good to add the missing test.

@wuuei
Copy link
Contributor Author

wuuei commented Mar 14, 2025

I've applied the style fix.
It looks like the unit test failed due to an update in the endroid/qr-code package. When locked to version 6.0.3, QrCodeActionTest runs fine, but versions 6.0.4 and 6.0.5 produce errors. This issue might be related: endroid/qr-code#470.
With both those changes ./indocker composer ci finishes cleanly. I've locked the version in composer.json. As the previous constraint was quite broad, this isn't a good fix. But for now maybe?

I have little experience with coding and none with tests. I looked at MatomoVisitSenderTest, but to be honest, I'm completely lost.
I'm not sure if it's relevant, but the Matomo API does accept the visit and Matomo displays it. Just without the country or flag. And there is a database error in the Matomo logs.

Copy link

codecov bot commented Mar 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.87%. Comparing base (a18360a) to head (1ceb38f).
Report is 7 commits behind head on develop.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #2392   +/-   ##
==========================================
  Coverage      93.87%   93.87%           
  Complexity      1707     1707           
==========================================
  Files            277      277           
  Lines           5915     5915           
==========================================
  Hits            5553     5553           
  Misses           362      362           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@acelaya
Copy link
Member

acelaya commented Mar 14, 2025

It looks like the unit test failed due to an update in the endroid/qr-code package. When locked to version 6.0.3, QrCodeActionTest runs fine, but versions 6.0.4 and 6.0.5 produce errors. This issue might be related: endroid/qr-code#470.

Ugh, that's unfortunate. Pinning to a fixed version is fine for now, as that's an unrelated issue. I'll try to address the actual problem afterwards.

I have little experience with coding and none with tests. I looked at MatomoVisitSenderTest, but to be honest, I'm completely lost.

That's fine, I can add the missing test. You helped a lot already.

I'm not sure if it's relevant, but the Matomo API does accept the visit and Matomo displays it. Just without the country or flag. And there is a database error in the Matomo logs.

In the dev environment, the GeoLocation is probably not working because it will be using the docker network IP address, not your public IP address.

The fact that it doesn't error out is probably good. I'll try to hardcode an actual public IP address later and see if matomo likes the result.

@acelaya
Copy link
Member

acelaya commented Mar 14, 2025

I'm not sure if it's relevant, but the Matomo API does accept the visit and Matomo displays it. Just without the country or flag. And there is a database error in the Matomo logs.

In the dev environment, the GeoLocation is probably not working because it will be using the docker network IP address, not your public IP address.

The fact that it doesn't error out is probably good. I'll try to hardcode an actual public IP address later and see if matomo likes the result.

It works 🙂. There's the Spain flag when using a public IP address from Spain.

image

@acelaya
Copy link
Member

acelaya commented Mar 14, 2025

The delete-artifacts step is failing, not sure why. I assume it might be related with some permission due to the fact that you created the PR. I'll just merge it.

@acelaya acelaya merged commit bc77750 into shlinkio:develop Mar 14, 2025
22 of 23 checks passed
@wuuei
Copy link
Contributor Author

wuuei commented Mar 14, 2025

Thanks for your guidance and patience :)

@wuuei wuuei deleted the patch-1 branch March 14, 2025 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants