Open tsteur opened 5 years ago
BTW, this might also help for people who use Matomo Tag Manager with multiple different hostnames. Currently whenever we load the MTM Preview Mode, it will use the piwikUrl from the database to fetch some of the resources (Logo, css files, etc)
Say you have multiple trusted hosts configured in Matomo:
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:
something like this could be done for example in the
config.ini.php
or inconfig.php
or it could be even simpler that we configure it in theoptions
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, checkpiwikUrl
. 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 topiwikUrl
.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 theidSite
as an argument when the idSite is available.