FR90
October 10, 2019, 12:37pm
1
Hi all,
when you receive a report, the server’s name is indicated as follow
.
1/ Is it possible to hide this server’s name ? Or to force an other name ?
2/ We have an infrastructure with 4 matomo servers which use an unique matomo data base. Depending on the day, the name of the server that sends the reports may be different: one of the four servers of the infrastructure. Is it possible to force only one server to send the reports ? (sending reports is triggering by a batch command under cron, under a dedicated server)
Thx for your help
FR90
Lukas
(Lukas Winkler)
October 10, 2019, 1:53pm
2
Hi,
I know this issue (I use a seperate Matomo domain pointing to the same instance for every site) and it sounds a lot like the one described here:
opened 09:24AM - 28 Jun 19 UTC
Enhancement
Say you have multiple trusted hosts configured in Matomo:
* foo.example.com
… * bar.example.com
* analytics.example.com
They are all used for different purposes/sites. When we currently get `SettingsPiwik::getMatomoUrl()` the last used URL will be used. This will be used for example in scheduled reports. When then sending out the email, one of those URLs will be used randomly depending on which one was used last.
However, a user might want to force the usage of a specific trusted host when accessing a site and maybe wants to force the usage of a specific host in emails etc.
The same applies to Tag Manager containers which contains a preview URL when the preview mode is enabled. Depending on which URL was used last, the preview URL will use that trusted host. However, you may want to enforce loading the preview file from a specific trusted host for a specific site.
Like you want to configure:
```
idSite = 1 use foo.example.com
idSite = 3 use bar.example.com
idSite = 8 use analytics.example.com
```
something like this could be done for example in the `config.ini.php` or in `config.php` or it could be even simpler that we configure it in the `options` DB .
Basically we would need a new parameter like `SettingsPiwik::getMatomoUrl($idsite = false)` and when a specific idSite is given, then we first look if there's a matomo URL for the specific site and if not, behave as usual where we return the last used URL.
Internally this could look like: check `option_name=piwikUrl_$idSite`. If it exists, use that URL.... if it doesn't exist, check `piwikUrl`. A user could configure it by setting the correct entry in the option table. As this would be rarely used, a setting in the config might be too much.
Note: if the stored URL in `piwikUrl_$idSite (eg piwikUrl_3)` is not a trusted host, we would also fallback to `piwikUrl`.
I reckon with tests this can be done in like 4-8 hours as not too much logic needs to be changed. We would also change a few usages of `SettingsPiwik::getMatomoUrl()` to pass the `idSite` as an argument when the idSite is available.
It would be amazing if you could create a patch fixing this.