8000 Shlink sends country names to Matomo instead of country codes, causing DB errors (CHAR(3) limit) and "Unknown" country · Issue #2391 · shlinkio/shlink · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Shlink sends country names to Matomo instead of country codes, causing DB errors (CHAR(3) limit) and "Unknown" country #2391

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

Closed
wuuei opened this issue Mar 13, 2025 · 3 comments · Fixed by #2392
Labels

Comments

@wuuei
Copy link
Contributor
wuuei commented Mar 13, 2025

Shlink version

4.4.5

PHP version

8.4.4

How do you serve Shlink

Docker image

Database engine

MariaDB

Database version

10.5.28

Current behavior

Shlink sends visit data to Matomo, but instead of sending a country code (e.g., "US" or "DE"), it sends the full country name (e.g., "United States" or "Germany"). Matomo expects a two- or three-letter country code, and since the database column for storing the country is defined as CHAR(3), the longer country names cause an error. As a result, Matomo sets the country to "Unknown".

Expected behavior

Shlink should send the country code instead of the full country name to ensure proper logging in Matomo. It already provides this from the geolocation.

Changing
->setCountry($location->countryName)
to
->setCountry($location->countryCode)
in the file module/Core/src/Matomo/MatomoVisitSender.php resolves this issue.
I'm not sure if this is the only necessary change or if other changes are required.

Minimum steps to reproduce

@acelaya
Copy link
Member
acelaya commented Mar 13, 2025

Thanks!

Since you already identified the source of the issue, do you want to provide a PR?

I'm not sure if this is the only necessary change or if other changes are required.

That should be the only change needed.

@wuuei
Copy link
Contributor Author
wuuei commented Mar 13, 2025

I've created a PR using the github webinterface. It's my first one, I hope it's ok.

@acelaya
Copy link
Member
acelaya commented Mar 20, 2025

I have just released Shlink 4.4.6, which includes this fix.

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

Successfully merging a pull request may close this issue.

2 participants
0