matomo-org / matomo-log-analytics

Import any kind of server logs in Matomo for powerful log analytics. Universal log file parsing and reporting.
https://matomo.org/log-analytics/
GNU General Public License v3.0
225 stars 118 forks source link

Add `--namesite` argument as alternative to `--idsite` #289

Open Prinzhorn opened 3 years ago

Prinzhorn commented 3 years ago

I assume there is an API to lookup the id by site.name or an API to achieve the same effect. If so then it would be great to add a --namesite argument, e.g. --namesite=www.example.com. I'm dumping dozens of sites into a Matomo instance (never used Matomo before) and IDs are not meant for humans. I'm waiting for the moment I import logs into the wrong site. And if I end up with multiple scripts along the way I don't want to go back and forth and check the id later once I forgot. How do others manage that?

sgiehl commented 3 years ago

In theory you can have multiple sites in Matomo tracking the same url. There is an API method SitesManager.getSitesIdFromSiteUrl which returns all IDs for a given url. That method is actually already used when you do not provide an idsite but an host is included in the logfile. The logimporter then automatically tries to find the correct sites based on the url. So guess we could implement such an option a similar way.

Prinzhorn commented 3 years ago

Oh neat. I'm not sure when I could look into this, I'll post here if I do to avoid double work. I personally would give --namesite precedence over --idsite. But if only --namesite is specified it would exit if getSitesIdFromSiteUrl returns more than one result (with a message listing all ids that were found). In this case --idsite would be required in addition and needs to be in the list returned from getSitesIdFromSiteUrl. This would make it super hard to import into the wrong site and even handle the case were you're using the same URL multiple times.

Edit: To be clear, that API you've mentioned is for the bottom list of URLs? There's probably something for just the name I assume Selection_729