Skip to content
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

Merged
merged 10 commits into from Dec 12, 2021

Conversation

diosmosis
Copy link
Member

@diosmosis diosmosis commented Dec 9, 2021

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

@diosmosis diosmosis added the Needs Review PRs that need a code review label Dec 9, 2021
@diosmosis diosmosis added this to the 4.7.0 milestone Dec 9, 2021
@diosmosis diosmosis requested a review from sgiehl December 9, 2021 22:10
@diosmosis diosmosis force-pushed the vue-site-selector-base-url-fix branch from acb9a78 to d25cc33 Compare December 9, 2021 22:50
Copy link
Member

@sgiehl sgiehl left a 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:

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}`;
},

@diosmosis
Copy link
Member Author

@sgiehl updated

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:

can't reproduce this, the URL I get if I ctrl + click a site entity looks like http://localhost/index.php?module=CoreHome&action=index&idSite=3&period=day&date=yesterday#?period=day&date=yesterday&idSite=3&category=Dashboard_Dashboard&subcategory=1 which works. What kind of URL are you seeing? What URL did you click from?

@sgiehl
Copy link
Member

sgiehl commented Dec 10, 2021

@diosmosis I'm not able to reproduce that either with the latest changes.
Seems some JS tests are currently failing. Would be good to merge, once they are fixed.

@diosmosis diosmosis merged commit 9c83cef into 4.x-dev Dec 12, 2021
@diosmosis diosmosis deleted the vue-site-selector-base-url-fix branch December 12, 2021 18:42
@justinvelluppillai justinvelluppillai added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants