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
[Vue] two bug fixes: use correct base for site change + correct URL for launching new site #18477
Conversation
…ince angularjs code will directly forward them w/o looking at the base query string
acb9a78
to
d25cc33
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to work as expected. Now when I'm a report page and click another site in the site selector, the idSite
is updated in the query string but not in the hash, causing ,the site to be selected in the site selector, but the loaded content is from the previous site.
And when I'm on a site without data (url without hash) and open another site in a new tab (strg + click), the new url contains a hash with the idSite
only, and the request fails. I guess the reason for that is here:
matomo/plugins/CoreHome/vue/src/SiteSelector/SiteSelector.vue
Lines 359 to 373 in d25cc33
getUrlForSiteId(idSite: string|number) { | |
const newQuery = MatomoUrl.stringify({ | |
...MatomoUrl.urlParsed.value, | |
segment: '', | |
idSite, | |
}); | |
const newHash = MatomoUrl.stringify({ | |
...MatomoUrl.hashParsed.value, | |
segment: '', | |
idSite, | |
}); | |
return `?${newQuery}#?${newHash}`; | |
}, |
@sgiehl updated
can't reproduce this, the URL I get if I ctrl + click a site entity looks like |
@diosmosis I'm not able to reproduce that either with the latest changes. |
Description:
Fixes:
First: when changing the site, we can't use hash values in the new URL since some hash parameters will break Matomo if present in the main URL. To reproduce, just change a site on a report page, the hash will merge w/ the rest of the URL and the page content will not load.
Second: when launching a site in a new tab, the hash needs to contain the period/date even if it's not in the hash, since some angularjs code will only forward what is in the hash in API requests. TO reproduce, create a site w/ no visits, go to a site w/ visits, then from the site selector cmd+click the site with no visits. It will load in a new tab, but the AJAX request for siteWithoutData content will fail because no date/period was specified in it. (The root problem is in the widgetloader, not sure if this is fixed automatically in the Vue migration PR).
Given how very specific/fragile the URL handling is in different places I wonder if there's a specific API that will avoid these sorts of problems in the future...Fixed the second one also by just making sure period/date/segment are always present in the hash params.
Review